@becomeopc/trendpublish 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dashboard/assets/-association-list-MaFlvvF5.js +1 -0
  2. package/dashboard/assets/-channel-templates-B0KzH4gz.js +6 -0
  3. package/dashboard/assets/-content-package-preview-Bc225W8p.js +1 -0
  4. package/dashboard/assets/-editor-page-DIrPd6Jj.js +1 -0
  5. package/dashboard/assets/-run-detail-view-CSb6Mp_W.js +12 -0
  6. package/dashboard/assets/-run-presentation-e-aAMUOA.js +1 -0
  7. package/dashboard/assets/AnimatePresence-dRKyi9jP.js +9 -0
  8. package/dashboard/assets/_app-C0k3Jpvj.js +1 -0
  9. package/dashboard/assets/app-dialog-CBRjH8y0.js +1 -0
  10. package/dashboard/assets/arrow-left-B1paVsKl.js +1 -0
  11. package/dashboard/assets/arrow-right-Bm6j4CRT.js +1 -0
  12. package/dashboard/assets/articles-CJ24swVV.js +1 -0
  13. package/dashboard/assets/automations-CSqhc87N.js +2 -0
  14. package/dashboard/assets/becomeopc-EvwYWHkB.js +1 -0
  15. package/dashboard/assets/check-_AvUITNy.js +1 -0
  16. package/dashboard/assets/chevron-down-CjEG9BtO.js +1 -0
  17. package/dashboard/assets/chevron-right-BcV2-ijN.js +1 -0
  18. package/dashboard/assets/connections-CUkG-3WF.js +1 -0
  19. package/dashboard/assets/content-plans-1_S1hkDo.js +1 -0
  20. package/dashboard/assets/content-plans_._planId.edit-2sqaHVmd.js +1 -0
  21. package/dashboard/assets/content-plans_.new-2sqaHVmd.js +1 -0
  22. package/dashboard/assets/copy-C4Adx2li.js +1 -0
  23. package/dashboard/assets/dropdown-menu-mpdg8__C.js +1 -0
  24. package/dashboard/assets/empty-state-B2PGtu_a.js +1 -0
  25. package/dashboard/assets/entity-list-B2WXTDDM.js +1 -0
  26. package/dashboard/assets/execution-Brd94hIY.js +1 -0
  27. package/dashboard/assets/external-link-B2pLgsIl.js +1 -0
  28. package/dashboard/assets/eye-DyaLFyNg.js +1 -0
  29. package/dashboard/assets/file-text-BqjzSiui.js +1 -0
  30. package/dashboard/assets/fingerprint-pattern-CVznkwfS.js +1 -0
  31. package/dashboard/assets/flask-conical-B9Pn4z-3.js +1 -0
  32. package/dashboard/assets/form-field-BJITE8Lh.js +1 -0
  33. package/dashboard/assets/identities-Bpb-f7oo.js +3 -0
  34. package/dashboard/assets/index-Bx1uywm3.js +51 -0
  35. package/dashboard/assets/index-ghPnBUnR.css +2 -0
  36. package/dashboard/assets/input-Br6N0XCJ.js +1 -0
  37. package/dashboard/assets/jobs-BiQwL4Yt.js +1 -0
  38. package/dashboard/assets/jobs_._runId-DQ9L-G8H.js +1 -0
  39. package/dashboard/assets/knowledge-BePtU9f6.js +1 -0
  40. package/dashboard/assets/layers-B6jc9X_5.js +1 -0
  41. package/dashboard/assets/layout-template-11JYpJ5n.js +1 -0
  42. package/dashboard/assets/library-BlLpV8Oh.js +1 -0
  43. package/dashboard/assets/newspaper-BF6EkBWC.js +1 -0
  44. package/dashboard/assets/notifications-wLr7xSyr.js +1 -0
  45. package/dashboard/assets/page-grid-BR5GG4AN.js +1 -0
  46. package/dashboard/assets/pagination-CEYfdE0s.js +1 -0
  47. package/dashboard/assets/play-DYoZjslk.js +1 -0
  48. package/dashboard/assets/plus-DewHiaw6.js +1 -0
  49. package/dashboard/assets/publication-destination-picker-DAgQcLxS.js +1 -0
  50. package/dashboard/assets/publishing-DOrwrfAd.js +1 -0
  51. package/dashboard/assets/publishing_.styles-DUnbtaS6.js +1 -0
  52. package/dashboard/assets/publishing_.templates-pMvBK24N.js +1 -0
  53. package/dashboard/assets/publishing_.templates_.sessions._sessionId-FkykBbtF.js +1 -0
  54. package/dashboard/assets/radio-tower-CS59Tvfq.js +1 -0
  55. package/dashboard/assets/react-OqyHmgtK.js +1 -0
  56. package/dashboard/assets/refresh-cw-BB9_0X86.js +1 -0
  57. package/dashboard/assets/rolldown-runtime-DoHqwKmD.js +1 -0
  58. package/dashboard/assets/routes-15GLqJa6.js +1 -0
  59. package/dashboard/assets/runs-Cbz28Mf6.js +1 -0
  60. package/dashboard/assets/select-9cx3otc_.js +1 -0
  61. package/dashboard/assets/settings-CeJjvt-K.js +1 -0
  62. package/dashboard/assets/sources-CsuPzTTH.js +1 -0
  63. package/dashboard/assets/sparkles-C9YU6Kr5.js +1 -0
  64. package/dashboard/assets/src-DVp5YM1T.js +1 -0
  65. package/dashboard/assets/sse-DQK6eHXZ.js +4 -0
  66. package/dashboard/assets/tabs-DdmTx_k0.js +1 -0
  67. package/dashboard/assets/textarea-zbjD4aac.js +1 -0
  68. package/dashboard/assets/trash-2-CcgFunKh.js +1 -0
  69. package/dashboard/assets/types-D57tnOAh.js +1 -0
  70. package/dashboard/assets/use-onboarding-fKNsbNhX.js +1 -0
  71. package/dashboard/assets/use-workspace-snapshot-MZKeTfAJ.js +1 -0
  72. package/dashboard/assets/useMutation-Xdq_89ou.js +1 -0
  73. package/dashboard/assets/workspace-XH4e6E59.js +1 -0
  74. package/dashboard/assets/wrench-C9HmhR9v.js +1 -0
  75. package/dashboard/favicon.svg +5 -0
  76. package/dashboard/index.html +15 -0
  77. package/dist/app.js +47724 -0
  78. package/dist/cli.js +11 -0
  79. package/drizzle/0000_zippy_juggernaut.sql +361 -0
  80. package/drizzle/0001_safe_green_goblin.sql +15 -0
  81. package/drizzle/meta/0000_snapshot.json +2221 -0
  82. package/drizzle/meta/0001_snapshot.json +2299 -0
  83. package/drizzle/meta/_journal.json +20 -0
  84. package/package.json +29 -4
  85. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ import{U as e,X as t,ln as n}from"./index-Bx1uywm3.js";import{t as r}from"./plus-DewHiaw6.js";import{t as i}from"./trash-2-CcgFunKh.js";import{n as a,o,r as s,t as c}from"./dropdown-menu-mpdg8__C.js";var l=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),u=t(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),d=n();function f({items:t,available:n,empty:f,addLabel:p,onAdd:m,onRemove:h,onMove:g}){return(0,d.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface)]`,children:[t.length?(0,d.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:t.map((n,r)=>(0,d.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-5 px-4 py-3`,children:[(0,d.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,d.jsx)(`strong`,{className:`block text-sm font-semibold text-[var(--ink)]`,children:n.name}),(0,d.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-[var(--muted-strong)]`,children:n.detail})]}),(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[g?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e,{type:`button`,size:`icon`,variant:`ghost`,className:`size-8 min-h-0`,disabled:r===0,"aria-label":`上移${n.name}`,onClick:()=>g(n.id,-1),children:(0,d.jsx)(u,{className:`size-3.5`})}),(0,d.jsx)(e,{type:`button`,size:`icon`,variant:`ghost`,className:`size-8 min-h-0`,disabled:r===t.length-1,"aria-label":`下移${n.name}`,onClick:()=>g(n.id,1),children:(0,d.jsx)(l,{className:`size-3.5`})})]}):null,(0,d.jsx)(e,{type:`button`,size:`icon`,variant:`ghost`,className:`size-8 min-h-0`,"aria-label":`移除${n.name}`,title:`移除${n.name}`,onClick:()=>h(n.id),children:(0,d.jsx)(i,{className:`size-4`})})]})]},n.id))}):(0,d.jsx)(`p`,{className:`px-4 py-7 text-center text-sm text-[var(--muted)]`,children:f}),n.length?(0,d.jsx)(`div`,{className:`border-t border-[var(--border)] p-2`,children:(0,d.jsxs)(c,{children:[(0,d.jsx)(o,{asChild:!0,children:(0,d.jsxs)(e,{type:`button`,size:`sm`,variant:`ghost`,children:[(0,d.jsx)(r,{className:`size-3.5`}),p]})}),(0,d.jsx)(a,{align:`start`,className:`min-w-64`,children:n.map(e=>(0,d.jsx)(s,{onSelect:()=>m(e.id),children:(0,d.jsxs)(`span`,{className:`min-w-0 py-0.5`,children:[(0,d.jsx)(`strong`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,d.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-[var(--muted)]`,children:e.detail})]})},e.id))})]})}):null]})}export{f as t};
