@tt-a1i/hive 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/src/server/hive-team-guidance.js +12 -11
  3. package/dist/src/server/role-templates.js +8 -4
  4. package/dist/src/server/team-operations.js +1 -1
  5. package/package.json +1 -1
  6. package/web/dist/assets/{AddWorkerDialog-DuUFz6UK.js → AddWorkerDialog-Cd53ifv2.js} +2 -2
  7. package/web/dist/assets/{AddWorkspaceFlow-CFuHJXFe.js → AddWorkspaceFlow-3sR25gDy.js} +1 -1
  8. package/web/dist/assets/{FirstRunWizard-qA5b90Ru.js → FirstRunWizard-DU8PipxA.js} +1 -1
  9. package/web/dist/assets/{MarketplaceDrawer-BdkVJyI0.js → MarketplaceDrawer-BkNcknv0.js} +1 -1
  10. package/web/dist/assets/{TaskGraphDrawer-DDhX2p_z.js → TaskGraphDrawer-9mXNimSE.js} +1 -1
  11. package/web/dist/assets/{WhatsNewDialog-Cp_gv_Co.js → WhatsNewDialog-C7awVYub.js} +1 -1
  12. package/web/dist/assets/WorkerModal-BzgrOKzF.js +1 -0
  13. package/web/dist/assets/{WorkflowsDrawer-wk6HSGNl.js → WorkflowsDrawer-C4yjTdY7.js} +1 -1
  14. package/web/dist/assets/{WorkspaceMemoryDrawer-CSxU_0b1.js → WorkspaceMemoryDrawer-BlDznlGm.js} +1 -1
  15. package/web/dist/assets/{WorkspaceTaskDrawer-Bz3fMad9.js → WorkspaceTaskDrawer-CpGGZkp3.js} +1 -1
  16. package/web/dist/assets/{index-B3XoRj0C.js → index-BEyvsWk6.js} +24 -24
  17. package/web/dist/assets/index-VHK8pAJq.css +1 -0
  18. package/web/dist/assets/{search-BdM5IXYB.js → search-Cv0KnMjw.js} +1 -1
  19. package/web/dist/assets/{square-terminal-DnmshYpr.js → square-terminal-BZ7EavxU.js} +1 -1
  20. package/web/dist/index.html +2 -2
  21. package/web/dist/sw.js +1 -1
  22. package/web/dist/assets/WorkerModal-BbKQsSSJ.js +0 -1
  23. package/web/dist/assets/index-CEP_bvOg.css +0 -1
