duclaw-cli 1.9.9 → 1.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1009 -933
- package/dist/main.js +1 -1
- package/dist/web/assets/{index-CiEOENzL.js → index-DnD9jpKq.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +2 -1
|
@@ -89,7 +89,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
89
89
|
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Vj(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=RM.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function JM(){return{exit:{taskListCheckValueChecked:XM,taskListCheckValueUnchecked:XM,paragraph:ZM}}}function YM(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:QM}}}function XM(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function ZM(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function QM(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=RM.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function $M(){return[aj(),kj(),Pj(),zM(),JM()]}function eN(e){return{extensions:[oj(),Aj(e),Fj(),qM(e),YM()]}}var tN={tokenize:hN,partial:!0},nN={tokenize:gN,partial:!0},rN={tokenize:_N,partial:!0},iN={tokenize:vN,partial:!0},aN={tokenize:yN,partial:!0},oN={name:`wwwAutolink`,tokenize:pN,previous:bN},sN={name:`protocolAutolink`,tokenize:mN,previous:xN},cN={name:`emailAutolink`,tokenize:fN,previous:SN},lN={};function uN(){return{text:lN}}for(var dN=48;dN<123;)lN[dN]=cN,dN++,dN===58?dN=65:dN===91&&(dN=97);lN[43]=cN,lN[45]=cN,lN[46]=cN,lN[95]=cN,lN[72]=[cN,sN],lN[104]=[cN,sN],lN[87]=[cN,oN],lN[119]=[cN,oN];function fN(e,t,n){let r=this,i,a;return o;function o(t){return!CN(t)||!SN.call(r,r.previous)||wN(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return CN(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(aN,u,l)(t):t===45||t===95||oE(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&aE(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function pN(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!bN.call(r,r.previous)||wN(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(tN,e.attempt(nN,e.attempt(rN,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function mN(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&xN.call(r,r.previous)&&!wN(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(aE(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||cE(t)||fE(t)||hE(t)||mE(t)?n(t):e.attempt(nN,e.attempt(rN,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function hN(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function gN(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(iN,c,s)(t):t===null||fE(t)||hE(t)||t!==45&&mE(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function _N(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(iN,t,a)(o):o===null||fE(o)||hE(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function vN(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||fE(o)||hE(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||fE(e)||hE(e)?t(e):r(e)}function a(e){return aE(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):aE(t)?(e.consume(t),o):n(t)}}function yN(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return oE(e)?n(e):t(e)}}function bN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||fE(e)}function xN(e){return!aE(e)}function SN(e){return!(e===47||CN(e))}function CN(e){return e===43||e===45||e===46||e===95||oE(e)}function wN(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var TN={tokenize:NN,partial:!0};function EN(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:AN,continuation:{tokenize:jN},exit:MN}},text:{91:{name:`gfmFootnoteCall`,tokenize:kN},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:DN,resolveTo:ON}}}}function DN(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=iE(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ON(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function kN(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||fE(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(iE(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return fE(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function AN(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||fE(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=iE(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return fE(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),vE(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function jN(e,t,n){return e.check(NE,t,e.attempt(TN,t,n))}function MN(e){e.exit(`gfmFootnoteDefinition`)}function NN(e,t,n){let r=this;return vE(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function PN(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&ZT(o,o.length,0,EE(s,e.slice(r+1,n),t)),ZT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ZT(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=TE(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=TE(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var FN=class{constructor(){this.map=[]}add(e,t,n){IN(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function IN(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function LN(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function RN(){return{flow:{null:{name:`table`,tokenize:zN,resolveAll:BN}}}}function zN(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):pE(t)?vE(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||fE(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,pE(t)?vE(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return pE(t)?vE(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return pE(t)?vE(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):pE(n)?vE(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||fE(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function BN(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new FN;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(HN(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=VN(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=VN(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=VN(f,t,o,i,n,d)):(o[0]=o[1],d=VN(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&HN(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=LN(t.events,n))}return e}function VN(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},UN(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=UN(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=UN(t.events,n[2]),a=UN(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},UN(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function HN(e,t,n,r,i){let a=[],o=UN(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function UN(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var WN={name:`tasklistCheck`,tokenize:KN};function GN(){return{text:{91:WN}}}function KN(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return fE(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):pE(r)?e.check({tokenize:qN},t,n)(r):n(r)}}function qN(e,t,n){return vE(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function JN(e){return eE([uN(),EN(),PN(e),RN(),GN()])}var YN={};function XN(e){let t=this,n=e||YN,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(JN(n)),a.push($M()),o.push(eN(n))}var ZN={h1:({className:e,...t})=>(0,B.jsx)(`h1`,{className:K(`text-lg font-semibold tracking-tight`,e),...t}),h2:({className:e,...t})=>(0,B.jsx)(`h2`,{className:K(`text-base font-semibold tracking-tight`,e),...t}),h3:({className:e,...t})=>(0,B.jsx)(`h3`,{className:K(`text-sm font-semibold tracking-tight`,e),...t}),p:({className:e,...t})=>(0,B.jsx)(`p`,{className:K(`my-0`,e),...t}),ul:({className:e,...t})=>(0,B.jsx)(`ul`,{className:K(`my-0 ml-5 list-disc space-y-1.5`,e),...t}),ol:({className:e,...t})=>(0,B.jsx)(`ol`,{className:K(`my-0 ml-5 list-decimal space-y-1.5`,e),...t}),li:({className:e,...t})=>(0,B.jsx)(`li`,{className:K(`pl-1`,e),...t}),blockquote:({className:e,...t})=>(0,B.jsx)(`blockquote`,{className:K(`my-0 border-l-2 border-border/80 pl-4 text-muted-foreground italic dark:border-white/10`,e),...t}),a:({className:e,...t})=>(0,B.jsx)(`a`,{className:K(`font-medium text-primary underline underline-offset-4`,e),target:`_blank`,rel:`noreferrer`,...t}),code:({className:e,...t})=>(0,B.jsx)(`code`,{className:K(`rounded-md bg-black/5 px-1.5 py-0.5 font-mono text-[0.85em] dark:bg-white/10`,e),...t}),pre:({className:e,...t})=>(0,B.jsx)(`pre`,{className:K(`my-0 overflow-x-auto rounded-2xl border border-border/70 bg-black/5 p-3 text-[0.85em] leading-6 dark:border-white/10 dark:bg-white/6`,e),...t}),hr:({className:e,...t})=>(0,B.jsx)(`hr`,{className:K(`border-border/70 dark:border-white/10`,e),...t}),table:({className:e,...t})=>(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsx)(`table`,{className:K(`w-full border-collapse text-left text-sm`,e),...t})}),th:({className:e,...t})=>(0,B.jsx)(`th`,{className:K(`border-b border-border/70 px-3 py-2 font-semibold dark:border-white/10`,e),...t}),td:({className:e,...t})=>(0,B.jsx)(`td`,{className:K(`border-b border-border/50 px-3 py-2 align-top dark:border-white/5`,e),...t})};function QN({content:e,className:t,compact:n=!1}){return(0,B.jsx)(`div`,{className:K(`space-y-4 break-words text-sm leading-7 [&>*+*]:mt-4`,n&&`text-[0.95rem] leading-6 [&>*+*]:mt-3`,t),children:(0,B.jsx)(KA,{remarkPlugins:[XN],components:ZN,children:e})})}function $N({className:e,orientation:t=`horizontal`,...n}){return(0,B.jsx)(Hh,{"data-slot":`tabs`,"data-orientation":t,className:K(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var eP=dv(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function tP({className:e,variant:t=`default`,...n}){return(0,B.jsx)(Uh,{"data-slot":`tabs-list`,"data-variant":t,className:K(eP({variant:t}),e),...n})}function nP({className:e,...t}){return(0,B.jsx)(Wh,{"data-slot":`tabs-trigger`,className:K(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function rP({className:e,...t}){return(0,B.jsx)(Gh,{"data-slot":`tabs-content`,className:K(`flex-1 text-sm outline-none`,e),...t})}function iP({className:e,size:t=`default`,...n}){return(0,B.jsx)(Th,{"data-slot":`switch`,"data-size":t,className:K(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,B.jsx)(Eh,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var aP=`manager`,oP=1200;function sP(e){let t=gP(e);return[{id:aP,mailboxId:aP,name:`CEO`,role:`CEO`,kind:`ceo`},...t.map(e=>({id:e.mailBoxId,mailboxId:e.mailBoxId,name:e.name,role:e.role===`department_head`?`Department Head`:`executor: ${e.name}`,kind:e.role===`department_head`?`department_head`:`executor`}))]}function cP(e){let t=sP(e.department),n=new Map(t.map(e=>[e.mailboxId,e])),r=[...e.messages].sort((e,t)=>e.sendTime-t.sendTime).map(e=>dP(e,n)),i=fP({contexts:e.memberContexts??[],messages:e.messages,participantsByMailbox:n});return[...r,...i].sort((e,t)=>e.createdAt===t.createdAt?e.id.localeCompare(t.id):e.createdAt-t.createdAt)}function lP(e,t){let n=t.query?.trim().toLowerCase()??``;return e.filter(e=>t.threadId&&e.threadId!==t.threadId||t.type===`messages`&&![`message_sent`,`message_reply`].includes(e.eventType)||t.type===`tools`&&![`tool_use`,`tool_result`].includes(e.eventType)||t.type===`communicate`&&e.eventType!==`communicate`||t.type===`errors`&&e.eventType!==`error`&&e.status!==`failed`?!1:n?yP(e).includes(n):!0)}function uP(e,t){return t?t.threadId?e.filter(e=>e.threadId===t.threadId):t.groupId?e.filter(e=>e.groupId===t.groupId):[t]:[]}function dP(e,t){let n=t.get(e.fromMailboxId),r=t.get(e.toMailboxId),i=pP(e,n,r);return{id:e.id,eventType:i,createdAt:e.sendTime,threadId:e.threadId,parentMessageId:e.parentMessageId,status:e.status,fromMailboxId:e.fromMailboxId,fromRole:n?.role??xP(e.fromMailboxId),fromName:n?.name??xP(e.fromMailboxId),toMailboxId:e.toMailboxId,toRole:r?.role??xP(e.toMailboxId),toName:r?.name??xP(e.toMailboxId),content:e.content,raw:e}}function fP({contexts:e,messages:t,participantsByMailbox:n}){let r=[];for(let i of e){let e=n.get(i.mailBoxId);if(!e)continue;let a=t.filter(e=>e.fromMailboxId===i.mailBoxId||e.toMailboxId===i.mailBoxId).sort((e,t)=>e.sendTime-t.sendTime),o=a.filter(e=>e.toMailboxId===i.mailBoxId),s=a.filter(e=>e.fromMailboxId===i.mailBoxId),c=0,l=new Map,u=new Map;for(let t of i.agentLogs)for(let n=0;n<t.blocks.length;n+=1){let a=t.blocks[n];if(a.type!==`tool_use`&&a.type!==`tool_result`)continue;let d=vP(a),f=d?u.get(d)??`${i.mailBoxId}:tool:${d}`:`${i.mailBoxId}:log:${t.index}:block:${n}`,p=mP({incoming:o,outgoing:s,toolIndex:c,isResult:a.type===`tool_result`,pairedUseTime:d?l.get(d):void 0});if(a.type===`tool_use`){d&&(l.set(d,p),u.set(d,f)),r.push({id:`${i.mailBoxId}:tool_use:${t.index}:${n}`,eventType:`tool_use`,createdAt:p,status:`completed`,actorMailboxId:i.mailBoxId,actorRole:e.role,actorName:e.name,toolName:typeof a.name==`string`?a.name:`unknown`,toolInput:a.input,groupId:f,relatedMessageId:hP(o,p)?.id,raw:{memberName:i.memberName,logIndex:t.index,block:a}}),c+=1;continue}r.push({id:`${i.mailBoxId}:tool_result:${t.index}:${n}`,eventType:`tool_result`,createdAt:p,status:`completed`,actorMailboxId:i.mailBoxId,actorRole:e.role,actorName:e.name,toolResult:a.content,groupId:f,relatedMessageId:hP(o,p)?.id,raw:{memberName:i.memberName,logIndex:t.index,block:a}})}}return r}function pP(e,t,n){return e.status===`failed`?`error`:e.content.trim().toLowerCase()===`communicate`?`communicate`:t?.kind===`ceo`?`message_sent`:t?.kind===`department_head`&&n?.kind===`executor`?`communicate`:t?.kind===`executor`&&(n?.kind===`department_head`||n?.kind===`ceo`)?`message_reply`:t&&n&&t.mailboxId!==n.mailboxId?`communicate`:`message_sent`}function mP({incoming:e,outgoing:t,toolIndex:n,isResult:r,pairedUseTime:i}){if(r&&i)return i+oP;let a=e[Math.min(n,Math.max(0,e.length-1))];if(!a)return(t[0]?.sendTime??0)+n*2e3+(r?oP:0);let o=t.find(e=>e.sendTime>a.sendTime)?.sendTime??a.sendTime+6e4,s=Math.max(3e3,o-a.sendTime);return a.sendTime+Math.min(s-1e3,Math.round(s*.35)+n*2e3)}function hP(e,t){return[...e].reverse().find(e=>e.sendTime<=t)??e[0]??null}function gP(e){return[...e.departmentMembers].sort((t,n)=>{let r=_P(e,t),i=_P(e,n);return r===i?t.name.localeCompare(n.name):r-i})}function _P(e,t){return e.headMemberId&&t.id===e.headMemberId||t.role===`department_head`?0:1}function vP(e){if(typeof e.id==`string`)return e.id;if(typeof e.toolUseId==`string`)return e.toolUseId}function yP(e){return[e.id,e.eventType,e.threadId,e.parentMessageId,e.actorMailboxId,e.actorRole,e.actorName,e.fromMailboxId,e.fromRole,e.fromName,e.toMailboxId,e.toRole,e.toName,e.content,e.toolName,bP(e.toolInput),bP(e.toolResult)].filter(Boolean).join(` `).toLowerCase()}function bP(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return``}}function xP(e){return e.split(`::`).at(-1)||e.slice(0,12)}var SP=3e3,CP=50;function wP({department:e,departmentName:t,messages:n,onRefresh:r}){let[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(`all`),[c,l]=(0,S.useState)(!0),[u,d]=(0,S.useState)(CP),[f,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(()=>new Set),g=(0,S.useRef)(null),_=(0,S.useRef)(null),v=(0,S.useRef)(null),y=(0,S.useRef)(null),b=_i({queries:e.departmentMembers.map(e=>({queryKey:Ty.memberContext(t,e.name),queryFn:()=>Cy(t,e.name),enabled:!!t&&!!e.name,refetchInterval:SP}))}),x=yi({queryKey:Ty.ceoContext(t),queryFn:()=>wy(t),enabled:!!t,refetchInterval:SP}),C=[x.data,...b.map(e=>e.data)].filter(e=>!!e),w=x.isFetching||b.some(e=>e.isFetching),T=(0,S.useMemo)(()=>kP({department:e,messages:n,contexts:C}),[C,e,n]),E=(0,S.useMemo)(()=>PP(T,{query:i,kind:o}),[T,o,i]),D=Math.min(u,E.length),O=E.slice(Math.max(0,E.length-D)),k=Math.max(0,E.length-D),A=E.at(-1)?.id??null;(0,S.useEffect)(()=>{d(CP),l(!0),p(!1),v.current=A},[o,i]),(0,S.useEffect)(()=>{if(A!==v.current){if(c){v.current=A,d(e=>Math.max(CP,Math.min(E.length,e+1)));return}A&&p(!0)}},[E.length,c,A]),(0,S.useEffect)(()=>{let e=g.current;if(e){if(y.current!=null){let t=y.current;y.current=null,e.scrollTop=e.scrollHeight-t;return}c&&_.current?.scrollIntoView({block:`end`})}},[c,O.length]);let j=()=>{if(k<=0)return;let e=g.current;e&&(y.current=e.scrollHeight),d(e=>Math.min(E.length,e+CP))},M=()=>{v.current=A,p(!1),l(!0),d(e=>Math.max(CP,Math.min(E.length,e))),requestAnimationFrame(()=>_.current?.scrollIntoView({block:`end`,behavior:`smooth`}))},N=()=>{let e=g.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;if(e.scrollTop<80&&j(),t<80){v.current=A,p(!1),l(!0);return}l(!1)},P=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,B.jsxs)(Y,{className:`overflow-hidden border-border/70 bg-card/90 shadow-sm backdrop-blur-sm`,children:[(0,B.jsxs)(Iy,{className:`space-y-4 border-b bg-background/70`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-xl`,children:[(0,B.jsx)(yo,{className:`h-5 w-5 text-rose-500`}),`聊天记录`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Boss/User、CEO、Department Head、executor 和工具调用按时间往下流动。`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(J,{variant:`outline`,children:[E.length,` / `,T.length,` 条`]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1 text-emerald-700 dark:text-emerald-200`,children:[(0,B.jsx)(`span`,{className:K(`h-2 w-2 rounded-full`,w?`animate-pulse bg-amber-500`:`bg-emerald-500`)}),w?`syncing`:`live`]}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:async()=>{await r(),await Promise.all([x.refetch(),...b.map(e=>e.refetch())])},children:(0,B.jsx)(Ao,{className:K(`h-4 w-4`,w&&`animate-spin`)})})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`div`,{className:`inline-flex rounded-lg border bg-background p-1`,children:[[`all`,`全部`],[`message`,`消息`],[`agent_text`,`发言`],[`tool_use`,`工具`],[`tool_result`,`结果`]].map(([e,t])=>(0,B.jsx)(q,{variant:o===e?`default`:`ghost`,size:`sm`,className:`h-8`,onClick:()=>s(e),children:t},e))}),(0,B.jsxs)(`div`,{className:`relative min-w-[260px] flex-1`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{value:i,onChange:e=>a(e.target.value),placeholder:`搜索成员、消息、tool name、tool result`,className:`pl-9`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border bg-background px-3 py-2 text-sm`,children:[(0,B.jsx)(iP,{size:`sm`,checked:c,onCheckedChange:e=>{l(e),e&&(v.current=A,p(!1))}}),`跟随最新`]})]})]}),(0,B.jsx)(zy,{className:`p-0`,children:(0,B.jsxs)(`div`,{ref:g,onScroll:N,className:`relative h-[min(760px,calc(100vh-280px))] min-h-[520px] overflow-y-auto`,children:[(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-5xl flex-col gap-4 px-4 py-5 sm:px-6`,children:[E.length===0?(0,B.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border/70 bg-muted/30 px-6 py-14 text-center`,children:[(0,B.jsx)(yo,{className:`mx-auto h-10 w-10 text-muted-foreground/45`}),(0,B.jsx)(`div`,{className:`mt-3 text-sm font-medium`,children:`还没有可展示的聊天记录`}),(0,B.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:`部门开始收发消息或调用工具后,这里会实时出现。`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(TP,{hiddenOlderCount:k,onLoadOlder:j}),O.map((e,t)=>(0,B.jsx)(EP,{event:e,previous:O[t-1],expanded:m.has(e.id),onToggleExpanded:()=>P(e.id)},e.id))]}),(0,B.jsx)(`div`,{ref:_})]}),(!c||f)&&E.length>0&&(0,B.jsxs)(q,{size:`sm`,className:`absolute bottom-4 right-4 z-10 rounded-full shadow-lg`,onClick:M,children:[(0,B.jsx)(Da,{className:`h-4 w-4`}),f?`有新消息`:`回到最新`]})]})})]})}function TP({hiddenOlderCount:e,onLoadOlder:t}){return(0,B.jsx)(`div`,{className:`flex justify-center`,children:e>0?(0,B.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:t,className:`text-muted-foreground`,children:[`查看更早消息(还有 `,e,` 条)`]}):(0,B.jsx)(`span`,{className:`rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground`,children:`已显示最早记录`})})}function EP({event:e,previous:t,expanded:n,onToggleExpanded:r}){return(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(!t||e.createdAt-t.createdAt>12e4)&&(0,B.jsx)(`div`,{className:`flex justify-center`,children:(0,B.jsx)(`span`,{className:`rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground`,children:VP(e.createdAt)})}),e.kind===`tool_use`||e.kind===`tool_result`?(0,B.jsx)(OP,{event:e,expanded:n,onToggleExpanded:r}):(0,B.jsx)(DP,{event:e})]})}function DP({event:e}){let t=FP(e),n=IP(e);return(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:K(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl`,t.avatar),children:(0,B.jsx)(n,{className:`h-5 w-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:e.actorName}),(0,B.jsx)(J,{variant:`outline`,className:K(`h-5 px-2 text-[11px]`,t.badge),children:e.actorRole}),e.targetName&&(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`to `,e.targetName]}),e.status&&(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status})]}),(0,B.jsx)(`div`,{className:K(`max-w-3xl rounded-2xl px-4 py-3 text-sm leading-6`,t.bubble),children:(0,B.jsx)(QN,{content:e.content||` `,compact:!0,className:`[&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:text-xs [&_pre]:leading-5`})}),e.threadId&&(0,B.jsxs)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[`thread `,e.threadId]})]})]})}function OP({event:e,expanded:t,onToggleExpanded:n}){let r=e.kind===`tool_result`,i=r?e.toolResult:e.toolInput,a=RP(i);return(0,B.jsx)(`div`,{className:`ml-2 border-l-2 border-dashed border-border/70 pl-5`,children:(0,B.jsxs)(`div`,{className:K(`max-w-4xl rounded-2xl border px-4 py-3 shadow-sm`,r?`border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-900/65`:`border-amber-200 bg-amber-50 dark:border-amber-500/25 dark:bg-amber-950/35`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,B.jsx)(`div`,{className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl`,r?`bg-slate-200 text-slate-700 dark:bg-slate-800 dark:text-slate-200`:`bg-amber-200 text-amber-800 dark:bg-amber-400/15 dark:text-amber-100`),children:r?(0,B.jsx)(Ma,{className:`h-4 w-4`}):(0,B.jsx)(Qo,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:r?`tool_result`:e.toolName??`tool_use`}),(0,B.jsx)(J,{variant:`outline`,className:`h-5 px-2 text-[11px]`,children:e.actorName})]}),(0,B.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:r?a:`input ${a}`})]})]}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:n,children:t?(0,B.jsx)(Xa,{className:`h-4 w-4`}):(0,B.jsx)(Za,{className:`h-4 w-4`})})]}),t&&(0,B.jsx)(`pre`,{className:`mt-3 max-h-80 overflow-auto rounded-xl bg-background/80 p-3 text-xs leading-5 text-foreground`,children:zP(i)})]})})}function kP({department:e,messages:t,contexts:n}){let r=sP(e),i=new Map(r.map(e=>[e.mailboxId,e])),a=cP({department:e,messages:t,memberContexts:n}),o=[];for(let e of a){if(e.eventType===`tool_use`||e.eventType===`tool_result`){o.push(AP(e));continue}o.push({id:`mailbox:${e.id}`,kind:`message`,createdAt:e.createdAt,actorName:e.fromName??e.fromMailboxId??`Unknown`,actorRole:e.fromRole??`sender`,actorMailboxId:e.fromMailboxId,targetName:e.toName,targetMailboxId:e.toMailboxId,content:e.content,threadId:e.threadId,status:e.status,raw:e.raw})}for(let e of n){let n=i.get(e.mailBoxId);n&&o.push(...jP(e,n.name,n.role,t))}return NP(o).sort((e,t)=>e.createdAt===t.createdAt?LP(e.kind)-LP(t.kind)||e.id.localeCompare(t.id):e.createdAt-t.createdAt)}function AP(e){let t=e.eventType===`tool_result`?`tool_result`:`tool_use`;return{id:`sequence:${e.id}`,kind:t,createdAt:e.createdAt,actorName:e.actorName??e.actorMailboxId??`Unknown`,actorRole:e.actorRole??`agent`,actorMailboxId:e.actorMailboxId,toolName:e.toolName,toolInput:e.toolInput,toolResult:e.toolResult,groupId:e.groupId,threadId:e.threadId,status:e.status,raw:e.raw}}function jP(e,t,n,r){let i=r.filter(t=>t.fromMailboxId===e.mailBoxId||t.toMailboxId===e.mailBoxId).sort((e,t)=>e.sendTime-t.sendTime)[0]?.sendTime??r.at(-1)?.sendTime??0;return e.agentLogs.flatMap(r=>r.role===`user`&&e.mailBoxId!==`manager`?[]:r.blocks.flatMap((a,o)=>{if(a.type!==`text`||typeof a.text!=`string`||!a.text.trim())return[];let s=e.mailBoxId===`manager`&&r.role===`user`;return[{id:`agent-text:${e.mailBoxId}:${r.index}:${o}`,kind:`agent_text`,createdAt:MP(i,r.index,o,s),actorName:s?`Boss/User`:t,actorRole:s?`User`:n,actorMailboxId:e.mailBoxId,content:a.text,raw:{context:e.memberName,logIndex:r.index,block:a}}]}))}function MP(e,t,n,r){return(e||0)+(r?-3e4:900)+t*1500+n*150}function NP(e){let t=new Set;return e.filter(e=>{let n=e.kind===`message`?`${e.actorMailboxId}:${e.targetMailboxId}:${e.content}:${e.createdAt}`:e.id;return t.has(n)?!1:(t.add(n),!0)})}function PP(e,t){let n=t.query.trim().toLowerCase();return e.filter(e=>t.kind!==`all`&&e.kind!==t.kind?!1:n?[e.actorName,e.actorRole,e.targetName,e.content,e.toolName,zP(e.toolInput),zP(e.toolResult),e.threadId,e.status].filter(Boolean).join(` `).toLowerCase().includes(n):!0)}function FP(e){return e.actorRole===`User`?{avatar:`bg-rose-100 text-rose-700 dark:bg-rose-500/15 dark:text-rose-100`,badge:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-500/25 dark:bg-rose-500/15 dark:text-rose-100`,bubble:`bg-rose-50 text-rose-950 dark:bg-rose-950/35 dark:text-rose-50`}:e.actorRole===`CEO`?{avatar:`bg-sky-100 text-sky-700 dark:bg-sky-500/15 dark:text-sky-100`,badge:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-500/25 dark:bg-sky-500/15 dark:text-sky-100`,bubble:`bg-sky-50 text-sky-950 dark:bg-sky-950/35 dark:text-sky-50`}:e.actorRole===`Department Head`?{avatar:`bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-100`,badge:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/25 dark:bg-violet-500/15 dark:text-violet-100`,bubble:`bg-violet-50 text-violet-950 dark:bg-violet-950/35 dark:text-violet-50`}:{avatar:`bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-100`,badge:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/25 dark:bg-emerald-500/15 dark:text-emerald-100`,bubble:`bg-muted/70 text-foreground dark:bg-muted/35`}}function IP(e){return e.actorRole===`User`?Yo:e.actorRole===`CEO`?qa:e.actorRole===`Department Head`?qo:ja}function LP(e){return e===`agent_text`?0:e===`message`?1:e===`tool_use`?2:3}function RP(e){return BP(zP(e).replace(/\s+/g,` `),140)}function zP(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function BP(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function VP(e){return e?new Date(e).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):`时间未知`}function HP({delayDuration:e=0,...t}){return(0,B.jsx)(Eg,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function UP({...e}){return(0,B.jsx)(Dg,{"data-slot":`tooltip`,...e})}function WP({...e}){return(0,B.jsx)(Og,{"data-slot":`tooltip-trigger`,...e})}function GP({className:e,sideOffset:t=0,children:n,...r}){return(0,B.jsx)(kg,{children:(0,B.jsxs)(Ag,{"data-slot":`tooltip-content`,sideOffset:t,className:K(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,B.jsx)(jg,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var KP=[{value:`all`,label:`全部`},{value:`messages`,label:`消息`},{value:`tools`,label:`工具`},{value:`communicate`,label:`communicate`},{value:`errors`,label:`错误`}],qP=230,JP=74,YP=178,XP=292,ZP=28,QP=[25,50,100];function $P({department:e,departmentName:t,messages:n,onRefresh:r}){let[i,a]=(0,S.useState)(`all`),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(0),[m,h]=(0,S.useState)(25),[g,_]=(0,S.useState)(1),v=(0,S.useRef)(null),y=_i({queries:e.departmentMembers.map(e=>({queryKey:Ty.memberContext(t,e.name),queryFn:()=>Cy(t,e.name),enabled:!!t&&!!e.name,refetchInterval:5e3}))}),b=yi({queryKey:Ty.ceoContext(t),queryFn:()=>wy(t),enabled:!!t,refetchInterval:5e3}),x=[b.data,...y.map(e=>e.data)].filter(e=>!!e),C=b.isLoading||y.some(e=>e.isLoading),w=(0,S.useMemo)(()=>sP(e),[e]),T=(0,S.useMemo)(()=>cP({department:e,messages:n,memberContexts:x}),[x,e,n]),E=T.find(e=>e.id===c)??null,D=u?E?.threadId??null:null,O=lP(T,{type:i,query:o,threadId:D}),k=Math.max(1,Math.ceil(O.length/m)),A=Math.min(g,k),j=O.length===0?0:(A-1)*m+1,M=Math.min(O.length,A*m),N=O.slice(j-1,M),P=uP(T,E),ee=new Set(P.map(e=>e.id)),F=(0,S.useMemo)(()=>pF(T),[T]),I=Math.min(XP,Math.max(YP,qP+f*ZP)),te=e=>{v.current?.scrollBy({left:e,behavior:`smooth`})};return(0,S.useEffect)(()=>{_(1),v.current?.scrollTo({top:0,left:0})},[D,i,m,o]),(0,S.useEffect)(()=>{g>k&&_(k)},[g,k]),(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(360px,390px)] xl:items-start`,children:[(0,B.jsxs)(Y,{className:`overflow-visible border-border/70 bg-card/90 shadow-sm backdrop-blur-sm`,children:[(0,B.jsxs)(Iy,{className:`space-y-4 border-b bg-background/70`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-xl`,children:[(0,B.jsx)(Xo,{className:`h-5 w-5 text-primary`}),`团队时序图 / Department Sequence`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`按时间查看 Department 内部消息、communicate、工具调用和回信链路。`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(J,{variant:`outline`,children:[w.length,` members`]}),(0,B.jsxs)(J,{variant:`outline`,children:[O.length,` / `,T.length,` events`]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1 text-emerald-700 dark:text-emerald-200`,children:[(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-emerald-500`}),`live sync`]}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:r,children:(0,B.jsx)(Ao,{className:`h-4 w-4`})})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`div`,{className:`inline-flex rounded-lg border bg-background p-1`,children:KP.map(e=>(0,B.jsx)(q,{variant:i===e.value?`default`:`ghost`,size:`sm`,onClick:()=>a(e.value),className:`h-8`,children:e.label},e.value))}),(0,B.jsxs)(`div`,{className:`relative min-w-[260px] flex-1`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{value:o,onChange:e=>s(e.target.value),placeholder:`搜索内容、成员、tool name、threadId`,className:`pl-9`})]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border bg-background px-3 py-2 text-sm`,children:[(0,B.jsx)(iP,{size:`sm`,checked:u,onCheckedChange:d,disabled:!E?.threadId}),`只看当前线程`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:()=>te(-520),children:(0,B.jsx)(Ra,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:()=>te(520),children:(0,B.jsx)(za,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:()=>p(e=>Math.max(-1,e-1)),disabled:I<=YP,children:(0,B.jsx)(ts,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:()=>p(e=>Math.min(2,e+1)),disabled:I>=XP,children:(0,B.jsx)(es,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,onClick:()=>{v.current?.scrollTo({left:0,top:0,behavior:`smooth`}),p(0)},children:(0,B.jsx)(vo,{className:`h-4 w-4`})})]})]}),(0,B.jsx)(eF,{page:A,pageCount:k,pageSize:m,pageStart:j,pageEnd:M,total:O.length,onPageChange:e=>{_(Math.min(Math.max(1,e),k)),v.current?.scrollTo({left:0,behavior:`smooth`})},onPageSizeChange:h})]}),(0,B.jsx)(zy,{className:`p-0`,children:C&&T.length===0?(0,B.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,B.jsx)(X,{className:`h-16 w-full`}),(0,B.jsx)(X,{className:`h-96 w-full`})]}):O.length===0?(0,B.jsx)(`div`,{className:`px-6 py-20 text-center text-sm text-muted-foreground`,children:`没有匹配的时序事件。可以放宽筛选或刷新 Department 活动。`}):(0,B.jsx)(`div`,{ref:v,className:`max-w-full overflow-x-auto overflow-y-visible overscroll-x-contain bg-background`,children:(0,B.jsx)(tF,{participants:w,events:N,toolNamesByGroupId:F,participantWidth:I,selectedEventId:c,relatedEventIds:ee,hasSelection:!!E,onSelectEvent:l})})})]}),(0,B.jsx)(oF,{event:E,events:T,toolNamesByGroupId:F,onClose:()=>l(null),onFocusThread:()=>d(!0)})]})}function eF({page:e,pageCount:t,pageSize:n,pageStart:r,pageEnd:i,total:a,onPageChange:o,onPageSizeChange:s}){return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-md border bg-background/80 px-3 py-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`text-muted-foreground`,children:[`显示 `,(0,B.jsxs)(`span`,{className:`font-mono text-foreground`,children:[r,`-`,i]}),` / `,(0,B.jsx)(`span`,{className:`font-mono text-foreground`,children:a}),` events`]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`inline-flex items-center rounded-md border bg-card p-0.5`,children:QP.map(e=>(0,B.jsxs)(q,{variant:n===e?`secondary`:`ghost`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:()=>s(e),children:[e,`/页`]},e))}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,disabled:e<=1,onClick:()=>o(1),children:`首页`}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,disabled:e<=1,onClick:()=>o(e-1),children:(0,B.jsx)(Ra,{className:`h-4 w-4`})}),(0,B.jsxs)(`span`,{className:`min-w-16 text-center font-mono text-xs text-muted-foreground`,children:[e,`/`,t]}),(0,B.jsx)(q,{variant:`outline`,size:`icon-sm`,disabled:e>=t,onClick:()=>o(e+1),children:(0,B.jsx)(za,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,disabled:e>=t,onClick:()=>o(t),children:`末页`})]})]})]})}function tF({participants:e,events:t,toolNamesByGroupId:n,participantWidth:r,selectedEventId:i,relatedEventIds:a,hasSelection:o,onSelectEvent:s}){let c=new Map(e.map((e,t)=>[e.mailboxId,t])),l=`${JP}px repeat(${e.length}, ${r}px)`;return(0,B.jsxs)(`div`,{className:`bg-background`,style:{width:JP+e.length*r},children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-20 grid border-b bg-card/95 backdrop-blur`,style:{gridTemplateColumns:l},children:[(0,B.jsx)(`div`,{className:`sticky left-0 z-30 border-r bg-card/95 p-3 text-xs text-muted-foreground shadow-[1px_0_0_hsl(var(--border))]`,children:`Time`}),e.map(e=>(0,B.jsx)(nF,{participant:e},e.mailboxId))]}),(0,B.jsx)(`div`,{className:`relative`,children:t.map(t=>(0,B.jsx)(rF,{event:t,participants:e,participantIndex:c,toolNamesByGroupId:n,participantWidth:r,selected:t.id===i,dimmed:o&&!a.has(t.id)&&t.id!==i,onSelect:()=>s(t.id)},t.id))})]})}function nF({participant:e}){return(0,B.jsx)(`div`,{className:`relative border-r px-4 py-4`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,B.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-full border bg-muted/50 text-foreground`,children:(0,B.jsx)(e.kind===`ceo`?qo:e.kind===`department_head`?Xo:Qa,{className:`h-5 w-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:e.role}),(0,B.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]})]})})}function rF({event:e,participants:t,participantIndex:n,toolNamesByGroupId:r,participantWidth:i,selected:a,dimmed:o,onSelect:s}){let c=`${JP}px repeat(${t.length}, ${i}px)`,l=e.fromMailboxId?n.get(e.fromMailboxId):void 0,u=e.toMailboxId?n.get(e.toMailboxId):void 0,d=e.actorMailboxId?n.get(e.actorMailboxId):void 0,f=l!=null&&u!=null&&l!==u;return(0,B.jsxs)(`div`,{className:K(`relative grid min-h-[108px] border-b transition-opacity even:bg-muted/20`,a&&`bg-primary/5`,o&&`opacity-35`),style:{gridTemplateColumns:c},children:[(0,B.jsxs)(`div`,{className:`sticky left-0 z-10 flex flex-col items-end gap-1 border-r bg-background px-3 py-5 font-mono text-xs text-muted-foreground shadow-[1px_0_0_hsl(var(--border))]`,children:[(0,B.jsx)(`span`,{children:xF(e.createdAt)}),(0,B.jsx)(`span`,{className:K(`h-1.5 w-1.5 rounded-full`,fF(e).dot)})]}),t.map(e=>(0,B.jsx)(`div`,{className:`relative border-r`,children:(0,B.jsx)(`div`,{className:`absolute left-1/2 top-0 h-full border-l border-dashed border-border/80`})},e.mailboxId)),f&&(0,B.jsx)(iF,{event:e,fromIndex:l,toIndex:u,participantWidth:i,selected:a,onSelect:s}),!f&&d!=null&&(0,B.jsx)(aF,{event:e,pairedToolName:e.groupId?r.get(e.groupId):void 0,actorIndex:d,participantWidth:i,selected:a,onSelect:s})]})}function iF({event:e,fromIndex:t,toIndex:n,participantWidth:r,selected:i,onSelect:a}){let o=Math.min(t,n),s=Math.max(t,n),c=n>t?`right`:`left`,l=JP+o*r+r/2,u=Math.max(70,(s-o)*r),d=s-o>1,f=fF(e);return(0,B.jsxs)(`button`,{type:`button`,onClick:a,className:K(`absolute top-8 z-10 h-14 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,i&&`rounded-md ring-2 ring-primary`),style:{left:l,width:u},children:[(0,B.jsx)(`div`,{className:K(`absolute top-1/2 h-[3px] -translate-y-1/2 rounded-full`,f.line),style:{left:0,right:0}}),(0,B.jsx)(`div`,{className:K(`absolute top-1/2 h-0 w-0 -translate-y-1/2 border-y-[6px] border-y-transparent`,c===`right`?`right-0 border-l-[9px]`:`left-0 border-r-[9px]`,f.arrow)}),(0,B.jsx)(`div`,{className:K(`absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full border-2 bg-background`,c===`right`?`-left-1.5`:`-right-1.5`,f.endpoint)}),(0,B.jsxs)(`div`,{className:K(`absolute top-1/2 max-w-[220px] -translate-y-1/2 rounded-md border px-3 py-2 text-xs shadow-sm`,d?`left-1/2 -translate-x-1/2`:c===`right`?`left-4`:`right-4`,f.card),children:[(0,B.jsx)(`div`,{className:`truncate font-semibold`,children:hF(e)}),(0,B.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] opacity-75`,children:vF(e)})]})]})}function aF({event:e,pairedToolName:t,actorIndex:n,participantWidth:r,selected:i,onSelect:a}){let o=fF(e),s=Math.min(210,Math.max(148,r-46)),c=JP+n*r+(r-s)/2;return(0,B.jsx)(`button`,{type:`button`,onClick:a,className:K(`absolute top-5 z-10 rounded-md border px-3 py-2 text-left text-xs shadow-sm transition-shadow`,o.card,i&&`ring-2 ring-primary`),style:{left:c,width:s},children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.eventType===`tool_use`?(0,B.jsx)(Qo,{className:`h-4 w-4`}):(0,B.jsx)(Ma,{className:`h-4 w-4`}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`truncate font-semibold`,children:hF(e,t)}),(0,B.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] opacity-75`,children:gF(e)})]})]})})}function oF({event:e,events:t,toolNamesByGroupId:n,onClose:r,onFocusThread:i}){let a=e?yF(t,e):null,o=e?bF(t,e):null,s=e?mF(t,e,`tool_use`):null,c=e?mF(t,e,`tool_result`):null,l=e?.groupId?n.get(e.groupId):void 0;return(0,B.jsxs)(Y,{className:`min-h-0 border-border/70 bg-card/95 shadow-sm xl:sticky xl:top-4 xl:max-h-[calc(100dvh-7rem)] xl:self-start`,children:[(0,B.jsx)(Iy,{className:`shrink-0 border-b`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(Ly,{className:`text-lg`,children:`事件详情`}),e&&(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:r,children:(0,B.jsx)($o,{className:`h-4 w-4`})})]})}),(0,B.jsx)(zy,{className:`min-h-0 flex-1 p-0`,children:e?(0,B.jsx)(`div`,{className:`h-[min(70dvh,680px)] overflow-y-auto overscroll-contain [scrollbar-gutter:stable] xl:h-[calc(100dvh-12.5rem)]`,children:(0,B.jsxs)(`div`,{className:`space-y-5 p-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:fF(e).chip,children:e.eventType}),(e.actorRole||e.fromRole)&&(0,B.jsx)(J,{variant:`secondary`,children:e.actorRole??e.fromRole}),(0,B.jsx)(J,{variant:`outline`,children:xF(e.createdAt,!0)}),e.status&&(0,B.jsxs)(J,{variant:`outline`,className:`border-emerald-200 bg-emerald-50 text-emerald-700`,children:[(0,B.jsx)(Va,{className:`h-3 w-3`}),e.status]})]}),(0,B.jsx)(sF,{event:e}),a&&(0,B.jsx)(cF,{title:`上游上下文`,children:(0,B.jsx)(lF,{event:a})}),e.eventType===`tool_use`&&(0,B.jsx)(cF,{title:`工具调用`,children:(0,B.jsx)(uF,{title:e.toolName??`unknown`,value:e.toolInput})}),e.eventType===`tool_use`&&c&&(0,B.jsxs)(cF,{title:`对应工具结果`,children:[(0,B.jsx)(lF,{event:c,pairedToolName:l}),(0,B.jsx)(uF,{title:`tool_result (${e.toolName??l??`unknown`})`,value:c.toolResult})]}),e.eventType===`tool_result`&&s&&(0,B.jsxs)(cF,{title:`对应工具调用`,children:[(0,B.jsx)(lF,{event:s,pairedToolName:l}),(0,B.jsx)(uF,{title:s.toolName??l??`unknown`,value:s.toolInput})]}),e.eventType===`tool_result`&&(0,B.jsx)(cF,{title:`工具结果`,children:(0,B.jsx)(uF,{title:`tool_result (${l??`unknown`})`,value:e.toolResult})}),o&&(0,B.jsx)(cF,{title:`下游回复`,children:(0,B.jsx)(lF,{event:o})}),(0,B.jsx)(cF,{title:`raw log`,children:(0,B.jsx)(uF,{value:e.raw})}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pt-2`,children:[(0,B.jsx)(dF,{icon:Ga,label:`复制 ID`,onClick:()=>CF(e.id)}),(0,B.jsx)(dF,{icon:Za,label:`聚焦成员`}),(0,B.jsx)(dF,{icon:$a,label:`聚焦线程`,onClick:i,disabled:!e.threadId}),(0,B.jsx)(dF,{icon:Ma,label:`原始日志`}),(0,B.jsx)(dF,{icon:Ya,label:`下载`}),(0,B.jsx)(dF,{icon:Go,label:`删除`,destructive:!0})]})]})}):(0,B.jsx)(`div`,{className:`px-6 py-20 text-center text-sm text-muted-foreground`,children:`选择一条消息、communicate 或工具调用后,这里会显示结构化详情。`})})]})}function sF({event:e}){return(0,B.jsx)(`div`,{className:`space-y-3`,children:[[`eventType`,e.eventType],[`actorMailboxId`,e.actorMailboxId],[`actorRole`,e.actorRole],[`toolName`,e.toolName],[`groupId`,e.groupId],[`fromMailboxId`,e.fromMailboxId],[`fromRole`,e.fromRole],[`toMailboxId`,e.toMailboxId],[`toRole`,e.toRole],[`threadId`,e.threadId],[`parentMessageId`,e.parentMessageId],[`relatedMessageId`,e.relatedMessageId],[`status`,e.status],[`message content`,e.content]].filter(([,e])=>e).map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] gap-3 text-sm`,children:[(0,B.jsx)(`div`,{className:`text-muted-foreground`,children:e}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-foreground`,children:t})]},e))})}function cF({title:e,children:t}){return(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t]})}function lF({event:e,pairedToolName:t}){return(0,B.jsxs)(`div`,{className:K(`rounded-lg border p-3 text-sm`,fF(e).card),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:fF(e).chip,children:e.eventType}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:vF(e)}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground`,children:xF(e.createdAt,!0)})]}),(0,B.jsx)(`div`,{className:`mt-2 line-clamp-3 text-sm leading-6`,children:hF(e,t)})]})}function uF({title:e,value:t}){return(0,B.jsxs)(`div`,{className:`rounded-lg border bg-muted/30`,children:[e&&(0,B.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2 text-xs font-semibold`,children:[(0,B.jsx)(`span`,{children:e}),(0,B.jsx)(Ga,{className:`h-3.5 w-3.5 text-muted-foreground`})]}),(0,B.jsx)(`pre`,{className:`max-h-52 overflow-auto whitespace-pre-wrap break-words p-3 text-xs leading-5 text-muted-foreground`,children:SF(t)})]})}function dF({icon:e,label:t,onClick:n,disabled:r,destructive:i}){return(0,B.jsxs)(UP,{children:[(0,B.jsx)(WP,{asChild:!0,children:(0,B.jsxs)(q,{variant:`outline`,className:K(`h-14 flex-col gap-1 text-xs`,i&&`text-destructive`),onClick:n,disabled:r,children:[(0,B.jsx)(e,{className:`h-4 w-4`}),t]})}),(0,B.jsx)(GP,{children:t})]})}function fF(e){return e.eventType===`tool_use`?{card:`border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100`,line:`bg-amber-500`,arrow:`border-l-amber-500 border-r-amber-500`,chip:`border-amber-200 bg-amber-50 text-amber-700`,endpoint:`border-amber-500`,dot:`bg-amber-500`}:e.eventType===`tool_result`?{card:`border-slate-200 bg-slate-50 text-slate-800 dark:border-slate-500/30 dark:bg-slate-500/10 dark:text-slate-100`,line:`bg-slate-500`,arrow:`border-l-slate-500 border-r-slate-500`,chip:`border-slate-200 bg-slate-50 text-slate-700`,endpoint:`border-slate-500`,dot:`bg-slate-500`}:e.eventType===`message_reply`?{card:`border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-100`,line:`bg-emerald-500`,arrow:`border-l-emerald-500 border-r-emerald-500`,chip:`border-emerald-200 bg-emerald-50 text-emerald-700`,endpoint:`border-emerald-500`,dot:`bg-emerald-500`}:e.eventType===`error`?{card:`border-rose-200 bg-rose-50 text-rose-900 dark:border-rose-500/30 dark:bg-rose-500/10 dark:text-rose-100`,line:`bg-rose-500`,arrow:`border-l-rose-500 border-r-rose-500`,chip:`border-rose-200 bg-rose-50 text-rose-700`,endpoint:`border-rose-500`,dot:`bg-rose-500`}:{card:`border-sky-200 bg-sky-50 text-sky-900 dark:border-sky-500/30 dark:bg-sky-500/10 dark:text-sky-100`,line:`bg-blue-500`,arrow:`border-l-blue-500 border-r-blue-500`,chip:`border-sky-200 bg-sky-50 text-sky-700`,endpoint:`border-blue-500`,dot:`bg-blue-500`}}function pF(e){let t=new Map;for(let n of e)n.eventType===`tool_use`&&n.groupId&&n.toolName&&t.set(n.groupId,n.toolName);return t}function mF(e,t,n){return t.groupId?e.find(e=>e.id!==t.id&&e.groupId===t.groupId&&e.eventType===n)??null:null}function hF(e,t){return e.eventType===`tool_use`?e.toolName??`tool_use`:e.eventType===`tool_result`?t?`tool_result (${t})`:`tool_result`:e.eventType===`communicate`?e.content?.trim()||`communicate`:e.content?.trim()||e.eventType}function gF(e){return e.eventType===`tool_result`?_F(e.toolResult):e.eventType===`tool_use`?e.eventType:e.threadId??e.eventType}function _F(e){let t=SF(e).replace(/\s+/g,` `).trim();return t?t.slice(0,64):`success`}function vF(e){return e.fromRole||e.toRole?`${e.fromRole??e.fromName} -> ${e.toRole??e.toName}`:e.actorRole??e.actorName??e.eventType}function yF(e,t){return[...e].filter(e=>e.id!==t.id&&e.createdAt<=t.createdAt).filter(e=>e.threadId&&e.threadId===t.threadId).sort((e,t)=>t.createdAt-e.createdAt)[0]??null}function bF(e,t){return e.filter(e=>e.id!==t.id&&e.createdAt>=t.createdAt).filter(e=>e.threadId&&e.threadId===t.threadId).sort((e,t)=>e.createdAt-t.createdAt)[0]??null}function xF(e,t=!1){return e?new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`,second:t?`2-digit`:void 0,hour12:!1}).format(new Date(e)):`--`}function SF(e){if(e==null)return`-`;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function CF(e){navigator.clipboard?.writeText(e)}var wF=e=>e?.mailboxId?vv(`/api/mailbox/${encodeURIComponent(e.mailboxId)}/messages`,{status:e.status}):Promise.resolve([]),TF=e=>e?.mailboxId?vv(`/api/mailbox/${encodeURIComponent(e.mailboxId)}/events`,{limit:e.limit}):Promise.resolve([]),EF={all:[`mailbox`],summaries:[`mailbox`,`summaries`],messages:e=>[`mailbox`,`messages`,e],events:e=>[`mailbox`,`events`,e]};function DF(e){return yi({queryKey:EF.messages(e),queryFn:()=>wF(e),enabled:!!e?.mailboxId})}function OF(e){return yi({queryKey:EF.events(e),queryFn:()=>TF(e),enabled:!!e?.mailboxId})}var kF={pending:{label:`待处理`,variant:`outline`,chipClass:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/15 dark:text-amber-200`},processing:{label:`执行中`,variant:`default`,chipClass:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-500/30 dark:bg-sky-500/15 dark:text-sky-200`},done:{label:`已完成`,variant:`secondary`,chipClass:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-200`},failed:{label:`失败`,variant:`destructive`,chipClass:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-500/30 dark:bg-rose-500/15 dark:text-rose-200`},cancelled:{label:`已取消`,variant:`secondary`,chipClass:`border-slate-200 bg-slate-100 text-slate-600 dark:border-slate-500/30 dark:bg-slate-500/15 dark:text-slate-200`},read:{label:`已读`,variant:`secondary`,chipClass:`border-slate-200 bg-slate-100 text-slate-600 dark:border-slate-500/30 dark:bg-slate-500/15 dark:text-slate-200`}},AF={standby:{label:`待命`,badge:`border-slate-200 bg-slate-100 text-slate-700 dark:border-slate-500/30 dark:bg-slate-500/15 dark:text-slate-200`,card:`border-slate-200/80 bg-gradient-to-br from-white via-slate-50 to-slate-100/70 dark:border-slate-700/70 dark:from-slate-900 dark:via-slate-900/95 dark:to-slate-800/75`,halo:`bg-slate-500/10 text-slate-600 dark:bg-slate-400/15 dark:text-slate-200`,bar:`bg-slate-500`},queued:{label:`待响应`,badge:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/15 dark:text-amber-200`,card:`border-amber-200/80 bg-gradient-to-br from-amber-50 via-white to-orange-50 dark:border-amber-500/25 dark:from-amber-950/45 dark:via-slate-900 dark:to-orange-950/35`,halo:`bg-amber-500/10 text-amber-700 dark:bg-amber-400/15 dark:text-amber-200`,bar:`bg-amber-500`},running:{label:`执行中`,badge:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-500/30 dark:bg-sky-500/15 dark:text-sky-200`,card:`border-sky-200/80 bg-gradient-to-br from-sky-50 via-white to-blue-50 dark:border-sky-500/25 dark:from-sky-950/45 dark:via-slate-900 dark:to-blue-950/35`,halo:`bg-sky-500/10 text-sky-700 dark:bg-sky-400/15 dark:text-sky-200`,bar:`bg-sky-500`},active:{label:`协作中`,badge:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/15 dark:text-violet-200`,card:`border-violet-200/80 bg-gradient-to-br from-violet-50 via-white to-indigo-50 dark:border-violet-500/25 dark:from-violet-950/45 dark:via-slate-900 dark:to-indigo-950/35`,halo:`bg-violet-500/10 text-violet-700 dark:bg-violet-400/15 dark:text-violet-200`,bar:`bg-violet-500`},completed:{label:`回合完成`,badge:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-200`,card:`border-emerald-200/80 bg-gradient-to-br from-emerald-50 via-white to-teal-50 dark:border-emerald-500/25 dark:from-emerald-950/45 dark:via-slate-900 dark:to-teal-950/35`,halo:`bg-emerald-500/10 text-emerald-700 dark:bg-emerald-400/15 dark:text-emerald-200`,bar:`bg-emerald-500`},support:{label:`需要支援`,badge:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-500/30 dark:bg-rose-500/15 dark:text-rose-200`,card:`border-rose-200/80 bg-gradient-to-br from-rose-50 via-white to-orange-50 dark:border-rose-500/25 dark:from-rose-950/45 dark:via-slate-900 dark:to-orange-950/35`,halo:`bg-rose-500/10 text-rose-700 dark:bg-rose-400/15 dark:text-rose-200`,bar:`bg-rose-500`}},jF={message_sent:{label:`已投递`,chipClass:`border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-500/30 dark:bg-indigo-500/15 dark:text-indigo-200`,icon:Fo},message_status_changed:{label:`状态变更`,chipClass:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-500/30 dark:bg-sky-500/15 dark:text-sky-200`,icon:ho},mailbox_listed:{label:`查看邮箱`,chipClass:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/15 dark:text-amber-200`,icon:Za},message_opened:{label:`选中邮件`,chipClass:`border-fuchsia-200 bg-fuchsia-50 text-fuchsia-700 dark:border-fuchsia-500/30 dark:bg-fuchsia-500/15 dark:text-fuchsia-200`,icon:wo},message_replied:{label:`提交回信`,chipClass:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-200`,icon:jo},message_discarded:{label:`已丢弃`,chipClass:`border-slate-200 bg-slate-100 text-slate-700 dark:border-slate-500/30 dark:bg-slate-500/15 dark:text-slate-200`,icon:Go},message_followed_up:{label:`线程跟进`,chipClass:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/15 dark:text-violet-200`,icon:Ka}},MF=`border-border/70 bg-card/90 shadow-sm backdrop-blur-sm dark:border-border/80 dark:bg-card/80`,NF=`bg-muted/60 text-foreground dark:bg-muted/35`,PF=`rounded-2xl border border-border/60 bg-muted/55 dark:border-border/70 dark:bg-muted/30`,FF=`rounded-2xl border border-dashed border-border/60 bg-muted/35 dark:border-border/70 dark:bg-muted/20`,IF=`rounded-2xl border border-border/60 bg-background/75 dark:border-white/10 dark:bg-slate-950/35`,LF=`relative overflow-hidden border border-sky-100/80 bg-gradient-to-br from-[#f7fbff] via-white to-[#eef6ff] text-slate-950 shadow-[0_24px_60px_-40px_rgba(59,130,246,0.35)] dark:border-white/8 dark:from-slate-950 dark:via-slate-900 dark:to-slate-950 dark:text-slate-50 dark:shadow-[0_30px_80px_-40px_rgba(15,23,42,0.9)]`,RF=`border-border/50 bg-background/80 text-foreground hover:bg-background dark:border-white/10 dark:bg-white/5 dark:text-white dark:hover:bg-white/10`,zF=`bg-slate-950 text-white hover:bg-slate-800 dark:bg-white dark:text-slate-900 dark:hover:bg-slate-100`,BF=`inline-flex items-center gap-2 rounded-full border border-border/50 bg-background/72 px-3 py-1.5 text-foreground/85 dark:border-white/10 dark:bg-white/5 dark:text-slate-200/85`,VF=`rounded-2xl border border-border/60 bg-background/78 p-4 backdrop-blur-sm dark:border-white/10 dark:bg-white/5`;function HF(){let{departmentName:e}=ot();return e?(0,B.jsx)(UF,{departmentName:e}):(0,B.jsx)(Py,{children:(0,B.jsx)(`p`,{children:`Invalid department name`})})}function UF({departmentName:e}){let t=nt(),{data:n,isLoading:r,refetch:i}=Dy(e),{data:a,refetch:o}=My(e),s=Ay(e),c=jy(e),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(null),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(`overview`),[y,b]=(0,S.useState)({name:``,focusOn:``}),x=async()=>{let e=y.name.trim();e&&(await s.mutateAsync({name:e,focusOn:y.focusOn||void 0}),m(e),u(!1),b({name:``,focusOn:``}))},C=async()=>{d&&(await c.mutateAsync(d),p===d&&m(null),h===d&&g(null),f(null))},w=async()=>{await Promise.all([i(),o()])},T=[...a?.messages??[]].sort((e,t)=>t.sendTime-e.sendTime),E=new Map;if(n?.departmentMembers)for(let e of n.departmentMembers)E.set(e.mailBoxId,e.name);let D=n?_I(n):[],O=n?gI(n)?.mailBoxId:void 0,k=n?D.map(e=>mI(e,T,O)):[],A=k.reduce((e,t)=>Math.max(e,t.totalMessages),1),j=k.map(e=>({...e,activityPercent:e.totalMessages===0?12:Math.max(22,Math.round(e.totalMessages/A*100))})),M=j.find(e=>e.member.name===p)??j[0]??null,N=hI(n,j,T);return(0,B.jsx)(Py,{children:(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsx)(WF,{department:n,departmentName:e,summary:N,onBack:()=>t(`/departments`),onRefresh:w,onAddMember:()=>u(!0)}),r?(0,B.jsx)(aI,{}):n?(0,B.jsxs)($N,{value:_,onValueChange:v,className:`space-y-6`,children:[(0,B.jsxs)(tP,{className:`h-auto flex-wrap justify-start`,children:[(0,B.jsx)(nP,{value:`overview`,children:`成员概览`}),(0,B.jsx)(nP,{value:`sequence`,children:`时序图`}),(0,B.jsx)(nP,{value:`battlelog`,children:`主线战报`}),(0,B.jsx)(nP,{value:`chat`,children:`聊天记录`})]}),(0,B.jsxs)(rP,{value:`overview`,className:`space-y-6`,children:[(0,B.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[minmax(320px,0.92fr)_minmax(0,1.08fr)]`,children:[(0,B.jsx)(KF,{memberStats:j,selectedMemberName:M?.member.name??null,onSelectMember:m,onDeleteMember:f,onAddMember:()=>u(!0)}),(0,B.jsx)(YF,{departmentName:e,stats:M,memberNameMap:E,onOpenContext:e=>g(e)})]}),(0,B.jsx)(rI,{department:n,summary:N,onAddMember:()=>u(!0)})]}),(0,B.jsx)(rP,{value:`sequence`,children:(0,B.jsx)($P,{department:n,departmentName:e,messages:T,onRefresh:w})}),(0,B.jsxs)(rP,{value:`battlelog`,className:`grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(300px,0.85fr)]`,children:[(0,B.jsx)(nI,{messages:T,memberNameMap:E}),(0,B.jsx)(rI,{department:n,summary:N,onAddMember:()=>u(!0)})]}),(0,B.jsx)(rP,{value:`chat`,children:(0,B.jsx)(wP,{department:n,departmentName:e,messages:T,onRefresh:w})})]}):(0,B.jsx)(Y,{children:(0,B.jsxs)(zy,{className:`py-16 text-center text-muted-foreground`,children:[`部门 `,e,` 不存在`]})}),(0,B.jsx)(nw,{open:l,onOpenChange:u,children:(0,B.jsxs)(aw,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`添加成员`}),(0,B.jsxs)(lw,{children:[`向部门 `,e,` 添加新成员`]})]}),(0,B.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`成员名称`}),(0,B.jsx)(ew,{value:y.name,onChange:e=>b(t=>({...t,name:e.target.value})),placeholder:`例如:TechEval`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`职责描述`}),(0,B.jsx)(ew,{value:y.focusOn,onChange:e=>b(t=>({...t,focusOn:e.target.value})),placeholder:`例如:技术评估 / 产品拆解 / 前端推进`})]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>u(!1),children:`取消`}),(0,B.jsxs)(q,{onClick:x,disabled:s.isPending||!y.name.trim(),children:[s.isPending&&(0,B.jsx)(ho,{className:`mr-1 h-4 w-4 animate-spin`}),`添加`]})]})]})}),(0,B.jsx)(nw,{open:!!d,onOpenChange:()=>f(null),children:(0,B.jsxs)(aw,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`确认移除`}),(0,B.jsxs)(lw,{children:[`确定要移除成员 `,d,` 吗?`]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>f(null),children:`取消`}),(0,B.jsxs)(q,{variant:`destructive`,onClick:C,disabled:c.isPending,children:[c.isPending&&(0,B.jsx)(ho,{className:`mr-1 h-4 w-4 animate-spin`}),`移除`]})]})]})}),(0,B.jsx)(oI,{departmentName:e,memberName:h,onClose:()=>g(null)})]})})}function WF({department:e,departmentName:t,summary:n,onBack:r,onRefresh:i,onAddMember:a}){return(0,B.jsxs)(Y,{className:LF,children:[(0,B.jsx)(`div`,{className:`absolute inset-0 bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.18),transparent_36%)] dark:bg-[radial-gradient(circle_at_top_left,rgba(59,130,246,0.35),transparent_36%)]`}),(0,B.jsx)(`div`,{className:`absolute inset-0 bg-[radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.14),transparent_32%)] dark:bg-[radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.22),transparent_32%)]`}),(0,B.jsx)(zy,{className:`relative px-6 py-6 sm:px-8 sm:py-8`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-8 xl:flex-row xl:items-start xl:justify-between`,children:[(0,B.jsxs)(`div`,{className:`max-w-3xl space-y-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:r,className:RF,children:(0,B.jsx)(Oa,{className:`h-4 w-4`})}),(0,B.jsx)(J,{variant:`outline`,className:K(RF,n.stageTone),children:n.stageLabel}),n.lastPulseAt&&(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground dark:text-slate-300/80`,children:[`最近动作 `,NI(n.lastPulseAt)]})]}),(0,B.jsx)(`div`,{className:`space-y-2`,children:(0,B.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight sm:text-4xl`,children:e?.name??t})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[(0,B.jsxs)(`div`,{className:BF,children:[(0,B.jsx)(Uo,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`font-medium`,children:`目标`}),(0,B.jsx)(`span`,{className:`text-muted-foreground dark:text-slate-300`,children:e?.sourceGoalId??`-`})]}),(0,B.jsxs)(`div`,{className:BF,children:[(0,B.jsx)(qo,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`font-medium`,children:`Department Head`}),(0,B.jsx)(`span`,{className:`max-w-40 truncate text-muted-foreground dark:text-slate-300`,children:n.headName})]}),e?.workpath&&(0,B.jsxs)(`div`,{className:K(BF,`max-w-full`),children:[(0,B.jsx)(eo,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`font-medium shrink-0`,children:`工作目录`}),(0,B.jsx)(`span`,{className:`truncate text-muted-foreground dark:text-slate-300`,children:e.workpath})]})]}),(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{index:`01`,title:`先点成员卡`,description:`左侧卡牌决定你当前聚焦的角色。`},{index:`02`,title:`再看任务流`,description:`右侧只保留这名成员最近一轮的关键往返。`},{index:`03`,title:`最后追上下文`,description:`需要深挖时,再打开完整执行记录。`}].map(e=>(0,B.jsxs)(`div`,{className:VF,children:[(0,B.jsx)(`div`,{className:`text-[11px] font-semibold tracking-[0.18em] text-slate-500 dark:text-slate-400`,children:e.index}),(0,B.jsx)(`div`,{className:`mt-2 text-sm font-semibold text-foreground dark:text-white`,children:e.title}),(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground dark:text-slate-300`,children:e.description})]},e.index))})]}),(0,B.jsxs)(`div`,{className:`w-full xl:max-w-[390px]`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap justify-end gap-2`,children:[(0,B.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:i,className:RF,children:[(0,B.jsx)(Ao,{className:`h-4 w-4`}),`刷新`]}),(0,B.jsxs)(q,{size:`sm`,onClick:a,className:zF,children:[(0,B.jsx)(Oo,{className:`h-4 w-4`}),`添加成员`]})]}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsx)(GF,{icon:Xo,label:`执行层 executor`,value:n.executorCount,description:`由 Department Head 管理`}),(0,B.jsx)(GF,{icon:Bo,label:`有动作成员`,value:n.activeMembers,description:`这一轮参与协作`}),(0,B.jsx)(GF,{icon:Ea,label:`处理中消息`,value:n.inFlightCount,description:`仍在推进的回合`}),(0,B.jsx)(GF,{icon:Va,label:`已完成回合`,value:n.completedCount,description:`${n.totalMessages} 条战报`})]}),n.riskCount>0&&(0,B.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-400/20 dark:bg-rose-400/10 dark:text-rose-50`,children:[`有 `,n.riskCount,` 条失败消息,建议让 Department Head 先定位阻塞来源。`]})]})]})})]})}function GF({icon:e,label:t,value:n,description:r}){return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-background/80 p-4 backdrop-blur-sm dark:border-white/10 dark:bg-white/5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground dark:text-slate-300`,children:[(0,B.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-xl bg-primary/10 text-primary dark:bg-white/10 dark:text-white`,children:(0,B.jsx)(e,{className:`h-4 w-4`})}),(0,B.jsx)(`span`,{children:t})]}),(0,B.jsx)(`div`,{className:`mt-4 text-3xl font-semibold text-foreground dark:text-white`,children:n}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground dark:text-slate-400`,children:r})]})}function KF({memberStats:e,selectedMemberName:t,onSelectMember:n,onDeleteMember:r,onAddMember:i}){return(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsxs)(Iy,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-lg`,children:[(0,B.jsx)(zo,{className:`h-5 w-5 text-primary`}),`部门成员目录`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Department Head 在最前,executor 是执行层;先选中成员,再查看最近任务流。`})]}),(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[e.length,` 位成员`]})]}),(0,B.jsx)(`div`,{className:K(PF,`border-dashed text-sm leading-6 text-muted-foreground`),children:`CEO 视角只需要关注 Department Head;详情页保留成员目录,方便排查部门内部协作。`})]}),(0,B.jsx)(zy,{children:e.length===0?(0,B.jsxs)(`div`,{className:K(FF,`rounded-3xl px-6 py-12 text-center`),children:[(0,B.jsx)(Xo,{className:`mx-auto h-10 w-10 text-muted-foreground/45`}),(0,B.jsx)(`div`,{className:`mt-4 text-base font-medium text-foreground`,children:`部门还没有成员`}),(0,B.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`先添加 1 到 3 个职责明确的角色,再开始分派任务。`}),(0,B.jsxs)(q,{className:`mt-4`,onClick:i,children:[(0,B.jsx)(Oo,{className:`h-4 w-4`}),`添加第一个成员`]})]}):(0,B.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-1 2xl:grid-cols-2`,children:e.map(e=>(0,B.jsx)(qF,{stats:e,selected:t===e.member.name,onSelect:()=>n(e.member.name),onDelete:()=>r(e.member.name)},e.member.id))})})]})}function qF({stats:e,selected:t,onSelect:n,onDelete:r}){let i=AF[e.state],a=e.member.role===`department_head`;return(0,B.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:K(`group relative flex w-full flex-col gap-4 overflow-hidden rounded-3xl border p-4 text-left transition-all duration-200 hover:-translate-y-0.5 hover:shadow-xl`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i.card,t&&`ring-2 ring-primary/25 shadow-xl`),children:[(0,B.jsx)(`div`,{className:`absolute -right-5 -top-5 h-20 w-20 rounded-full bg-white/70 blur-2xl dark:bg-white/10`}),(0,B.jsxs)(`div`,{className:`relative flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,B.jsx)(`div`,{className:K(`flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl`,i.halo),children:a?(0,B.jsx)(qo,{className:`h-5 w-5`}):(0,B.jsx)(Yo,{className:`h-5 w-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`truncate text-base font-semibold text-foreground dark:text-slate-50`,children:e.member.name}),a&&(0,B.jsx)(J,{variant:`secondary`,children:`Department Head`})]}),(0,B.jsx)(`div`,{className:`truncate text-sm text-muted-foreground dark:text-slate-300`,children:e.member.focusOn||`尚未设置职责`})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:i.badge,children:i.label}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`opacity-0 transition-opacity group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),r()},title:`移除成员`,children:(0,B.jsx)(Go,{className:`h-4 w-4 text-muted-foreground`})})]})]}),(0,B.jsxs)(`div`,{className:`relative space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground dark:text-slate-300`,children:[(0,B.jsx)(`span`,{children:`活跃度`}),(0,B.jsxs)(`span`,{children:[e.totalMessages,` 条动作`]})]}),(0,B.jsx)(`div`,{className:`h-2 rounded-full bg-background/80 dark:bg-slate-950/35`,children:(0,B.jsx)(`div`,{className:K(`h-2 rounded-full transition-all`,i.bar),style:{width:`${e.activityPercent}%`}})})]}),(0,B.jsxs)(`div`,{className:`relative grid grid-cols-3 gap-2`,children:[(0,B.jsx)(JF,{label:`收到`,value:e.receivedMessages.length,accent:`text-sky-600`}),(0,B.jsx)(JF,{label:`发出`,value:e.sentMessages.length,accent:`text-emerald-600`}),(0,B.jsx)(JF,{label:e.failedCount>0?`风险`:`完成`,value:e.failedCount>0?e.failedCount:e.doneCount,accent:e.failedCount>0?`text-rose-600`:`text-violet-600`})]}),(0,B.jsxs)(`div`,{className:K(IF,`relative p-3 text-sm leading-6 text-muted-foreground dark:text-slate-300`),children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground dark:text-slate-50`,children:`下一步:`}),OI(e.nextAction,62)]}),(0,B.jsxs)(`div`,{className:`relative flex items-center justify-between text-xs text-muted-foreground dark:text-slate-300`,children:[(0,B.jsx)(`span`,{children:e.lastActiveAt?`最近动作 ${NI(e.lastActiveAt)}`:`尚未进入任务循环`}),(0,B.jsx)(`span`,{className:`font-medium text-foreground/85 dark:text-slate-200`,children:t?`当前聚焦`:`点击查看`})]})]})}function JF({label:e,value:t,accent:n}){return(0,B.jsxs)(`div`,{className:K(IF,`px-3 py-2`),children:[(0,B.jsx)(`div`,{className:`text-[11px] text-muted-foreground dark:text-slate-300`,children:e}),(0,B.jsx)(`div`,{className:K(`mt-1 text-lg font-semibold`,n),children:t})]})}function YF({departmentName:e,stats:t,memberNameMap:n,onOpenContext:r}){if(!t)return(0,B.jsx)(Y,{className:K(MF,`border-dashed`),children:(0,B.jsxs)(zy,{className:`flex min-h-[420px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,B.jsx)(Yo,{className:`h-12 w-12 text-muted-foreground/45`}),(0,B.jsx)(`div`,{className:`mt-4 text-lg font-medium text-foreground`,children:`先选一个成员`}),(0,B.jsx)(`div`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:`右侧会固定展示这名成员的任务流、原始收件箱和执行上下文,不再需要来回切 tab。`})]})});let i=AF[t.state];return(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(Y,{className:LF,children:[(0,B.jsx)(`div`,{className:`absolute inset-0 bg-[radial-gradient(circle_at_top_left,rgba(99,102,241,0.16),transparent_34%)] dark:bg-[radial-gradient(circle_at_top_left,rgba(99,102,241,0.32),transparent_34%)]`}),(0,B.jsx)(`div`,{className:`absolute inset-0 bg-[radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.12),transparent_28%)] dark:bg-[radial-gradient(circle_at_bottom_right,rgba(16,185,129,0.22),transparent_28%)]`}),(0,B.jsx)(zy,{className:`relative px-6 py-6 sm:px-7`,children:(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-4`,children:[(0,B.jsx)(`div`,{className:K(`flex h-14 w-14 shrink-0 items-center justify-center rounded-3xl border border-border/50 dark:border-white/10`,i.halo),children:(0,B.jsx)(Yo,{className:`h-6 w-6`})}),(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`truncate text-2xl font-semibold`,children:t.member.name}),(0,B.jsx)(J,{variant:`outline`,className:i.badge,children:i.label})]})})]}),(0,B.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(t.member.name),className:RF,children:[(0,B.jsx)(Wo,{className:`h-4 w-4`}),`查看完整上下文`]})]}),(0,B.jsxs)(`div`,{className:`rounded-3xl border border-border/60 bg-background/80 p-4 dark:border-white/10 dark:bg-white/6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground dark:text-white`,children:[(0,B.jsx)(Yo,{className:`h-4 w-4 text-primary`}),`角色设定`]}),t.member.focusOn?.trim()?(0,B.jsx)(`div`,{className:`mt-3 text-slate-700 dark:text-slate-200`,children:(0,B.jsx)(QN,{content:t.member.focusOn,compact:!0,className:`[&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:text-xs [&_pre]:leading-5`})}):(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:`暂未设置职责,建议补充角色定位。`})]}),(0,B.jsxs)(`div`,{className:`rounded-3xl border border-border/60 bg-background/80 p-4 dark:border-white/10 dark:bg-white/6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground dark:text-white`,children:[(0,B.jsx)(Bo,{className:`h-4 w-4 text-amber-500 dark:text-amber-300`}),`当前建议动作`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-700 dark:text-slate-300`,children:t.nextAction})]}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,B.jsx)(XF,{icon:co,label:`收到消息`,value:t.receivedMessages.length,note:t.pendingCount>0?`${t.pendingCount} 条待响应`:`收件箱稳定`}),(0,B.jsx)(XF,{icon:Fo,label:`发出消息`,value:t.sentMessages.length,note:t.doneCount>0?`${t.doneCount} 条已完成`:`还没有回报`}),(0,B.jsx)(XF,{icon:Ua,label:`最近动作`,value:t.lastActiveAt?MI(t.lastActiveAt):`--`,note:t.lastActiveAt?NI(t.lastActiveAt):`尚未开始`})]})]})})]}),(0,B.jsx)(ZF,{stats:t,memberNameMap:n}),(0,B.jsxs)(`div`,{className:`grid gap-6 2xl:grid-cols-2`,children:[(0,B.jsx)($F,{stats:t,memberNameMap:n}),(0,B.jsx)(tI,{departmentName:e,memberName:t.member.name,onOpenContext:()=>r(t.member.name)})]})]})}function XF({icon:e,label:t,value:n,note:r}){return(0,B.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-background/80 p-4 dark:border-white/10 dark:bg-white/6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground dark:text-slate-300`,children:[(0,B.jsx)(e,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{children:t})]}),(0,B.jsx)(`div`,{className:`mt-3 text-2xl font-semibold text-foreground dark:text-white`,children:n}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground dark:text-slate-400`,children:r})]})}function ZF({stats:e,memberNameMap:t}){return(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-lg`,children:[(0,B.jsx)(Ea,{className:`h-5 w-5 text-primary`}),`任务流`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`只保留当前成员最近一轮最关键的往返消息,按时间倒序展示。`})]}),(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[e.combinedMessages.length,` 条动作`]})]})}),(0,B.jsx)(zy,{children:e.combinedMessages.length===0?(0,B.jsx)(`div`,{className:K(FF,`px-5 py-10 text-center text-sm text-muted-foreground`),children:`这名成员还没有进入协作回合,先给他一个明确任务会更直观。`}):(0,B.jsx)(`div`,{className:`space-y-3`,children:e.combinedMessages.slice(0,6).map(n=>(0,B.jsx)(QF,{message:n,direction:n.fromMailboxId===e.member.mailBoxId?`sent`:`received`,counterpartName:n.fromMailboxId===e.member.mailBoxId?t.get(n.toMailboxId):t.get(n.fromMailboxId)},n.id))})})]})}function QF({message:e,direction:t,counterpartName:n}){let[r,i]=(0,S.useState)(!1),a=e.content.length>180,o=kF[e.status]??kF.pending,s=e.threadId??e.id,c=t===`received`?{container:`border-sky-100 bg-sky-50/70 dark:border-sky-500/20 dark:bg-sky-500/10`,chip:`border-sky-200 bg-sky-100 text-sky-700 dark:border-sky-500/30 dark:bg-sky-500/15 dark:text-sky-200`,label:`收到任务`,icon:co}:{container:`border-emerald-100 bg-emerald-50/70 dark:border-emerald-500/20 dark:bg-emerald-500/10`,chip:`border-emerald-200 bg-emerald-100 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/15 dark:text-emerald-200`,label:`发出回报`,icon:Fo},l=e.parentMessageId?t===`received`?`线程追问`:`线程续报`:c.label,u=c.icon;return(0,B.jsxs)(`div`,{className:K(`rounded-2xl border p-4 transition-colors`,c.container,a&&`cursor-pointer hover:border-primary/25`),onClick:()=>{a&&i(e=>!e)},children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(J,{variant:`outline`,className:c.chip,children:[(0,B.jsx)(u,{className:`h-3 w-3`}),l]}),(0,B.jsx)(J,{variant:`outline`,className:o.chipClass,children:o.label}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-background/80 px-2 py-1 font-mono text-[11px] text-muted-foreground dark:bg-white/5 dark:text-slate-300`,children:[(0,B.jsx)(ro,{className:`h-3 w-3`}),DI(s)]}),e.parentMessageId&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-background/80 px-2 py-1 font-mono text-[11px] text-muted-foreground dark:bg-white/5 dark:text-slate-300`,children:[(0,B.jsx)(Ka,{className:`h-3 w-3`}),DI(e.parentMessageId)]}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground dark:text-slate-300`,children:[t===`received`?`来自`:`发给`,` `,n??`系统`]}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground dark:text-slate-300`,children:jI(e.sendTime)})]}),(0,B.jsx)(`div`,{className:`mt-3 text-sm leading-6 text-foreground dark:text-slate-100`,children:r||!a?(0,B.jsx)(QN,{content:e.content,compact:!0}):(0,B.jsx)(`p`,{className:`whitespace-pre-wrap`,children:AI(e.content,180)})}),a&&(0,B.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-muted-foreground dark:text-slate-300`,children:[r?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`}),r?`收起全文`:`展开全文`]})]})}function $F({stats:e,memberNameMap:t}){let{data:n}=DF({mailboxId:e.member.mailBoxId}),{data:r,isLoading:i}=OF({mailboxId:e.member.mailBoxId,limit:40}),a=[...r??[]].sort((e,t)=>e.createdAt-t.createdAt).slice(-8);return(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(_o,{className:`h-4 w-4 text-primary`}),`信箱投递过程`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`这里记录的是 mailbox 本身的动作轨迹:谁投递、谁查看、看完选中了哪封、何时回信。`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[n?.length??0,` 封消息`]}),(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[r?.length??0,` 条轨迹`]})]})]})}),(0,B.jsx)(zy,{children:i?(0,B.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,B.jsx)(X,{className:`h-24 w-full`},e))}):a.length===0?(0,B.jsx)(`div`,{className:K(FF,`px-4 py-10 text-center text-sm text-muted-foreground`),children:`暂无 mailbox 过程事件。新版本开始处理后,这里会持续记录浏览和决策轨迹。`}):(0,B.jsx)(iv,{className:`h-[360px] pr-4`,children:(0,B.jsx)(`div`,{children:a.map((e,n)=>(0,B.jsx)(eI,{event:e,index:n,isLast:n===a.length-1,memberNameMap:t},e.id))})})})]})}function eI({event:e,index:t,isLast:n,memberNameMap:r}){let i=CI(e),a=i.icon,o=wI(e,r),s=e.eventType===`message_status_changed`?String(e.detail?.nextStatus??``):e.message?.status,c=s?kF[s]??null:null,l=e.message?.threadId||(typeof e.detail?.threadId==`string`?e.detail.threadId:void 0)||e.messageId,u=e.eventType===`message_followed_up`&&typeof e.detail?.preview==`string`?e.detail.preview:e.message?.content;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[2rem_minmax(0,1fr)] gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative flex justify-center`,children:[!n&&(0,B.jsx)(`div`,{className:`absolute top-8 bottom-0 w-px bg-border dark:bg-slate-700`}),(0,B.jsx)(`div`,{className:K(`relative z-10 flex h-7 w-7 items-center justify-center rounded-full border text-xs font-semibold`,i.nodeClass),children:t+1})]}),(0,B.jsxs)(`div`,{className:K(`mb-3 rounded-lg border p-3`,i.rowClass),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(J,{variant:`outline`,className:i.chipClass,children:[(0,B.jsx)(a,{className:`h-3 w-3`}),i.label]}),c&&(0,B.jsx)(J,{variant:`outline`,className:c.chipClass,children:c.label}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-xs text-muted-foreground dark:text-slate-300`,children:MI(e.createdAt)})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-xs font-medium`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:o.from}),(0,B.jsx)(ka,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground dark:text-slate-400`}),(0,B.jsx)(`span`,{className:`truncate`,children:o.to}),l&&(0,B.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-background/80 px-2 py-1 font-mono text-[11px] text-muted-foreground dark:bg-slate-950/50 dark:text-slate-300`,children:DI(l)})]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-foreground dark:text-slate-100`,children:SI(e,r)}),u&&(0,B.jsxs)(`div`,{className:K(IF,`mt-3 p-3`),children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground dark:text-slate-300`,children:`消息摘要`}),(0,B.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-6 text-foreground dark:text-slate-100`,children:AI(u,160)})]})]})]})}function tI({departmentName:e,memberName:t,onOpenContext:n}){let{data:r,isLoading:i}=Ny(e,t),a=r?[...r.agentLogs].slice(-3).reverse():[];return(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(Wo,{className:`h-4 w-4 text-primary`}),`脑内上下文`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`不再直接堆完整日志,只先给你最近几段关键上下文。`})]}),(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[r?.agentLogs.length??0,` 条记录`]})]})}),(0,B.jsxs)(zy,{className:`space-y-4`,children:[i?(0,B.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,B.jsx)(X,{className:`h-20 w-full`},e))}):a.length===0?(0,B.jsx)(`div`,{className:K(FF,`px-4 py-10 text-center text-sm text-muted-foreground`),children:`该成员还没有执行记录。`}):(0,B.jsx)(`div`,{className:`space-y-3`,children:a.map(e=>(0,B.jsxs)(`div`,{className:K(PF,`p-4`),children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground dark:text-slate-300`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.index]}),(0,B.jsx)(J,{variant:e.role===`user`?`default`:`secondary`,children:e.role===`user`?`User`:`Assistant`})]}),(0,B.jsx)(`div`,{className:`mt-3 text-sm leading-6 text-foreground dark:text-slate-100`,children:(0,B.jsx)(bI,{log:e})})]},e.index))}),(0,B.jsxs)(q,{variant:`outline`,className:`w-full`,onClick:n,children:[(0,B.jsx)(Wo,{className:`h-4 w-4`}),`查看完整执行上下文`]})]})]})}function nI({messages:e,memberNameMap:t}){let[n,r]=(0,S.useState)(null);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-lg`,children:[(0,B.jsx)(Ea,{className:`h-5 w-5 text-primary`}),`部门主线战报`]}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`从全队视角看最近的协作主线,方便你快速判断当前整体推进节奏。`})]}),(0,B.jsxs)(J,{variant:`outline`,className:NF,children:[e.length,` 条`]})]})}),(0,B.jsx)(zy,{children:e.length===0?(0,B.jsx)(`div`,{className:K(FF,`px-5 py-12 text-center text-sm text-muted-foreground`),children:`全队还没有产生协作消息。`}):(0,B.jsx)(iv,{className:`max-h-[520px] pr-4`,children:(0,B.jsx)(`div`,{className:`space-y-3`,children:e.slice(0,12).map(e=>{let n=kF[e.status]??kF.pending,i=t.get(e.fromMailboxId)??EI(e.fromMailboxId),a=t.get(e.toMailboxId)??EI(e.toMailboxId),o=kI(e.content),s=o.length>260;return(0,B.jsxs)(`div`,{role:`button`,tabIndex:0,className:K(PF,`cursor-pointer p-4 transition-colors hover:border-primary/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`),onClick:()=>r(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e))},children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:n.chipClass,children:n.label}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-background/80 px-2 py-1 font-mono text-[11px] text-muted-foreground dark:bg-white/5 dark:text-slate-300`,children:[(0,B.jsx)(ro,{className:`h-3 w-3`}),DI(e.threadId??e.id)]}),e.parentMessageId&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-background/80 px-2 py-1 font-mono text-[11px] text-muted-foreground dark:bg-white/5 dark:text-slate-300`,children:[(0,B.jsx)(Ka,{className:`h-3 w-3`}),DI(e.parentMessageId)]}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground dark:text-slate-50`,children:i}),(0,B.jsx)(Fo,{className:`h-3.5 w-3.5 text-muted-foreground dark:text-slate-400`}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-foreground dark:text-slate-50`,children:a}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground dark:text-slate-300`,children:jI(e.sendTime)})]}),s?(0,B.jsx)(`div`,{className:`mt-3`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,B.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-2xl border border-border/60 bg-background/80 p-4 pr-5 dark:border-white/10 dark:bg-white/5`,children:(0,B.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-foreground dark:text-slate-100`,children:o})})}):(0,B.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap text-sm leading-6 text-foreground dark:text-slate-100`,children:o}),s&&(0,B.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground dark:text-slate-300`,children:`预览区域支持上下滚动`}),(0,B.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),r(e)},children:[(0,B.jsx)(Qa,{className:`h-4 w-4`}),`查看全文`]})]})]},e.id)})})})})]}),(0,B.jsx)(nw,{open:!!n,onOpenChange:e=>!e&&r(null),children:(0,B.jsx)(aw,{className:`sm:max-w-4xl max-h-[85vh] overflow-hidden grid-rows-[auto_minmax(0,1fr)]`,children:n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(ow,{children:[(0,B.jsxs)(cw,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(Ea,{className:`h-4 w-4`}),`部门主线战报详情`]}),(0,B.jsxs)(lw,{children:[t.get(n.fromMailboxId)??EI(n.fromMailboxId),` -> `,t.get(n.toMailboxId)??EI(n.toMailboxId),` · `,jI(n.sendTime)]})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col space-y-4 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:(kF[n.status]??kF.pending).chipClass,children:(kF[n.status]??kF.pending).label}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-muted px-2 py-1 font-mono text-xs text-muted-foreground`,children:[(0,B.jsx)(ro,{className:`h-3 w-3`}),DI(n.threadId??n.id)]}),n.parentMessageId&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-muted px-2 py-1 font-mono text-xs text-muted-foreground`,children:[(0,B.jsx)(Ka,{className:`h-3 w-3`}),DI(n.parentMessageId)]}),(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:"点击外部区域或按 `Esc` 可关闭"})]}),(0,B.jsx)(iv,{className:`min-h-0 flex-1 pr-4`,children:(0,B.jsx)(`div`,{className:K(PF,`p-5 text-foreground dark:text-slate-100`),children:(0,B.jsx)(QN,{content:n.content,className:`[&_h1]:text-xl [&_h2]:text-lg [&_h3]:text-base [&_pre]:text-xs [&_pre]:leading-6`})})})]})]}):null})})]})}function rI({department:e,summary:t,onAddMember:n}){return(0,B.jsxs)(Y,{className:MF,children:[(0,B.jsxs)(Iy,{children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-lg`,children:[(0,B.jsx)(zo,{className:`h-5 w-5 text-primary`}),`操作说明`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`详情页展示部门内部结构;CEO视角仍以 Department Head 为唯一入口。`})]}),(0,B.jsxs)(zy,{className:`space-y-5`,children:[(0,B.jsx)(`div`,{className:`space-y-3`,children:[`先看 Department Head 是否已经接住任务,再决定是否进入 executor 细节。`,`右侧优先读“当前建议动作”和“任务流”,大多数判断不需要翻完整日志。`,`只有当消息不够解释行为时,再点开完整上下文去看内部推理和工具调用。`].map((e,t)=>(0,B.jsxs)(`div`,{className:K(PF,`flex items-start gap-3 px-4 py-3`),children:[(0,B.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-sm font-semibold text-primary`,children:t+1}),(0,B.jsx)(`p`,{className:`text-sm leading-6 text-foreground dark:text-slate-100`,children:e})]},e))}),(0,B.jsxs)(`div`,{className:K(PF,`rounded-3xl p-4`),children:[(0,B.jsx)(`div`,{className:`text-xs font-semibold tracking-[0.18em] text-muted-foreground dark:text-slate-300`,children:`部门参数`}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,B.jsx)(iI,{icon:Uo,label:`目标 ID`,value:e.sourceGoalId??`未关联`,mono:!!e.sourceGoalId}),(0,B.jsx)(iI,{icon:qo,label:`Department Head`,value:t.headName}),(0,B.jsx)(iI,{icon:Xo,label:`执行层 executor`,value:`${t.executorCount} 人`}),(0,B.jsx)(iI,{icon:eo,label:`工作目录`,value:e.workpath??`未设置`,mono:!!e.workpath}),(0,B.jsx)(iI,{icon:Ao,label:`刷新策略`,value:`自动 5 秒同步 + 手动刷新`})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`状态图例`}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.values(AF).map(e=>(0,B.jsx)(J,{variant:`outline`,className:e.badge,children:e.label},e.label))})]}),(0,B.jsxs)(q,{className:`w-full`,onClick:n,children:[(0,B.jsx)(Oo,{className:`h-4 w-4`}),`添加新成员`]})]})]})}function iI({icon:e,label:t,value:n,mono:r=!1}){return(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-background text-muted-foreground ring-1 ring-border dark:bg-slate-950/35 dark:text-slate-200 dark:ring-white/10`,children:(0,B.jsx)(e,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground dark:text-slate-300`,children:t}),(0,B.jsx)(`div`,{className:K(`mt-1 break-all text-sm text-foreground dark:text-slate-100`,r&&`font-mono text-xs`),children:n})]})]})}function aI(){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[minmax(320px,0.92fr)_minmax(0,1.08fr)]`,children:[(0,B.jsxs)(Y,{children:[(0,B.jsxs)(Iy,{children:[(0,B.jsx)(X,{className:`h-7 w-32`}),(0,B.jsx)(X,{className:`h-4 w-64`})]}),(0,B.jsx)(zy,{className:`space-y-3`,children:[1,2,3].map(e=>(0,B.jsx)(X,{className:`h-40 w-full`},e))})]}),(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsx)(X,{className:`h-52 w-full rounded-3xl`}),(0,B.jsx)(X,{className:`h-72 w-full rounded-3xl`}),(0,B.jsxs)(`div`,{className:`grid gap-6 2xl:grid-cols-2`,children:[(0,B.jsx)(X,{className:`h-80 w-full rounded-3xl`}),(0,B.jsx)(X,{className:`h-80 w-full rounded-3xl`})]})]})]}),(0,B.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(300px,0.85fr)]`,children:[(0,B.jsx)(X,{className:`h-[420px] w-full rounded-3xl`}),(0,B.jsx)(X,{className:`h-[420px] w-full rounded-3xl`})]})]})}function oI({departmentName:e,memberName:t,onClose:n}){let{data:r,isLoading:i}=Ny(e,t);return(0,B.jsx)(nw,{open:!!t,onOpenChange:e=>!e&&n(),children:(0,B.jsxs)(aw,{className:`sm:max-w-4xl max-h-[85vh]`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsxs)(cw,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Yo,{className:`h-4 w-4`}),t??`成员`,` 的完整上下文`]}),(0,B.jsx)(lw,{children:r?r.mailBoxId:`加载中...`})]}),i?(0,B.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,B.jsx)(X,{className:`h-5 w-32`}),[1,2,3,4].map(e=>(0,B.jsx)(X,{className:`h-16 w-full`},e))]}):r?(0,B.jsx)(`div`,{className:`max-h-[65vh] overflow-y-auto rounded-md border p-3`,children:(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,B.jsx)(Wo,{className:`h-4 w-4 text-emerald-500`}),(0,B.jsx)(`h3`,{className:`text-sm font-semibold`,children:`对话上下文`}),(0,B.jsxs)(J,{variant:`outline`,className:`text-xs`,children:[r.agentLogs.length,` 条`]})]}),r.agentLogs.length===0?(0,B.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground/60`,children:`该成员暂无执行记录`}):(0,B.jsx)(`div`,{className:`space-y-4 pl-1`,children:r.agentLogs.map(e=>(0,B.jsx)(sI,{log:e},e.index))})]})}):(0,B.jsx)(`div`,{className:`py-12 text-center text-muted-foreground`,children:`无法加载成员上下文`})]})})}function sI({log:e}){let t=e.role===`user`;return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs text-muted-foreground/60`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.index]}),(0,B.jsx)(J,{variant:t?`default`:`secondary`,className:`text-[10px] px-1.5 py-0 h-4`,children:t?`User`:`Assistant`})]}),(0,B.jsx)(`div`,{className:`space-y-2 pl-2`,children:e.blocks.map((e,n)=>e.type===`text`?(0,B.jsx)(cI,{text:String(e.text??``),isUser:t},n):e.type===`tool_use`?(0,B.jsx)(uI,{name:String(e.name??`unknown`),input:e.input},n):e.type===`tool_result`?(0,B.jsx)(dI,{toolUseId:String(e.toolUseId??``),content:e.content},n):e.type===`thinking`?(0,B.jsx)(lI,{thinking:typeof e.thinking==`string`?e.thinking:``},n):e.type===`image`?(0,B.jsx)(`div`,{className:`rounded-md border border-slate-500/15 bg-slate-500/5 px-3 py-2 text-sm text-muted-foreground`,children:`图片内容块`},n):(0,B.jsxs)(`div`,{className:`rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground`,children:[`[unknown block: `,e.type,`]`]},n))})]})}function cI({text:e,isUser:t}){let[n,r]=(0,S.useState)(!1),i=e.length>300;return(0,B.jsxs)(`div`,{className:K(`cursor-pointer rounded-md border px-3 py-2 text-sm whitespace-pre-wrap break-words`,t?`border-emerald-500/10 bg-emerald-500/5 text-foreground`:`border-sky-500/10 bg-sky-500/5 text-foreground`),onClick:()=>{i&&r(e=>!e)},children:[n||!i?(0,B.jsx)(QN,{content:e,compact:!0,className:K(`[&_a]:text-primary [&_blockquote]:text-inherit [&_code]:bg-black/6 dark:[&_code]:bg-white/10 [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:text-xs [&_pre]:leading-5`,t?`[&_blockquote]:border-emerald-500/20`:`[&_blockquote]:border-sky-500/20`)}):AI(e,300),i&&(0,B.jsxs)(`span`,{className:`ml-1 inline-flex text-muted-foreground/40`,children:[n?(0,B.jsx)(La,{className:`inline h-3 w-3`}):(0,B.jsx)(za,{className:`inline h-3 w-3`}),(0,B.jsx)(`span`,{className:`ml-0.5 text-xs`,children:n?`收起`:`展开`})]})]})}function lI({thinking:e}){let[t,n]=(0,S.useState)(!1),r=e.trim().length>0;return(0,B.jsxs)(`div`,{className:`rounded-md border border-violet-500/15 bg-violet-500/5 px-3 py-2 text-sm text-muted-foreground`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>n(e=>!e),children:[(0,B.jsx)(Bo,{className:`h-3.5 w-3.5 shrink-0 text-violet-500`}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:`thinking`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:`模型思考块`}),r&&(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),t&&r&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:e})]})}function uI({name:e,input:t}){let[n,r]=(0,S.useState)(!1),i=JSON.stringify(t,null,2);return(0,B.jsxs)(`div`,{className:`rounded-md border border-primary/20 bg-primary/5 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-2`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Qo,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,B.jsx)(`span`,{className:`text-sm font-semibold text-primary`,children:e}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground/40`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:i})]})}function dI({toolUseId:e,content:t}){let[n,r]=(0,S.useState)(!1),i=typeof t==`string`?t:JSON.stringify(t,null,2);return(0,B.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/40 px-3 py-2`,children:[e&&(0,B.jsxs)(`div`,{className:`mb-1 truncate font-mono text-[10px] text-muted-foreground/50`,children:[`toolUseId: `,e]}),(0,B.jsxs)(`div`,{className:`mb-1 flex cursor-pointer items-center gap-2`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Qa,{className:`h-3 w-3 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`执行结果`}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground/40`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:i})]})}var fI=`manager`;function pI(e,t,n){return e.fromMailboxId===t&&(e.toMailboxId===fI||e.toMailboxId===n)}function mI(e,t,n){let r=t.filter(t=>t.toMailboxId===e.mailBoxId),i=t.filter(t=>t.fromMailboxId===e.mailBoxId),a=[...r,...i].sort((e,t)=>t.sendTime-e.sendTime),o=a.filter(t=>!pI(t,e.mailBoxId,n)),s=o.filter(e=>e.status===`pending`).length,c=o.filter(e=>e.status===`processing`).length,l=r.filter(e=>e.status===`done`).length,u=o.filter(e=>e.status===`failed`).length,d=i.some(t=>pI(t,e.mailBoxId,n)),f=`standby`;return f=u>0?`support`:c>0?`running`:s>0?`queued`:a.length===0?`standby`:l>0||d?`completed`:`active`,{member:e,receivedMessages:r,sentMessages:i,combinedMessages:a,totalMessages:a.length,pendingCount:s,processingCount:c,doneCount:l,failedCount:u,lastActiveAt:a[0]?.sendTime??null,state:f,nextAction:vI({state:f,totalMessages:a.length,pendingCount:s,processingCount:c,failedCount:u,focusOn:e.focusOn}),activityPercent:0}}function hI(e,t,n){let r=e?.departmentMembers.length??0,i=gI(e),a=Math.max(0,r-+!!i),o=i?.name??`未配置`,s=t.filter(e=>e.totalMessages>0).length,c=n.filter(e=>e.status===`pending`||e.status===`processing`).length,l=n.filter(e=>e.status===`done`).length,u=n.filter(e=>e.status===`failed`).length,d=n[0]?.sendTime??null;return r===0?{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`等待招募`,stageHint:`这个部门还没有成员。先招募角色,再开始派发任务。`,stageTone:`border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-300/20 dark:bg-slate-300/10 dark:text-slate-100`}:u>0?{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`需要人工支援`,stageHint:`有成员产生了失败结果,建议从红色成员卡开始排查本轮阻塞。`,stageTone:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-300/20 dark:bg-rose-400/10 dark:text-rose-100`}:c>0?{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`任务推进中`,stageHint:`当前有消息正在流转。先点一个角色卡,看他最近一轮的任务流。`,stageTone:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-300/20 dark:bg-sky-400/10 dark:text-sky-100`}:l>0?{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`本轮已收官`,stageHint:`最近一轮基本已经闭环,可以继续派发下一步任务。`,stageTone:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-300/20 dark:bg-emerald-400/10 dark:text-emerald-100`}:s>0?{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`协作已启动`,stageHint:`成员之间已经开始协作,但还没有形成完整回合,可以先看谁最活跃。`,stageTone:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-300/20 dark:bg-violet-400/10 dark:text-violet-100`}:{totalMembers:r,executorCount:a,headName:o,activeMembers:s,inFlightCount:c,completedCount:l,riskCount:u,totalMessages:n.length,lastPulseAt:d,stageLabel:`等待首个任务`,stageHint:`部门已经存在,但还没有消息流转。先给每个角色一个明确分工。`,stageTone:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-300/20 dark:bg-amber-400/10 dark:text-amber-100`}}function gI(e){return e?e.departmentMembers.find(t=>t.id===e.headMemberId)??e.departmentMembers.find(e=>e.role===`department_head`)??null:null}function _I(e){let t=gI(e),n=e.departmentMembers.filter(e=>e.id!==t?.id);return t?[t,...n]:n}function vI({state:e,totalMessages:t,pendingCount:n,processingCount:r,failedCount:i,focusOn:a}){return e===`support`?`该成员有 ${i} 条失败结果,建议先人工查看原因,再决定是否继续推进。`:e===`running`?`该成员正在执行中,先观察结果回报;如果长时间无响应,再补充 ${a||`任务`} 上下文。`:e===`queued`?`收件箱里还有 ${n} 条待处理消息,优先确认这轮任务是否足够明确。`:e===`completed`?`上一轮已经交付,可以继续给他下发下一步,或者切到其他角色看看是否需要衔接。`:e===`active`?`这名成员已经进入协作流,建议查看最近往返消息,判断是否需要追问或补充边界。`:t===0?`这名成员还没有开始行动,先给他一个清晰的小目标${a?`,最好贴合 ${a}`:``}。`:r>0?`任务仍在推进,先观察这一轮结果。`:`可以继续观察最近战报,确认是否需要新的输入。`}function yI(e){for(let t of e.blocks){if(t.type===`text`&&typeof t.text==`string`&&t.text.trim())return OI(t.text.trim(),180);if(t.type===`tool_use`)return`调用工具 ${String(t.name??`unknown`)},参数已写入执行上下文。`;if(t.type===`tool_result`)return typeof t.content==`string`&&t.content.trim()?OI(t.content.trim(),180):`收到一次工具执行结果。`;if(t.type===`thinking`)return`模型思考块。`;if(t.type===`image`)return`图片内容块。`}return`该记录没有可预览的文本内容。`}function bI({log:e}){let t=xI(e);return t?t.type===`markdown`?(0,B.jsx)(`div`,{className:`max-h-44 overflow-hidden`,children:(0,B.jsx)(QN,{content:t.content,compact:!0,className:`[&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:text-xs [&_pre]:leading-5`})}):(0,B.jsx)(`p`,{className:`whitespace-pre-wrap`,children:t.content}):(0,B.jsx)(`p`,{className:`whitespace-pre-wrap`,children:yI(e)})}function xI(e){for(let t of e.blocks){if(t.type===`text`&&typeof t.text==`string`&&t.text.trim())return{type:`markdown`,content:t.text.trim()};if(t.type===`tool_result`&&typeof t.content==`string`&&t.content.trim())return{type:`markdown`,content:t.content.trim()};if(t.type===`tool_use`)return{type:`text`,content:`调用工具 ${String(t.name??`unknown`)},参数已写入执行上下文。`};if(t.type===`thinking`)return{type:`text`,content:`模型思考块。`};if(t.type===`image`)return{type:`text`,content:`图片内容块。`}}return null}function SI(e,t){let n=TI(e.actorMailboxId,t),r=TI(e.mailboxId,t),i=TI(e.counterpartMailboxId??e.message?.fromMailboxId,t),a=typeof e.detail?.visibleCount==`number`?e.detail.visibleCount:null,o=typeof e.detail?.previousStatus==`string`?e.detail.previousStatus:null,s=typeof e.detail?.nextStatus==`string`?e.detail.nextStatus:null;if(e.eventType===`message_sent`)return`${TI(e.message?.fromMailboxId,t)??n} 向 ${TI(e.message?.toMailboxId,t)??r} 投递了一封邮件。`;if(e.eventType===`mailbox_listed`)return`${n??r??`成员`} 查看了邮箱,当前看到了 ${a??0} 封候选邮件。`;if(e.eventType===`message_opened`)return`${n??r??`成员`} 已选中一封邮件开始阅读,来源是 ${i??`上游成员`}。`;if(e.eventType===`message_replied`)return`${n??r??`成员`} 已完成处理,并把结果回给了 ${i??`上游成员`}。`;if(e.eventType===`message_discarded`){let t=typeof e.detail?.reason==`string`?e.detail.reason:null;return`${n??r??`成员`} 已将一封无需业务回复的邮件移出待处理队列${t?`,原因:${t}`:``}。`}if(e.eventType===`message_followed_up`){let t=typeof e.detail?.kind==`string`?e.detail.kind:`progress`,a=t===`question`?`追问`:t===`partial_result`?`部分结果`:t===`nudge`?`催办`:`进展`,o=e.message?.threadId||(typeof e.detail?.threadId==`string`?e.detail.threadId:void 0)||e.messageId;return`${n??r??`成员`} 在线程 ${DI(o??`unknown`)} 中追加了一条${a},发送给 ${i??`上游成员`}。`}return e.eventType===`message_status_changed`?`${r??`该邮箱`} 中的一封邮件状态从 ${o??`unknown`} 变成了 ${s??`unknown`}。`:`发生了一条 mailbox 过程事件。`}function CI(e){let t=jF[e.eventType]??{label:`未知事件`,chipClass:`border-slate-200 bg-slate-100 text-slate-700 dark:border-slate-500/30 dark:bg-slate-500/15 dark:text-slate-200`,icon:Ea},n=e.eventType===`message_status_changed`&&typeof e.detail?.nextStatus==`string`?e.detail.nextStatus:e.message?.status,r=typeof e.detail?.kind==`string`?e.detail.kind:``;return n===`failed`||n===`cancelled`||r===`question`||r===`nudge`?{...t,nodeClass:`border-rose-300 bg-rose-50 text-rose-700 dark:border-rose-500/40 dark:bg-rose-500/15 dark:text-rose-200`,rowClass:`border-rose-200 bg-rose-50/45 dark:border-rose-500/30 dark:bg-rose-500/10`}:e.eventType===`message_replied`?{...t,nodeClass:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-500/40 dark:bg-emerald-500/15 dark:text-emerald-200`,rowClass:`border-emerald-200 bg-emerald-50/40 dark:border-emerald-500/25 dark:bg-emerald-500/10`}:e.eventType===`message_discarded`?{...t,nodeClass:`border-slate-300 bg-slate-50 text-slate-700 dark:border-slate-500/40 dark:bg-slate-500/15 dark:text-slate-200`,rowClass:`border-slate-200 bg-slate-50/45 dark:border-slate-500/30 dark:bg-slate-500/10`}:e.eventType===`message_followed_up`?{...t,nodeClass:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-500/40 dark:bg-violet-500/15 dark:text-violet-200`,rowClass:`border-violet-200 bg-violet-50/35 dark:border-violet-500/25 dark:bg-violet-500/10`}:{...t,nodeClass:`border-primary/30 bg-primary/10 text-primary dark:border-primary/40 dark:bg-primary/15`,rowClass:`border-border/70 bg-muted/20 dark:border-slate-700/70 dark:bg-slate-900/40`}}function wI(e,t){return e.eventType===`mailbox_listed`?{from:TI(e.actorMailboxId||e.mailboxId,t)??`成员`,to:`收件箱`}:e.eventType===`message_opened`?{from:TI(e.counterpartMailboxId,t)??TI(e.message?.fromMailboxId,t)??`上游成员`,to:TI(e.mailboxId,t)??`邮箱`}:{from:TI(e.message?.fromMailboxId,t)??TI(e.actorMailboxId,t)??TI(e.counterpartMailboxId,t)??TI(e.mailboxId,t)??`unknown`,to:TI(e.message?.toMailboxId,t)??TI(e.counterpartMailboxId,t)??TI(e.mailboxId,t)??TI(e.actorMailboxId,t)??`unknown`}}function TI(e,t){return e?t.get(e)??EI(e):null}function EI(e){return e.length<=12?e:`${e.slice(0,8)}...`}function DI(e){return e.length<=10?e:`${e.slice(0,8)}...`}function OI(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function kI(e){return e.replace(/\r\n?/g,`
|
|
90
90
|
`).replace(/```[\s\S]*?```/g,e=>e.replace(/```[\w-]*\n?/g,``).trim()).replace(/^#{1,6}\s+/gm,``).replace(/^\s*>\s?/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+\.\s+/gm,``).replace(/\[([^\]]+)\]\(([^)]+)\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\n{3,}/g,`
|
|
91
91
|
|
|
92
|
-
`).trim()}function AI(e,t){return OI(kI(e),t)}function jI(e){try{return new Date(e).toLocaleString(`zh-CN`)}catch{return String(e)}}function MI(e){try{return new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}function NI(e){try{let t=Date.now()-e;return t<6e4?`刚刚`:t<36e5?`${Math.max(1,Math.floor(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.floor(t/36e5))} 小时前`:new Date(e).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}var PI={title:``,description:``,syntax:`0 * * * *`,channel:`default`,to:``};function FI(){let{data:e,isLoading:t,refetch:n}=jv(),r=Nv(),i=Pv(),a=ri(),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(PI),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(!1),v=()=>{d(PI),s(!0)},y=e=>{d({title:e.title,description:e.description,syntax:e.schedule.syntax,channel:e.delivery.channel,to:e.delivery.to}),l(e)},b=async()=>{!u.title.trim()||!u.syntax.trim()||(await r.mutateAsync({title:u.title,description:u.description,schedule:{syntax:u.syntax},delivery:{channel:u.channel,to:u.to}}),s(!1),d(PI))},x=async()=>{if(!(!c||!u.title.trim()||!u.syntax.trim())){_(!0);try{await Tv(c.id,{title:u.title,description:u.description,schedule:{syntax:u.syntax,createTime:c.schedule.createTime,lastRunTime:c.schedule.lastRunTime},delivery:{channel:u.channel,to:u.to}}),await a.invalidateQueries({queryKey:Av.all}),l(null),d(PI)}finally{_(!1)}}},C=async e=>{await Dv(e.id,!e.enabled),await a.invalidateQueries({queryKey:Av.all})},w=async e=>{await Ov(e.id),await a.invalidateQueries({queryKey:Av.all})},T=async()=>{f&&(await i.mutateAsync(f),p(null))},E=e=>{if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`)}catch{return e}};return(0,B.jsx)(Py,{children:(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Cron Jobs`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`管理定时任务调度`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>n(),children:(0,B.jsx)(Ao,{className:`h-4 w-4`})}),(0,B.jsxs)(q,{size:`sm`,onClick:v,children:[(0,B.jsx)(Oo,{className:`h-4 w-4 mr-1`}),`新建任务`]})]})]}),t?(0,B.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`p-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(X,{className:`h-5 w-48`}),(0,B.jsx)(X,{className:`h-4 w-32`})]}),(0,B.jsx)(X,{className:`h-6 w-12`})]})})},e))}):!e||e.length===0?(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`py-12`,children:(0,B.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,B.jsx)(Wa,{className:`h-10 w-10 text-muted-foreground mb-3`}),(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`暂无定时任务`}),(0,B.jsxs)(q,{variant:`outline`,className:`mt-3`,size:`sm`,onClick:v,children:[(0,B.jsx)(Oo,{className:`h-4 w-4 mr-1`}),`创建第一个任务`]})]})})}):(0,B.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`p-4`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,B.jsx)(`h3`,{className:`font-medium truncate`,children:e.title}),(0,B.jsx)(J,{variant:e.enabled?`default`:`secondary`,children:e.enabled?`启用`:`禁用`})]}),e.description&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-1 mb-2`,children:e.description}),(0,B.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono bg-muted px-1.5 py-0.5 rounded`,children:e.schedule.syntax}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(Wa,{className:`h-3 w-3 inline mr-1`}),E(e.schedule.lastRunTime)]}),(0,B.jsxs)(`span`,{children:[e.delivery.channel,` → `,e.delivery.to]})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,B.jsx)(iP,{checked:e.enabled,onCheckedChange:()=>C(e)}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>w(e),disabled:!e.enabled,title:`手动触发`,children:(0,B.jsx)(Do,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>h(e.id),title:`执行历史`,children:(0,B.jsx)(Wa,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>y(e),title:`编辑`,children:(0,B.jsx)(Ba,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>p(e.id),title:`删除`,children:(0,B.jsx)(Go,{className:`h-4 w-4`})})]})]})})},e.id))}),(0,B.jsx)(nw,{open:o,onOpenChange:s,children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`新建定时任务`}),(0,B.jsx)(lw,{children:`配置 cron 表达式和投递方式`})]}),(0,B.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:u.title,onChange:e=>d(t=>({...t,title:e.target.value})),placeholder:`任务标题`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`描述`}),(0,B.jsx)(tw,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:`任务描述(可选)`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`Cron 表达式`}),(0,B.jsx)(ew,{value:u.syntax,onChange:e=>d(t=>({...t,syntax:e.target.value})),placeholder:`0 * * * *`,className:`font-mono`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`格式: 分 时 日 月 周(如 0 */2 * * * 表示每2小时)`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递通道`}),(0,B.jsx)(ew,{value:u.channel,onChange:e=>d(t=>({...t,channel:e.target.value})),placeholder:`channel`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递目标`}),(0,B.jsx)(ew,{value:u.to,onChange:e=>d(t=>({...t,to:e.target.value})),placeholder:`to`})]})]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>s(!1),children:`取消`}),(0,B.jsxs)(q,{onClick:b,disabled:r.isPending||!u.title.trim(),children:[r.isPending&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`创建`]})]})]})}),(0,B.jsx)(nw,{open:!!c,onOpenChange:()=>l(null),children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`编辑定时任务`}),(0,B.jsx)(lw,{children:`修改任务配置`})]}),(0,B.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:u.title,onChange:e=>d(t=>({...t,title:e.target.value})),placeholder:`任务标题`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`描述`}),(0,B.jsx)(tw,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:`任务描述(可选)`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`Cron 表达式`}),(0,B.jsx)(ew,{value:u.syntax,onChange:e=>d(t=>({...t,syntax:e.target.value})),placeholder:`0 * * * *`,className:`font-mono`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递通道`}),(0,B.jsx)(ew,{value:u.channel,onChange:e=>d(t=>({...t,channel:e.target.value})),placeholder:`channel`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递目标`}),(0,B.jsx)(ew,{value:u.to,onChange:e=>d(t=>({...t,to:e.target.value})),placeholder:`to`})]})]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>l(null),children:`取消`}),(0,B.jsxs)(q,{onClick:x,disabled:g||!u.title.trim(),children:[g&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`保存`]})]})]})}),(0,B.jsx)(nw,{open:!!f,onOpenChange:()=>p(null),children:(0,B.jsxs)(aw,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`确认删除`}),(0,B.jsx)(lw,{children:`删除后不可恢复,确定要删除此定时任务吗?`})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>p(null),children:`取消`}),(0,B.jsxs)(q,{variant:`destructive`,onClick:T,disabled:i.isPending,children:[i.isPending&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`删除`]})]})]})}),(0,B.jsx)(II,{jobId:m,onClose:()=>h(null)})]})})}function II({jobId:e,onClose:t}){let{data:n,isLoading:r}=Mv(e??``);return(0,B.jsx)(nw,{open:!!e,onOpenChange:()=>t(),children:(0,B.jsxs)(aw,{className:`sm:max-w-lg`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`执行历史`}),(0,B.jsx)(lw,{children:`查看该定时任务的执行记录`})]}),(0,B.jsx)(iv,{className:`max-h-[400px]`,children:r?(0,B.jsx)(`div`,{className:`space-y-2 py-4`,children:[1,2,3].map(e=>(0,B.jsx)(X,{className:`h-12 w-full`},e))}):!n||n.length===0?(0,B.jsx)(`div`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`暂无执行记录`}):(0,B.jsx)(`div`,{className:`space-y-2`,children:n.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border text-sm`,children:[(0,B.jsx)(`div`,{children:(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:LI(e.timestamp)})}),(0,B.jsx)(J,{variant:e.result===`success`?`default`:`destructive`,children:e.result})]},t))})})]})})}function LI(e){try{return new Date(e).toLocaleString(`zh-CN`)}catch{return e}}function RI({...e}){return(0,B.jsx)(Xs,{"data-slot":`collapsible`,...e})}function zI({...e}){return(0,B.jsx)(Gs,{"data-slot":`collapsible-trigger`,...e})}function BI({...e}){return(0,B.jsx)(qs,{"data-slot":`collapsible-content`,...e})}var VI={file:{label:`文件操作`,icon:Qa},web:{label:`网络`,icon:io},system:{label:`系统`,icon:Io},task:{label:`任务管理`,icon:mo},department:{label:`部门管理`,icon:Xo},cron:{label:`定时任务`,icon:Wa}},HI={label:`其他`,icon:ko};function UI(e){let t=e.toLowerCase();return t.includes(`file`)||t.includes(`read`)||t.includes(`write`)||t.includes(`edit`)||t.includes(`glob`)||t.includes(`grep`)||t.includes(`bash`)||t.includes(`mkdir`)?`file`:t.includes(`web`)||t.includes(`search`)||t.includes(`fetch`)||t.includes(`http`)||t.includes(`url`)?`web`:t.includes(`system`)||t.includes(`process`)||t.includes(`env`)||t.includes(`config`)||t.includes(`memory`)?`system`:t.includes(`task`)||t.includes(`goal`)?`task`:t.includes(`department`)||t.includes(`member`)||t.includes(`communicat`)?`department`:t.includes(`cron`)||t.includes(`schedule`)||t.includes(`timer`)?`cron`:`other`}function WI({schema:e}){return e?.properties?(0,B.jsx)(`div`,{className:`space-y-2`,children:Object.entries(e.properties).map(([t,n])=>(0,B.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-sm font-medium`,children:t}),(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:n.type}),e.required?.includes(t)&&(0,B.jsx)(J,{variant:`destructive`,className:`text-xs`,children:`必填`})]}),n.description&&(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.description}),n.enum&&(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:n.enum.map(e=>(0,B.jsx)(J,{variant:`secondary`,className:`text-xs`,children:String(e)},String(e)))})]},t))}):null}function GI(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(new Set),{data:i,isLoading:a}=py(),o=(0,S.useMemo)(()=>{let t={};return(i??[]).filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase())).forEach(e=>{let n=UI(e.name);t[n]||(t[n]=[]),t[n].push(e)}),t},[i,e]),s=i?.length??0,c=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Tools`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`查看所有已注册的工具及其参数`})]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1`,children:[(0,B.jsx)(Qo,{className:`h-3 w-3`}),a?`...`:`${s} 个工具`]})]}),(0,B.jsxs)(`div`,{className:`relative mb-6`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{placeholder:`搜索工具...`,className:`pl-9`,value:e,onChange:e=>t(e.target.value)})]}),a?(0,B.jsx)(`div`,{className:`space-y-6`,children:Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(X,{className:`h-6 w-32`}),(0,B.jsx)(X,{className:`h-24 w-full`})]},t))}):Object.keys(o).length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,B.jsx)(Qo,{className:`mb-3 h-10 w-10`}),(0,B.jsx)(`p`,{className:`text-sm`,children:e?`未找到匹配的工具`:`暂无工具`})]}):(0,B.jsx)(`div`,{className:`space-y-8`,children:Object.entries(o).map(([e,t])=>{let r=VI[e]??HI,i=r.icon;return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,B.jsx)(i,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:r.label}),(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:t.length})]}),(0,B.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=n.has(e.name);return(0,B.jsx)(Y,{size:`sm`,children:(0,B.jsxs)(RI,{open:t,onOpenChange:()=>c(e.name),children:[(0,B.jsx)(zI,{className:`w-full`,children:(0,B.jsx)(Iy,{className:`cursor-pointer`,children:(0,B.jsxs)(Ly,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Qo,{className:`h-3.5 w-3.5 text-primary`}),(0,B.jsx)(`code`,{className:`text-sm`,children:e.name})]}),(0,B.jsx)(La,{className:`h-4 w-4 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})})}),(0,B.jsx)(BI,{children:(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`参数 Schema`}),(0,B.jsx)(WI,{schema:e.inputSchema})]})]})})]})},e.name)})})]},e)})})]})}var KI=dv(`group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function qI({className:e,variant:t,...n}){return(0,B.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:K(KI({variant:t}),e),...n})}function JI({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-title`,className:K(`font-heading font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground`,e),...t})}function YI({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-description`,className:K(`text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),...t})}var XI=e=>e?.scope===`department`?e.departmentName?`部门 Skill · ${e.departmentName}`:`部门 Skill`:e?.scope===`project`||e?.deletable?`项目 Skill`:`系统 Skill`,ZI=e=>e.replace(/[`*_#]/g,``).replace(/\s+/g,` `).trim(),QI=(e,t)=>e.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g,`-`).replace(/^-+|-+$/g,``)||t,$I=e=>{if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map($I).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return $I(t?.children)}return``},eL=e=>{let t=e??``,n=t.match(/^Base directory for this skill:\s*(.+)$/m),r=t.replace(/^Base directory for this skill:\s*.+\n{0,2}/,``).trim(),i=new Map,a=Array.from(r.matchAll(/^(#{1,4})\s+(.+)$/gm)).map((e,t)=>{let n=ZI(e[2]),r=QI(n,`section-${t+1}`),a=i.get(r)??0;return i.set(r,a+1),{level:e[1].length,text:n,id:a===0?r:`${r}-${a+1}`}}),o=Array.from(r.matchAll(/```(\w+)?\n([\s\S]*?)```/g)).map(e=>({lang:e[1]||`text`,code:e[2].trim()})),s=a.map(e=>e.text.toLowerCase()).join(` `);return{baseDir:n?.[1]?.trim()??null,content:r,headings:a,codeBlocks:o,sections:{installation:/install|安装/.test(s),quickStart:/quick start|quickstart|快速开始|入门/.test(s),commands:/command|命令/.test(s),configuration:/config|配置|setting|设置/.test(s)}}},tL=e=>(e??``).split(/[\s-_]+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`SK`;function nL(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)(null),c=(0,S.useRef)(null),{data:l,isLoading:u}=my(),d=hy(),{data:f,isLoading:p}=yi({queryKey:fy.detail(n),queryFn:async()=>{let e=await fetch(wi(`/api/skills/${encodeURIComponent(n)}`));if(!e.ok)throw Error(`Failed to fetch skill detail`);return e.json()},enabled:!!n}),m=(0,S.useMemo)(()=>eL(f?.detail),[f?.detail]),h=m.headings.some(e=>e.id===o)?o:m.headings[0]?.id,g=new Map,_=e=>{let t=QI(ZI($I(e)),`section`),n=g.get(t)??0;return g.set(t,n+1),n===0?t:`${t}-${n+1}`},v=e=>{s(e);let t=document.getElementById(e),n=c.current;if(!t||!n){t?.scrollIntoView({block:`start`,behavior:`smooth`});return}let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=n.scrollTop+r.top-i.top-72;n.scrollTo({top:Math.max(0,a),behavior:`smooth`})},y=()=>{let e=c.current;if(!e)return;let t=m.headings.map(e=>document.getElementById(e.id)).filter(e=>!!e);if(t.length===0)return;let n=e.getBoundingClientRect().top;s(t.reduce((e,t)=>t.getBoundingClientRect().top-n<=80?t:e,t[0]).id)},b=(l??[]).filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()));return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Skills`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`查看所有已注册的技能`})]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1`,children:[(0,B.jsx)(Bo,{className:`h-3 w-3`}),u?`...`:`${l?.length??0} 个技能`]})]}),(0,B.jsxs)(`div`,{className:`relative mb-6`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{placeholder:`搜索技能...`,className:`pl-9`,value:e,onChange:e=>t(e.target.value)})]}),u?(0,B.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,B.jsxs)(Y,{children:[(0,B.jsxs)(Iy,{children:[(0,B.jsx)(X,{className:`h-5 w-32`}),(0,B.jsx)(X,{className:`h-4 w-48`})]}),(0,B.jsx)(zy,{children:(0,B.jsx)(X,{className:`h-4 w-full`})})]},t))}):b.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,B.jsx)(Bo,{className:`mb-3 h-10 w-10`}),(0,B.jsx)(`p`,{className:`text-sm`,children:e?`未找到匹配的技能`:`暂无技能`})]}):(0,B.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:b.map(e=>(0,B.jsx)(Y,{className:`relative cursor-pointer transition-shadow hover:shadow-md`,onClick:()=>r(e.name),children:(0,B.jsxs)(Iy,{className:e.deletable?`pr-12`:void 0,children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Bo,{className:`h-4 w-4 text-primary`}),e.name]}),e.deletable&&(0,B.jsx)(`div`,{className:`absolute top-3 right-3`,children:(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,disabled:d.isPending,onClick:t=>{t.stopPropagation(),a(e.name)},title:`删除技能`,children:(0,B.jsx)(Go,{className:`h-4 w-4 text-destructive`})})}),(0,B.jsx)(Ry,{children:e.description})]})},e.name))}),(0,B.jsx)(nw,{open:!!n,onOpenChange:e=>!e&&r(null),children:(0,B.jsxs)(aw,{className:`grid h-[88vh] max-h-[88vh] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-0 sm:max-w-[960px]`,children:[(0,B.jsx)(ow,{className:`border-b px-6 py-5`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-4 pr-8`,children:[(0,B.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-lg border bg-primary/8 text-primary`,children:(0,B.jsx)(`span`,{className:`text-base font-semibold`,children:tL(f?.name??n)})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(cw,{className:`flex flex-wrap items-center gap-2 text-xl leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:f?.name??n}),(0,B.jsx)(J,{variant:`secondary`,className:`shrink-0`,children:XI(f)})]}),(0,B.jsx)(lw,{className:`mt-2 max-w-2xl leading-relaxed`,children:f?.description??`加载中...`}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsx)(Ho,{className:`size-3.5`}),`ID: `,n]}),m.baseDir&&(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,B.jsx)(to,{className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:m.baseDir})]})]})]})]})}),(0,B.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1 overflow-hidden lg:grid-cols-[1fr_260px]`,children:[p?(0,B.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,B.jsx)(X,{className:`h-8 w-52`}),(0,B.jsx)(X,{className:`h-28 w-full`}),(0,B.jsx)(X,{className:`h-28 w-full`})]}):m.content?(0,B.jsxs)(`div`,{ref:c,className:`h-full min-h-0 overflow-y-auto overscroll-contain scroll-smooth`,onScroll:y,children:[(0,B.jsx)(`div`,{className:`sticky top-0 z-10 flex h-14 items-center border-b bg-popover/95 px-6 backdrop-blur`,children:(0,B.jsxs)(`div`,{className:`inline-flex h-full items-center gap-2 border-b-2 border-foreground px-1 text-sm font-medium`,children:[(0,B.jsx)(Aa,{className:`size-4`}),`使用指南`]})}),(0,B.jsx)(`div`,{className:`px-6 py-6`,children:(0,B.jsx)(`div`,{className:`skill-detail-markdown`,children:(0,B.jsx)(KA,{remarkPlugins:[XN],components:{h1:({children:e,...t})=>(0,B.jsx)(`h1`,{id:_(e),...t,children:e}),h2:({children:e,...t})=>(0,B.jsx)(`h2`,{id:_(e),...t,children:e}),h3:({children:e,...t})=>(0,B.jsx)(`h3`,{id:_(e),...t,children:e}),h4:({children:e,...t})=>(0,B.jsx)(`h4`,{id:_(e),...t,children:e}),a:({...e})=>(0,B.jsx)(`a`,{...e,className:`font-medium text-primary underline-offset-4 hover:underline`,target:`_blank`,rel:`noreferrer`}),code:({className:e,children:t,...n})=>e?.startsWith(`language-`)?(0,B.jsx)(`code`,{...n,className:e,children:t}):(0,B.jsx)(`code`,{...n,className:`rounded bg-muted px-1.5 py-0.5 text-[0.9em]`,children:t})},children:m.content})})})]}):(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`无详细内容`}),(0,B.jsx)(`aside`,{className:`hidden min-h-0 border-l bg-muted/20 p-5 lg:block`,children:(0,B.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:m.headings.length>0&&(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`h3`,{className:`mb-3 text-sm font-medium`,children:`章节导航`}),(0,B.jsx)(`nav`,{className:`min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-1`,children:m.headings.map(e=>(0,B.jsx)(`button`,{type:`button`,className:[`block w-full truncate rounded-md py-1.5 pr-2 text-left text-sm transition-colors`,h===e.id?`bg-primary/8 font-medium text-primary`:`text-muted-foreground hover:bg-background hover:text-foreground`].join(` `),style:{paddingLeft:`${Math.max(0,e.level-1)*16+8}px`},onClick:()=>v(e.id),children:e.text},e.id))})]})})})]})]})}),(0,B.jsx)(nw,{open:!!i,onOpenChange:e=>{!e&&!d.isPending&&a(null)},children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsxs)(cw,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Ko,{className:`size-5 text-destructive`}),`确认删除 Skill?`]}),(0,B.jsxs)(lw,{children:[`你正在删除 `,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:i}),`。`]})]}),(0,B.jsxs)(qI,{variant:`destructive`,children:[(0,B.jsx)(Ko,{className:`size-4`}),(0,B.jsx)(JI,{children:`删除后不可恢复`}),(0,B.jsx)(YI,{children:`该 Skill 的文件会被永久移除,后续无法从管理台恢复。请确认不再需要后再继续。`})]}),(0,B.jsxs)(sw,{className:`-mx-4 -mb-4`,children:[(0,B.jsx)(q,{variant:`outline`,disabled:d.isPending,onClick:()=>a(null),children:`取消`}),(0,B.jsx)(q,{variant:`destructive`,disabled:d.isPending||!i,onClick:()=>{if(!i)return;let e=i;d.mutate(e,{onSuccess:()=>{n===e&&r(null),a(null)}})},children:d.isPending?`删除中...`:`确认删除`})]})]})})]})}var rL=1,iL=.9,aL=.8,oL=.17,sL=.1,cL=.999,lL=.9999,uL=.99,dL=/[\\\/_+.#"@\[\(\{&]/,fL=/[\\\/_+.#"@\[\(\{&]/g,pL=/[\s-]/,mL=/[\s-]/g;function hL(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?rL:uL;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=hL(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=rL:dL.test(e.charAt(l-1))?(d*=aL,p=e.slice(i,l-1).match(fL),p&&i>0&&(d*=cL**+p.length)):pL.test(e.charAt(l-1))?(d*=iL,m=e.slice(i,l-1).match(mL),m&&i>0&&(d*=cL**+m.length)):(d*=oL,i>0&&(d*=cL**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=lL)),(d<sL&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=hL(e,t,n,r,l+1,a+2,o),f*sL>d&&(d=f*sL)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function gL(e){return e.toLowerCase().replace(mL,` `)}function _L(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,hL(e,t,gL(e),gL(t),0,0,{})}var vL=Symbol.for(`react.lazy`),yL=S.use;function bL(e){return typeof e==`object`&&!!e&&`then`in e}function xL(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===vL&&`_payload`in e&&bL(e._payload)}function SL(e){let t=CL(e),n=S.forwardRef((e,n)=>{let{children:r,...i}=e;xL(r)&&typeof yL==`function`&&(r=yL(r._payload));let a=S.Children.toArray(r),o=a.find(TL);if(o){let e=o.props.children,r=a.map(t=>t===o?S.Children.count(e)>1?S.Children.only(null):S.isValidElement(e)?e.props.children:null:t);return(0,B.jsx)(t,{...i,ref:n,children:S.isValidElement(e)?S.cloneElement(e,void 0,r):null})}return(0,B.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function CL(e){let t=S.forwardRef((e,t)=>{let{children:n,...r}=e;if(xL(n)&&typeof yL==`function`&&(n=yL(n._payload)),S.isValidElement(n)){let e=DL(n),i=EL(r,n.props);return n.type!==S.Fragment&&(i.ref=t?is(t,e):e),S.cloneElement(n,i)}return S.Children.count(n)>1?S.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wL=Symbol(`radix.slottable`);function TL(e){return S.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===wL}function EL(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function DL(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OL=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=SL(`Primitive.${t}`),r=S.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,B.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),kL=`[cmdk-group=""]`,AL=`[cmdk-group-items=""]`,jL=`[cmdk-group-heading=""]`,ML=`[cmdk-item=""]`,NL=`${ML}:not([aria-disabled="true"])`,PL=`cmdk-item-select`,FL=`data-value`,IL=(e,t,n)=>_L(e,t,n),LL=S.createContext(void 0),RL=()=>S.useContext(LL),zL=S.createContext(void 0),BL=()=>S.useContext(zL),VL=S.createContext(void 0),HL=S.forwardRef((e,t)=>{let n=nR(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=nR(()=>new Set),i=nR(()=>new Map),a=nR(()=>new Map),o=nR(()=>new Set),s=eR(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ls(),y=Ls(),b=Ls(),x=S.useRef(null),C=aR();tR(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),tR(()=>{C(6,A)},[]);let w=S.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=S.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function E(e,t){let r=s.current?.filter??IL;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(AL);t?t.appendChild(e.parentElement===t?e:e.closest(`${AL} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${AL} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${kL}[${FL}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(FL);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(kL)?.querySelector(jL))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${ML}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(NL)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(FL))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(FL))}function ee(e){let t=j()?.closest(kL),n;for(;t&&!n;)t=e>0?QL(t,kL):$L(t,kL),n=t?.querySelector(NL);n?w.setState(`value`,n.getAttribute(FL)):P(e)}let F=()=>N(M().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?ee(1):P(1)},te=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?ee(-1):P(-1)};return S.createElement(OL.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(PL);t.dispatchEvent(e)}}}}},S.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:cR},c),sR(e,e=>S.createElement(zL.Provider,{value:w},S.createElement(LL.Provider,{value:T},e))))}),UL=S.forwardRef((e,t)=>{let n=Ls(),r=S.useRef(null),i=S.useContext(VL),a=RL(),o=eR(e),s=o.current?.forceMount??i?.forceMount;tR(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=iR(n,r,[e.value,e.children,r],e.keywords),l=BL(),u=rR(e=>e.value&&e.value===c.current),d=rR(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);S.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(PL,f),()=>t.removeEventListener(PL,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return S.createElement(OL.div,{ref:is(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),WL=S.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ls(),s=S.useRef(null),c=S.useRef(null),l=Ls(),u=RL(),d=rR(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);tR(()=>u.group(o),[]),iR(o,s,[e.value,e.heading,c]);let f=S.useMemo(()=>({id:o,forceMount:i}),[i]);return S.createElement(OL.div,{ref:is(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&S.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),sR(e,e=>S.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},S.createElement(VL.Provider,{value:f},e))))}),GL=S.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=S.useRef(null),a=rR(e=>!e.search);return!n&&!a?null:S.createElement(OL.div,{ref:is(i,t),...r,"cmdk-separator":``,role:`separator`})}),KL=S.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=BL(),o=rR(e=>e.search),s=rR(e=>e.selectedItemId),c=RL();return S.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),S.createElement(OL.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),qL=S.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=S.useRef(null),o=S.useRef(null),s=rR(e=>e.selectedItemId),c=RL();return S.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),S.createElement(OL.div,{ref:is(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},sR(e,e=>S.createElement(`div`,{ref:is(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),JL=S.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return S.createElement(Mu,{open:n,onOpenChange:r},S.createElement(Nu,{container:o},S.createElement(Pu,{"cmdk-overlay":``,className:i}),S.createElement(Fu,{"aria-label":e.label,"cmdk-dialog":``,className:a},S.createElement(HL,{ref:t,...s}))))}),YL=S.forwardRef((e,t)=>rR(e=>e.filtered.count===0)?S.createElement(OL.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),XL=S.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return S.createElement(OL.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},sR(e,e=>S.createElement(`div`,{"aria-hidden":!0},e)))}),ZL=Object.assign(HL,{List:qL,Item:UL,Input:KL,Group:WL,Separator:GL,Dialog:JL,Empty:YL,Loading:XL});function QL(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function $L(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function eR(e){let t=S.useRef(e);return tR(()=>{t.current=e}),t}var tR=typeof window>`u`?S.useEffect:S.useLayoutEffect;function nR(e){let t=S.useRef();return t.current===void 0&&(t.current=e()),t}function rR(e){let t=BL(),n=()=>e(t.snapshot());return S.useSyncExternalStore(t.subscribe,n,n)}function iR(e,t,n,r=[]){let i=S.useRef(),a=RL();return tR(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(FL,s),i.current=s}),i}var aR=()=>{let[e,t]=S.useState(),n=nR(()=>new Map);return tR(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function oR(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function sR({asChild:e,children:t},n){return e&&S.isValidElement(t)?S.cloneElement(oR(t),{ref:t.ref},n(t.props.children)):n(t)}var cR={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function lR({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:K(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var uR=dv(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function dR({className:e,align:t=`inline-start`,...n}){return(0,B.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:K(uR({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function fR({className:e,...t}){return(0,B.jsx)(ZL,{"data-slot":`command`,className:K(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground`,e),...t})}function pR({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,B.jsxs)(lR,{className:`h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!`,children:[(0,B.jsx)(ZL.Input,{"data-slot":`command-input`,className:K(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,B.jsx)(dR,{children:(0,B.jsx)(Po,{className:`size-4 shrink-0 opacity-50`})})]})})}function mR({className:e,...t}){return(0,B.jsx)(ZL.List,{"data-slot":`command-list`,className:K(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function hR({className:e,...t}){return(0,B.jsx)(ZL.Empty,{"data-slot":`command-empty`,className:K(`py-6 text-center text-sm`,e),...t})}function gR({className:e,...t}){return(0,B.jsx)(ZL.Group,{"data-slot":`command-group`,className:K(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function _R({className:e,children:t,...n}){return(0,B.jsxs)(ZL.Item,{"data-slot":`command-item`,className:K(`group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,B.jsx)(Ia,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}function vR({...e}){return(0,B.jsx)(ym,{"data-slot":`popover`,...e})}function yR({...e}){return(0,B.jsx)(bm,{"data-slot":`popover-trigger`,...e})}function bR({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,B.jsx)(xm,{children:(0,B.jsx)(Sm,{"data-slot":`popover-content`,align:t,sideOffset:n,className:K(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function xR(){let{data:e,refetch:t}=Qv(),n=ay(),r=oy(),i=sy(),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(``),[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(``),[y,b]=(0,S.useState)(`memory`),[x,C]=(0,S.useState)(null);(0,S.useEffect)(()=>{!s&&e?.[0]?.userId&&(c(e[0].userId),u(e[0].userId))},[s,e]);let w=s?.trim()||null,T=(0,S.useMemo)(()=>FR(e??[]),[e]),{data:E,isLoading:D}=$v(w),{data:O,isLoading:k}=ey(w),{data:A,isLoading:j}=ty(w),M=y===`all-context`||!!x,{data:N,isLoading:P,refetch:ee}=ny({enabled:M,refetchInterval:M?5e3:!1}),{data:F,isLoading:I}=ry(w),{data:te,isLoading:ne}=iy(w,_.trim()),re=F?.summaries??[],L=te?.entries??[],R=O?.dreamHistory??[],z=E?.find(e=>e.id===d)??null,ie=e?.find(e=>e.userId===w)??null,ae=re[0]??null,oe=N?.sources??[],se=x?oe.find(e=>e.userId===x)??null:null;(0,S.useEffect)(()=>{if(!w)return;if(!E||E.length===0){f(null);return}let e=E.some(e=>e.id===d);(!d||!e)&&f(E[0].id)},[w,E,d]),(0,S.useEffect)(()=>{if(z){m(z.title),g(z.content);return}m(``),g(``)},[z]),(0,S.useEffect)(()=>{!x||!N||oe.some(e=>e.userId===x)||C(null)},[oe,N,x]);let ce=()=>{let e=l.trim();e&&(c(e),f(null))},le=e=>{c(e),u(e),f(null),o(!1)};return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`上下文与记忆`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`观测用户长期记忆、梦境、会话压缩和统一召回索引;Memory 可编辑,Compact 与 Dream 只做审计。`})]}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{t(),ee()},children:[(0,B.jsx)(Ao,{className:`h-4 w-4`}),`刷新`]})]}),(0,B.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium`,children:[(0,B.jsx)(Jo,{className:`h-4 w-4 text-primary`}),`用户 / 线程`]}),(0,B.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_220px]`,children:[(0,B.jsxs)(vR,{open:a,onOpenChange:o,children:[(0,B.jsx)(yR,{asChild:!0,children:(0,B.jsxs)(q,{variant:`outline`,className:`h-14 min-w-0 justify-between px-4 text-left`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:w?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(w,ie??void 0)}),(0,B.jsx)(J,{variant:`outline`,children:LR(w)})]}),(0,B.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:w})]}):(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`选择一个用户或线程`})}),(0,B.jsx)(La,{className:`ml-3 h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,B.jsx)(bR,{align:`start`,className:`w-[min(760px,calc(100vw-3rem))] p-0`,children:(0,B.jsxs)(fR,{children:[(0,B.jsx)(pR,{placeholder:`搜索 userId、部门成员、kanban 线程`}),(0,B.jsxs)(mR,{className:`max-h-[420px]`,children:[(0,B.jsx)(hR,{children:`没有匹配到已发现的用户,可用右侧手动输入。`}),T.map(e=>(0,B.jsx)(gR,{heading:e.label,children:e.users.map(e=>(0,B.jsxs)(_R,{value:IR(e),onSelect:()=>le(e.userId),className:`items-start gap-3 py-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(e.userId,e)}),e.hasMemory&&(0,B.jsxs)(J,{variant:`secondary`,children:[e.memoryCount,` 条记忆`]}),e.hasDream&&(0,B.jsx)(J,{variant:`outline`,children:`有梦境`})]}),(0,B.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-muted-foreground`,children:e.userId}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.lastActivityAt?`最近活跃 ${BR(e.lastActivityAt)}`:`暂无活跃时间`})]}),e.userId===w&&(0,B.jsx)(Va,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary`})]},e.userId))},e.kind))]})]})})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(ew,{value:l,onChange:e=>u(e.target.value),placeholder:`手动 userId`,className:`h-14 min-w-0 font-mono text-xs`}),(0,B.jsx)(q,{className:`h-14 shrink-0`,onClick:ce,disabled:!l.trim(),children:`应用`})]})]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:`当前对象`}),w?(0,B.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,children:LR(w)}),ie?.hasConversation&&(0,B.jsx)(J,{variant:`secondary`,children:`有对话索引`}),ie?.hasDream&&(0,B.jsx)(J,{variant:`secondary`,children:`有梦境`}),(ie?.relatedUserIds?.length??0)>0&&(0,B.jsxs)(J,{variant:`secondary`,children:[ie?.relatedUserIds?.length,` 个上下文源`]})]}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-muted-foreground`,children:w}),(ie?.relatedUserIds?.length??0)>0&&(0,B.jsx)(`div`,{className:`text-xs leading-5 text-muted-foreground`,children:`已合并 Main Manager 主线与部门 mailbox 上下文。`})]}):(0,B.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:`尚未选择用户。`})]})]}),w?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-5`,children:[(0,B.jsx)(SR,{icon:Na,label:`Memory`,value:`${E?.length??0}`,note:`可编辑长期记忆`,loading:D}),(0,B.jsx)(SR,{icon:Bo,label:`Dream`,value:O?.dreamContent?`有`:`无`,note:`${R.length} 条历史`,loading:k}),(0,B.jsx)(SR,{icon:Ja,label:`Compact`,value:`${re.length}`,note:ae?`最近 ${BR(ae.createdAt)}`:`暂无压缩`,loading:I}),(0,B.jsx)(SR,{icon:Po,label:`Recall`,value:`${te?.total??0}`,note:_.trim()?`查询结果`:`索引总数`,loading:ne}),(0,B.jsx)(SR,{icon:Ua,label:`活跃`,value:ie?.lastActivityAt?zR(ie.lastActivityAt):`--`,note:ie?.lastActivityAt?BR(ie.lastActivityAt):`暂无记录`})]}),(0,B.jsxs)($N,{value:y,onValueChange:b,className:`space-y-4`,children:[(0,B.jsxs)(tP,{className:`h-auto flex-wrap justify-start`,children:[(0,B.jsx)(nP,{value:`memory`,children:`长期记忆`}),(0,B.jsx)(nP,{value:`dream`,children:`梦境`}),(0,B.jsx)(nP,{value:`compact`,children:`会话压缩`}),(0,B.jsx)(nP,{value:`recall`,children:`召回索引`}),(0,B.jsx)(nP,{value:`all-context`,children:`所有上下文`}),(0,B.jsx)(nP,{value:`context`,children:`注入预览`})]}),(0,B.jsx)(rP,{value:`memory`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,B.jsxs)(Y,{children:[(0,B.jsxs)(Iy,{className:`flex-row items-center justify-between`,children:[(0,B.jsx)(Ly,{className:`text-base`,children:`Memory 列表`}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{f(null),m(``),g(``)},children:[(0,B.jsx)(Oo,{className:`h-4 w-4`}),`新建`]})]}),(0,B.jsx)(zy,{children:D?(0,B.jsx)(NR,{rows:4}):E?.length?(0,B.jsx)(iv,{className:`max-h-[590px]`,children:(0,B.jsx)(`div`,{className:`space-y-2 pr-3`,children:E.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:`w-full rounded-lg border p-3 text-left hover:bg-muted/40 ${d===e.id?`border-primary bg-primary/5`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`max-w-28 overflow-hidden text-ellipsis font-mono text-[10px]`,children:e.id}),e.userId!==w&&(0,B.jsx)(J,{variant:`secondary`,className:`max-w-36 overflow-hidden text-ellipsis font-mono text-[10px]`,children:e.userId}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:BR(e.updatedAt)})]}),(0,B.jsx)(`div`,{className:`mt-2 break-words text-sm font-semibold`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]`,children:VR(HR(e.content),120)})]},e.id))})}):(0,B.jsx)(PR,{text:`这个 userId 还没有长期记忆。`})})]}),(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsx)(Ly,{className:`text-base`,children:z?`编辑长期记忆`:`新建长期记忆`})}),(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:p,onChange:e=>m(e.target.value),placeholder:`例如:偏好-包管理器`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`内容`}),(0,B.jsx)(tw,{value:h,onChange:e=>g(e.target.value),className:`min-h-44`,placeholder:`稳定事实、偏好或长期约束。`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:z?.id??`new memory`}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[z&&(0,B.jsxs)(q,{variant:`destructive`,onClick:async()=>{!w||!z||(await i.mutateAsync({id:z.id,userId:z.userId||w}),f(null))},disabled:i.isPending,children:[(0,B.jsx)(Go,{className:`h-4 w-4`}),`删除`]}),(0,B.jsxs)(q,{onClick:async()=>{if(!(!w||!p.trim()||!h.trim())){if(z){await r.mutateAsync({id:z.id,data:{userId:z.userId||w,title:p.trim(),content:h.trim()}});return}f((await n.mutateAsync({userId:w,title:p.trim(),content:h.trim()})).id)}},disabled:!p.trim()||!h.trim()||n.isPending||r.isPending,children:[(0,B.jsx)(No,{className:`h-4 w-4`}),z?`保存`:`创建`]})]})]})]})]})]})}),(0,B.jsx)(rP,{value:`dream`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,B.jsx)(CR,{title:`最新梦境`,icon:Bo,loading:k,empty:`还没有 dream。系统会在长时间不活跃后生成长期记忆沉淀。`,content:O?.dreamContent}),(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(so,{className:`h-4 w-4 text-primary`}),`Dream History`]})}),(0,B.jsx)(zy,{children:k?(0,B.jsx)(NR,{rows:4}):R.length===0?(0,B.jsx)(PR,{text:`暂无梦境历史。`}):(0,B.jsx)(iv,{className:`max-h-[520px]`,children:(0,B.jsx)(`div`,{className:`space-y-3 pr-3`,children:R.map(e=>(0,B.jsx)(jR,{title:BR(e.createdAt),meta:`${e.sourceMessageCount} 条来源消息`,content:e.content},e.id))})})})]})]})}),(0,B.jsx)(rP,{value:`compact`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(Ja,{className:`h-4 w-4 text-primary`}),`Compact Summaries`]})}),(0,B.jsx)(zy,{children:I?(0,B.jsx)(NR,{rows:5}):re.length===0?(0,B.jsx)(PR,{text:`暂无会话压缩摘要。长上下文触发 compact 后会出现在这里。`}):(0,B.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:re.map(e=>(0,B.jsx)(kR,{summary:e},e.id))})})]})}),(0,B.jsx)(rP,{value:`recall`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(Po,{className:`h-4 w-4 text-primary`}),`Recall 测试`]})}),(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,B.jsx)(ew,{value:_,onChange:e=>v(e.target.value),placeholder:`输入关键词,例如:蓝兔支付 / 准生产 / ENOENT`,className:`h-10`}),(0,B.jsx)(q,{variant:`outline`,onClick:()=>v(``),disabled:!_,children:`清空`})]}),ne?(0,B.jsx)(NR,{rows:5}):L.length===0?(0,B.jsx)(PR,{text:_.trim()?`没有匹配的召回结果。`:`暂无 recall index 条目。`}):(0,B.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:L.map(e=>(0,B.jsx)(AR,{entry:e},`${e.type}:${e.id}`))})]})]})}),(0,B.jsx)(rP,{value:`context`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-2`,children:[(0,B.jsx)(CR,{title:`Memory Context`,icon:Qa,loading:j,content:A?.memoryContextBlock,empty:`没有长期记忆注入块。`}),(0,B.jsx)(CR,{title:`Dream Context`,icon:bo,loading:j,content:A?.dreamContextBlock,empty:`没有梦境注入块。`})]})}),(0,B.jsx)(rP,{value:`all-context`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(bo,{className:`h-4 w-4 text-primary`}),`Main Manager 可见上下文`]})}),(0,B.jsx)(zy,{children:P?(0,B.jsx)(NR,{rows:5}):oe.length===0?(0,B.jsx)(PR,{text:`暂无可查看的对话上下文。`}):(0,B.jsx)(`div`,{className:`space-y-4`,children:oe.map(e=>(0,B.jsx)(wR,{source:e,onOpen:()=>C(e.userId)},e.userId))})})]})})]})]}):(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`py-16 text-center text-muted-foreground`,children:`先选择一个 userId,再查看上下文、记忆和召回索引。`})})]}),(0,B.jsx)(TR,{source:se,onClose:()=>C(null)})]})}function SR({icon:e,label:t,value:n,note:r,loading:i}){return(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{className:`pb-2`,children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,B.jsx)(e,{className:`h-4 w-4`}),t]})}),(0,B.jsxs)(zy,{children:[i?(0,B.jsx)(X,{className:`h-7 w-20`}):(0,B.jsx)(`div`,{className:`text-2xl font-semibold`,children:n}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r})]})]})}function CR({title:e,icon:t,content:n,empty:r,loading:i}){return(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(t,{className:`h-4 w-4 text-primary`}),e]})}),(0,B.jsx)(zy,{children:i?(0,B.jsx)(NR,{rows:4}):n?.trim()?(0,B.jsx)(`div`,{className:`max-h-[560px] overflow-auto rounded-lg border bg-muted/25 p-4`,children:(0,B.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm leading-6 [overflow-wrap:anywhere]`,children:n})}):(0,B.jsx)(PR,{text:r})})]})}function wR({source:e,onOpen:t}){let n=e.agentLogs.slice(-2);return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(e.userId)}),(0,B.jsx)(J,{variant:`outline`,children:LR(e.userId)}),(0,B.jsxs)(J,{variant:`secondary`,children:[e.messageCount,` 条上下文`]})]}),(0,B.jsx)(`div`,{className:`mt-1 break-all font-mono text-xs text-muted-foreground`,children:e.userId})]}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:t,children:[(0,B.jsx)(Za,{className:`h-4 w-4`}),`查看`]})]}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-muted/20 p-3`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`最近上下文预览`}),n.map(t=>(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(J,{variant:t.role===`user`?`default`:`secondary`,className:`h-4 px-1.5 py-0 text-[10px]`,children:t.role===`user`?`User`:`Assistant`}),(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,t.index]}),(0,B.jsx)(`span`,{className:`truncate`,children:DR(t)})]},`${e.userId}:${t.index}`)),n.length===0&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`暂无预览。`})]})]})}function TR({source:e,onClose:t}){let[n,r]=(0,S.useState)(1);if((0,S.useEffect)(()=>{r(1)},[e?.userId]),!e)return null;let i=Math.max(1,Math.ceil(e.agentLogs.length/12)),a=Math.min(n,i),o=(a-1)*12,s=e.agentLogs.slice(o,o+12);return(0,B.jsx)(nw,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,B.jsxs)(aw,{className:`grid max-h-[88vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden p-0 sm:max-w-5xl`,children:[(0,B.jsxs)(ow,{className:`border-b px-6 py-5`,children:[(0,B.jsxs)(cw,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(bo,{className:`h-4 w-4 text-primary`}),RR(e.userId),(0,B.jsx)(J,{variant:`outline`,children:LR(e.userId)})]}),(0,B.jsxs)(lw,{className:`break-all font-mono text-xs`,children:[e.userId,` · 共 `,e.messageCount,` 条上下文`]})]}),(0,B.jsx)(iv,{className:`min-h-0 px-6 py-4`,children:(0,B.jsx)(`div`,{className:`space-y-4 pr-3`,children:s.map(t=>(0,B.jsx)(ER,{log:t},`${e.userId}:${t.index}`))})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t px-6 py-4 text-sm`,children:[(0,B.jsxs)(`div`,{className:`text-muted-foreground`,children:[`第 `,a,` / `,i,` 页 · 当前 `,s.length,` 条`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(1),disabled:a<=1,children:`首页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(e=>Math.max(1,e-1)),disabled:a<=1,children:`上一页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(e=>Math.min(i,e+1)),disabled:a>=i,children:`下一页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(i),disabled:a>=i,children:`末页`})]})]})]})})}function ER({log:e}){let t=e.role===`user`;return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.index]}),(0,B.jsx)(J,{variant:t?`default`:`secondary`,className:`h-4 px-1.5 py-0 text-[10px]`,children:t?`User`:`Assistant`})]}),(0,B.jsx)(`div`,{className:`space-y-2 pl-2`,children:e.blocks.map((e,n)=>(0,B.jsx)(OR,{block:e,isUser:t},n))})]})}function DR(e){let t=e.blocks.find(e=>e.type===`text`&&typeof e.text==`string`);if(t&&typeof t.text==`string`&&t.text.trim())return VR(t.text.replace(/\s+/g,` `).trim(),120);let n=e.blocks.find(e=>e.type===`tool_use`);if(n)return`tool_use: ${String(n.name??`unknown`)}`;let r=e.blocks.find(e=>e.type===`tool_result`);return r?`tool_result: ${String(r.toolUseId??``)}`:e.blocks.find(e=>e.type===`thinking`)?`thinking: 模型思考块`:e.blocks.find(e=>e.type===`image`)?`image: 图片内容块`:`无文本内容`}function OR({block:e,isUser:t}){let[n,r]=(0,S.useState)(!1),i=String(e.type??`unknown`);if(i===`text`){let i=String(e.text??``),a=i.length>360;return(0,B.jsxs)(`div`,{className:`rounded-md border px-3 py-2 text-sm whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t?`border-emerald-500/10 bg-emerald-500/5`:`border-sky-500/10 bg-sky-500/5`}`,children:[n||!a?i:VR(i,360),a&&(0,B.jsx)(q,{variant:`ghost`,size:`sm`,className:`ml-1 h-6 px-1 text-xs`,onClick:()=>r(e=>!e),children:n?`收起`:`展开`})]})}if(i===`tool_use`)return(0,B.jsxs)(`div`,{className:`rounded-md border border-primary/20 bg-primary/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Qo,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,B.jsx)(`span`,{className:`text-sm font-semibold text-primary`,children:String(e.name??`unknown`)}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:JSON.stringify(e.input??{},null,2)})]});if(i===`tool_result`){let t=typeof e.content==`string`?e.content:JSON.stringify(e.content,null,2);return(0,B.jsxs)(`div`,{className:`rounded-md border border-amber-500/20 bg-amber-500/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-amber-700 dark:text-amber-300`,children:[`tool_result `,String(e.toolUseId??``)]}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:t})]})}if(i===`thinking`){let t=String(e.thinking??``);return(0,B.jsxs)(`div`,{className:`rounded-md border border-violet-500/20 bg-violet-500/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Na,{className:`h-3.5 w-3.5 shrink-0 text-violet-500`}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:`thinking`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:`模型思考块`}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&t.trim()&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:t})]})}return i===`image`?(0,B.jsx)(`div`,{className:`rounded-md border border-slate-500/15 bg-slate-500/5 px-3 py-2 text-sm text-muted-foreground`,children:`图片内容块`}):(0,B.jsxs)(`div`,{className:`rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground`,children:[`[unknown block: `,i,`]`]})}function kR({summary:e}){return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,children:e.date}),e.cronTitle&&(0,B.jsx)(J,{variant:`secondary`,children:e.cronTitle}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:BR(e.createdAt)})]}),(0,B.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(MR,{label:`before`,value:UR(e.contextTokensBefore)}),(0,B.jsx)(MR,{label:`after`,value:UR(e.contextTokensAfter)}),(0,B.jsx)(MR,{label:`hot tail`,value:String(e.hotTailCount)})]}),(0,B.jsx)(`pre`,{className:`mt-3 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted/25 p-3 text-xs leading-5 [overflow-wrap:anywhere]`,children:e.summary})]})}function AR({entry:e}){return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:e.type===`memory`?`secondary`:`outline`,children:e.type}),(0,B.jsx)(J,{variant:`outline`,children:e.date}),e.score!==void 0&&(0,B.jsxs)(J,{variant:`outline`,children:[`score `,e.score]})]}),(0,B.jsx)(`h3`,{className:`mt-3 break-words text-sm font-semibold`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-2 break-words text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:VR(e.summary,360)}),e.keywords.length>0&&(0,B.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,children:e.keywords.slice(0,8).map(e=>(0,B.jsx)(J,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})}function jR({title:e,meta:t,content:n}){return(0,B.jsxs)(`article`,{className:`rounded-lg border p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:e}),(0,B.jsx)(`span`,{children:t})]}),(0,B.jsx)(`p`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap break-words text-xs leading-5 [overflow-wrap:anywhere]`,children:n})]})}function MR({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`rounded-md border bg-muted/20 px-2 py-1`,children:[(0,B.jsx)(`div`,{children:e}),(0,B.jsx)(`div`,{className:`font-mono text-foreground`,children:t})]})}function NR({rows:e}){return(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:e}).map((e,t)=>(0,B.jsx)(X,{className:`h-20 w-full`},t))})}function PR({text:e}){return(0,B.jsx)(`div`,{className:`rounded-lg border border-dashed px-4 py-10 text-center text-sm text-muted-foreground`,children:e})}function FR(e){let t=[`Chat`,`Department`,`Kanban`,`User`],n=new Map;for(let t of e){let e=LR(t.userId),r=n.get(e)??[];r.push(t),n.set(e,r)}return t.map(e=>({kind:e,label:e,users:(n.get(e)??[]).sort((e,t)=>(t.lastActivityAt??0)-(e.lastActivityAt??0)||(t.memoryCount??0)-(e.memoryCount??0)||e.userId.localeCompare(t.userId))})).filter(e=>e.users.length>0)}function IR(e){return[e.userId,RR(e.userId,e),LR(e.userId),e.hasMemory?`has-memory`:``,e.hasDream?`has-dream`:``].filter(Boolean).join(` `)}function LR(e){return e.startsWith(`kanban:`)?`Kanban`:e.includes(`::`)?`Department`:e.startsWith(`oc_`)||e.startsWith(`chat_`)?`Chat`:`User`}function RR(e,t){return t?.displayName?t.displayName:e.startsWith(`kanban:`)?e.split(`:`).at(-1)||e:e.includes(`::`)&&e.split(`::`).at(-1)||e}function zR(e){try{return new Date(e).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}function BR(e){try{let t=Date.now()-e;return t<6e4?`刚刚`:t<36e5?`${Math.max(1,Math.floor(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.floor(t/36e5))} 小时前`:zR(e)}catch{return String(e)}}function VR(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function HR(e){return e.replace(/\r\n?/g,`
|
|
92
|
+
`).trim()}function AI(e,t){return OI(kI(e),t)}function jI(e){try{return new Date(e).toLocaleString(`zh-CN`)}catch{return String(e)}}function MI(e){try{return new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}function NI(e){try{let t=Date.now()-e;return t<6e4?`刚刚`:t<36e5?`${Math.max(1,Math.floor(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.floor(t/36e5))} 小时前`:new Date(e).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}var PI={title:``,description:``,syntax:`0 * * * *`,channel:`default`,to:``};function FI(){let{data:e,isLoading:t,refetch:n}=jv(),r=Nv(),i=Pv(),a=ri(),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(PI),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(!1),v=()=>{d(PI),s(!0)},y=e=>{d({title:e.title,description:e.description,syntax:e.schedule.syntax,channel:e.delivery.channel,to:e.delivery.to}),l(e)},b=async()=>{!u.title.trim()||!u.syntax.trim()||(await r.mutateAsync({title:u.title,description:u.description,schedule:{syntax:u.syntax},delivery:{channel:u.channel,to:u.to}}),s(!1),d(PI))},x=async()=>{if(!(!c||!u.title.trim()||!u.syntax.trim())){_(!0);try{await Tv(c.id,{title:u.title,description:u.description,schedule:{syntax:u.syntax,createTime:c.schedule.createTime,lastRunTime:c.schedule.lastRunTime},delivery:{channel:u.channel,to:u.to}}),await a.invalidateQueries({queryKey:Av.all}),l(null),d(PI)}finally{_(!1)}}},C=async e=>{await Dv(e.id,!e.enabled),await a.invalidateQueries({queryKey:Av.all})},w=async e=>{await Ov(e.id),await a.invalidateQueries({queryKey:Av.all})},T=async()=>{f&&(await i.mutateAsync(f),p(null))},E=e=>{if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`)}catch{return e}};return(0,B.jsx)(Py,{children:(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Cron Jobs`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`管理定时任务调度`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>n(),children:(0,B.jsx)(Ao,{className:`h-4 w-4`})}),(0,B.jsxs)(q,{size:`sm`,onClick:v,children:[(0,B.jsx)(Oo,{className:`h-4 w-4 mr-1`}),`新建任务`]})]})]}),t?(0,B.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`p-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(X,{className:`h-5 w-48`}),(0,B.jsx)(X,{className:`h-4 w-32`})]}),(0,B.jsx)(X,{className:`h-6 w-12`})]})})},e))}):!e||e.length===0?(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`py-12`,children:(0,B.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,B.jsx)(Wa,{className:`h-10 w-10 text-muted-foreground mb-3`}),(0,B.jsx)(`p`,{className:`text-muted-foreground`,children:`暂无定时任务`}),(0,B.jsxs)(q,{variant:`outline`,className:`mt-3`,size:`sm`,onClick:v,children:[(0,B.jsx)(Oo,{className:`h-4 w-4 mr-1`}),`创建第一个任务`]})]})})}):(0,B.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`p-4`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,B.jsx)(`h3`,{className:`font-medium truncate`,children:e.title}),(0,B.jsx)(J,{variant:e.enabled?`default`:`secondary`,children:e.enabled?`启用`:`禁用`})]}),e.description&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-1 mb-2`,children:e.description}),(0,B.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{className:`font-mono bg-muted px-1.5 py-0.5 rounded`,children:e.schedule.syntax}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(Wa,{className:`h-3 w-3 inline mr-1`}),E(e.schedule.lastRunTime)]}),(0,B.jsxs)(`span`,{children:[e.delivery.channel,` → `,e.delivery.to]})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,B.jsx)(iP,{checked:e.enabled,onCheckedChange:()=>C(e)}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>w(e),disabled:!e.enabled,title:`手动触发`,children:(0,B.jsx)(Do,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>h(e.id),title:`执行历史`,children:(0,B.jsx)(Wa,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>y(e),title:`编辑`,children:(0,B.jsx)(Ba,{className:`h-4 w-4`})}),(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,onClick:()=>p(e.id),title:`删除`,children:(0,B.jsx)(Go,{className:`h-4 w-4`})})]})]})})},e.id))}),(0,B.jsx)(nw,{open:o,onOpenChange:s,children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`新建定时任务`}),(0,B.jsx)(lw,{children:`配置 cron 表达式和投递方式`})]}),(0,B.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:u.title,onChange:e=>d(t=>({...t,title:e.target.value})),placeholder:`任务标题`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`描述`}),(0,B.jsx)(tw,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:`任务描述(可选)`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`Cron 表达式`}),(0,B.jsx)(ew,{value:u.syntax,onChange:e=>d(t=>({...t,syntax:e.target.value})),placeholder:`0 * * * *`,className:`font-mono`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`格式: 分 时 日 月 周(如 0 */2 * * * 表示每2小时)`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递通道`}),(0,B.jsx)(ew,{value:u.channel,onChange:e=>d(t=>({...t,channel:e.target.value})),placeholder:`channel`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递目标`}),(0,B.jsx)(ew,{value:u.to,onChange:e=>d(t=>({...t,to:e.target.value})),placeholder:`to`})]})]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>s(!1),children:`取消`}),(0,B.jsxs)(q,{onClick:b,disabled:r.isPending||!u.title.trim(),children:[r.isPending&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`创建`]})]})]})}),(0,B.jsx)(nw,{open:!!c,onOpenChange:()=>l(null),children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`编辑定时任务`}),(0,B.jsx)(lw,{children:`修改任务配置`})]}),(0,B.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:u.title,onChange:e=>d(t=>({...t,title:e.target.value})),placeholder:`任务标题`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`描述`}),(0,B.jsx)(tw,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:`任务描述(可选)`,rows:2})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`Cron 表达式`}),(0,B.jsx)(ew,{value:u.syntax,onChange:e=>d(t=>({...t,syntax:e.target.value})),placeholder:`0 * * * *`,className:`font-mono`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递通道`}),(0,B.jsx)(ew,{value:u.channel,onChange:e=>d(t=>({...t,channel:e.target.value})),placeholder:`channel`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`投递目标`}),(0,B.jsx)(ew,{value:u.to,onChange:e=>d(t=>({...t,to:e.target.value})),placeholder:`to`})]})]})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>l(null),children:`取消`}),(0,B.jsxs)(q,{onClick:x,disabled:g||!u.title.trim(),children:[g&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`保存`]})]})]})}),(0,B.jsx)(nw,{open:!!f,onOpenChange:()=>p(null),children:(0,B.jsxs)(aw,{className:`sm:max-w-sm`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`确认删除`}),(0,B.jsx)(lw,{children:`删除后不可恢复,确定要删除此定时任务吗?`})]}),(0,B.jsxs)(sw,{children:[(0,B.jsx)(q,{variant:`outline`,onClick:()=>p(null),children:`取消`}),(0,B.jsxs)(q,{variant:`destructive`,onClick:T,disabled:i.isPending,children:[i.isPending&&(0,B.jsx)(ho,{className:`h-4 w-4 mr-1 animate-spin`}),`删除`]})]})]})}),(0,B.jsx)(II,{jobId:m,onClose:()=>h(null)})]})})}function II({jobId:e,onClose:t}){let{data:n,isLoading:r}=Mv(e??``);return(0,B.jsx)(nw,{open:!!e,onOpenChange:()=>t(),children:(0,B.jsxs)(aw,{className:`sm:max-w-lg`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsx)(cw,{children:`执行历史`}),(0,B.jsx)(lw,{children:`查看该定时任务的执行记录`})]}),(0,B.jsx)(iv,{className:`max-h-[400px]`,children:r?(0,B.jsx)(`div`,{className:`space-y-2 py-4`,children:[1,2,3].map(e=>(0,B.jsx)(X,{className:`h-12 w-full`},e))}):!n||n.length===0?(0,B.jsx)(`div`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`暂无执行记录`}):(0,B.jsx)(`div`,{className:`space-y-2`,children:n.map((e,t)=>(0,B.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border text-sm`,children:[(0,B.jsx)(`div`,{children:(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:LI(e.timestamp)})}),(0,B.jsx)(J,{variant:e.result===`success`?`default`:`destructive`,children:e.result})]},t))})})]})})}function LI(e){try{return new Date(e).toLocaleString(`zh-CN`)}catch{return e}}function RI({...e}){return(0,B.jsx)(Xs,{"data-slot":`collapsible`,...e})}function zI({...e}){return(0,B.jsx)(Gs,{"data-slot":`collapsible-trigger`,...e})}function BI({...e}){return(0,B.jsx)(qs,{"data-slot":`collapsible-content`,...e})}var VI={file:{label:`文件操作`,icon:Qa},web:{label:`网络`,icon:io},system:{label:`系统`,icon:Io},task:{label:`任务管理`,icon:mo},department:{label:`部门管理`,icon:Xo},cron:{label:`定时任务`,icon:Wa}},HI={label:`其他`,icon:ko};function UI(e){let t=e.toLowerCase();return t.includes(`file`)||t.includes(`read`)||t.includes(`write`)||t.includes(`edit`)||t.includes(`glob`)||t.includes(`grep`)||t.includes(`bash`)||t.includes(`mkdir`)?`file`:t.includes(`web`)||t.includes(`search`)||t.includes(`fetch`)||t.includes(`http`)||t.includes(`url`)?`web`:t.includes(`system`)||t.includes(`process`)||t.includes(`env`)||t.includes(`config`)||t.includes(`memory`)?`system`:t.includes(`task`)||t.includes(`goal`)?`task`:t.includes(`department`)||t.includes(`member`)||t.includes(`communicat`)?`department`:t.includes(`cron`)||t.includes(`schedule`)||t.includes(`timer`)?`cron`:`other`}function WI({schema:e}){return e?.properties?(0,B.jsx)(`div`,{className:`space-y-2`,children:Object.entries(e.properties).map(([t,n])=>(0,B.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`text-sm font-medium`,children:t}),(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:n.type}),e.required?.includes(t)&&(0,B.jsx)(J,{variant:`destructive`,className:`text-xs`,children:`必填`})]}),n.description&&(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.description}),n.enum&&(0,B.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:n.enum.map(e=>(0,B.jsx)(J,{variant:`secondary`,className:`text-xs`,children:String(e)},String(e)))})]},t))}):null}function GI(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(new Set),{data:i,isLoading:a}=py(),o=(0,S.useMemo)(()=>{let t={};return(i??[]).filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase())).forEach(e=>{let n=UI(e.name);t[n]||(t[n]=[]),t[n].push(e)}),t},[i,e]),s=i?.length??0,c=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Tools`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`查看所有已注册的工具及其参数`})]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1`,children:[(0,B.jsx)(Qo,{className:`h-3 w-3`}),a?`...`:`${s} 个工具`]})]}),(0,B.jsxs)(`div`,{className:`relative mb-6`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{placeholder:`搜索工具...`,className:`pl-9`,value:e,onChange:e=>t(e.target.value)})]}),a?(0,B.jsx)(`div`,{className:`space-y-6`,children:Array.from({length:3}).map((e,t)=>(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(X,{className:`h-6 w-32`}),(0,B.jsx)(X,{className:`h-24 w-full`})]},t))}):Object.keys(o).length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,B.jsx)(Qo,{className:`mb-3 h-10 w-10`}),(0,B.jsx)(`p`,{className:`text-sm`,children:e?`未找到匹配的工具`:`暂无工具`})]}):(0,B.jsx)(`div`,{className:`space-y-8`,children:Object.entries(o).map(([e,t])=>{let r=VI[e]??HI,i=r.icon;return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,B.jsx)(i,{className:`h-4 w-4 text-muted-foreground`}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:r.label}),(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:t.length})]}),(0,B.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=n.has(e.name);return(0,B.jsx)(Y,{size:`sm`,children:(0,B.jsxs)(RI,{open:t,onOpenChange:()=>c(e.name),children:[(0,B.jsx)(zI,{className:`w-full`,children:(0,B.jsx)(Iy,{className:`cursor-pointer`,children:(0,B.jsxs)(Ly,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Qo,{className:`h-3.5 w-3.5 text-primary`}),(0,B.jsx)(`code`,{className:`text-sm`,children:e.name})]}),(0,B.jsx)(La,{className:`h-4 w-4 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})})}),(0,B.jsx)(BI,{children:(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`参数 Schema`}),(0,B.jsx)(WI,{schema:e.inputSchema})]})]})})]})},e.name)})})]},e)})})]})}var KI=dv(`group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function qI({className:e,variant:t,...n}){return(0,B.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:K(KI({variant:t}),e),...n})}function JI({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-title`,className:K(`font-heading font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground`,e),...t})}function YI({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`alert-description`,className:K(`text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),...t})}var XI=e=>e?.scope===`department`?e.departmentName?`部门 Skill · ${e.departmentName}`:`部门 Skill`:e?.scope===`project`||e?.deletable?`项目 Skill`:`系统 Skill`,ZI=e=>e.replace(/[`*_#]/g,``).replace(/\s+/g,` `).trim(),QI=(e,t)=>e.toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g,`-`).replace(/^-+|-+$/g,``)||t,$I=e=>{if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map($I).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return $I(t?.children)}return``},eL=e=>{let t=e??``,n=t.match(/^Base directory for this skill:\s*(.+)$/m),r=t.replace(/^Base directory for this skill:\s*.+\n{0,2}/,``).trim(),i=new Map,a=Array.from(r.matchAll(/^(#{1,4})\s+(.+)$/gm)).map((e,t)=>{let n=ZI(e[2]),r=QI(n,`section-${t+1}`),a=i.get(r)??0;return i.set(r,a+1),{level:e[1].length,text:n,id:a===0?r:`${r}-${a+1}`}}),o=Array.from(r.matchAll(/```(\w+)?\n([\s\S]*?)```/g)).map(e=>({lang:e[1]||`text`,code:e[2].trim()})),s=a.map(e=>e.text.toLowerCase()).join(` `);return{baseDir:n?.[1]?.trim()??null,content:r,headings:a,codeBlocks:o,sections:{installation:/install|安装/.test(s),quickStart:/quick start|quickstart|快速开始|入门/.test(s),commands:/command|命令/.test(s),configuration:/config|配置|setting|设置/.test(s)}}},tL=e=>(e??``).split(/[\s-_]+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`SK`;function nL(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)(null),c=(0,S.useRef)(null),{data:l,isLoading:u}=my(),d=hy(),{data:f,isLoading:p}=yi({queryKey:[...fy.detail(n?.name??``),n?.departmentName??``],queryFn:async()=>{let e=n?.departmentName?`?departmentName=${encodeURIComponent(n.departmentName)}`:``,t=await fetch(wi(`/api/skills/${encodeURIComponent(n.name)}${e}`));if(!t.ok)throw Error(`Failed to fetch skill detail`);return t.json()},enabled:!!n}),m=(0,S.useMemo)(()=>eL(f?.detail),[f?.detail]),h=m.headings.some(e=>e.id===o)?o:m.headings[0]?.id,g=new Map,_=e=>{let t=QI(ZI($I(e)),`section`),n=g.get(t)??0;return g.set(t,n+1),n===0?t:`${t}-${n+1}`},v=e=>{s(e);let t=document.getElementById(e),n=c.current;if(!t||!n){t?.scrollIntoView({block:`start`,behavior:`smooth`});return}let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=n.scrollTop+r.top-i.top-72;n.scrollTo({top:Math.max(0,a),behavior:`smooth`})},y=()=>{let e=c.current;if(!e)return;let t=m.headings.map(e=>document.getElementById(e.id)).filter(e=>!!e);if(t.length===0)return;let n=e.getBoundingClientRect().top;s(t.reduce((e,t)=>t.getBoundingClientRect().top-n<=80?t:e,t[0]).id)},b=(l??[]).filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()));return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Skills`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`查看所有已注册的技能`})]}),(0,B.jsxs)(J,{variant:`secondary`,className:`gap-1`,children:[(0,B.jsx)(Bo,{className:`h-3 w-3`}),u?`...`:`${l?.length??0} 个技能`]})]}),(0,B.jsxs)(`div`,{className:`relative mb-6`,children:[(0,B.jsx)(Po,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,B.jsx)(ew,{placeholder:`搜索技能...`,className:`pl-9`,value:e,onChange:e=>t(e.target.value)})]}),u?(0,B.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,B.jsxs)(Y,{children:[(0,B.jsxs)(Iy,{children:[(0,B.jsx)(X,{className:`h-5 w-32`}),(0,B.jsx)(X,{className:`h-4 w-48`})]}),(0,B.jsx)(zy,{children:(0,B.jsx)(X,{className:`h-4 w-full`})})]},t))}):b.length===0?(0,B.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-muted-foreground`,children:[(0,B.jsx)(Bo,{className:`mb-3 h-10 w-10`}),(0,B.jsx)(`p`,{className:`text-sm`,children:e?`未找到匹配的技能`:`暂无技能`})]}):(0,B.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:b.map(e=>(0,B.jsx)(Y,{className:`relative cursor-pointer transition-shadow hover:shadow-md`,onClick:()=>r(e),children:(0,B.jsxs)(Iy,{className:e.deletable?`pr-12`:void 0,children:[(0,B.jsxs)(Ly,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Bo,{className:`h-4 w-4 text-primary`}),e.name]}),e.deletable&&(0,B.jsx)(`div`,{className:`absolute top-3 right-3`,children:(0,B.jsx)(q,{variant:`ghost`,size:`icon-sm`,disabled:d.isPending,onClick:t=>{t.stopPropagation(),a(e.name)},title:`删除技能`,children:(0,B.jsx)(Go,{className:`h-4 w-4 text-destructive`})})}),(0,B.jsx)(Ry,{children:e.description})]})},`${e.scope??`global`}:${e.departmentName??``}:${e.name}`))}),(0,B.jsx)(nw,{open:!!n,onOpenChange:e=>!e&&r(null),children:(0,B.jsxs)(aw,{className:`grid h-[88vh] max-h-[88vh] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-0 sm:max-w-[960px]`,children:[(0,B.jsx)(ow,{className:`border-b px-6 py-5`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-4 pr-8`,children:[(0,B.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center rounded-lg border bg-primary/8 text-primary`,children:(0,B.jsx)(`span`,{className:`text-base font-semibold`,children:tL(f?.name??n?.name)})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(cw,{className:`flex flex-wrap items-center gap-2 text-xl leading-tight`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:f?.name??n?.name}),(0,B.jsx)(J,{variant:`secondary`,className:`shrink-0`,children:XI(f)})]}),(0,B.jsx)(lw,{className:`mt-2 max-w-2xl leading-relaxed`,children:f?.description??`加载中...`}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsx)(Ho,{className:`size-3.5`}),`ID: `,n?.name]}),m.baseDir&&(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,B.jsx)(to,{className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:m.baseDir})]})]})]})]})}),(0,B.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1 overflow-hidden lg:grid-cols-[1fr_260px]`,children:[p?(0,B.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,B.jsx)(X,{className:`h-8 w-52`}),(0,B.jsx)(X,{className:`h-28 w-full`}),(0,B.jsx)(X,{className:`h-28 w-full`})]}):m.content?(0,B.jsxs)(`div`,{ref:c,className:`h-full min-h-0 overflow-y-auto overscroll-contain scroll-smooth`,onScroll:y,children:[(0,B.jsx)(`div`,{className:`sticky top-0 z-10 flex h-14 items-center border-b bg-popover/95 px-6 backdrop-blur`,children:(0,B.jsxs)(`div`,{className:`inline-flex h-full items-center gap-2 border-b-2 border-foreground px-1 text-sm font-medium`,children:[(0,B.jsx)(Aa,{className:`size-4`}),`使用指南`]})}),(0,B.jsx)(`div`,{className:`px-6 py-6`,children:(0,B.jsx)(`div`,{className:`skill-detail-markdown`,children:(0,B.jsx)(KA,{remarkPlugins:[XN],components:{h1:({children:e,...t})=>(0,B.jsx)(`h1`,{id:_(e),...t,children:e}),h2:({children:e,...t})=>(0,B.jsx)(`h2`,{id:_(e),...t,children:e}),h3:({children:e,...t})=>(0,B.jsx)(`h3`,{id:_(e),...t,children:e}),h4:({children:e,...t})=>(0,B.jsx)(`h4`,{id:_(e),...t,children:e}),a:({...e})=>(0,B.jsx)(`a`,{...e,className:`font-medium text-primary underline-offset-4 hover:underline`,target:`_blank`,rel:`noreferrer`}),code:({className:e,children:t,...n})=>e?.startsWith(`language-`)?(0,B.jsx)(`code`,{...n,className:e,children:t}):(0,B.jsx)(`code`,{...n,className:`rounded bg-muted px-1.5 py-0.5 text-[0.9em]`,children:t})},children:m.content})})})]}):(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`无详细内容`}),(0,B.jsx)(`aside`,{className:`hidden min-h-0 border-l bg-muted/20 p-5 lg:block`,children:(0,B.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:m.headings.length>0&&(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`h3`,{className:`mb-3 text-sm font-medium`,children:`章节导航`}),(0,B.jsx)(`nav`,{className:`min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-1`,children:m.headings.map(e=>(0,B.jsx)(`button`,{type:`button`,className:[`block w-full truncate rounded-md py-1.5 pr-2 text-left text-sm transition-colors`,h===e.id?`bg-primary/8 font-medium text-primary`:`text-muted-foreground hover:bg-background hover:text-foreground`].join(` `),style:{paddingLeft:`${Math.max(0,e.level-1)*16+8}px`},onClick:()=>v(e.id),children:e.text},e.id))})]})})})]})]})}),(0,B.jsx)(nw,{open:!!i,onOpenChange:e=>{!e&&!d.isPending&&a(null)},children:(0,B.jsxs)(aw,{className:`sm:max-w-md`,children:[(0,B.jsxs)(ow,{children:[(0,B.jsxs)(cw,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Ko,{className:`size-5 text-destructive`}),`确认删除 Skill?`]}),(0,B.jsxs)(lw,{children:[`你正在删除 `,(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:i}),`。`]})]}),(0,B.jsxs)(qI,{variant:`destructive`,children:[(0,B.jsx)(Ko,{className:`size-4`}),(0,B.jsx)(JI,{children:`删除后不可恢复`}),(0,B.jsx)(YI,{children:`该 Skill 的文件会被永久移除,后续无法从管理台恢复。请确认不再需要后再继续。`})]}),(0,B.jsxs)(sw,{className:`-mx-4 -mb-4`,children:[(0,B.jsx)(q,{variant:`outline`,disabled:d.isPending,onClick:()=>a(null),children:`取消`}),(0,B.jsx)(q,{variant:`destructive`,disabled:d.isPending||!i,onClick:()=>{if(!i)return;let e=i;d.mutate(e,{onSuccess:()=>{n?.name===e&&!n.departmentName&&r(null),a(null)}})},children:d.isPending?`删除中...`:`确认删除`})]})]})})]})}var rL=1,iL=.9,aL=.8,oL=.17,sL=.1,cL=.999,lL=.9999,uL=.99,dL=/[\\\/_+.#"@\[\(\{&]/,fL=/[\\\/_+.#"@\[\(\{&]/g,pL=/[\s-]/,mL=/[\s-]/g;function hL(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?rL:uL;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=hL(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=rL:dL.test(e.charAt(l-1))?(d*=aL,p=e.slice(i,l-1).match(fL),p&&i>0&&(d*=cL**+p.length)):pL.test(e.charAt(l-1))?(d*=iL,m=e.slice(i,l-1).match(mL),m&&i>0&&(d*=cL**+m.length)):(d*=oL,i>0&&(d*=cL**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=lL)),(d<sL&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=hL(e,t,n,r,l+1,a+2,o),f*sL>d&&(d=f*sL)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function gL(e){return e.toLowerCase().replace(mL,` `)}function _L(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,hL(e,t,gL(e),gL(t),0,0,{})}var vL=Symbol.for(`react.lazy`),yL=S.use;function bL(e){return typeof e==`object`&&!!e&&`then`in e}function xL(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===vL&&`_payload`in e&&bL(e._payload)}function SL(e){let t=CL(e),n=S.forwardRef((e,n)=>{let{children:r,...i}=e;xL(r)&&typeof yL==`function`&&(r=yL(r._payload));let a=S.Children.toArray(r),o=a.find(TL);if(o){let e=o.props.children,r=a.map(t=>t===o?S.Children.count(e)>1?S.Children.only(null):S.isValidElement(e)?e.props.children:null:t);return(0,B.jsx)(t,{...i,ref:n,children:S.isValidElement(e)?S.cloneElement(e,void 0,r):null})}return(0,B.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function CL(e){let t=S.forwardRef((e,t)=>{let{children:n,...r}=e;if(xL(n)&&typeof yL==`function`&&(n=yL(n._payload)),S.isValidElement(n)){let e=DL(n),i=EL(r,n.props);return n.type!==S.Fragment&&(i.ref=t?is(t,e):e),S.cloneElement(n,i)}return S.Children.count(n)>1?S.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wL=Symbol(`radix.slottable`);function TL(e){return S.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===wL}function EL(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function DL(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OL=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=SL(`Primitive.${t}`),r=S.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,B.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),kL=`[cmdk-group=""]`,AL=`[cmdk-group-items=""]`,jL=`[cmdk-group-heading=""]`,ML=`[cmdk-item=""]`,NL=`${ML}:not([aria-disabled="true"])`,PL=`cmdk-item-select`,FL=`data-value`,IL=(e,t,n)=>_L(e,t,n),LL=S.createContext(void 0),RL=()=>S.useContext(LL),zL=S.createContext(void 0),BL=()=>S.useContext(zL),VL=S.createContext(void 0),HL=S.forwardRef((e,t)=>{let n=nR(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=nR(()=>new Set),i=nR(()=>new Map),a=nR(()=>new Map),o=nR(()=>new Set),s=eR(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ls(),y=Ls(),b=Ls(),x=S.useRef(null),C=aR();tR(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),tR(()=>{C(6,A)},[]);let w=S.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=S.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function E(e,t){let r=s.current?.filter??IL;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(AL);t?t.appendChild(e.parentElement===t?e:e.closest(`${AL} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${AL} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${kL}[${FL}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(FL);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(kL)?.querySelector(jL))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${ML}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(NL)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(FL))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(FL))}function ee(e){let t=j()?.closest(kL),n;for(;t&&!n;)t=e>0?QL(t,kL):$L(t,kL),n=t?.querySelector(NL);n?w.setState(`value`,n.getAttribute(FL)):P(e)}let F=()=>N(M().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?ee(1):P(1)},te=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?ee(-1):P(-1)};return S.createElement(OL.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(PL);t.dispatchEvent(e)}}}}},S.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:cR},c),sR(e,e=>S.createElement(zL.Provider,{value:w},S.createElement(LL.Provider,{value:T},e))))}),UL=S.forwardRef((e,t)=>{let n=Ls(),r=S.useRef(null),i=S.useContext(VL),a=RL(),o=eR(e),s=o.current?.forceMount??i?.forceMount;tR(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=iR(n,r,[e.value,e.children,r],e.keywords),l=BL(),u=rR(e=>e.value&&e.value===c.current),d=rR(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);S.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(PL,f),()=>t.removeEventListener(PL,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return S.createElement(OL.div,{ref:is(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),WL=S.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ls(),s=S.useRef(null),c=S.useRef(null),l=Ls(),u=RL(),d=rR(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);tR(()=>u.group(o),[]),iR(o,s,[e.value,e.heading,c]);let f=S.useMemo(()=>({id:o,forceMount:i}),[i]);return S.createElement(OL.div,{ref:is(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&S.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),sR(e,e=>S.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},S.createElement(VL.Provider,{value:f},e))))}),GL=S.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=S.useRef(null),a=rR(e=>!e.search);return!n&&!a?null:S.createElement(OL.div,{ref:is(i,t),...r,"cmdk-separator":``,role:`separator`})}),KL=S.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=BL(),o=rR(e=>e.search),s=rR(e=>e.selectedItemId),c=RL();return S.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),S.createElement(OL.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),qL=S.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=S.useRef(null),o=S.useRef(null),s=rR(e=>e.selectedItemId),c=RL();return S.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),S.createElement(OL.div,{ref:is(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},sR(e,e=>S.createElement(`div`,{ref:is(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),JL=S.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return S.createElement(Mu,{open:n,onOpenChange:r},S.createElement(Nu,{container:o},S.createElement(Pu,{"cmdk-overlay":``,className:i}),S.createElement(Fu,{"aria-label":e.label,"cmdk-dialog":``,className:a},S.createElement(HL,{ref:t,...s}))))}),YL=S.forwardRef((e,t)=>rR(e=>e.filtered.count===0)?S.createElement(OL.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),XL=S.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return S.createElement(OL.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},sR(e,e=>S.createElement(`div`,{"aria-hidden":!0},e)))}),ZL=Object.assign(HL,{List:qL,Item:UL,Input:KL,Group:WL,Separator:GL,Dialog:JL,Empty:YL,Loading:XL});function QL(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function $L(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function eR(e){let t=S.useRef(e);return tR(()=>{t.current=e}),t}var tR=typeof window>`u`?S.useEffect:S.useLayoutEffect;function nR(e){let t=S.useRef();return t.current===void 0&&(t.current=e()),t}function rR(e){let t=BL(),n=()=>e(t.snapshot());return S.useSyncExternalStore(t.subscribe,n,n)}function iR(e,t,n,r=[]){let i=S.useRef(),a=RL();return tR(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(FL,s),i.current=s}),i}var aR=()=>{let[e,t]=S.useState(),n=nR(()=>new Map);return tR(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function oR(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function sR({asChild:e,children:t},n){return e&&S.isValidElement(t)?S.cloneElement(oR(t),{ref:t.ref},n(t.props.children)):n(t)}var cR={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function lR({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:K(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var uR=dv(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function dR({className:e,align:t=`inline-start`,...n}){return(0,B.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:K(uR({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}function fR({className:e,...t}){return(0,B.jsx)(ZL,{"data-slot":`command`,className:K(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground`,e),...t})}function pR({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,B.jsxs)(lR,{className:`h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!`,children:[(0,B.jsx)(ZL.Input,{"data-slot":`command-input`,className:K(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,B.jsx)(dR,{children:(0,B.jsx)(Po,{className:`size-4 shrink-0 opacity-50`})})]})})}function mR({className:e,...t}){return(0,B.jsx)(ZL.List,{"data-slot":`command-list`,className:K(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function hR({className:e,...t}){return(0,B.jsx)(ZL.Empty,{"data-slot":`command-empty`,className:K(`py-6 text-center text-sm`,e),...t})}function gR({className:e,...t}){return(0,B.jsx)(ZL.Group,{"data-slot":`command-group`,className:K(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function _R({className:e,children:t,...n}){return(0,B.jsxs)(ZL.Item,{"data-slot":`command-item`,className:K(`group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,B.jsx)(Ia,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}function vR({...e}){return(0,B.jsx)(ym,{"data-slot":`popover`,...e})}function yR({...e}){return(0,B.jsx)(bm,{"data-slot":`popover-trigger`,...e})}function bR({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,B.jsx)(xm,{children:(0,B.jsx)(Sm,{"data-slot":`popover-content`,align:t,sideOffset:n,className:K(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function xR(){let{data:e,refetch:t}=Qv(),n=ay(),r=oy(),i=sy(),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(``),[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(``),[y,b]=(0,S.useState)(`memory`),[x,C]=(0,S.useState)(null);(0,S.useEffect)(()=>{!s&&e?.[0]?.userId&&(c(e[0].userId),u(e[0].userId))},[s,e]);let w=s?.trim()||null,T=(0,S.useMemo)(()=>FR(e??[]),[e]),{data:E,isLoading:D}=$v(w),{data:O,isLoading:k}=ey(w),{data:A,isLoading:j}=ty(w),M=y===`all-context`||!!x,{data:N,isLoading:P,refetch:ee}=ny({enabled:M,refetchInterval:M?5e3:!1}),{data:F,isLoading:I}=ry(w),{data:te,isLoading:ne}=iy(w,_.trim()),re=F?.summaries??[],L=te?.entries??[],R=O?.dreamHistory??[],z=E?.find(e=>e.id===d)??null,ie=e?.find(e=>e.userId===w)??null,ae=re[0]??null,oe=N?.sources??[],se=x?oe.find(e=>e.userId===x)??null:null;(0,S.useEffect)(()=>{if(!w)return;if(!E||E.length===0){f(null);return}let e=E.some(e=>e.id===d);(!d||!e)&&f(E[0].id)},[w,E,d]),(0,S.useEffect)(()=>{if(z){m(z.title),g(z.content);return}m(``),g(``)},[z]),(0,S.useEffect)(()=>{!x||!N||oe.some(e=>e.userId===x)||C(null)},[oe,N,x]);let ce=()=>{let e=l.trim();e&&(c(e),f(null))},le=e=>{c(e),u(e),f(null),o(!1)};return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`上下文与记忆`}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`观测用户长期记忆、梦境、会话压缩和统一召回索引;Memory 可编辑,Compact 与 Dream 只做审计。`})]}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{t(),ee()},children:[(0,B.jsx)(Ao,{className:`h-4 w-4`}),`刷新`]})]}),(0,B.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-sm font-medium`,children:[(0,B.jsx)(Jo,{className:`h-4 w-4 text-primary`}),`用户 / 线程`]}),(0,B.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_220px]`,children:[(0,B.jsxs)(vR,{open:a,onOpenChange:o,children:[(0,B.jsx)(yR,{asChild:!0,children:(0,B.jsxs)(q,{variant:`outline`,className:`h-14 min-w-0 justify-between px-4 text-left`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:w?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(w,ie??void 0)}),(0,B.jsx)(J,{variant:`outline`,children:LR(w)})]}),(0,B.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:w})]}):(0,B.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`选择一个用户或线程`})}),(0,B.jsx)(La,{className:`ml-3 h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,B.jsx)(bR,{align:`start`,className:`w-[min(760px,calc(100vw-3rem))] p-0`,children:(0,B.jsxs)(fR,{children:[(0,B.jsx)(pR,{placeholder:`搜索 userId、部门成员、kanban 线程`}),(0,B.jsxs)(mR,{className:`max-h-[420px]`,children:[(0,B.jsx)(hR,{children:`没有匹配到已发现的用户,可用右侧手动输入。`}),T.map(e=>(0,B.jsx)(gR,{heading:e.label,children:e.users.map(e=>(0,B.jsxs)(_R,{value:IR(e),onSelect:()=>le(e.userId),className:`items-start gap-3 py-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(e.userId,e)}),e.hasMemory&&(0,B.jsxs)(J,{variant:`secondary`,children:[e.memoryCount,` 条记忆`]}),e.hasDream&&(0,B.jsx)(J,{variant:`outline`,children:`有梦境`})]}),(0,B.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-muted-foreground`,children:e.userId}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.lastActivityAt?`最近活跃 ${BR(e.lastActivityAt)}`:`暂无活跃时间`})]}),e.userId===w&&(0,B.jsx)(Va,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary`})]},e.userId))},e.kind))]})]})})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(ew,{value:l,onChange:e=>u(e.target.value),placeholder:`手动 userId`,className:`h-14 min-w-0 font-mono text-xs`}),(0,B.jsx)(q,{className:`h-14 shrink-0`,onClick:ce,disabled:!l.trim(),children:`应用`})]})]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium`,children:`当前对象`}),w?(0,B.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,children:LR(w)}),ie?.hasConversation&&(0,B.jsx)(J,{variant:`secondary`,children:`有对话索引`}),ie?.hasDream&&(0,B.jsx)(J,{variant:`secondary`,children:`有梦境`}),(ie?.relatedUserIds?.length??0)>0&&(0,B.jsxs)(J,{variant:`secondary`,children:[ie?.relatedUserIds?.length,` 个上下文源`]})]}),(0,B.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-muted-foreground`,children:w}),(ie?.relatedUserIds?.length??0)>0&&(0,B.jsx)(`div`,{className:`text-xs leading-5 text-muted-foreground`,children:`已合并 Main Manager 主线与部门 mailbox 上下文。`})]}):(0,B.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:`尚未选择用户。`})]})]}),w?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-5`,children:[(0,B.jsx)(SR,{icon:Na,label:`Memory`,value:`${E?.length??0}`,note:`可编辑长期记忆`,loading:D}),(0,B.jsx)(SR,{icon:Bo,label:`Dream`,value:O?.dreamContent?`有`:`无`,note:`${R.length} 条历史`,loading:k}),(0,B.jsx)(SR,{icon:Ja,label:`Compact`,value:`${re.length}`,note:ae?`最近 ${BR(ae.createdAt)}`:`暂无压缩`,loading:I}),(0,B.jsx)(SR,{icon:Po,label:`Recall`,value:`${te?.total??0}`,note:_.trim()?`查询结果`:`索引总数`,loading:ne}),(0,B.jsx)(SR,{icon:Ua,label:`活跃`,value:ie?.lastActivityAt?zR(ie.lastActivityAt):`--`,note:ie?.lastActivityAt?BR(ie.lastActivityAt):`暂无记录`})]}),(0,B.jsxs)($N,{value:y,onValueChange:b,className:`space-y-4`,children:[(0,B.jsxs)(tP,{className:`h-auto flex-wrap justify-start`,children:[(0,B.jsx)(nP,{value:`memory`,children:`长期记忆`}),(0,B.jsx)(nP,{value:`dream`,children:`梦境`}),(0,B.jsx)(nP,{value:`compact`,children:`会话压缩`}),(0,B.jsx)(nP,{value:`recall`,children:`召回索引`}),(0,B.jsx)(nP,{value:`all-context`,children:`所有上下文`}),(0,B.jsx)(nP,{value:`context`,children:`注入预览`})]}),(0,B.jsx)(rP,{value:`memory`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-[380px_minmax(0,1fr)]`,children:[(0,B.jsxs)(Y,{children:[(0,B.jsxs)(Iy,{className:`flex-row items-center justify-between`,children:[(0,B.jsx)(Ly,{className:`text-base`,children:`Memory 列表`}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{f(null),m(``),g(``)},children:[(0,B.jsx)(Oo,{className:`h-4 w-4`}),`新建`]})]}),(0,B.jsx)(zy,{children:D?(0,B.jsx)(NR,{rows:4}):E?.length?(0,B.jsx)(iv,{className:`max-h-[590px]`,children:(0,B.jsx)(`div`,{className:`space-y-2 pr-3`,children:E.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:`w-full rounded-lg border p-3 text-left hover:bg-muted/40 ${d===e.id?`border-primary bg-primary/5`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`max-w-28 overflow-hidden text-ellipsis font-mono text-[10px]`,children:e.id}),e.userId!==w&&(0,B.jsx)(J,{variant:`secondary`,className:`max-w-36 overflow-hidden text-ellipsis font-mono text-[10px]`,children:e.userId}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:BR(e.updatedAt)})]}),(0,B.jsx)(`div`,{className:`mt-2 break-words text-sm font-semibold`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]`,children:VR(HR(e.content),120)})]},e.id))})}):(0,B.jsx)(PR,{text:`这个 userId 还没有长期记忆。`})})]}),(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsx)(Ly,{className:`text-base`,children:z?`编辑长期记忆`:`新建长期记忆`})}),(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`标题`}),(0,B.jsx)(ew,{value:p,onChange:e=>m(e.target.value),placeholder:`例如:偏好-包管理器`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:`内容`}),(0,B.jsx)(tw,{value:h,onChange:e=>g(e.target.value),className:`min-h-44`,placeholder:`稳定事实、偏好或长期约束。`})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:z?.id??`new memory`}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[z&&(0,B.jsxs)(q,{variant:`destructive`,onClick:async()=>{!w||!z||(await i.mutateAsync({id:z.id,userId:z.userId||w}),f(null))},disabled:i.isPending,children:[(0,B.jsx)(Go,{className:`h-4 w-4`}),`删除`]}),(0,B.jsxs)(q,{onClick:async()=>{if(!(!w||!p.trim()||!h.trim())){if(z){await r.mutateAsync({id:z.id,data:{userId:z.userId||w,title:p.trim(),content:h.trim()}});return}f((await n.mutateAsync({userId:w,title:p.trim(),content:h.trim()})).id)}},disabled:!p.trim()||!h.trim()||n.isPending||r.isPending,children:[(0,B.jsx)(No,{className:`h-4 w-4`}),z?`保存`:`创建`]})]})]})]})]})]})}),(0,B.jsx)(rP,{value:`dream`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,B.jsx)(CR,{title:`最新梦境`,icon:Bo,loading:k,empty:`还没有 dream。系统会在长时间不活跃后生成长期记忆沉淀。`,content:O?.dreamContent}),(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(so,{className:`h-4 w-4 text-primary`}),`Dream History`]})}),(0,B.jsx)(zy,{children:k?(0,B.jsx)(NR,{rows:4}):R.length===0?(0,B.jsx)(PR,{text:`暂无梦境历史。`}):(0,B.jsx)(iv,{className:`max-h-[520px]`,children:(0,B.jsx)(`div`,{className:`space-y-3 pr-3`,children:R.map(e=>(0,B.jsx)(jR,{title:BR(e.createdAt),meta:`${e.sourceMessageCount} 条来源消息`,content:e.content},e.id))})})})]})]})}),(0,B.jsx)(rP,{value:`compact`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(Ja,{className:`h-4 w-4 text-primary`}),`Compact Summaries`]})}),(0,B.jsx)(zy,{children:I?(0,B.jsx)(NR,{rows:5}):re.length===0?(0,B.jsx)(PR,{text:`暂无会话压缩摘要。长上下文触发 compact 后会出现在这里。`}):(0,B.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:re.map(e=>(0,B.jsx)(kR,{summary:e},e.id))})})]})}),(0,B.jsx)(rP,{value:`recall`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(Po,{className:`h-4 w-4 text-primary`}),`Recall 测试`]})}),(0,B.jsxs)(zy,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,B.jsx)(ew,{value:_,onChange:e=>v(e.target.value),placeholder:`输入关键词,例如:蓝兔支付 / 准生产 / ENOENT`,className:`h-10`}),(0,B.jsx)(q,{variant:`outline`,onClick:()=>v(``),disabled:!_,children:`清空`})]}),ne?(0,B.jsx)(NR,{rows:5}):L.length===0?(0,B.jsx)(PR,{text:_.trim()?`没有匹配的召回结果。`:`暂无 recall index 条目。`}):(0,B.jsx)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:L.map(e=>(0,B.jsx)(AR,{entry:e},`${e.type}:${e.id}`))})]})]})}),(0,B.jsx)(rP,{value:`context`,children:(0,B.jsxs)(`section`,{className:`grid gap-5 xl:grid-cols-2`,children:[(0,B.jsx)(CR,{title:`Memory Context`,icon:Qa,loading:j,content:A?.memoryContextBlock,empty:`没有长期记忆注入块。`}),(0,B.jsx)(CR,{title:`Dream Context`,icon:bo,loading:j,content:A?.dreamContextBlock,empty:`没有梦境注入块。`})]})}),(0,B.jsx)(rP,{value:`all-context`,children:(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(bo,{className:`h-4 w-4 text-primary`}),`Main Manager 可见上下文`]})}),(0,B.jsx)(zy,{children:P?(0,B.jsx)(NR,{rows:5}):oe.length===0?(0,B.jsx)(PR,{text:`暂无可查看的对话上下文。`}):(0,B.jsx)(`div`,{className:`space-y-4`,children:oe.map(e=>(0,B.jsx)(wR,{source:e,onOpen:()=>C(e.userId)},e.userId))})})]})})]})]}):(0,B.jsx)(Y,{children:(0,B.jsx)(zy,{className:`py-16 text-center text-muted-foreground`,children:`先选择一个 userId,再查看上下文、记忆和召回索引。`})})]}),(0,B.jsx)(TR,{source:se,onClose:()=>C(null)})]})}function SR({icon:e,label:t,value:n,note:r,loading:i}){return(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{className:`pb-2`,children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,B.jsx)(e,{className:`h-4 w-4`}),t]})}),(0,B.jsxs)(zy,{children:[i?(0,B.jsx)(X,{className:`h-7 w-20`}):(0,B.jsx)(`div`,{className:`text-2xl font-semibold`,children:n}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r})]})]})}function CR({title:e,icon:t,content:n,empty:r,loading:i}){return(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2 text-base`,children:[(0,B.jsx)(t,{className:`h-4 w-4 text-primary`}),e]})}),(0,B.jsx)(zy,{children:i?(0,B.jsx)(NR,{rows:4}):n?.trim()?(0,B.jsx)(`div`,{className:`max-h-[560px] overflow-auto rounded-lg border bg-muted/25 p-4`,children:(0,B.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm leading-6 [overflow-wrap:anywhere]`,children:n})}):(0,B.jsx)(PR,{text:r})})]})}function wR({source:e,onOpen:t}){let n=e.agentLogs.slice(-2);return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:RR(e.userId)}),(0,B.jsx)(J,{variant:`outline`,children:LR(e.userId)}),(0,B.jsxs)(J,{variant:`secondary`,children:[e.messageCount,` 条上下文`]})]}),(0,B.jsx)(`div`,{className:`mt-1 break-all font-mono text-xs text-muted-foreground`,children:e.userId})]}),(0,B.jsxs)(q,{variant:`outline`,size:`sm`,onClick:t,children:[(0,B.jsx)(Za,{className:`h-4 w-4`}),`查看`]})]}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-muted/20 p-3`,children:[(0,B.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`最近上下文预览`}),n.map(t=>(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(J,{variant:t.role===`user`?`default`:`secondary`,className:`h-4 px-1.5 py-0 text-[10px]`,children:t.role===`user`?`User`:`Assistant`}),(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,t.index]}),(0,B.jsx)(`span`,{className:`truncate`,children:DR(t)})]},`${e.userId}:${t.index}`)),n.length===0&&(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`暂无预览。`})]})]})}function TR({source:e,onClose:t}){let[n,r]=(0,S.useState)(1);if((0,S.useEffect)(()=>{r(1)},[e?.userId]),!e)return null;let i=Math.max(1,Math.ceil(e.agentLogs.length/12)),a=Math.min(n,i),o=(a-1)*12,s=e.agentLogs.slice(o,o+12);return(0,B.jsx)(nw,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,B.jsxs)(aw,{className:`grid max-h-[88vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden p-0 sm:max-w-5xl`,children:[(0,B.jsxs)(ow,{className:`border-b px-6 py-5`,children:[(0,B.jsxs)(cw,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(bo,{className:`h-4 w-4 text-primary`}),RR(e.userId),(0,B.jsx)(J,{variant:`outline`,children:LR(e.userId)})]}),(0,B.jsxs)(lw,{className:`break-all font-mono text-xs`,children:[e.userId,` · 共 `,e.messageCount,` 条上下文`]})]}),(0,B.jsx)(iv,{className:`min-h-0 px-6 py-4`,children:(0,B.jsx)(`div`,{className:`space-y-4 pr-3`,children:s.map(t=>(0,B.jsx)(ER,{log:t},`${e.userId}:${t.index}`))})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t px-6 py-4 text-sm`,children:[(0,B.jsxs)(`div`,{className:`text-muted-foreground`,children:[`第 `,a,` / `,i,` 页 · 当前 `,s.length,` 条`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(1),disabled:a<=1,children:`首页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(e=>Math.max(1,e-1)),disabled:a<=1,children:`上一页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(e=>Math.min(i,e+1)),disabled:a>=i,children:`下一页`}),(0,B.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>r(i),disabled:a>=i,children:`末页`})]})]})]})})}function ER({log:e}){let t=e.role===`user`;return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.index]}),(0,B.jsx)(J,{variant:t?`default`:`secondary`,className:`h-4 px-1.5 py-0 text-[10px]`,children:t?`User`:`Assistant`})]}),(0,B.jsx)(`div`,{className:`space-y-2 pl-2`,children:e.blocks.map((e,n)=>(0,B.jsx)(OR,{block:e,isUser:t},n))})]})}function DR(e){let t=e.blocks.find(e=>e.type===`text`&&typeof e.text==`string`);if(t&&typeof t.text==`string`&&t.text.trim())return VR(t.text.replace(/\s+/g,` `).trim(),120);let n=e.blocks.find(e=>e.type===`tool_use`);if(n)return`tool_use: ${String(n.name??`unknown`)}`;let r=e.blocks.find(e=>e.type===`tool_result`);return r?`tool_result: ${String(r.toolUseId??``)}`:e.blocks.find(e=>e.type===`thinking`)?`thinking: 模型思考块`:e.blocks.find(e=>e.type===`image`)?`image: 图片内容块`:`无文本内容`}function OR({block:e,isUser:t}){let[n,r]=(0,S.useState)(!1),i=String(e.type??`unknown`);if(i===`text`){let i=String(e.text??``),a=i.length>360;return(0,B.jsxs)(`div`,{className:`rounded-md border px-3 py-2 text-sm whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t?`border-emerald-500/10 bg-emerald-500/5`:`border-sky-500/10 bg-sky-500/5`}`,children:[n||!a?i:VR(i,360),a&&(0,B.jsx)(q,{variant:`ghost`,size:`sm`,className:`ml-1 h-6 px-1 text-xs`,onClick:()=>r(e=>!e),children:n?`收起`:`展开`})]})}if(i===`tool_use`)return(0,B.jsxs)(`div`,{className:`rounded-md border border-primary/20 bg-primary/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Qo,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,B.jsx)(`span`,{className:`text-sm font-semibold text-primary`,children:String(e.name??`unknown`)}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:JSON.stringify(e.input??{},null,2)})]});if(i===`tool_result`){let t=typeof e.content==`string`?e.content:JSON.stringify(e.content,null,2);return(0,B.jsxs)(`div`,{className:`rounded-md border border-amber-500/20 bg-amber-500/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsxs)(`span`,{className:`font-mono text-xs text-amber-700 dark:text-amber-300`,children:[`tool_result `,String(e.toolUseId??``)]}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:t})]})}if(i===`thinking`){let t=String(e.thinking??``);return(0,B.jsxs)(`div`,{className:`rounded-md border border-violet-500/20 bg-violet-500/5 px-3 py-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:()=>r(e=>!e),children:[(0,B.jsx)(Na,{className:`h-3.5 w-3.5 shrink-0 text-violet-500`}),(0,B.jsx)(`span`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:`thinking`}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:`模型思考块`}),(0,B.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,B.jsx)(La,{className:`h-3 w-3`}):(0,B.jsx)(za,{className:`h-3 w-3`})})]}),n&&t.trim()&&(0,B.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded bg-background/60 p-2 text-xs text-muted-foreground`,children:t})]})}return i===`image`?(0,B.jsx)(`div`,{className:`rounded-md border border-slate-500/15 bg-slate-500/5 px-3 py-2 text-sm text-muted-foreground`,children:`图片内容块`}):(0,B.jsxs)(`div`,{className:`rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground`,children:[`[unknown block: `,i,`]`]})}function kR({summary:e}){return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,children:e.date}),e.cronTitle&&(0,B.jsx)(J,{variant:`secondary`,children:e.cronTitle}),(0,B.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:BR(e.createdAt)})]}),(0,B.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs text-muted-foreground`,children:[(0,B.jsx)(MR,{label:`before`,value:UR(e.contextTokensBefore)}),(0,B.jsx)(MR,{label:`after`,value:UR(e.contextTokensAfter)}),(0,B.jsx)(MR,{label:`hot tail`,value:String(e.hotTailCount)})]}),(0,B.jsx)(`pre`,{className:`mt-3 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted/25 p-3 text-xs leading-5 [overflow-wrap:anywhere]`,children:e.summary})]})}function AR({entry:e}){return(0,B.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(J,{variant:e.type===`memory`?`secondary`:`outline`,children:e.type}),(0,B.jsx)(J,{variant:`outline`,children:e.date}),e.score!==void 0&&(0,B.jsxs)(J,{variant:`outline`,children:[`score `,e.score]})]}),(0,B.jsx)(`h3`,{className:`mt-3 break-words text-sm font-semibold`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-2 break-words text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:VR(e.summary,360)}),e.keywords.length>0&&(0,B.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,children:e.keywords.slice(0,8).map(e=>(0,B.jsx)(J,{variant:`outline`,className:`text-[10px]`,children:e},e))})]})}function jR({title:e,meta:t,content:n}){return(0,B.jsxs)(`article`,{className:`rounded-lg border p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:e}),(0,B.jsx)(`span`,{children:t})]}),(0,B.jsx)(`p`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap break-words text-xs leading-5 [overflow-wrap:anywhere]`,children:n})]})}function MR({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`rounded-md border bg-muted/20 px-2 py-1`,children:[(0,B.jsx)(`div`,{children:e}),(0,B.jsx)(`div`,{className:`font-mono text-foreground`,children:t})]})}function NR({rows:e}){return(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:e}).map((e,t)=>(0,B.jsx)(X,{className:`h-20 w-full`},t))})}function PR({text:e}){return(0,B.jsx)(`div`,{className:`rounded-lg border border-dashed px-4 py-10 text-center text-sm text-muted-foreground`,children:e})}function FR(e){let t=[`Chat`,`Department`,`Kanban`,`User`],n=new Map;for(let t of e){let e=LR(t.userId),r=n.get(e)??[];r.push(t),n.set(e,r)}return t.map(e=>({kind:e,label:e,users:(n.get(e)??[]).sort((e,t)=>(t.lastActivityAt??0)-(e.lastActivityAt??0)||(t.memoryCount??0)-(e.memoryCount??0)||e.userId.localeCompare(t.userId))})).filter(e=>e.users.length>0)}function IR(e){return[e.userId,RR(e.userId,e),LR(e.userId),e.hasMemory?`has-memory`:``,e.hasDream?`has-dream`:``].filter(Boolean).join(` `)}function LR(e){return e.startsWith(`kanban:`)?`Kanban`:e.includes(`::`)?`Department`:e.startsWith(`oc_`)||e.startsWith(`chat_`)?`Chat`:`User`}function RR(e,t){return t?.displayName?t.displayName:e.startsWith(`kanban:`)?e.split(`:`).at(-1)||e:e.includes(`::`)&&e.split(`::`).at(-1)||e}function zR(e){try{return new Date(e).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return String(e)}}function BR(e){try{let t=Date.now()-e;return t<6e4?`刚刚`:t<36e5?`${Math.max(1,Math.floor(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.floor(t/36e5))} 小时前`:zR(e)}catch{return String(e)}}function VR(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function HR(e){return e.replace(/\r\n?/g,`
|
|
93
93
|
`).replace(/```[\s\S]*?```/g,e=>e.replace(/```[\w-]*\n?/g,``).trim()).replace(/^#{1,6}\s+/gm,``).replace(/\[([^\]]+)\]\(([^)]+)\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\n{3,}/g,`
|
|
94
94
|
|
|
95
95
|
`).trim()}function UR(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var WR=()=>vv(`/api/system/info`),GR={info:[`system`,`info`]};function KR(){return yi({queryKey:GR.info,queryFn:WR,refetchInterval:3e4})}function qR(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=[];return t>0&&a.push(`${t} 天`),n>0&&a.push(`${n} 小时`),r>0&&a.push(`${r} 分钟`),(i>0||a.length===0)&&a.push(`${i} 秒`),a.join(` `)}function JR(){let{data:e,isLoading:t}=KR();return(0,B.jsxs)(Py,{children:[(0,B.jsxs)(`div`,{className:`mb-6`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Settings`}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`系统配置与状态信息`})]}),(0,B.jsxs)(Y,{className:`mb-6`,children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Ea,{className:`h-4 w-4`}),`系统状态`]})}),(0,B.jsx)(zy,{children:t?(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(X,{className:`h-5 w-full`},t))}):e?(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[120px_1fr] items-center gap-3 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`版本`}),(0,B.jsx)(J,{variant:`secondary`,children:e.version})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[120px_1fr] items-center gap-3 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`运行时间`}),(0,B.jsx)(`span`,{children:qR(e.uptime)})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[120px_1fr] items-center gap-3 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`环境`}),(0,B.jsx)(J,{variant:e.env===`production`?`default`:`secondary`,children:e.env})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[120px_1fr] items-center gap-3 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Node.js`}),(0,B.jsx)(`code`,{className:`rounded bg-muted px-2 py-0.5 text-xs`,children:e.nodeVersion})]})]}):(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`无法获取系统信息`})})]}),(0,B.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2`,children:[(0,B.jsx)(lo,{className:`h-4 w-4`}),`关于`]})}),(0,B.jsx)(zy,{children:(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`DuClaw Agent Manager 是一个多 Agent 协作管理平台, 提供 Kanban 看板、部门管理、定时任务、技能/工具管理等功能。`})})]}),(0,B.jsxs)(Y,{children:[(0,B.jsx)(Iy,{children:(0,B.jsxs)(Ly,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Io,{className:`h-4 w-4`}),`API 端点`]})}),(0,B.jsx)(zy,{children:(0,B.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/goals`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/departments`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/tools`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/skills`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/cron/jobs`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(J,{variant:`outline`,className:`text-xs`,children:`GET`}),(0,B.jsx)(`code`,{className:`text-xs`,children:`/api/system/info`})]})]})})]})]})]})}function YR(){return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,B.jsxs)(`div`,{className:`text-center`,children:[(0,B.jsx)(`h1`,{className:`text-4xl font-bold text-foreground`,children:`404`}),(0,B.jsx)(`p`,{className:`mt-2`,children:`页面不存在`})]})})}function XR(){return(0,B.jsx)(HP,{children:(0,B.jsx)(Pt,{children:(0,B.jsxs)(Mt,{element:(0,B.jsx)(hv,{}),children:[(0,B.jsx)(Mt,{index:!0,element:(0,B.jsx)(At,{to:`/dashboard`,replace:!0})}),(0,B.jsx)(Mt,{path:`dashboard`,element:(0,B.jsx)(nb,{})}),(0,B.jsx)(Mt,{path:`kanban`,element:(0,B.jsx)(YC,{})}),(0,B.jsx)(Mt,{path:`kanban/:goalId`,element:(0,B.jsx)(YC,{})}),(0,B.jsx)(Mt,{path:`departments`,element:(0,B.jsx)(uw,{})}),(0,B.jsx)(Mt,{path:`departments/:departmentName`,element:(0,B.jsx)(HF,{})}),(0,B.jsx)(Mt,{path:`memory`,element:(0,B.jsx)(xR,{})}),(0,B.jsx)(Mt,{path:`cron`,element:(0,B.jsx)(FI,{})}),(0,B.jsx)(Mt,{path:`tools`,element:(0,B.jsx)(GI,{})}),(0,B.jsx)(Mt,{path:`skills`,element:(0,B.jsx)(nL,{})}),(0,B.jsx)(Mt,{path:`settings`,element:(0,B.jsx)(JR,{})}),(0,B.jsx)(Mt,{path:`mailbox`,element:(0,B.jsx)(At,{to:`/departments`,replace:!0})}),(0,B.jsx)(Mt,{path:`*`,element:(0,B.jsx)(YR,{})})]})})})}(0,xi.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(S.StrictMode,{children:(0,B.jsx)(zi,{children:(0,B.jsx)(ii,{client:Si,children:(0,B.jsxs)(Sn,{basename:Ci(),children:[(0,B.jsx)(XR,{}),(0,B.jsx)(ns,{position:`top-right`,richColors:!0})]})})})}));
|