@@ -0,0 +1,6 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{$ as t,F as n,It as r,J as i,Lt as a,N as o,P as s,Q as c,U as l,W as u,X as d,Z as f,dn as p,in as m,ln as h,nt as g}from"./index-Bx1uywm3.js";import{n as _,r as v,t as y}from"./notifications-wLr7xSyr.js";import{t as b}from"./useMutation-Xdq_89ou.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./select-9cx3otc_.js";import{a as D,i as O,n as k,o as A,r as j,t as M}from"./dropdown-menu-mpdg8__C.js";import{n as N,t as P}from"./entity-list-B2WXTDDM.js";import{t as F}from"./arrow-left-B1paVsKl.js";import{t as I}from"./arrow-right-Bm6j4CRT.js";import{n as L,r as R,t as z}from"./wrench-C9HmhR9v.js";import{t as B}from"./check-_AvUITNy.js";import{t as ee}from"./chevron-down-CjEG9BtO.js";import{n as te,t as ne}from"./pagination-CEYfdE0s.js";import{t as re}from"./chevron-right-BcV2-ijN.js";import{t as V}from"./eye-DyaLFyNg.js";import{t as ie}from"./file-text-BqjzSiui.js";import{t as ae}from"./layers-B6jc9X_5.js";import{t as oe}from"./plus-DewHiaw6.js";import{o as se,r as ce}from"./articles-CJ24swVV.js";import{a as le,c as ue,i as de,n as fe,o as pe,s as me,t as he}from"./app-dialog-CBRjH8y0.js";import{t as ge}from"./input-Br6N0XCJ.js";import{n as _e,t as ve}from"./react-OqyHmgtK.js";import{t as ye}from"./AnimatePresence-dRKyi9jP.js";import{n as be}from"./use-workspace-snapshot-MZKeTfAJ.js";import{t as H}from"./textarea-zbjD4aac.js";import{t as U}from"./form-field-BJITE8Lh.js";import{t as xe}from"./page-grid-BR5GG4AN.js";import"./types-D57tnOAh.js";import{t as Se}from"./tabs-DdmTx_k0.js";import{n as Ce,t as we}from"./sse-DQK6eHXZ.js";var Te=d(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Ee=d(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),De=d(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Oe=d(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ke=d(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Ae=d(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),je=d(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Me=d(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Ne=d(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Pe=d(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Fe=d(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),W={Active:`active`,Completed:`completed`,Incompatible:`incompatible`,Archived:`archived`},Ie={Running:`running`,Completed:`completed`,Interrupted:`interrupted`,Failed:`failed`},Le={ClientCancelled:`client_cancelled`,ConnectionInterrupted:`connection_interrupted`,ExecutionFailed:`execution_failed`,RuntimeRestarted:`runtime_restarted`,TurnConflict:`turn_conflict`,ProtocolMismatch:`protocol_mismatch`},G={TurnStarted:`turn.started`,TurnCompleted:`turn.completed`,TurnInterrupted:`turn.interrupted`,TurnFailed:`turn.failed`,UserMessage:`message.user`,AssistantMessage:`message.assistant`,Question:`question.proposed`,Answer:`answer.user`,ToolStarted:`tool.started`,ToolCompleted:`tool.completed`,ToolFailed:`tool.failed`,ArtifactProposed:`artifact.proposed`,ArtifactSelected:`artifact.selected`,ArtifactPreviewed:`artifact.previewed`,ArtifactConfirmed:`artifact.confirmed`},K={SingleSelect:`single_select`,MultiSelect:`multi_select`,Text:`text`,UrlList:`url_list`,Confirm:`confirm`};function Re(e){let t=[],n=[],r=/<\/?think>/gi,i=0,a=!1;for(let o of e.matchAll(r)){let r=o.index??i;(a?n:t).push(e.slice(i,r)),a=!o[0].startsWith(`</`),i=r+o[0].length}return(a?n:t).push(e.slice(i)),{message:t.join(``),thinking:n.join(`
2
+ `).trim()}}var ze=(e,t,n=1,r=20)=>s(o.api[`channel-templates`].$get({query:{channel:e,publicationType:t,page:n,pageSize:r}})),Be=(e,t,n)=>s(o.api[`channel-templates`][`:id`].versions[`:versionId`].activate.$post({param:{id:e,versionId:t},json:{revision:n}})),Ve=(e,t)=>{let r=new FormData;return r.set(`file`,e),r.set(`channel`,t.channel),r.set(`publicationType`,t.publicationType),r.set(`alt`,t.alt),n(`/api/channel-template-assets`,r)},He=e=>s(o.api[`chatbot-profiles`][`:profileId`].$get({param:{profileId:encodeURIComponent(e)}})),Ue=(e,t)=>s(o.api[`chat-sessions`].$post({json:{profileId:e,context:t}})),We=e=>s(o.api[`chat-sessions`].$get({query:{page:String(e.page??1),pageSize:String(e.pageSize??20),...e.profileId?{profileId:e.profileId}:{},...e.subjectKind?{subjectKind:e.subjectKind}:{},...e.subjectId?{subjectId:e.subjectId}:{},...e.status?{status:e.status}:{}}})),Ge=e=>s(o.api[`chat-sessions`][`:sessionId`].$get({param:{sessionId:e}})),Ke=(e,t={})=>s(o.api[`chat-sessions`][`:sessionId`].timeline.$get({param:{sessionId:e},query:{limit:String(t.limit??100),...t.beforeSequence===void 0?{}:{beforeSequence:String(t.beforeSequence)},...t.afterSequence===void 0?{}:{afterSequence:String(t.afterSequence)}}},{headers:tt()})),qe=e=>s(o.api[`chat-sessions`][`:sessionId`].$delete({param:{sessionId:e}})),Je=(e,t)=>s(o.api[`chat-sessions`][`:sessionId`].artifacts[`:artifactId`].select.$post({param:{sessionId:e,artifactId:t}}));async function Ye(e,t,n,i={}){let a=`/api/chat-sessions/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}/preview`,o=await fetch(a,{method:`POST`,signal:i.signal,headers:{Authorization:`Bearer ${r.read()}`,Accept:`text/event-stream`,"Content-Type":`application/json`},body:JSON.stringify({contentPackageId:n})});if(!o.ok)throw new f({message:await o.text()||`${o.status}`,status:o.status,statusText:o.statusText,path:a});if(!Ce(o.headers.get(`content-type`))||!o.body)throw new c(`模板预览接口没有返回实时进度流`,!0);let s;if(await we(o.body,e=>{let t=JSON.parse(e);if(t.type===`progress`)i.onProgress?.(t.progress);else if(t.type===`completed`)s=t.artifact;else throw new c(t.message,!0)}),!s)throw new c(`模板预览连接结束但没有返回结果`,!0);return{artifact:s}}var Xe=(e,t,n)=>s(o.api[`chat-sessions`][`:sessionId`].artifacts[`:artifactId`].confirm.$post({param:{sessionId:e,artifactId:t},json:n}));async function Ze(e,t){let n=new URLSearchParams({afterSequence:String(t.afterSequence??0)}),i=`/api/chat-sessions/${encodeURIComponent(e)}/events?${n}`,a=new Headers({Authorization:`Bearer ${r.read()}`,Accept:`text/event-stream`,"X-Chatbot-Protocol":`2`});t.lastEventId&&a.set(`Last-Event-ID`,t.lastEventId);let o=await fetch(i,{signal:t.signal,headers:a});if(!o.ok)throw new c(`ChatBot 活动流连接失败:${o.status}`,!0);if(!Ce(o.headers.get(`content-type`))||!o.body)throw new c(`ChatBot 活动流返回了无效响应`,!1);await we(o.body,e=>{let n=et(e);n.event.type===`persistent.event`&&t.onEvent(n.event.event)})}async function Qe(e,t,n){let i=`/api/chat-sessions/${encodeURIComponent(e)}/turns`,a=r.read(),o=await fetch(i,{method:`POST`,signal:n.signal,headers:{Authorization:`Bearer ${a}`,Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Chatbot-Protocol":`2`},body:JSON.stringify(t)});if(!o.ok){let e=await o.text()||`${o.status}`;throw new f({message:e,status:o.status,statusText:o.statusText,path:i})}if(!Ce(o.headers.get(`content-type`)))throw new c(`ChatBot 实时接口返回了无效的 Content-Type`,!1);if(!o.body)throw new c(`浏览器没有提供 ChatBot 响应流`,!1);await we(o.body,async e=>{let{event:t}=et(e);if(t.type===`stream.error`)throw await n.onEvent(t),new c(t.error.message,t.error.retryable);await n.onEvent(t)})}var $e=(e,t)=>s(o.api[`chat-sessions`][`:sessionId`].turns[`:turnId`].stop.$post({param:{sessionId:e,turnId:t}},{headers:tt()}));function et(e){let t=JSON.parse(e);if(t.protocolVersion!==2)throw new c(`ChatBot 实时协议不兼容:需要 v2`,!1);return t}function tt(){return{"X-Chatbot-Protocol":`2`}}var q=e(p(),1),nt={phase:`idle`,liveText:``,liveToolCalls:[]};function rt(e,t){if(t.type===`reset`)return nt;if(t.type===`submitting`)return{phase:`settling`,turnId:t.turnId,liveText:``,liveToolCalls:[]};let n=t.event;if(n.type===`model.started`)return{...e,phase:`receiving_model`,turnId:n.turnId,modelCallId:n.modelCallId,liveText:``,liveToolCalls:[],error:void 0};if(n.type===`model.delta`)return{...e,phase:`receiving_model`,turnId:n.turnId,modelCallId:n.modelCallId,liveText:e.liveText+n.delta};if(n.type===`tool_call.delta`){let t=`${n.modelCallId}:${n.callIndex}`,r=e.liveToolCalls.find(e=>e.key===t),i={key:t,callId:n.callId??r?.callId,name:n.name??r?.name,argumentsText:!r||n.accumulatedArguments.length>=r.argumentsText.length?n.accumulatedArguments:r.argumentsText};return{...e,phase:`receiving_tool_call`,turnId:n.turnId,modelCallId:n.modelCallId,liveToolCalls:r?e.liveToolCalls.map(e=>e.key===t?i:e):[...e.liveToolCalls,i]}}if(n.type===`model.completed`)return{...e,phase:`settling`};if(n.type===`artifact.snapshot`)return{...J(e),phase:`artifact_ready`};if(n.type===`stream.error`)return{...J(e),phase:ot(n.error.code)?`interrupted`:`failed`,error:{message:n.error.message,retryable:n.error.retryable}};if(n.type===`turn.snapshot`){let t=n.turn.status===Ie.Interrupted?`interrupted`:n.turn.status===Ie.Failed?`failed`:n.turn.outcome?.kind===`question`?`awaiting_user`:n.turn.outcome?.kind===`artifact`?`artifact_ready`:`completed`;return{...J(e),phase:t,turnId:n.turn.id}}let r=n.event;if(e.lastPersistentSequence!==void 0&&r.sequence<=e.lastPersistentSequence)return e;let i={...e,lastPersistentSequence:r.sequence};if(r.type===G.TurnStarted)return{...i,phase:`settling`,turnId:r.turnId,error:void 0};if(r.type===G.ToolStarted)return{...i,phase:`running_tool`,liveText:``,modelCallId:void 0,liveToolCalls:i.liveToolCalls.filter(e=>e.callId!==r.tool.callId)};if(r.type===G.ToolCompleted||r.type===G.ToolFailed)return{...i,phase:`settling`};if(r.type===G.AssistantMessage)return{...i,liveText:``};if(r.type===G.Question)return{...J(i),phase:`awaiting_user`};if(r.type===G.ArtifactProposed)return{...J(i),phase:`artifact_ready`};if(r.type===G.TurnCompleted){let e=r.turn.outcome?.kind===`question`?`awaiting_user`:r.turn.outcome?.kind===`artifact`?`artifact_ready`:`completed`;return{...J(i),phase:e}}return r.type===G.TurnInterrupted?{...J(i),phase:`interrupted`,error:r.turn.error?{message:r.turn.error.message,retryable:r.turn.error.retryable}:void 0}:r.type===G.TurnFailed?{...J(i),phase:`failed`,error:r.turn.error?{message:r.turn.error.message,retryable:r.turn.error.retryable}:void 0}:i}function it(e){return e===`receiving_model`||e===`receiving_tool_call`||e===`running_tool`||e===`settling`}function at(e){let t=[...e].reverse().find(e=>e.type===G.Question);if(t?.question)return e.some(e=>e.sequence>t.sequence&&(e.type===G.Answer||e.type===G.UserMessage))?void 0:{eventId:t.id,questions:t.question.questions}}function J(e){return{...e,liveText:``,liveToolCalls:[],modelCallId:void 0}}function ot(e){return e===Le.ClientCancelled||e===Le.ConnectionInterrupted||e===Le.RuntimeRestarted}var Y=h();function st({session:e,events:t,artifacts:n,viewModel:r,canLoadEarlier:a,loadingEarlier:o,onLoadEarlier:s,onSend:c,onStop:u,onRetry:d,onSelectArtifact:f,artifactWorkspace:p,composerTools:m,className:h}){let{generating:_,turn:v}=r,y=v.liveText,b=v.liveToolCalls,x=_e(),S=(0,q.useRef)(null),C=(0,q.useRef)(!0),[w,T]=(0,q.useState)(``),[E,D]=(0,q.useState)([]),[O,k]=(0,q.useState)(`chat`),A=(0,q.useMemo)(()=>ht(t),[t]),j=(0,q.useMemo)(()=>at(t),[t]),M=!!p;return(0,q.useEffect)(()=>{if(!C.current)return;let e=S.current;e&&(e.scrollTop=e.scrollHeight)},[A.length,y,j?.questions]),(0,q.useEffect)(()=>D([]),[j?.eventId]),(0,Y.jsxs)(`div`,{className:g(`grid min-h-0 h-[min(680px,calc(100dvh-150px))] overflow-hidden`,M&&`grid-rows-[auto_minmax(0,1fr)] lg:grid-cols-[minmax(300px,1fr)_minmax(0,2fr)] lg:grid-rows-1`,h),children:[M?(0,Y.jsx)(`div`,{className:`flex border-b border-[var(--border)] bg-[var(--surface)] p-1 lg:hidden`,children:[{value:`chat`,label:`对话`,icon:je},{value:`artifact`,label:`候选`,icon:Me}].map(e=>{let t=e.icon;return(0,Y.jsxs)(`button`,{type:`button`,className:g(`flex min-h-9 flex-1 items-center justify-center gap-2 rounded-[var(--radius-sm)] text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,O===e.value?`bg-[var(--surface-2)] font-medium text-[var(--ink)]`:`text-[var(--muted-strong)]`),onClick:()=>k(e.value),children:[(0,Y.jsx)(t,{className:`size-4`}),e.label]},e.value)})}):null,(0,Y.jsxs)(`section`,{className:g(`min-h-0 min-w-0 grid-rows-[minmax(0,1fr)_auto] overflow-hidden bg-[var(--surface)]`,M&&O===`artifact`?`hidden lg:grid`:`grid`),children:[(0,Y.jsx)(`div`,{ref:S,className:`scrollbar-stable min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain px-4 py-5`,onScroll:e=>{let t=e.currentTarget;C.current=t.scrollHeight-t.scrollTop-t.clientHeight<72},children:(0,Y.jsxs)(`div`,{className:`mx-auto grid min-w-0 w-full max-w-[760px] gap-5`,"aria-live":`polite`,children:[a&&s?(0,Y.jsx)(l,{variant:`ghost`,size:`sm`,className:`justify-self-center`,loading:o,onClick:s,children:`加载更早消息`}):null,A.length===0&&!y?(0,Y.jsxs)(`div`,{className:`py-12 text-center`,children:[(0,Y.jsx)(R,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-medium text-[var(--ink)]`,children:`开始描述你想要的排版`}),(0,Y.jsx)(`p`,{className:`mx-auto mt-1 max-w-[52ch] text-xs leading-5 text-[var(--muted-strong)]`,children:`可以直接说明参考公众号、内容密度、标题风格或希望调整的具体细节。`})]}):null,A.map(t=>(0,Y.jsx)(ft,{entry:t,artifacts:n,currentArtifactId:e.currentArtifactId,onSelectArtifact:e=>{f(e),k(`artifact`)}},t.key)),y||b.length||_?(0,Y.jsxs)(`div`,{className:`flex min-w-0 w-full items-start gap-3`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-[var(--surface-2)] text-[var(--muted-strong)]`,children:y?(0,Y.jsx)(R,{className:`size-3.5`}):(0,Y.jsx)(i,{className:`size-3.5 animate-spin`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 max-w-full flex-1 overflow-hidden pt-1 text-sm leading-6 text-[var(--ink)] [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(pt,{content:y,fallback:b.length?`正在准备工具调用`:`正在整理回复`}),b.map(e=>(0,Y.jsxs)(`div`,{className:`mt-3 min-w-0 max-w-full overflow-hidden border-l-2 border-[var(--border-strong)] pl-3 text-xs text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-[var(--ink)]`,children:e.name??`工具调用`}),(0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[e.argumentsText.length,` 字符`]})]}),e.argumentsText?(0,Y.jsx)(`pre`,{className:`mt-1 min-w-0 max-w-full max-h-28 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-all font-mono text-[11px] leading-5`,children:e.argumentsText}):null]},e.key))]})]}):null,(0,Y.jsx)(ye,{initial:!1,children:j?(0,Y.jsx)(ve.div,{initial:{opacity:+!!x,y:x?0:10},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:x?0:.2,ease:[.16,1,.3,1]},children:(0,Y.jsx)(lt,{questions:j.questions,value:E,disabled:_,onChange:D})},j.eventId):null})]})}),(0,Y.jsx)(ct,{value:w,pendingAnswers:E.length,generating:_,onChange:T,onSubmit:()=>{let e=w.trim();(e||E.length)&&(c({...e?{message:e}:{},...E.length?{answers:E}:{}}),T(``),D([]))},onStop:u,onRetry:d,tools:m})]}),(0,Y.jsx)(ye,{initial:!1,children:M?(0,Y.jsx)(ve.aside,{initial:{opacity:+!!x,x:x?0:24},animate:{opacity:1,x:0},transition:{duration:x?0:.24,ease:[.16,1,.3,1]},className:g(`min-h-0 min-w-0 overflow-hidden bg-[var(--surface)] lg:border-l lg:border-[var(--border)]`,O===`chat`&&`hidden lg:block`),children:p}):null})]})}function ct({value:e,pendingAnswers:t,generating:n,onChange:r,onSubmit:a,onStop:o,onRetry:s,tools:c}){return(0,Y.jsx)(`div`,{className:`min-w-0 border-t border-[var(--border)] bg-[var(--surface)] px-4 py-3`,children:(0,Y.jsxs)(`div`,{className:`mx-auto grid min-w-0 w-full max-w-[760px] gap-2`,children:[c||s&&!n?(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:c}),s&&!n?(0,Y.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-1.5 text-xs text-[var(--muted-strong)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,onClick:s,children:[(0,Y.jsx)(L,{className:`size-3.5`}),`重试上次回复`]}):null]}):null,(0,Y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Y.jsx)(H,{rows:2,value:e,disabled:n,placeholder:t?`可以补充说明后一起提交`:`输入消息`,className:`max-h-32 min-h-11 resize-none`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a())}}),n&&o?(0,Y.jsx)(u,{label:`停止生成`,onClick:o,children:(0,Y.jsx)(Pe,{className:`size-4 fill-current`})}):n?(0,Y.jsx)(u,{label:`回复正在其他页面生成`,disabled:!0,children:(0,Y.jsx)(i,{className:`size-4 animate-spin`})}):(0,Y.jsx)(u,{label:t?`提交回答`:`发送消息`,onClick:a,children:(0,Y.jsx)(se,{className:`size-4`})})]})]})})}function lt({questions:e,value:t,disabled:n,onChange:r}){let i=e=>t.find(t=>t.questionId===e)??{questionId:e},a=e=>r([...t.filter(t=>t.questionId!==e.questionId),e]);return(0,Y.jsx)(`div`,{className:`grid gap-5 border-y border-[var(--border)] py-4`,children:e.map(e=>{let t=i(e.id);return(0,Y.jsxs)(`fieldset`,{disabled:n,className:`grid gap-2.5`,children:[(0,Y.jsx)(`legend`,{className:`text-sm font-medium text-[var(--ink)]`,children:e.prompt}),e.description?(0,Y.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:e.description}):null,e.options?.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(n=>{let r=t.selectedOptionIds?.includes(n.id)??!1;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:n.description,className:g(`inline-flex min-h-9 items-center gap-2 rounded-[var(--radius-sm)] border px-3 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,r?`border-[var(--ink)] bg-[var(--ink)] text-white`:`border-[var(--border)] bg-[var(--surface)] text-[var(--ink)] hover:bg-[var(--surface-2)]`),onClick:()=>{let i=t.selectedOptionIds??[],o=e.type===K.MultiSelect?r?i.filter(e=>e!==n.id):[...i,n.id]:[n.id];a({...t,selectedOptionIds:o})},children:[r?(0,Y.jsx)(B,{className:`size-3.5`}):null,n.swatches?.length?(0,Y.jsx)(`span`,{className:`flex`,"aria-hidden":`true`,children:n.swatches.map(e=>(0,Y.jsx)(`span`,{className:`size-3 border border-white/50 first:rounded-l-sm last:rounded-r-sm`,style:{backgroundColor:e}},e))}):null,(0,Y.jsx)(`span`,{children:n.label})]},n.id)})}):null,e.type===K.Text?(0,Y.jsx)(H,{rows:2,value:t.text??``,onChange:e=>a({...t,text:e.target.value})}):null,e.type===K.UrlList?(0,Y.jsx)(H,{rows:3,value:t.urls?.join(`
3
+ `)??``,placeholder:`每行一个 URL`,onChange:e=>a({...t,urls:e.target.value.split(`
4
+ `).map(e=>e.trim()).filter(Boolean)})}):null,e.type===K.Confirm?(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[{label:`确认`,value:!0},{label:`暂不`,value:!1}].map(e=>(0,Y.jsx)(l,{variant:t.confirmed===e.value?`primary`:`secondary`,size:`sm`,onClick:()=>a({...t,confirmed:e.value}),children:e.label},String(e.value)))}):null]},e.id)})})}function ut({event:e}){let t=e.type===G.ToolFailed,n=e.type===G.ToolStarted;return(0,Y.jsxs)(`details`,{className:`group min-w-0 max-w-full overflow-hidden text-xs text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`summary`,{className:`flex min-h-8 min-w-0 cursor-pointer list-none items-center gap-2 rounded-[var(--radius-sm)] px-2 hover:bg-[var(--surface-2)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:[t?(0,Y.jsx)(De,{className:`size-3.5 text-[var(--danger)]`}):n?(0,Y.jsx)(i,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(z,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.tool?.label??e.tool?.name??`工具调用`}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0`,children:t?`失败`:n?`执行中`:`完成`}),(0,Y.jsx)(ee,{className:`size-3 shrink-0 transition-transform group-open:rotate-180`})]}),(0,Y.jsx)(`pre`,{className:`mt-1 min-w-0 max-w-full max-h-40 overflow-x-hidden overflow-y-auto border-y border-[var(--border)] px-2 py-2 text-[11px] leading-5 whitespace-pre-wrap break-all`,children:JSON.stringify(e.tool?.error??e.tool?.observation??e.tool?.inputSummary??{},null,2)})]})}function dt({artifacts:e,currentArtifactId:t,onSelect:n,children:r}){return(0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 border-b border-[var(--border)] px-5 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`h3`,{className:`shrink-0 text-sm font-semibold text-[var(--ink)]`,children:`候选版本`}),(0,Y.jsxs)(`p`,{className:`truncate text-xs text-[var(--muted-strong)]`,children:[e.length,` 个不可变候选`]})]}),(0,Y.jsxs)(C,{value:t??e.at(-1)?.id??``,onValueChange:n,children:[(0,Y.jsx)(x,{size:`sm`,"aria-label":`选择模板候选`,className:`w-[168px] max-w-[45vw] text-xs`,children:(0,Y.jsx)(w,{})}),(0,Y.jsx)(T,{position:`popper`,align:`end`,children:e.map(e=>(0,Y.jsxs)(S,{value:e.id,className:`text-xs`,children:[`候选 `,e.ordinal,` ·`,` `,e.status===`confirmed`?`已保存`:e.status===`previewed`?`已预览`:`待预览`]},e.id))})]})]}),(0,Y.jsx)(`div`,{className:`scrollbar-stable min-h-0 min-w-0 overflow-x-hidden overflow-y-auto`,children:r})]})}function ft({entry:e,artifacts:t,currentArtifactId:n,onSelectArtifact:r}){if(e.kind===`tool`)return(0,Y.jsx)(ut,{event:e.event});if(e.kind===`artifact`){let i=t.find(t=>t.id===e.event.artifactId);return i?(0,Y.jsxs)(`button`,{type:`button`,className:g(`flex w-full items-center justify-between border-y border-[var(--border)] px-2 py-3 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,i.id===n&&`bg-[var(--surface-2)]`),onClick:()=>r(i.id),children:[(0,Y.jsxs)(`span`,{className:`font-medium text-[var(--ink)]`,children:[`已生成模板候选 `,i.ordinal]}),(0,Y.jsx)(`span`,{className:`text-xs text-[var(--muted-strong)]`,children:`查看`})]}):null}let i=e.event.type===G.UserMessage||e.event.type===G.Answer,a=e.event.content??gt(e.event.answers),o=i?void 0:Re(a);return(0,Y.jsxs)(`div`,{className:g(`flex min-w-0 w-full items-start gap-3`,i&&`flex-row-reverse`),children:[(0,Y.jsx)(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-[var(--surface-2)] text-[var(--muted-strong)]`,children:i?(0,Y.jsx)(Fe,{className:`size-3.5`}):(0,Y.jsx)(R,{className:`size-3.5`})}),(0,Y.jsxs)(`div`,{className:g(`min-w-0 max-w-[82%] break-words text-sm leading-6 whitespace-pre-wrap [overflow-wrap:anywhere]`,i?`rounded-[var(--radius-sm)] bg-[var(--ink)] px-3 py-2 text-white`:`min-w-0 flex-1 pt-1 text-[var(--ink)]`),children:[o?.thinking?(0,Y.jsx)(mt,{content:o.thinking}):null,o?o.message:a]})]})}function pt({content:e,fallback:t}){let n=Re(e);return(0,Y.jsxs)(`div`,{className:`grid min-w-0 max-w-full gap-2.5 overflow-hidden [overflow-wrap:anywhere]`,children:[n.thinking?(0,Y.jsx)(mt,{content:n.thinking,live:!0}):null,(0,Y.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n.message||(n.thinking?null:t)})]})}function mt({content:e,live:t=!1}){return(0,Y.jsxs)(`div`,{className:`min-w-0 max-w-full overflow-hidden border-y border-[var(--border)] bg-[var(--surface-2)] px-3 py-2 text-xs leading-5 text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 font-medium text-[var(--ink)]`,children:[t?(0,Y.jsx)(i,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(Ee,{className:`size-3.5`}),(0,Y.jsx)(`span`,{children:`思考`})]}),(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]})}function ht(e){let t=new Map;for(let n of e)n.tool?.callId&&(n.type===G.ToolCompleted||n.type===G.ToolFailed)&&t.set(n.tool.callId,n);return e.flatMap(e=>e.type===G.UserMessage||e.type===G.AssistantMessage||e.type===G.Answer||e.type===G.TurnInterrupted?[{key:e.id,kind:`message`,event:e}]:e.type===G.ToolStarted||e.type===G.ToolCompleted||e.type===G.ToolFailed?e.type===G.ToolStarted&&t.has(e.tool?.callId??``)?[]:[{key:e.id,kind:`tool`,event:e}]:e.type===G.ArtifactProposed?[{key:e.id,kind:`artifact`,event:e}]:[])}function gt(e){return(e??[]).map(e=>e.skipped?`已跳过`:[e.selectedOptionIds?.join(`、`),e.text,e.urls?.join(`、`),e.confirmed===void 0?void 0:e.confirmed?`确认`:`暂不`].filter(Boolean).join(` · `)).filter(Boolean).join(`
5
+ `)}var _t=48,vt=class{emit;immediate;pending=Promise.resolve();constructor(e,t=()=>!1){this.emit=e,this.immediate=t}present(e){let t=this.pending.then(()=>this.deliver(e));return this.pending=t.catch(()=>void 0),t}async deliver(e){if(e.type!==`model.delta`&&e.type!==`tool_call.delta`){await this.emit(e);return}let t=bt(e.delta);if(t.length===1||this.immediate()){await this.emit(e);return}let n=0;for(let[r,i]of t.entries()){if(r>0&&this.immediate()){await this.emit(yt(e,e.delta.slice(n),e.delta.length));return}n+=i.length,await this.emit(yt(e,i,n)),r<t.length-1&&await xt()}}};function yt(e,t,n){return e.type===`model.delta`?{...e,delta:t,accumulatedCharacters:e.accumulatedCharacters-e.delta.length+n}:{...e,delta:t,accumulatedArguments:e.accumulatedArguments.slice(0,e.accumulatedArguments.length-e.delta.length)+e.delta.slice(0,n)}}function bt(e){if(e.length<=_t)return[e];let t=[];for(let n=0;n<e.length;){let r=Math.min(n+_t,e.length),i=e.charCodeAt(r-1);r<e.length&&i>=55296&&i<=56319&&--r,t.push(e.slice(n,r)),n=r}return t}function xt(){return new Promise(e=>setTimeout(e,12))}function St(e){let t=a(),[n,r]=(0,q.useReducer)(rt,nt),[i,o]=(0,q.useState)(),s=(0,q.useRef)(void 0),c=(0,q.useRef)(!1),l=e.sessionId,u=v({queryKey:[`chat-session`,l],queryFn:()=>Ge(l),enabled:!!(e.enabled&&l),refetchInterval:e=>e.state.data?.session.activeTurnId?1e3:!1,structuralSharing:(e,t)=>Tt(e,t)}),d=v({queryKey:[`chat-timeline`,l],queryFn:()=>Ke(l,{limit:200}),enabled:!!(e.enabled&&l)}),f=b({mutationFn:()=>Ke(l,{beforeSequence:d.data?.nextBeforeSequence,limit:200}),onSuccess:e=>{t.setQueryData([`chat-timeline`,l],t=>({events:wt(e.events,t?.events??[]),hasMore:e.hasMore,nextBeforeSequence:e.nextBeforeSequence}))},onError:e=>y.error(`加载更早消息失败`,e)}),p=(0,q.useCallback)(async e=>{r({type:`event`,event:e}),e.type===`persistent.event`?(t.setQueryData([`chat-timeline`,l],t=>({events:Ct(t?.events??[],e.event),hasMore:t?.hasMore??!1,nextBeforeSequence:t?.nextBeforeSequence})),(e.event.type===G.ArtifactProposed||e.event.type===G.ArtifactSelected||e.event.type===G.ArtifactPreviewed||e.event.type===G.ArtifactConfirmed||e.event.type===G.TurnCompleted||e.event.type===G.TurnInterrupted||e.event.type===G.TurnFailed)&&await t.invalidateQueries({queryKey:[`chat-session`,l]})):e.type===`artifact.snapshot`?t.setQueryData([`chat-session`,l],t=>t&&{...t,artifacts:X(t.artifacts,e.artifact)}):e.type===`turn.snapshot`&&t.setQueryData([`chat-session`,l],t=>t&&{...t,session:e.session})},[t,l]);(0,q.useEffect)(()=>{s.current?.abort(),s.current=void 0,c.current=!1,r({type:`reset`}),o(void 0)},[e.enabled,l]),(0,q.useEffect)(()=>{if(!e.enabled||!l)return;let n=new AbortController,r,i=0,a=t.getQueryData([`chat-timeline`,l])?.events.at(-1)?.sequence??0,o=async()=>{try{await Ze(l,{signal:n.signal,afterSequence:a,lastEventId:a?String(a):void 0,onEvent:e=>{a=Math.max(a,e.sequence),p({type:`persistent.event`,event:e})}})}catch{if(n.signal.aborted)return;i+=1,r=setTimeout(()=>void o(),Math.min(1e3*2**i,15e3))}};return o(),()=>{n.abort(),r&&clearTimeout(r)}},[p,e.enabled,t,l]);let m=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`chat-session`,l]}),t.invalidateQueries({queryKey:[`chat-timeline`,l]}),t.invalidateQueries({queryKey:[`chat-sessions`,e.profileId]})])},h=async(t,i=crypto.randomUUID())=>{if(!l||it(n.phase)||u.data?.session.activeTurnId)return;let a={clientTurnId:i,...t},d=new AbortController;s.current=d,c.current=!1,r({type:`submitting`});let f=new vt(async e=>await p(e),()=>e.reducedMotion||typeof document<`u`&&document.hidden);try{await Qe(l,a,{signal:d.signal,onEvent:async e=>await f.present(e)}),o(void 0),await m()}catch(e){!d.signal.aborted&&!c.current&&(o(a),y.error(`ChatBot 回复失败`,e),await m())}finally{s.current===d&&(s.current=void 0),c.current=!1}},g=u.data?.session,_=u.data?.artifacts??[],x=(0,q.useCallback)(e=>{t.setQueryData([`chat-session`,l],t=>t&&{...t,artifacts:X(t.artifacts,e)})},[t,l]);return{detail:u,timeline:d,loadEarlier:f,session:g,artifacts:_,currentArtifact:_.find(e=>e.id===g?.currentArtifactId)??_.at(-1),turnState:n,generating:it(n.phase)||!!g?.activeTurnId,retryable:!!i,send:h,stop:async()=>{let e=s.current,t=n.turnId??g?.activeTurnId;c.current=!0;try{l&&t&&await $e(l,t)}catch(e){y.error(`停止 ChatBot 回复失败`,e)}finally{e?.abort()}},retry:i?()=>{let{clientTurnId:e,...t}=i;return h(t,e)}:void 0,cacheArtifact:x,refresh:m}}function Ct(e,t){return e.some(e=>e.id===t.id||e.sequence===t.sequence)?e:[...e,t].sort((e,t)=>e.sequence-t.sequence)}function wt(e,t){let n=new Map;for(let r of[...e,...t])n.set(r.id,r);return[...n.values()].sort((e,t)=>e.sequence-t.sequence)}function X(e,t){let n=e.find(e=>e.id===t.id);if(n&&n.updatedAt>t.updatedAt)return e;let r=Et(n,t),i=r.length?{...t,preview:t.preview??r.at(-1),previews:r}:t;return[...e.filter(e=>e.id!==t.id),i].sort((e,t)=>e.ordinal-t.ordinal)}function Tt(e,t){if(!e)return t;let n=t.artifacts.reduce((e,t)=>X(e,t),e.artifacts);return{session:e.session.revision>t.session.revision?e.session:t.session,artifacts:n}}function Et(e,t){let n=new Map;for(let r of[e,t])if(r)for(let e of[...r.previews??[],...r.preview?[r.preview]:[]])n.set(e.id??e.receipt,e);return[...n.values()]}function Dt({disabled:e,onSelect:t}){return(0,Y.jsxs)(M,{children:[(0,Y.jsx)(A,{asChild:!0,children:(0,Y.jsxs)(l,{variant:`primary`,disabled:e,children:[(0,Y.jsx)(oe,{className:`size-4`}),`制作模板`]})}),(0,Y.jsxs)(k,{align:`end`,className:`w-72`,children:[(0,Y.jsx)(O,{children:`选择制作方式`}),(0,Y.jsx)(D,{}),(0,Y.jsxs)(j,{className:`items-start py-2.5`,onSelect:()=>t(`history`),children:[(0,Y.jsx)(ke,{className:`mt-0.5 size-4`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block text-sm font-medium`,children:`参考公众号`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-[var(--muted-strong)]`,children:`研究公众号和代表文章的历史排版。`})]})]}),(0,Y.jsxs)(j,{className:`items-start py-2.5`,onSelect:()=>t(`consultation`),children:[(0,Y.jsx)(je,{className:`mt-0.5 size-4`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block text-sm font-medium`,children:`咨询排版风格`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-[var(--muted-strong)]`,children:`通过自由对话逐步确定视觉方向。`})]})]})]})]})}function Ot(){return(0,Y.jsx)(`div`,{className:`grid h-full min-h-0 place-items-center bg-[var(--surface-2)] p-6 text-center`,children:(0,Y.jsxs)(`div`,{className:`max-w-[38ch]`,children:[(0,Y.jsx)(ae,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-medium text-[var(--ink)]`,children:`候选与预览会显示在这里`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:`在左侧说明排版方向。Agent 提交首个候选后,右侧可以切换版本、生成手机预览并保存模板。`})]})})}function kt({channel:e,publicationType:t,disabled:n,onUploaded:r}){let i=(0,q.useRef)(null),a=b({mutationFn:n=>Ve(n,{channel:e,publicationType:t,alt:n.name.replace(/\.[^.]+$/,``).trim()||`模板固定素材`}),onSuccess:({asset:e})=>{y.success(`固定素材已上传`,`资源信息已发送给模板 Agent。`),r(e)},onError:e=>y.error(`上传固定素材失败`,e)});return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{ref:i,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`sr-only`,tabIndex:-1,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&a.mutate(t)}}),(0,Y.jsxs)(l,{type:`button`,variant:`ghost`,size:`sm`,loading:a.isPending,disabled:n,title:`上传背景、纹理或装饰图片,最大 10MB`,onClick:()=>i.current?.click(),children:[a.isPending?null:(0,Y.jsx)(Ae,{className:`size-3.5`}),`上传固定素材`]}),(0,Y.jsx)(`span`,{className:`hidden truncate text-[11px] text-[var(--muted-strong)] sm:inline`,children:`PNG / JPEG / GIF / WebP,最大 10MB`})]})}function At({session:e,template:t,artifacts:n,artifact:r,onSelect:a,onChanged:o,onArtifactUpdated:s,onSaved:c}){let[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1),[g,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(`正在启动微信排版 Agent`),[w,T]=(0,q.useState)(t?.name??``),[D,O]=(0,q.useState)(t?.description??``),[k,A]=(0,q.useState)(()=>Q(Z(r).at(-1))??``),j=v({queryKey:[`content-packages`,`chat-template-preview`],queryFn:()=>ce(1,100)}),M=b({mutationFn:t=>Ye(e.id,r.id,t,{onProgress:e=>C(e.label)}),onMutate:e=>{d(!1),A(`pending:${e}`),C(`正在启动微信排版 Agent`)},onSuccess:({artifact:e})=>{s(e);let t=Z(e).at(-1);t&&A(Q(t)??``),y.success(`模板预览已生成`,`可以在候选的预览结果中查看。`),o().catch(e=>y.error(`刷新预览列表失败`,e))},onError:e=>{A(Q(Z(r).at(-1))??``),y.error(`模板预览失败`,e)}}),N=M.data?.artifact,P=N?X([r],N)[0]??r:r,F=Z(P),I=F.find(e=>Q(e)===k)??F.at(-1),L=!I||Date.parse(I.expiresAt)<=Date.now();(0,q.useEffect)(()=>{if(M.isPending)return;let e=F.at(-1);e&&!F.some(e=>Q(e)===k)&&A(Q(e)??``)},[M.isPending,F,k]);let R=b({mutationFn:()=>Xe(e.id,r.id,{receipt:I.receipt,name:t?.name??w,description:D||void 0,templateId:t?.id,revision:t?.revision}),onSuccess:async()=>{h(!1),await o(),await c(),y.success(`模板版本已保存`,`保存不会自动激活,可以继续对话优化。`)},onError:e=>y.error(`保存模板版本失败`,e)}),z=(I?.result)?.content?.html,B=r.payload.outputMode===`prompt_with_dsl`?`prompt_with_dsl`:`prompt_only`;return(0,Y.jsxs)(dt,{artifacts:n,currentArtifactId:r.id,onSelect:a,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`section`,{className:`border-b border-[var(--border)]`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start justify-between gap-4 px-5 py-3`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`候选定义`}),(0,Y.jsx)(_,{tone:B===`prompt_with_dsl`?`accent`:`info`,children:B===`prompt_with_dsl`?`固定 DSL`:`动态 HTML`})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 max-w-[90ch] text-xs leading-5 text-[var(--muted-strong)]`,children:typeof r.payload.designSummary==`string`?r.payload.designSummary:``})]})}),(0,Y.jsxs)(`div`,{className:B===`prompt_with_dsl`?`grid border-t border-[var(--border)] lg:grid-cols-2 lg:divide-x lg:divide-[var(--border)]`:`border-t border-[var(--border)]`,children:[(0,Y.jsxs)(`section`,{className:`min-w-0 px-5 py-3`,children:[(0,Y.jsxs)(`h5`,{className:`flex items-center gap-2 text-xs font-semibold text-[var(--ink)]`,children:[(0,Y.jsx)(ie,{className:`size-3.5 text-[var(--muted-strong)]`}),`排版提示词`]}),(0,Y.jsx)(`pre`,{className:`mt-2 h-64 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words text-xs leading-5 text-[var(--muted-strong)] [overflow-wrap:anywhere]`,children:typeof r.payload.prompt==`string`?r.payload.prompt:``})]}),B===`prompt_with_dsl`?(0,Y.jsxs)(`section`,{className:`min-w-0 border-t border-[var(--border)] px-5 py-3 lg:border-t-0`,children:[(0,Y.jsxs)(`h5`,{className:`flex items-center gap-2 text-xs font-semibold text-[var(--ink)]`,children:[(0,Y.jsx)(Te,{className:`size-3.5 text-[var(--accent)]`}),`微信布局 DSL`]}),(0,Y.jsx)(`pre`,{className:`mt-2 max-h-44 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-all font-mono text-[11px] leading-5 text-[var(--muted-strong)]`,children:JSON.stringify(r.payload.dsl??{},null,2)})]}):null]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 border-b border-[var(--border)] px-5 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`预览结果`}),(0,Y.jsxs)(`p`,{className:`truncate text-xs text-[var(--muted-strong)]`,children:[F.length,` 条已完成记录`]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[r.status!==`confirmed`&&I?(0,Y.jsxs)(l,{variant:`ghost`,size:`sm`,disabled:L,title:L?`最新预览回执已过期,请重新生成预览`:void 0,onClick:()=>h(!0),children:[(0,Y.jsx)(Ne,{className:`size-3.5`}),`保存模板`]}):null,(0,Y.jsxs)(l,{variant:`secondary`,size:`sm`,loading:M.isPending,disabled:M.isPending,onClick:()=>d(!0),children:[M.isPending?null:(0,Y.jsx)(V,{className:`size-3.5`}),M.isPending?`生成中`:`生成预览`]})]})]}),(0,Y.jsxs)(`div`,{className:`border-b border-[var(--border)]`,children:[M.isPending?(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5 px-5 py-2.5 text-sm`,children:[(0,Y.jsx)(i,{className:`size-4 shrink-0 animate-spin text-[var(--accent)]`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`truncate font-medium text-[var(--ink)]`,children:Mt(j.data?.items,M.variables)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-strong)]`,role:`status`,"aria-live":`polite`,children:S})]}),(0,Y.jsx)(_,{tone:`info`,children:`生成中`})]}):null,[...F].reverse().map((e,t)=>{let n=Q(e),r=Date.parse(e.expiresAt)<=Date.now();return(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-w-0 w-full items-center gap-2.5 border-t border-[var(--border)] bg-[var(--surface)] px-5 py-2.5 text-left transition-colors first:border-t-0 hover:bg-[var(--surface-2)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,onClick:()=>{A(n),p(!0)},children:[(0,Y.jsx)(V,{className:`size-4 shrink-0 text-[var(--muted)]`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-[var(--ink)]`,children:Mt(j.data?.items,e.contentPackageId)}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block text-xs text-[var(--muted-strong)]`,children:[jt(e,P),` · 手机端文章预览`]})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-[var(--muted-strong)]`,children:r?`回执过期`:t===0?`最新`:`已完成`}),(0,Y.jsx)(re,{className:`size-3.5 shrink-0 text-[var(--muted)]`})]},n)}),!M.isPending&&F.length===0?(0,Y.jsxs)(`div`,{className:`px-5 py-8 text-center`,children:[(0,Y.jsx)(V,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--ink)]`,children:`还没有预览结果`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:`点击“生成预览”,选择一篇真实内容进行检查。`})]}):null]})]}),(0,Y.jsx)(de,{open:f,onOpenChange:p,children:(0,Y.jsxs)(pe,{showCloseButton:!1,className:`grid h-[min(780px,calc(100dvh-32px))] w-[min(410px,calc(100vw-24px))] max-w-[410px] grid-rows-[44px_minmax(0,1fr)] gap-0 overflow-hidden rounded-[20px] border border-[var(--border-strong)] bg-white p-0 shadow-[0_18px_52px_rgba(20,20,24,0.20)] sm:max-w-[410px]`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-[36px_minmax(0,1fr)_36px] items-center border-b border-[#e7e7e7] px-2 text-[#181818]`,children:[(0,Y.jsx)(le,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,className:`grid size-8 place-items-center rounded-[var(--radius-sm)] transition-colors hover:bg-[#f4f4f4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:(0,Y.jsx)(te,{className:`size-5`})})}),(0,Y.jsx)(ue,{className:`truncate text-center text-sm font-semibold leading-5`,children:`公众号文章`}),(0,Y.jsx)(Oe,{className:`size-5 justify-self-center`,"aria-hidden":`true`}),(0,Y.jsx)(me,{className:`sr-only`,children:I?Mt(j.data?.items,I.contentPackageId):`微信文章手机端预览`})]}),I&&z?(0,Y.jsx)(`iframe`,{title:`微信文章手机端预览`,sandbox:``,srcDoc:`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"></head><body style="margin:16px;background:#fff">${z}</body></html>`,className:`min-h-0 size-full bg-white`}):(0,Y.jsx)(`div`,{className:`grid min-h-0 place-items-center px-6 text-center text-sm text-[var(--muted-strong)]`,children:`当前预览没有可展示的 HTML`})]})}),(0,Y.jsxs)(he,{open:m,onOpenChange:h,title:`保存模板版本`,description:`保存当前候选,不会自动激活,也不会修改已经存在的模板版本。`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[t?null:(0,Y.jsx)(U,{label:`模板名称`,required:!0,children:(0,Y.jsx)(ge,{value:w,onChange:e=>T(e.target.value)})}),(0,Y.jsx)(U,{label:`说明`,children:(0,Y.jsx)(ge,{value:D,onChange:e=>O(e.target.value)})})]}),(0,Y.jsxs)(fe,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(l,{variant:`secondary`,onClick:()=>h(!1),children:`取消`}),(0,Y.jsx)(l,{variant:`primary`,disabled:L||!t&&!w.trim(),loading:R.isPending,onClick:()=>R.mutate(),children:`保存为模板版本`})]})]})]}),(0,Y.jsxs)(he,{open:u,onOpenChange:d,title:`生成模板预览`,description:`选择一篇真实内容,生成微信手机端文章预览。`,children:[(0,Y.jsx)(U,{label:`真实内容包`,required:!0,children:(0,Y.jsxs)(E,{value:g,onChange:e=>x(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`请选择内容包`}),j.data?.items.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.contentPackage.document.title},e.id))]})}),(0,Y.jsxs)(fe,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(l,{variant:`secondary`,onClick:()=>d(!1),children:`取消`}),(0,Y.jsx)(l,{variant:`primary`,disabled:!g,onClick:()=>M.mutate(g),children:`生成预览`})]})]})]})}function Z(e){let t=e.previews??[];return!e.preview||t.some(t=>t.receipt===e.preview?.receipt)?t:[...t,e.preview]}function Q(e){return e?.id??(e?`legacy:${e.receipt}`:void 0)}function jt(e,t){return new Date(e.createdAt??t.updatedAt).toLocaleString(`zh-CN`)}function Mt(e,t){return t?e?.find(e=>e.id===t)?.contentPackage.document.title??t:`未知内容包`}var Nt=20,$=`channel-template-authoring/weixin/article`,Pt={chat:`对话模型`,"source-search":`搜索连接`,"source-fetch":`网页抓取`,image:`图片生成`,"image-generation":`图片生成`};function Ft({channel:e,publicationType:t,page:n,onPageChange:r,onPublicationTypeChange:i}){let{data:o}=be({live:!1}),s=a(),c=m(),u=v({queryKey:[`channel-templates`,e,t,n],queryFn:()=>ze(e,t,n,Nt)}),d=v({queryKey:[`chatbot-profile`,$],queryFn:()=>He($)}),f=v({queryKey:[`chat-sessions`,$,`recent`],queryFn:()=>We({profileId:$,subjectKind:`channel-template`,page:1,pageSize:20})}),p=o?.publicationTypeProfiles.find(n=>n.channel===e&&n.type===t),h=o?.channelDefinitions.find(t=>t.id===e),g=(o?.publicationTypeProfiles??[]).filter(t=>t.channel===e&&t.layout),x=b({mutationFn:e=>Be(e.templateId,e.versionId,e.revision),onSuccess:async()=>{await s.invalidateQueries({queryKey:[`channel-templates`,e]}),await s.invalidateQueries({queryKey:[`workspace`]}),y.success(`模板版本已激活`,`账号选择激活版本时会使用该版本。`)},onError:e=>y.error(`激活模板失败`,e)}),S=r=>c({to:`/publishing/templates/sessions/$sessionId`,params:{sessionId:r},search:{channel:e,publicationType:t,page:n}}),C=b({mutationFn:e=>Ue($,{method:e.method,...e.templateId?{templateId:e.templateId}:{}}),onSuccess:async({session:e})=>{await s.invalidateQueries({queryKey:[`chat-sessions`,$]}),await S(e.id)},onError:e=>y.error(`创建模板对话失败`,e)}),w=b({mutationFn:qe,onSuccess:async()=>{await s.invalidateQueries({queryKey:[`chat-sessions`,$]}),y.success(`制作会话已删除`)},onError:e=>y.error(`删除制作会话失败`,e)});return(0,Y.jsxs)(xe,{children:[g.length>1?(0,Y.jsx)(Se,{value:t,onChange:i,items:g.map(e=>({value:e.type,label:e.name})),className:`justify-self-start`}):null,d.data&&!d.data.ready?(0,Y.jsxs)(`section`,{role:`status`,className:`flex flex-wrap items-center justify-between gap-3 rounded-[var(--radius)] border border-[var(--warning-border)] bg-[var(--warning-bg)] px-4 py-3.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Y.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-[var(--warning)]`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`配置所需连接后即可开始制作模板`}),(0,Y.jsxs)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:[`当前还缺少:`,d.data.missingCapabilities.map(e=>Pt[e]??e).join(`、`),`。完成配置后,“制作模板”按钮将自动可用。`]})]})]}),(0,Y.jsxs)(l,{variant:`secondary`,size:`sm`,onClick:()=>void c({to:`/connections`,search:{page:1}}),children:[`前往连接配置`,(0,Y.jsx)(I,{className:`size-3.5`})]})]}):null,o&&!p?.layout?(0,Y.jsx)(`p`,{className:`py-8 text-sm text-[var(--muted-strong)]`,children:`该渠道没有可配置的排版模板。`}):(0,Y.jsx)(P,{title:`${h?.name??e} · ${p?.name??t}排版模板`,description:`模板版本不可变;账号和内容方案可默认跟随激活版本,也可按需锁定具体版本。`,compact:!0,summary:`共 ${u.data?.total??0} 个模板`,action:(0,Y.jsx)(Dt,{disabled:!d.data?.ready||C.isPending,onSelect:e=>C.mutate({method:e})}),empty:!u.data?.items.length,emptyTitle:`还没有渠道模板`,emptyDescription:`通过多轮对话研究历史排版或咨询风格,再预览并保存模板。`,pagination:(0,Y.jsx)(ne,{page:n,pageSize:Nt,total:u.data?.total??0,onChange:r}),children:u.data?.items.map(e=>{let t=e.versions.find(t=>t.id===e.activeVersionId),n=e.versions.at(-1);return(0,Y.jsxs)(N,{title:e.name,description:`${e.versions.length} 个不可变版本 · ${t?`已激活 v${t.version}`:`尚未激活`}`,status:e.enabled?`ready`:`disabled`,meta:n?(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(_,{tone:Lt(n.artifact)===`prompt_with_dsl`?`accent`:`info`,children:Lt(n.artifact)===`prompt_with_dsl`?`固定 DSL`:`动态 HTML`}),(0,Y.jsxs)(_,{children:[`最新 v`,n.version]})]}):void 0,children:[n&&n.id!==e.activeVersionId?(0,Y.jsxs)(l,{variant:`ghost`,loading:x.isPending,onClick:()=>x.mutate({templateId:e.id,versionId:n.id,revision:e.revision}),children:[(0,Y.jsx)(B,{className:`size-4`}),`激活 v`,n.version]}):null,(0,Y.jsx)(l,{variant:`ghost`,loading:C.isPending&&C.variables?.templateId===e.id,onClick:()=>C.mutate({method:`consultation`,templateId:e.id}),children:`继续优化`})]},e.id)})}),(0,Y.jsx)(P,{title:`制作会话`,description:`打开进行中或历史会话会进入独立制作页面,对话和预览互不挤占。`,compact:!0,summary:`最近 ${f.data?.items.length??0} 个会话`,empty:!f.data?.items.length,emptyTitle:`还没有制作会话`,emptyDescription:`从“制作模板”选择参考公众号或风格咨询后,会话会保留在这里。`,children:f.data?.items.map(e=>{let t=o?.channelTemplates.find(t=>t.id===e.subject.id);return(0,Y.jsx)(N,{title:t?`${t.name} · ${e.title}`:e.title,description:`${Rt(e.status)} · ${new Date(e.updatedAt).toLocaleString(`zh-CN`)}`,status:e.status===W.Incompatible?`warning`:`ready`,meta:e.currentArtifactId?(0,Y.jsx)(_,{children:`已有候选`}):void 0,onOpen:()=>void S(e.id),onDelete:()=>w.mutateAsync(e.id),deleteDescription:`只删除这次制作对话,不影响已经确认保存的模板版本。`,children:(0,Y.jsx)(l,{variant:`ghost`,onClick:()=>void S(e.id),children:`打开`})},e.id)})})]})}function It({sessionId:e,channel:n,publicationType:r,onBack:i}){let o=a(),s=_e(),{data:c}=be({live:!1}),u=St({sessionId:e,enabled:!0,profileId:$,reducedMotion:!!s}),{timeline:d,loadEarlier:f,session:p,artifacts:m,currentArtifact:h}=u,g=c?.channelTemplates.find(e=>e.id===p?.subject.id),v=typeof p?.context.channel==`string`?p.context.channel:n,y=typeof p?.context.publicationType==`string`?p.context.publicationType:r;return u.detail.error||d.error?(0,Y.jsx)(`section`,{className:`grid min-h-80 place-items-center rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-6 text-center`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`无法打开模板制作会话`}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-[60ch] text-sm text-[var(--muted-strong)]`,children:t(u.detail.error??d.error)}),(0,Y.jsxs)(l,{variant:`secondary`,className:`mt-4`,onClick:i,children:[(0,Y.jsx)(F,{className:`size-4`}),`返回模板列表`]})]})}):!p||!d.data?(0,Y.jsx)(`div`,{className:`grid min-h-[520px] place-items-center rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] text-sm text-[var(--muted-strong)]`,children:`正在恢复制作会话`}):(0,Y.jsxs)(`section`,{className:`grid h-[calc(100dvh-8.75rem)] min-h-[520px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:i,children:[(0,Y.jsx)(F,{className:`size-4`}),`返回模板列表`]}),(0,Y.jsx)(`span`,{className:`hidden h-4 w-px bg-[var(--border)] sm:block`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`hidden min-w-0 truncate text-sm font-medium text-[var(--ink)] sm:block`,children:g?.name?`${g.name} · ${p.title}`:p.title})]}),(0,Y.jsx)(_,{tone:u.generating?`info`:`neutral`,children:u.generating?`正在生成`:Rt(p.status)})]}),(0,Y.jsx)(`div`,{className:`min-h-0`,children:(0,Y.jsx)(st,{session:p,events:d.data.events,artifacts:m,className:`h-full`,viewModel:{turn:u.turnState,generating:u.generating},canLoadEarlier:d.data.hasMore,loadingEarlier:f.isPending,onLoadEarlier:()=>f.mutate(),onSend:e=>void u.send(e),onStop:u.generating?u.stop:void 0,onRetry:u.retry?()=>void u.retry?.():void 0,onSelectArtifact:e=>{Je(p.id,e).then(u.refresh)},composerTools:(0,Y.jsx)(kt,{channel:v,publicationType:y,disabled:u.generating,onUploaded:e=>u.send({message:[`我上传了一个固定模板图片资源。请结合当前要求将它用于下一版固定 DSL 候选。`,`如果尚未确认固定 DSL 模式,请先实际询问是否切换;不要把资源字节写入候选。`,`资源元数据(可直接写入 DSL assets):${JSON.stringify(e)}`].join(`
6
+ `)})}),artifactWorkspace:h?(0,Y.jsx)(At,{session:p,template:g,artifacts:m,artifact:h,onSelect:e=>void Je(p.id,e).then(u.refresh),onChanged:u.refresh,onArtifactUpdated:u.cacheArtifact,onSaved:async()=>{await o.invalidateQueries({queryKey:[`channel-templates`,v]}),await o.invalidateQueries({queryKey:[`workspace`]})}},h.id):(0,Y.jsx)(Ot,{})})})]})}function Lt(e){return e&&typeof e==`object`&&!Array.isArray(e)&&e.outputMode===`prompt_with_dsl`?`prompt_with_dsl`:`prompt_only`}function Rt(e){return e===W.Completed?`已保存,可继续优化`:e===W.Incompatible?`版本不可继续`:e===W.Archived?`已归档`:`制作中`}export{Ft as n,It as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{dn as t,ln as n,nn as r}from"./index-Bx1uywm3.js";import{n as i}from"./notifications-wLr7xSyr.js";import{n as a,r as o,t as s}from"./-run-presentation-e-aAMUOA.js";var c=e(t(),1),l=n();function u({document:e,assets:t,evidence:n,materials:r}){let i={assets:new Map(t.map(e=>[e.id,e])),evidence:new Map(n.map(e=>[e.id,e])),materials:new Map(r.map(e=>[e.id,e]))};return(0,l.jsx)(`article`,{className:`mx-auto grid w-full max-w-3xl gap-5 text-[15px] leading-7 text-[var(--ink-2)]`,children:e.root.children.map(e=>d(e,i))})}function d(e,t){switch(e.type){case`heading`:{let n=Math.min(6,Math.max(1,Math.trunc(e.depth))),r=n<=2?`mt-4 text-xl font-semibold tracking-[-0.015em] text-[var(--ink)] first:mt-0`:`mt-2 text-base font-semibold text-[var(--ink)] first:mt-0`;return(0,c.createElement)(`h${n}`,{key:e.id,className:r},p(e.children,t))}case`paragraph`:return f(e,t);case`blockquote`:return(0,l.jsx)(`blockquote`,{className:`grid gap-3 border-l-2 border-[var(--border-strong)] pl-4 text-[var(--muted-strong)]`,children:e.children.map(e=>d(e,t))},e.id);case`list`:{let n=e.ordered?`ol`:`ul`;return(0,l.jsx)(n,{start:e.ordered?e.start:void 0,className:e.ordered?`grid list-decimal gap-2 pl-6`:`grid list-disc gap-2 pl-6`,children:e.items.map(e=>(0,l.jsx)(`li`,{className:`pl-1`,children:(0,l.jsxs)(`div`,{className:`grid gap-2`,children:[e.checked===void 0?null:(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-xs text-[var(--muted)]`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:e.checked,readOnly:!0,disabled:!0}),e.checked?`已完成`:`未完成`]}),e.children.map(e=>d(e,t))]})},e.id))},e.id)}case`code`:return(0,l.jsx)(`pre`,{className:`overflow-x-auto rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] p-4 font-mono text-[13px] leading-6 text-[var(--ink)]`,children:(0,l.jsx)(`code`,{children:e.text})},e.id);case`table`:return(0,l.jsx)(`div`,{className:`overflow-x-auto border border-[var(--border)]`,children:(0,l.jsxs)(`table`,{className:`w-full border-collapse text-left text-sm`,children:[(0,l.jsx)(`thead`,{className:`bg-[var(--surface-2)] text-[var(--ink)]`,children:(0,l.jsx)(`tr`,{children:e.header.map((n,r)=>(0,l.jsx)(`th`,{className:`border-b border-r border-[var(--border)] px-3 py-2 font-semibold last:border-r-0`,style:{textAlign:e.align[r]??void 0},children:p(n,t)},`${e.id}:header:${r}`))})}),(0,l.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,l.jsx)(`tr`,{children:n.map((n,i)=>(0,l.jsx)(`td`,{className:`border-b border-r border-[var(--border)] px-3 py-2 align-top last:border-r-0`,style:{textAlign:e.align[i]??void 0},children:p(n,t)},`${e.id}:row:${r}:cell:${i}`))},`${e.id}:row:${r}`))})]})},e.id);case`html`:return(0,l.jsx)(b,{label:`文档包含不受支持的原始 HTML`},e.id);case`thematic-break`:return(0,l.jsx)(`hr`,{className:`my-2 border-0 border-t border-[var(--border)]`},e.id);default:return w(e)}}function f(e,t){let n=e.children.length===1?e.children[0]:void 0;return n?.type===`asset`?v(n,t):(0,l.jsx)(`p`,{className:`m-0`,children:p(e.children,t)},e.id)}function p(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=h(e,r,t);i?(n.push(...i.nodes),r+=i.consumed-1):n.push(m(e[r],t))}return n}function m(e,t){switch(e.type){case`text`:return g(e.text);case`emphasis`:return(0,l.jsx)(`em`,{children:p(e.children,t)},e.id);case`strong`:return(0,l.jsx)(`strong`,{className:`font-semibold text-[var(--ink)]`,children:p(e.children,t)},e.id);case`strikethrough`:return(0,l.jsx)(`s`,{children:p(e.children,t)},e.id);case`inline-code`:return(0,l.jsx)(`code`,{className:`rounded bg-[var(--surface-3)] px-1.5 py-0.5 font-mono text-[0.88em] text-[var(--ink)]`,children:e.text},e.id);case`link`:return x(e.href)?(0,l.jsx)(`a`,{href:e.href,title:e.title,target:`_blank`,rel:`noreferrer`,className:`text-[var(--info)] underline decoration-[var(--info-border)] underline-offset-2`,children:p(e.children,t)},e.id):(0,l.jsx)(`span`,{children:p(e.children,t)},e.id);case`citation`:return _(e,t);case`remote-image`:return(0,l.jsx)(b,{label:`文档包含未入库的远程图片`},e.id);case`line-break`:return(0,l.jsx)(`br`,{},e.id);case`asset`:return y(e,t);default:return w(e)}}function h(e,t,n){let r=e[t],i=e[t+1],a=e[t+2];if(r?.type!==`text`||i?.type!==`strong`||a?.type!==`text`)return null;let o=r.text.lastIndexOf(`**`),s=a.text.indexOf(`**`);return o<0||s<1?null:{consumed:3,nodes:[g(r.text.slice(0,o)),(0,l.jsx)(`strong`,{className:`font-semibold text-[var(--ink)]`,children:g(r.text.slice(o+2))},`${r.id}:repaired`),...p(i.children,n),(0,l.jsx)(`strong`,{className:`font-semibold text-[var(--ink)]`,children:g(a.text.slice(0,s))},`${a.id}:repaired`),g(a.text.slice(s+2))]}}function g(e){return e.replace(/&(?:#x[\da-f]+|#\d+|amp|apos|quot|lt|gt|nbsp);/gi,e=>{let t={"&amp;":`&`,"&apos;":`'`,"&quot;":`"`,"&lt;":`<`,"&gt;":`>`,"&nbsp;":` `},n=e.toLowerCase();if(n in t)return t[n];let r=n.match(/^&#x([\da-f]+);$/i)?.[1],i=n.match(/^&#(\d+);$/)?.[1],a=Number.parseInt(r??i??``,r?16:10);return Number.isSafeInteger(a)&&a>=0&&a<=1114111?String.fromCodePoint(a):e})}function _(e,t){let n=t.evidence.get(e.evidenceId),r=n?t.materials.get(n.materialId):void 0;return r?.sourceUrl&&x(r.sourceUrl)?(0,l.jsx)(`a`,{href:r.sourceUrl,title:r.title,target:`_blank`,rel:`noreferrer`,className:`ml-0.5 text-xs font-medium text-[var(--info)] underline decoration-[var(--info-border)] underline-offset-2`,children:e.label},e.id):(0,l.jsx)(`span`,{title:n?`来源没有公开链接`:`证据缺失:${e.evidenceId}`,className:`ml-0.5 text-xs font-medium text-[var(--warning)]`,children:e.label},e.id)}function v(e,t){let n=t.assets.get(e.assetId);return n?n.mediaType===`image`?S(n.source.uri)?(0,l.jsxs)(`figure`,{className:`grid gap-2`,children:[(0,l.jsx)(`img`,{src:n.source.uri,alt:e.alt||n.alt||``,title:e.title,className:`max-h-[520px] w-full rounded-[var(--radius-sm)] border border-[var(--border)] object-contain`}),e.caption||n.caption?(0,l.jsx)(`figcaption`,{className:`text-center text-xs leading-5 text-[var(--muted)]`,children:e.caption??n.caption}):null]},e.id):(0,l.jsx)(b,{label:`图片地址无效:${e.assetId}`},e.id):y(e,t):(0,l.jsx)(b,{label:`资源缺失:${e.assetId}`},e.id)}function y(e,t){let n=t.assets.get(e.assetId);return n?n.mediaType===`image`?S(n.source.uri)?(0,l.jsx)(`img`,{src:n.source.uri,alt:e.alt||n.alt||``,title:e.title,className:`mx-1 inline-block max-h-40 max-w-full align-middle`},e.id):(0,l.jsx)(b,{label:`图片地址无效:${e.assetId}`},e.id):C(n.source.uri)?n.mediaType===`video`?(0,l.jsx)(`video`,{src:n.source.uri,controls:!0,className:`my-3 max-h-[520px] w-full`},e.id):n.mediaType===`audio`?(0,l.jsx)(`audio`,{src:n.source.uri,controls:!0,className:`my-3 w-full`},e.id):(0,l.jsx)(`a`,{href:n.source.uri,target:`_blank`,rel:`noreferrer`,className:`text-[var(--info)] underline decoration-[var(--info-border)] underline-offset-2`,children:e.caption||e.title||n.title||e.alt||`查看附件`},e.id):(0,l.jsx)(b,{label:`资源地址无效:${e.assetId}`},e.id):(0,l.jsx)(b,{label:`资源缺失:${e.assetId}`},e.id)}function b({label:e}){return(0,l.jsx)(`span`,{className:`inline-flex border border-[var(--warning-border)] bg-[var(--warning-bg)] px-2 py-1 text-xs text-[var(--warning)]`,children:e})}function x(e){return/^(https?:|mailto:|tel:)/i.test(e.trim())||e.trim().startsWith(`#`)}function S(e){return/^(https?:|data:image\/)/i.test(e.trim())}function C(e){return/^https?:/i.test(e.trim())}function w(e){throw Error(`不支持的文章节点 ${e.type??`unknown`}`)}function T({value:e,generationRun:t,generationRunPending:n=!1}){return(0,l.jsxs)(`div`,{className:`grid gap-5`,children:[(0,l.jsx)(`p`,{className:`text-sm leading-6 text-[var(--muted-strong)]`,children:e.contentPackage.document.digest}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(i,{tone:`success`,children:`可发布内容包`}),(0,l.jsxs)(i,{children:[e.contentPackage.evidence.length,` 条证据`]}),(0,l.jsxs)(i,{children:[e.contentPackage.assets.length,` 个资源`]}),(0,l.jsxs)(i,{children:[e.contentPackage.materials.length,` 个来源`]})]}),(0,l.jsxs)(`dl`,{className:`divide-y divide-[var(--border)] border-y border-[var(--border)] text-sm`,children:[(0,l.jsx)(E,{label:`生成运行`,value:t?(0,l.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,l.jsx)(r,{to:`/jobs/$runId`,params:{runId:t.id},className:`font-medium text-[var(--info)] underline decoration-[var(--info-border)] underline-offset-2`,children:s(t)}),(0,l.jsx)(i,{tone:o(t.status),children:a(t.status)})]}):n?(0,l.jsx)(`span`,{className:`text-[var(--muted)]`,children:`正在关联生成运行…`}):(0,l.jsx)(`span`,{className:`text-[var(--muted)]`,children:`历史内容包,生成运行不可用`})}),(0,l.jsx)(E,{label:`内容方案`,value:`${e.contentPackage.origin.planId} · v${e.contentPackage.origin.planRevision}`}),(0,l.jsx)(E,{label:`编译器`,value:`v${e.contentPackage.build.compilerVersion}`}),(0,l.jsx)(E,{label:`质量策略`,value:e.contentPackage.quality.policyVersion})]}),e.contentPackage.quality.warnings.length?(0,l.jsx)(`div`,{className:`grid gap-2 border-l-2 border-[var(--warning-border)] pl-4 text-sm text-[var(--warning)]`,children:e.contentPackage.quality.warnings.map(e=>(0,l.jsx)(`p`,{children:e.message},`${e.code}:${e.message}`))}):null,(0,l.jsx)(u,{document:e.contentPackage.document,assets:e.contentPackage.assets,evidence:e.contentPackage.evidence,materials:e.contentPackage.materials})]})}function E({label:e,value:t}){return(0,l.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] gap-4 py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-[var(--muted)]`,children:e}),(0,l.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-[var(--ink-2)]`,children:t})]})}export{T as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{B as t,Lt as n,M as r,R as i,U as a,V as o,X as s,Y as c,an as l,dn as u,in as d,k as f,ln as p,nt as m}from"./index-Bx1uywm3.js";import{t as h}from"./play-DYoZjslk.js";import{n as g,t as _}from"./react-OqyHmgtK.js";import"./types-D57tnOAh.js";import{n as ee}from"./use-workspace-snapshot-MZKeTfAJ.js";import{t as v}from"./useMutation-Xdq_89ou.js";import{i as y}from"./articles-CJ24swVV.js";import{t as b}from"./tabs-DdmTx_k0.js";import{t as x}from"./fingerprint-pattern-CVznkwfS.js";import{t as S}from"./radio-tower-CS59Tvfq.js";import{t as C}from"./input-Br6N0XCJ.js";import{t as w}from"./select-9cx3otc_.js";import{t as T}from"./empty-state-B2PGtu_a.js";import{t as E}from"./AnimatePresence-dRKyi9jP.js";import{t as D}from"./form-field-BJITE8Lh.js";import{t as O}from"./src-DVp5YM1T.js";import{t as k}from"./publication-destination-picker-DAgQcLxS.js";import{t as A}from"./-association-list-MaFlvvF5.js";import{n as j,r as M,t as N}from"./notifications-wLr7xSyr.js";import{a as P}from"./runs-Cbz28Mf6.js";import{t as F}from"./pagination-CEYfdE0s.js";import{t as I}from"./-run-detail-view-CSb6Mp_W.js";import{n as L,r as R,t as z}from"./-run-presentation-e-aAMUOA.js";var B=s(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),V=s(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),H=s(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),U=s(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),W=e(u(),1),G=p(),K=[[`basic`,`Agent 设置`,`策略、模型与预算`,U],[`identity`,`内容身份`,`定位、受众和语气`,x],[`knowledge`,`知识库`,`长期参考材料`,B],[`sources`,`输入来源`,`运行时内容输入`,V],[`publishing`,`发布账号`,`多渠道发布目的地`,S]];function q({section:e,onSectionChange:t,form:n,update:r,workspace:i,error:a}){let s=g(),l=K.findIndex(([t])=>t===e);return(0,G.jsxs)(`div`,{className:`grid min-h-0 gap-2 lg:h-full lg:grid-cols-[220px_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsx)(`nav`,{"aria-label":`内容方案配置模块`,className:`min-w-0 overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-2 lg:h-full`,children:(0,G.jsx)(`div`,{className:`flex gap-1 overflow-x-auto lg:grid lg:overflow-visible`,children:K.map(([r,i,a,o])=>{let l=X(r,n);return(0,G.jsx)(`div`,{className:`min-w-[164px] lg:min-w-0`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(r),className:m(`relative isolate flex w-full items-center gap-3 overflow-hidden rounded-[var(--radius-sm)] px-2.5 py-2 text-left transition-colors duration-[var(--motion-base)] ease-[var(--ease-standard)]`,e===r?`text-[var(--ink)]`:`text-[var(--muted-strong)] hover:bg-[var(--surface-2)]`),children:[e===r?(0,G.jsx)(_.span,{layoutId:`content-plan-section-active`,className:`absolute inset-0 -z-10 rounded-[var(--radius-sm)] bg-[var(--surface-2)]`,transition:{duration:s?0:.28,ease:[.16,1,.3,1]}}):null,(0,G.jsx)(`span`,{className:`relative z-10 grid size-6 shrink-0 place-items-center text-[var(--muted-strong)]`,children:(0,G.jsx)(o,{className:`size-4`})}),(0,G.jsxs)(`span`,{className:`relative z-10 min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`strong`,{className:`block truncate text-sm font-semibold`,children:i}),l?(0,G.jsx)(c,{className:`size-3.5 shrink-0 text-[var(--success)]`}):null]}),(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-[var(--muted)]`,children:a})]})]})},r)})})}),(0,G.jsx)(`div`,{className:`scrollbar-stable min-h-[560px] min-w-0 overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] lg:h-full lg:min-h-0 lg:overflow-y-auto lg:overscroll-contain`,children:(0,G.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-5 py-5 sm:px-7 lg:py-6`,children:(0,G.jsx)(E,{initial:!1,mode:`wait`,custom:l,children:(0,G.jsxs)(_.div,{initial:{opacity:0,x:s?0:18,clipPath:s?`none`:`inset(0 0 0 12px)`},animate:{opacity:1,x:0,clipPath:`inset(0 0 0 0)`},exit:{opacity:0,x:s?0:-12,clipPath:s?`none`:`inset(0 12px 0 0)`},transition:{duration:s?0:.22,ease:[.16,1,.3,1]},children:[(0,G.jsx)(J,{section:e}),(0,G.jsx)(`div`,{className:`mt-6`,children:(0,G.jsx)(Y,{section:e,form:n,update:r,workspace:i})}),(0,G.jsx)(o,{error:a})]},e)})})})]})}function J({section:e}){let t=K.find(([t])=>t===e);return(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold`,children:t[1]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-strong)]`,children:{basic:`选择 ReAct 策略和原生 Tool Calling 模型;策略不规定工具顺序。`,identity:`选择内容表达主体;身份只负责定位、受众、语气和边界。`,knowledge:`选择已上传的长期参考材料,不会在运行时重新抓取。`,sources:`选择 URL、查询等来源集合;工具连接统一在 Agent 设置中授权。`,publishing:`直接选择一个或多个账号;系统按渠道和发布类型启动独立 ReAct 会话。`}[e]})]})}function Y({section:e,form:t,update:n,workspace:r}){if(!r)return(0,G.jsx)(`p`,{className:`text-sm text-[var(--muted)]`,children:`正在加载配置…`});let i=new Map(r.connectorDefinitions.map(e=>[e.id,e])),o=e=>r.connections.filter(t=>t.enabled&&i.get(t.connectorId)?.capabilities.includes(e)),s=r.identities.filter(e=>e.enabled),c=r.knowledgeBases.filter(e=>e.enabled),l=r.sourceCollections.filter(e=>e.enabled);if(e===`basic`){let e=Z(t),a=r.connections.filter(e=>e.enabled?(i.get(e.connectorId)?.capabilities??[]).some(e=>[`source-search`,`source-fetch`].includes(e)):!1),s=e=>{let t=r.connections.find(t=>t.id===e);return t?{id:e,name:t.name,detail:i.get(t.connectorId)?.displayName??t.connectorId}:void 0};return(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,G.jsx)(D,{label:`方案名称`,required:!0,children:(0,G.jsx)(C,{value:t.name,onChange:e=>n({...t,name:e.target.value}),placeholder:`例如:工程观察日报`})}),(0,G.jsx)(D,{label:`生成模型`,required:!0,children:(0,G.jsxs)(w,{value:e.modelConnectionId,onChange:r=>n({...t,connections:{...t.connections,chat:r.target.value},agent:{...e,modelConnectionId:r.target.value}}),children:[(0,G.jsx)(`option`,{value:``,children:`请选择 Chat 连接`}),o(`chat`).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,G.jsx)(D,{label:`内容策略`,required:!0,className:`md:col-span-2`,children:(0,G.jsx)(w,{value:e.strategyId,onChange:r=>n({...t,agent:{...e,strategyId:r.target.value}}),children:r.contentStrategies.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.description]},e.id))})}),(0,G.jsxs)(`section`,{className:`grid gap-2 border-t border-[var(--border)] pt-4 md:col-span-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-sm font-semibold`,children:`Agent 工具权限`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:`搜索和网页抓取连接会成为内容 Agent 的可调用工具;发布器工具由发布账号单独引用。`})]}),(0,G.jsx)(A,{items:e.toolConnectionIds.flatMap(e=>{let t=s(e);return t?[t]:[]}),available:a.filter(t=>!e.toolConnectionIds.includes(t.id)).map(e=>s(e.id)),empty:`尚未授权搜索或抓取工具`,addLabel:`添加工具连接`,onAdd:r=>n({...t,agent:{...e,toolConnectionIds:[...e.toolConnectionIds,r]}}),onRemove:r=>n({...t,agent:{...e,toolConnectionIds:e.toolConnectionIds.filter(e=>e!==r)}})})]}),(0,G.jsxs)(`details`,{className:`border-t border-[var(--border)] pt-4 md:col-span-2`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`运行预算`}),(0,G.jsx)(`div`,{className:`mt-4 max-w-sm`,children:(0,G.jsx)(D,{label:`最大 Agent 轮次`,helper:`默认 24,范围 1–100;最后一轮只用于提交当前最佳结果`,children:(0,G.jsx)(C,{type:`number`,min:1,max:100,value:e.budget?.maxTurns??24,onChange:r=>n({...t,agent:{...e,budget:{...e.budget,maxTurns:Number(r.target.value)}}})})})})]})]})}if(e===`identity`){if(!s.length)return(0,G.jsx)(T,{className:`min-h-48 border-y border-[var(--border)]`,title:`还没有内容身份`,description:`先创建一个身份,定义内容的定位、受众、语气和表达边界。`,action:(0,G.jsx)(a,{size:`sm`,onClick:()=>window.location.href=`/dashboard/identities`,children:`创建内容身份`})});let e=r.identities.find(e=>e.id===t.identityId);return(0,G.jsx)(A,{items:e?[{id:e.id,name:e.name,detail:`定位:${e.positioning} 语气:${e.tone}`}]:[],available:e?[]:s.map(e=>({id:e.id,name:e.name,detail:`定位:${e.positioning} 语气:${e.tone}`})),empty:`还没有添加内容身份`,addLabel:`添加内容身份`,onAdd:e=>n({...t,identityId:e}),onRemove:()=>n({...t,identityId:``})})}return e===`knowledge`?c.length?(0,G.jsx)(A,{items:t.knowledgeBaseIds.flatMap(e=>{let t=r.knowledgeBases.find(t=>t.id===e);return t?[{id:t.id,name:t.name,detail:`${t.documents.length} 份参考文档`}]:[]}),available:c.filter(e=>!t.knowledgeBaseIds.includes(e.id)).map(e=>({id:e.id,name:e.name,detail:`${e.documents.length} 份参考文档`})),empty:`还没有添加知识库`,addLabel:`添加知识库`,onAdd:e=>n({...t,knowledgeBaseIds:[...t.knowledgeBaseIds,e]}),onRemove:e=>n({...t,knowledgeBaseIds:t.knowledgeBaseIds.filter(t=>t!==e)})}):(0,G.jsx)(T,{className:`min-h-48 border-y border-[var(--border)]`,title:`还没有知识库`,description:`知识库用于保存长期参考材料;这一步也可以暂时跳过。`,action:(0,G.jsx)(a,{size:`sm`,onClick:()=>window.location.href=`/dashboard/knowledge`,children:`新建知识库`})}):e===`sources`?(0,G.jsx)(A,{items:t.sourceCollectionIds.flatMap(e=>{let t=r.sourceCollections.find(t=>t.id===e);return t?[{id:t.id,name:t.name,detail:`${t.sources.filter(e=>e.enabled).length} 个动态来源`}]:[]}),available:l.filter(e=>!t.sourceCollectionIds.includes(e.id)).map(e=>({id:e.id,name:e.name,detail:`${e.sources.filter(e=>e.enabled).length} 个动态来源`})),empty:`还没有添加输入来源`,addLabel:`添加来源集合`,onAdd:e=>n({...t,sourceCollectionIds:[...t.sourceCollectionIds,e]}),onRemove:e=>n({...t,sourceCollectionIds:t.sourceCollectionIds.filter(t=>t!==e)})}):e===`publishing`?(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(k,{accounts:r.channelAccounts,channels:r.channelDefinitions,profiles:r.publicationTypeProfiles,templates:r.channelTemplates,writingStyles:r.writingStyles,value:t.publishing.destinations,onChange:e=>n({...t,publishing:{destinations:e}})}),t.publishing.destinations.length?(0,G.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:`每个账号与发布类型会独立格式化、上传和发布;单个失败不会中断其他目的地。`}):(0,G.jsx)(`p`,{className:`text-sm text-[var(--muted-strong)]`,children:`未选择发布账号:运行后仅生成可发布内容包,不经过额外审核门禁。`})]}):null}function X(e,t){return e===`basic`?!!(t.name.trim()&&t.agent?.modelConnectionId):e!==`identity`||!!t.identityId}function Z(e){return e.agent??{modelConnectionId:e.connections.chat??``,strategyId:`daily-brief`,toolConnectionIds:[...e.researchConnections?.search??[],...e.researchConnections?.fetch??[],...e.connections.image?[e.connections.image]:[]].filter((e,t,n)=>n.indexOf(e)===t)}}function te(e,t){let n=new Map(e.connectorDefinitions.map(e=>[e.id,e]));return e.connections.filter(e=>e.enabled&&n.get(e.connectorId)?.capabilities.includes(t))}var Q=20;function ne({planId:e,startedRunId:t,runError:n}){let r=d(),a=i.useSearch(),s=a.runPage??1,{data:c}=M({queryKey:[`runs`,`plan`,e,s],queryFn:()=>P(s,Q,e),enabled:!!e,refetchInterval:2e3}),l=c?.items??[],u=typeof a.run==`string`&&l.some(e=>e.id===a.run)?a.run:l[0]?.id??null;return(0,W.useEffect)(()=>{t&&r({to:`.`,search:e=>({...e,runPage:1,run:t,destination:void 0}),replace:!0,resetScroll:!1})},[r,t]),e?(0,G.jsxs)(`div`,{className:`grid min-h-0 gap-2 lg:h-full lg:grid-cols-[250px_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,G.jsxs)(`div`,{className:`border-b border-[var(--border)] px-4 py-3.5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`运行记录`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:`主会话与发布会话统一归档。`})]}),l.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`scrollbar-stable min-h-0 flex-1 divide-y divide-[var(--border)] lg:overflow-y-auto lg:overscroll-contain`,children:l.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void r({to:`.`,search:t=>({...t,run:e.id}),resetScroll:!1}),className:m(`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--surface-2)]`,u===e.id&&`bg-[var(--surface-2)]`),children:[(0,G.jsx)(`strong`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:z(e)}),(0,G.jsx)(j,{tone:R(e.status),children:L(e.status)})]},e.id))}),(0,G.jsx)(F,{compact:!0,className:`shrink-0 border-t border-[var(--border)]`,page:s,pageSize:Q,total:c?.total??0,onChange:e=>void r({to:`.`,search:t=>({...t,runPage:e,run:void 0,destination:void 0}),resetScroll:!1})})]}):(0,G.jsx)(T,{className:`min-h-64`,title:`还没有运行记录`,description:`运行内容方案后会显示在这里。`})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,G.jsx)(o,{error:n}),(0,G.jsx)(I,{className:`min-h-0 flex-1`,runId:u,planScoped:!0})]})]}):(0,G.jsx)(T,{className:`min-h-[420px] rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,title:`保存后显示运行记录`,description:`运行记录会按内容方案过滤。`})}function $(){return{name:``,enabled:!0,identityId:``,knowledgeBaseIds:[],sourceCollectionIds:[],connections:{},researchConnections:{search:[],fetch:[]},agent:{modelConnectionId:``,strategyId:O,toolConnectionIds:[]},publishing:{destinations:[]}}}function re(e){let t=n();return v({mutationFn:t=>e?r(e,t):f(t),onSuccess:()=>t.invalidateQueries({queryKey:[`content-plans`]})})}function ie(){let e=l({strict:!1}).planId,[r,o]=(0,W.useState)(),s=e??r,{data:c}=ee({live:!1}),u=re(s),f=n(),p=d(),m=i.useSearch(),x=m.tab===`runs`?`runs`:`config`,S=ae(m.panel),[C,w]=(0,W.useState)(1),[T,D]=(0,W.useState)($),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),I=t(),L=g(),R=(0,W.useRef)(null),z=c?.contentPlans.find(e=>e.id===s),B=v({mutationFn:e=>y({planId:e}),onSuccess:e=>{F(e.run.id),f.invalidateQueries({queryKey:[`runs`]}),N.success(`运行已启动`,`可在运行记录中查看实时活动。`)},onError:e=>N.error(`启动运行失败`,e)});(0,W.useEffect)(()=>{if(!c)return;let e=s??`__new__`;if(R.current!==e&&(!s||z)){if(s&&z)D({...z,revision:z.revision,knowledgeBaseIds:z.knowledgeBaseIds??[],researchConnections:z.researchConnections??{search:[],fetch:[]},publishing:z.publishing??{destinations:[]},agent:z.agent??{modelConnectionId:z.connections.chat??``,strategyId:O,toolConnectionIds:[...z.researchConnections?.search??[],...z.researchConnections?.fetch??[],...z.connections.image?[z.connections.image]:[]].filter((e,t,n)=>n.indexOf(e)===t)}});else if(!s){let e=$();e.identityId=c.identities.find(e=>e.enabled)?.id??``,e.connections.chat=te(c,`chat`)[0]?.id??``,e.agent.modelConnectionId=e.connections.chat,D(e)}R.current=e,A(!1)}},[c,z,s]),(0,W.useEffect)(()=>{let e=e=>{k&&e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[k]);let V=e=>{D(e),A(!0),M(null)},K=e=>{e!==x&&(w(e===`runs`?1:-1),p({to:`.`,search:t=>({...t,tab:e}),resetScroll:!1}))},J=e=>{x!==`config`&&w(-1),p({to:`.`,search:t=>({...t,tab:`config`,panel:e}),resetScroll:!1})},Y=()=>{k?I({title:`放弃未保存的修改?`,description:`当前配置修改尚未保存,离开后无法恢复。`,confirmLabel:`放弃修改`,action:()=>p({to:`/content-plans`,search:{page:1}})}):p({to:`/content-plans`,search:{page:1}})},X=()=>T.name.trim()?T.agent?.modelConnectionId?T.identityId?(M(null),!0):(J(`identity`),M(Error(`请添加内容身份`)),!1):(J(`basic`),M(Error(`请选择生成模型连接`)),!1):(J(`basic`),M(Error(`请填写方案名称`)),!1),Z=()=>{J(S),X()&&u.mutate(T,{onSuccess:()=>{A(!1),N.success(`内容方案已保存`,`“${T.name.trim()}”的配置已更新。`),p({to:`/content-plans`,search:{page:1}})},onError:e=>N.error(`保存内容方案失败`,e)})},Q=async()=>{if(!X())return;let e=s;if(!e||k)try{let t=await u.mutateAsync(T);e=t.contentPlan.id,o(e=>e??t.contentPlan.id),D(e=>({...e,revision:t.contentPlan.revision})),A(!1)}catch(e){N.error(`保存内容方案失败`,e);return}B.mutate(e)};return e&&c&&!z?(0,G.jsx)(`div`,{className:`rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-8 text-sm`,children:`内容方案不存在或已被删除。`}):(0,G.jsxs)(`section`,{className:`grid gap-4 lg:h-[calc(100dvh-6rem)] lg:grid-rows-[auto_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(b,{value:x,onChange:K,className:`w-fit`,items:[{value:`config`,label:`配置`,icon:(0,G.jsx)(U,{className:`size-3.5`})},{value:`runs`,label:`运行记录`,icon:(0,G.jsx)(H,{className:`size-3.5`})}]}),(0,G.jsx)(E,{initial:!1,mode:`popLayout`,children:x===`config`?(0,G.jsxs)(_.div,{initial:{opacity:0,x:L?0:12},animate:{opacity:1,x:0},exit:{opacity:0,x:L?0:-8},transition:{duration:L?0:.18,ease:[.16,1,.3,1]},className:`flex gap-2`,children:[(0,G.jsx)(a,{size:`sm`,variant:`ghost`,onClick:Y,children:`取消`}),(0,G.jsx)(a,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:Z,children:`保存方案`})]},`config-actions`):(0,G.jsx)(_.div,{initial:{opacity:0,x:L?0:12},animate:{opacity:1,x:0},exit:{opacity:0,x:L?0:-8},transition:{duration:L?0:.18,ease:[.16,1,.3,1]},children:(0,G.jsxs)(a,{size:`sm`,variant:`primary`,loading:u.isPending||B.isPending,title:k||!s?`保存当前配置并运行`:`运行内容方案`,onClick:()=>void Q(),children:[(0,G.jsx)(h,{className:`size-3.5`}),`运行`]})},`run-action`)})]}),(0,G.jsx)(`div`,{className:`relative min-h-0 overflow-hidden`,children:(0,G.jsx)(E,{initial:!1,mode:`popLayout`,custom:C,children:(0,G.jsx)(_.div,{custom:C,initial:{opacity:0,x:L?0:C*22,filter:L?`none`:`blur(3px)`},animate:{opacity:1,x:0,filter:`none`},exit:{opacity:0,x:L?0:C*-14,filter:L?`none`:`blur(2px)`},transition:{duration:L?0:.24,ease:[.16,1,.3,1]},className:`h-full min-h-0`,children:x===`config`?(0,G.jsx)(q,{section:S,onSectionChange:J,form:T,update:V,workspace:c,error:j??u.error}):(0,G.jsx)(ne,{planId:s,startedRunId:P,runError:B.error??u.error})},x)})})]})}function ae(e){return e===`identity`||e===`knowledge`||e===`sources`||e===`publishing`?e:`basic`}export{ie as t};
@@ -0,0 +1,12 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{Lt as t,R as n,U as r,V as i,X as a,dn as o,et as s,in as c,ln as l,nt as u}from"./index-Bx1uywm3.js";import{t as d}from"./useMutation-Xdq_89ou.js";import{n as f,r as p,t as m}from"./notifications-wLr7xSyr.js";import{n as h,r as g,t as _}from"./wrench-C9HmhR9v.js";import{t as v}from"./eye-DyaLFyNg.js";import{n as y,t as b}from"./react-OqyHmgtK.js";import"./types-D57tnOAh.js";import{c as x,i as S,l as ee,n as C,o as w,r as T,s as E,t as te}from"./runs-Cbz28Mf6.js";import{n as ne,o as re,t as ie}from"./articles-CJ24swVV.js";import{t as ae}from"./app-dialog-CBRjH8y0.js";import{t as D}from"./AnimatePresence-dRKyi9jP.js";import{a as O,i as k,o as A,r as j}from"./execution-Brd94hIY.js";import{t as M}from"./empty-state-B2PGtu_a.js";import{t as oe}from"./-content-package-preview-Bc225W8p.js";import{a as N,i as se,n as P,o as F,r as I,t as ce}from"./-run-presentation-e-aAMUOA.js";import{t as L}from"./newspaper-BF6EkBWC.js";import{t as R}from"./chevron-down-CjEG9BtO.js";var z=a(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),B=a(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),V=a(`file-output`,[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]),H=a(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),le=a(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),U=a(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),W=e(o(),1),G=2e3;function ue(e){let n=t(),[r,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(()=>e?J.read(e):[]),[c,l]=(0,W.useState)(`idle`),[u,d]=(0,W.useState)(`idle`),[f,m]=(0,W.useState)(!1),h=(0,W.useRef)(0),g=(0,W.useRef)(0),_=(0,W.useRef)({runId:null,value:0}),v=p({queryKey:[`runs`,e],queryFn:()=>T(e??``),enabled:!!e,refetchInterval:e=>K(e.state.data?.run.status)?G:!1}),y=p({queryKey:[`runs`,e,`activities`],queryFn:()=>S(e??``),enabled:!!e,refetchInterval:c===`unavailable`&&K(v.data?.run.status)?G:!1}),b=(0,W.useMemo)(()=>q(y.data?.activities??[],r),[y.data?.activities,r]),C=b.at(-1)?.sequence??0;_.current.runId===e?_.current.value=Math.max(_.current.value,C):_.current={runId:e,value:C},(0,W.useEffect)(()=>{i([]),o(e?J.read(e):[]),m(!1),_.current={runId:e,value:0}},[e]);let w=v.data?.run.status,E=!!e&&(w===void 0||K(w));return(0,W.useEffect)(()=>{if(!e||!E){l(`idle`);return}let t=++h.current,r=new AbortController,a,o=0,c=()=>t===h.current&&!r.signal.aborted,u=async()=>{if(!c())return;let t=_.current.runId===e?_.current.value:0;l(o?`retrying`:`connecting`);try{await x(e,{signal:r.signal,afterSequence:t,lastEventId:t?String(t):void 0,onOpen:()=>{c()&&(o=0,l(`live`))},onEvent:t=>{c()&&(_.current={runId:e,value:Math.max(_.current.value,t.sequence)},i(e=>q(e,[t])),n.invalidateQueries({queryKey:[`runs`,e]}))}})}catch(e){if(!c())return;if(s(e)){l(`unavailable`);return}o+=1,l(o>=5?`unavailable`:`retrying`),a=setTimeout(()=>void u(),Math.min(1e3*2**o,15e3))}};return u(),()=>{r.abort(),a&&clearTimeout(a)}},[n,e,E]),(0,W.useEffect)(()=>{if(!e||!K(w)){d(`idle`);return}J.read(e).length&&m(!0);let t=++g.current,n=new AbortController,r,i=0,a=()=>t===g.current&&!n.signal.aborted,c=async()=>{if(a()){d(i?`retrying`:`connecting`);try{await ee(e,{signal:n.signal,onOpen:()=>{a()&&(i=0,d(`live`))},onEvent:t=>{a()&&o(J.remember(e,t))}})}catch(e){if(!a())return;if(m(!0),s(e)){d(`unavailable`);return}i+=1,d(`retrying`),r=setTimeout(()=>void c(),Math.min(1e3*2**i,15e3))}}};return c(),()=>{n.abort(),r&&clearTimeout(r)}},[w,e]),{...v,activities:b,modelEvents:a,activityStreamState:c,modelStreamState:u,modelStreamInterrupted:f}}function K(e){return e===A.Queued||e===A.Running}function q(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>{let t=n.get(e.id);(!t||e.sequence>=t.sequence)&&n.set(e.id,e)}),[...n.values()].sort((e,t)=>e.sequence-t.sequence)}var J=new class{maxRuns;maxEventsPerRun;streams=new Map;constructor(e=20,t=1e3){this.maxRuns=e,this.maxEventsPerRun=t}read(e){return[...this.streams.get(e)??[]]}remember(e,t){let n=[...this.streams.get(e)??[],t].slice(-this.maxEventsPerRun);for(this.streams.delete(e),this.streams.set(e,n);this.streams.size>this.maxRuns;){let e=this.streams.keys().next().value;if(typeof e!=`string`)break;this.streams.delete(e)}return[...n]}},Y=l(),X=68,Z=10;function de({sessions:e,selected:t,sourceTitle:n,onSelect:r}){let i=y(),a=e.length*X+Math.max(0,e.length-1)*Z,o=a/2,s=e.findIndex(e=>e.id===t);return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3`,children:[(0,Y.jsx)(`strong`,{className:`text-sm`,children:`发布流程`}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-[var(--muted)]`,children:[e.filter(e=>e.status===A.Succeeded).length,`/`,e.length,` 个目的地完成`]})]}),(0,Y.jsxs)(`div`,{className:`publication-flow-canvas`,children:[(0,Y.jsx)(b.div,{className:`publication-flow-source-wrap`,initial:{opacity:0,x:i?0:-10},animate:{opacity:1,x:0},transition:{duration:i?0:.32,ease:[.16,1,.3,1]},children:(0,Y.jsxs)(`div`,{className:`publication-flow-source publication-flow-node`,children:[(0,Y.jsx)(`span`,{className:`publication-flow-icon`,children:(0,Y.jsx)(V,{className:`size-4`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block truncate text-xs font-semibold`,children:`可发布内容包`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-[var(--muted)]`,children:n})]})]})}),(0,Y.jsxs)(`div`,{className:`publication-flow-rail`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`publication-flow-line publication-flow-source-line`,style:{top:o}}),(0,Y.jsx)(`span`,{className:`publication-flow-line publication-flow-trunk`,style:{top:X/2,height:Math.max(0,a-X)}}),e.map((e,t)=>{let n=$(t);return(0,Y.jsx)(`span`,{className:`publication-flow-line publication-flow-branch`,"data-status":e.status,style:{top:n}},`branch-${e.id}`)}),s>=0?(0,Y.jsx)(Q,{className:`publication-flow-selection-line`,sourceY:o,targetY:$(s)}):null,e.map((e,t)=>e.status===A.Running?(0,Y.jsx)(Q,{className:`publication-flow-signal`,sourceY:o,targetY:$(t),animated:!0},`signal-${e.id}`):null)]}),(0,Y.jsx)(`div`,{className:`publication-flow-destinations`,children:e.map((e,n)=>{let a=t===e.id;return(0,Y.jsxs)(b.button,{layout:`position`,type:`button`,"aria-pressed":a,onClick:()=>r(e.id),initial:{opacity:0,x:i?0:12},animate:{opacity:1,x:0},transition:{duration:i?0:.3,delay:i?0:Math.min(n*.045,.18),ease:[.16,1,.3,1]},className:u(`publication-flow-channel publication-flow-node`,a&&`is-selected`),children:[a?(0,Y.jsx)(b.span,{layoutId:`publication-flow-selected-node`,className:`publication-flow-selection`,transition:{duration:i?0:.24,ease:[.16,1,.3,1]}}):null,(0,Y.jsx)(`span`,{className:`publication-flow-port`,"data-status":e.status}),(0,Y.jsx)(`span`,{className:`publication-flow-icon`,children:pe(e)}),(0,Y.jsxs)(`span`,{className:`relative min-w-0 flex-1 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Y.jsx)(`strong`,{className:`truncate text-xs font-semibold`,children:e.destination?.accountName??`发布账号`}),(0,Y.jsx)(f,{tone:I(e.status),children:P(e.status)})]}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-[var(--muted)]`,children:[fe(e),` · `,e.currentActivity??`等待开始`]})]})]},e.id)})})]})]})}function Q({className:e,sourceY:t,targetY:n,animated:r=!1}){let i=Math.min(t,n),a=Math.abs(t-n);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:u(e,`publication-flow-path-source`,r&&`is-animated`),style:{top:t}}),a?(0,Y.jsx)(`span`,{className:u(e,`publication-flow-path-vertical`,r&&`is-animated`),"data-direction":n<t?`up`:`down`,style:{top:i,height:a}}):null,(0,Y.jsx)(`span`,{className:u(e,`publication-flow-path-branch`,r&&`is-animated`),style:{top:n}})]})}function $(e){return X/2+e*78}function fe(e){let t=e.destination?.channel,n=e.destination?.publicationType;return`${t===`weixin-official-account`?`微信公众号`:t||`发布渠道`} · ${n===`article`?`图文`:n||`内容`}`}function pe(e){return e.destination?.publicationType===`video`?(0,Y.jsx)(U,{className:`size-4`}):e.destination?.publicationType===`audio`?(0,Y.jsx)(z,{className:`size-4`}):e.destination?.channel===`weixin-official-account`?(0,Y.jsx)(L,{className:`size-4`}):(0,Y.jsx)(re,{className:`size-4`})}function me(e){return e.kind===O.Publication&&e.destination?.channel===`weixin-official-account`&&e.destination.publicationType===`article`}function he({mode:e,preview:t,pending:n,error:r,onOpenChange:a}){let o=e===`cover`?`微信封面预览`:`微信 HTML 预览`;return(0,Y.jsx)(ae,{open:e!==null,onOpenChange:a,title:t?.title||o,description:o,size:e===`html`?`wide`:`medium`,children:n?(0,Y.jsx)(`div`,{className:`grid min-h-72 place-items-center`,"aria-live":`polite`,children:(0,Y.jsx)(`span`,{className:`text-sm text-[var(--muted)]`,children:`正在读取渠道准备结果…`})}):r?(0,Y.jsxs)(`div`,{className:`grid min-h-48 content-center gap-3`,children:[(0,Y.jsx)(i,{error:r}),(0,Y.jsx)(`p`,{className:`text-center text-xs leading-5 text-[var(--muted)]`,children:`渠道 ReAct 完成内容准备后即可查看,不需要等待发布执行结束。`})]}):e===`cover`?t?.cover?(0,Y.jsxs)(`figure`,{className:`grid gap-3`,children:[(0,Y.jsx)(`div`,{className:`grid aspect-video place-items-center overflow-hidden rounded-[var(--radius-sm)] bg-[var(--surface-2)]`,children:(0,Y.jsx)(`img`,{src:t.cover.source,alt:t.cover.alt||`${t.title}封面`,className:`h-full w-full object-contain`})}),(0,Y.jsx)(`figcaption`,{className:`text-center text-xs leading-5 text-[var(--muted)]`,children:t.cover.alt||t.title})]}):(0,Y.jsx)(M,{title:`没有可预览的封面`,description:`渠道准备结果未包含安全的封面图片地址。`}):t?.body.format===`html`?(0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[t.adaptation?(0,Y.jsxs)(`details`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-3 py-2 text-xs`,children:[(0,Y.jsxs)(`summary`,{className:`cursor-pointer font-medium text-[var(--ink)]`,children:[`已按写作风格「`,t.adaptation.styleName,`」改写(点击查看改写文案)`]}),(0,Y.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-sans text-xs leading-5 text-[var(--muted-strong)]`,children:t.adaptation.bodyMarkdown})]}):null,(0,Y.jsx)(`iframe`,{title:`${t.title}微信 HTML 预览`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:ge(t.body.content),className:`h-[min(680px,70dvh)] w-full rounded-[var(--radius-sm)] border border-[var(--border)] bg-white`})]}):(0,Y.jsx)(M,{title:`没有 HTML 预览`,description:`该渠道准备结果不是 HTML 格式。`})})}function ge(e){return`<!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="referrer" content="no-referrer">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
7
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: http: https:; style-src 'unsafe-inline'; font-src data: http: https:; base-uri 'none'; form-action 'none'">
8
+ <style>html{background:#fff}body{box-sizing:border-box;max-width:677px;margin:0 auto;padding:24px 20px;color:#222;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;overflow-wrap:anywhere}img{max-width:100%;height:auto}pre{overflow:auto;white-space:pre-wrap}table{max-width:100%;border-collapse:collapse}</style>
9
+ </head>
10
+ <body>${e}</body>
11
+ </html>`}function _e({session:e,activities:t,modelEvents:n,retrying:i,hideHeader:a,onPreviewCover:o,onPreviewHtml:s,onRetry:c}){return(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[a?null:(0,Y.jsx)(`section`,{className:`rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-4`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{className:`text-sm`,children:F(e)}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted)]`,children:e.kind===O.Publication?`渠道内容准备 · 发布执行`:`动态 ReAct 主会话`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,Y.jsxs)(r,{size:`sm`,onClick:o,children:[(0,Y.jsx)(H,{className:`size-4`}),`封面预览`]}):null,s?(0,Y.jsxs)(r,{size:`sm`,onClick:s,children:[(0,Y.jsx)(B,{className:`size-4`}),`HTML 预览`]}):null,(0,Y.jsx)(f,{tone:I(e.status),children:P(e.status)}),c?(0,Y.jsxs)(r,{loading:i,onClick:c,children:[(0,Y.jsx)(h,{className:`size-4`}),`重试目的地`]}):null]})]})}),(0,Y.jsx)(ve,{activities:ye(t,e),modelEvents:n})]})}function ve({activities:e,modelEvents:t}){let n=(0,W.useMemo)(()=>we(t),[t]),r=(0,W.useMemo)(()=>e.filter(e=>!be(e)),[e]);return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--border)] px-4 py-3`,children:[(0,Y.jsx)(_,{className:`size-4`}),(0,Y.jsx)(`strong`,{className:`text-sm`,children:`运行活动`}),(0,Y.jsx)(`span`,{className:`text-[11px] text-[var(--muted)]`,children:`可恢复历史`})]}),r.length?(0,Y.jsx)(`ol`,{className:`divide-y divide-[var(--border)]`,children:(0,Y.jsx)(D,{initial:!1,children:r.map(e=>(0,Y.jsx)(xe,{activity:e,modelOutput:e.taskId?n.get(e.taskId):void 0},e.id))})}):(0,Y.jsx)(`p`,{className:`px-4 py-8 text-center text-xs text-[var(--muted)]`,children:`尚无活动记录`})]})}function ye(e,t){return t.status!==A.Failed&&t.status!==A.NeedsAttention?e:e.map(e=>e.status===k.Running?{...e,status:t.status===A.NeedsAttention?k.NeedsAttention:k.Failed,error:e.error??(t.status===A.NeedsAttention?`服务重启,本轮执行已中断`:t.error),finishedAt:t.finishedAt??t.updatedAt,updatedAt:t.finishedAt??t.updatedAt}:e)}function be(e){return!!e.taskId?.split(`/`).includes(`quality`)}function xe({activity:e,modelOutput:t}){let[n,r]=(0,W.useState)(!1),i=e.kind===j.ModelTurn,a=y();return(0,Y.jsxs)(b.li,{layout:`position`,initial:{opacity:0,y:a?0:8,filter:a?`none`:`blur(3px)`},animate:{opacity:1,y:0,filter:`none`},exit:{opacity:0,y:a?0:-4},transition:{duration:a?0:.2,ease:[.16,1,.3,1]},className:`px-4 py-3`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`grid w-full grid-cols-[minmax(0,1fr)_auto] gap-4 text-left`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`strong`,{className:`truncate text-xs font-medium`,children:e.label}),(0,Y.jsx)(f,{tone:Le(e.status),children:Ie(e)})]}),e.summary?(0,Y.jsx)(`span`,{className:`mt-1 block text-[11px] text-[var(--muted)]`,children:e.summary}):null]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-[10px] text-[var(--muted)]`,children:[new Date(e.updatedAt).toLocaleTimeString(),(0,Y.jsx)(R,{className:u(`size-3 transition-transform`,n&&`rotate-180`)})]})]}),e.error?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-[var(--danger)]`,children:e.error}):null,i&&(t||e.status===k.Running)?(0,Y.jsx)(Se,{activity:e,output:t}):null,(0,Y.jsx)(D,{initial:!1,children:n?(0,Y.jsx)(b.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:a?0:.22,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-[var(--border)] pt-3`,children:[(0,Y.jsxs)(`p`,{className:`font-mono text-[10px] text-[var(--muted)]`,children:[e.taskId??e.id,` · 尝试 `,e.attempt??1]}),e.input===void 0?null:(0,Y.jsx)(Ce,{title:`输入摘要`,value:e.input}),e.output===void 0?null:(0,Y.jsx)(Ce,{title:`输出摘要`,value:e.output})]})}):null})]})}function Se({activity:e,output:t}){let n=Me(e);return(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--muted)]`,children:[(0,Y.jsx)(`span`,{children:t?.model??`模型生成中`}),(0,Y.jsxs)(`span`,{children:[Te(t),` 字符`]}),t?.toolCharacters?(0,Y.jsxs)(`span`,{children:[`工具参数 `,t.toolCharacters,` 字符`]}):null,t?.tokens===void 0?null:(0,Y.jsxs)(`span`,{children:[t.tokens,` tokens`]}),(0,Y.jsx)(`span`,{children:Pe(n)})]}),t?.content?(0,Y.jsx)(ke,{value:t.content,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-[var(--radius-sm)] bg-[var(--surface-2)] p-3 font-mono text-[11px] leading-5`}):null,(t?.tools??[]).map(e=>(0,Y.jsx)(ke,{value:De(e.arguments),className:`max-h-44 overflow-auto whitespace-pre-wrap break-all rounded-[var(--radius-sm)] border border-[var(--border)] p-3 font-mono text-[10px] leading-5`,prefix:(0,Y.jsx)(`strong`,{children:e.name||`Tool Call ${e.index+1}`})},e.index))]})}function Ce({title:e,value:t}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{className:`text-[10px] text-[var(--muted)]`,children:e}),(0,Y.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded bg-[var(--surface-2)] p-2 font-mono text-[10px] leading-5`,children:JSON.stringify(t,null,2)})]})}function we(e){let t=new Map;for(let n of e){if(!n.taskId)continue;let e=Fe(n.data),r=t.get(n.taskId)??{content:``,characters:0,toolCharacters:0,partial:!1,tools:[]};if(typeof e.model==`string`&&(r.model=e.model),n.type===`response.delta`&&typeof e.delta==`string`){r.content+=e.delta;let t=typeof e.accumulatedCharacters==`number`?e.accumulatedCharacters:r.content.length;r.characters=t,t>r.content.length&&(r.partial=!0)}if(n.type===`response.tool_delta`){let t=typeof e.index==`number`?e.index:0,n=r.tools.find(e=>e.index===t)??{index:t,arguments:``};r.tools.includes(n)||r.tools.push(n),typeof e.name==`string`&&(n.name=e.name),typeof e.accumulatedArguments==`string`&&(n.arguments=e.accumulatedArguments),r.toolCharacters=r.tools.reduce((e,t)=>e+t.arguments.length,0)}n.type===`response.completed`&&(r.tokens=Ee(e.usage),typeof e.accumulatedCharacters==`number`&&(r.characters=e.accumulatedCharacters,e.accumulatedCharacters>r.content.length&&(r.partial=!0))),t.set(n.taskId,r)}return t}function Te(e){return(e?.characters??0)+(e?.toolCharacters??0)}function Ee(e){let t=Fe(e??null),n=t.totalTokens??t.total_tokens;return typeof n==`number`?n:void 0}function De(e){if(!e.trim())return`等待参数…`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return Oe(e)}}function Oe(e){return e.replace(/\\u([\dA-Fa-f]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}function ke({value:e,className:t,prefix:n}){let r=(0,W.useRef)(null);return Ae(r,e),(0,Y.jsxs)(`pre`,{ref:r,className:t,children:[n?(0,Y.jsxs)(Y.Fragment,{children:[n,`
12
+ `]}):null,e]})}function Ae(e,t,n=!0,r){let i=(0,W.useRef)(!0),a=(0,W.useRef)(r);(0,W.useEffect)(()=>{a.current!==r&&(a.current=r,i.current=!1,n&&e.current&&(e.current.scrollTop=0))},[n,e,r]),(0,W.useEffect)(()=>{let t=e.current;if(!n||!t)return;let r=()=>{i.current=je(t)};return t.addEventListener(`scroll`,r,{passive:!0}),()=>t.removeEventListener(`scroll`,r)},[n,e]),(0,W.useEffect)(()=>{n&&e.current&&i.current&&(e.current.scrollTop=e.current.scrollHeight)},[n,e,t])}function je(e){return e.scrollHeight-e.clientHeight-e.scrollTop<=32}function Me(e){let t=e.status===k.Running,[n,r]=(0,W.useState)(()=>Date.now());return(0,W.useEffect)(()=>{if(!t)return;r(Date.now());let e=window.setInterval(()=>r(Date.now()),100);return()=>window.clearInterval(e)},[t]),Ne(e,n)}function Ne(e,t=Date.now()){let n=Date.parse(e.startedAt);if(!Number.isFinite(n))return 0;let r=e.finishedAt?Date.parse(e.finishedAt):NaN,i=e.status===k.Running||!Number.isFinite(r)?t:r;return Math.max(0,i-n)}function Pe(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Fe(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ie(e){return e.status===k.Running?`进行中`:e.status===k.Succeeded?`完成`:e.status===k.NeedsAttention&&e.error?.includes(`本轮执行已中断`)?`已中断`:e.status===k.NeedsAttention?`需要处理`:`失败`}function Le(e){return e===k.Running?`info`:e===k.Succeeded?`success`:e===k.NeedsAttention?`warning`:`danger`}function Re(e){return e===`live`?`实时`:e===`retrying`?`恢复中`:e===`unavailable`?`轮询`:e===`connecting`?`连接中`:`待机`}function ze({runId:e,className:a,planScoped:o=!1}){let s=ue(e),l=t(),_=c(),x=n.useSearch(),[S,ee]=(0,W.useState)(1),[T,re]=(0,W.useState)(1),[k,j]=(0,W.useState)(!1),[F,L]=(0,W.useState)(null),R=(0,W.useId)(),z=y(),B=d({mutationFn:()=>w(e),onSuccess:()=>(m.success(`运行已恢复`,`执行器将从安全检查点继续。`),l.invalidateQueries({queryKey:[`runs`,e]})),onError:e=>m.error(`恢复运行失败`,e)}),V=d({mutationFn:t=>E(e,t),onSuccess:()=>(m.success(`目的地已重新执行`,`可在当前发布会话中查看进度。`),l.invalidateQueries({queryKey:[`runs`,e]})),onError:e=>m.error(`重试目的地失败`,e)}),H=s.data,U=p({queryKey:ie(H?.run.packageId),queryFn:()=>ne(H.run.packageId),enabled:!!H?.run.packageId}),G=H?.sessions.find(e=>e.kind===O.Main),K=H?.sessions.filter(e=>e.kind===O.Publication)??[],q=x.runTab===`publication`||!x.runTab&&!G&&K.length>0?`publication`:`main`,J=typeof x.destination==`string`?x.destination:null,X=K.find(e=>e.id===J)??K[0],Z=q===`main`?G:X,Q=p({queryKey:te(e,X?.id),queryFn:()=>C(e,X.id),enabled:!!(e&&X&&F),retry:!1}),$=(0,W.useRef)(null),fe=s.activities.at(-1)?.sequence,pe=s.modelEvents.at(-1)?.id,ge=e=>{e!==q&&(ee(e===`publication`?1:-1),_({to:`.`,search:t=>({...t,runTab:e}),resetScroll:!1}))},ve=e=>{let t=K.findIndex(e=>e.id===J),n=K.findIndex(t=>t.id===e);re(t<0||n>=t?1:-1),_({to:`.`,search:t=>({...t,runTab:`publication`,destination:e}),resetScroll:!1})};if((0,W.useEffect)(()=>j(!1),[e]),(0,W.useEffect)(()=>L(null),[e,X?.id]),Ae($,`${Z?.id??``}:${fe??``}:${pe??``}`,o,Z?.id),!e)return(0,Y.jsx)(M,{className:u(`min-h-[420px] rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,a),title:`选择一次运行`,description:`查看动态 ReAct 活动、实时模型输出和独立发布结果。`});if(s.error)return(0,Y.jsx)(`div`,{className:a,children:(0,Y.jsx)(i,{error:s.error})});if(!H)return(0,Y.jsx)(`div`,{className:u(`h-80 animate-pulse rounded bg-[var(--surface-2)]`,a)});let ye=H.run.status===A.Failed||H.run.status===A.NeedsAttention&&G?.status===A.NeedsAttention,be=[{value:`main`,label:`主流程`,icon:(0,Y.jsx)(g,{className:`size-3.5`})},{value:`publication`,label:`发布`,count:K.length,icon:(0,Y.jsx)(le,{className:`size-3.5`})}],xe=(0,Y.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center justify-between gap-x-5 border-t border-[var(--border)] px-4 sm:px-5`,children:[(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`运行内容视图`,className:`flex h-11 items-stretch gap-5`,children:be.map(e=>{let t=q===e.value;return(0,Y.jsxs)(`button`,{id:`${R}-${e.value}-tab`,type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`${R}-${e.value}-panel`,onClick:()=>ge(e.value),className:u(`relative inline-flex min-w-0 items-center gap-1.5 text-xs font-medium text-[var(--muted-strong)] transition-colors duration-[var(--motion-fast)] ease-[var(--ease-standard)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)] focus-visible:ring-offset-2`,t&&`font-semibold text-[var(--ink)]`),children:[e.icon,(0,Y.jsx)(`span`,{children:e.label}),e.count===void 0?null:(0,Y.jsx)(`span`,{className:u(`min-w-5 rounded px-1.5 py-0.5 text-center text-[10px] font-semibold leading-4`,t?`bg-[var(--surface-3)] text-[var(--ink)]`:`bg-[var(--surface-2)] text-[var(--muted)]`),children:e.count}),t?(0,Y.jsx)(b.span,{layoutId:`run-section-indicator-${R}`,className:`absolute inset-x-0 bottom-0 h-0.5 rounded-t bg-[var(--ink)]`,transition:{duration:z?0:.24,ease:[.16,1,.3,1]}}):null]},e.value)})}),(0,Y.jsxs)(`span`,{className:`py-2 text-[11px] text-[var(--muted)]`,children:[`活动流:`,Re(s.activityStreamState),` · 模型流:`,Re(s.modelStreamState)]})]}),Se=(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`header`,{className:`p-4 sm:p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`truncate text-base font-semibold`,children:o?ce(H.run):N(H.run)}),(0,Y.jsx)(f,{tone:I(H.run.status),children:P(H.run.status)}),H.run.trigger.kind===`automation`?(0,Y.jsx)(f,{children:`自动任务`}):null]}),(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:[o?null:(0,Y.jsxs)(Y.Fragment,{children:[H.run.planName??`独立发布`,` · `]}),o?null:(0,Y.jsxs)(Y.Fragment,{children:[se(H.run),` · `]}),new Date(H.run.createdAt).toLocaleString()]}),U.data?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-[var(--muted)]`,children:H.run.kind===`publication`&&U.data.generationRun?`内容来自 ${ce(U.data.generationRun)}`:`已生成可发布内容包`}):null]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[U.data?(0,Y.jsxs)(r,{onClick:()=>j(!0),children:[(0,Y.jsx)(v,{className:`size-4`}),`预览内容`]}):null,ye?(0,Y.jsxs)(r,{loading:B.isPending,onClick:()=>B.mutate(),children:[(0,Y.jsx)(h,{className:`size-4`}),`恢复运行`]}):null]})]}),H.run.error?(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-[var(--danger)]`,children:H.run.error}):null]}),xe]});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{className:u(`grid gap-4`,o&&`h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden`,a),children:[Se,(0,Y.jsx)(`div`,{ref:$,className:u(`grid gap-4`,o&&`scrollbar-stable min-h-0 content-start overflow-y-auto overscroll-contain`),children:(0,Y.jsx)(D,{initial:!1,mode:`wait`,custom:S,children:(0,Y.jsx)(b.div,{id:`${R}-${q}-panel`,role:`tabpanel`,"aria-labelledby":`${R}-${q}-tab`,custom:S,initial:{opacity:0,x:z?0:S*18,filter:z?`none`:`blur(3px)`},animate:{opacity:1,x:0,filter:`none`},exit:{opacity:0,x:z?0:S*-12,filter:z?`none`:`blur(2px)`},transition:{duration:z?0:.22,ease:[.16,1,.3,1]},children:q===`publication`&&!K.length?(0,Y.jsx)(M,{className:`min-h-64 rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,title:`仅生成可发布内容包`,description:`本次运行没有配置发布目的地。`}):(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[q===`publication`?(0,Y.jsx)(de,{sessions:K,selected:X?.id,sourceTitle:N(H.run),onSelect:ve}):null,(0,Y.jsx)(D,{initial:!1,mode:`wait`,custom:T,children:(0,Y.jsx)(b.div,{custom:T,initial:{opacity:0,x:z?0:T*14},animate:{opacity:1,x:0},exit:{opacity:0,x:z?0:T*-10},transition:{duration:z?0:.18,ease:[.16,1,.3,1]},className:`min-w-0`,children:Z?(0,Y.jsx)(_e,{session:Z,activities:s.activities.filter(e=>e.sessionId===Z.id),modelEvents:s.modelEvents.filter(e=>e.sessionId===Z.id),retrying:V.isPending,hideHeader:Z.kind===O.Main,onPreviewCover:me(Z)?()=>L(`cover`):void 0,onPreviewHtml:me(Z)?()=>L(`html`):void 0,onRetry:Z.destination&&Z.status===A.Failed?()=>V.mutate(Z.destination.destinationId):void 0}):(0,Y.jsx)(M,{title:`会话尚未开始`,description:`运行开始后会实时显示活动。`})},Z?.id??`${q}-empty`)})]})},q)})})]}),U.data?(0,Y.jsx)(ae,{open:k,onOpenChange:j,title:U.data.contentPackage.contentPackage.document.title,description:`${U.data.contentPackage.contentPackage.schemaVersion} · 运行产物`,size:`wide`,children:(0,Y.jsx)(oe,{value:U.data.contentPackage,generationRun:U.data.generationRun})}):null,(0,Y.jsx)(he,{mode:F,preview:Q.data,pending:Q.isPending,error:Q.error,onOpenChange:e=>{e||L(null)}})]})}export{ze as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./execution-Brd94hIY.js";import"./types-D57tnOAh.js";function t(t){return t===e.Queued?`等待运行`:t===e.Running?`运行中`:t===e.Succeeded?`已完成`:t===e.Partial?`部分完成`:t===e.NeedsAttention?`需要处理`:`失败`}function n(t){return t===e.Running?`info`:t===e.Succeeded?`success`:t===e.Partial||t===e.NeedsAttention?`warning`:t===e.Failed?`danger`:`neutral`}function r(e){return e.title||e.requestedTopic||e.planName||(e.kind===`publication`?`内容发布`:`内容生成`)}function i(e){let t=[e.title,e.requestedTopic].find(t=>t?.trim()&&t.trim()!==e.planName?.trim());if(t)return t.trim();let n=new Date(e.createdAt);return Number.isNaN(n.getTime())?`本次运行`:n.toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function a(e){return e.kind===`publication`?c(e):e.publicationSummary.total?`主流程 · ${c(e)}`:`主流程 · 仅生成内容包`}function o(e){return e.kind===`main`?`主流程`:`${e.destination?.accountName??`发布账号`} · ${s(e.destination?.publicationType)}`}function s(e){return e===`article`?`图文`:e===`video`?`视频`:e===`audio`?`音频`:e||`发布`}function c(e){let t=e.publicationSummary;return t.total?`发布 ${t.succeeded}/${t.total}`:`尚未开始发布`}export{r as a,a as i,t as n,o,n as r,i as t};
@@ -0,0 +1,9 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{dn as t,ln as n}from"./index-Bx1uywm3.js";import{a as r,c as i,i as a,l as o,o as s,r as c,s as l}from"./react-OqyHmgtK.js";var u=n(),d=e(t(),1);function f(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function p(...e){return t=>{let n=!1,r=e.map(e=>{let r=f(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():f(e[t],null)}}}}function m(...e){return d.useCallback(p(...e),e)}var h=class extends d.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(r(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=r(e)&&e.offsetWidth||0,i=r(e)&&e.offsetHeight||0,a=getComputedStyle(t),o=this.props.sizeRef.current;o.height=parseFloat(a.height),o.width=parseFloat(a.width),o.top=t.offsetTop,o.left=t.offsetLeft,o.right=n-o.width-o.left,o.bottom=i-o.height-o.top,o.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function g({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:o}){let s=(0,d.useId)(),c=(0,d.useRef)(null),l=(0,d.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:f}=(0,d.useContext)(a),p=m(c,o===!1?void 0:e.props?.ref??e?.ref);return(0,d.useInsertionEffect)(()=>{let{width:e,height:a,top:u,left:d,right:p,bottom:m,direction:h}=l.current;if(t||o===!1||!c.current||!e||!a)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${d}`:g?`left: ${d}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${u}`;c.current.dataset.motionPopId=s;let y=document.createElement(`style`);f&&(y.nonce=f);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
2
+ [data-motion-pop-id="${s}"] {
3
+ position: absolute !important;
4
+ width: ${e}px !important;
5
+ height: ${a}px !important;
6
+ ${_}px !important;
7
+ ${v}px !important;
8
+ }
9
+ `),()=>{c.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,u.jsx)(h,{isPresent:t,childRef:c,sizeRef:l,pop:o,children:o===!1?e:d.cloneElement(e,{ref:p})})}var _=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:o,mode:c,anchorX:f,anchorY:p,root:m})=>{let h=i(v),_=(0,d.useId)(),y=(0,d.useRef)(n),b=(0,d.useRef)(r);l(()=>{y.current=n,b.current=r});let x=!0,S=(0,d.useMemo)(()=>(x=!1,{id:_,initial:t,isPresent:n,custom:a,onExitComplete:e=>{h.set(e,!0);for(let e of h.values())if(!e)return;r&&r()},register:e=>(h.set(e,!1),()=>{h.delete(e),!y.current&&!h.size&&b.current?.()})}),[n,h,r]);return o&&x&&(S={...S}),(0,d.useMemo)(()=>{h.forEach((e,t)=>h.set(t,!1))},[n]),d.useEffect(()=>{!n&&!h.size&&r&&r()},[n]),e=(0,u.jsx)(g,{pop:c===`popLayout`,isPresent:n,anchorX:f,anchorY:p,root:m,children:e}),(0,u.jsx)(s.Provider,{value:S,children:e})};function v(){return new Map}var y=e=>e.key||``;function b(e){let t=[];return d.Children.forEach(e,e=>{(0,d.isValidElement)(e)&&t.push(e)}),t}var x=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:s=`sync`,propagate:f=!1,anchorX:p=`left`,anchorY:m=`top`,root:h})=>{let[g,v]=c(f),x=(0,d.useMemo)(()=>b(e),[e]),S=f&&!g?[]:x.map(y),C=(0,d.useRef)(!0),w=(0,d.useRef)(x),T=i(()=>new Map),E=(0,d.useRef)(new Set),[D,O]=(0,d.useState)(x),[k,A]=(0,d.useState)(x);l(()=>{C.current=!1,w.current=x;for(let e=0;e<k.length;e++){let t=y(k[e]);S.includes(t)?(T.delete(t),E.current.delete(t)):T.get(t)!==!0&&T.set(t,!1)}},[k,S.length,S.join(`-`)]);let j=[];if(x!==D){let e=[...x];for(let t=0;t<k.length;t++){let n=k[t],r=y(n);S.includes(r)||(e.splice(t,0,n),j.push(n))}return s===`wait`&&j.length&&(e=j),A(b(e)),O(x),null}let{forceRender:M}=(0,d.useContext)(o);return(0,u.jsx)(u.Fragment,{children:k.map(e=>{let i=y(e),o=f&&!g?!1:x===k||S.includes(i);return(0,u.jsx)(_,{isPresent:o,initial:!C.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:s,root:h,onExitComplete:o?void 0:()=>{if(E.current.has(i))return;if(T.has(i))E.current.add(i),T.set(i,!0);else return;let e=!0;T.forEach(t=>{t||(e=!1)}),e&&(M?.(),A(w.current),f&&v?.(),r&&r())},anchorX:p,anchorY:m,children:e},i)})})};export{x as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{$ as t,Ft as n,Lt as r,U as i,W as a,X as o,cn as s,dn as c,in as l,ln as u,nn as d,nt as f,on as p,q as m,rn as h,sn as g,tn as _,tt as ee}from"./index-Bx1uywm3.js";import{t as v}from"./check-_AvUITNy.js";import{t as y}from"./chevron-right-BcV2-ijN.js";import{t as b}from"./refresh-cw-BB9_0X86.js";import{l as x,n as S,r as C,t as w}from"./app-dialog-CBRjH8y0.js";import{t as T}from"./input-Br6N0XCJ.js";import{t as E}from"./fingerprint-pattern-CVznkwfS.js";import{t as D}from"./layout-template-11JYpJ5n.js";import{i as O,n as k,r as A,t as j}from"./use-onboarding-fKNsbNhX.js";import{t as M}from"./newspaper-BF6EkBWC.js";import{t as N}from"./radio-tower-CS59Tvfq.js";import{t as P}from"./sparkles-C9YU6Kr5.js";import{n as F,t as I}from"./react-OqyHmgtK.js";import{n as te,t as L}from"./notifications-wLr7xSyr.js";import{a as ne,n as re,u as ie}from"./becomeopc-EvwYWHkB.js";import{n as ae}from"./use-workspace-snapshot-MZKeTfAJ.js";import{t as oe}from"./arrow-right-Bm6j4CRT.js";function se(e){let t=s({warn:e?.router===void 0}),n=e?.router||t;return g(n.stores.__store,p(e,n))}var ce=o(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),R=o(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),z=o(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),B=o(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),V=o(`library-big`,[[`rect`,{width:`8`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`oynpb5`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z`,key:`1qboyk`}]]),H=o(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),U=o(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),W=o(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),G=o(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),le=o(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),ue=o(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),de=o(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),fe=o(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),K=o(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),q=e(c(),1),J=[{id:`today`,label:`工作台`,shortLabel:`台`,description:`当前行动`,intent:`开始内容任务。`,icon:B,items:[{to:`/automations`,label:`任务`,description:`内容与发布编排`,detail:`选择内容方案、发布账号和触发方式。`,icon:A},{to:`/workspace`,label:`今天`,description:`下一步行动`,detail:`查看准备度和最近运行。`,icon:B}]},{id:`content`,label:`内容准备`,shortLabel:`内容`,description:`身份、素材与预设`,intent:`维护稳定内容输入。`,icon:M,items:[{to:`/identities`,label:`内容身份`,description:`定位与语气`,detail:`维护定位、受众、语气和表达边界。`,icon:E},{to:`/knowledge`,label:`知识库`,description:`参考资料`,detail:`上传并维护内容生产所需的长期参考材料。`,icon:V},{to:`/sources`,label:`输入来源`,description:`动态数据输入`,detail:`维护运行时需要抓取的网页和数据来源。`,icon:M},{to:`/content-plans`,label:`内容方案`,description:`ReAct 策略与工具`,detail:`组合 Agent 策略、身份、知识库、授权工具和发布配置。`,icon:H}]},{id:`publish`,label:`发布`,shortLabel:`发布`,description:`账号与目标`,intent:`管理渠道和扇出关系。`,icon:N,items:[{to:`/publishing`,label:`发布账号`,description:`身份 + 账号`,detail:`维护渠道、接入方式与账号凭证。`,icon:N},{to:`/publishing/styles`,label:`写作风格`,description:`平台语感与结构`,detail:`维护内置与自定义写作风格,在发布阶段按目标平台受控改写并保留证据引用。`,icon:de},{to:`/publishing/templates`,label:`排版模板`,description:`渠道视觉布局`,detail:`按渠道维护不可变排版模板版本与发布视觉规则。`,icon:D}]},{id:`records`,label:`记录`,shortLabel:`记录`,description:`任务与成品`,intent:`查看可靠执行和内容资产。`,icon:G,items:[{to:`/jobs`,label:`运行记录`,description:`执行状态与检查点`,detail:`查看每次运行的状态、失败原因与恢复操作。`,icon:G},{to:`/library`,label:`内容包`,description:`成品与发布`,detail:`查看渠道无关的内容包并发布。`,icon:z}]},{id:`system`,label:`设置`,shortLabel:`设置`,description:`连接与架构`,intent:`维护外部能力和扩展。`,icon:K,items:[{to:`/connections`,label:`连接`,description:`外部服务能力`,detail:`维护模型、图片、通知和渠道 API 连接。`,icon:ce},{to:`/settings`,label:`运行架构`,description:`扩展注册`,detail:`查看 Agent 策略、工具和渠道发布类型。`,icon:K}]}],Y=J.flatMap(e=>[...e.items]);function pe(e){let t=Y.flatMap(e=>[e.to,...e.activePrefixes??[]].map(t=>({candidate:e,prefix:t}))).filter(({prefix:t})=>e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)).sort((e,t)=>t.prefix.length-e.prefix.length)[0]?.candidate??Y[0];return{domain:J.find(e=>e.items.some(e=>e.to===t.to))??J[0],item:t}}var X=u();function me({open:e,onOpenChange:t}){let[n,r]=(0,q.useState)(``),i=l(),a=(0,q.useMemo)(()=>{let e=n.trim().toLowerCase();return e?Y.filter(t=>`${t.label}${t.description}${t.detail}`.toLowerCase().includes(e)):Y},[n]);return(0,q.useEffect)(()=>{let n=n=>{(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`k`&&(n.preventDefault(),t(!e))};return globalThis.addEventListener(`keydown`,n),()=>globalThis.removeEventListener(`keydown`,n)},[e,t]),(0,X.jsxs)(w,{open:e,onOpenChange:t,variant:`dialog`,title:`快速跳转`,description:`搜索页面和配置入口。`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(fe,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-[var(--muted)]`}),(0,X.jsx)(T,{autoFocus:!0,className:`pl-9`,placeholder:`搜索页面`,value:n,onChange:e=>r(e.target.value)})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-1`,children:a.map(e=>{let n=e.icon;return(0,X.jsxs)(`button`,{className:`flex min-h-12 items-center gap-3 rounded px-3 text-left hover:bg-[var(--surface-2)]`,onClick:()=>{t(!1),i({to:e.to})},children:[(0,X.jsx)(n,{className:`size-4`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{className:`block text-sm`,children:e.label}),(0,X.jsx)(`span`,{className:`text-xs text-[var(--muted)]`,children:e.detail})]})]},e.to)})})]})}function he({className:e,...t}){return(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 64 64`,"aria-hidden":`true`,className:f(`size-8 shrink-0`,e),...t,children:[(0,X.jsx)(`rect`,{width:`64`,height:`64`,rx:`16`,fill:`#101114`}),(0,X.jsx)(`path`,{fill:`#fff`,d:`M16 19h32v8H36v21h-8V27H16z`}),(0,X.jsx)(`path`,{fill:`#e85f35`,d:`M41 33h7a10 10 0 0 1-10 10h-2v-7h2a3 3 0 0 0 3-3z`})]})}function ge({activeItem:e,collapsed:t,open:n,onClose:r,onSelect:i}){let o=l(),{data:s}=ie(),c=re(s);return(0,X.jsx)(`aside`,{"aria-label":`工作台导航`,className:f(`fixed inset-y-0 left-0 z-40 flex w-[268px] max-w-[calc(100vw-20px)] flex-none -translate-x-full flex-col overflow-hidden border-r border-[var(--border)] bg-[var(--surface-chrome)] shadow-xl transition-[transform,width] duration-[var(--duration-base)] ease-[var(--ease-out)]`,`lg:static lg:z-auto lg:h-full lg:translate-x-0 lg:rounded-[var(--radius-lg)] lg:border lg:border-[var(--border)] lg:shadow-[var(--shadow-sm)]`,t?`lg:w-[72px]`:`lg:w-[228px]`,n&&`translate-x-0`),children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:f(`flex h-[56px] shrink-0 items-center gap-2 border-b border-[color-mix(in_srgb,var(--border)_75%,transparent)] px-3`,t&&`lg:justify-center lg:px-2`),children:[(0,X.jsxs)(`button`,{type:`button`,className:f(`flex min-w-0 flex-1 items-center gap-2.5 rounded-[var(--radius-sm)] px-1.5 py-1 text-left transition-colors duration-[var(--duration-fast)] hover:bg-[var(--overlay)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,t&&`lg:flex-none lg:px-1`),onClick:()=>{i(),o({to:`/workspace`})},children:[(0,X.jsx)(he,{className:`size-8 shrink-0`}),(0,X.jsxs)(`span`,{className:f(`min-w-0`,t&&`lg:hidden`),children:[(0,X.jsx)(`span`,{className:`block text-[10px] font-semibold uppercase tracking-[0.06em] text-[var(--muted)]`,children:`TrendPublish`}),(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold leading-tight tracking-[var(--tracking-heading)] text-[var(--ink)]`,children:`内容工作台`})]})]}),(0,X.jsx)(a,{label:`关闭导航`,variant:`ghost`,className:`size-8 min-h-0 lg:hidden`,onClick:r,children:(0,X.jsx)(x,{className:`size-4`})})]}),(0,X.jsx)(`nav`,{"aria-label":`工作台入口`,className:f(`scrollbar-stable min-h-0 flex-1 overflow-y-auto px-2.5 py-3`,t&&`lg:px-2`),children:(0,X.jsx)(`div`,{className:`grid gap-3.5`,children:J.map(n=>(0,X.jsxs)(`section`,{className:`grid gap-0.5`,children:[(0,X.jsx)(`div`,{className:f(`mb-1 px-2 text-[11px] font-semibold uppercase tracking-[0.04em] text-[var(--muted)]`,t&&`lg:sr-only`),children:n.label}),n.items.map(n=>{let r=n.icon,a=n.to===e.to;return(0,X.jsxs)(d,{to:n.to,onClick:i,"aria-current":a?`page`:void 0,title:t?n.label:void 0,className:f(`relative flex h-[34px] items-center gap-2.5 rounded-[var(--radius-sm)] px-2 text-sm transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,t&&`lg:mx-auto lg:size-9 lg:justify-center lg:px-0`,a?`font-medium text-[var(--ink)]`:`text-[var(--muted-strong)] hover:bg-[var(--overlay)] hover:text-[var(--ink)]`),children:[a&&!t&&(0,X.jsx)(I.span,{layoutId:`nav-active-bg`,"aria-hidden":!0,className:`absolute inset-0 rounded-[var(--radius-sm)] bg-[var(--surface-3)]`,transition:{type:`spring`,stiffness:420,damping:34}}),a&&t&&(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-[var(--radius-sm)] bg-[var(--surface-3)]`}),(0,X.jsx)(r,{className:`relative z-[1] size-4 shrink-0`}),(0,X.jsx)(`span`,{className:f(`relative z-[1] truncate`,t&&`lg:hidden`),children:n.label})]},n.to)})]},n.id))})}),(0,X.jsx)(`div`,{className:f(`shrink-0 border-t border-[color-mix(in_srgb,var(--border)_75%,transparent)] p-2.5`,t&&`lg:p-2`),children:(0,X.jsxs)(d,{to:`/connections`,search:{page:1},onClick:i,title:t?`BecomeOPC 订阅(${c.label})`:void 0,className:f(`group relative flex items-center gap-2.5 rounded-[var(--radius-sm)] border transition-colors duration-[var(--duration-fast)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,s?.entitled?`border-[var(--border)] bg-[var(--surface-2)] hover:bg-[var(--surface-3)]`:`border-[var(--accent-border)] bg-[var(--accent-bg)] hover:bg-[color-mix(in_srgb,var(--accent-bg)_80%,var(--surface))]`,t?`lg:mx-auto lg:size-9 lg:justify-center lg:px-0`:`px-2.5 py-2`),children:[(0,X.jsxs)(`span`,{className:`relative flex size-6 shrink-0 items-center justify-center rounded-[6px] bg-[var(--surface)] text-[var(--accent)] shadow-[var(--shadow-xs)]`,children:[(0,X.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t?(0,X.jsx)(`span`,{"aria-hidden":!0,className:f(`absolute -top-0.5 -right-0.5 size-2 rounded-full ring-2 ring-[var(--surface-chrome)]`,s?.entitled?`bg-[var(--success)]`:s?.expired?`bg-[var(--danger)]`:`bg-[var(--accent)]`)}):null]}),(0,X.jsxs)(`span`,{className:f(`min-w-0 flex-1`,t&&`lg:hidden`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-semibold text-[var(--ink)]`,children:`BecomeOPC`}),(0,X.jsx)(te,{tone:s?.connected?c.tone:`accent`,className:`min-h-4 px-1 text-[10px]`,children:s?.connected?c.label:`去订阅`})]}),(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-[var(--muted-strong)]`,children:s?.entitled?`${ne(s.plan)} · 托管 Relay`:s?.expired?`订阅已过期 · 点击续费`:`订阅托管微信 Relay`})]}),(0,X.jsx)(y,{className:f(`size-3.5 shrink-0 text-[var(--muted)] transition-transform duration-[var(--duration-fast)] group-hover:translate-x-0.5`,t&&`lg:hidden`),"aria-hidden":!0})]})})]})})}function _e({channels:e,value:t,onChange:n}){let r=F();return(0,X.jsx)(`div`,{className:`border-t border-[color-mix(in_srgb,var(--border)_72%,transparent)] px-4 sm:px-5`,children:(0,X.jsxs)(`div`,{className:`flex min-h-11 min-w-0 items-stretch gap-5 overflow-x-auto scrollbar-stable`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0 items-center text-sm font-medium text-[var(--muted-strong)]`,children:`渠道`}),(0,X.jsx)(`nav`,{"aria-label":`发布渠道`,className:`flex min-w-max items-stretch gap-1`,children:e.map(e=>{let i=e.id===t;return(0,X.jsxs)(`button`,{type:`button`,"aria-current":i?`page`:void 0,className:f(`relative min-w-20 px-3 text-sm font-medium text-[var(--muted)] transition-colors duration-[var(--motion-fast)] ease-[var(--ease-standard)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,i&&`text-[var(--ink)]`),onClick:()=>n(e.id),children:[e.name,i?(0,X.jsx)(I.span,{layoutId:`publishing-channel-indicator`,"aria-hidden":!0,className:`absolute inset-x-3 bottom-0 h-px bg-[var(--ink)]`,transition:{duration:r?0:.24,ease:[.16,1,.3,1]}}):null]},e.id)})})]})})}function Z({className:e}){return(0,X.jsx)(`div`,{className:f(`animate-pulse rounded-[var(--radius-sm)] bg-[var(--surface-3)]`,e)})}function ve(){let e=l(),{steps:t,pending:n}=k(),r=n[0];if(!r)return null;let a=t.findIndex(e=>e.id===r.id);return(0,X.jsxs)(w,{open:!0,variant:`dialog`,onOpenChange:e=>{e||j.dismiss()},title:`开始配置 TrendPublish`,description:`第 ${a+1} / ${t.length} 步 · 走完即可发布第一篇`,children:[(0,X.jsx)(`ol`,{className:`grid gap-1.5`,children:t.map(e=>{let t=e.id===r.id;return(0,X.jsxs)(`li`,{className:t?`flex items-center gap-2 rounded-[var(--radius-sm)] bg-[var(--surface-2)] px-2.5 py-2 text-sm font-medium text-[var(--ink)]`:`flex items-center gap-2 px-2.5 py-1.5 text-sm text-[var(--muted-strong)]`,children:[e.done?(0,X.jsx)(v,{className:`size-4 shrink-0 text-[var(--success)]`}):(0,X.jsx)(O,{className:`size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:e.done?`line-through opacity-70`:``,children:e.title}),e.optional?(0,X.jsx)(`span`,{className:`text-xs opacity-60`,children:`可选`}):null]},e.id)})}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] p-3.5`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-[var(--ink)]`,children:r.title}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:r.description})]}),(0,X.jsxs)(S,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>j.dismiss(),children:`退出引导`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>j.skip(r.id),children:`跳过此步`}),(0,X.jsxs)(i,{variant:`primary`,size:`sm`,onClick:()=>{j.dismiss(),r.to===`/connections`?e({to:`/connections`,search:{page:1}}):r.to===`/publishing`?e({to:`/publishing`,search:{page:1,channel:void 0}}):r.to===`/content-plans`?e({to:`/content-plans`,search:{page:1}}):r.to===`/automations`?e({to:`/automations`,search:{page:1}}):e({to:r.to})},children:[`去配置`,(0,X.jsx)(oe,{className:`size-3.5`})]})]})]})]})}var Q=`trendpublish.sidebar.collapsed`,ye=420;function be(){let{logout:e}=n(),[t,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(Ee),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),m=(0,q.useRef)(null),h=l(),g=se({select:e=>e.location}),v=g.pathname,{domain:y,item:b}=pe(v),x=ae(),S=k(),w=r(),T=Ce({activeDomain:y,activeItem:b,pathname:v,identities:x.data?.identities??[]}),E=x.error,D=ee(E),O=x.data?.channelDefinitions??[],A=g.search,j=O.find(e=>e.id===A.channel)??O[0],M=v.startsWith(`/publishing`)&&O.length>0;(0,q.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let N=e=>{if(b.to===`/publishing/styles`)h({to:`/publishing/styles`,search:{channel:e,page:1}});else if(b.to===`/publishing/templates`){let t=O.find(t=>t.id===e),n=(x.data?.publicationTypeProfiles??[]).filter(t=>t.channel===e&&t.layout),r=n.find(e=>e.type===t?.defaultPublicationType)?.type??n[0]?.type;h({to:`/publishing/templates`,search:{channel:e,publicationType:r,page:1}})}else h({to:`/publishing`,search:{channel:e,page:1}})},P=(0,q.useCallback)(async()=>{if(!u){m.current&&clearTimeout(m.current),p(!1),d(!0);try{await Promise.all([w.invalidateQueries(),new Promise(e=>setTimeout(e,ye))]),p(!0),L.success(`数据已刷新`),m.current=setTimeout(()=>p(!1),1200)}catch(e){L.error(`刷新失败`,e)}finally{d(!1)}}},[w,u]);return(0,X.jsxs)(`div`,{className:`flex h-dvh min-h-0 flex-col overflow-hidden text-[var(--ink)] lg:flex-row lg:gap-3 lg:p-3`,children:[(0,X.jsx)(ge,{activeItem:b,collapsed:s,open:t,onClose:()=>i(!1),onSelect:()=>i(!1)}),t&&(0,X.jsx)(`button`,{type:`button`,"aria-label":`关闭导航遮罩`,className:`fixed inset-0 z-30 bg-black/36 backdrop-blur-[2px] lg:hidden`,onClick:()=>i(!1)}),(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 p-2 lg:gap-3 lg:p-0`,children:[(0,X.jsx)(xe,{header:T,collapsed:s,refreshing:u,justRefreshed:f,onOpenNavigation:()=>i(!0),onToggleCollapsed:()=>{c(e=>{let t=!e;return De(t),t})},onOpenCommand:()=>o(!0),onRefresh:()=>void P(),onLogout:e,channelNavigation:M?(0,X.jsx)(_e,{channels:O,value:j?.id,onChange:N}):void 0}),(0,X.jsx)(`section`,{"aria-label":`主工作区内容`,className:`relative flex min-h-0 flex-1 flex-col overflow-hidden rounded-[var(--radius-lg)] border border-[var(--border)] bg-[var(--surface)] shadow-[var(--shadow-sm)]`,children:(0,X.jsx)(C,{outletClassName:`p-3 sm:p-5`,children:(0,X.jsxs)(`main`,{className:`mx-auto grid w-full min-w-0 gap-3`,children:[E&&(0,X.jsx)(Te,{error:E,unauthorized:D,refreshing:u,onRefresh:()=>void P(),onLogout:e}),(0,X.jsx)(`div`,{className:`motion-page`,children:(0,X.jsx)(q.Suspense,{fallback:(0,X.jsx)($,{activeItem:b}),children:(0,X.jsx)(_,{})})})]})})})]}),(0,X.jsx)(me,{open:a,onOpenChange:o}),S.showWizard?(0,X.jsx)(ve,{}):null]})}function $({activeItem:e}){return(0,X.jsxs)(`section`,{"aria-busy":`true`,"aria-label":`${e.label}加载中`,className:`grid gap-5`,children:[(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(Z,{className:`h-4 w-24`}),(0,X.jsx)(Z,{className:`h-8 w-[min(420px,70%)]`}),(0,X.jsx)(Z,{className:`h-4 w-[min(560px,82%)]`})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1.15fr)_minmax(280px,0.85fr)]`,children:[(0,X.jsx)(Z,{className:`min-h-[260px]`}),(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(Z,{className:`h-32`}),(0,X.jsx)(Z,{className:`h-32`})]})]})]})}function xe({header:e,collapsed:t,refreshing:n,justRefreshed:r,onOpenNavigation:o,onToggleCollapsed:s,onOpenCommand:c,onRefresh:l,onLogout:u,channelNavigation:d}){return(0,X.jsxs)(`header`,{className:`flex-none overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] shadow-[var(--shadow-sm)]`,children:[(0,X.jsxs)(`div`,{className:`flex min-h-[54px] items-center justify-between gap-3 px-3 sm:px-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,X.jsx)(a,{label:`打开导航`,variant:`ghost`,className:`size-8 min-h-0 lg:hidden`,onClick:o,children:(0,X.jsx)(W,{className:`size-4`})}),(0,X.jsx)(a,{label:t?`展开侧栏`:`收起侧栏`,variant:`ghost`,className:`hidden size-8 min-h-0 lg:inline-flex`,onClick:s,children:t?(0,X.jsx)(ue,{className:`size-4`}):(0,X.jsx)(le,{className:`size-4`})}),(0,X.jsx)(`span`,{className:`hidden h-4 w-px shrink-0 bg-[var(--border)] lg:block`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(Se,{breadcrumbs:e.breadcrumbs}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-baseline gap-2.5`,children:[(0,X.jsx)(`h1`,{className:`truncate text-[15px] font-semibold leading-5 tracking-[var(--tracking-heading)] text-[var(--ink)]`,children:e.title}),(0,X.jsx)(`p`,{className:`hidden truncate text-xs text-[var(--muted)] md:block`,children:e.detail})]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,X.jsxs)(i,{size:`sm`,variant:`secondary`,className:`hidden min-w-[144px] justify-start bg-[var(--surface-2)] text-[var(--muted-strong)] shadow-none hover:bg-[var(--surface-3)] md:inline-flex`,onClick:c,children:[(0,X.jsx)(R,{className:`size-3.5`}),`快速跳转`,(0,X.jsx)(`span`,{className:`ml-auto rounded border border-[var(--border)] bg-[var(--surface)] px-1.5 py-0.5 text-[10px] leading-none text-[var(--muted)]`,children:`⌘K`})]}),(0,X.jsx)(a,{label:n?`正在刷新数据`:`刷新数据`,variant:`ghost`,className:`size-8 min-h-0`,disabled:n,"aria-busy":n||void 0,onClick:l,children:r&&!n?(0,X.jsx)(v,{className:`size-4 text-[var(--success)]`}):(0,X.jsx)(b,{className:f(`size-4`,n&&`animate-spin text-[var(--ink)]`)})}),(0,X.jsx)(a,{label:`退出工作台`,variant:`ghost`,className:`size-8 min-h-0`,onClick:u,children:(0,X.jsx)(U,{className:`size-4`})})]})]}),d]})}function Se({breadcrumbs:e}){return(0,X.jsx)(`nav`,{"aria-label":`当前位置`,className:`flex min-w-0 items-center gap-1.5 text-[11px] font-medium text-[var(--muted)]`,children:e.map((t,n)=>{let r=n===e.length-1;return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[t.to&&!r?(0,X.jsx)(d,{to:t.to,className:`truncate rounded-[6px] transition hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:t.label}):(0,X.jsx)(`span`,{"aria-current":r?`page`:void 0,className:f(`truncate`,r&&`text-[var(--muted-strong)]`),children:t.label}),!r&&(0,X.jsx)(y,{className:`size-3.5 shrink-0`})]},`${t.label}-${n}`)})})}function Ce({activeDomain:e,activeItem:t,pathname:n,identities:r}){let i=[{label:e.label,to:e.items[0]?.to},{label:t.label}],a=we(n);if(n===`/content-plans/new`||/^\/content-plans\/[^/]+\/edit$/.test(n)){let r=n===`/content-plans/new`;return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:r?`新建`:`编辑`}],title:r?`新建内容方案`:`编辑内容方案`,detail:`配置 ReAct 策略、身份、授权工具与发布账号。`}}if(/^\/publishing\/templates\/sessions\/[^/]+$/.test(n))return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:`制作会话`}],title:`模板制作`,detail:`左侧持续对话,右侧比较候选并生成真实内容预览。`};if(t.to===`/identities`&&a){let n=r.find(e=>e.id===a)?.name||`身份详情`;return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:n}],title:n,detail:`内容身份详情`}}return{breadcrumbs:i,title:t.label,detail:t.detail}}function we(e){let t=e.match(/^\/identities\/([^/?#]+)/);if(!t?.[1])return``;try{return decodeURIComponent(t[1])}catch{return t[1]}}function Te({error:e,unauthorized:n,refreshing:r,onRefresh:a,onLogout:o}){return(0,X.jsx)(`section`,{className:`rounded-[var(--radius)] border border-[var(--warning-border)] bg-[var(--warning-bg)] px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center text-[var(--warning)]`,children:(0,X.jsx)(m,{className:`size-4`})}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`p`,{className:`text-sm text-[var(--ink)]`,children:[(0,X.jsx)(`strong`,{className:`font-semibold`,children:n?`访问凭证需要更新`:`工作台数据暂时不可用`}),(0,X.jsx)(`span`,{className:`ml-2 text-[var(--muted-strong)]`,children:n?`当前访问凭证已失效或权限不足。请重新进入工作台。`:t(e)})]})})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2 sm:justify-end`,children:[(0,X.jsxs)(i,{type:`button`,variant:`secondary`,loading:r,onClick:a,children:[!r&&(0,X.jsx)(b,{className:`size-4`}),`重试`]}),n&&(0,X.jsxs)(i,{type:`button`,variant:`primary`,onClick:o,children:[(0,X.jsx)(U,{className:`size-4`}),`重新进入`]})]})]})})}function Ee(){return typeof localStorage>`u`?!1:localStorage.getItem(Q)===`true`}function De(e){typeof localStorage<`u`&&localStorage.setItem(Q,String(e))}function Oe(){let{isAuthenticated:e}=n();return e?(0,X.jsx)(be,{}):(0,X.jsx)(h,{to:`/`,replace:!0})}export{Oe as component};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{X as t,ct as n,dn as r,dt as i,ft as a,ln as o,lt as s,mt as c,nt as l,pt as u,un as d,ut as f}from"./index-Bx1uywm3.js";var p=t(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),m=e(d(),1),h=e(r(),1),g=o();function _({...e}){return(0,g.jsx)(n,{"data-slot":`dialog`,...e})}function v({...e}){return(0,g.jsx)(u,{"data-slot":`dialog-portal`,...e})}function y({...e}){return(0,g.jsx)(s,{"data-slot":`dialog-close`,...e})}function b({className:e,...t}){return(0,g.jsx)(a,{"data-slot":`dialog-overlay`,className:l(`dialog-overlay-motion fixed inset-0 z-50 bg-black/42`,e),...t})}function x({className:e,children:t,showCloseButton:n=!0,...r}){return(0,g.jsxs)(v,{"data-slot":`dialog-portal`,children:[(0,g.jsx)(b,{}),(0,g.jsx)(`div`,{className:`dialog-positioner`,children:(0,g.jsxs)(f,{"data-slot":`dialog-content`,className:l(`dialog-content-motion pointer-events-auto relative z-50 grid w-full max-w-[calc(100vw-2rem)] gap-4 rounded-lg border bg-background p-6 shadow-lg outline-none sm:max-w-lg`,e),...r,children:[t,n&&(0,g.jsxs)(s,{"data-slot":`dialog-close`,className:`absolute right-4 top-3.5 grid size-8 place-items-center rounded-[var(--radius-sm)] text-[var(--muted)] transition-colors hover:bg-[var(--surface-2)] hover:text-[var(--ink)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)] disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4`,children:[(0,g.jsx)(p,{}),(0,g.jsx)(`span`,{className:`sr-only`,children:`关闭`})]})]})})]})}function S({className:e,...t}){return(0,g.jsx)(`div`,{"data-slot":`dialog-header`,className:l(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function C({className:e,...t}){return(0,g.jsx)(c,{"data-slot":`dialog-title`,className:l(`text-lg leading-none font-semibold`,e),...t})}function w({className:e,...t}){return(0,g.jsx)(i,{"data-slot":`dialog-description`,className:l(`text-sm text-muted-foreground`,e),...t})}var T=(0,h.createContext)(null);function E(){return(0,h.useContext)(T)}function D({children:e,outletClassName:t}){let[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)([]),o=(0,h.useCallback)(e=>{a(t=>t.includes(e)?t:[...t,e])},[]),s=(0,h.useCallback)(e=>{a(t=>t.filter(t=>t!==e))},[]),c=(0,h.useMemo)(()=>({host:n,layers:i,register:o,unregister:s}),[n,i,o,s]),u=i.length>0;return(0,g.jsxs)(T.Provider,{value:c,children:[(0,g.jsx)(`div`,{className:l(`sheet-surface-outlet min-h-0 flex-1 overflow-y-auto overscroll-contain`,u&&`sheet-surface-receded`,t),"aria-hidden":u||void 0,children:e}),(0,g.jsx)(`div`,{ref:r,className:`sheet-host-portal`})]})}var O=240,k={sm:`rise-sheet-sm`,md:`rise-sheet-md`,lg:`rise-sheet-lg`};function A(e,t){let[n,r]=(0,h.useState)(e);return(0,h.useEffect)(()=>{if(e){r(!0);return}let n=globalThis.setTimeout(()=>r(!1),t);return()=>globalThis.clearTimeout(n)},[e,t]),{mounted:e||n,closing:!e&&n}}function j({open:e,onClose:t,title:n,description:r,size:i=`md`,escapeDisabled:a=!1,contentClassName:o,footerRef:s,children:c}){let{mounted:u,closing:d}=A(e,O),f=(0,h.useRef)(null),_=E(),v=(0,h.useId)(),y=_?.layers.includes(v)??!1,b=(0,h.useRef)(0);_&&y&&(b.current=_.layers.indexOf(v));let x=b.current,S=!_||!y||_.layers[_.layers.length-1]===v,C=y&&!S,w=C&&_?_.layers.length-1-x:0,T=_?.register,D=_?.unregister;(0,h.useEffect)(()=>{if(e&&T&&D)return T(v),()=>D(v)},[e,T,D,v]);let j=(0,h.useRef)(t);if(j.current=t,(0,h.useEffect)(()=>{e&&S&&f.current?.focus({preventScroll:!0})},[e,S]),(0,h.useEffect)(()=>{if(!e||!S)return;let t=e=>{e.key===`Escape`&&!a&&(e.preventDefault(),j.current())};return globalThis.addEventListener(`keydown`,t),()=>globalThis.removeEventListener(`keydown`,t)},[e,S,a]),!u||_&&!_.host)return null;let M=(0,g.jsxs)(`div`,{"data-slot":`rise-sheet-layer`,className:l(`rise-sheet-layer`,!_&&`rise-sheet-layer-fixed`,d&&`rise-sheet-closing`),style:{"--layer-index":x,"--sheet-exit":`${O}ms`},"aria-hidden":C||void 0,...C?{inert:``}:{},children:[(0,g.jsx)(`div`,{className:`rise-sheet-dismiss`,onClick:S?t:void 0,"aria-hidden":!0}),(0,g.jsxs)(`section`,{ref:f,"data-slot":`rise-sheet`,className:l(`rise-sheet-panel`,k[i],C&&`rise-sheet-behind`),style:{"--sheet-depth":w},role:`dialog`,"aria-modal":`true`,"aria-label":n,tabIndex:-1,children:[(0,g.jsx)(`div`,{className:`rise-sheet-grip`,"aria-hidden":!0}),(0,g.jsxs)(`header`,{className:`flex flex-none items-start justify-between gap-4 border-b border-[var(--border)] bg-[var(--surface)] px-6 py-3.5`,children:[(0,g.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,g.jsx)(`h2`,{className:`break-words text-base font-semibold leading-6 tracking-[var(--tracking-heading)] text-[var(--ink)]`,children:n}),r?(0,g.jsx)(`p`,{className:`break-words text-xs leading-5 text-[var(--muted-strong)]`,children:r}):null]}),(0,g.jsx)(`button`,{type:`button`,"aria-label":`关闭面板`,title:`关闭 (Esc)`,onClick:t,className:`grid size-8 shrink-0 place-items-center rounded-[var(--radius-sm)] text-[var(--muted)] transition-[background-color,color,transform] duration-[var(--duration-fast)] ease-[var(--ease-out)] hover:bg-[var(--overlay)] hover:text-[var(--ink)] active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:(0,g.jsx)(p,{className:`size-4`})})]}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-content`,className:l(`scrollbar-stable min-h-0 flex-1 overflow-y-auto overscroll-contain bg-[var(--surface)] px-6 py-5`,o),children:c}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-footer-root`,ref:s})]})]});return _?.host?(0,m.createPortal)(M,_.host):typeof document<`u`?(0,m.createPortal)(M,document.body):M}var M=(0,h.createContext)(null);function N({open:e,onOpenChange:t,title:n,description:r,size:i=`default`,variant:a=`sheet`,children:o,contentClassName:s}){let[c,u]=(0,h.useState)(null);return a===`sheet`?(0,g.jsx)(j,{open:e,onClose:()=>t(!1),title:n,description:r,size:i===`wide`?`lg`:i===`medium`?`md`:`sm`,contentClassName:s,footerRef:u,children:(0,g.jsx)(M.Provider,{value:c,children:o})}):(0,g.jsx)(_,{open:e,onOpenChange:t,children:(0,g.jsx)(x,{className:l(`grid max-h-[min(800px,calc(100dvh-24px))] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden rounded-[var(--radius)] border-[var(--border)] bg-[var(--surface)] p-0 shadow-[0_12px_32px_rgba(17,24,39,0.14)]`,i===`wide`?`sm:max-w-[min(1080px,calc(100vw-32px))]`:i===`medium`?`sm:max-w-[min(800px,calc(100vw-32px))]`:`sm:max-w-xl`),children:(0,g.jsxs)(M.Provider,{value:c,children:[(0,g.jsxs)(S,{className:`grid min-w-0 gap-1 border-b border-[var(--border)] bg-[var(--surface)] px-5 py-3.5 pr-14 text-left`,children:[(0,g.jsx)(C,{className:`min-w-0 break-words text-base font-semibold leading-6 tracking-[var(--tracking-heading)] text-[var(--ink)]`,children:n}),r?(0,g.jsx)(w,{className:`min-w-0 break-words text-xs leading-5 text-[var(--muted-strong)]`,children:r}):null]}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-content`,className:l(`scrollbar-stable min-h-0 overflow-y-auto overscroll-contain bg-[var(--surface)] p-5`,s),children:o}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-footer-root`,ref:u})]})})})}function P({className:e,...t}){let n=(0,h.useContext)(M);return n?(0,m.createPortal)((0,g.jsx)(`div`,{"data-slot":`app-dialog-footer`,className:l(`border-t border-[var(--border)] bg-[var(--surface)] px-6 py-3 [&_button]:min-h-8 [&_button]:px-3 [&_button]:text-xs`,e),...t}),n):null}export{y as a,C as c,_ as i,p as l,P as n,x as o,D as r,w as s,N as t};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{N as e,P as t,X as n}from"./index-Bx1uywm3.js";var r=n(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),i=n=>t(e.api.articles.$post({json:n})),a=n=>t(e.api.publications.$post({json:n})),o=e=>[`content-packages`,e,`run-context`],s=(n=1,r=20)=>t(e.api[`content-packages`].$get({query:{page:String(n),pageSize:String(r)}})),c=n=>t(e.api[`content-packages`][`:id`][`run-context`].$get({param:{id:n}}));export{a,i,c as n,r as o,s as r,o as t};
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{t}from"./useMutation-Xdq_89ou.js";import{n,r,t as i}from"./notifications-wLr7xSyr.js";import{L as a,Lt as o,N as s,P as c,U as l,V as u,dn as d,ln as f,rt as p}from"./index-Bx1uywm3.js";import{t as m}from"./play-DYoZjslk.js";import{t as h}from"./plus-DewHiaw6.js";import{n as g}from"./use-workspace-snapshot-MZKeTfAJ.js";import{t as _}from"./input-Br6N0XCJ.js";import{t as v}from"./textarea-zbjD4aac.js";import{t as y}from"./select-9cx3otc_.js";import{n as b,t as x}from"./app-dialog-CBRjH8y0.js";import{t as S}from"./form-field-BJITE8Lh.js";import{n as C,t as w}from"./entity-list-B2WXTDDM.js";import{t as T}from"./pagination-CEYfdE0s.js";import{t as E}from"./page-grid-BR5GG4AN.js";var D=(e=1,t=20)=>c(s.api.automations.$get({query:{page:String(e),pageSize:String(t)}})),O=e=>c(s.api.automations.$post({json:e})),k=(e,t)=>c(s.api.automations[`:id`].$patch({param:{id:e},json:t})),A=e=>c(s.api.automations[`:id`].$delete({param:{id:e}})),j=(e,t={})=>c(s.api.automations[`:id`].run.$post({param:{id:e},json:t})),M=e(d(),1),N=f(),P=20,F=()=>[`automations`];function I(e=1){return r({queryKey:[...F(),e],queryFn:()=>D(e,P)})}function L(){let e=o();return t({mutationFn:e=>A(e),onSuccess:()=>e.invalidateQueries({queryKey:F()})})}function R(){let e=o();return t({mutationFn:({id:e,body:t})=>e?k(e,t):O(t),onSuccess:()=>e.invalidateQueries({queryKey:F()})})}function z(){return t({mutationFn:({id:e,body:t={}})=>j(e,t)})}var B=()=>({name:``,enabled:!0,contentPlanId:``,instructions:``,keywords:[],trigger:{type:`manual`}});function V({page:e,onPageChange:t}){let{data:r,error:a}=I(e),{data:o}=g({live:!1}),[s,c]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),f=R(),p=L(),_=r?.items??[],v=o?.contentPlans.some(e=>e.enabled)??!1;return a&&!r?null:(0,N.jsxs)(E,{children:[(0,N.jsx)(w,{title:`任务列表`,description:`任务只负责选择内容方案和触发方式;内容与发布配置由方案自身维护。`,compact:!0,summary:`共 ${r?.total??0} 个任务`,action:(0,N.jsxs)(l,{variant:`primary`,disabled:!v,onClick:()=>c(`new`),children:[(0,N.jsx)(h,{className:`size-4`}),`新建任务`]}),empty:!_.length,emptyTitle:v?`还没有自动化任务`:`先创建内容方案`,emptyDescription:v?`创建任务后,可从这里手动运行并查看状态。`:`内容方案组合模板、身份、参考输入和模型连接,是创建任务的前置条件。`,emptyAction:v?void 0:(0,N.jsx)(l,{onClick:()=>window.location.href=`/dashboard/content-plans`,children:`前往内容方案`}),pagination:(0,N.jsx)(T,{page:e,pageSize:P,total:r?.total??0,onChange:t}),children:_.map(e=>{let t=o?.contentPlans.find(t=>t.id===e.contentPlanId),r=o?.identities.find(e=>e.id===t?.identityId);return(0,N.jsx)(C,{title:e.name,description:`${t?.name??`方案缺失`} · ${r?.name??`身份缺失`}`,status:e.enabled&&t?.enabled?`ready`:`disabled`,meta:(0,N.jsx)(n,{children:G(e.trigger.type)}),onEdit:()=>c(e),deleteDescription:`任务删除后将不再触发,已有运行记录不会被删除。`,onDelete:()=>p.mutateAsync(e.id),children:(0,N.jsxs)(l,{disabled:!e.enabled||!t?.enabled,onClick:()=>d(e),children:[(0,N.jsx)(m,{className:`size-4`}),`运行`]})},e.id)})}),(0,N.jsx)(H,{value:s,open:!!s,onOpenChange:e=>!e&&c(null),onSave:e=>f.mutate({id:s===`new`?void 0:s.id,body:e},{onSuccess:()=>{c(null),i.success(`任务已保存`,`“${e.name}”的触发配置已更新。`)},onError:e=>i.error(`保存任务失败`,e)}),saving:f.isPending,error:f.error}),(0,N.jsx)(U,{automation:u,onOpenChange:e=>!e&&d(null)})]})}function H({value:e,open:t,onOpenChange:n,onSave:r,saving:i,error:a}){let{data:o}=g({live:!1}),[s,c]=(0,M.useState)(B()),[d,f]=(0,M.useState)(``);(0,M.useEffect)(()=>{if(!e)return;let t=e===`new`?B():{...e,revision:e.revision};e===`new`&&(t.contentPlanId=o?.contentPlans[0]?.id??``),c(t),f(t.keywords.join(`
2
+ `))},[e,o]);let m=o?.contentPlans.find(e=>e.id===s.contentPlanId),h=o?.identities.find(e=>e.id===m?.identityId),C=(m?.sourceCollectionIds??[]).map(e=>o?.sourceCollections.find(t=>t.id===e)?.name).filter(Boolean);return(0,N.jsxs)(x,{open:t,onOpenChange:n,title:e===`new`?`新建任务`:`编辑任务`,description:`选择要运行的内容方案,并配置何时触发。`,size:`wide`,children:[(0,N.jsxs)(`div`,{className:`grid gap-6`,children:[(0,N.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(S,{label:`任务名称`,required:!0,children:(0,N.jsx)(_,{value:s.name,onChange:e=>c({...s,name:e.target.value})})}),(0,N.jsx)(S,{label:`状态`,children:(0,N.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s.enabled,onChange:e=>c({...s,enabled:e.target.checked})}),`启用任务`]})})]}),(0,N.jsxs)(`section`,{className:`grid gap-4 border-y border-[var(--border)] py-5`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:`内容与参考`}),(0,N.jsx)(S,{label:`内容方案`,required:!0,helper:`内容方案决定 ReAct 策略、身份、知识库、授权工具、模型和发布配置。`,children:(0,N.jsxs)(y,{value:s.contentPlanId,onChange:e=>c({...s,contentPlanId:e.target.value}),children:[(0,N.jsx)(`option`,{value:``,children:`请选择`}),o?.contentPlans.filter(e=>e.enabled).map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),m?(0,N.jsxs)(`dl`,{className:`divide-y divide-[var(--border)] border-y border-[var(--border)] text-sm`,children:[(0,N.jsxs)(`div`,{className:`grid gap-1 py-3 sm:grid-cols-[140px_1fr]`,children:[(0,N.jsx)(`dt`,{className:`text-[var(--muted)]`,children:`内容身份`}),(0,N.jsx)(`dd`,{children:h?.name??`身份缺失`})]}),(0,N.jsxs)(`div`,{className:`grid gap-1 py-3 sm:grid-cols-[140px_1fr]`,children:[(0,N.jsx)(`dt`,{className:`text-[var(--muted)]`,children:`抓取数据源`}),(0,N.jsx)(`dd`,{children:C.join(`、`)||`未配置`})]})]}):null,(0,N.jsx)(S,{label:`领域与任务说明`,helper:`补充本任务关注的领域、判断标准和内容边界。`,children:(0,N.jsx)(v,{className:`min-h-28`,value:s.instructions??``,onChange:e=>c({...s,instructions:e.target.value})})}),(0,N.jsx)(S,{label:`关注关键词`,helper:`每行一个,用作运行上下文;热点监控接入后也会复用。`,children:(0,N.jsx)(v,{className:`min-h-24`,value:d,onChange:e=>f(e.target.value)})})]}),(0,N.jsxs)(`section`,{className:`grid gap-3 border-t border-[var(--border)] pt-5`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:`触发方式`}),(0,N.jsx)(S,{label:`当前方式`,children:(0,N.jsxs)(y,{value:s.trigger.type,onChange:e=>c({...s,trigger:W(e.target.value)}),children:[(0,N.jsx)(`option`,{value:`manual`,children:`手动触发`}),(0,N.jsx)(`option`,{value:`schedule`,children:`定时触发`}),(0,N.jsx)(`option`,{value:`hotspot`,children:`热点触发`}),(0,N.jsx)(`option`,{value:`api`,children:`API 触发`})]})}),s.trigger.type===`schedule`?(0,N.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(S,{label:`Cron 表达式`,required:!0,children:(0,N.jsx)(_,{value:s.trigger.cron,onChange:e=>c({...s,trigger:{type:`schedule`,cron:e.target.value,timezone:s.trigger.type===`schedule`?s.trigger.timezone:`Asia/Shanghai`}}),placeholder:`0 9 * * *`})}),(0,N.jsx)(S,{label:`时区`,required:!0,children:(0,N.jsx)(_,{value:s.trigger.timezone,onChange:e=>c({...s,trigger:{type:`schedule`,cron:s.trigger.type===`schedule`?s.trigger.cron:`0 9 * * *`,timezone:e.target.value}})})})]}):null,s.trigger.type===`hotspot`?(0,N.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(S,{label:`监控关键词`,required:!0,children:(0,N.jsx)(_,{value:s.trigger.query,onChange:e=>c({...s,trigger:{type:`hotspot`,query:e.target.value,intervalMinutes:s.trigger.type===`hotspot`?s.trigger.intervalMinutes:30}})})}),(0,N.jsx)(S,{label:`检查间隔(分钟)`,required:!0,children:(0,N.jsx)(_,{type:`number`,min:5,value:s.trigger.intervalMinutes,onChange:e=>c({...s,trigger:{type:`hotspot`,query:s.trigger.type===`hotspot`?s.trigger.query:``,intervalMinutes:Number(e.target.value)}})})})]}):null,s.trigger.type===`api`?(0,N.jsx)(S,{label:`调用标识`,helper:`用于在日志中区分调用方,可留空。`,children:(0,N.jsx)(_,{value:s.trigger.tokenName??``,onChange:e=>c({...s,trigger:{type:`api`,tokenName:e.target.value}})})}):null]}),(0,N.jsx)(u,{error:a})]}),(0,N.jsxs)(b,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(l,{onClick:()=>n(!1),children:`取消`}),(0,N.jsx)(l,{variant:`primary`,loading:i,disabled:!s.name.trim()||!s.contentPlanId,onClick:()=>r({...s,name:s.name.trim(),instructions:s.instructions?.trim()||void 0,keywords:p(d)}),children:`保存`})]})]})}function U({automation:e,onOpenChange:t}){let[n,r]=(0,M.useState)(``);(0,M.useEffect)(()=>r(``),[e]);let a=z();return(0,N.jsxs)(x,{open:!!e,onOpenChange:t,title:`运行任务`,description:e?.name??``,children:[(0,N.jsxs)(`div`,{className:`grid gap-4`,children:[(0,N.jsx)(S,{label:`本次指定主题`,helper:`可留空,由内容方案根据数据源选题。`,children:(0,N.jsx)(_,{value:n,onChange:e=>r(e.target.value)})}),(0,N.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:`本次运行会执行内容方案中保存的生成与发布配置。`}),(0,N.jsx)(u,{error:a.error})]}),(0,N.jsxs)(b,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(l,{onClick:()=>t(!1),children:`取消`}),(0,N.jsxs)(l,{variant:`primary`,loading:a.isPending,onClick:()=>a.mutate({id:e.id,body:{requestedTopic:n.trim()||void 0}},{onSuccess:()=>{t(!1),i.success(`任务已启动`,`可在运行记录中查看实时活动。`)},onError:e=>i.error(`启动任务失败`,e)}),children:[(0,N.jsx)(m,{className:`size-4`}),`开始运行`]})]})]})}function W(e){return e===`schedule`?{type:e,cron:`0 9 * * *`,timezone:`Asia/Shanghai`}:e===`hotspot`?{type:e,query:``,intervalMinutes:30}:e===`api`?{type:e,tokenName:``}:{type:`manual`}}function G(e){return{manual:`手动触发`,schedule:`定时触发`,hotspot:`热点触发`,api:`API 触发`}[e]}function K(){let{page:e}=a.useSearch(),t=a.useNavigate();return(0,N.jsx)(V,{page:e,onPageChange:e=>t({search:t=>({...t,page:e})})})}export{K as component};
@@ -0,0 +1 @@
1
+ import{r as e}from"./notifications-wLr7xSyr.js";import{N as t,P as n}from"./index-Bx1uywm3.js";var r=()=>[`becomeopc`,`status`],i=()=>n(t.api.becomeopc.status.$get()),a=()=>n(t.api.becomeopc.sync.$post()),o=()=>n(t.api.becomeopc.connection.$delete()),s=()=>n(t.api.becomeopc.oauth.start.$post()),c=e=>n(t.api.becomeopc.oauth.status.$get({query:{state:e}}));function l(){return e({queryKey:r(),queryFn:i,staleTime:3e4,retry:!1})}function u(e){if(!e)return`TrendPublish 托管订阅`;let t=e.toLowerCase();return t.includes(`bundle`)?t.includes(`year`)||t.includes(`annual`)?`全家桶年付`:t.includes(`month`)?`全家桶月付`:`全家桶订阅`:t.includes(`year`)||t.includes(`annual`)?`年付订阅`:t.includes(`month`)?`月付订阅`:t.includes(`trial`)?`试用版`:t.includes(`pro`)?`Pro 订阅`:e}function d(e,t=Date.now()){if(!e)return!1;if(e.status===`trialing`)return!0;if(!e.trialEnd)return!1;let n=Date.parse(e.trialEnd);return Number.isFinite(n)&&n>t}function f(e,t=Date.now()){if(!e||!e.connected)return{label:`未连接`,tone:`neutral`};if(e.expired)return{label:`已过期`,tone:`danger`};if(d(e,t))return{label:`试用中`,tone:`info`};switch(e.status){case`active`:return{label:`已订阅`,tone:`success`};case`canceling`:return{label:`到期后取消`,tone:`warning`};case`past_due`:return{label:`待续费`,tone:`warning`};default:return e.entitled?{label:`已连接`,tone:`success`}:{label:`未生效`,tone:`warning`}}}function p(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(new Date(t)):e}export{u as a,s as c,p as i,a as l,f as n,c as o,o as r,d as s,r as t,l as u};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{t}from"./useMutation-Xdq_89ou.js";import{n,r,t as i}from"./notifications-wLr7xSyr.js";import{G as a,H as o,I as s,Lt as c,N as l,P as u,U as d,V as f,X as p,dn as m,ln as h,nt as g,q as _}from"./index-Bx1uywm3.js";import{t as v}from"./flask-conical-B9Pn4z-3.js";import{t as y}from"./plus-DewHiaw6.js";import{t as b}from"./input-Br6N0XCJ.js";import{t as x}from"./select-9cx3otc_.js";import{t as S}from"./textarea-zbjD4aac.js";import{n as C,t as w}from"./app-dialog-CBRjH8y0.js";import{t as T}from"./external-link-B2pLgsIl.js";import{t as E}from"./refresh-cw-BB9_0X86.js";import{t as D}from"./sparkles-C9YU6Kr5.js";import{a as O,c as k,i as A,l as j,n as M,o as N,r as P,s as F,t as I,u as ee}from"./becomeopc-EvwYWHkB.js";import{t as L}from"./form-field-BJITE8Lh.js";import{n as R,t as z}from"./entity-list-B2WXTDDM.js";import{t as B}from"./page-grid-BR5GG4AN.js";import{t as te}from"./pagination-CEYfdE0s.js";var V=p(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),ne=p(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),re=(e=1,t=20)=>u(l.api.connections.$get({query:{page:String(e),pageSize:String(t)}})),ie=e=>u(l.api.connections.$post({json:e})),ae=(e,t)=>u(l.api.connections[`:id`].$patch({param:{id:e},json:t})),H=e=>u(l.api.connections[`:id`].$delete({param:{id:e}})),U=e=>u(l.api.connections.test.$post({json:e})),W=e(m(),1),G=h(),K=1200;function q(){let e=c(),{data:r,isLoading:o}=ee(),[s,l]=(0,W.useState)(null),[u,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),h=(0,W.useRef)(null),v=()=>{h.current&&=(clearInterval(h.current),null),l(null)};(0,W.useEffect)(()=>v,[]),(0,W.useEffect)(()=>{if(!s)return;let t=async()=>{try{let t=await N(s);if(t.status===`pending`)return;if(v(),t.status===`completed`){f(null),await e.invalidateQueries({queryKey:I()}),await e.invalidateQueries({queryKey:[`connections`]}),i.success(t.synced?`已连接 BecomeOPC,并同步 ${t.synced} 个微信 Relay 连接`:`已连接 BecomeOPC 订阅`);return}if(t.status===`not_entitled`){f(t.error??`当前 BecomeOPC 账户尚未订阅 TrendPublish,请先前往订阅或开始试用。`),i.info(`已登录 BecomeOPC,当前账户尚未订阅 TrendPublish`);return}i.error(`连接 BecomeOPC 失败`,t.error??`登录会话已结束`)}catch(e){v(),i.error(`检查 BecomeOPC 登录状态失败`,e)}};return h.current=setInterval(()=>void t(),K),()=>{h.current&&=(clearInterval(h.current),null)}},[s,e]);let y=t({mutationFn:k,onSuccess:({state:e,authorizeUrl:t})=>{f(null),l(e),window.open(t,`_blank`,`noopener,noreferrer`)?i.info(`已打开 BecomeOPC 授权页面,完成登录后将自动同步`):i.info(`浏览器拦截了弹窗,请允许新窗口或手动打开授权页`)},onError:e=>i.error(`发起 BecomeOPC 连接失败`,e)}),b=t({mutationFn:j,onSuccess:async t=>{f(null),await e.invalidateQueries({queryKey:I()}),i.success(t.synced?`订阅状态已刷新,并同步 ${t.synced} 个微信 Relay 连接`:`BecomeOPC 订阅状态已刷新`)},onError:e=>i.error(`刷新 BecomeOPC 订阅失败`,e)}),x=t({mutationFn:P,onSuccess:async()=>{m(!1),f(null),await e.invalidateQueries({queryKey:I()}),i.success(`已断开本地 BecomeOPC 订阅凭证`)},onError:e=>i.error(`断开 BecomeOPC 连接失败`,e)}),S=M(r),C=r?.urls.subscribe??`https://becomeopc.com/trendpublish/zh#pricing`,w=r?.urls.manage??`https://becomeopc.com/account?product=trendpublish&lang=zh`,L=!!s,R=F(r),z=(R?r?.trialEnd:null)??r?.periodEnd??r?.expiresAt??null;return(0,G.jsxs)(`section`,{"aria-label":`BecomeOPC 订阅与托管 Relay`,className:`grid gap-3.5 rounded-[var(--radius-md)] border border-[var(--border)] bg-[var(--surface)] p-4 sm:p-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-[var(--accent-border)] bg-[var(--accent-bg)] text-[var(--accent)]`,children:(0,G.jsx)(D,{className:`size-4`,"aria-hidden":!0})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`BecomeOPC 订阅 · 托管微信 Relay`}),(0,G.jsx)(n,{tone:S.tone,children:o?`检查中…`:S.label})]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:`无需自备国内固定 IP 服务器,订阅后自动同步微信公众号托管 Relay 凭证并每 6 小时自动续期。`})]})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:r?.connected?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`a`,{href:r.expired?C:w,target:`_blank`,rel:`noopener noreferrer`,className:g(a({variant:r.expired?`primary`:`secondary`,size:`sm`})),children:[r.expired?`前往 BecomeOPC 续费`:`管理订阅`,(0,G.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})]}),(0,G.jsxs)(d,{type:`button`,size:`sm`,variant:`secondary`,loading:b.isPending,onClick:()=>b.mutate(),children:[!b.isPending&&(0,G.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),`刷新同步`]}),r.expired&&r.canBrowserLogin?(0,G.jsxs)(d,{type:`button`,size:`sm`,variant:`secondary`,loading:y.isPending||L,onClick:()=>y.mutate(),children:[!y.isPending&&!L&&(0,G.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),L?`等待授权…`:`重新连接`]}):null,p?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(d,{type:`button`,size:`sm`,variant:`danger`,loading:x.isPending,onClick:()=>x.mutate(),children:`确认断开`}),(0,G.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,disabled:x.isPending,onClick:()=>m(!1),children:`取消`})]}):(0,G.jsxs)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>m(!0),children:[(0,G.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),`断开`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:g(a({variant:`primary`,size:`sm`})),children:[`前往 BecomeOPC 订阅`,(0,G.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})]}),r?.canBrowserLogin?L?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(d,{type:`button`,size:`sm`,variant:`secondary`,loading:!0,children:`等待浏览器授权…`}),(0,G.jsx)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:v,children:`取消`})]}):(0,G.jsxs)(d,{type:`button`,size:`sm`,variant:`secondary`,loading:y.isPending,onClick:()=>y.mutate(),children:[!y.isPending&&(0,G.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),`连接 BecomeOPC 账号`]}):(0,G.jsx)(`span`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-2.5 py-1.5 font-mono text-[11px] text-[var(--muted-strong)]`,children:`CLI 执行 trendpublish login 绑定`})]})})]}),r?.connected?(0,G.jsxs)(`div`,{className:`grid gap-2.5 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] text-[var(--muted)]`,children:`当前套餐`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-sm font-medium text-[var(--ink)]`,children:O(r.plan)})]}),(0,G.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] text-[var(--muted)]`,children:R?`试用到期`:r.periodEnd?`当前周期截止`:`本地凭证有效至`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-sm font-medium tabular-nums text-[var(--ink)]`,children:A(z)})]}),(0,G.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] text-[var(--muted)]`,children:`托管 Relay 地址`}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between gap-2 text-xs font-medium text-[var(--ink)]`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono`,children:r.managedRelayUrl}),(0,G.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-[var(--muted)]`,children:[`已同步 `,r.syncedRelayCount,` 个`]})]})]})]}):null,u?(0,G.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center justify-between gap-3 rounded-[var(--radius-sm)] border border-[var(--warning-border)] bg-[var(--warning-bg)] px-3.5 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-xs leading-5 text-[var(--ink)]`,children:[(0,G.jsx)(_,{className:`mt-0.5 size-4 shrink-0 text-[var(--warning)]`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:u})]}),(0,G.jsxs)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:g(a({variant:`secondary`,size:`sm`})),children:[`去购买 / 开始试用`,(0,G.jsx)(T,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]})}function oe(e,t){let n=e.trim(),r=new Set(t.map(e=>e.trim().toLocaleLowerCase()));if(!r.has(n.toLocaleLowerCase()))return n;let i=2;for(;r.has(`${n} ${i}`.toLocaleLowerCase());)i+=1;return`${n} ${i}`}var J=()=>[`connections`],Y=20;function se(e=1){return r({queryKey:[...J(),e],queryFn:()=>re(e,Y)})}function ce(){let e=c();return t({mutationFn:e=>H(e),onSuccess:()=>e.invalidateQueries({queryKey:J()})})}function le(){let e=c();return t({mutationFn:({id:e,body:t})=>e?ae(e,t):ie(t),onSuccess:()=>e.invalidateQueries({queryKey:J()})})}function X(){return t({mutationFn:e=>U(e)})}function ue({page:e,onPageChange:t}){let{data:r}=se(e),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),c=ce(),l=r?.definitions??[],u=r?.items??[],f=(0,W.useMemo)(()=>new Map(l.map(e=>[e.id,e])),[l]);return(0,G.jsxs)(B,{children:[(0,G.jsx)(q,{}),(0,G.jsx)(z,{title:`连接列表`,description:`超时、重试与恢复不属于连接配置;调用失败会由运行记录和检查点安全处理。`,compact:!0,summary:`共 ${r?.total??0} 个连接`,action:(0,G.jsxs)(d,{variant:`primary`,onClick:()=>s(!0),children:[(0,G.jsx)(y,{className:`size-4`}),`新建连接`]}),empty:!u.length,pagination:(0,G.jsx)(te,{page:e,pageSize:Y,total:r?.total??0,onChange:t}),children:u.map(e=>{let t=f.get(e.connectorId);return(0,G.jsx)(R,{title:e.name,description:`${t?.displayName??e.connectorId} · ${t?.description??``}`,status:e.enabled?`ready`:`disabled`,meta:(0,G.jsx)(`span`,{className:`flex gap-1`,children:t?.capabilities.map(e=>(0,G.jsx)(n,{children:e},e))}),onEdit:()=>t&&a({definition:t,connection:e}),deleteDescription:`删除后无法恢复;正在被方案或账号使用时不会删除。`,onDelete:()=>c.mutateAsync(e.id)},e.id)})}),(0,G.jsx)(w,{open:o,onOpenChange:s,title:`选择 Connector`,description:`每个 Connector 定义一组稳定能力和所需基础字段。`,size:`medium`,children:(0,G.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:l.map(e=>(0,G.jsxs)(`button`,{className:`grid w-full gap-1 rounded-[var(--radius-sm)] px-2 py-3.5 text-left transition-colors duration-[var(--duration-fast)] hover:bg-[var(--overlay)]`,onClick:()=>{a({definition:e,suggestedName:oe(e.displayName,u.map(e=>e.name))})},children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[e.displayName,(0,G.jsx)(`span`,{className:`flex gap-1`,children:e.capabilities.map(e=>(0,G.jsx)(n,{children:e},e))})]}),(0,G.jsx)(`span`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:e.description})]},e.id))})}),(0,G.jsx)(de,{editor:i,onOpenChange:e=>!e&&a(null),onSaved:()=>{a(null),s(!1)}})]})}function de({editor:e,onOpenChange:t,onSaved:n}){let[r,a]=(0,W.useState)(``),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)({}),[p,m]=(0,W.useState)(`{}`),[h,g]=(0,W.useState)(`{}`),[_,y]=(0,W.useState)(`{}`),[x,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)();(0,W.useEffect)(()=>{if(!e)return;a(e.connection?.name??e.suggestedName??e.definition.displayName),c(e.connection?.enabled??!0);let t=Object.fromEntries(e.definition.fields.filter(e=>e.defaultValue!==void 0).map(e=>[e.key,e.defaultValue]));u({...t,...e.connection?.settings}),m(JSON.stringify(e.connection?.overrides?.headers??{},null,2)),g(JSON.stringify(e.connection?.overrides?.query??{},null,2)),y(JSON.stringify(e.connection?.overrides?.body??{},null,2)),T(!1),D(void 0)},[e]);let O=()=>({id:e?.connection?.id,revision:e?.connection?.revision,connectorId:e.definition.id,name:r.trim(),enabled:s,settings:Object.fromEntries(e.definition.fields.filter(e=>e.location===`settings`).map(e=>[e.key,l[e.key]]).filter(([,e])=>e!==void 0&&e!==``)),credentials:Object.fromEntries(e.definition.fields.filter(e=>e.location===`credentials`).map(e=>[e.key,l[e.key]]).filter(([,e])=>e!==void 0&&e!==``)),overrides:e.definition.requestOverrides?{headers:Q(p,`Headers`),query:Q(h,`Query`),body:Q(_,`Body`)}:void 0}),k=le(),A=X();if(!e)return null;let j=[...e.definition.fields].sort((e,t)=>(e.order??0)-(t.order??0)),M=j.filter(e=>e.defaultValue===void 0),N=j.filter(e=>e.defaultValue!==void 0),P=j.some(t=>{if(!t.required)return!1;let n=l[t.key];return n!==void 0&&n!==``?!1:!(t.location===`credentials`&&e.connection?.credentialState[t.key])});return(0,G.jsxs)(w,{open:!0,onOpenChange:t,title:e.connection?`编辑连接`:`新建连接`,description:`${e.definition.displayName} · ${e.definition.capabilities.join(` / `)}`,size:`medium`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(`div`,{className:`grid gap-4`,children:M.map(t=>(0,G.jsx)(Z,{field:t,value:l[t.key],hasStoredCredential:!!e.connection?.credentialState[t.key],onChange:e=>u({...l,[t.key]:e})},`${t.location}:${t.key}`))}),(0,G.jsxs)(`details`,{className:`group border-t border-[var(--border)] pt-4`,open:x,onToggle:e=>T(e.currentTarget.open),children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer list-none text-sm font-medium text-[var(--muted-strong)] hover:text-[var(--ink)]`,children:[`高级设置`,(0,G.jsx)(`span`,{className:`ml-2 text-xs font-normal text-[var(--muted)]`,children:`名称、状态与接口参数`})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto]`,children:[(0,G.jsx)(L,{label:`连接名称`,required:!0,children:(0,G.jsx)(b,{value:r,onChange:e=>a(e.target.value)})}),(0,G.jsx)(L,{label:`状态`,children:(0,G.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),`启用`]})})]}),N.length?(0,G.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:N.map(t=>(0,G.jsx)(Z,{field:t,value:l[t.key],hasStoredCredential:!!e.connection?.credentialState[t.key],onChange:e=>u({...l,[t.key]:e})},`${t.location}:${t.key}`))}):null,e.definition.requestOverrides?(0,G.jsxs)(`details`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer list-none text-sm font-medium`,children:[`请求覆盖`,(0,G.jsx)(`span`,{className:`ml-2 text-xs font-normal text-[var(--muted)]`,children:`Headers · Query · Body`})]}),(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-[var(--muted-strong)]`,children:`仅用于特殊接入;认证保留字段不能覆盖。`}),(0,G.jsxs)(`div`,{className:`mt-4 grid gap-4`,children:[(0,G.jsx)(L,{label:`Headers`,children:(0,G.jsx)(S,{className:`min-h-32 font-mono text-xs`,value:p,onChange:e=>m(e.target.value)})}),(0,G.jsx)(L,{label:`Query`,children:(0,G.jsx)(S,{className:`min-h-32 font-mono text-xs`,value:h,onChange:e=>g(e.target.value)})}),(0,G.jsx)(L,{label:`Body`,children:(0,G.jsx)(S,{className:`min-h-32 font-mono text-xs`,value:_,onChange:e=>y(e.target.value)})})]})]}):null]})]}),E?(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded border px-3 py-2 text-xs ${E.success?`border-[var(--success-border)] bg-[var(--success-bg)] text-[var(--success)]`:`border-[var(--danger-border)] bg-[var(--danger-bg)] text-[var(--danger)]`}`,children:[E.message,` · `,E.latencyMs,` ms`]}):null,(0,G.jsx)(f,{error:k.error??A.error})]}),(0,G.jsxs)(C,{className:`flex justify-between gap-2`,children:[(0,G.jsxs)(d,{loading:A.isPending,disabled:P,onClick:()=>{D(void 0);try{A.mutate(O(),{onSuccess:e=>{D(e.test),e.test.success?i.success(`连接测试成功`,`${e.test.message} · ${e.test.latencyMs} ms`):i.error(`连接测试失败`,e.test.message)},onError:e=>i.error(`连接测试失败`,e)})}catch(e){D({success:!1,message:o(e),latencyMs:0}),i.error(`连接测试失败`,e)}},children:[!A.isPending&&(0,G.jsx)(v,{className:`size-4`}),`测试连接`]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(d,{onClick:()=>t(!1),children:`取消`}),(0,G.jsx)(d,{variant:`primary`,loading:k.isPending,disabled:!r.trim()||P,onClick:()=>k.mutate({id:e.connection?.id,body:O()},{onSuccess:()=>{n(),i.success(`连接已保存`,`“${r.trim()}”可以用于 Agent。`)},onError:e=>i.error(`保存连接失败`,e)}),children:`保存连接`})]})]})]})}function Z({field:e,value:t,hasStoredCredential:n,onChange:r}){return(0,G.jsx)(L,{label:e.label,required:e.required,helper:e.description,children:e.input===`boolean`?(0,G.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!t,onChange:e=>r(e.target.checked)}),`启用`]}):e.input===`select`?(0,G.jsx)(x,{value:$(t),onChange:e=>r(e.target.value),children:e.options?.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,G.jsx)(b,{type:e.input===`password`?`password`:e.input===`number`?`number`:e.input===`url`?`url`:`text`,value:$(t),placeholder:n?`留空保留已有值`:e.placeholder,onChange:t=>r(e.input===`number`?Number(t.target.value):t.target.value)})})}function Q(e,t){let n=JSON.parse(e||`{}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`${t} 必须是 JSON 对象`);return n}function $(e){return typeof e==`string`||typeof e==`number`?String(e):``}function fe(){let{page:e}=s.useSearch(),t=s.useNavigate();return(0,G.jsx)(ue,{page:e,onPageChange:e=>t({search:t=>({...t,page:e})})})}export{fe as component};
@@ -0,0 +1 @@
1
+ import{t as e}from"./useMutation-Xdq_89ou.js";import{r as t,t as n}from"./notifications-wLr7xSyr.js";import{A as r,D as i,Lt as a,M as o,O as s,U as c,j as l,k as u,ln as d}from"./index-Bx1uywm3.js";import"./types-D57tnOAh.js";import{t as f}from"./copy-C4Adx2li.js";import{t as p}from"./eye-DyaLFyNg.js";import{t as m}from"./plus-DewHiaw6.js";import{n as h}from"./use-workspace-snapshot-MZKeTfAJ.js";import{n as g,t as _}from"./entity-list-B2WXTDDM.js";import{t as v}from"./src-DVp5YM1T.js";import{t as y}from"./page-grid-BR5GG4AN.js";import{t as b}from"./pagination-CEYfdE0s.js";var x=d(),S=20;function C(e=1){return t({queryKey:[...s(),e],queryFn:()=>l(e,S)})}function w(){let t=a();return e({mutationFn:e=>r(e),onSuccess:()=>t.invalidateQueries({queryKey:s()})})}function T(t){let n=a();return e({mutationFn:e=>t?o(t,e):u(e),onSuccess:()=>n.invalidateQueries({queryKey:s()})})}function E(){let t=a();return e({mutationFn:e=>u({name:`${e.name} (副本)`,enabled:!1,identityId:e.identityId,knowledgeBaseIds:e.knowledgeBaseIds??[],sourceCollectionIds:e.sourceCollectionIds,connections:{...e.connections},researchConnections:e.researchConnections??{search:[],fetch:[]},agent:e.agent?{...e.agent,toolConnectionIds:[...e.agent.toolConnectionIds],budget:e.agent.budget?{...e.agent.budget}:void 0}:void 0,publishing:{...e.publishing}}),onSuccess:()=>t.invalidateQueries({queryKey:s()})})}function D(){let{data:e}=h({live:!1}),{page:t}=i.useSearch(),r=i.useNavigate(),{data:a}=C(t),o=w(),s=E(),l=a?.items??[];return(0,x.jsx)(y,{children:(0,x.jsx)(_,{title:`内容方案`,description:`一个方案完整描述一次内容生产:使用谁的身份、参考什么、如何生成,以及生成后去哪里。`,compact:!0,summary:`共 ${a?.total??0} 个方案`,action:(0,x.jsxs)(c,{variant:`primary`,size:`sm`,onClick:()=>r({to:`/content-plans/new`}),children:[(0,x.jsx)(m,{className:`size-4`}),`新建方案`]}),empty:!l.length,emptyTitle:`还没有内容方案`,emptyDescription:`创建方案后,任务只需要选择方案和触发方式。`,pagination:(0,x.jsx)(b,{page:t,pageSize:S,total:a?.total??0,onChange:e=>r({search:t=>({...t,page:e})})}),children:l.map(t=>{let i=e?.identities.find(e=>e.id===t.identityId),a=e?.contentStrategies.find(e=>e.id===(t.agent?.strategyId??v)),l=t.publishing?.destinations??[];return(0,x.jsxs)(g,{title:t.name,description:`${i?.name??`身份缺失`} · ${a?.name??`每日资讯解读`} · ${t.knowledgeBaseIds?.length??0} 个知识库 · ${t.sourceCollectionIds.length} 个输入来源 · ${l.length?`${l.length} 个发布目的地`:`仅生成内容包`}`,status:t.enabled?`ready`:`disabled`,deleteDescription:`方案删除后无法恢复,已有运行记录不会被删除。`,onDelete:()=>o.mutateAsync(t.id),children:[(0,x.jsxs)(c,{variant:`ghost`,onClick:()=>r({to:`/content-plans/$planId/edit`,params:{planId:t.id}}),children:[(0,x.jsx)(p,{className:`size-3.5`}),`查看`]}),(0,x.jsxs)(c,{variant:`ghost`,loading:s.isPending&&s.variables?.id===t.id,onClick:()=>s.mutate(t,{onSuccess:()=>n.success(`内容方案已复制`,`已创建“${t.name} (副本)”。`),onError:e=>n.error(`复制内容方案失败`,e)}),children:[(0,x.jsx)(f,{className:`size-3.5`}),`复制`]})]},t.id)})})})}export{D as component,C as useContentPlans,w as useDeleteContentPlan,T as useSaveContentPlan};
@@ -0,0 +1 @@
1
+ import{t as e}from"./-editor-page-DIrPd6Jj.js";var t=e;export{t as component};
@@ -0,0 +1 @@
1
+ import{t as e}from"./-editor-page-DIrPd6Jj.js";var t=e;export{t as component};
@@ -0,0 +1 @@
1
+ import{X as e}from"./index-Bx1uywm3.js";var t=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{At as t,Ct as n,Dt as r,Et as i,Mt as a,Nt as o,Ot as s,Pt as c,St as l,Tt as u,_t as d,at as f,bt as p,dn as m,gt as h,ht as g,it as _,jt as v,kt as y,ln as b,nt as x,ot as S,st as C,vt as w,wt as T,xt as E,yt as ee}from"./index-Bx1uywm3.js";import{c as D,s as te}from"./select-9cx3otc_.js";var O=e(m(),1),ne=Object.defineProperty,k=(e,t)=>ne(e,`name`,{value:t,configurable:!0}),A=!1;function j(){let[e,t]=O.useState(A);return O.useEffect(()=>{A||(A=!0,t(!0))},[]),e}k(j,`useIsHydrated`);var M=O.useSyncExternalStore;function N(){return()=>{}}k(N,`subscribe`);function P(){return M(N,()=>!0,()=>!1)}k(P,`useIsHydratedModern`);var re=typeof M==`function`?P:j,F=b(),ie=Object.defineProperty,I=(e,t)=>ie(e,`name`,{value:t,configurable:!0}),L=`rovingFocusGroup.onEntryFocus`,R={bubbles:!1,cancelable:!0},z=`RovingFocusGroup`,[B,V,H]=D(z),[ae,U]=t(z,[H]),W={Vertical:`vertical`,Horizontal:`horizontal`},oe={LTR:`ltr`,RTL:`rtl`},[G,se]=ae(z),ce=O.forwardRef(I(function(e,t){return(0,F.jsx)(B.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(B.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(le,{...e,ref:t})})})},`RovingFocusGroup`)),le=O.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,orientation:i,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...m}=e,h=O.useRef(null),g=c(t,h),_=te(o),[y,b]=r({prop:l,defaultProp:u??null,onChange:d,caller:z}),[x,S]=O.useState(!1),C=T(f),w=V(n),E=O.useRef(!1),[ee,D]=O.useState(0);return O.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(L,C),()=>e.removeEventListener(L,C)},[C]),(0,F.jsx)(G,{scope:n,orientation:i,dir:_,loop:a,currentTabStopId:y,onItemFocus:O.useCallback(e=>b(e),[b]),onItemShiftTab:O.useCallback(()=>S(!0),[]),onFocusableItemAdd:O.useCallback(()=>D(e=>e+1),[]),onFocusableItemRemove:O.useCallback(()=>D(e=>e-1),[]),children:(0,F.jsx)(v.div,{tabIndex:x||ee===0?-1:0,"data-orientation":i,...m,ref:g,style:{outline:`none`,...e.style},onMouseDown:s(e.onMouseDown,()=>{E.current=!0}),onFocus:s(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(L,R);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=w().filter(e=>e.focusable);he([e.find(e=>e.active),e.find(e=>e.id===y),...e].filter(Boolean).map(e=>e.ref.current),p)}}E.current=!1}),onBlur:s(e.onBlur,()=>S(!1))})})},`RovingFocusGroupImpl`)),ue=`RovingFocusGroupItem`,de=O.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=e,l=u(),d=a||l,f=se(ue,n),p=f.currentTabStopId===d,m=V(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=f,b=re();return y(()=>{if(b&&r)return h(),()=>g()},[b,r,h,g]),O.useEffect(()=>{if(!b&&r)return h(),()=>g()},[b,r,h,g]),(0,F.jsx)(B.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:(0,F.jsx)(v.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:s(e.onMouseDown,e=>{r?f.onItemFocus(d):e.preventDefault()}),onFocus:s(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:s(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){f.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=me(e,f.orientation,f.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=f.loop?ge(n,r+1):n.slice(r+1)}setTimeout(()=>he(n))}}),children:typeof o==`function`?o({isCurrentTabStop:p,hasTabStop:_!=null}):o})})},`RovingFocusGroupItem`)),fe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function pe(e,t){return t===oe.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}I(pe,`getDirectionAwareKey`);function me(e,t,n){let r=pe(e.key,n);if(!(t===W.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===W.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return fe[r]}I(me,`getFocusIntent`);function he(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}I(he,`focusFirst`);function ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I(ge,`wrapArray`);var _e=Object.defineProperty,K=(e,t)=>_e(e,`name`,{value:t,configurable:!0}),ve=[`Enter`,` `],ye=[`ArrowDown`,`PageUp`,`Home`],be=[`ArrowUp`,`PageDown`,`End`],xe=[...ye,...be];[...ve],[...ve];var q=`Menu`,[Se,Ce,we]=D(q),[J,Te]=t(q,[we,C,U]),Ee=C(),De=U(),[Oe,Y]=J(q),[ke,Ae]=J(q),je=K(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ee(t),[c,l]=O.useState(null),u=O.useRef(!1),d=T(a),f=te(i);return O.useEffect(()=>{let e=K(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=K(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),O.useEffect(()=>{if(!n)return;let e=K(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,F.jsx)(_,{...s,children:(0,F.jsx)(Oe,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,F.jsx)(ke,{scope:t,onClose:O.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Me=O.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e,i=Ee(n);return(0,F.jsx)(f,{...i,...r,ref:t})},`MenuAnchor`)),Ne=`MenuPortal`,[Pe,Fe]=J(Ne,{forceMount:void 0}),Ie=K(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=Y(Ne,t);return(0,F.jsx)(Pe,{scope:t,forceMount:n,children:(0,F.jsx)(i,{present:n||o.open,children:(0,F.jsx)(w,{asChild:!0,container:a,children:r})})})},`MenuPortal`),X=`MenuContent`,[Le,Re]=J(X),ze=O.forwardRef(K(function(e,t){let n=Fe(X,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=Y(X,e.__scopeMenu),s=Ae(X,e.__scopeMenu);return(0,F.jsx)(Se.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(i,{present:r||o.open,children:(0,F.jsx)(Se.Slot,{scope:e.__scopeMenu,children:s.modal?(0,F.jsx)(Be,{...a,ref:t}):(0,F.jsx)(Ve,{...a,ref:t})})})})},`MenuContent`)),Be=O.forwardRef(K(function(e,t){let n=Y(X,e.__scopeMenu),r=O.useRef(null),i=c(t,r);return O.useEffect(()=>{let e=r.current;if(e)return g(e)},[]),(0,F.jsx)(Ue,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:s(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Ve=O.forwardRef(K(function(e,t){let n=Y(X,e.__scopeMenu);return(0,F.jsx)(Ue,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),He=o(`MenuContent.ScrollLock`),Ue=O.forwardRef(K(function(e,t){let{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:u,disableOutsidePointerEvents:f,onEntryFocus:m,onEscapeKeyDown:g,onPointerDownOutside:_,onFocusOutside:v,onInteractOutside:y,onDismiss:b,disableOutsideScroll:x,...C}=e,w=Y(X,r),T=Ae(X,r),D=Ee(r),te=De(r),ne=Ce(r),[k,A]=O.useState(null),j=O.useRef(null),[M,N]=O.useState(null);E(M);let{nodes:P,registry:re}=l(),ie=!!(a||x),I=c(t,j,w.onContentChange,N),L=O.useRef(0),R=O.useRef(``),z=O.useRef(0),B=O.useRef(null),V=O.useRef(`right`),H=O.useRef(0),ae=O.useMemo(()=>x?[j,...P.map(e=>({current:e}))]:[],[j,P,x]),U=x?h:O.Fragment,W=x?{as:He,allowPinchZoom:!0,shards:ae}:void 0,oe=K(e=>{let t=R.current+e,n=ne().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=st(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){R.current=e,window.clearTimeout(L.current),e!==``&&(L.current=window.setTimeout(()=>s(``),1e3))}K(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);O.useEffect(()=>()=>window.clearTimeout(L.current),[]),d();let G=O.useCallback(e=>V.current===B.current?.side&&lt(e,B.current?.area),[]);return(0,F.jsx)(Le,{scope:r,searchRef:R,onItemEnter:O.useCallback(e=>{G(e)&&e.preventDefault()},[G]),onItemLeave:O.useCallback(e=>{G(e)||(j.current?.focus(),A(null))},[G]),onTriggerLeave:O.useCallback(e=>{G(e)&&e.preventDefault()},[G]),pointerGraceTimerRef:z,onPointerGraceIntentChange:O.useCallback(e=>{B.current=e},[]),children:(0,F.jsx)(p,{registry:ie?re:null,children:(0,F.jsx)(U,{...W,children:(0,F.jsx)(ee,{asChild:!0,trapped:a,branches:P,onMountAutoFocus:s(o,e=>{e.preventDefault(),j.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:u,children:(0,F.jsx)(n,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:_,onFocusOutside:v,onInteractOutside:y,onDismiss:b,children:(0,F.jsx)(ce,{asChild:!0,...te,dir:T.dir,orientation:`vertical`,loop:i,currentTabStopId:k,onCurrentTabStopIdChange:A,onEntryFocus:s(m,e=>{T.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,F.jsx)(S,{role:`menu`,"aria-orientation":`vertical`,"data-state":nt(w.open),"data-radix-menu-content":``,dir:T.dir,...D,...C,ref:I,style:{outline:`none`,...C.style},onKeyDown:s(C.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&oe(e.key));let i=j.current;if(e.target!==i||!xe.includes(e.key))return;e.preventDefault();let a=ne().filter(e=>!e.disabled).map(e=>e.ref.current);be.includes(e.key)&&a.reverse(),at(a)}),onBlur:s(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(L.current),R.current=``)}),onPointerMove:s(e.onPointerMove,Z(e=>{let t=e.target,n=H.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>H.current?`right`:`left`;V.current=t,H.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),We=O.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e;return(0,F.jsx)(v.div,{...r,ref:t})},`MenuLabel`)),Ge=`MenuItem`,Ke=`menu.itemSelect`,qe=O.forwardRef(K(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,o=O.useRef(null),l=Ae(Ge,e.__scopeMenu),u=Re(Ge,e.__scopeMenu),d=c(t,o),f=O.useRef(!1),p=K(()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(Ke,{bubbles:!0,cancelable:!0});e.addEventListener(Ke,e=>r?.(e),{once:!0}),a(e,t),t.defaultPrevented?f.current=!1:l.onClose()}},`handleSelect`);return(0,F.jsx)(Je,{...i,ref:d,disabled:n,onClick:s(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:s(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:s(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(u.searchRef.current===``||e.key!==` `)&&ve.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Je=O.forwardRef(K(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Re(Ge,n),l=De(n),u=O.useRef(null),d=c(t,u),[f,p]=O.useState(!1),[m,h]=O.useState(``);return O.useEffect(()=>{let e=u.current;e&&h((e.textContent??``).trim())},[a.children]),(0,F.jsx)(Se.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,F.jsx)(de,{asChild:!0,...l,focusable:!r,children:(0,F.jsx)(v.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:d,onPointerMove:s(e.onPointerMove,Z(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:s(e.onPointerLeave,Z(e=>o.onItemLeave(e))),onFocus:s(e.onFocus,()=>p(!0)),onBlur:s(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),[Ye,Xe]=J(`MenuRadioGroup`,{value:void 0,onValueChange:K(()=>{},`onValueChange`)}),[Ze,Qe]=J(`MenuItemIndicator`,{checked:!1}),$e=O.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e;return(0,F.jsx)(v.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[et,tt]=J(`MenuSub`);function nt(e){return e?`open`:`closed`}K(nt,`getOpenState`);function rt(e){return e===`indeterminate`}K(rt,`isIndeterminate`);function it(e){return rt(e)?`indeterminate`:e?`checked`:`unchecked`}K(it,`getCheckedState`);function at(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}K(at,`focusFirst`);function ot(e,t){return e.map((n,r)=>e[(t+r)%e.length])}K(ot,`wrapArray`);function st(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ot(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}K(st,`getNextMatch`);function ct(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}K(ct,`isPointInPolygon`);function lt(e,t){return t?ct({x:e.clientX,y:e.clientY},t):!1}K(lt,`isPointerInGraceArea`);function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}K(Z,`whenMouse`);var ut=Object.defineProperty,Q=(e,t)=>ut(e,`name`,{value:t,configurable:!0}),dt=`DropdownMenu`,[ft,pt]=t(dt,[Te]),$=Te(),[mt,ht]=ft(dt),gt=Q(e=>{let{__scopeDropdownMenu:t,children:n,dir:i,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=$(t),d=O.useRef(null),[f,p]=r({prop:a,defaultProp:o??!1,onChange:s,caller:dt});return(0,F.jsx)(mt,{scope:t,triggerId:u(),triggerRef:d,contentId:u(),open:f,onOpenChange:p,onOpenToggle:O.useCallback(()=>p(e=>!e),[p]),modal:c,children:(0,F.jsx)(je,{...l,open:f,onOpenChange:p,dir:i,modal:c,children:n})})},`DropdownMenu`),_t=`DropdownMenuTrigger`,vt=O.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ht(_t,n),o=$(n),l=c(t,a.triggerRef);return(0,F.jsx)(Me,{asChild:!0,...o,children:(0,F.jsx)(v.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:l,onPointerDown:s(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:s(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),yt=Q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,F.jsx)(Ie,{...r,...n})},`DropdownMenuPortal`),bt=`DropdownMenuContent`,xt=O.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ht(bt,n),a=$(n),o=O.useRef(!1);return(0,F.jsx)(ze,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:s(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:s(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),St=O.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,F.jsx)(We,{...i,...r,ref:t})},`DropdownMenuLabel`)),Ct=O.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,F.jsx)(qe,{...i,...r,ref:t})},`DropdownMenuItem`)),wt=O.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,F.jsx)($e,{...i,...r,ref:t})},`DropdownMenuSeparator`));function Tt({...e}){return(0,F.jsx)(gt,{"data-slot":`dropdown-menu`,...e})}function Et({...e}){return(0,F.jsx)(vt,{"data-slot":`dropdown-menu-trigger`,...e})}function Dt({className:e,sideOffset:t=4,...n}){return(0,F.jsx)(yt,{children:(0,F.jsx)(xt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:x(`dropdown-content-motion z-50 max-h-[min(18rem,var(--radix-dropdown-menu-content-available-height))] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface)] p-1 text-[var(--ink)] shadow-[var(--shadow-raised)]`,e),...n})})}function Ot({className:e,inset:t,variant:n=`default`,...r}){return(0,F.jsx)(Ct,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:x(`relative flex cursor-default items-center gap-2 rounded-[var(--radius-xs)] px-2 py-1.5 text-sm text-[var(--ink)] outline-hidden select-none focus:bg-[var(--surface-3)] focus:text-[var(--ink)] data-[disabled]:pointer-events-none data-[disabled]:text-[var(--muted)] data-[disabled]:opacity-55 data-[inset]:pl-8 data-[variant=destructive]:text-[var(--danger)] data-[variant=destructive]:focus:bg-[var(--danger-bg)] data-[variant=destructive]:focus:text-[var(--danger-strong)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-[var(--muted)] data-[variant=destructive]:*:[svg]:text-[var(--danger)]!`,e),...r})}function kt({className:e,inset:t,...n}){return(0,F.jsx)(St,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:x(`px-2 py-1.5 text-sm font-medium text-[var(--muted-strong)] data-[inset]:pl-8`,e),...n})}function At({className:e,...t}){return(0,F.jsx)(wt,{"data-slot":`dropdown-menu-separator`,className:x(`-mx-1 my-1 h-px bg-[var(--border)]`,e),...t})}export{At as a,kt as i,Dt as n,Et as o,Ot as r,Tt as t};