@@ -1,4 +1,4 @@
1
- import{c as cr,r as R,u as at,j as h,an as ur,ao as pr,ap as hr,i as dr,R as fr,P as mr,O as gr,k as xr,m as kr,a0 as br,z as Tr,X as wr,aq as yr}from"./index-B3XoRj0C.js";import{S as mn}from"./search-BdM5IXYB.js";const Ar=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],Sr=cr("bookmark",Ar),_r={academic:{en:"Academic",zh:"学术"},design:{en:"Design",zh:"设计"},engineering:{en:"Engineering",zh:"工程"},finance:{en:"Finance",zh:"金融"},"game-development":{en:"Game Development",zh:"游戏开发"},hr:{en:"HR",zh:"人力资源"},integrations:{en:"System Integrations",zh:"系统集成"},legal:{en:"Legal",zh:"法务"},marketing:{en:"Marketing",zh:"营销"},misc:{en:"Misc",zh:"其他"},"paid-media":{en:"Paid Ads",zh:"广告投放"},product:{en:"Product",zh:"产品"},"project-management":{en:"Project Management",zh:"项目管理"},sales:{en:"Sales",zh:"销售"},"spatial-computing":{en:"Spatial Computing",zh:"空间计算"},specialized:{en:"Industry Verticals",zh:"行业角色"},"supply-chain":{en:"Supply Chain",zh:"供应链"},support:{en:"Support",zh:"客户支持"},testing:{en:"Testing",zh:"测试"}},Er=t=>t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Lt=(t,e)=>{const n=_r[t];return n?n[e]:Er(t)},Rr=["engineering","testing","product","design","project-management","integrations","specialized","marketing","paid-media","sales","finance","legal","hr","supply-chain","support","academic","game-development","spatial-computing","misc"],Nr=(t,e)=>{if(e!=="zh")return t;const n=new Map(Rr.map((s,r)=>[s,r]));return[...t].sort((s,r)=>{const a=n.get(s)??Number.POSITIVE_INFINITY,l=n.get(r)??Number.POSITIVE_INFINITY;return a!==l?a-l:s.localeCompare(r)})},vr=({agent:t,selected:e,imported:n,onSelect:s})=>{const{t:r}=at(),a=R.useCallback(()=>s(t.path),[t.path,s]),l=t.vibe?.trim()?t.vibe:t.description,o=r("marketplace.importedBadge"),p=t.displayName??t.name,c=t.nameOverflows?p:void 0;return h.jsxs("button",{type:"button",onClick:a,"data-testid":"marketplace-agent-card","data-agent-path":t.path,"data-imported":n?"true":void 0,"data-selected":e?"true":void 0,className:"marketplace-card flex w-full cursor-pointer flex-col gap-2 rounded-xl border p-3.5 text-left outline-none transition-all duration-200 ease-out focus-visible:ring-2 focus-visible:ring-offset-0 active:scale-[0.98]",style:{"--tw-ring-color":"color-mix(in oklab, var(--accent) 55%, transparent)"},children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[h.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-bright bg-3 text-base shadow-sm",children:t.emoji||"🤖"}),h.jsx("div",{className:"flex min-w-0 flex-col",children:h.jsx("span",{className:"truncate text-sm font-semibold text-pri",title:c,children:p})})]}),n?h.jsxs("span",{role:"status","aria-label":o,title:o,"data-testid":"marketplace-agent-imported",className:"flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[9px] font-semibold tracking-wide uppercase transition-colors",style:{background:e?"var(--accent)":"color-mix(in oklab, var(--accent) 15%, transparent)",color:e?"#ffffff":"var(--accent)",border:e?"none":"1px solid color-mix(in oklab, var(--accent) 25%, transparent)"},children:[h.jsx(Sr,{size:9,"aria-hidden":!0}),h.jsx("span",{className:"max-sm:hidden",children:o})]}):null]}),h.jsx("p",{className:"line-clamp-2 text-xs leading-normal text-sec mt-1",children:l})]})},Cr=R.memo(vr);function gn(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,s=Array(e);n<e;n++)s[n]=t[n];return s}function Ir(t){if(Array.isArray(t))return t}function Or(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,r,a,l,o=[],p=!0,c=!1;try{if(a=(n=n.call(t)).next,e!==0)for(;!(p=(s=a.call(n)).done)&&(o.push(s.value),o.length!==e);p=!0);}catch(m){c=!0,r=m}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}function Lr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{c as cr,r as R,u as at,j as h,an as ur,ao as pr,ap as hr,i as dr,R as fr,P as mr,O as gr,k as xr,m as kr,a0 as br,z as Tr,X as wr,aq as yr}from"./index-BEyvsWk6.js";import{S as mn}from"./search-Cv0KnMjw.js";const Ar=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],Sr=cr("bookmark",Ar),_r={academic:{en:"Academic",zh:"学术"},design:{en:"Design",zh:"设计"},engineering:{en:"Engineering",zh:"工程"},finance:{en:"Finance",zh:"金融"},"game-development":{en:"Game Development",zh:"游戏开发"},hr:{en:"HR",zh:"人力资源"},integrations:{en:"System Integrations",zh:"系统集成"},legal:{en:"Legal",zh:"法务"},marketing:{en:"Marketing",zh:"营销"},misc:{en:"Misc",zh:"其他"},"paid-media":{en:"Paid Ads",zh:"广告投放"},product:{en:"Product",zh:"产品"},"project-management":{en:"Project Management",zh:"项目管理"},sales:{en:"Sales",zh:"销售"},"spatial-computing":{en:"Spatial Computing",zh:"空间计算"},specialized:{en:"Industry Verticals",zh:"行业角色"},"supply-chain":{en:"Supply Chain",zh:"供应链"},support:{en:"Support",zh:"客户支持"},testing:{en:"Testing",zh:"测试"}},Er=t=>t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Lt=(t,e)=>{const n=_r[t];return n?n[e]:Er(t)},Rr=["engineering","testing","product","design","project-management","integrations","specialized","marketing","paid-media","sales","finance","legal","hr","supply-chain","support","academic","game-development","spatial-computing","misc"],Nr=(t,e)=>{if(e!=="zh")return t;const n=new Map(Rr.map((s,r)=>[s,r]));return[...t].sort((s,r)=>{const a=n.get(s)??Number.POSITIVE_INFINITY,l=n.get(r)??Number.POSITIVE_INFINITY;return a!==l?a-l:s.localeCompare(r)})},vr=({agent:t,selected:e,imported:n,onSelect:s})=>{const{t:r}=at(),a=R.useCallback(()=>s(t.path),[t.path,s]),l=t.vibe?.trim()?t.vibe:t.description,o=r("marketplace.importedBadge"),p=t.displayName??t.name,c=t.nameOverflows?p:void 0;return h.jsxs("button",{type:"button",onClick:a,"data-testid":"marketplace-agent-card","data-agent-path":t.path,"data-imported":n?"true":void 0,"data-selected":e?"true":void 0,className:"marketplace-card flex w-full cursor-pointer flex-col gap-2 rounded-xl border p-3.5 text-left outline-none transition-all duration-200 ease-out focus-visible:ring-2 focus-visible:ring-offset-0 active:scale-[0.98]",style:{"--tw-ring-color":"color-mix(in oklab, var(--accent) 55%, transparent)"},children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[h.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-bright bg-3 text-base shadow-sm",children:t.emoji||"🤖"}),h.jsx("div",{className:"flex min-w-0 flex-col",children:h.jsx("span",{className:"truncate text-sm font-semibold text-pri",title:c,children:p})})]}),n?h.jsxs("span",{role:"status","aria-label":o,title:o,"data-testid":"marketplace-agent-imported",className:"flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[9px] font-semibold tracking-wide uppercase transition-colors",style:{background:e?"var(--accent)":"color-mix(in oklab, var(--accent) 15%, transparent)",color:e?"#ffffff":"var(--accent)",border:e?"none":"1px solid color-mix(in oklab, var(--accent) 25%, transparent)"},children:[h.jsx(Sr,{size:9,"aria-hidden":!0}),h.jsx("span",{className:"max-sm:hidden",children:o})]}):null]}),h.jsx("p",{className:"line-clamp-2 text-xs leading-normal text-sec mt-1",children:l})]})},Cr=R.memo(vr);function gn(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,s=Array(e);n<e;n++)s[n]=t[n];return s}function Ir(t){if(Array.isArray(t))return t}function Or(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,r,a,l,o=[],p=!0,c=!1;try{if(a=(n=n.call(t)).next,e!==0)for(;!(p=(s=a.call(n)).done)&&(o.push(s.value),o.length!==e);p=!0);}catch(m){c=!0,r=m}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}function Lr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dr(t,e){return Ir(t)||Or(t,e)||Mr(t,e)||Lr()}function Mr(t,e){if(t){if(typeof t=="string")return gn(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gn(t,e):void 0}}const $n=Object.entries,xn=Object.setPrototypeOf,Pr=Object.isFrozen,zr=Object.getPrototypeOf,jr=Object.getOwnPropertyDescriptor;let H=Object.freeze,Y=Object.seal,Ce=Object.create,Fn=typeof Reflect<"u"&&Reflect,Nt=Fn.apply,vt=Fn.construct;H||(H=function(e){return e});Y||(Y=function(e){return e});Nt||(Nt=function(e,n){for(var s=arguments.length,r=new Array(s>2?s-2:0),a=2;a<s;a++)r[a-2]=arguments[a];return e.apply(n,r)});vt||(vt=function(e){for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return new e(...s)});const _e=L(Array.prototype.forEach),$r=L(Array.prototype.lastIndexOf),kn=L(Array.prototype.pop),Ee=L(Array.prototype.push),Fr=L(Array.prototype.splice),B=Array.isArray,je=L(String.prototype.toLowerCase),yt=L(String.prototype.toString),bn=L(String.prototype.match),Re=L(String.prototype.replace),Tn=L(String.prototype.indexOf),Ur=L(String.prototype.trim),Br=L(Number.prototype.toString),Hr=L(Boolean.prototype.toString),wn=typeof BigInt>"u"?null:L(BigInt.prototype.toString),yn=typeof Symbol>"u"?null:L(Symbol.prototype.toString),N=L(Object.prototype.hasOwnProperty),Pe=L(Object.prototype.toString),F=L(RegExp.prototype.test),Ke=Gr(TypeError);function L(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return Nt(t,e,s)}}function Gr(t){return function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return vt(t,n)}}function b(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:je;if(xn&&xn(t,null),!B(e))return t;let s=e.length;for(;s--;){let r=e[s];if(typeof r=="string"){const a=n(r);a!==r&&(Pr(e)||(e[s]=a),r=a)}t[r]=!0}return t}function Wr(t){for(let e=0;e<t.length;e++)N(t,e)||(t[e]=null);return t}function W(t){const e=Ce(null);for(const s of $n(t)){var n=Dr(s,2);const r=n[0],a=n[1];N(t,r)&&(B(a)?e[r]=Wr(a):a&&typeof a=="object"&&a.constructor===Object?e[r]=W(a):e[r]=a)}return e}function qr(t){switch(typeof t){case"string":return t;case"number":return Br(t);case"boolean":return Hr(t);case"bigint":return wn?wn(t):"0";case"symbol":return yn?yn(t):"Symbol()";case"undefined":return Pe(t);case"function":case"object":{if(t===null)return Pe(t);const e=t,n=de(e,"toString");if(typeof n=="function"){const s=n(e);return typeof s=="string"?s:Pe(s)}return Pe(t)}default:return Pe(t)}}function de(t,e){for(;t!==null;){const s=jr(t,e);if(s){if(s.get)return L(s.get);if(typeof s.value=="function")return L(s.value)}t=zr(t)}function n(){return null}return n}function Yr(t){try{return F(t,""),!0}catch{return!1}}const An=H(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),At=H(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),St=H(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Zr=H(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_t=H(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Xr=H(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Sn=H(["#text"]),_n=H(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Et=H(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),En=H(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Je=H(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vr=Y(/{{[\w\W]*|^[\w\W]*}}/g),Qr=Y(/<%[\w\W]*|^[\w\W]*%>/g),Kr=Y(/\${[\w\W]*/g),Jr=Y(/^data-[\-\w.\u00B7-\uFFFF]+$/),es=Y(/^aria-[\-\w]+$/),Rn=Y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ts=Y(/^(?:\w+script|data):/i),ns=Y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rs=Y(/^html$/i),ss=Y(/^[a-z][.\w]*(-[.\w]+)+$/i),Ne={element:1,text:3,progressingInstruction:7,comment:8,document:9},as=function(){return typeof window>"u"?null:window},is=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(s=n.getAttribute(r));const a="dompurify"+(s?"#"+s:"");try{return e.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Nn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Un(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:as();const e=x=>Un(x);if(e.version="3.4.5",e.removed=[],!t||!t.document||t.document.nodeType!==Ne.document||!t.Element)return e.isSupported=!1,e;let n=t.document;const s=n,r=s.currentScript,a=t.DocumentFragment,l=t.HTMLTemplateElement,o=t.Node,p=t.Element,c=t.NodeFilter,m=t.NamedNodeMap,d=m===void 0?t.NamedNodeMap||t.MozNamedAttrMap:m,k=t.HTMLFormElement,_=t.DOMParser,w=t.trustedTypes,P=p.prototype,q=de(P,"cloneNode"),xe=de(P,"remove"),ke=de(P,"nextSibling"),S=de(P,"childNodes"),te=de(P,"parentNode"),ne=o&&o.prototype?de(o.prototype,"nodeType"):null;if(typeof l=="function"){const x=n.createElement("template");x.content&&x.content.ownerDocument&&(n=x.content.ownerDocument)}let E,Q="";const ae=n,be=ae.implementation,Ue=ae.createNodeIterator,Be=ae.createDocumentFragment,He=ae.getElementsByTagName,Ge=s.importNode;let g=Nn();e.isSupported=typeof $n=="function"&&typeof te=="function"&&be&&be.createHTMLDocument!==void 0;const v=Vr,ie=Qr,Te=Kr,Kn=Jr,Jn=es,er=ts,Ht=ns,tr=ss;let Gt=Rn,z=null;const Wt=b({},[...An,...At,...St,..._t,...Sn]);let $=null;const qt=b({},[..._n,...Et,...En,...Je]);let C=Object.seal(Ce(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,We=null;const le=Object.seal(Ce(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Yt=!0,ot=!0,Zt=!1,Xt=!0,oe=!1,Le=!0,pe=!1,ct=!1,ut=!1,we=!1,qe=!1,Ye=!1,Vt=!0,Qt=!1;const Kt="user-content-";let pt=!0,De=!1,ye={},K=null;const ht=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Jt=null;const en=b({},["audio","video","img","source","image","track"]);let dt=null;const tn=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ze="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",J="http://www.w3.org/1999/xhtml";let Ae=J,ft=!1,mt=null;const nr=b({},[Ze,Xe,J],yt);let gt=b({},["mi","mo","mn","ms","mtext"]),xt=b({},["annotation-xml"]);const rr=b({},["title","style","font","a","script"]);let Me=null;const sr=["application/xhtml+xml","text/html"],ar="text/html";let M=null,Se=null;const ir=n.createElement("form"),nn=function(i){return i instanceof RegExp||i instanceof Function},kt=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Se&&Se===i)return;(!i||typeof i!="object")&&(i={}),i=W(i),Me=sr.indexOf(i.PARSER_MEDIA_TYPE)===-1?ar:i.PARSER_MEDIA_TYPE,M=Me==="application/xhtml+xml"?yt:je,z=N(i,"ALLOWED_TAGS")&&B(i.ALLOWED_TAGS)?b({},i.ALLOWED_TAGS,M):Wt,$=N(i,"ALLOWED_ATTR")&&B(i.ALLOWED_ATTR)?b({},i.ALLOWED_ATTR,M):qt,mt=N(i,"ALLOWED_NAMESPACES")&&B(i.ALLOWED_NAMESPACES)?b({},i.ALLOWED_NAMESPACES,yt):nr,dt=N(i,"ADD_URI_SAFE_ATTR")&&B(i.ADD_URI_SAFE_ATTR)?b(W(tn),i.ADD_URI_SAFE_ATTR,M):tn,Jt=N(i,"ADD_DATA_URI_TAGS")&&B(i.ADD_DATA_URI_TAGS)?b(W(en),i.ADD_DATA_URI_TAGS,M):en,K=N(i,"FORBID_CONTENTS")&&B(i.FORBID_CONTENTS)?b({},i.FORBID_CONTENTS,M):ht,Oe=N(i,"FORBID_TAGS")&&B(i.FORBID_TAGS)?b({},i.FORBID_TAGS,M):W({}),We=N(i,"FORBID_ATTR")&&B(i.FORBID_ATTR)?b({},i.FORBID_ATTR,M):W({}),ye=N(i,"USE_PROFILES")?i.USE_PROFILES&&typeof i.USE_PROFILES=="object"?W(i.USE_PROFILES):i.USE_PROFILES:!1,Yt=i.ALLOW_ARIA_ATTR!==!1,ot=i.ALLOW_DATA_ATTR!==!1,Zt=i.ALLOW_UNKNOWN_PROTOCOLS||!1,Xt=i.ALLOW_SELF_CLOSE_IN_ATTR!==!1,oe=i.SAFE_FOR_TEMPLATES||!1,Le=i.SAFE_FOR_XML!==!1,pe=i.WHOLE_DOCUMENT||!1,we=i.RETURN_DOM||!1,qe=i.RETURN_DOM_FRAGMENT||!1,Ye=i.RETURN_TRUSTED_TYPE||!1,ut=i.FORCE_BODY||!1,Vt=i.SANITIZE_DOM!==!1,Qt=i.SANITIZE_NAMED_PROPS||!1,pt=i.KEEP_CONTENT!==!1,De=i.IN_PLACE||!1,Gt=Yr(i.ALLOWED_URI_REGEXP)?i.ALLOWED_URI_REGEXP:Rn,Ae=typeof i.NAMESPACE=="string"?i.NAMESPACE:J,gt=N(i,"MATHML_TEXT_INTEGRATION_POINTS")&&i.MATHML_TEXT_INTEGRATION_POINTS&&typeof i.MATHML_TEXT_INTEGRATION_POINTS=="object"?W(i.MATHML_TEXT_INTEGRATION_POINTS):b({},["mi","mo","mn","ms","mtext"]),xt=N(i,"HTML_INTEGRATION_POINTS")&&i.HTML_INTEGRATION_POINTS&&typeof i.HTML_INTEGRATION_POINTS=="object"?W(i.HTML_INTEGRATION_POINTS):b({},["annotation-xml"]);const u=N(i,"CUSTOM_ELEMENT_HANDLING")&&i.CUSTOM_ELEMENT_HANDLING&&typeof i.CUSTOM_ELEMENT_HANDLING=="object"?W(i.CUSTOM_ELEMENT_HANDLING):Ce(null);if(C=Ce(null),N(u,"tagNameCheck")&&nn(u.tagNameCheck)&&(C.tagNameCheck=u.tagNameCheck),N(u,"attributeNameCheck")&&nn(u.attributeNameCheck)&&(C.attributeNameCheck=u.attributeNameCheck),N(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(C.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),oe&&(ot=!1),qe&&(we=!0),ye&&(z=b({},Sn),$=Ce(null),ye.html===!0&&(b(z,An),b($,_n)),ye.svg===!0&&(b(z,At),b($,Et),b($,Je)),ye.svgFilters===!0&&(b(z,St),b($,Et),b($,Je)),ye.mathMl===!0&&(b(z,_t),b($,En),b($,Je))),le.tagCheck=null,le.attributeCheck=null,N(i,"ADD_TAGS")&&(typeof i.ADD_TAGS=="function"?le.tagCheck=i.ADD_TAGS:B(i.ADD_TAGS)&&(z===Wt&&(z=W(z)),b(z,i.ADD_TAGS,M))),N(i,"ADD_ATTR")&&(typeof i.ADD_ATTR=="function"?le.attributeCheck=i.ADD_ATTR:B(i.ADD_ATTR)&&($===qt&&($=W($)),b($,i.ADD_ATTR,M))),N(i,"ADD_URI_SAFE_ATTR")&&B(i.ADD_URI_SAFE_ATTR)&&b(dt,i.ADD_URI_SAFE_ATTR,M),N(i,"FORBID_CONTENTS")&&B(i.FORBID_CONTENTS)&&(K===ht&&(K=W(K)),b(K,i.FORBID_CONTENTS,M)),N(i,"ADD_FORBID_CONTENTS")&&B(i.ADD_FORBID_CONTENTS)&&(K===ht&&(K=W(K)),b(K,i.ADD_FORBID_CONTENTS,M)),pt&&(z["#text"]=!0),pe&&b(z,["html","head","body"]),z.table&&(b(z,["tbody"]),delete Oe.tbody),i.TRUSTED_TYPES_POLICY){if(typeof i.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof i.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=i.TRUSTED_TYPES_POLICY,Q=E.createHTML("")}else E===void 0&&(E=is(w,r)),E!==null&&typeof Q=="string"&&(Q=E.createHTML(""));H&&H(i),Se=i},rn=b({},[...At,...St,...Zr]),sn=b({},[..._t,...Xr]),lr=function(i){let u=te(i);(!u||!u.tagName)&&(u={namespaceURI:Ae,tagName:"template"});const f=je(i.tagName),T=je(u.tagName);return mt[i.namespaceURI]?i.namespaceURI===Xe?u.namespaceURI===J?f==="svg":u.namespaceURI===Ze?f==="svg"&&(T==="annotation-xml"||gt[T]):!!rn[f]:i.namespaceURI===Ze?u.namespaceURI===J?f==="math":u.namespaceURI===Xe?f==="math"&&xt[T]:!!sn[f]:i.namespaceURI===J?u.namespaceURI===Xe&&!xt[T]||u.namespaceURI===Ze&&!gt[T]?!1:!sn[f]&&(rr[f]||!rn[f]):!!(Me==="application/xhtml+xml"&&mt[i.namespaceURI]):!1},Z=function(i){Ee(e.removed,{element:i});try{te(i).removeChild(i)}catch{xe(i)}},he=function(i,u){try{Ee(e.removed,{attribute:u.getAttributeNode(i),from:u})}catch{Ee(e.removed,{attribute:null,from:u})}if(u.removeAttribute(i),i==="is")if(we||qe)try{Z(u)}catch{}else try{u.setAttribute(i,"")}catch{}},an=function(i){let u=null,f=null;if(ut)i="<remove></remove>"+i;else{const O=bn(i,/^[\r\n\t ]+/);f=O&&O[0]}Me==="application/xhtml+xml"&&Ae===J&&(i='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+i+"</body></html>");const T=E?E.createHTML(i):i;if(Ae===J)try{u=new _().parseFromString(T,Me)}catch{}if(!u||!u.documentElement){u=be.createDocument(Ae,"template",null);try{u.documentElement.innerHTML=ft?Q:T}catch{}}const I=u.body||u.documentElement;return i&&f&&I.insertBefore(n.createTextNode(f),I.childNodes[0]||null),Ae===J?He.call(u,pe?"html":"body")[0]:pe?u.documentElement:I},ln=function(i){return Ue.call(i.ownerDocument||i,i,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},on=function(i){i.normalize();const u=Ue.call(i.ownerDocument||i,i,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let f=u.nextNode();for(;f;){let T=f.data;_e([v,ie,Te],I=>{T=Re(T,I," ")}),f.data=T,f=u.nextNode()}},bt=function(i){return i instanceof k&&(typeof i.nodeName!="string"||typeof i.textContent!="string"||typeof i.removeChild!="function"||!(i.attributes instanceof d)||typeof i.removeAttribute!="function"||typeof i.setAttribute!="function"||typeof i.namespaceURI!="string"||typeof i.insertBefore!="function"||typeof i.hasChildNodes!="function")},Ve=function(i){if(!ne||typeof i!="object"||i===null)return!1;try{return typeof ne(i)=="number"}catch{return!1}};function re(x,i,u){_e(x,f=>{f.call(e,i,u,Se)})}const cn=function(i){let u=null;if(re(g.beforeSanitizeElements,i,null),bt(i))return Z(i),!0;const f=M(i.nodeName);if(re(g.uponSanitizeElement,i,{tagName:f,allowedTags:z}),Le&&i.hasChildNodes()&&!Ve(i.firstElementChild)&&F(/<[/\w!]/g,i.innerHTML)&&F(/<[/\w!]/g,i.textContent)||Le&&i.namespaceURI===J&&f==="style"&&Ve(i.firstElementChild)||i.nodeType===Ne.progressingInstruction||Le&&i.nodeType===Ne.comment&&F(/<[/\w]/g,i.data))return Z(i),!0;if(Oe[f]||!(le.tagCheck instanceof Function&&le.tagCheck(f))&&!z[f]){if(!Oe[f]&&pn(f)&&(C.tagNameCheck instanceof RegExp&&F(C.tagNameCheck,f)||C.tagNameCheck instanceof Function&&C.tagNameCheck(f)))return!1;if(pt&&!K[f]){const T=te(i)||i.parentNode,I=S(i)||i.childNodes;if(I&&T){const O=I.length;for(let G=O-1;G>=0;--G){const ce=q(I[G],!0);T.insertBefore(ce,ke(i))}}}return Z(i),!0}return i instanceof p&&!lr(i)||(f==="noscript"||f==="noembed"||f==="noframes")&&F(/<\/no(script|embed|frames)/i,i.innerHTML)?(Z(i),!0):(oe&&i.nodeType===Ne.text&&(u=i.textContent,_e([v,ie,Te],T=>{u=Re(u,T," ")}),i.textContent!==u&&(Ee(e.removed,{element:i.cloneNode()}),i.textContent=u)),re(g.afterSanitizeElements,i,null),!1)},un=function(i,u,f){if(We[u]||Vt&&(u==="id"||u==="name")&&(f in n||f in ir))return!1;const T=$[u]||le.attributeCheck instanceof Function&&le.attributeCheck(u,i);if(!(ot&&!We[u]&&F(Kn,u))){if(!(Yt&&F(Jn,u))){if(!T||We[u]){if(!(pn(i)&&(C.tagNameCheck instanceof RegExp&&F(C.tagNameCheck,i)||C.tagNameCheck instanceof Function&&C.tagNameCheck(i))&&(C.attributeNameCheck instanceof RegExp&&F(C.attributeNameCheck,u)||C.attributeNameCheck instanceof Function&&C.attributeNameCheck(u,i))||u==="is"&&C.allowCustomizedBuiltInElements&&(C.tagNameCheck instanceof RegExp&&F(C.tagNameCheck,f)||C.tagNameCheck instanceof Function&&C.tagNameCheck(f))))return!1}else if(!dt[u]){if(!F(Gt,Re(f,Ht,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&i!=="script"&&Tn(f,"data:")===0&&Jt[i])){if(!(Zt&&!F(er,Re(f,Ht,"")))){if(f)return!1}}}}}}return!0},or=b({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),pn=function(i){return!or[je(i)]&&F(tr,i)},hn=function(i){re(g.beforeSanitizeAttributes,i,null);const u=i.attributes;if(!u||bt(i))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let T=u.length;for(;T--;){const I=u[T],O=I.name,G=I.namespaceURI,ce=I.value,se=M(O),wt=ce;let j=O==="value"?wt:Ur(wt);if(f.attrName=se,f.attrValue=j,f.keepAttr=!0,f.forceKeepAttr=void 0,re(g.uponSanitizeAttribute,i,f),j=f.attrValue,Qt&&(se==="id"||se==="name")&&Tn(j,Kt)!==0&&(he(O,i),j=Kt+j),Le&&F(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,j)){he(O,i);continue}if(se==="attributename"&&bn(j,"href")){he(O,i);continue}if(f.forceKeepAttr)continue;if(!f.keepAttr){he(O,i);continue}if(!Xt&&F(/\/>/i,j)){he(O,i);continue}oe&&_e([v,ie,Te],fn=>{j=Re(j,fn," ")});const dn=M(i.nodeName);if(!un(dn,se,j)){he(O,i);continue}if(E&&typeof w=="object"&&typeof w.getAttributeType=="function"&&!G)switch(w.getAttributeType(dn,se)){case"TrustedHTML":{j=E.createHTML(j);break}case"TrustedScriptURL":{j=E.createScriptURL(j);break}}if(j!==wt)try{G?i.setAttributeNS(G,O,j):i.setAttribute(O,j),bt(i)?Z(i):kn(e.removed)}catch{he(O,i)}}re(g.afterSanitizeAttributes,i,null)},Tt=function(i){let u=null;const f=ln(i);for(re(g.beforeSanitizeShadowDOM,i,null);u=f.nextNode();)re(g.uponSanitizeShadowNode,u,null),cn(u),hn(u),u.content instanceof a&&Tt(u.content);re(g.afterSanitizeShadowDOM,i,null)},Qe=function(i){if(i.nodeType===Ne.element&&i.shadowRoot instanceof a){const T=i.shadowRoot;Qe(T),Tt(T)}const u=i.childNodes;if(!u)return;const f=[];_e(u,T=>{Ee(f,T)});for(const T of f)Qe(T)};return e.sanitize=function(x){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,f=null,T=null,I=null;if(ft=!x,ft&&(x="<!-->"),typeof x!="string"&&!Ve(x)&&(x=qr(x),typeof x!="string"))throw Ke("dirty is not a string, aborting");if(!e.isSupported)return x;if(ct||kt(i),e.removed=[],typeof x=="string"&&(De=!1),De){const ce=x.nodeName;if(typeof ce=="string"){const se=M(ce);if(!z[se]||Oe[se])throw Ke("root node is forbidden and cannot be sanitized in-place")}Qe(x)}else if(Ve(x))u=an("<!---->"),f=u.ownerDocument.importNode(x,!0),f.nodeType===Ne.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?u=f:u.appendChild(f),Qe(f);else{if(!we&&!oe&&!pe&&x.indexOf("<")===-1)return E&&Ye?E.createHTML(x):x;if(u=an(x),!u)return we?null:Ye?Q:""}u&&ut&&Z(u.firstChild);const O=ln(De?x:u);for(;T=O.nextNode();)cn(T),hn(T),T.content instanceof a&&Tt(T.content);if(De)return oe&&on(x),x;if(we){if(oe&&on(u),qe)for(I=Be.call(u.ownerDocument);u.firstChild;)I.appendChild(u.firstChild);else I=u;return($.shadowroot||$.shadowrootmode)&&(I=Ge.call(s,I,!0)),I}let G=pe?u.outerHTML:u.innerHTML;return pe&&z["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&F(rs,u.ownerDocument.doctype.name)&&(G="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
3
3
  `+G),oe&&_e([v,ie,Te],ce=>{G=Re(G,ce," ")}),E&&Ye?E.createHTML(G):G},e.setConfig=function(){let x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};kt(x),ct=!0},e.clearConfig=function(){Se=null,ct=!1},e.isValidAttribute=function(x,i,u){Se||kt({});const f=M(x),T=M(i);return un(f,T,u)},e.addHook=function(x,i){typeof i=="function"&&Ee(g[x],i)},e.removeHook=function(x,i){if(i!==void 0){const u=$r(g[x],i);return u===-1?void 0:Fr(g[x],u,1)[0]}return kn(g[x])},e.removeHooks=function(x){g[x]=[]},e.removeAllHooks=function(){g=Nn()},e}var D=Un(),ls=D;D.sanitize.bind(D);D.isSupported;D.addHook.bind(D);D.removeHook.bind(D);D.removeHooks.bind(D);D.removeAllHooks.bind(D);D.setConfig.bind(D);D.clearConfig.bind(D);D.isValidAttribute.bind(D);D.version;D.removed;function Dt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ge=Dt();function Bn(t){ge=t}var fe={exec:()=>null};function ve(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),r=e[s];return r||(r=t(s),e[s]=r),r}}function y(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(U.caret,"$1"),n=n.replace(r,l),s},getRegex:()=>new RegExp(n,e)};return s}var os=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),U={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ve(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ve(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ve(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:ve(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:ve(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ve(t=>new RegExp(`^ {0,${t}}>`))},cs=/^(?:[ \t]*(?:\n|$))+/,us=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ps=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Fe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Mt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Hn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Gn=y(Hn).replace(/bull/g,Mt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ds=y(Hn).replace(/bull/g,Mt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fs=/^[^\n]+/,zt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ms=y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gs=y(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Mt).getRegex(),it="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",jt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xs=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",jt).replace("tag",it).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Wn=y(Pt).replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex(),ks=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Wn).getRegex(),$t={blockquote:ks,code:us,def:ms,fences:ps,heading:hs,hr:Fe,html:xs,lheading:Gn,list:gs,newline:cs,paragraph:Wn,table:fe,text:fs},vn=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex(),bs={...$t,lheading:ds,table:vn,paragraph:y(Pt).replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",vn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex()},Ts={...$t,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",jt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(Pt).replace("hr",Fe).replace("heading",` *#{1,6} *[^
4
4
  ]`).replace("lheading",Gn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ws=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ys=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qn=/^( {2,}|\\)\n(?!\s*$)/,As=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ie=/[\p{P}\p{S}]/u,lt=/[\s\p{P}\p{S}]/u,Ft=/[^\s\p{P}\p{S}]/u,Ss=y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,lt).getRegex(),Yn=/(?!~)[\p{P}\p{S}]/u,_s=/(?!~)[\s\p{P}\p{S}]/u,Es=/(?:[^\s\p{P}\p{S}]|~)/u,Rs=y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",os?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Zn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ns=y(Zn,"u").replace(/punct/g,Ie).getRegex(),vs=y(Zn,"u").replace(/punct/g,Yn).getRegex(),Xn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Cs=y(Xn,"gu").replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,lt).replace(/punct/g,Ie).getRegex(),Is=y(Xn,"gu").replace(/notPunctSpace/g,Es).replace(/punctSpace/g,_s).replace(/punct/g,Yn).getRegex(),Os=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,lt).replace(/punct/g,Ie).getRegex(),Ls=y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ie).getRegex(),Ds="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ms=y(Ds,"gu").replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,lt).replace(/punct/g,Ie).getRegex(),Ps=y(/\\(punct)/,"gu").replace(/punct/g,Ie).getRegex(),zs=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),js=y(jt).replace("(?:-->|$)","-->").getRegex(),$s=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",js).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),nt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Fs=y(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",nt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Vn=y(/^!?\[(label)\]\[(ref)\]/).replace("label",nt).replace("ref",zt).getRegex(),Qn=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",zt).getRegex(),Us=y("reflink|nolink(?!\\()","g").replace("reflink",Vn).replace("nolink",Qn).getRegex(),Cn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ut={_backpedal:fe,anyPunctuation:Ps,autolink:zs,blockSkip:Rs,br:qn,code:ys,del:fe,delLDelim:fe,delRDelim:fe,emStrongLDelim:Ns,emStrongRDelimAst:Cs,emStrongRDelimUnd:Os,escape:ws,link:Fs,nolink:Qn,punctuation:Ss,reflink:Vn,reflinkSearch:Us,tag:$s,text:As,url:fe},Bs={...Ut,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",nt).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",nt).getRegex()},Ct={...Ut,emStrongRDelimAst:Is,emStrongLDelim:vs,delLDelim:Ls,delRDelim:Ms,url:y(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Cn).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:y(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Cn).getRegex()},Hs={...Ct,br:y(qn).replace("{2,}","*").getRegex(),text:y(Ct.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},et={normal:$t,gfm:bs,pedantic:Ts},ze={normal:Ut,gfm:Ct,breaks:Hs,pedantic:Bs},Gs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},In=t=>Gs[t];function ee(t,e){if(e){if(U.escapeTest.test(t))return t.replace(U.escapeReplace,In)}else if(U.escapeTestNoEncode.test(t))return t.replace(U.escapeReplaceNoEncode,In);return t}function On(t){try{t=encodeURI(t).replace(U.percentDecode,"%")}catch{return null}return t}function Ln(t,e){let n=t.replace(U.findPipe,(a,l,o)=>{let p=!1,c=l;for(;--c>=0&&o[c]==="\\";)p=!p;return p?"|":" |"}),s=n.split(U.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(U.slashPipe,"|");return s}function ue(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s&&t.charAt(s-r-1)===e;)r++;return t.slice(0,s-r)}function Dn(t){let e=t.split(`
@@ -1 +1 @@
1
- import{c as I,j as e,u as M,a6 as le,a8 as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,a9 as pe,aa as he,T as S,X as xe,E as me,ab as Q,C as W,b as ee,ac as H,d as ke,ad as fe,ae as be,x as ge,y as je,af as we,t as ye}from"./index-B3XoRj0C.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],P=I("at-sign",ve);const Ne=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=I("corner-down-right",Ne);const _e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Te=I("file-code",_e);const Ce=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$e=I("save",Ce),B=s=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let r=0;for(;r<s.length;){const i=s.slice(r),o=i.match(/^\*\*([^*]+?)\*\*/);if(o?.[1]){c(),n.push(e.jsx("strong",{children:B(o[1])},a++)),r+=o[0].length;continue}const t=i.match(/^`([^`]+?)`/);if(t?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:t[1]},a++)),r+=t[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:B(u[1])},a++)),r+=u[0].length;continue}l+=s[r],r+=1}return c(),n},ze=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=M(),o=t=>{t.preventDefault(),r()};return e.jsxs("form",{onSubmit:o,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:s.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:s,onChange:t=>l(t.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(le,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(re,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx($e,{size:14}),i("tasks.raw.save")]})})]})},O=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],se=s=>{let n=0;for(let l=0;l<s.length;l+=1)n=n*31+s.charCodeAt(l)>>>0;return O[n%O.length]??O[0]},Se=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],q=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),X=new Set(["报告","report","文件","file","path","日志","log","产物"]),Ee=/^(.*?)\s*\(([^()]+)\)\s*$/,De=/\s*[·,,;;]\s*/,Re=/^([^::]+)[::]\s*(.+)$/,Me=s=>{for(const{pattern:n,tone:l}of Se)if(n.test(s))return l;return"neutral"},Le=s=>s.includes("/")||/^[A-Za-z]:\\/.test(s)||(s.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(s),Ae=s=>{const n=s.match(Ee);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(De).filter(Boolean),r=[];for(const i of c){const o=i.match(Re);if(!o){r.push({kind:"note",value:i.trim()});continue}const t=(o[1]??"").trim(),u=(o[2]??"").trim(),d=t.toLowerCase();q.has(d)||q.has(t)?r.push({kind:"owner",value:u}):G.has(d)||G.has(t)?r.push({kind:"status",value:u,tone:Me(u)}):X.has(d)||X.has(t)||Le(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Pe=({item:s,handlers:n})=>{if(s.kind==="status")return e.jsx("span",{className:`pill pill--${s.tone}`,"data-testid":"task-meta-status",children:s.value});if(s.kind==="owner"){const a={"--owner-tone":se(s.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":s.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(s.value)},style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":s.value,style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]})}return s.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${s.label}: ${s.value}`,children:[e.jsx(Q,{size:10,"aria-hidden":!0}),s.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:s.value})},Z=({initial:s,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,r]=f.useState(s),i=()=>{const t=c.trim();if(!t){l();return}n(t)},o=t=>{t.key==="Enter"?(t.preventDefault(),i()):t.key==="Escape"&&(t.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:t=>r(t.target.value),onKeyDown:o,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},V=({task:s,handlers:n,depth:l})=>{const{t:a}=M(),c=s.checked?ke:fe,{title:r,meta:i}=Ae(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[b,E]=f.useState(!1),[w,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:y,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:g=!1}=n,C=!!y&&!g,N=!!_&&!g,L=!!D&&!g,$=!!T,R=!o&&!u&&(C||N||L||$),z=s.children.length,x=be(s),A=l+1>=Y,K=z>0,te=b?a("tasks.aria.expandSubtasks",{count:z}):a("tasks.aria.collapseSubtasks",{count:z}),ae=k?{onSelectOwner:k}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${s.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Y?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:s.checked,disabled:g,onChange:()=>{g||p(s.line)},className:"sr-only","data-testid":`task-checkbox-${s.line}`,"aria-label":s.text||`task-line-${s.line}`}),e.jsx("span",{className:`task-row__indicator ${s.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:o?e.jsx(Z,{initial:s.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:h=>{t(!1),y?.(s.line,h)},onCancel:()=>t(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${s.checked?"text-ter line-through":"text-pri"}`,children:B(r)}),K?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:h=>{h.stopPropagation(),E(j=>!j)},"data-testid":`task-collapse-${s.line}`,"aria-expanded":!b,"aria-label":te,children:b?e.jsx(ee,{size:12,"aria-hidden":!0}):e.jsx(W,{size:12,"aria-hidden":!0})}):null,x?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${s.line}`,title:a("tasks.progress.subtaskTitle",{done:x.done,total:x.total}),children:[x.done,"/",x.total]}):null]}),i.length>0||s.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(h=>e.jsx(Pe,{item:h,handlers:ae},`${s.line}-meta-${h.kind}-${"label"in h?h.label:""}-${h.value}`)),s.mentions.map(h=>{const j=h.replace(/^@/,""),F={"--owner-tone":se(j)};return k?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${j}`,"data-owner":j,onClick:ne=>{ne.stopPropagation(),k(j)},style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${j}`,"data-owner":j,style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`)})]}):null]})}),R?e.jsxs("div",{className:"task-row__actions pointer-coarse:opacity-100",children:[$?e.jsx(S,{label:a(w?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{T?.(s.line),v(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{v(!1),m.current=null},1500)},"data-testid":`task-copy-${s.line}`,"aria-label":a(w?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:w?e.jsx(ge,{size:12}):e.jsx(je,{size:12})})}):null,C?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>t(!0),"data-testid":`task-edit-${s.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,L?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{E(!1),d(!0)},"data-testid":`task-add-subtask-${s.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(U,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>_?.(s.line),"data-testid":`task-delete-${s.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),z>0&&!b||u?e.jsxs("ul",{className:`task-children${A?" task-children--deep":""}`,"data-testid":`task-children-${s.line}`,children:[b?null:s.children.map(h=>e.jsx(V,{depth:l+1,handlers:n,task:h},h.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(U,{size:12})}),e.jsx(Z,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:h=>{d(!1),D?.(s.line,h)},onCancel:()=>d(!1)})]})}):null]}):null]})},J=({onSubmit:s,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=M(),[c,r]=f.useState(!1),[i,o]=f.useState(""),t=()=>{const d=i.trim();if(!d){r(!1);return}s(d),o("")},u=d=>{d.key==="Enter"?(d.preventDefault(),t()):d.key==="Escape"&&(d.preventDefault(),o(""),r(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(H,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:d=>o(d.target.value),onKeyDown:u,onBlur:t,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(H,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ie=s=>{let n=0,l=0;const a=[],c=[],r=o=>{n+=1,o.checked&&(l+=1);for(const t of o.children)r(t)};for(const o of s)o.checked?c.push(o):a.push(o),r(o);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ke=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:b,workspacePath:E,knownWorkerNames:w,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=M(),[y,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const A=s.split(/\r?\n/)[x];typeof A=="string"&&navigator.clipboard?.writeText(A).catch(K=>{console.error("[hive] swallowed:tasks.copyLine",K)})},...d&&!m?{onUpdateText:d}:{},...b&&!m?{onDelete:b}:{},...u&&!m?{onAppendSubtask:u}:{},...v?{onSelectOwner:v}:{},...m?{writeDisabled:!0}:{}},k=f.useMemo(()=>pe(s,w?{knownWorkerNames:w}:{}),[s,w]),{completedTasks:g,completionPercent:C,doneRoots:N,openRoots:L,totalTasks:$}=f.useMemo(()=>Ie(k),[k]),[R,z]=f.useState(N.length<=3);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"task-graph-content",children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(he,{size:16,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:p("tasks.title.todo")}),$>0?e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{background:C===100?"color-mix(in oklab, var(--status-green) 18%, transparent)":"var(--bg-3)",color:C===100?"var(--status-green)":"var(--text-secondary)"},"data-testid":"task-graph-summary",children:e.jsxs("span",{"data-testid":"task-progress-text",children:[g,"/",$]})}):null]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(S,{label:p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>_(x=>!x),"data-testid":"task-raw-toggle",className:"icon-btn pointer-coarse:min-h-10","aria-label":p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Te,{size:14})})}),l?e.jsx(S,{label:p("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":p("tasks.action.closeTodo"),className:"icon-btn pointer-coarse:min-h-10",children:e.jsx(xe,{size:14})})}):null]})]}),!y&&$>0?e.jsx("div",{"aria-label":p("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":C,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${C}%`}})}):null,e.jsx("div",{className:"scroll-y flex-1 px-3 py-2.5 text-sm",children:y?e.jsx(ze,{content:s,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i}):k.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(Q,{size:20}),title:p("tasks.empty.title"),description:p("tasks.empty.description"),...t?{action:e.jsx(J,{variant:"primary",disabled:m,onSubmit:t})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line)),t?e.jsx("li",{children:e.jsx(J,{disabled:m,onSubmit:t})}):null]}),N.length>0?e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>z(x=>!x),"aria-expanded":R,"data-testid":"task-completed-toggle",className:"task-completed-toggle pointer-coarse:min-h-10",children:[R?e.jsx(W,{size:11,"aria-hidden":!0}):e.jsx(ee,{size:11,"aria-hidden":!0}),e.jsx("span",{children:p("tasks.completed.toggle",{count:N.length})}),e.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[9px] tabular-nums",style:{background:"var(--bg-3)",color:"var(--text-tertiary)"},children:N.length})]}),R?e.jsx("ul",{className:"task-list mt-1","data-testid":"task-completed-list",children:N.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line))}):null]}):null]})})]})},Be=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:b,open:E,workspacePath:w,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:y}=M(),_=ie(),D=k=>{if(k.key!=="Escape")return;const g=k.target?.tagName;g==="INPUT"||g==="TEXTAREA"||(k.preventDefault(),l())},T=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${p?" task-dialog--stale":""}`;return e.jsx(oe,{open:E,onOpenChange:k=>!k&&l(),children:e.jsxs(ce,{children:[e.jsx(de,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ue,{"aria-label":y("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":p||void 0,"data-mobile":_||void 0,onEscapeKeyDown:k=>k.preventDefault(),onKeyDown:D,className:T,style:_?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 64px))",width:"min(640px, calc(100vw - 48px))"},children:e.jsx(Ke,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:w,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...b?{onDeleteTask:b}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Ke as TaskGraphContent,Be as TaskGraphDrawer};
1
+ import{c as I,j as e,u as M,a6 as le,a8 as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,a9 as pe,aa as he,T as S,X as xe,E as me,ab as Q,C as W,b as ee,ac as H,d as ke,ad as fe,ae as be,x as ge,y as je,af as we,t as ye}from"./index-BEyvsWk6.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],P=I("at-sign",ve);const Ne=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=I("corner-down-right",Ne);const _e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Te=I("file-code",_e);const Ce=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$e=I("save",Ce),B=s=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let r=0;for(;r<s.length;){const i=s.slice(r),o=i.match(/^\*\*([^*]+?)\*\*/);if(o?.[1]){c(),n.push(e.jsx("strong",{children:B(o[1])},a++)),r+=o[0].length;continue}const t=i.match(/^`([^`]+?)`/);if(t?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:t[1]},a++)),r+=t[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:B(u[1])},a++)),r+=u[0].length;continue}l+=s[r],r+=1}return c(),n},ze=({content:s,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=M(),o=t=>{t.preventDefault(),r()};return e.jsxs("form",{onSubmit:o,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:s.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:s,onChange:t=>l(t.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(le,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(re,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx($e,{size:14}),i("tasks.raw.save")]})})]})},O=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],se=s=>{let n=0;for(let l=0;l<s.length;l+=1)n=n*31+s.charCodeAt(l)>>>0;return O[n%O.length]??O[0]},Se=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],q=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),X=new Set(["报告","report","文件","file","path","日志","log","产物"]),Ee=/^(.*?)\s*\(([^()]+)\)\s*$/,De=/\s*[·,,;;]\s*/,Re=/^([^::]+)[::]\s*(.+)$/,Me=s=>{for(const{pattern:n,tone:l}of Se)if(n.test(s))return l;return"neutral"},Le=s=>s.includes("/")||/^[A-Za-z]:\\/.test(s)||(s.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(s),Ae=s=>{const n=s.match(Ee);if(!n)return{title:s,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:s,meta:[]};const c=a.split(De).filter(Boolean),r=[];for(const i of c){const o=i.match(Re);if(!o){r.push({kind:"note",value:i.trim()});continue}const t=(o[1]??"").trim(),u=(o[2]??"").trim(),d=t.toLowerCase();q.has(d)||q.has(t)?r.push({kind:"owner",value:u}):G.has(d)||G.has(t)?r.push({kind:"status",value:u,tone:Me(u)}):X.has(d)||X.has(t)||Le(u)?r.push({kind:"path",label:t,value:u}):r.push({kind:"note",value:`${t}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Pe=({item:s,handlers:n})=>{if(s.kind==="status")return e.jsx("span",{className:`pill pill--${s.tone}`,"data-testid":"task-meta-status",children:s.value});if(s.kind==="owner"){const a={"--owner-tone":se(s.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":s.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(s.value)},style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":s.value,style:a,children:[e.jsx(P,{size:10,"aria-hidden":!0}),s.value]})}return s.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${s.label}: ${s.value}`,children:[e.jsx(Q,{size:10,"aria-hidden":!0}),s.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:s.value})},Z=({initial:s,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,r]=f.useState(s),i=()=>{const t=c.trim();if(!t){l();return}n(t)},o=t=>{t.key==="Enter"?(t.preventDefault(),i()):t.key==="Escape"&&(t.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:t=>r(t.target.value),onKeyDown:o,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},V=({task:s,handlers:n,depth:l})=>{const{t:a}=M(),c=s.checked?ke:fe,{title:r,meta:i}=Ae(s.text),[o,t]=f.useState(!1),[u,d]=f.useState(!1),[b,E]=f.useState(!1),[w,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:y,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:g=!1}=n,C=!!y&&!g,N=!!_&&!g,L=!!D&&!g,$=!!T,R=!o&&!u&&(C||N||L||$),z=s.children.length,x=be(s),A=l+1>=Y,K=z>0,te=b?a("tasks.aria.expandSubtasks",{count:z}):a("tasks.aria.collapseSubtasks",{count:z}),ae=k?{onSelectOwner:k}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${s.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Y?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:s.checked,disabled:g,onChange:()=>{g||p(s.line)},className:"sr-only","data-testid":`task-checkbox-${s.line}`,"aria-label":s.text||`task-line-${s.line}`}),e.jsx("span",{className:`task-row__indicator ${s.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:o?e.jsx(Z,{initial:s.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:h=>{t(!1),y?.(s.line,h)},onCancel:()=>t(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${s.checked?"text-ter line-through":"text-pri"}`,children:B(r)}),K?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:h=>{h.stopPropagation(),E(j=>!j)},"data-testid":`task-collapse-${s.line}`,"aria-expanded":!b,"aria-label":te,children:b?e.jsx(ee,{size:12,"aria-hidden":!0}):e.jsx(W,{size:12,"aria-hidden":!0})}):null,x?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${s.line}`,title:a("tasks.progress.subtaskTitle",{done:x.done,total:x.total}),children:[x.done,"/",x.total]}):null]}),i.length>0||s.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(h=>e.jsx(Pe,{item:h,handlers:ae},`${s.line}-meta-${h.kind}-${"label"in h?h.label:""}-${h.value}`)),s.mentions.map(h=>{const j=h.replace(/^@/,""),F={"--owner-tone":se(j)};return k?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${j}`,"data-owner":j,onClick:ne=>{ne.stopPropagation(),k(j)},style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${j}`,"data-owner":j,style:F,children:[e.jsx(P,{size:10,"aria-hidden":!0}),j]},`${s.line}-mention-${h}`)})]}):null]})}),R?e.jsxs("div",{className:"task-row__actions pointer-coarse:opacity-100",children:[$?e.jsx(S,{label:a(w?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{T?.(s.line),v(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{v(!1),m.current=null},1500)},"data-testid":`task-copy-${s.line}`,"aria-label":a(w?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:w?e.jsx(ge,{size:12}):e.jsx(je,{size:12})})}):null,C?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>t(!0),"data-testid":`task-edit-${s.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,L?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{E(!1),d(!0)},"data-testid":`task-add-subtask-${s.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(U,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>_?.(s.line),"data-testid":`task-delete-${s.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),z>0&&!b||u?e.jsxs("ul",{className:`task-children${A?" task-children--deep":""}`,"data-testid":`task-children-${s.line}`,children:[b?null:s.children.map(h=>e.jsx(V,{depth:l+1,handlers:n,task:h},h.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(U,{size:12})}),e.jsx(Z,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:h=>{d(!1),D?.(s.line,h)},onCancel:()=>d(!1)})]})}):null]}):null]})},J=({onSubmit:s,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=M(),[c,r]=f.useState(!1),[i,o]=f.useState(""),t=()=>{const d=i.trim();if(!d){r(!1);return}s(d),o("")},u=d=>{d.key==="Enter"?(d.preventDefault(),t()):d.key==="Escape"&&(d.preventDefault(),o(""),r(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(H,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:d=>o(d.target.value),onKeyDown:u,onBlur:t,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(H,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ie=s=>{let n=0,l=0;const a=[],c=[],r=o=>{n+=1,o.checked&&(l+=1);for(const t of o.children)r(t)};for(const o of s)o.checked?c.push(o):a.push(o),r(o);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ke=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:b,workspacePath:E,knownWorkerNames:w,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=M(),[y,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const A=s.split(/\r?\n/)[x];typeof A=="string"&&navigator.clipboard?.writeText(A).catch(K=>{console.error("[hive] swallowed:tasks.copyLine",K)})},...d&&!m?{onUpdateText:d}:{},...b&&!m?{onDelete:b}:{},...u&&!m?{onAppendSubtask:u}:{},...v?{onSelectOwner:v}:{},...m?{writeDisabled:!0}:{}},k=f.useMemo(()=>pe(s,w?{knownWorkerNames:w}:{}),[s,w]),{completedTasks:g,completionPercent:C,doneRoots:N,openRoots:L,totalTasks:$}=f.useMemo(()=>Ie(k),[k]),[R,z]=f.useState(N.length<=3);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"task-graph-content",children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(he,{size:16,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:p("tasks.title.todo")}),$>0?e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{background:C===100?"color-mix(in oklab, var(--status-green) 18%, transparent)":"var(--bg-3)",color:C===100?"var(--status-green)":"var(--text-secondary)"},"data-testid":"task-graph-summary",children:e.jsxs("span",{"data-testid":"task-progress-text",children:[g,"/",$]})}):null]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(S,{label:p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>_(x=>!x),"data-testid":"task-raw-toggle",className:"icon-btn pointer-coarse:min-h-10","aria-label":p(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Te,{size:14})})}),l?e.jsx(S,{label:p("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":p("tasks.action.closeTodo"),className:"icon-btn pointer-coarse:min-h-10",children:e.jsx(xe,{size:14})})}):null]})]}),!y&&$>0?e.jsx("div",{"aria-label":p("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":C,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${C}%`}})}):null,e.jsx("div",{className:"scroll-y flex-1 px-3 py-2.5 text-sm",children:y?e.jsx(ze,{content:s,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i}):k.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(Q,{size:20}),title:p("tasks.empty.title"),description:p("tasks.empty.description"),...t?{action:e.jsx(J,{variant:"primary",disabled:m,onSubmit:t})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line)),t?e.jsx("li",{children:e.jsx(J,{disabled:m,onSubmit:t})}):null]}),N.length>0?e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>z(x=>!x),"aria-expanded":R,"data-testid":"task-completed-toggle",className:"task-completed-toggle pointer-coarse:min-h-10",children:[R?e.jsx(W,{size:11,"aria-hidden":!0}):e.jsx(ee,{size:11,"aria-hidden":!0}),e.jsx("span",{children:p("tasks.completed.toggle",{count:N.length})}),e.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[9px] tabular-nums",style:{background:"var(--bg-3)",color:"var(--text-tertiary)"},children:N.length})]}),R?e.jsx("ul",{className:"task-list mt-1","data-testid":"task-completed-list",children:N.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line))}):null]}):null]})})]})},Be=({content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:t,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:b,open:E,workspacePath:w,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:y}=M(),_=ie(),D=k=>{if(k.key!=="Escape")return;const g=k.target?.tagName;g==="INPUT"||g==="TEXTAREA"||(k.preventDefault(),l())},T=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${p?" task-dialog--stale":""}`;return e.jsx(oe,{open:E,onOpenChange:k=>!k&&l(),children:e.jsxs(ce,{children:[e.jsx(de,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ue,{"aria-label":y("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":p||void 0,"data-mobile":_||void 0,onEscapeKeyDown:k=>k.preventDefault(),onKeyDown:D,className:T,style:_?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 64px))",width:"min(640px, calc(100vw - 48px))"},children:e.jsx(Ke,{content:s,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:w,...t?{onAppendTask:t}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...b?{onDeleteTask:b}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{Ke as TaskGraphContent,Be as TaskGraphDrawer};
@@ -1 +1 @@
1
- import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a0 as f}from"./index-B3XoRj0C.js";const b=({open:r,entries:n,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:r,onOpenChange:c,children:e.jsxs(h,{children:[e.jsx(m,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(p,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-6 pt-6",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"scroll-y mx-6 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto pr-3",children:n.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"flex shrink-0 justify-end border-t px-6 py-5",style:{borderColor:"var(--border)"},children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{b as WhatsNewDialog};
1
+ import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a0 as f}from"./index-BEyvsWk6.js";const b=({open:r,entries:n,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:r,onOpenChange:c,children:e.jsxs(h,{children:[e.jsx(m,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(p,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-6 pt-6",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"scroll-y mx-6 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto pr-3",children:n.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"flex shrink-0 justify-end border-t px-6 py-5",style:{borderColor:"var(--border)"},children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{b as WhatsNewDialog};
@@ -0,0 +1 @@
1
+ import{r as d,u as C,i as N,aj as f,j as e,R,P as M,O as E,k as S,m as L,a0 as O,a6 as D,T as y,z as j,X as I,ak as W,q as A,al as T,am as P}from"./index-BEyvsWk6.js";const _=r=>{switch(r){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"sentinel":return{badgeClass:"role-badge--sentinel",label:"Sentinel"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(r)}}},k="hive.worker-modal.width",u=480,F=.5,p=r=>{const n=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(r,u),Math.max(u,n))},g=()=>typeof window>"u"?u:p(Math.round(window.innerWidth*F)),K=()=>{try{const r=localStorage.getItem(k);if(!r)return g();const n=Number.parseInt(r,10);return Number.isFinite(n)?p(n):g()}catch{return g()}},X=()=>{const[r,n]=d.useState(()=>K()),[m,c]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(k,String(Math.round(r)))}catch{}},[r]),d.useEffect(()=>{const a=()=>{n(t=>p(t))};return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const b=d.useCallback(a=>t=>{t.preventDefault();const s=t.clientX,x=r;c(!0);const h=document.body.style.cursor,v=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=l=>{const w=l.clientX-s,z=a==="left"?x-2*w:x+2*w;n(p(z))},i=()=>{c(!1),document.body.style.cursor=h,document.body.style.userSelect=v,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)},[r]);return{width:r,resizing:m,beginResize:b}},U=({onClose:r,onStart:n,runId:m,startError:c,starting:b,worker:a})=>{const{t}=C(),s=N(),x=_(a.role),h=!!m,v=T(h),o=X();d.useLayoutEffect(()=>{if(!s)return;const l=P();return f(!0),()=>f(l)},[s]);const i=l=>{l||r()};return e.jsx(R,{open:!0,onOpenChange:i,children:e.jsxs(M,{children:[e.jsx(E,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(S,{"data-testid":"worker-modal","aria-label":t("worker.detail",{name:a.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden","data-mobile":s||void 0,onEscapeKeyDown:l=>l.preventDefault(),style:s?{background:"var(--bg-1)"}:{background:"var(--bg-1)",width:`${o.width}px`},children:[s?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":t("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":t("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("right")})]}),e.jsx(L,{className:"sr-only",children:a.name}),e.jsxs(O,{className:"sr-only",children:[x.label," agent — status ",v.label]}),c?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(D,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:c})]}):null,s?null:e.jsx("div",{className:"pointer-events-none absolute top-2 left-1/2 z-10 -translate-x-1/2 rounded border px-2 py-1 text-[11px]","data-testid":"worker-modal-close-hint",style:{background:"color-mix(in oklab, var(--bg-1) 88%, transparent)",borderColor:"var(--border)",color:"var(--text-tertiary)"},children:t("worker.closeOutsideHint")}),e.jsxs("div",{className:`relative flex min-h-0 flex-1 flex-col${s?"":" p-3"}`,"data-testid":"worker-modal-terminal-slot",children:[s?e.jsx(y,{label:t("common.close"),children:e.jsx(j,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:"float-action absolute top-2 right-2 z-10",style:{minHeight:44,minWidth:44},children:e.jsx(I,{size:16,"aria-hidden":!0})})})}):e.jsx(y,{label:t("common.close"),children:e.jsx(j,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:"sr-only",children:t("common.close")})})}),e.jsx("div",{className:`flex min-h-0 flex-1${s?"":" rounded-lg border"}`,style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:h?e.jsx("div",{id:`worker-pty-${m}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(W,{commandPresetId:a.commandPresetId,workerRole:a.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:a.name}),e.jsxs("div",{className:"text-xs text-ter",children:[a.status==="stopped"?t("worker.terminalStopped"):t("worker.terminalNotStarted"),t("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>n(a),disabled:b,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",t(b?"common.starting":"common.start")]})]})})]})]})})]})})};export{U as WorkerModal};
@@ -1 +1 @@
1
- import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-B3XoRj0C.js";import{S as Z}from"./square-terminal-DnmshYpr.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
1
+ import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-BEyvsWk6.js";import{S as Z}from"./square-terminal-BZ7EavxU.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
@@ -1 +1 @@
1
- import{c as g,i as te,u as W,r as c,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as ce,m as de,T as j,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as U,Z as fe}from"./index-B3XoRj0C.js";import{S as je}from"./search-BdM5IXYB.js";const ge=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ye=g("archive",ge);const ve=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ne=g("eye-off",ve);const we=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ke=g("pin-off",we);const Se=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],$e=g("pin",Se);const Ce=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Me=g("settings-2",Ce),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Re=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},_e=r=>r==="dreams"?null:r,Ee=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,d]=c.useState(!1),{t:o}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":i,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.scope==="user"?e.jsx("span",{className:"text-ter",children:o("memory.scopeUser")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Re(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})}),s.procedureRef?e.jsx("span",{children:`${s.procedureRef.type}: ${s.procedureRef.title??s.procedureRef.id}`}):null]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx($e,{size:13})})}),e.jsx(j,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(j,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},Q=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),De=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=c.useState(!1),{t:i}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:De(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(j,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(d=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${d.kind} scale-90 origin-left inline-block mr-1`,children:i(G[d.kind])}),d.body]})]},d.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),i("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(d=>d.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),i("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(d=>d.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),i("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(d=>d.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,d]=c.useState("active"),[o,m]=c.useState(""),[y,$]=c.useState([]),[v,C]=c.useState([]),[M,N]=c.useState(null),[q,T]=c.useState(!1),[L,x]=c.useState(null),[J,B]=c.useState(null),[R,w]=c.useState(null),[_,E]=c.useState(null),[D,z]=c.useState(null),[A,F]=c.useState(!1),b=c.useRef(0),X=c.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=_e(i),f=c.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){$([]),C([]),N(null),T(!1);return}T(!0),x(null),$([]),C([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,scope:"all",status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),$(h),C(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);c.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=c.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(ce,{"data-testid":"memory-drawer","aria-label":n("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(de,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(j,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>d(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:n("memory.searchPlaceholder")}),e.jsx(je,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[L?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:L}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:R!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[R==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(Q,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:R===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(Ee,{memory:t,busy:J===t.id,onArchive:E,onToggleDisabled:l=>P(l,h=>U(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>U(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:_!==null,onOpenChange:t=>{t||E(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!_)return;const t=_;E(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:D!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!D)return;const t=D;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
1
+ import{c as g,i as te,u as W,r as c,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as ce,m as de,T as j,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as U,Z as fe}from"./index-BEyvsWk6.js";import{S as je}from"./search-Cv0KnMjw.js";const ge=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ye=g("archive",ge);const ve=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ne=g("eye-off",ve);const we=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ke=g("pin-off",we);const Se=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],$e=g("pin",Se);const Ce=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Me=g("settings-2",Ce),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Re=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},_e=r=>r==="dreams"?null:r,Ee=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,d]=c.useState(!1),{t:o}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":i,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.scope==="user"?e.jsx("span",{className:"text-ter",children:o("memory.scopeUser")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Re(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})}),s.procedureRef?e.jsx("span",{children:`${s.procedureRef.type}: ${s.procedureRef.title??s.procedureRef.id}`}):null]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx($e,{size:13})})}),e.jsx(j,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(j,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},Q=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),De=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=c.useState(!1),{t:i}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:De(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(j,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(d=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${d.kind} scale-90 origin-left inline-block mr-1`,children:i(G[d.kind])}),d.body]})]},d.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),i("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(d=>d.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),i("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(d=>d.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),i("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(d=>d.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,d]=c.useState("active"),[o,m]=c.useState(""),[y,$]=c.useState([]),[v,C]=c.useState([]),[M,N]=c.useState(null),[q,T]=c.useState(!1),[L,x]=c.useState(null),[J,B]=c.useState(null),[R,w]=c.useState(null),[_,E]=c.useState(null),[D,z]=c.useState(null),[A,F]=c.useState(!1),b=c.useRef(0),X=c.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=_e(i),f=c.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){$([]),C([]),N(null),T(!1);return}T(!0),x(null),$([]),C([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,scope:"all",status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),$(h),C(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);c.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=c.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(ce,{"data-testid":"memory-drawer","aria-label":n("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(de,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(j,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>d(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:n("memory.searchPlaceholder")}),e.jsx(je,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[L?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:L}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:R!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[R==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(Q,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:R===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(Ee,{memory:t,busy:J===t.id,onArchive:E,onToggleDisabled:l=>P(l,h=>U(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>U(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:_!==null,onOpenChange:t=>{t||E(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!_)return;const t=_;E(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:D!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!D)return;const t=D;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
@@ -1 +1 @@
1
- import{r as k,j as h,_ as e}from"./index-B3XoRj0C.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-DDhX2p_z.js";const u=({tasksFile:a,workspacePath:T,open:c,onClose:r,workers:n,onSelectOwner:p,connectionStale:d})=>{const s=k.useMemo(()=>n?.length?n.map(o=>o.name):void 0,[n]);return h.jsx(g,{content:a.content,hasConflict:a.hasConflict,onClose:r,onContentChange:a.onChange,onKeepLocal:a.onKeepLocal,onReload:a.onReload,onSave:a.onSave,onToggleTaskLine:o=>{a.toggleTaskAtLine(o).catch(e("tasks.toggleTaskAtLine"))},onAppendTask:o=>{a.appendTask(o).catch(e("tasks.appendTask"))},onAppendSubtask:(o,t)=>{a.appendSubtask(o,t).catch(e("tasks.appendSubtask"))},onUpdateTaskText:(o,t)=>{a.updateTaskText(o,t).catch(e("tasks.updateTaskText"))},onDeleteTask:o=>{a.deleteTask(o).catch(e("tasks.deleteTask"))},open:c,workspacePath:T,...s?{knownWorkerNames:s}:{},...p?{onSelectOwner:p}:{},...d!==void 0?{connectionStale:d}:{}})};export{u as WorkspaceTaskDrawer};
1
+ import{r as k,j as h,_ as e}from"./index-BEyvsWk6.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-9mXNimSE.js";const u=({tasksFile:a,workspacePath:T,open:c,onClose:r,workers:n,onSelectOwner:p,connectionStale:d})=>{const s=k.useMemo(()=>n?.length?n.map(o=>o.name):void 0,[n]);return h.jsx(g,{content:a.content,hasConflict:a.hasConflict,onClose:r,onContentChange:a.onChange,onKeepLocal:a.onKeepLocal,onReload:a.onReload,onSave:a.onSave,onToggleTaskLine:o=>{a.toggleTaskAtLine(o).catch(e("tasks.toggleTaskAtLine"))},onAppendTask:o=>{a.appendTask(o).catch(e("tasks.appendTask"))},onAppendSubtask:(o,t)=>{a.appendSubtask(o,t).catch(e("tasks.appendSubtask"))},onUpdateTaskText:(o,t)=>{a.updateTaskText(o,t).catch(e("tasks.updateTaskText"))},onDeleteTask:o=>{a.deleteTask(o).catch(e("tasks.deleteTask"))},open:c,workspacePath:T,...s?{knownWorkerNames:s}:{},...p?{onSelectOwner:p}:{},...d!==void 0?{connectionStale:d}:{}})};export{u as WorkspaceTaskDrawer};