@open-mercato/cezar 0.9.1-pr470.729 → 0.9.1
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/README.md +9 -13
- package/dist/config.d.ts +3 -7
- package/dist/config.js +1 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-env.js +15 -21
- package/dist/core/agent-env.js.map +1 -1
- package/dist/core/agent-runner.d.ts +6 -16
- package/dist/core/agent-runner.js +3 -15
- package/dist/core/agent-runner.js.map +1 -1
- package/dist/core/backend-detect.d.ts +5 -5
- package/dist/core/backend-detect.js +5 -37
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/model-identity.js +0 -4
- package/dist/core/model-identity.js.map +1 -1
- package/dist/core/model-presets.js +0 -5
- package/dist/core/model-presets.js.map +1 -1
- package/dist/core/runner-factory.js +0 -3
- package/dist/core/runner-factory.js.map +1 -1
- package/dist/core/ui-events.d.ts +1 -1
- package/dist/runs/store.d.ts +12 -13
- package/dist/runs/store.js +2 -3
- package/dist/runs/store.js.map +1 -1
- package/dist/server/open-in-app.d.ts +1 -2
- package/dist/server/open-in-app.js +0 -1
- package/dist/server/open-in-app.js.map +1 -1
- package/dist/server/server.d.ts +0 -7
- package/dist/server/server.js +7 -102
- package/dist/server/server.js.map +1 -1
- package/dist/server-install/steps.js +2 -6
- package/dist/server-install/steps.js.map +1 -1
- package/dist/workflows/types.d.ts +14 -14
- package/dist/workflows/types.js +1 -2
- package/dist/workflows/types.js.map +1 -1
- package/dist/workspace/config.d.ts +0 -11
- package/dist/workspace/config.js +0 -13
- package/dist/workspace/config.js.map +1 -1
- package/package.json +1 -1
- package/web/dist/assets/{centered-state-Dk2G08OJ.js → centered-state-DOsTcJZF.js} +11 -11
- package/web/dist/assets/{commit-list-BKRBe1ff.js → commit-list-BrxBEzRK.js} +1 -1
- package/web/dist/assets/{compare-variants-BcWTGJrd.js → compare-variants-Bv2c9ORF.js} +1 -1
- package/web/dist/assets/{diff-view-CFQ0zXBT.js → diff-view-DCeSegKk.js} +3 -3
- package/web/dist/assets/{dist-DC3TJo3T.js → dist-B6XQOhgM.js} +1 -1
- package/web/dist/assets/{git-toolbar-CaBCbiSp.js → git-toolbar-pIC1ubPM.js} +1 -1
- package/web/dist/assets/github-DTTSG0ht.js +1 -0
- package/web/dist/assets/index-Cijmlz7q.js +30 -0
- package/web/dist/assets/index-DzroxqBG.css +2 -0
- package/web/dist/assets/{project-router-CXmL3t6s.js → project-router-BMx4e8m-.js} +1 -1
- package/web/dist/assets/{repo-git-D5N2okPE.js → repo-git-BusYfa3t.js} +1 -1
- package/web/dist/assets/{run-diff-3xRPsGI4.js → run-diff-wOJ3odA-.js} +2 -2
- package/web/dist/assets/run-header-Cg5incil.js +1 -0
- package/web/dist/assets/skills-PpP2owbM.js +1 -0
- package/web/dist/assets/{tab-link-Q8NhDqnE.js → tab-link-F3uQrdm2.js} +1 -1
- package/web/dist/assets/{task-changes-DHpP7WS3.js → task-changes-iD9kS79I.js} +1 -1
- package/web/dist/assets/{task-commits-D0IcDbGX.js → task-commits-COkLaUri.js} +1 -1
- package/web/dist/assets/{task-files-DvKQHU1f.js → task-files-Ckttz7XH.js} +2 -2
- package/web/dist/assets/task-thread-CQD91VPt.js +9 -0
- package/web/dist/assets/{use-desktop-M42tdz-1.js → use-desktop-DUh0STzq.js} +2 -2
- package/web/dist/assets/workflows-BFk8C0co.js +11 -0
- package/web/dist/index.html +5 -5
- package/dist/core/pi-runner.d.ts +0 -24
- package/dist/core/pi-runner.js +0 -342
- package/dist/core/pi-runner.js.map +0 -1
- package/dist/core/pi-ui-mapper.d.ts +0 -24
- package/dist/core/pi-ui-mapper.js +0 -255
- package/dist/core/pi-ui-mapper.js.map +0 -1
- package/dist/skills-update.d.ts +0 -88
- package/dist/skills-update.js +0 -392
- package/dist/skills-update.js.map +0 -1
- package/scripts/mock-pi-rpc.mjs +0 -83
- package/web/dist/assets/circle-check-ClxqLJCI.js +0 -1
- package/web/dist/assets/github-Dn-ZvcbO.js +0 -1
- package/web/dist/assets/index-CDk4tcLt.js +0 -30
- package/web/dist/assets/index-CwNZ1v7S.css +0 -2
- package/web/dist/assets/run-header-Bd1vyMz_.js +0 -1
- package/web/dist/assets/skills-C5b1tbwv.js +0 -1
- package/web/dist/assets/task-thread-JlVT8p1a.js +0 -9
- package/web/dist/assets/workflows-D_gHO2WW.js +0 -11
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,F as a,G as o,O as s,Ot as c,P as l,Tt as u,Z as d,a as f,bt as p,ct as m,dn as h,hn as g,i as _,k as v,ln as y,lt as b,n as x,pn as S,t as C,tt as w,ut as ee}from"./centered-state-DOsTcJZF.js";import{n as te,o as T,r as E,t as D}from"./utils-B8s5qIcK.js";import{c as ne,l as re,n as O,o as ie,r as ae,s as oe,t as se}from"./run-header-Cg5incil.js";import{n as ce,t as le}from"./trash-2-DAyZ0VSi.js";import{n as ue}from"./tab-link-F3uQrdm2.js";import{t as de}from"./git-pull-request-DnR8Xh4_.js";import{t as fe}from"./search-x-BDjaMrzG.js";import{t as pe}from"./square-terminal-Ckjjn0vb.js";import{t as me}from"./textarea-Bj_LCreg.js";import{i as k,n as A,r as j,t as he}from"./run-diff-wOJ3odA-.js";import{t as ge}from"./project-router-BMx4e8m-.js";import{B as _e,E as ve,G as ye,I as be,K as xe,Lt as M,T as Se,U as Ce,V as we,W as Te,Yt as Ee,a as De,an as N,at as Oe,cn as ke,ct as Ae,et as je,it as Me,on as Ne,ot as Pe,q as Fe,rn as Ie,sn as Le,st as Re,x as P}from"./index-Cijmlz7q.js";import{t as ze}from"./lib-DPEZDBUN.js";import{t as Be}from"./zoomable-image-PEDOqyLQ.js";var Ve=E(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),He=E(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Ue=E(`folder-input`,[[`path`,{d:`M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),We=E(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),Ge=E(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),F=E(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),I=E(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),L=n(t(),1),Ke=[`run-event`,`ui-event`];function qe(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function Je(e){let[t,n]=(0,L.useState)([]);return(0,L.useEffect)(()=>{if(n([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let r=0,i=null,a,o=!1,s=Date.now(),c,l=e=>{s=Date.now();let t=qe(e.data);!t||!(t.seq>r)||(r=t.seq,n(e=>[...e,t]))},u=()=>{s=Date.now()},d=()=>{o||a!==void 0||(a=setTimeout(()=>{a=void 0,o||f()},1500))},f=()=>{i?.close(),s=Date.now(),i=new t(T(`/api/runs/${encodeURIComponent(e)}/events`));for(let e of Ke)i.addEventListener(e,l);i.addEventListener(`ping`,u),i.addEventListener(`error`,()=>{i?.readyState===2&&d()})},p=()=>{document.visibilityState===`visible`&&(!i||i.readyState===2)&&(clearTimeout(a),a=void 0,f())},m=()=>{clearTimeout(a),a=void 0,i?.close()},h=e=>{e.persisted&&f()};return c=setInterval(()=>{o||document.visibilityState!==`visible`||Date.now()-s<=4e4||(clearTimeout(a),a=void 0,f())},1e4),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pagehide`,m),window.addEventListener(`pageshow`,h),f(),()=>{o=!0,clearTimeout(a),clearInterval(c),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pagehide`,m),window.removeEventListener(`pageshow`,h),i?.close()}},[e]),t}var R=e=>e.kind===`tool`,Ye=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Xe=(e,t,n)=>`${e} ${e===1?t:n}`;function Ze(e,t){let n=[];return e>0&&n.push(Xe(e,`file`,`files`)),t>0&&n.push(Xe(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Qe(e){return`${e} earlier tool call${e===1?``:`s`}`}var $e=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function et(e){for(let t of $e)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function tt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(R).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:Ze(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]};for(let e of i)R(e)&&Ye(e)&&!r.has(e.id)?o.push(e):(s(),R(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}));s();let c=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,l=e=>e.kind===`context-group`?e.tools.length:1,u=[],d=[],f=()=>{if(d.length>3){let e=d.slice(0,d.length-3);u.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+l(t),0),blocks:e}),u.push(...d.slice(d.length-3))}else u.push(...d);d=[]};for(let e of a)c(e)?d.push(e):(f(),u.push(e));return f(),u}var z=e(),B=new Map,nt=(0,L.createContext)(null);function rt(){return(0,L.useContext)(nt)}function it({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>B.get(e)?.get(t),set:(t,n)=>{let r=B.get(e)??new Map;r.set(t,n),B.set(e,r)}}),[e]);return(0,z.jsx)(nt.Provider,{value:n,children:t})}function V(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function at(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var ot=new Map;function st(e,t){ot.set(e,t)}function ct(e){return ot.get(e)}var lt=new Map;function ut(e,t){lt.set(e,t)}function dt(e,t){let n=lt.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}function H({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let c=t-n.length,[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(e),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(),_=()=>{f(e),g(void 0),u(!0)},v=async()=>{let t=d.trim();if(!t||t===e){u(!1);return}m(!0),g(void 0);try{await r?.(t),u(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{m(!1)}},y=async()=>{m(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{m(!1)}};return l?(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,"data-editing":`true`,className:`max-w-[78%] self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[(0,z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),u(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[13.5px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,z.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(!1),disabled:p,className:`rounded-sm px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:p,className:`rounded-sm bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:p?(0,z.jsx)(s,{className:`size-3.5 animate-spin`}):`Save`})]}),h?(0,z.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:h}):null]}):(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,className:`group max-w-[78%] min-w-0 self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[r||i?(0,z.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[r?(0,z.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:p,className:`rounded-sm p-1 text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,z.jsx)(F,{className:`size-3.5`})}):null,i?(0,z.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:p,className:`rounded-sm p-1 text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,z.jsx)(le,{className:`size-3.5`})}):null]}):null,h?(0,z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:h}):null,(0,z.jsx)(P,{breaks:!0,children:e}),n.length>0?(0,z.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:n.map(e=>(0,z.jsx)(Be,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e))}):null,c>0?(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[c,` image`,c>1?`s`:``,` attached`]}):null]})}function ft({text:e}){return(0,z.jsx)(`div`,{"data-slot":`assistant-message`,className:`min-w-0 text-[15px] leading-[1.65]`,children:(0,z.jsx)(P,{children:e})})}function U({note:e}){return(0,z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:D(`px-0.5 text-xs`,e.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function pt({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
|
+
`,1)[0]??``,r=n.length<e.length;return(0,z.jsxs)(A,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,z.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(N,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,z.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,z.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,z.jsx)(P,{inline:!0,children:n})}),r?(0,z.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,z.jsx)(k,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,z.jsx)(j,{children:(0,z.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,z.jsx)(P,{children:e})})})]})}function mt(){return(0,z.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,z.jsx)(s,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,z.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var ht={read:re,edit:F,delete:le,move:Ue,search:Ee,execute:pe,think:Ve,fetch:ne,task:Le,plan:We,other:I},gt=e=>e.split(`
|
|
3
|
+
`).length;function _t({text:e,streaming:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=gt(e),s=!t&&!n&&o>12;return(0,z.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=V(e.currentTarget)}:void 0,className:D(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,z.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,z.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,z.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function vt({diffs:e}){return(0,z.jsx)(z.Fragment,{children:e.map((e,t)=>(0,z.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,z.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...yt(e.oldText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...yt(e.newText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
|
+
`).map((e,t)=>(0,z.jsx)(bt,{text:e},t))})]},`${e.path}:${t}`))})}function yt(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
+
`)}function bt({text:e}){return(0,z.jsx)(`span`,{className:D(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function xt(e){return e.status===`failed`||e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function W({item:e,nested:t=[],cacheKey:n}){let r=rt(),[i,a]=(0,L.useState)(()=>n===void 0?null:r?.get(n)??null),o=e=>{n!==void 0&&r?.set(n,e),a(e)},c=e.status===`running`||e.status===`pending`,l=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,u=l&&(i??xt(e)),{verb:d,detail:f}=et(e.title),p=ht[e.toolKind]??I;return(0,z.jsxs)(A,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:u,onOpenChange:o,className:D(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/40`:`border-border`),children:[(0,z.jsxs)(k,{disabled:!l,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,z.jsx)(N,{"aria-hidden":!0,className:D(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!l&&`invisible`)}),(0,z.jsx)(p,{"aria-hidden":!0,className:D(`size-3.5 shrink-0`,e.status===`failed`?`text-danger`:`text-muted-foreground`)}),(0,z.jsx)(`span`,{className:D(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`failed`&&`text-danger`,e.status===`declined`&&`text-muted-foreground`),children:d}),f===void 0?null:(0,z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:f}),(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,z.jsx)(s,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,z.jsx)(`span`,{className:`text-xs text-danger`,children:`failed`}):null,e.status===`declined`?(0,z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,z.jsx)(`span`,{"data-slot":`tool-exit`,className:D(`rounded-full px-2 py-px font-mono text-[10.5px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,z.jsx)(j,{children:(0,z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.error!==void 0&&e.error!==``?(0,z.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,z.jsx)(vt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,z.jsx)(_t,{text:e.output,streaming:c}):null,t.length>0?(0,z.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:t.map(e=>(0,z.jsx)(St,{entry:e,scope:n},e.id))}):null]})})]})}function St({entry:e,scope:t}){switch(e.kind){case`message`:return(0,z.jsx)(ft,{text:e.text});case`reasoning`:return(0,z.jsx)(pt,{text:e.text});case`tool`:return(0,z.jsx)(W,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`});case`note`:return(0,z.jsx)(U,{note:e});case`image`:return(0,z.jsx)(Tt,{image:e});case`ask`:return null}}function Ct({group:e,scope:t}){return(0,z.jsxs)(A,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,z.jsxs)(k,{className:`group flex h-[34px] w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(N,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,z.jsx)(j,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,z.jsx)(W,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function wt({count:e,children:t}){return(0,z.jsxs)(A,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,z.jsxs)(k,{className:`group flex items-center gap-1.5 rounded-md p-0.5 text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(N,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Qe(e)]}),(0,z.jsx)(j,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Tt({image:e}){return(0,z.jsx)(Be,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function Et(e){let t=g(),n=oe(e).continueRun,a=i(),o=l(),s=m(n),[c,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(null),h=Ce(a.data?.checks??[]),_=e.runner??`claude`,v=Fe(c,h,_),y=v===_&&e.model?{...o.data?.defaultModels,[v]:e.model}:o.data?.defaultModels,b=ye(v,s.data,[f,y?.[v]]),x=xe(f,v,y,s.data),C=S({mutationFn:({text:t,images:n})=>u(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:c===null?void 0:v,model:f===null?void 0:x}),onSuccess:()=>t.invalidateQueries({queryKey:r.runs.all})});return{available:n,pills:(0,z.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`flex flex-wrap items-center gap-1.5`,children:[h.length>1?(0,z.jsx)(we,{runners:h,value:v,onPick:e=>{d(e),p(null)}}):null,(0,z.jsx)(_e,{slot:`follow-up-model-pill`,ariaLabel:`Model`,label:b.find(e=>e.id===x)?.label??`auto`,value:x,onPick:e=>p(e),options:b.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Te(v,s.data,s.isError)})]}),continueWith:(e,t)=>C.mutateAsync({text:e,images:t})}}var Dt=120,G=e=>e!==`pending`&&e!==`running`,Ot=e=>e.kind===`tool`&&e.toolKind===`task`,K=e=>Ot(e)&&e.parentItemId===void 0,kt=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function At(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>K(e)&&t.has(e.id)))return n;return 0}function jt(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function Mt(e){if(e.kind===`tool`)return Nt(e.title);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
|
+
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Nt(n)}}}function Nt(e){return e.length>Dt?`${e.slice(0,Dt-1).trimEnd()}…`:e}function Pt(e,t=!1){let n=zt(e,e=>e.items.some(K));if(n===-1)return[];let r=e=>!t&&!G(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(K);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(K)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?At(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!kt(n))continue;let e=n.parentItemId;if(e===void 0||!o.has(e))continue;let t=c.get(e);t?t.push(n):c.set(e,[n])}return a.map(e=>Ft(e,c.get(e.id)??[],t))}function Ft(e,t,n){let r={id:e.id,title:et(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=jt(e);i!==void 0&&(r.agentType=i),n&&!G(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Mt(t[e]);if(n!==void 0){r.activity=n;break}}return r}function It(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Lt(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function Rt(e){return e.find(e=>!G(e.status))??e[0]}function zt(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Bt(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&K(e));if(i!==void 0)return Ft(i,Vt(e,t),n)}}function Vt(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&K(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)kt(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}var Ht=new Map;function Ut(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function Wt({runId:e,agents:t,onSelect:n}){let[r,i]=(0,L.useState)(()=>Ht.get(e)??Ut());if(t.length===0)return null;let{done:a,total:o}=It(t),s=Rt(t);return(0,z.jsxs)(`section`,{"data-slot":`agents-dock`,"data-state":r?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(t=>(Ht.set(e,!t),!t)),"aria-expanded":r,className:D(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,r?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(Le,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Agents`}),(0,z.jsxs)(`span`,{"data-slot":`agents-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,a,`/`,o]}),!r&&s!==void 0?(0,z.jsxs)(`span`,{"data-slot":`agents-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,Lt(s)]}):null,(0,z.jsx)(Ne,{"aria-hidden":!0,className:D(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!r&&`rotate-180`)})]}),r?(0,z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map(e=>(0,z.jsx)(Gt,{agent:e,onSelect:n},e.id))}):null]})}function Gt({agent:e,onSelect:t}){let n=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Kt,{status:e.status,stalled:e.stalled===!0}),(0,z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Lt(e)}),(0,z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function Kt({status:e,stalled:t=!1}){return t?(0,z.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,z.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}var qt=new Map;function Jt(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function Yt(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Xt(e){return e.find(e=>e.status===`in_progress`)??e.find(e=>e.status===`pending`)}function Zt({runId:e,entries:t}){let[n,r]=(0,L.useState)(()=>qt.get(e)??Jt());if(t.length===0)return null;let{done:i,total:a}=Yt(t),o=Xt(t);return(0,z.jsxs)(`section`,{"data-slot":`plan-dock`,"data-state":n?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(t=>(qt.set(e,!t),!t)),"aria-expanded":n,className:D(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,n?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Plan`}),(0,z.jsxs)(`span`,{"data-slot":`plan-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,i,`/`,a]}),!n&&o!==void 0?(0,z.jsxs)(`span`,{"data-slot":`plan-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,o.activeForm??o.content]}):null,(0,z.jsx)(Ne,{"aria-hidden":!0,className:D(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!n&&`rotate-180`)})]}),n?(0,z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map((e,t)=>(0,z.jsx)(Qt,{entry:e},`${t}:${e.content}`))}):null]})}function Qt({entry:e}){return(0,z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:D(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,z.jsx)($t,{status:e.status}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function $t({status:e}){return e===`cancelled`?(0,z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,z.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,z.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function en({agent:e,entries:t,onClose:n}){return(0,z.jsx)(Me,{open:e!==void 0,onOpenChange:e=>{e||n()},children:(0,z.jsx)(Oe,{"data-slot":`subagent-sheet`,side:`right`,className:`w-full gap-0 p-0 sm:max-w-xl`,children:e===void 0?null:(0,z.jsx)(tn,{agent:e,entries:t})})})}function tn({agent:e,entries:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Re,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,z.jsxs)(Ae,{className:`flex min-w-0 items-center gap-2 pr-8 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType})]}),(0,z.jsxs)(Pe,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(rn,{status:e.status}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,z.jsx)(nn,{entries:t,scope:e.id})]})}function nn({entries:e,scope:t}){let n=(0,L.useRef)(null),r=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{let e=n.current;e===null||!r.current||(e.scrollTop=e.scrollHeight)},[e.reduce((e,t)=>e+(t.kind===`message`||t.kind===`reasoning`?t.text.length:t.kind===`tool`?(t.output?.length??0)+(t.error?.length??0):0),e.length)]),e.length===0?(0,z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`px-5 py-6 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`}):(0,z.jsx)(`div`,{ref:n,"data-slot":`subagent-stream`,onScroll:e=>{let t=e.currentTarget;r.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-5 py-4`,children:e.map(e=>(0,z.jsx)(St,{entry:e,scope:`subagent:${t}`},e.id))})}function rn({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:D(`rounded-full px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function an({run:e}){return(0,z.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,z.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-violet/30 bg-violet/10 px-3.5 py-2.5`,children:[(0,z.jsx)(Ie,{className:`size-4 shrink-0 text-violet`,"aria-hidden":`true`}),(0,z.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,z.jsx)(he,{runId:e.id}),(0,z.jsx)(on,{run:e})]})}function on({run:e}){let t=g(),n=(0,L.useRef)(null),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(null),l=O(e.id),d=()=>t.invalidateQueries({queryKey:r.runs.all}),m=S({mutationFn:t=>u(e.id,{text:`Review feedback:\n${t}`}),onSuccess:()=>{a(``),d()},onError:e=>_(e.message,{tone:`danger`})}),h=S({mutationFn:()=>c(e.id),onSuccess:e=>{_(`Draft PR created — ${e.url}`),d()},onError:e=>{e instanceof p&&e.manual!==void 0&&s(e.manual),_(e.message,{tone:`danger`})}}),y=()=>{let e=i.trim();if(e.length===0){_(`Write what to change first.`),n.current?.focus();return}m.mutate(e)};return(0,z.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,z.jsx)(me,{ref:n,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{ve({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},className:`min-h-[52px] text-[13px]`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(f,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:`Send the notes back into the agent's session`,disabled:m.isPending,onClick:y,children:[(0,z.jsx)(He,{"aria-hidden":`true`}),`Send back`]}),te(e.pullRequestUrl)?(0,z.jsx)(f,{asChild:!0,variant:`outline`,size:`sm`,children:(0,z.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,z.jsx)(ue,{"aria-hidden":`true`}),`PR ↗`]})}):(0,z.jsxs)(f,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:h.isPending,onClick:()=>h.mutate(),children:[(0,z.jsx)(de,{"aria-hidden":`true`}),`Draft PR`]}),(0,z.jsxs)(f,{"data-slot":`review-accept`,variant:`contrast`,size:`sm`,className:`ml-auto`,title:ae(`review`),disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,z.jsx)(v,{"aria-hidden":`true`}),`Accept`]})]}),o===null?null:(0,z.jsx)(sn,{command:o})]})}function sn({command:e}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>_(`Command copied to clipboard.`)).catch(()=>_(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(ce,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function cn(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var ln=1500;function un({status:e}){let t=(0,L.useRef)(e),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||cn())return;r(!0);let i=setTimeout(()=>r(!1),ln);return()=>clearTimeout(i)},[e]),n?(0,z.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,z.jsx)(x,{}),(0,z.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-violet/30 bg-violet/15 px-4 py-1.5 text-[13px] font-medium text-violet shadow-modal`,children:`✓ Changes accepted`})})]}):null}function dn(e,t){return`${e.header}: ${t.join(`, `)}`}function fn({ask:e,runId:t}){let n=ee(t),r=e.questions,i=r.length===1&&r[0]?.multiSelect!==!0,[a,o]=(0,L.useState)({});if(e.resolved)return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,z.jsx)(`span`,{className:`ml-1.5 whitespace-pre-line text-foreground`,children:e.answer}):null]});let s=(e,t)=>o(n=>({...n,[e]:t})),c=r.every((e,t)=>(a[t]?.length??0)>0);return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,className:`rounded-lg border border-primary/25 bg-primary/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,z.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,z.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`The agent is asking`})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,z.jsx)(pn,{question:e,disabled:n.isPending,selected:a[t]??[],onSelect:r=>{i?n.mutateAsync({text:dn(e,r)}):s(t,r)}},e.id??t))}),i?null:(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,z.jsx)(f,{size:`sm`,disabled:n.isPending||!c,onClick:()=>void n.mutateAsync({text:r.map((e,t)=>dn(e,a[t]??[])).join(`
|
|
7
|
+
`)}),children:`Send answer`}),(0,z.jsxs)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:[r.length>1?`answer each question`:`pick one or more`,` — or type a reply below`]})]})]})}function pn({question:e,disabled:t,selected:n,onSelect:r}){let i=e.multiSelect===!0,a=e=>{if(!i){r([e]);return}r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,z.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded-md bg-primary px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary-foreground`,children:e.header}),i?(0,z.jsx)(`span`,{className:`ml-auto text-[10.5px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,z.jsx)(`p`,{className:`mb-2.5 text-sm font-semibold text-foreground`,children:e.question}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map(e=>{let r=n.includes(e.label);return(0,z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>a(e.label),className:D(`flex w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-primary/50 hover:bg-primary/[0.06] disabled:pointer-events-none disabled:opacity-50`,r?`border-primary/60 bg-primary/[0.06]`:`border-border bg-card`),children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-[13.5px] font-semibold text-foreground`,children:[i?(0,z.jsx)(`span`,{"aria-hidden":!0,className:D(`flex size-4 items-center justify-center rounded border text-[10px]`,r?`border-primary bg-primary text-primary-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,e.label]}),e.description?(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description}):null]},e.label)})})]})}function mn(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(!0),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useCallback)(e=>{r(e),e&&(t.current=e.closest(`[data-slot="main"]`))},[]),d=(0,L.useCallback)(e=>{let n=t.current;if(!n)return;let r=l.current;r?r.scrollTo(e):n.scrollTop=e},[]),f=(0,L.useCallback)(()=>{let e=t.current;e&&d(e.scrollHeight-e.clientHeight)},[d]),p=(0,L.useCallback)(()=>{o.current&&f()},[f]),m=(0,L.useCallback)(()=>{let e=t.current;e&&(s.current=null,o.current=!0,e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:`smooth`}))},[]);return(0,L.useEffect)(()=>{let r=t.current,i=n;if(!r||!i)return;if(c.current!==e){c.current=e;let t=ct(e);t&&!t.atBottom?(o.current=!1,s.current=t.top,r.scrollTop=t.top):(o.current=!0,f())}let l=0,u=null,p=()=>{s.current=null,o.current=!1,l=0},m=()=>{l=Date.now()},h=e=>{e.deltaY<0?p():m()},g=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?p():[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&m()},_=()=>{V(r,80)||(p(),m())},v=e=>{u=e.touches[0]?.clientY??null},y=e=>{let t=e.touches[0]?.clientY;t!==void 0&&(u!==null&&t>u+1?p():u!==null&&t<u-1&&m(),u=t)},b=()=>{let t=V(r,80);t&&s.current===null&&(o.current||Date.now()-l<2e3)&&(o.current=!0),a(!t),s.current===null&&st(e,{top:r.scrollTop,atBottom:t})};r.addEventListener(`scroll`,b,{passive:!0}),r.addEventListener(`wheel`,h,{passive:!0}),r.addEventListener(`touchstart`,v,{passive:!0}),r.addEventListener(`touchmove`,y,{passive:!0}),r.addEventListener(`pointerdown`,_,{passive:!0}),r.addEventListener(`keydown`,g);let x;return typeof ResizeObserver<`u`&&(x=new ResizeObserver(()=>{let e=s.current;if(e!==null){let t=r.scrollHeight-r.clientHeight;d(Math.min(e,t)),t>=e&&(s.current=null)}else o.current&&f()}),x.observe(i)),()=>{r.removeEventListener(`scroll`,b),r.removeEventListener(`wheel`,h),r.removeEventListener(`touchstart`,v),r.removeEventListener(`touchmove`,y),r.removeEventListener(`pointerdown`,_),r.removeEventListener(`keydown`,g),x?.disconnect()}},[e,n,d,f]),{attachContent:u,scrollElRef:t,virtualizerRef:l,pillVisible:i,jumpToLatest:m,restickIfStuck:p}}function hn({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,z.jsx)(gn,{runId:e,rows:t,controls:r}):(0,z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,children:t.map(e=>(0,z.jsx)(`div`,{"data-slot":`thread-row`,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function gn({runId:e,rows:t,controls:n}){let r=(0,L.useRef)(null),[i]=(0,L.useState)(()=>dt(e,t.length)),a=(0,L.useRef)(t.length);a.current=t.length;let o=(0,L.useRef)(null),s=(0,L.useCallback)(t=>{n.virtualizerRef.current=t,t?o.current=t:o.current&&=(ut(e,{rows:a.current,cache:o.current.cache}),null)},[e,n.virtualizerRef]),[c,l]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||l(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,children:(0,z.jsx)(ze,{ref:s,scrollRef:n.scrollElRef,startMargin:c,...i===void 0?{}:{cache:i},children:t.map(e=>(0,z.jsx)(`div`,{"data-slot":`thread-row`,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))})})}function _n({onJump:e}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,onClick:e,className:`pointer-events-auto inline-flex min-h-8 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,z.jsx)(ke,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}var vn=120;function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e){let t=e.replace(/\s+/g,` `).trim();return t.length>vn?`${t.slice(0,vn-1)}…`:t}function Y(e,...t){if(q(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return J(t)}}function yn(e){if(!q(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return J(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return J(e.join(` `))}}function bn(e){if(!q(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)q(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function xn(e){return Y(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function X(e,t){return t?`${e} ${t}`:e}function Sn(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:X(`Ran`,yn(t)),subtitle:Y(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:X(`Edit`,Y(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:X(`Write`,Y(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:X(`Edit`,Y(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=bn(t);return{toolKind:`edit`,title:X(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:X(`Read`,Y(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:X(`View image`,Y(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:X(`Search`,Y(t,`pattern`,`query`)),subtitle:Y(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:X(`Fetch`,Y(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:X(`Web search`,Y(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=Y(t,`subagent_type`,`subagentType`),i=Y(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=Y(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:Y(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=Y(t,`server`),n=Y(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:xn(t)}}}if(n.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?J(e):`Tool`,subtitle:xn(t)}}function Cn(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function wn(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function Tn(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`string`?e:void 0}function $(e){let t=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``).replace(/\s*CEZ:ASK[ \t]+\{[\s\S]*\}\s*$/,``);return t.includes(`CEZ:`)?t.split(`
|
|
8
|
+
`).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
|
|
9
|
+
`):t}function En(e){let t=e=>$(e).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function Dn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var On=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,kn=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function An(e){if(!Z(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!Z(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:kn.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function jn(e){let t=[],n=new Map,r,i=0,a,o=()=>{i+=1;let e={id:`turn-${i}`,entries:[],v2Items:!1};return t.push(e),e},s=()=>t.at(-1)??o(),c=(e,t)=>{let n=Q(e.stepId);return n===void 0?t:`${n}:${t}`},l=(e,t,r)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&n.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=n.get(r);if(a&&a.turn===e){a.entry.entry=i,n.set(r,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),n.set(r,{turn:e,entry:o})};for(let i of e)switch(i.type){case`user-message`:{let e=Q(i.text)??``;a&&!a.resolved&&(a.resolved=!0,e!==``&&(a.answer=e),a=void 0);let t=o();t.userMessage={text:e,imageCount:typeof i.imageCount==`number`?i.imageCount:0,images:Array.isArray(i.images)?i.images.filter(e=>typeof e==`string`):[]};break}case`turn.started`:{let e=Q(i.turnId),n=t.at(-1);n&&n.turnId===void 0&&!n.v2Items?n.turnId=e:o().turnId=e;break}case`turn.completed`:{let e=Q(i.turnId),n;for(let r=t.length-1;r>=0&&!n;--r)t[r].turnId===e&&(n=t[r]);let r=n??t.at(-1);r&&(r.completed={stopReason:Q(i.stopReason)??`end_turn`,...typeof i.costUsd==`number`?{costUsd:i.costUsd}:{}});break}case`item.started`:case`item.updated`:case`item.completed`:{if(!Z(i.item))break;let e=i.item.kind,t=i.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof t!=`string`||t===``)break;let r=i.item,a=c(i,r.id);l(n.get(a)?.turn??s(),r,a);break}case`item.delta`:{let e=Q(i.itemId)??``,t=n.get(c(i,e)),r=Q(i.delta)??``;if(!t||r===``||!On(t.entry.entry))break;let a=t.entry.entry;i.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+r:i.field!==`output`&&a.kind!==`tool`&&(a.text+=r);break}case`text`:{let e=s(),t=Q(i.text)??``;if(t===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${i.seq}`,role:`assistant`,text:t}});break}case`tool-call`:{let e=s();if(e.v2Items)break;let t=Q(i.tool)??`Tool`,r=Sn(t,i.input);if(r.toolKind===`plan`){let t=An(i.input);t!==void 0&&(e.planEntries=t)}let a={kind:`tool`,id:Q(i.id)??`v1:${i.seq}`,name:t,toolKind:r.toolKind,title:r.title,status:`running`,input:i.input},o={origin:`v1`,entry:a};e.entries.push(o),n.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=n.get(Q(i.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let t=e.entry.entry;if(t.kind!==`tool`)break;t.status=`completed`,t.output=Dn(i.result);break}case`note`:case`lifecycle`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`dim`}});break}case`error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${i.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(i.status!==`failed`)break;let e=Q(i.error)?` — ${Q(i.error)}`:``;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:`step ${Q(i.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=Q(i.command)??`check`,t=typeof i.exitCode==`number`?i.exitCode:-1,n={kind:`tool`,id:`v1:${i.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:t===0?`completed`:`failed`,output:Q(i.text)??``,exitCode:t};s().entries.push({origin:`meta`,entry:n});break}case`image`:{let e=Q(i.url);if(e===void 0)break;let t={kind:`image`,id:`v1:${i.seq}`,url:e},n=Q(i.name);n!==void 0&&(t.name=n),s().entries.push({origin:`meta`,entry:t});break}case`plan.updated`:Array.isArray(i.entries)&&(s().planEntries=i.entries);break;case`session.ended`:r={reason:Q(i.reason)??`end_turn`,...Q(i.message)===void 0?{}:{message:Q(i.message)}};break;case`ask.requested`:{let e=Q(i.requestId);if(e===void 0||!Array.isArray(i.questions))break;let t=i.questions.filter(e=>Z(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(t.length===0)break;let n={kind:`ask`,id:e,questions:t,resolved:!1};s().entries.push({origin:`meta`,entry:n}),a=n;break}case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of t){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text).trim()))),En(e))}return{turns:t.map(e=>({id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:$(e.text)}:e)})),...r===void 0?{}:{sessionEnded:r}}}function Mn(){let{id:e}=h(),t=w(e),n=Je(e),r=(0,L.useMemo)(()=>jn(n),[n]);if(t.isPending)return(0,z.jsx)(De,{});if(t.isError){let e=t.error instanceof p&&t.error.status===404;return(0,z.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,z.jsx)(C,{icon:e?(0,z.jsx)(fe,{}):(0,z.jsx)(Ge,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,z.jsx)(f,{asChild:!0,variant:`outline`,children:(0,z.jsx)(ge,{to:`/`,children:`Back to tasks`})})})})}return(0,z.jsx)(Pn,{run:t.data,thread:r})}function Nn(e,t,n){let r=[];e.task&&r.push({key:`task`,node:(0,z.jsx)(H,{text:e.task,images:e.taskImages??[],onEdit:n?n.onEditTask:void 0,editLabel:`Edit the prompt`})});for(let t of e.queuedMessages??[])r.push({key:`queued:${t.id}`,node:(0,z.jsx)(H,{text:t.text,images:t.images??[],onEdit:n?e=>n.onEditMessage(t.id,e):void 0,onRemove:n?()=>n.onRemoveMessage(t.id):void 0})});for(let n of t.turns){n.userMessage&&r.push({key:`${n.id}:user`,node:(0,z.jsx)(H,{text:n.userMessage.text,imageCount:n.userMessage.imageCount,images:n.userMessage.images})});for(let t of tt(n.items))r.push({key:`${n.id}:${t.id}`,node:(0,z.jsx)(In,{block:t,scope:n.id,runId:e.id})})}return r}function Pn({run:e,thread:t}){let n=Tn(e.status,e.error),r=Cn(t),i=r!==void 0&&r.length>0?Yt(r):void 0,s=e.status===`running`||e.status===`waiting`,c=e.status===`queued`,l=Et(e),u=!s&&!c&&l.available,f=!s&&e.status!==`queued`,p=(0,L.useMemo)(()=>Pt(t.turns,f),[t.turns,f]),[m,h]=(0,L.useState)(void 0),[g,_]=(0,L.useState)(e.id);g!==e.id&&(_(e.id),h(void 0));let v=(0,L.useMemo)(()=>m===void 0?void 0:Bt(t.turns,m,f),[t.turns,m,f]),b=(0,L.useMemo)(()=>m===void 0?[]:Vt(t.turns,m),[t.turns,m]),x=ee(e.id),{mutateAsync:S}=o(e.id),{mutateAsync:C}=a(e.id),{mutateAsync:w}=d(e.id),T=(0,L.useMemo)(()=>c?{onEditTask:async e=>{await S({task:e})},onEditMessage:(e,t)=>C({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>w(e).then(()=>void 0)}:void 0,[c,S,C,w]),E=(0,L.useMemo)(()=>Nn(e,t,T),[e,t,T]),{search:ne}=y(),re=at(ne,E.length),O=mn(e.id);return be(O.restickIfStuck),(0,z.jsxs)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:[(0,z.jsx)(se,{run:e,planTally:i}),(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-1 flex-col gap-3.5 px-4 py-5 md:px-6`,children:[(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(hn,{runId:e.id,rows:E,mode:re,controls:O})}),t.turns.length===0?e.status===`queued`?(0,z.jsx)(Fn,{run:e}):(0,z.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`?(0,z.jsx)(mt,{}):null,n&&n.state===`closed`?(0,z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":n.state,className:D(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,n.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[n.label,te(je(e))?(0,z.jsx)(`a`,{"data-slot":`pr-link`,href:je(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null]}):null,e.status===`review`?(0,z.jsx)(an,{run:e}):null]}),(0,z.jsx)(un,{status:e.status}),(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(en,{agent:v,entries:b,onClose:()=>h(void 0)})}),(0,z.jsxs)(`div`,{"data-slot":`thread-dock`,className:`sticky bottom-[var(--kb,0px)] z-10 bg-background px-4 pt-1.5 pb-3 max-md:border-t max-md:border-border md:px-6 md:pb-4`,children:[O.pillVisible?(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 -top-12 flex justify-center`,children:(0,z.jsx)(_n,{onJump:O.jumpToLatest})}):null,(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-col gap-2.5`,children:[(0,z.jsx)(Wt,{runId:e.id,agents:p,onSelect:h},`agents:${e.id}`),r!==void 0&&r.length>0?(0,z.jsx)(Zt,{runId:e.id,entries:r},e.id):null,e.status===`waiting`?(0,z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(M,{tone:`pending`,pulse:!0}),`The agent is paused, waiting for your reply`]}):null,c?(0,z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(M,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,(0,z.jsx)(Se,{onSubmit:u?(e,t)=>l.continueWith(e,t):(e,t)=>x.mutateAsync({text:e,images:t}),disabled:!s&&!c&&!u,disabledReason:`Session closed — no session to resume.`,footerEnd:u?l.pills:void 0,allowEmptySubmit:u,sendAriaLabel:u?`Continue`:`Send`,placeholder:c?`Add to the prompt — sent when the run starts…`:u?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`,autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>wn(t)})]})]})]})}function Fn({run:e}){let t=ie(b().data??[],e.id);return(0,z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,z.jsx)(M,{tone:`pending`,pulse:!0}),(0,z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}function In({block:e,scope:t,runId:n}){switch(e.kind){case`entry`:return(0,z.jsx)(Ln,{entry:e.entry,scope:t,runId:n});case`tool-card`:return(0,z.jsx)(W,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`});case`context-group`:return(0,z.jsx)(Ct,{group:e,scope:t});case`streak`:return(0,z.jsx)(wt,{count:e.count,children:e.blocks.map(e=>(0,z.jsx)(In,{block:e,scope:t,runId:n},e.id))})}}function Ln({entry:e,scope:t,runId:n}){switch(e.kind){case`message`:return e.role===`assistant`?(0,z.jsx)(ft,{text:e.text}):(0,z.jsx)(H,{text:e.text});case`reasoning`:return(0,z.jsx)(pt,{text:e.text});case`tool`:return(0,z.jsx)(W,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return(0,z.jsx)(U,{note:e});case`image`:return(0,z.jsx)(Tt,{image:e});case`ask`:return(0,z.jsx)(fn,{ask:e,runId:n})}}export{Mn as TaskThreadRoute};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-
|
|
2
|
-
import{a as e,i as t,s as n,u as r}from"./bundle-mjs-BegPhL5c.js";import{a as i}from"./centered-state-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-DCeSegKk.js","assets/bundle-mjs-BegPhL5c.js","assets/utils-B8s5qIcK.js","assets/index-Cijmlz7q.js","assets/centered-state-DOsTcJZF.js","assets/search-x-BDjaMrzG.js","assets/triangle-alert-Uy8rokUh.js","assets/textarea-Bj_LCreg.js","assets/dist-B6XQOhgM.js","assets/project-router-BMx4e8m-.js","assets/chunk-BO2N2NFS-DtrdTCWa.js","assets/lib-uHpeUPzK.js","assets/index-DzroxqBG.css","assets/lib-DPEZDBUN.js","assets/image-preview-DEhW0TFz.js","assets/zoomable-image-PEDOqyLQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,s as n,u as r}from"./bundle-mjs-BegPhL5c.js";import{a as i}from"./centered-state-DOsTcJZF.js";import{r as a,t as o}from"./utils-B8s5qIcK.js";import{rt as s,tn as c}from"./index-Cijmlz7q.js";import{n as l,t as u}from"./image-preview-DEhW0TFz.js";var d=a(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),f=a(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),p=e();function m({mode:e,wrap:t,onModeChange:n,onWrapChange:r}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`span`,{"data-slot":`diff-mode-toggle`,role:`group`,"aria-label":`Diff layout`,className:`flex items-center rounded-md border border-border p-0.5`,children:[(0,p.jsx)(h,{current:e,value:`unified`,onModeChange:n}),(0,p.jsx)(h,{current:e,value:`split`,onModeChange:n})]}),(0,p.jsx)(i,{variant:`ghost`,size:`icon-sm`,"data-slot":`wrap-toggle`,"aria-pressed":t,"aria-label":`Wrap long lines`,title:`Wrap long lines`,className:o(t&&`bg-muted text-foreground`),onClick:()=>r(!t),children:(0,p.jsx)(f,{"aria-hidden":`true`})})]})}function h({current:e,value:t,onModeChange:n}){let r=e===t;return(0,p.jsx)(`button`,{type:`button`,"data-mode":t,"aria-pressed":r,onClick:()=>n(t),className:o(`rounded-[5px] px-2 py-0.5 text-[11px] font-medium capitalize`,r?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:t})}function g({branch:e}){return(0,p.jsxs)(`span`,{"data-slot":`branch-chip`,className:`flex min-w-0 items-center gap-1 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium`,children:[(0,p.jsx)(c,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,p.jsx)(`span`,{className:`truncate`,children:e})]})}var _=r(n(),1);function v(e){let[n,r]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let e=!1;return t(()=>import(`./diff-view-DCeSegKk.js`).then(t=>{e||r({View:t.DiffView})},()=>{e||r(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),()=>{e=!0}},[]),e.files.length===0?(0,p.jsx)(`p`,{"data-slot":`diff-empty`,className:o(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):n===`failed`?(0,p.jsx)(y,{...e}):n===null?(0,p.jsx)(`p`,{"data-slot":`diff-loading`,className:o(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,p.jsx)(n.View,{...e})}function y({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:r,viewRef:i,className:a}){let c={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},l=(0,_.useRef)(null);return(0,_.useImperativeHandle)(i,()=>({scrollToPath:e=>{for(let t of l.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,p.jsxs)(`div`,{ref:l,"data-slot":`diff`,"data-fallback":`true`,className:o(`flex min-w-0 flex-col gap-3`,a),children:[(0,p.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,p.jsxs)(`span`,{children:[c.files,` `,c.files===1?`file`:`files`,` changed`]}),(0,p.jsx)(s,{stat:c})]}),e.map(e=>(0,p.jsx)(b,{file:e,wrap:t,imageSrc:n,onOpenInApp:r},`${e.oldPath??``}→${e.path}`))]})}function b({file:e,wrap:t,imageSrc:n,onOpenInApp:r}){return(0,p.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,p.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,p.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,p.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,p.jsx)(s,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),l(e)?(0,p.jsx)(u,{file:e,imageSrc:n,onOpenInApp:r}):e.binary?(0,p.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,p.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,p.jsx)(`pre`,{className:o(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
|
|
3
3
|
`).map((e,t)=>(0,p.jsxs)(`span`,{className:o(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}function x(){let[e,t]=(0,_.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches);return(0,_.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(min-width: 768px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}export{d as a,m as i,v as n,g as r,x as t};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as e,o as t,s as n,u as r}from"./bundle-mjs-BegPhL5c.js";import{A as i,Bt as a,Ut as o,a as s,bt as c,dn as l,dt as u,hn as d,ht as f,i as p,jt as m,k as h,kt as g,pn as _,pt as v,t as y}from"./centered-state-DOsTcJZF.js";import{r as b,t as x}from"./utils-B8s5qIcK.js";import{n as S,t as C}from"./trash-2-DAyZ0VSi.js";import{n as w,r as ee}from"./skill-empty-hint-DTUSp6Vl.js";import{t as te}from"./square-terminal-Ckjjn0vb.js";import{t as T}from"./triangle-alert-Uy8rokUh.js";import{t as ne}from"./upload-CDdyPPo_.js";import{n as E,t as re}from"./textarea-Bj_LCreg.js";import{Jt as ie,St as ae,Zt as D,_ as oe,bt as se,c as O,cn as ce,d as le,en as ue,f as k,g as de,h as A,m as fe,p as j,u as pe,zt as M}from"./index-Cijmlz7q.js";var me=b(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),N=r(t()),P=r(n());function he(){var e=[...arguments];return(0,P.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var F=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function I(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function L(e){return`nodeType`in e}function R(e){return e?I(e)?e:L(e)?e.ownerDocument?.defaultView??window:window:window}function z(e){let{Document:t}=R(e);return e instanceof t}function ge(e){return!I(e)&&e instanceof R(e).HTMLElement}function _e(e){return e instanceof R(e).SVGElement}function B(e){return e?I(e)?e.document:L(e)?z(e)?e:ge(e)||_e(e)?e.ownerDocument:document:document:document}var V=F?P.useLayoutEffect:P.useEffect;function ve(e){let t=(0,P.useRef)(e);return V(()=>{t.current=e}),(0,P.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function ye(){let e=(0,P.useRef)(null);return[(0,P.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,P.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function be(e,t){t===void 0&&(t=[e]);let n=(0,P.useRef)(e);return V(()=>{n.current!==e&&(n.current=e)},t),n}function H(e,t){let n=(0,P.useRef)();return(0,P.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function U(e){let t=ve(e),n=(0,P.useRef)(null);return[n,(0,P.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function xe(e){let t=(0,P.useRef)();return(0,P.useEffect)(()=>{t.current=e},[e]),t.current}var W={};function Se(e,t){return(0,P.useMemo)(()=>{if(t)return t;let n=W[e]==null?0:W[e]+1;return W[e]=n,e+`-`+n},[e,t])}function Ce(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var we=Ce(1),Te=Ce(-1);function Ee(e){return`clientX`in e&&`clientY`in e}function G(e){if(!e)return!1;let{KeyboardEvent:t}=R(e.target);return t&&e instanceof t}function De(e){if(!e)return!1;let{TouchEvent:t}=R(e.target);return t&&e instanceof t}function Oe(e){if(De(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ee(e)?{x:e.clientX,y:e.clientY}:null}var K=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[K.Translate.toString(e),K.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),ke=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Ae(e){return e.matches(ke)?e:e.querySelector(ke)}var je={display:`none`};function Me(e){let{id:t,value:n}=e;return P.createElement(`div`,{id:t,style:je},n)}function Ne(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return P.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Pe(){let[e,t]=(0,P.useState)(``);return{announce:(0,P.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Fe=(0,P.createContext)(null);function Ie(e){let t=(0,P.useContext)(Fe);(0,P.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Le(){let[e]=(0,P.useState)(()=>new Set),t=(0,P.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,P.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Re={draggable:`
|
|
2
|
+
To pick up a draggable item, press the space bar.
|
|
3
|
+
While dragging, use the arrow keys to move the item.
|
|
4
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
+
`},ze={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Be(e){let{announcements:t=ze,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Re}=e,{announce:a,announcement:o}=Pe(),s=Se(`DndLiveRegion`),[c,l]=(0,P.useState)(!1);if((0,P.useEffect)(()=>{l(!0)},[]),Ie((0,P.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=P.createElement(P.Fragment,null,P.createElement(Me,{id:r,value:i.draggable}),P.createElement(Ne,{id:s,announcement:o}));return n?(0,N.createPortal)(u,n):u}var q;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(q||={});function Ve(){}function He(e,t){return(0,P.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Ue(){var e=[...arguments];return(0,P.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var J=Object.freeze({x:0,y:0});function We(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Ge(e,t){let n=Oe(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function Ke(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function qe(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Je(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function Ye(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Xe(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Ze=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Xe(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=We(Xe(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Ke)},Qe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Je(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Je(r),o=i.reduce((e,t,r)=>e+We(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(Ke)};function $e(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var et=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=$e(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(qe)};function tt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function nt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:J}function rt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var it=rt(1);function at(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ot(e,t,n){let r=at(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var st={ignoreTransform:!1};function ct(e,t){t===void 0&&(t=st);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=R(e).getComputedStyle(e);t&&(n=ot(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function lt(e){return ct(e,{ignoreTransform:!0})}function ut(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function dt(e,t){return t===void 0&&(t=R(e).getComputedStyle(e)),t.position===`fixed`}function ft(e,t){t===void 0&&(t=R(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function pt(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(z(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ge(i)||_e(i)||n.includes(i))return n;let a=R(e).getComputedStyle(i);return i!==e&&ft(i,a)&&n.push(i),dt(i,a)?n:r(i.parentNode)}return e?r(e):n}function mt(e){let[t]=pt(e,1);return t??null}function ht(e){return!F||!e?null:I(e)?e:L(e)?z(e)||e===B(e).scrollingElement?window:ge(e)?e:null:null}function gt(e){return I(e)?e.scrollX:e.scrollLeft}function _t(e){return I(e)?e.scrollY:e.scrollTop}function vt(e){return{x:gt(e),y:_t(e)}}var Y;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Y||={});function yt(e){return!F||!e?!1:e===document.scrollingElement}function bt(e){let t={x:0,y:0},n=yt(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var xt={x:.2,y:.2};function St(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=xt);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=bt(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Y.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Y.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Y.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Y.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Ct(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function wt(e){return e.reduce((e,t)=>we(e,vt(t)),J)}function Tt(e){return e.reduce((e,t)=>e+gt(t),0)}function Et(e){return e.reduce((e,t)=>e+_t(t),0)}function Dt(e,t){if(t===void 0&&(t=ct),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);mt(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Ot=[[`x`,[`left`,`right`],Tt],[`y`,[`top`,`bottom`],Et]],kt=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=pt(t),r=wt(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Ot)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},At=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function jt(e){let{EventTarget:t}=R(e);return e instanceof t?e:B(e)}function Mt(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var X;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(X||={});function Nt(e){e.preventDefault()}function Pt(e){e.stopPropagation()}var Z;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Z||={});var Ft={start:[Z.Space,Z.Enter],cancel:[Z.Esc],end:[Z.Space,Z.Enter,Z.Tab]},It=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Z.Right:return{...n,x:n.x+25};case Z.Left:return{...n,x:n.x-25};case Z.Down:return{...n,y:n.y+25};case Z.Up:return{...n,y:n.y-25}}},Lt=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new At(B(t)),this.windowListeners=new At(R(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(X.Resize,this.handleCancel),this.windowListeners.add(X.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(X.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Dt(n),t(J)}handleKeyDown(e){if(G(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Ft,coordinateGetter:a=It,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:J;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Te(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=bt(n),p=Ct(n),m={x:Math.min(i===Z.Right?p.right-p.width/2:p.right,Math.max(i===Z.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Z.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Z.Down?p.top:p.top+p.height/2,u.y))},h=i===Z.Right&&!s||i===Z.Left&&!c,g=i===Z.Down&&!l||i===Z.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Z.Right&&e<=d.x||i===Z.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Z.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Z.Down&&e<=d.y||i===Z.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Z.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,we(Te(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Lt.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Ft,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Rt(e){return!!(e&&`distance`in e)}function zt(e){return!!(e&&`delay`in e)}var Bt=class{constructor(e,t,n){n===void 0&&(n=jt(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=B(i),this.documentListeners=new At(this.document),this.listeners=new At(n),this.windowListeners=new At(R(i)),this.initialCoordinates=Oe(r)??J,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(X.Resize,this.handleCancel),this.windowListeners.add(X.DragStart,Nt),this.windowListeners.add(X.VisibilityChange,this.handleCancel),this.windowListeners.add(X.ContextMenu,Nt),this.documentListeners.add(X.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(zt(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Rt(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(X.Click,Pt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(X.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Oe(e)??J,s=Te(n,o);if(!t&&a){if(Rt(a)){if(a.tolerance!=null&&Mt(s,a.tolerance))return this.handleCancel();if(Mt(s,a.distance))return this.handleStart()}if(zt(a)&&Mt(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Z.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Vt={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Ht=class extends Bt{constructor(e){let{event:t}=e,n=B(t.target);super(e,Vt,n)}};Ht.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Ut={move:{name:`mousemove`},end:{name:`mouseup`}},Wt;(function(e){e[e.RightClick=2]=`RightClick`})(Wt||={});var Gt=class extends Bt{constructor(e){super(e,Ut,B(e.event.target))}};Gt.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Wt.RightClick?!1:(r?.({event:n}),!0)}}];var Kt={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},qt=class extends Bt{constructor(e){super(e,Kt)}static setup(){return window.addEventListener(Kt.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Kt.move.name,e)};function e(){}}};qt.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Jt;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Jt||={});var Yt;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Yt||={});function Xt(e){let{acceleration:t,activator:n=Jt.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Yt.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Qt({delta:d,disabled:!a}),[m,h]=ye(),g=(0,P.useRef)({x:0,y:0}),_=(0,P.useRef)({x:0,y:0}),v=(0,P.useMemo)(()=>{switch(n){case Jt.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Jt.DraggableRect:return i}},[n,i,c]),y=(0,P.useRef)(null),b=(0,P.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,P.useMemo)(()=>s===Yt.TreeOrder?[...l].reverse():l,[s,l]);(0,P.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=St(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Zt={x:{[Y.Backward]:!1,[Y.Forward]:!1},y:{[Y.Backward]:!1,[Y.Forward]:!1}};function Qt(e){let{delta:t,disabled:n}=e,r=xe(t);return H(e=>{if(n||!r||!e)return Zt;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Y.Backward]:e.x[Y.Backward]||i.x===-1,[Y.Forward]:e.x[Y.Forward]||i.x===1},y:{[Y.Backward]:e.y[Y.Backward]||i.y===-1,[Y.Forward]:e.y[Y.Forward]||i.y===1}}},[n,t,r])}function $t(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return H(e=>t==null?null:r??e??null,[r,t])}function en(e,t){return(0,P.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var tn;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(tn||={});var nn;(function(e){e.Optimized=`optimized`})(nn||={});var rn=new Map;function an(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,P.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,P.useRef)(e),d=g(),f=be(d),p=(0,P.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,P.useRef)(null),h=H(t=>{if(d&&!n)return rn;if(!t||t===rn||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new kt(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,P.useEffect)(()=>{u.current=e},[e]),(0,P.useEffect)(()=>{d||p()},[n,d]),(0,P.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,P.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case tn.Always:return!1;case tn.BeforeDragging:return n;default:return!n}}}function on(e,t){return H(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function sn(e,t){return on(e,t)}function cn(e){let{callback:t,disabled:n}=e,r=ve(t),i=(0,P.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,P.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ln(e){let{callback:t,disabled:n}=e,r=ve(t),i=(0,P.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,P.useEffect)(()=>()=>i?.disconnect(),[i]),i}function un(e){return new kt(ct(e),e)}function dn(e,t,n){t===void 0&&(t=un);let[r,i]=(0,P.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=cn({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=ln({callback:a});return V(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function fn(e){return nt(e,on(e))}var pn=[];function mn(e){let t=(0,P.useRef)(e),n=H(n=>e?n&&n!==pn&&e&&t.current&&e.parentNode===t.current.parentNode?n:pt(e):pn,[e]);return(0,P.useEffect)(()=>{t.current=e},[e]),n}function hn(e){let[t,n]=(0,P.useState)(null),r=(0,P.useRef)(e),i=(0,P.useCallback)(e=>{let t=ht(e.target);t&&n(e=>e?(e.set(t,vt(t)),new Map(e)):null)},[]);return(0,P.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=ht(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,vt(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{ht(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,P.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>we(e,t),J):wt(e):J,[e,t])}function gn(e,t){t===void 0&&(t=[]);let n=(0,P.useRef)(null);return(0,P.useEffect)(()=>{n.current=null},t),(0,P.useEffect)(()=>{let t=e!==J;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Te(e,n.current):J}function _n(e){(0,P.useEffect)(()=>{if(!F)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function vn(e,t){return(0,P.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function yn(e){return(0,P.useMemo)(()=>e?ut(e):null,[e])}var bn=[];function xn(e,t){t===void 0&&(t=ct);let[n]=e,r=yn(n?R(n):null),[i,a]=(0,P.useState)(bn);function o(){a(()=>e.length?e.map(e=>yt(e)?r:new kt(t(e),e)):bn)}let s=ln({callback:o});return V(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Sn(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return ge(t)?t:e}function Cn(e){let{measure:t}=e,[n,r]=(0,P.useState)(null),i=ln({callback:(0,P.useCallback)(e=>{for(let{target:n}of e)if(ge(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=U((0,P.useCallback)(e=>{let n=Sn(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,P.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var wn=[{sensor:Ht,options:{}},{sensor:Lt,options:{}}],Tn={current:{}},En={draggable:{measure:lt},droppable:{measure:lt,strategy:tn.WhileDragging,frequency:nn.Optimized},dragOverlay:{measure:ct}},Dn=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},On={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Dn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ve},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:En,measureDroppableContainers:Ve,windowRect:null,measuringScheduled:!1},kn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Ve,draggableNodes:new Map,over:null,measureDroppableContainers:Ve},An=(0,P.createContext)(kn),jn=(0,P.createContext)(On);function Mn(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Dn}}}function Nn(e,t){switch(t.type){case q.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case q.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case q.DragEnd:case q.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case q.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Dn(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case q.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Dn(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case q.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Dn(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Pn(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,P.useContext)(An),a=xe(r),o=xe(n?.id);return(0,P.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!G(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Ae(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Fn(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function In(e){return(0,P.useMemo)(()=>({draggable:{...En.draggable,...e?.draggable},droppable:{...En.droppable,...e?.droppable},dragOverlay:{...En.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ln(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,P.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;V(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=nt(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=mt(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Rn=(0,P.createContext)({...J,scaleX:1,scaleY:1}),zn;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(zn||={});var Bn=(0,P.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=wn,collisionDetection:o=et,measuring:s,modifiers:c,...l}=e,[u,d]=(0,P.useReducer)(Nn,void 0,Mn),[f,p]=Le(),[m,h]=(0,P.useState)(zn.Uninitialized),g=m===zn.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,P.useRef)({initial:null,translated:null}),C=(0,P.useMemo)(()=>_==null?null:{id:_,data:x?.data??Tn,rect:S},[_,x]),w=(0,P.useRef)(null),[ee,te]=(0,P.useState)(null),[T,ne]=(0,P.useState)(null),E=be(l,Object.values(l)),re=Se(`DndDescribedBy`,t),ie=(0,P.useMemo)(()=>b.getEnabled(),[b]),ae=In(s),{droppableRects:D,measureDroppableContainers:oe,measuringScheduled:se}=an(ie,{dragging:g,dependencies:[y.x,y.y],config:ae.droppable}),O=$t(v,_),ce=(0,P.useMemo)(()=>T?Oe(T):null,[T]),le=Ae(),ue=sn(O,ae.draggable.measure);Ln({activeNode:_==null?null:v.get(_),config:le.layoutShiftCompensation,initialRect:ue,measure:ae.draggable.measure});let k=dn(O,ae.draggable.measure,ue),de=dn(O?O.parentElement:null),A=(0,P.useRef)({activatorEvent:null,active:null,activeNode:O,collisionRect:null,collisions:null,droppableRects:D,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fe=b.getNodeFor(A.current.over?.id),j=Cn({measure:ae.dragOverlay.measure}),pe=j.nodeRef.current??O,M=g?j.rect??k:null,me=!!(j.nodeRef.current&&j.rect),he=fn(me?null:k),F=yn(pe?R(pe):null),I=mn(g?fe??O:null),L=xn(I),z=Fn(c,{transform:{x:y.x-he.x,y:y.y-he.y,scaleX:1,scaleY:1},activatorEvent:T,active:C,activeNodeRect:k,containerNodeRect:de,draggingNodeRect:M,over:A.current.over,overlayNodeRect:j.rect,scrollableAncestors:I,scrollableAncestorRects:L,windowRect:F}),ge=ce?we(ce,y):null,_e=hn(I),B=gn(_e),ve=gn(_e,[k]),ye=we(z,B),H=M?it(M,z):null,U=C&&H?o({active:C,collisionRect:H,droppableRects:D,droppableContainers:ie,pointerCoordinates:ge}):null,xe=Ye(U,`id`),[W,Ce]=(0,P.useState)(null),Te=tt(me?z:we(z,ve),W?.rect??null,k),Ee=(0,P.useRef)(null),G=(0,P.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:A,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=E.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=E.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=E.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,N.unstable_batchedUpdates)(()=>{r?.(i),h(zn.Initializing),d({type:q.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),te(Ee.current),ne(a)})},onMove(e){d({type:q.DragMove,coordinates:e})},onEnd:s(q.DragEnd),onCancel:s(q.DragCancel)});Ee.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=A.current,o=null;if(t&&i){let{cancelDrop:s}=E.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===q.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=q.DragCancel)}w.current=null,(0,N.unstable_batchedUpdates)(()=>{d({type:e}),h(zn.Uninitialized),Ce(null),te(null),ne(null),Ee.current=null;let t=e===q.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=E.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),De=en(a,(0,P.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,G(n,t))},[v,G]));_n(a),V(()=>{k&&m===zn.Initializing&&h(zn.Initialized)},[k,m]),(0,P.useEffect)(()=>{let{onDragMove:e}=E.current,{active:t,activatorEvent:n,collisions:r,over:i}=A.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ye.x,y:ye.y},over:i};(0,N.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ye.x,ye.y]),(0,P.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=A.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=E.current,o=r.get(xe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,N.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),V(()=>{A.current={activatorEvent:T,active:C,activeNode:O,collisionRect:H,collisions:U,droppableRects:D,draggableNodes:v,draggingNode:pe,draggingNodeRect:M,droppableContainers:b,over:W,scrollableAncestors:I,scrollAdjustedTranslate:ye},S.current={initial:M,translated:H}},[C,O,U,H,v,pe,M,D,b,W,I,ye]),Xt({...le,delta:y,draggingRect:H,pointerCoordinates:ge,scrollableAncestors:I,scrollableAncestorRects:L});let K=(0,P.useMemo)(()=>({active:C,activeNode:O,activeNodeRect:k,activatorEvent:T,collisions:U,containerNodeRect:de,dragOverlay:j,draggableNodes:v,droppableContainers:b,droppableRects:D,over:W,measureDroppableContainers:oe,scrollableAncestors:I,scrollableAncestorRects:L,measuringConfiguration:ae,measuringScheduled:se,windowRect:F}),[C,O,k,T,U,de,j,v,b,D,W,oe,I,L,ae,se,F]),ke=(0,P.useMemo)(()=>({activatorEvent:T,activators:De,active:C,activeNodeRect:k,ariaDescribedById:{draggable:re},dispatch:d,draggableNodes:v,over:W,measureDroppableContainers:oe}),[T,De,C,k,d,re,v,W,oe]);return P.createElement(Fe.Provider,{value:p},P.createElement(An.Provider,{value:ke},P.createElement(jn.Provider,{value:K},P.createElement(Rn.Provider,{value:Te},i)),P.createElement(Pn,{disabled:n?.restoreFocus===!1})),P.createElement(Be,{...n,hiddenTextDescribedById:re}));function Ae(){let e=ee?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Vn=(0,P.createContext)(null),Hn=`button`,Un=`Draggable`;function Wn(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Se(Un),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,P.useContext)(An),{role:p=Hn,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,P.useContext)(g?Rn:Vn),[v,y]=U(),[b,x]=U(),S=vn(o,t),C=be(n);return V(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,P.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Hn?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Gn(){return(0,P.useContext)(jn)}var Kn=`Droppable`,qn={timeout:25};function Jn(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Se(Kn),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,P.useContext)(An),u=(0,P.useRef)({disabled:n}),d=(0,P.useRef)(!1),f=(0,P.useRef)(null),p=(0,P.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...qn,...i},_=be(h??r),v=ln({callback:(0,P.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=U((0,P.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=be(t);return(0,P.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,P.useEffect)(()=>(s({type:q.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:q.UnregisterDroppable,key:a,id:r})),[r]),(0,P.useEffect)(()=>{n!==u.current.disabled&&(s({type:q.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Yn(e){let{animation:t,children:n}=e,[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(null),s=xe(n);return!n&&!r&&s&&i(s),V(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),P.createElement(P.Fragment,null,n,r?(0,P.cloneElement)(r,{ref:o}):null)}var Xn={x:0,y:0,scaleX:1,scaleY:1};function Zn(e){let{children:t}=e;return P.createElement(An.Provider,{value:kn},P.createElement(Rn.Provider,{value:Xn},t))}var Qn={position:`fixed`,touchAction:`none`},$n=e=>G(e)?`transform 250ms ease`:void 0,er=(0,P.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=$n}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Qn,width:s.width,height:s.height,top:s.top,left:s.left,transform:K.Transform.toString(d),transformOrigin:i&&r?Ge(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return P.createElement(n,{className:o,style:f,ref:t},a)}),tr={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:K.Transform.toString(t)},{transform:K.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function nr(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return ve((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Sn(a);if(!c)return;let{transform:l}=R(a).getComputedStyle(a),u=at(l);if(!u)return;let d=typeof t==`function`?t:rr(t);return Dt(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function rr(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...tr,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var ir=0;function ar(e){return(0,P.useMemo)(()=>{if(e!=null)return ir++,ir},[e])}var or=P.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Gn(),S=(0,P.useContext)(Rn),C=ar(d?.id),w=Fn(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),ee=on(f),te=nr({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),T=ee?g.setRef:void 0;return P.createElement(Zn,null,P.createElement(Yn,{animation:te},d&&C?P.createElement(er,{key:C,id:d.id,ref:T,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:ee,style:{zIndex:l,...i},transform:w},n):null))});function sr(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function cr(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function lr(e){return e!==null&&e>=0}function ur(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dr(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var fr=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=sr(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},pr={scaleX:1,scaleY:1},mr=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...pr}:null}let s=hr(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...pr}:r<t&&r>=a?{x:0,y:o.height+s,...pr}:{x:0,y:0,...pr}};function hr(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var gr=`Sortable`,_r=P.createContext({activeIndex:-1,containerId:gr,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:fr,disabled:{draggable:!1,droppable:!1}});function vr(e){let{children:t,id:n,items:r,strategy:i=fr,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=Gn(),d=Se(gr,n),f=s.rect!==null,p=(0,P.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,P.useRef)(p),v=!ur(p,_.current),y=g!==-1&&h===-1||v,b=dr(a);V(()=>{v&&m&&u(p)},[v,p,m,u]),(0,P.useEffect)(()=>{_.current=p},[p]);let x=(0,P.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:cr(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return P.createElement(_r.Provider,{value:x},t)}var yr=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return sr(n,r,i).indexOf(t)},br=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},xr={duration:200,easing:`ease`},Sr=`transform`,Cr=K.Transition.toString({property:Sr,duration:0,easing:`linear`}),wr={roleDescription:`sortable`};function Tr(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,P.useState)(null),s=(0,P.useRef)(n);return V(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=ct(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,P.useEffect)(()=>{a&&o(null)},[a]),a}function Er(e){let{animateLayoutChanges:t=br,attributes:n,disabled:r,data:i,getNewIndex:a=yr,id:o,strategy:s,resizeObserverConfig:c,transition:l=xr}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,P.useContext)(_r),y=Dr(r,p),b=u.indexOf(o),x=(0,P.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,P.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:ee,setNodeRef:te}=Jn({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:T,activatorEvent:ne,activeNodeRect:E,attributes:re,setNodeRef:ie,listeners:ae,isDragging:D,over:oe,setActivatorNodeRef:se,transform:O}=Wn({id:o,data:x,attributes:{...wr,...n},disabled:y.draggable}),ce=he(te,ie),le=!!T,ue=le&&!m&&lr(f)&&lr(g),k=!_&&D,de=ue?(k&&ue?O:null)??(s??v)({rects:h,activeNodeRect:E,activeIndex:f,overIndex:g,index:b}):null,A=lr(f)&&lr(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,fe=T?.id,j=(0,P.useRef)({activeId:fe,items:u,newIndex:A,containerId:d}),pe=u!==j.current.items,M=t({active:T,containerId:d,isDragging:D,isSorting:le,id:o,index:b,items:u,newIndex:j.current.newIndex,previousItems:j.current.items,previousContainerId:j.current.containerId,transition:l,wasDragging:j.current.activeId!=null}),me=Tr({disabled:!M,index:b,node:w,rect:C});return(0,P.useEffect)(()=>{le&&j.current.newIndex!==A&&(j.current.newIndex=A),d!==j.current.containerId&&(j.current.containerId=d),u!==j.current.items&&(j.current.items=u)},[le,A,d,u]),(0,P.useEffect)(()=>{if(fe===j.current.activeId)return;if(fe!=null&&j.current.activeId==null){j.current.activeId=fe;return}let e=setTimeout(()=>{j.current.activeId=fe},50);return()=>clearTimeout(e)},[fe]),{active:T,activeIndex:f,attributes:re,data:x,rect:C,index:b,newIndex:A,items:u,isOver:ee,isSorting:le,isDragging:D,listeners:ae,node:w,overIndex:g,over:oe,setNodeRef:ce,setActivatorNodeRef:se,setDroppableNodeRef:te,setDraggableNodeRef:ie,transform:me??de,transition:N()};function N(){if(me||pe&&j.current.newIndex===b)return Cr;if(!(k&&!G(ne)||!l)&&(le||M))return K.Transition.toString({...l,property:Sr})}}function Dr(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Or(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var kr=[Z.Down,Z.Right,Z.Up,Z.Left],Ar=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(kr.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case Z.Down:r.top<a.top&&t.push(n);break;case Z.Up:r.top>a.top&&t.push(n);break;case Z.Left:r.left>a.left&&t.push(n);break;case Z.Right:r.left<a.left&&t.push(n);break}});let c=Qe({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=Ye(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=pt(c).some((e,t)=>s[t]!==e),i=jr(e,t),a=Mr(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Te(u,l)}}}};function jr(e,t){return!Or(e)||!Or(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Mr(e,t){return!Or(e)||!Or(t)||!jr(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Nr(e){let t=[];for(let n of e){if(n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.model||n.runner||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Pr(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function Fr(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function Ir(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function Lr(e,t){return e.filter((e,n)=>n!==t)}function Q(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function Rr(e,t,n){let r=` `.repeat(n);return t.includes(`
|
|
6
|
+
`)?[`${r}${e}: |`,...t.split(`
|
|
7
|
+
`).map(e=>`${r} ${e}`)]:[`${r}${e}: ${Q(t)}`]}function zr(e,t,n){let r=[`name: ${Q(e.trim()||`my-workflow`)}`];t.trim()&&r.push(...Rr(`description`,t.trim(),0));let i=Nr(n);if(i){r.push(`skills:`);for(let e of i)r.push(` - ${Q(e)}`)}else if(n.length){r.push(`steps:`);for(let e of n)r.push(` - id: ${Q(e.id)}`),e.name&&e.name!==e.id&&r.push(` name: ${Q(e.name)}`),e.skill&&r.push(` skill: ${Q(e.skill)}`),e.prompt&&r.push(...Rr(`prompt`,e.prompt,4)),e.model&&r.push(` model: ${Q(e.model)}`),e.runner&&r.push(` runner: ${Q(e.runner)}`),e.allowedTools&&r.push(` allowedTools: [${e.allowedTools.map(Q).join(`, `)}]`),e.bashAllowlist&&r.push(` bashAllowlist: [${e.bashAllowlist.map(Q).join(`, `)}]`),e.command&&r.push(...Rr(`command`,e.command,4)),e.onFail&&r.push(` onFail:`,` retry: ${Q(e.onFail.retry)}`,` max: ${e.onFail.max??2}`)}else r.push(`skills: []`);return`${r.join(`
|
|
8
|
+
`)}\n`}function Br(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`workflow`}function Vr(e){let t=Nr(e)?`skill`:`step`;return`${e.length} ${t}${e.length===1?``:`s`}`}function Hr(e,t){let n=new Set,r=[];for(let t of e.steps.slice(0,8)){let e=t.id||`step`,i=e;for(let t=2;n.has(i);t++)i=`${e}-${t}`;n.add(i),r.push({...t,id:i})}return{name:e.name?.trim()||t,steps:r}}function Ur(e,t,n){let r=Nr(n);return{name:e.trim(),...t.trim()?{description:t.trim()}:{},...r?{skills:r}:{steps:[...n]}}}var $=e(),Wr=`wb-canvas`;function Gr(){return{name:`my-workflow`,description:``,steps:[]}}function Kr(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function qr(){let{name:e}=l();return(0,$.jsx)(Jr,{routeName:e},e??``)}function Jr({routeName:e}){let t=f(),n=u(),r=v(),l=d(),[b,S]=(0,P.useState)(null),[w,te]=(0,P.useState)(``),[E,D]=(0,P.useState)(!1),[se,ce]=(0,P.useState)(``),[ue,N]=(0,P.useState)(``),[he,F]=(0,P.useState)(!1),[I,L]=(0,P.useState)(``),[R,z]=(0,P.useState)(!1),[ge,_e]=(0,P.useState)(!1),[B,V]=(0,P.useState)(null),[ve,ye]=(0,P.useState)(null),be=(0,P.useRef)(null),H=t.data?.workflows??[],U=n.data??[],xe=ae(U,r.data?.skillUsage);(0,P.useEffect)(()=>{if(b!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);S(r?Kr(r):Gr())},[b,t.data,e]);let W=e=>S(t=>t===null?t:{...t,steps:e}),Se=_({mutationFn:e=>a(e),onSuccess:e=>{S({name:e.name,description:e.description??``,steps:e.steps}),D(!1),ce(``),N(``),p(`Imported "${e.name}" — review, then Save.`)},onError:e=>N(e.message)}),Ce=_({mutationFn:e=>o(e),onSuccess:e=>{S(t=>{let n=t??Gr(),{name:r,steps:i}=Hr(e,n.name);return{...n,name:r,steps:i}}),F(!1),L(``),p(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??b?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>p(e instanceof Error?e.message:String(e),{tone:`danger`})}),we=_({mutationFn:e=>g({...Ur(b?.name??``,b?.description??``,b?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:e=>{z(!1),p(`Saved — ${e.path.split(`/`).pop()??e.path}`),l.invalidateQueries({queryKey:i.workflows})},onError:e=>{e instanceof c&&e.exists===!0?z(!0):p(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Te=_({mutationFn:e=>m(e),onSuccess:(e,t)=>{_e(!1),p(`Deleted "${t}".`),S(Gr()),l.invalidateQueries({queryKey:i.workflows})},onError:e=>{_e(!1),p(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Ee=Ue(He(Ht,{activationConstraint:{distance:4}}),He(Lt,{coordinateGetter:Ar}));if(t.isError)return(0,$.jsx)(`div`,{"data-route":`workflows`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(y,{icon:(0,$.jsx)(T,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(b===null)return(0,$.jsx)(O,{});let G=b.steps,De=b.name.trim(),Oe=H.find(e=>e.name===De&&e.source===`file`),K=zr(b.name,b.description,G),ke=(e,t=G.length)=>{if(G.length>=8){p(`A workflow holds at most 8 steps.`,{tone:`danger`});return}W(Fr(G,Pr(e,G),t))},Ae=e=>{let t=e.active.data.current;V(t??null)},je=e=>{ye(e.over?String(e.over.id):null)},Me=e=>{V(null),ye(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===Wr?G.length:G.findIndex(e=>e.id===n.id);ke(r.skill,e===-1?G.length:e);return}if(n.id===t.id)return;let i=G.findIndex(e=>e.id===t.id),a=G.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&W(Ir(G,i,a))},Ne=()=>{let e=se.trim();e!==``&&Se.mutate(e)},Pe=()=>{let e=I.trim();e===``||Ce.isPending||Ce.mutate(e)};return(0,$.jsxs)(`div`,{"data-route":`workflows`,className:`flex min-h-full flex-col`,children:[(0,$.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold`,children:`Workflows`}),(0,$.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Portable skill chains — the agent applies them top to bottom.`})]}),(0,$.jsxs)(Bn,{sensors:Ee,collisionDetection:Ze,onDragStart:Ae,onDragOver:je,onDragEnd:Me,onDragCancel:()=>{V(null),ye(null)},children:[(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-6 p-3 pb-[calc(90px+env(safe-area-inset-bottom))] md:flex-row md:p-5 md:pb-5`,children:[(0,$.jsxs)(`section`,{"data-slot":`wb-main`,className:`mx-auto w-full min-w-0 max-w-3xl flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,$.jsx)(M,{ref:be,"data-slot":`wb-name`,"aria-label":`Workflow name`,spellCheck:!1,value:b.name,onChange:e=>S({...b,name:e.target.value}),className:`h-8 max-w-56 font-mono text-[13px] font-semibold`}),(0,$.jsx)(`span`,{"data-slot":`wb-count`,className:`shrink-0 font-mono text-xs text-soft-foreground`,children:Vr(G)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[Oe?(0,$.jsxs)(s,{type:`button`,variant:`danger-ghost`,size:`sm`,"data-slot":`wb-delete`,title:`Delete the saved workflow file`,onClick:()=>_e(!0),children:[(0,$.jsx)(C,{"aria-hidden":`true`,className:`size-3`}),`Delete`]}):null,(0,$.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto`,"aria-expanded":he,title:`Describe a chain — the agent builds it`,onClick:()=>{D(!1),F(e=>!e)},children:[(0,$.jsx)(me,{"aria-hidden":`true`,className:`size-3`}),`Auto`]}),(0,$.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import`,onClick:()=>{N(``),F(!1),D(e=>!e)},children:[(0,$.jsx)(ne,{"aria-hidden":`true`,className:`size-3`}),`Import`]}),(0,$.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-export`,title:`Download workflow.yaml`,onClick:()=>{let e=new Blob([K],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${Br(b.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},children:[(0,$.jsx)(ee,{"aria-hidden":`true`,className:`size-3`}),`Export`]}),(0,$.jsxs)(s,{type:`button`,variant:`contrast`,size:`sm`,"data-slot":`wb-save`,disabled:we.isPending,onClick:()=>{if(De===``){be.current?.focus();return}if(G.length===0){p(`Add at least one step first.`,{tone:`danger`});return}we.mutate(!1)},children:[(0,$.jsx)(h,{"aria-hidden":`true`,className:`size-3`}),`Save`]})]})]}),(0,$.jsxs)(`div`,{"data-slot":`wb-load`,className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`mr-0.5 text-[11px] font-medium tracking-wide text-soft-foreground uppercase`,children:`edit`}),H.map(e=>(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-load-chip`,"data-name":e.name,title:e.description??``,"aria-pressed":De===e.name,onClick:()=>S(Kr(e)),className:x(`rounded-full border border-border bg-card px-2.5 py-1 font-mono text-[11.5px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,De===e.name&&`border-primary/40 bg-primary/10 text-foreground`),children:e.name},e.name)),(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-new`,title:`Start an empty workflow`,onClick:()=>S(Gr()),className:`rounded-full border border-dashed border-border px-2.5 py-1 font-mono text-[11.5px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`+ new`})]}),he?(0,$.jsxs)(`div`,{"data-slot":`wb-auto-panel`,className:`mt-4 rounded-lg border border-border bg-card p-3 shadow-xs`,children:[(0,$.jsx)(`div`,{className:`text-[11px] font-medium tracking-wide text-soft-foreground uppercase`,children:`Build a chain from a prompt`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-soft-foreground`,children:`Describe what the chain should do. An agent proposes a title and an ordered set of skill / check steps — land it on the canvas, then tweak and Save.`}),(0,$.jsx)(re,{"data-slot":`wb-auto-text`,"aria-label":`Describe the chain to build`,rows:3,autoFocus:!0,placeholder:`e.g. Fix the bug, run the tests, then review the diff for regressions.`,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Pe())},className:`mt-2 min-h-20 text-[13px]`}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,$.jsxs)(s,{type:`button`,variant:`contrast`,size:`sm`,"data-slot":`wb-auto-run`,disabled:Ce.isPending||I.trim()===``,onClick:Pe,children:[(0,$.jsx)(me,{"aria-hidden":`true`,className:`size-3`}),Ce.isPending?`Building…`:`Build chain`]}),(0,$.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto-cancel`,onClick:()=>{F(!1),L(``)},children:`Cancel`})]})]}):null,E?(0,$.jsxs)(`div`,{"data-slot":`wb-import-panel`,className:`mt-4 rounded-lg border border-border bg-card p-3 shadow-xs`,children:[(0,$.jsx)(`div`,{className:`text-[11px] font-medium tracking-wide text-soft-foreground uppercase`,children:`Import workflow YAML`}),(0,$.jsx)(re,{"data-slot":`wb-import-text`,"aria-label":`Workflow YAML to import`,rows:6,spellCheck:!1,placeholder:`name: my-flow
|
|
9
|
+
skills:
|
|
10
|
+
- test-conventions
|
|
11
|
+
- commit-style`,value:se,onChange:e=>ce(e.target.value),className:`mt-2 min-h-28 font-mono text-xs`}),ue===``?null:(0,$.jsx)(`p`,{"data-slot":`wb-import-error`,className:`mt-2 text-xs text-danger`,children:ue}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,$.jsx)(s,{type:`button`,variant:`contrast`,size:`sm`,"data-slot":`wb-import-run`,disabled:Se.isPending,onClick:Ne,children:`Import`}),(0,$.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:()=>{D(!1),ce(``),N(``)},children:`Cancel`})]})]}):null,(0,$.jsx)(Yr,{steps:G,skills:U,dragging:B!==null,overId:ve,activeStepId:B?.type===`step`?B.step.id:null,onRemove:e=>W(Lr(G,e))})]}),(0,$.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`w-full shrink-0 md:w-[320px]`,children:[(0,$.jsx)(`div`,{className:`text-[11px] font-medium tracking-wide text-soft-foreground uppercase`,children:`Skills`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-soft-foreground`,children:`Drag into the flow. Order is execution order — the agent applies them top to bottom.`}),(0,$.jsx)(M,{"data-slot":`wb-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:w,onChange:e=>te(e.target.value),className:`mt-2.5 h-8 text-[13px]`}),(0,$.jsx)(Qr,{skills:xe,query:w,error:n.isError?n.error.message:null,inFlow:new Set(G.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>ke(e)}),(0,$.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium tracking-wide text-soft-foreground uppercase`,children:`workflow.yaml`}),(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(ei,{yaml:K})]}),(0,$.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 overflow-x-auto rounded-lg border border-border bg-card p-3 font-mono text-[11.5px] leading-relaxed whitespace-pre text-muted-foreground shadow-xs`,children:K}),(0,$.jsx)(`p`,{className:`mt-2 text-[11.5px] leading-relaxed text-soft-foreground`,children:`Portable — export this file and import it in any repo running cezar.`})]})]}),(0,$.jsx)(or,{children:B?.type===`palette`?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5 text-primary`}),B.skill]}):B?.type===`step`?(0,$.jsx)(Zr,{step:B.step,index:G.findIndex(e=>e.id===B.step.id),skills:U,overlay:!0}):null})]}),(0,$.jsx)(pe,{open:R,onOpenChange:e=>!e&&z(!1),children:(0,$.jsxs)(j,{"data-slot":`wb-overwrite-dialog`,children:[(0,$.jsxs)(de,{children:[(0,$.jsxs)(oe,{children:[`“`,De,`” already exists`]}),(0,$.jsx)(fe,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(k,{children:`Keep the file`}),(0,$.jsx)(le,{"data-slot":`wb-overwrite-confirm`,onClick:()=>we.mutate(!0),children:`Overwrite`})]})]})}),(0,$.jsx)(pe,{open:ge,onOpenChange:e=>!e&&_e(!1),children:(0,$.jsxs)(j,{"data-slot":`wb-delete-dialog`,children:[(0,$.jsxs)(de,{children:[(0,$.jsxs)(oe,{children:[`Delete workflow “`,De,`”?`]}),(0,$.jsxs)(fe,{children:[`Removes `,Oe?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(k,{children:`Keep it`}),(0,$.jsx)(le,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>Te.mutate(De),children:`Delete`})]})]})})]})}function Yr({steps:e,skills:t,dragging:n,overId:r,activeStepId:i,onRemove:a}){let{setNodeRef:o,isOver:s}=Jn({id:Wr}),c=n&&r===Wr;return(0,$.jsx)(`div`,{ref:o,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:x(`mt-4 rounded-lg border border-dashed p-2 transition-colors`,s?`border-primary/60 bg-primary/5`:`border-muted-foreground/25`),children:e.length===0?(0,$.jsx)(`p`,{className:x(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,s?`text-primary`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,$.jsxs)(vr,{items:e.map(e=>e.id),strategy:mr,children:[(0,$.jsx)(`ol`,{className:`flex flex-col gap-2.5`,children:e.map((e,o)=>(0,$.jsx)(Xr,{step:e,index:o,skills:t,connector:o>0,dragging:n,insertBefore:n&&r===e.id&&i!==e.id,onRemove:()=>a(o)},e.id))}),(0,$.jsx)(`div`,{"aria-hidden":`true`,className:x(`mx-1 mt-2.5 h-[3px] rounded-full transition-colors`,c?`bg-primary`:`bg-transparent`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 pt-1.5 pb-1 text-[11px] text-muted-foreground`,children:[(0,$.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),`runs top to bottom`]})]})})}function Xr({step:e,index:t,skills:n,connector:r,dragging:i,insertBefore:a,onRemove:o}){let{attributes:s,listeners:c,setNodeRef:l,transform:u,transition:d,isDragging:f}=Er({id:e.id,data:{type:`step`,step:e}});return(0,$.jsxs)(`li`,{ref:l,style:{transform:K.Transform.toString(u),transition:d},className:x(`relative`,f&&`opacity-40`),children:[r&&!i?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-[11px] left-1/2 h-[9px] w-px -translate-x-1/2 bg-muted-foreground/30`}):null,a?(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-primary`}):null,(0,$.jsx)(Zr,{step:e,index:t,skills:n,onRemove:o,gripProps:{...s,...c}})]})}function Zr({step:e,index:t,skills:n,onRemove:r,gripProps:i,overlay:a=!1}){let o=n.find(t=>t.name===e.skill),s=!!e.command,c=s||!e.skill?e.name??e.id:e.skill,l=s?`$ ${e.command}${e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``}`:e.skill?o?.description??`Not in this repo or the team skills — the step runs on its plain prompt.`:e.prompt??``,u=s?`check`:e.skill?o?null:`unknown`:`prompt`;return(0,$.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:x(`flex items-center gap-2.5 rounded-md border border-muted-foreground/20 bg-card-2 px-2.5 py-2 shadow-xs`,a&&`shadow-md`),children:[(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${t+1}: ${c}`,className:`shrink-0 cursor-grab rounded text-muted-foreground outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,...i,children:(0,$.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:String(t+1).padStart(2,`0`)}),s?(0,$.jsx)(te,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-success`}):(0,$.jsx)(ie,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-[13px] font-medium`,children:c}),l?(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:l}):null]}),u?(0,$.jsx)(`span`,{"data-slot":`wb-step-badge`,className:x(`shrink-0 rounded-full border px-2 py-px font-mono text-[10.5px]`,u===`check`&&`border-success/30 text-success`,u===`unknown`&&`border-danger/35 text-danger`,u===`prompt`&&`border-border text-soft-foreground`),children:u}):null,r?(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-step-remove`,"aria-label":`Remove step ${t+1}: ${c}`,title:`Remove from flow`,onClick:r,className:`shrink-0 rounded p-0.5 text-soft-foreground transition-colors outline-none hover:text-danger focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,$.jsx)(E,{"aria-hidden":`true`,className:`size-3.5`})}):null]})}function Qr({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,$.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=t.trim().toLowerCase(),o=e.filter(e=>a===``||e.name.toLowerCase().includes(a)||(e.description??``).toLowerCase().includes(a));return(0,$.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:o.length>0?o.map(e=>(0,$.jsx)($r,{skill:e,inFlow:r.has(e.name),onAdd:i},e.path)):(0,$.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:(0,$.jsx)(w,{})})})}function $r({skill:e,inFlow:t,onAdd:n}){let{attributes:r,listeners:i,setNodeRef:a,isDragging:o}=Wn({id:`palette:${e.name}`,data:{type:`palette`,skill:e.name}});return(0,$.jsxs)(`div`,{ref:a,"data-slot":`wb-skill`,"data-skill":e.name,title:e.description??``,className:x(`flex cursor-grab items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 shadow-xs transition-colors hover:bg-muted`,o&&`opacity-40`),...r,...i,children:[(0,$.jsx)(ie,{"aria-hidden":`true`,className:x(`size-3.5 shrink-0`,se(e)?`text-violet`:`text-soft-foreground`)}),(0,$.jsx)(`span`,{className:x(`min-w-0 flex-1 truncate font-mono text-[13px]`,se(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),t?(0,$.jsx)(h,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-success`}):null,(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.name),className:`shrink-0 rounded p-0.5 text-soft-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,$.jsx)(D,{"aria-hidden":`true`,className:`size-3.5`})})]})}function ei({yaml:e}){let[t,n]=(0,P.useState)(!1),r=(0,P.useRef)(null);return(0,P.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,$.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(h,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}export{qr as WorkflowsRoute};
|
package/web/dist/index.html
CHANGED
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
}
|
|
42
42
|
})()
|
|
43
43
|
</script>
|
|
44
|
-
<script type="module" crossorigin src="/assets/index-
|
|
44
|
+
<script type="module" crossorigin src="/assets/index-Cijmlz7q.js"></script>
|
|
45
45
|
<link rel="modulepreload" crossorigin href="/assets/bundle-mjs-BegPhL5c.js">
|
|
46
46
|
<link rel="modulepreload" crossorigin href="/assets/utils-B8s5qIcK.js">
|
|
47
|
-
<link rel="modulepreload" crossorigin href="/assets/centered-state-
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/centered-state-DOsTcJZF.js">
|
|
48
48
|
<link rel="modulepreload" crossorigin href="/assets/search-x-BDjaMrzG.js">
|
|
49
49
|
<link rel="modulepreload" crossorigin href="/assets/triangle-alert-Uy8rokUh.js">
|
|
50
50
|
<link rel="modulepreload" crossorigin href="/assets/textarea-Bj_LCreg.js">
|
|
51
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
52
|
-
<link rel="modulepreload" crossorigin href="/assets/project-router-
|
|
51
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-B6XQOhgM.js">
|
|
52
|
+
<link rel="modulepreload" crossorigin href="/assets/project-router-BMx4e8m-.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="/assets/lib-uHpeUPzK.js">
|
|
54
54
|
<link rel="modulepreload" crossorigin href="/assets/chunk-BO2N2NFS-DtrdTCWa.js">
|
|
55
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
55
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DzroxqBG.css">
|
|
56
56
|
</head>
|
|
57
57
|
<body>
|
|
58
58
|
<div id="root"></div>
|
package/dist/core/pi-runner.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AgentEvent, AgentRunResult, AgentRunSpec, AgentRunner, AgentSession, SessionOptions } from './agent-runner.js';
|
|
2
|
-
export interface PiRunnerOptions {
|
|
3
|
-
/** Override the binary name/path; defaults to `pi` on PATH (`CEZ_PI_BIN`). */
|
|
4
|
-
bin?: string;
|
|
5
|
-
/** Wall-clock timeout for a run (ms); per-spec `timeoutMs` still wins. */
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Persistent subprocess adapter for pi's documented RPC mode.
|
|
10
|
-
*
|
|
11
|
-
* Contract: https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/rpc.md
|
|
12
|
-
* Pi has its own command/event vocabulary; it is not Claude stream-json.
|
|
13
|
-
*/
|
|
14
|
-
export declare class PiRunner implements AgentRunner {
|
|
15
|
-
readonly backend: 'pi';
|
|
16
|
-
private readonly bin;
|
|
17
|
-
private readonly timeoutMs;
|
|
18
|
-
private lastSession;
|
|
19
|
-
constructor(opts?: PiRunnerOptions);
|
|
20
|
-
run(spec: AgentRunSpec, onEvent?: (event: AgentEvent) => void): Promise<AgentRunResult>;
|
|
21
|
-
interrupt(): Promise<void>;
|
|
22
|
-
startSession(spec: AgentRunSpec, onEvent?: (event: AgentEvent) => void, opts?: SessionOptions): AgentSession;
|
|
23
|
-
}
|
|
24
|
-
export declare function buildPiArgs(spec: AgentRunSpec): string[];
|