@markus-global/cli 0.9.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +15 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +28 -14
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +66 -11
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/start.js +55 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/lib/provider-models.d.ts +48 -0
- package/dist/lib/provider-models.d.ts.map +1 -0
- package/dist/lib/provider-models.js +88 -0
- package/dist/lib/provider-models.js.map +1 -0
- package/dist/markus.mjs +11590 -4895
- package/dist/web-ui/assets/{CommentInput-B9QvgXRU.js → CommentInput-BqMnooel.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-BEWNNIbH.js → ContentRenderer-DL45IlDu.js} +3 -3
- package/dist/web-ui/assets/DeliverableShareModal-2BWwrD0B.js +1 -0
- package/dist/web-ui/assets/Deliverables-ZRYTt61i.js +3 -0
- package/dist/web-ui/assets/{Notifications-CApxHk72.js → Notifications-DTWB_mkr.js} +1 -1
- package/dist/web-ui/assets/{Search-Afkxd1a6.js → Search-CJotdd_7.js} +1 -1
- package/dist/web-ui/assets/Settings-hOETMz7R.js +8 -0
- package/dist/web-ui/assets/{Store-DOYqG495.js → Store-BA0EkZGV.js} +1 -1
- package/dist/web-ui/assets/Team-D2FwZz_o.js +84 -0
- package/dist/web-ui/assets/Work-DJOaN4GX.js +12 -0
- package/dist/web-ui/assets/{arc-DaSSpFFZ.js → arc-DHkGrr0f.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-DLDEmNda.js → architectureDiagram-3BPJPVTR-SV9bE7r9.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-wjnnl7YH.js → blockDiagram-GPEHLZMM-Bb1vRq1C.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-PlSSecfa.js → c4Diagram-AAUBKEIU-tcZyAXyl.js} +1 -1
- package/dist/web-ui/assets/channel-N52kezHF.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-DK9cA6te.js → chunk-2J33WTMH-CJwLLa3C.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-QfjEzeta.js → chunk-4BX2VUAB-BOtdLqQJ.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-Baasjplz.js → chunk-55IACEB6-NQr5uRBA.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-ChZiZqSs.js → chunk-727SXJPM-B5zAoAuj.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CvnzN3BF.js → chunk-AQP2D5EJ-D6ckRpUW.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-BnvdtniW.js → chunk-FMBD7UC4-uWIbAJn7.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Cya4BDdk.js → chunk-ND2GUHAM-DRoYVcWH.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-DWHJ4QkC.js → chunk-QZHKN3VN-TwjLbnMx.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-XkibfmWR.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-XkibfmWR.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CELyP0mw.js → cose-bilkent-S5V4N54A-BfQ_0liP.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-CDI3cyCz.js → dagre-BM42HDAG-CU3dMbrI.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BsR5QcOg.js → diagram-2AECGRRQ-DYleVZiW.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-qfBEt9Wm.js → diagram-5GNKFQAL-DykVmK0r.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DgV2-oUF.js → diagram-KO2AKTUF-BIlHPMdB.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-D3G5wDy7.js → diagram-LMA3HP47-D70tKzYv.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-Did_RC7f.js → diagram-OG6HWLK6-CV2Nu6ik.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-CaBnt7lQ.js → docx-preview-DL_6q0h-.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DkCfZBLl.js → erDiagram-TEJ5UH35-Dzq3Vw8P.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CSExusvH.js → flowDiagram-I6XJVG4X-DGkcoQ60.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BueFExNX.js → ganttDiagram-6RSMTGT7-BLQ3H0r3.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B6AA-uri.js → gitGraphDiagram-PVQCEYII-DUmAstFU.js} +1 -1
- package/dist/web-ui/assets/index-B6fl84HP.js +882 -0
- package/dist/web-ui/assets/index-CT8Kx3sa.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-pN1OECDX.js → infoDiagram-5YYISTIA-CsXOZLwT.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-DYLLTDk5.js → ishikawaDiagram-YF4QCWOH-FxKhYmDc.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Cvhifuv6.js → journeyDiagram-JHISSGLW-BlhEY13x.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DQlM9G-1.js → kanban-definition-UN3LZRKU-CBPhJXrD.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-DL-UboGV.js → mermaid.core-DHGX5lHc.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-h2m6w0EF.js → mindmap-definition-RKZ34NQL-DBuFrFuP.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-eSVk7_C0.js → pieDiagram-4H26LBE5-mWrxRhxJ.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-DIryaeZl.js → quadrantDiagram-W4KKPZXB-JFaiGibg.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BVjw_HOt.js → requirementDiagram-4Y6WPE33-CVHcioJN.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CBvvHuJW.js → sankeyDiagram-5OEKKPKP-BI8QYkQZ.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DrhK7vnS.js → sequenceDiagram-3UESZ5HK-DloeuaaF.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-CwvoCJ1j.js → stateDiagram-AJRCARHV-u1GtjbZs.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DligGfEm.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-DOet_7ho.js → timeline-definition-PNZ67QCA-CbhjCcpj.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B6DiA4eK.js → vennDiagram-CIIHVFJN-CUKEb9oX.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DgN-f4t8.js → wardley-L42UT6IY-D64zeLnz.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-66dcjCfX.js → wardleyDiagram-YWT4CUSO-BpbJymuq.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-D8EN-vdQ.js → xychartDiagram-2RQKCTM6-Dt54kL4V.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/templates/roles/data-analyst/ROLE.md +184 -0
- package/templates/skills/chrome-devtools/SKILL.md +55 -0
- package/dist/web-ui/assets/DeliverableShareModal-C4bKsQbU.js +0 -42
- package/dist/web-ui/assets/Deliverables-Bx8nwOQ9.js +0 -3
- package/dist/web-ui/assets/Settings-B90Lsxn1.js +0 -8
- package/dist/web-ui/assets/Team-BLcZORSs.js +0 -81
- package/dist/web-ui/assets/Work-FiluoP3I.js +0 -11
- package/dist/web-ui/assets/channel-eCnCx_6n.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Bm-i2o0g.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Bm-i2o0g.js +0 -1
- package/dist/web-ui/assets/index-BfGY_nvu.css +0 -1
- package/dist/web-ui/assets/index-DHzWBdt5.js +0 -672
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BflH5xmz.js +0 -1
|
@@ -145,6 +145,61 @@ Chrome version **144+** is required (146+ recommended). Check with:
|
|
|
145
145
|
| **Auto-Allow Debugging Dialog** | Off | Auto-click Chrome's "Allow remote debugging?" dialog via OS APIs. Only needed when extension is not installed. macOS requires Accessibility permission; Windows works out of the box; Linux not supported. |
|
|
146
146
|
| **Remote Debugging Port** | 0 (auto-connect) | Set to a port number (e.g. 9222) to use a persistent debugging connection instead of auto-connect, eliminating repeated permission dialogs. |
|
|
147
147
|
| **Extension Bridge Port** | 9333 | WebSocket port for communication between Markus and the Chrome extension. Change if 9333 conflicts with another service. |
|
|
148
|
+
| **Element Selection** | Direct | How agents decide *which* element to act on. Independent of the backend above. See the section below. |
|
|
149
|
+
|
|
150
|
+
## Element selection modes (Settings > Browser Automation)
|
|
151
|
+
|
|
152
|
+
Two orthogonal axes are configured in this section. They combine freely:
|
|
153
|
+
|
|
154
|
+
| Axis | Setting | Question it answers |
|
|
155
|
+
|------|---------|---------------------|
|
|
156
|
+
| **Browser backend** | `mode` | WHICH browser runs (built-in Electron vs system Chrome) |
|
|
157
|
+
| **Element selection** | `elementSelection` | HOW the agent picks the element to act on |
|
|
158
|
+
|
|
159
|
+
### Direct (default)
|
|
160
|
+
|
|
161
|
+
You call `take_snapshot`, read the accessibility tree, and pick the element yourself. This is the
|
|
162
|
+
normal flow described in this document. Nothing changes.
|
|
163
|
+
|
|
164
|
+
### Jev-assisted
|
|
165
|
+
|
|
166
|
+
When the user selects this mode, the platform appends an instruction block to this skill telling
|
|
167
|
+
you to route element choice through the `decide` tool (a decision model — e.g. TypeSafe Jev).
|
|
168
|
+
The loop is:
|
|
169
|
+
|
|
170
|
+
1. **Enumerate in code** — `evaluate_script` returns a compact, numbered list of interactive
|
|
171
|
+
elements, each tagged with a stable selector. Scope it to the relevant container, never the
|
|
172
|
+
whole page.
|
|
173
|
+
2. **Ask once** — call `decide` with the goal, the current stage, and that numbered list. Ask ONE
|
|
174
|
+
question: which element should I operate on next.
|
|
175
|
+
3. **Check `confidence`** — below 0.5, do not act; narrow the scope and re-ask, or stop and ask the
|
|
176
|
+
user.
|
|
177
|
+
4. **Act** — use the normal `click` / `fill` tool with the selector you tagged in step 1.
|
|
178
|
+
|
|
179
|
+
The decision model emits **no text**: it cannot produce a selector, a coordinate, or a click. Your
|
|
180
|
+
code owns what is possible, and you must re-validate the element before acting.
|
|
181
|
+
|
|
182
|
+
Four rules, all from measurement — not optional:
|
|
183
|
+
|
|
184
|
+
- **Put the evidence in the state — the model only knows what you send it.** It cannot see the page.
|
|
185
|
+
A question whose evidence is missing still returns a confident-looking number (measured: same
|
|
186
|
+
question, same model — 0.3 without the observed button text, 0.97 with it; truth = yes). Read the
|
|
187
|
+
DOM in code, pass the observation in `state`, and put the option list in `criteria`.
|
|
188
|
+
|
|
189
|
+
- **Never split action and element into two questions.** The answers are computed independently and
|
|
190
|
+
can contradict each other (measured: `action="type"` together with `target="none"`). Ask only for
|
|
191
|
+
the element; derive the action from its role in code.
|
|
192
|
+
- **Always state the current stage / next subgoal.** Without it, the model latches onto a word in the
|
|
193
|
+
goal and picks an element with a matching name (measured: a goal containing “登录” made it choose
|
|
194
|
+
the link *named* “登录”, confidence 0.88, wrong page region). Rewording the goal or adding a stage
|
|
195
|
+
line fixed it.
|
|
196
|
+
- **A `choice` question accepts at most 255 options.** If the scope yields more, narrow it in code
|
|
197
|
+
first — do not spread the whole page across parallel questions (measured: 609 elements →
|
|
198
|
+
`HTTP 400 Too many choices`).
|
|
199
|
+
|
|
200
|
+
Measured trade-off, so you can set expectations: on a small page, Jev-assisted is ~2x faster per
|
|
201
|
+
step but roughly comparable in cost; on a dense page it is both cheaper and more accurate than
|
|
202
|
+
reading the full snapshot. Use it where the page is large or repetitive.
|
|
148
203
|
|
|
149
204
|
## Tool reference
|
|
150
205
|
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/docx-preview-CaBnt7lQ.js","assets/index-DHzWBdt5.js","assets/index-BfGY_nvu.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as D,r as d,l as E,j as r,_ as z,h as F,o as pe,t as xe}from"./index-DHzWBdt5.js";const J=new Set(["pdf","docx","xlsx"]),be=30*1024*1024;function De({data:e,reference:s,onFallback:n}){const{t:a}=D("deliverables"),t=(e.format||"").toLowerCase().replace(/^\./,""),i=d.useRef(null),[o,c]=d.useState("loading"),[u,f]=d.useState(""),[h,b]=d.useState(0),[m,M]=d.useState(null),[y,V]=d.useState(1),[v,$]=d.useState(1),g=d.useCallback(()=>{n?.()},[n]),S=d.useCallback(async()=>{if(s)try{await E.files.reveal(s);return}catch{}g()},[s,g]),w=d.useCallback(p=>{const j=i.current?.querySelector(`canvas[data-page="${p}"]`);j&&(j.scrollIntoView({behavior:"smooth",block:"start"}),V(p))},[]);d.useEffect(()=>{const p=i.current;if(!p||!J.has(t)){c("ready");return}let j=!1,k;return c("loading"),f(""),p.innerHTML="",(async()=>{try{t==="pdf"?k=await we(e.streamUrl,p,{onReady:I=>{M(I),V(1)},zoom:v}):t==="docx"?k=await je(e.streamUrl,p):t==="xlsx"&&(k=await ke(e.streamUrl,p)),j||c("ready")}catch(I){j||(c("error"),f(String(I)))}})(),()=>{j=!0,k&&k(),p.innerHTML=""}},[e.streamUrl,t,h,v]);const A=!J.has(t);return r.jsx("div",{className:"flex flex-col h-full min-h-0",children:A?r.jsx(me,{format:t,size:e.size,onOpenSystem:S,onDownload:()=>g()}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-1.5 border-b border-border-default/60 bg-surface-elevated/40",children:[r.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wide",children:t}),e.name&&r.jsx("span",{className:"text-[11px] text-fg-secondary truncate flex-1 min-w-0",title:e.name,children:e.name}),e.size!=null&&e.size>be&&r.jsx("span",{className:"text-[10px] text-amber-500 shrink-0",children:a("officeLargeFile")}),t==="pdf"&&m!=null&&r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{onClick:()=>w(Math.max(1,y-1)),disabled:y<=1,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"‹"}),r.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[y,"/",m]}),r.jsx("button",{onClick:()=>w(Math.min(m??1,y+1)),disabled:y>=(m??1),className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"›"})]}),t==="pdf"&&r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx("button",{onClick:()=>$(p=>Math.max(.5,+(p-.25).toFixed(2))),disabled:v<=.5,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"−"}),r.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:[Math.round(v*100),"%"]}),r.jsx("button",{onClick:()=>$(p=>Math.min(3,+(p+.25).toFixed(2))),disabled:v>=3,className:"w-6 h-6 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary disabled:opacity-30",children:"+"})]}),r.jsx("button",{onClick:S,className:"shrink-0 text-[10px] text-fg-tertiary hover:text-fg-secondary px-1.5 py-0.5 rounded hover:bg-surface-overlay transition-colors",children:a("officeOpenSystem")})]}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[o==="loading"&&r.jsxs("div",{className:"flex items-center justify-center h-full text-fg-tertiary",children:[r.jsxs("svg",{className:"animate-spin w-4 h-4 mr-2",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{className:"text-xs",children:a("officeLoading")})]}),o==="error"&&r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-center px-4",children:[r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("officeFailed")}),r.jsx("span",{className:"text-[10px] text-fg-quaternary max-w-xs truncate",children:u}),r.jsxs("div",{className:"flex gap-2 mt-1",children:[r.jsx("button",{onClick:()=>b(p=>p+1),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 transition-colors",children:a("officeRetry")}),r.jsx("button",{onClick:S,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:a("officeOpenSystem")})]})]}),r.jsx("div",{ref:i,className:o==="loading"?"hidden":""})]})]})})}function me({format:e,size:s,onOpenSystem:n,onDownload:a}){const{t}=D("deliverables");return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-6",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated flex items-center justify-center text-xl",children:"📄"}),r.jsx("div",{className:"text-xs text-fg-secondary",children:t("officeNoInlinePreview",{format:e})}),s!=null&&r.jsx("div",{className:"text-[10px] text-fg-tertiary",children:t("officeSize",{size:ge(s)})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 transition-colors",children:t("officeOpenSystem")}),r.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs border border-border-default text-fg-secondary rounded-lg hover:bg-surface-elevated transition-colors",children:t("officeDownload")})]})]})}function ge(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ye(){const e=Uint8Array.prototype;typeof e.toHex!="function"&&(e.toHex=function(){let t="",i=0,o=this.length,c;for(;i<o;++i)c=this[i],t+=(c>>>4).toString(16)+(c&15).toString(16);return t});const s=Map.prototype;typeof s.getOrInsertComputed!="function"&&(s.getOrInsertComputed=function(t,i){if(this.has(t))return this.get(t);const o=i(t);return this.set(t,o),o}),typeof s.getOrInsert!="function"&&(s.getOrInsert=function(t,i){return this.has(t)?this.get(t):(this.set(t,i),i)});const n=Promise;typeof n.try!="function"&&(n.try=function(t){return new Promise(i=>i(t()))});const a=typeof Iterator<"u"?Iterator.prototype:null;a&&typeof a.join!="function"&&(a.join=function(t=","){let i="",o=!0;for(const c of this)o||(i+=t),i+=String(c),o=!1;return i})}ye();let U=null;function ve(){if(!U){const s=`
|
|
3
|
-
if (typeof Uint8Array.prototype.toHex !== 'function') {
|
|
4
|
-
Uint8Array.prototype.toHex = function() {
|
|
5
|
-
var s = '', i = 0, n = this.length, b;
|
|
6
|
-
for (; i < n; ++i) {
|
|
7
|
-
b = this[i];
|
|
8
|
-
s += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
|
|
9
|
-
}
|
|
10
|
-
return s;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
Map.prototype.getOrInsertComputed ??= function(key, cb) {
|
|
14
|
-
if (this.has(key)) return this.get(key);
|
|
15
|
-
const v = cb(key);
|
|
16
|
-
this.set(key, v);
|
|
17
|
-
return v;
|
|
18
|
-
};
|
|
19
|
-
Map.prototype.getOrInsert ??= function(key, value) {
|
|
20
|
-
if (this.has(key)) return this.get(key);
|
|
21
|
-
this.set(key, value);
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
Promise.try ??= function(fn) { return new Promise(function(res) { res(fn()); }); };
|
|
25
|
-
var ip = typeof Iterator !== 'undefined' ? Iterator.prototype : null;
|
|
26
|
-
if (ip && typeof ip.join !== 'function') {
|
|
27
|
-
ip.join = function(sep) {
|
|
28
|
-
sep = sep || ',';
|
|
29
|
-
var r = '', first = true;
|
|
30
|
-
for (var v of this) { if (!first) r += sep; r += String(v); first = false; }
|
|
31
|
-
return r;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).toString()}");
|
|
35
|
-
`;U=URL.createObjectURL(new Blob([s],{type:"text/javascript"}))}return U}async function we(e,s,n){const a=await z(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=ve();const t=await a.getDocument({url:e}).promise,i=[];for(let o=1;o<=t.numPages;o++){const c=await t.getPage(o),u=c.getViewport({scale:1.5*n.zoom}),f=document.createElement("canvas");f.width=Math.floor(u.width),f.height=Math.floor(u.height),f.style.width=`${Math.floor(u.width)}px`,f.style.height=`${Math.floor(u.height)}px`,f.style.marginBottom="8px",f.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",f.style.borderRadius="2px";const h=f.getContext("2d");if(!h)throw new Error("canvas 2d context unavailable");await c.render({canvas:f,canvasContext:h,viewport:u}).promise,f.dataset.page=String(o),s.appendChild(f),i.push(f)}return n.onReady(t.numPages),()=>{for(const o of i)o.remove();t.cleanup()}}async function je(e,s){const{renderAsync:n}=await z(async()=>{const{renderAsync:t}=await import("./docx-preview-CaBnt7lQ.js");return{renderAsync:t}},__vite__mapDeps([0,1,2])),a=await fetch(e).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()});if(a.size===0)throw new Error("empty docx");return await n(a,s,void 0,{inWrapper:!0,ignoreWidth:!0,ignoreHeight:!1,breakPages:!0,className:"office-docx"}),()=>{s.innerHTML=""}}async function ke(e,s){const n=await z(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.arrayBuffer()});if(a.byteLength===0)throw new Error("empty xlsx");const t=n.read(a,{type:"array"});if(!t.SheetNames||t.SheetNames.length===0)throw new Error("no sheets");const i=n.utils.sheet_to_html(t.Sheets[t.SheetNames[0]],{id:"office-xlsx-sheet",editable:!1});s.innerHTML=i;const o=document.createElement("style");return o.textContent=`
|
|
36
|
-
#office-xlsx-sheet { border-collapse: collapse; font-size: 12px; color: var(--fg-primary, #333); }
|
|
37
|
-
#office-xlsx-sheet td, #office-xlsx-sheet th {
|
|
38
|
-
border: 1px solid var(--border-default, #ddd); padding: 4px 8px; white-space: nowrap;
|
|
39
|
-
background: var(--surface-primary, #fff);
|
|
40
|
-
}
|
|
41
|
-
#office-xlsx-sheet th { background: var(--surface-elevated, #f3f4f6); font-weight: 600; }
|
|
42
|
-
`,s.prepend(o),()=>{s.innerHTML=""}}const Y=50*1024*1024,se=new Set(["markdown","html"]);function Ne(e){return e||"markdown"}function Se(e){return se.has(Ne(e))}class P extends Error{constructor(s){super(s),this.name="DeliverableShareError"}}class ae extends P{constructor(){super("需要登录 Markus Hub 账号后才能分享产出物。"),this.name="NotLoggedIntoHubError"}}class Ie extends P{bytes;limit;constructor(s,n){super(`产出物文件大小 ${s} 字节超过上限 ${n} 字节(50MB),请压缩或拒绝分享。`),this.name="DeliverableTooLargeError",this.bytes=s,this.limit=n}}class Ce extends P{status;constructor(s,n){super(`Hub 请求失败 (HTTP ${s}): ${n}`),this.name="HubApiError",this.status=s}}function He(e){const s=e.replace(/\s+/g,"");if(!s)return 0;let n=0;return s.endsWith("==")?n=2:s.endsWith("=")&&(n=1),Math.floor(s.length*3/4)-n}function B(e,s){const n=e&&typeof e=="object"?e:{},a=n.share??n.deliverable??{},t=m=>n[m]??a[m],i=t("id")??t("shareId")??"",o=t("slug"),c=o!=null?String(o):void 0,u=t("url")??t("shareUrl");let f=null;u!=null?f=String(u):c&&s&&(f=`${s.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(c)}`);const h=t("reason")??t("rejectNote"),b=t("localDeliverableId")??t("localId");return{id:String(i),slug:c,visibility:t("visibility")??"public",status:t("status")??"pending_review",url:f,reason:h!=null?String(h):null,localId:b!=null?String(b):null}}class Ee{basePath;fetchImpl;hubOrigin;constructor(s){this.getHubToken=s.getHubToken,this.hubOrigin=s.hubUrl,this.basePath=(s.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=s.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new ae}async doFetch(s,n){const a=this.getHubToken(),t={"Content-Type":"application/json",...n.headers};a&&(t.Authorization=`Bearer ${a}`);const i=await this.fetchImpl(`${this.basePath}${s}`,{...n,headers:t,credentials:"include"});let o=null;try{o=await i.json()}catch{o=null}if(!i.ok){const c=o&&typeof o=="object"&&"error"in o?String(o.error):i.statusText||`HTTP ${i.status}`;throw new Ce(i.status,c)}return{status:i.status,data:o}}async publish(s){this.assertHubLoggedIn();const n=s.fileSizeBytes??(s.fileBase64?He(s.fileBase64):0);if(n>Y)throw new Ie(n,Y);const a={localDeliverableId:s.localId,visibility:s.visibility,title:s.title,summary:s.summary,tags:s.tags,filename:s.filename,format:s.format,producerAgent:{id:s.producerAgent.id,name:s.producerAgent.name,source:s.producerAgent.source}};s.content&&(a.content=s.content),s.fileBase64&&(a.fileBase64=s.fileBase64);const{data:t}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(a)});return B(t,this.hubOrigin)}async pollStatus(s){this.assertHubLoggedIn();const{data:n}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(s)}`,{method:"GET"});return B(n,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:s}=await this.doFetch("/deliverables/mine",{method:"GET"}),n=s&&typeof s=="object"?s:{};return(Array.isArray(n.shares)?n.shares:[]).map(t=>B(t,this.hubOrigin))}async revoke(s){this.assertHubLoggedIn();const{data:n}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:s})});return{...B(n,this.hubOrigin),status:"revoked",url:null}}}function Le(e,s){return new Ee({getHubToken:e,hubUrl:s,proxyBasePath:"/api/hub"})}const Te=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,Pe=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function Q(e){return Te.test(e)?"image":Pe.test(e)?"media":"other"}function Me(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function ee(e){const s=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(s)return s[1].trim().split(/\s+(?="|')/)[0].trim()||null;const n=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return n?n[1]:null}function te(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function re(e,s){if(!e)return null;const n=e.trim(),a=n.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(a)try{return decodeURIComponent(a[1])||null}catch{return a[1]||null}return/^file:\/\//i.test(n)?Me(n).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(n)?n.replace(/\\/g,"/"):n.startsWith("/")?n:s&&(n.startsWith("./")||n.startsWith("../")||!n.includes("://"))?`${s.replace(/\\/g,"/").replace(/\/+$/,"")}/${n.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function Ve(e,s){const n=[],a=new Set,t=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const o of e.matchAll(t)){const c=o[0],u=ee(c);if(!u||!te(u))continue;const f=re(u,s);!f||a.has(c)||(a.add(c),n.push({raw:c,localPath:f,kind:Q(f.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const o of e.matchAll(i)){const c=o[0],u=ee(c);if(!u||!te(u))continue;const f=re(u,s);!f||a.has(c)||(a.add(c),n.push({raw:c,localPath:f,kind:Q(f.split("?")[0])}))}return{refs:n,baseDir:s??""}}function $e(e,s){let n=e;for(const[a,t]of s){const i=Ae(a,t);n=n.split(a).join(i)}return n}function Ae(e,s){const n=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(n)return`${n[1]}(${s})`;const a=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return a?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${a[1]}${a[2]}${a[3]}${s}${a[3]}`):s}function Re(e,s){return/^https?:\/\//i.test(e)?e:`${s.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function _e(e,s,n){const a=new Map,t=new Map(e.map(i=>[i.localPath,i]));for(const i of s){if(!i.key)continue;const o=t.get(i.key);!o||!i.url||a.set(o.raw,Re(i.url,n))}return a}async function Be(e){try{const s=E.files.streamUrl(e),n=await fetch(s).then(u=>u.ok?u.blob():null);if(!n)return null;const a=await n.arrayBuffer(),t=new Uint8Array(a);let i="";const o=32768;for(let u=0;u<t.length;u+=o)i+=String.fromCharCode.apply(null,Array.from(t.subarray(u,u+o)));const c=e.split("/").pop()||"media";return{base64:btoa(i),filename:c}}catch{return null}}async function Oe(e,s){const n=new Map;if(e.length===0)return n;const a=[];for(const o of e){const c=await Be(o.localPath);c&&a.push({key:o.localPath,filename:c.filename,base64:c.base64})}if(a.length===0)return n;const{files:t,errors:i}=await F.uploadMediaBatch(a);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),_e(e,t,s)}async function Ue(e,s,n){if(!e||s==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const a=await E.files.preview(e);if((a.type==="text"||a.type==="markdown"||a.type==="html"||a.type==="json"||a.type==="csv")&&typeof a.content=="string"){if(!(a.type==="markdown"||a.type==="html"))return{content:a.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:o}=Ve(a.content,i);if(o.length===0)return{content:a.content};const c=await Oe(o,n);return c.size===0?{content:a.content}:{content:$e(a.content,c),uploadedMedia:c.size}}if(a.type==="image"||a.type==="audio"||a.type==="video"||a.type==="binary"){const t=a.streamUrl||(a.path?E.files.streamUrl(a.path):E.files.streamUrl(e)),o=await(await fetch(t).then(h=>h.blob())).arrayBuffer(),c=new Uint8Array(o);let u="";const f=32768;for(let h=0;h<c.length;h+=f)u+=String.fromCharCode.apply(null,Array.from(c.subarray(h,h+f)));return{fileBase64:btoa(u)}}return{}}catch{return{}}}function ze({item:e,onClose:s,onShared:n,service:a}){const{t}=D(["deliverables","common"]),i=d.useMemo(()=>a??Le(pe,F.getUrl()),[a]),[o,c]=d.useState(()=>i?i.isHubLoggedIn():null),[u,f]=d.useState(!1),[h,b]=d.useState(()=>{const l=e.shareStatus;return l==="published"?"published":l==="pending_review"?"pending_review":l==="rejected"?"rejected":"form"}),[m,M]=d.useState("public"),[y,V]=d.useState(e.title||""),[v,$]=d.useState(e.summary||""),[g,S]=d.useState(Array.isArray(e.tags)?[...e.tags]:[]),[w,A]=d.useState(""),[p,j]=d.useState(null),[k,I]=d.useState(!1),[R,N]=d.useState(null),W=d.useRef(n);W.current=n;const C=d.useCallback(l=>{j(l);const x=l.status;b(x==="published"?"published":x==="rejected"?"rejected":x==="revoked"?"revoked":x==="pending_review"?"pending_review":"form"),W.current?.(l)},[]);d.useEffect(()=>{c(i.isHubLoggedIn())},[i]);const ne=d.useCallback(async()=>{f(!0),N(null);try{await xe({force:!0}),c(i.isHubLoggedIn())}catch{c(i.isHubLoggedIn())}finally{f(!1)}},[i]),O=d.useCallback(()=>{const l=w.trim().replace(/^#/,"");l&&!g.includes(l)&&S(x=>[...x,l]),A("")},[w,g]),ie=d.useCallback(l=>{S(x=>x.filter(H=>H!==l))},[]),le=d.useCallback(l=>{l.key==="Enter"||l.key===","?(l.preventDefault(),O()):l.key==="Backspace"&&!w&&g.length&&S(x=>x.slice(0,-1))},[O,w,g.length]),oe=d.useCallback(()=>{const l=p?.url??e.shareUrl;l&&navigator.clipboard?.writeText(l).then(()=>{I(!0),setTimeout(()=>I(!1),1500)}).catch(()=>{})},[p,e.shareUrl]),ce=d.useCallback(async()=>{if(!Se(e.format)){N(`分享仅支持 ${[...se].join(" / ")} 格式`);return}N(null),b("busy");try{const l=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",x=F.getUrl(),{content:H,fileBase64:ue,uploadedMedia:G}=await Ue(e.reference,e.type,x);G&&console.info(`[deliverable-share] uploaded ${G} local media reference(s) to Hub`);const L=e.agentId??"";let Z=L;if(L)try{const{agents:fe}=await E.agents.list(),q=fe.find(he=>he.id===L);q&&(Z=q.name||L)}catch{}const T=await i.publish({localId:e.id,title:y.trim()||e.title,summary:v.trim(),tags:g,visibility:m,filename:l,format:e.format||"markdown",content:H,fileBase64:ue,producerAgent:{id:L,name:Z,source:"local"}});C(T),T.status==="rejected"?N(typeof T.reason=="string"&&T.reason?T.reason:"分享被拒绝"):s()}catch(l){if(b("form"),l instanceof ae){c(!1);return}N(l instanceof P||l instanceof Error?l.message:String(l))}},[i,e,y,v,g,m,C]),de=d.useCallback(async()=>{N(null);try{const l=await i.revoke(e.id);C({...l,status:"revoked",url:null})}catch(l){N(l instanceof P?l.message:String(l))}},[i,e.id,C]),K=d.useCallback(()=>{b("form"),N(null)},[]);d.useEffect(()=>{if(h!=="pending_review")return;let l=!1;const x=setInterval(async()=>{try{const H=await i.pollStatus(e.id);if(l)return;H.status!=="pending_review"&&C(H)}catch{}},8e3);return()=>{l=!0,clearInterval(x)}},[h,i,e.id,C]),d.useEffect(()=>{const l=x=>{x.key==="Escape"&&s()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[s]);const _=m==="link",X=p?.url??e.shareUrl;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:s,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:l=>l.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:t("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:s,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:o===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:t("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{ne()},disabled:u,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors disabled:opacity-60",children:u?t("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):t("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:t("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:h==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:t("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?t("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):t("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),X?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:X}),r.jsx("button",{onClick:oe,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${k?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:k?t("common:copied",{defaultValue:"已复制"}):t("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:t("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{de()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:t("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):h==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:t("deliverables:share.pendingReview",{defaultValue:"审核中"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:t("deliverables:share.pendingHint",{defaultValue:"你的产出物已提交审核,通过后将生成可分享链接。"})})]}):h==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:t("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),R&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:R}),r.jsx("button",{onClick:K,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:t("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):h==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:t("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:K,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:t("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:t("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${_?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!_,onChange:()=>M("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:t("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:t("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${_?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:_,onChange:()=>M("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:t("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:t("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:t("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:y,onChange:l=>V(l.target.value),placeholder:t("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:t("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:v,onChange:l=>$(l.target.value),rows:3,placeholder:t("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:t("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:g.map(l=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[l,r.jsx("button",{onClick:()=>ie(l),className:"text-fg-tertiary hover:text-red-500","aria-label":"remove",children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},l))}),r.jsx("input",{value:w,onChange:l=>A(l.target.value),onKeyDown:le,onBlur:O,placeholder:t("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),R&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:R}),r.jsxs("button",{type:"button",onClick:()=>{ce()},disabled:h==="busy"||!y.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[h==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),h==="busy"?t("deliverables:share.sharing",{defaultValue:"分享中…"}):t("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]})}export{ze as D,De as O,Se as a,Le as c};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{u as Ke,j as e,r as a,a as vs,b as js,m as ks,d as ws,c as Ns,l as p,w as xt,o as Jt,p as Ss,P,n as ee,M as Cs,q as Ue,h as Is,i as Xt,s as Ls}from"./index-DHzWBdt5.js";import{resolveFormat as Rs,ContentRenderer as Es}from"./ContentRenderer-BEWNNIbH.js";import{c as Ts,a as Ps,O as Bs,D as Ms}from"./DeliverableShareModal-C4bKsQbU.js";function $(d){return Array.isArray(d)?d.map(o=>String(o).trim()).filter(Boolean):typeof d=="string"&&d?d.split(",").map(o=>o.trim()).filter(Boolean):[]}function As(d){return d.files&&typeof d.files=="object"&&!Array.isArray(d.files)?d.files:null}function te({label:d,value:o}){return o?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:d}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:o})]}):null}function de({label:d,value:o,color:c}){if(!o)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:d}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[c]??r.gray} capitalize inline-block`,children:o})]})}function ft({files:d}){const{t:o}=Ke(["builder","common"]),[c,r]=a.useState(Object.keys(d)[0]??""),u=Object.keys(d);return u.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o("builder:artifact.files",{count:u.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:u.map(v=>e.jsx("button",{onClick:()=>r(v),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${c===v?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:v},v))}),c&&d[c]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:d[c]})]})]})}function $s({artifact:d,mode:o}){const{t:c}=Ke(["builder","common"]),r=As(d),u=d.agent,v=d.team,S=d.dependencies,N=d.displayName??d.name;if(o==="agent"){const j=u?.roleName,E=u?.agentRole,k=u?.llmProvider,L=u?.llmModel,g=$(S?.env),R=$(S?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(te,{label:c("builder:artifact.name"),value:N}),e.jsx(te,{label:c("builder:artifact.description"),value:d.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[j&&e.jsx(de,{label:c("builder:artifact.baseTemplate"),value:j,color:"indigo"}),e.jsx(de,{label:c("builder:artifact.agentRole"),value:E,color:E==="manager"?"purple":"cyan"})]}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(w=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:w},w))}),(k||L)&&e.jsxs("div",{className:"flex gap-2",children:[k&&e.jsx(de,{label:c("builder:artifact.llmProvider"),value:k,color:"gray"}),L&&e.jsx(de,{label:c("builder:artifact.llmModel"),value:L,color:"gray"})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(w=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:w},w))})]}),R.length>0&&e.jsx(te,{label:c("builder:artifact.skills"),value:R.join(", ")}),r&&e.jsx(ft,{files:r})]})}if(o==="team"){const E=v?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(te,{label:c("builder:artifact.name"),value:N}),e.jsx(te,{label:c("builder:artifact.description"),value:d.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(de,{label:c("builder:artifact.category"),value:d.category,color:"indigo"})}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),r&&e.jsx(ft,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.members",{count:E.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:E.map((k,L)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${k.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:k.role==="manager"?"★":L+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:k.name}),typeof k.roleName=="string"&&k.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:k.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(k.count??1)]})]}),$(k.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:$(k.skills).map(g=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},L))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(te,{label:c("builder:artifact.name"),value:N}),e.jsx(te,{label:c("builder:artifact.description"),value:d.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(de,{label:c("builder:artifact.category"),value:d.category,color:"indigo"})}),r&&e.jsx(ft,{files:r}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(j=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:j},j))})]})}const ue={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Ds=["file","directory"];function Oe(d){return/^https?:\/\//i.test(d)}function I(d){return d?.shareStatus??null}function Vs(d,o){const c=Date.now(),r=new Date(d).getTime(),u=c-r,v=Math.floor(u/6e4);if(v<1)return o("time.justNow");if(v<60)return o("time.minutesAgo",{count:v});const S=Math.floor(v/60);if(S<24)return o("time.hoursAgo",{count:S});const N=Math.floor(S/24);if(N===1)return o("time.yesterday");if(N<30)return o("time.daysAgo",{count:N});const j=Math.floor(N/30);return j<12?o("time.monthsAgo",{count:j}):o("time.yearsAgo",{count:Math.floor(j/12)})}const z={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function Us({authUser:d,previewMode:o,previewData:c}={}){const{t:r}=Ke(["deliverables","common"]),u=vs(),v=js(P.DELIVERABLES),S=ks({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[N,j]=a.useState(!1),E=a.useRef(N);E.current=N,a.useEffect(()=>{if(!u)return;const t=()=>{E.current&&j(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[u]);const k=100,L=5e3,[g,R]=a.useState(c?.items??[]),[w,D]=a.useState(c?.items?.length??0),[m,se]=a.useState(!1),[ze,ht]=a.useState(c?.projects??[]),[mt,pt]=a.useState(c?.agents??[]),[gt,es]=a.useState([]),[G,bt]=a.useState(!c),[Ie,Le]=a.useState(""),[fe,Re]=a.useState(""),[V,he]=a.useState(""),[W,me]=a.useState(""),[F,H]=a.useState(""),[re,Ee]=a.useState(""),[ts,Ge]=a.useState(!1),[B,yt]=a.useState("date"),[n,T]=a.useState(()=>c?.initialSelectedId&&c.items?c.items.find(t=>t.id===c.initialSelectedId)??c.items[0]??null:c?.items?.[0]??null),[qe,vt]=a.useState(null),[jt,kt]=a.useState(""),[q,ss]=a.useState(!0),[Ye,pe]=a.useState(()=>{const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([s])}),[Qe,rs]=a.useState(!1),[Je,wt]=a.useState(!1),ns=a.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),as=a.useCallback(t=>{yt(t)},[]),Nt=ws(ns,B,as),Y=a.useRef(null),[Te,Pe]=a.useState(null),[Be,St]=a.useState("markdown"),[ge,Ct]=a.useState(null),[be,It]=a.useState(null),[ne,Lt]=a.useState(null),[Rt,Et]=a.useState(!1),[Tt,ye]=a.useState(!1),[Me,Pt]=a.useState(!1),[Xe,Ae]=a.useState(null),[ls,Ze]=a.useState(!1),[et,is]=a.useState(""),[Bt,os]=a.useState(new Set),ve=ne&&n?.type==="file",[_,Q]=a.useState(!1),M=Ns(),ae=M?.keyboardPane??"content",[je,le]=a.useState(null),[ie,J]=a.useState(!1),[ke,tt]=a.useState(""),[U,X]=a.useState(!1),[st,Mt]=a.useState(!1),[rt,Z]=a.useState(null),nt=a.useRef(null),At=a.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),$t=a.useRef(void 0);a.useEffect(()=>{At(nt.current)},[ke,ie,At]);const A=(t,s)=>{vt({type:t,text:s}),setTimeout(()=>vt(null),3e3)},Dt=async t=>{await Ls(t)?(Pt(!0),setTimeout(()=>Pt(!1),1500)):A("error",r("detail.copyFailed"))},$e=a.useMemo(()=>new Map(mt.map(t=>[t.id,t])),[mt]),at=a.useMemo(()=>new Map(ze.map(t=>[t.id,t])),[ze]),Vt=a.useMemo(()=>new Map(gt.map(t=>[t.id,t])),[gt]),we=a.useCallback(t=>{if(!t||t==="default")return null;const s=at.get(t)?.name;return!s||s==="default"?null:s},[at]);a.useEffect(()=>{o||(p.projects.list().then(t=>ht(t.projects)).catch(()=>{}),p.agents.list().then(t=>pt(t.agents??[])).catch(()=>{}),p.teams.list().then(t=>es(t.teams??[])).catch(()=>{}),p.system.storage().then(t=>is(t.dataDir+"/shared")).catch(()=>{}),p.deliverables.checkHealth().then(t=>os(new Set(t.missingFiles))).catch(()=>{}))},[o]),a.useEffect(()=>($t.current=setTimeout(()=>Re(Ie),300),()=>clearTimeout($t.current)),[Ie]);const oe=a.useMemo(()=>({q:fe||void 0,projectId:re||void 0,type:V||void 0,artifactType:W||void 0,source:F||void 0}),[fe,V,W,re,F]),ce=B==="date"?k:L,lt=a.useCallback((t,s)=>s?{...s,hubShareId:s.hubShareId!=null?s.hubShareId:t.hubShareId??null,shareStatus:s.shareStatus!=null?s.shareStatus:t.shareStatus??null,shareUrl:s.shareUrl!=null?s.shareUrl:t.shareUrl??null,shareVisibility:s.shareVisibility!=null?s.shareVisibility:t.shareVisibility??null,shareReason:s.shareReason!=null?s.shareReason:t.shareReason}:t,[]),De=a.useCallback(async()=>{try{const{results:t,total:s}=await p.deliverables.search({...oe,offset:0,limit:ce});R(i=>i.map(l=>{const f=t.find(x=>x.id===l.id);return f?lt(l,f):l})),D(s),T(i=>{if(!i)return null;const l=t.find(f=>f.id===i.id);return l?lt(i,l):i})}catch{}},[oe,ce,lt]),O=a.useCallback(async()=>{bt(!0),Y.current?.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:s}=await p.deliverables.search({...oe,offset:0,limit:ce});R(t),D(s),T(i=>i&&t.some(l=>l.id===i.id)?i:null)}catch{R([]),D(0),T(null)}bt(!1)},[oe,ce]),Ve=a.useCallback(async()=>{if(!(m||g.length>=w)){se(!0);try{const{results:t,total:s}=await p.deliverables.search({...oe,offset:g.length,limit:ce});R(i=>[...i,...t]),D(s)}catch{}se(!1)}},[oe,ce,g.length,w,m]);a.useEffect(()=>{o||O()},[O,o]),a.useEffect(()=>{!o||!c||(R(c.items??[]),D(c.items?.length??0),ht(c.projects??[]),pt(c.agents??[]),c.initialSelectedId&&T(c.items?.find(t=>t.id===c.initialSelectedId)??c.items?.[0]??null))},[o,c]);const it=a.useRef(n);it.current=n,a.useEffect(()=>{if(o||!v)return;const t=xt.on("deliverable:created",()=>O()),s=xt.on("deliverable:updated",l=>{De();const f=l.payload?.deliverableId;f&&it.current?.id===f&&p.deliverables.get(f).then(x=>{x.deliverable&&(T(h=>({...h??x.deliverable,...x.deliverable,hubShareId:h?.hubShareId??x.deliverable.hubShareId??null,shareStatus:h?.shareStatus??x.deliverable.shareStatus??null,shareUrl:h?.shareUrl??x.deliverable.shareUrl??null,shareVisibility:h?.shareVisibility??x.deliverable.shareVisibility??null,shareReason:h?.shareReason??x.deliverable.shareReason??null})),Ht(x.deliverable))}).catch(()=>{})}),i=xt.on("deliverable:removed",()=>O());return()=>{t(),s(),i()}},[De,v,o]);const Wt=a.useMemo(()=>Ts(Jt,Is.getUrl()),[]);a.useEffect(()=>{if(o||!v||!Jt())return;let t=!1;const s=async()=>{try{const l=await Wt.listMine();if(t)return;const f=new Map,x=new Map;for(const b of l)b.id&&f.set(b.id,b),b.localId&&x.set(b.localId,b);const h=new Map;R(b=>b.map(y=>{const C=y.hubShareId&&f.get(y.hubShareId)||x.get(y.id);if(!C)return y;const Ce={hubShareId:y.hubShareId??C.id??null,shareStatus:C.status??null,shareUrl:C.url??null,shareVisibility:y.shareVisibility??C.visibility??null,...C.reason!=null?{shareReason:C.reason}:{}};return h.set(y.id,Ce),{...y,...Ce}})),T(b=>{if(!b)return b;const y=h.get(b.id);return y?{...b,...y}:b});for(const[b,y]of h)p.deliverables.update(b,y).catch(C=>{console.warn("[deliverables] Hub 分享状态本地持久化失败:",C)})}catch{}};s();const i=setInterval(s,3e4);return()=>{t=!0,clearInterval(i)}},[Wt,v,o]);const We=a.useRef(null),ot=a.useRef(g);ot.current=g;const Ne=a.useCallback(t=>{const s=l=>{T(l),u&&(j(!0),history.pushState({mobileDetail:P.DELIVERABLES},"",window.location.hash))},i=ot.current.find(l=>l.id===t);if(i){s(i);return}p.deliverables.get(t).then(l=>{l.deliverable&&s(l.deliverable)}).catch(()=>{})},[u]);a.useEffect(()=>{if(o)return;const t=window.location.hash.slice(1).split("/"),s=Ss(t[0])===P.DELIVERABLES?t[1]:void 0,i=localStorage.getItem("markus_nav_projectId"),l=localStorage.getItem("markus_nav_source");i&&(localStorage.removeItem("markus_nav_projectId"),Ee(i)),(l==="knowledge"||l==="agent")&&(localStorage.removeItem("markus_nav_source"),H(l));const f=localStorage.getItem("markus_nav_openDeliverable")||s;f&&(localStorage.removeItem("markus_nav_openDeliverable"),ot.current.length>0?Ne(f):We.current=f);const x=h=>{const y=h.detail?.params;y?.projectId&&Ee(y.projectId),(y?.source==="knowledge"||y?.source==="agent")&&H(y.source),y?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),Ne(y.openDeliverable))};return window.addEventListener("markus:navigate",x),()=>window.removeEventListener("markus:navigate",x)},[Ne,o]),a.useEffect(()=>{const t=We.current;!t||g.length===0||(We.current=null,Ne(t))},[g,Ne]);const Ft=a.useCallback(()=>{const t=Y.current;!t||G||m||g.length>=w||t.scrollHeight<=t.clientHeight+100&&Ve()},[G,m,g.length,w,Ve]);a.useEffect(()=>{const t=Y.current;if(!t)return;const s=()=>{t.scrollTop+t.clientHeight>=t.scrollHeight-100&&Ve()};return t.addEventListener("scroll",s,{passive:!0}),()=>t.removeEventListener("scroll",s)},[Ve]),a.useEffect(()=>{Ft()},[Ft,q,Ye]);const K=a.useMemo(()=>{const t=new Map;for(const i of g){let l,f;if(B==="project"){const x=we(i.projectId);l=x?i.projectId??"_none":"_none",f=x??r("noProject")}else if(B==="team"){const h=(i.agentId?$e.get(i.agentId):void 0)?.teamId??"_none";l=h,f=h!=="_none"?Vt.get(h)?.name??h:r("noTeam")}else if(B==="agent")l=i.agentId??"_none",f=i.agentId?$e.get(i.agentId)?.name??i.agentId:r("common:unknown");else{const x=new Date(i.updatedAt);l=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,f=l}t.has(l)||t.set(l,{label:f,items:[]}),t.get(l).items.push(i)}const s=[...t.entries()];return B==="date"?s.sort((i,l)=>l[0].localeCompare(i[0])):s.sort((i,l)=>i[1].label.localeCompare(l[1].label)),s},[g,B,at,$e,Vt,r]);a.useEffect(()=>{if(B==="date"&&q){const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;pe(new Set([s]))}else pe(new Set)},[B]);const cs=async t=>{kt("remove");try{await p.deliverables.remove(t.id),A("success",r("removed")),T(null),O()}catch(s){A("error",r("common:error",{message:String(s)}))}kt("")},ds=a.useCallback(t=>{const s=it.current,i=s?.id;if(!i)return;const l={hubShareId:t.id??null,shareStatus:t.status??null,shareUrl:t.url??null,shareVisibility:t.visibility??null,...t.reason!=null||t.status==="rejected"?{shareReason:t.reason??s?.shareReason??null}:{}},f={...l,shareStatus:l.shareStatus??s?.shareStatus??null};T(x=>x&&x.id===i?{...x,...f}:x),R(x=>x.map(h=>h.id===i?{...h,...f}:h)),(async()=>{try{await p.deliverables.update(i,l)}catch(x){console.warn("[deliverables] 分享状态本地回写失败,将由 Hub 轮询补偿:",x)}De()})()},[De]),us=()=>{ee.navigate(P.BUILDER)},Ht=async t=>{if(t.reference&&!Oe(t.reference)){if(t.type==="directory"){ye(!0);return}Et(!0);try{const s=await p.files.preview(t.reference);if(s.type==="image"&&s.mimeType){const i=s.streamUrl||(s.path?p.files.streamUrl(s.path):p.files.streamUrl(t.reference));Ct({src:i,name:s.name})}else if(s.type==="audio"||s.type==="video"){const i=s.streamUrl||(s.path?p.files.streamUrl(s.path):p.files.streamUrl(t.reference));It({kind:s.type,src:i,name:s.name})}else if(s.type==="office"){const i=s.streamUrl||(s.path?p.files.streamUrl(s.path):p.files.streamUrl(t.reference));Lt({format:s.format||String(s.extension||"").replace(/^\./,"")||"pdf",streamUrl:i,name:s.name,size:s.size,reference:s.path||t.reference})}else s.type==="binary"?ye(!0):typeof s.content=="string"?(Pe(s.content),St(Rs({format:t.format,reference:t.reference,content:s.content}))):ye(!0)}catch{Pe(null),t.type==="file"&&ye(!0)}Et(!1)}};a.useEffect(()=>{o||(Pe(null),St("markdown"),Ct(null),It(null),Lt(null),ye(!1),n&&Ht(n))},[n?.id,o]);const _t=a.useCallback(t=>q!==Ye.has(t),[q,Ye]),Ut=K.length>0&&K.every(([t])=>_t(t)),xs=a.useCallback(t=>{pe(s=>{const i=new Set(s);return i.has(t)?i.delete(t):i.add(t),i})},[]),Ot=a.useCallback(t=>{pe(s=>{if(s.has(t)===q)return s;const i=new Set(s);return q?i.add(t):i.delete(t),i})},[q]),fs=a.useCallback(()=>{ss(t=>!t),pe(new Set)},[]),Fe=!!(V||W||F||re||fe),Kt=a.useCallback(()=>{he(""),me(""),H(""),Ee(""),Le(""),Re("")},[]),Se=a.useMemo(()=>K.flatMap(([,t])=>t.items),[K]);a.useEffect(()=>{o||u||G||n||We.current||Se.length!==0&&T(Se[0])},[o,u,G,n,Se]);const ct=a.useRef(null);a.useEffect(()=>{if(!n){ct.current=null;return}if(ct.current===n.id)return;const t=K.find(([,s])=>s.items.some(i=>i.id===n.id));t&&(ct.current=n.id,Ot(t[0]))},[n?.id,K,Ot]);const zt=a.useRef(null),Gt=a.useRef(null),He=a.useRef(!1),qt=a.useRef(ae);a.useEffect(()=>{if(o||u||!v)return;const t=qt.current;qt.current=ae,!(ae!=="l1"||t==="l1")&&_&&(He.current=!0,Q(!1))},[ae,o,u,v,_]),a.useEffect(()=>{if(o||u||!v)return;const t=s=>{if(s.metaKey||s.ctrlKey){if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(Xt(s.target))return;if(s.key==="f"){s.preventDefault(),zt.current?.focus();return}if(s.key.toLowerCase()==="b"){s.preventDefault(),Q(C=>{const Ce=!C;return Ce&&(He.current=!0,M?.setKeyboardPane("l1"),requestAnimationFrame(()=>Gt.current?.focus())),Ce});return}if(s.key.toLowerCase()==="l"){s.preventDefault(),ut();return}return s.altKey,void 0}if(M?.keyboardPane==="l0")return;if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(Xt(s.target)||s.metaKey||s.ctrlKey||s.altKey)return;const l=s.key.length===1?s.key.toLowerCase():s.key;if(l==="h"||l==="ArrowLeft"){s.preventDefault(),_&&Q(!1),M?.setL0FocusPageId(P.DELIVERABLES),M?.setLeftCollapsed(!1),M?.setKeyboardPane("l0");return}if(l==="l"||l==="ArrowRight"){s.preventDefault(),_&&Q(!1),M?.keyboardPane!=="l1"&&M?.setKeyboardPane("l1");return}const f=l==="j"||l==="ArrowDown"?1:l==="k"||l==="ArrowUp"?-1:0;if(!f)return;s.preventDefault(),M?.setKeyboardPane("l1"),_&&(He.current=!0,Q(!1));const x=Se;if(x.length===0)return;const h=n?x.findIndex(C=>C.id===n.id):-1,b=h<0?f>0?-1:0:h,y=Math.max(0,Math.min(x.length-1,b+f));Yt(x[y]),requestAnimationFrame(()=>{document.querySelector(`[data-deliverable-id="${x[y].id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[Se,n,o,u,v,M,_]);const _e=a.useRef(null),hs=a.useCallback(t=>{if(!u)return;const s=Y.current;!s||s.scrollTop>0||(_e.current={y:t.touches[0].clientY,scrollTop:s.scrollTop})},[u]),ms=a.useCallback(t=>{if(!u||!_e.current||Je)return;const s=t.changedTouches[0].clientY-_e.current.y;_e.current=null,s>80&&Y.current&&Y.current.scrollTop<=0&&(wt(!0),O().finally(()=>wt(!1)))},[u,Je,O]),Yt=t=>{const s=()=>{T(t),Ze(!1),J(!1),X(!1),u&&(j(!0),history.pushState({mobileDetail:P.DELIVERABLES},"",window.location.hash))};U?Z({action:s}):s()},ps=()=>{if(!U){const t=Te??n?.summary??"";tt(t)}J(!0)},gs=()=>{U?Z({action:()=>{J(!1),X(!1)}}):J(!1)},Qt=async()=>{if(!(!n?.reference||st)){Mt(!0);try{await p.files.write(n.reference,ke),Pe(ke),X(!1),J(!1),A("success",r("detail.saved"))}catch(t){A("error",r("detail.saveFailed")+": "+String(t))}Mt(!1)}},bs=()=>{J(!1),X(!1),Z(null)};a.useEffect(()=>{if(!U)return;const t=s=>{s.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[U]),a.useEffect(()=>{if(!U)return;const t=s=>{s.preventDefault(),s.stopImmediatePropagation(),Z({action:()=>{J(!1),X(!1);const{page:i,params:l}=s.detail||{};i&&ee.navigate(i,l)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[U]);const dt=a.useRef(null),ut=a.useCallback((t,s)=>{const i=n?.agentId??"",l=n?.id??"",f={};l&&(f.openDeliverable=l);const x=[];if(l){const h=n?.title?.trim()||l,b=h.length>40?`${h.slice(0,24)}…${h.slice(-12)}`:h;x.push({label:`📄 ${b}`,content:["[deliverable]",`ID: ${l}`,`Title: ${n?.title??""}`,n?.reference?`Reference: ${n.reference}`:"",n?.taskId?`Task: ${n.taskId}`:"",n?.projectId?`Project: ${n.projectId}`:""].filter(Boolean).join(`
|
|
2
|
-
`)})}if(t?.trim()){const h=t.trim().length>40?`${t.trim().slice(0,24)}…${t.trim().slice(-12)}`:t.trim();if(s){const b=n?.reference??"";x.push({label:`🌐 ${h}`,content:["[html-selection]",`Text: "${t.trim()}"`,`CSS Selector: ${s.cssSelector}`,`XPath: ${s.xpath}`,b?`File: ${b}`:""].filter(Boolean).join(`
|
|
3
|
-
`)})}else x.push({label:`📝 ${h}`,content:t.trim()})}x.length>0&&(f.chatChips=JSON.stringify(x)),i&&(f.agentId=i),le(null),window.getSelection()?.removeAllRanges(),ee.navigate(P.TEAM,f)},[n]),ys=a.useCallback(t=>{if(!t.text.trim())return;const i=dt.current?.querySelector("iframe")?.getBoundingClientRect(),l=(i?.left??0)+t.rect.x+t.rect.width/2,f=(i?.top??0)+t.rect.y;le({x:l,y:f,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return a.useEffect(()=>{const t=dt.current;if(!t)return;const s=()=>{requestAnimationFrame(()=>{const l=window.getSelection(),f=l?.toString().trim();if(!f||!l?.rangeCount){le(null);return}const x=l.getRangeAt(0);if(!t.contains(x.commonAncestorContainer)){le(null);return}const h=x.getBoundingClientRect();le({x:h.left+h.width/2,y:h.top,text:f})})},i=l=>{const f=document.getElementById("selection-toolbar");f&&f.contains(l.target)||le(null)};return t.addEventListener("mouseup",s),document.addEventListener("mousedown",i),()=>{t.removeEventListener("mouseup",s),document.removeEventListener("mousedown",i)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{ref:Gt,tabIndex:-1,"data-keyboard-pane":"l1",className:`${u?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0 outline-none ${!u&&ae==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,style:u?N?{display:"none"}:void 0:_?{display:"none"}:{width:S.width},children:[e.jsxs("div",{"data-electron-drag":!0,className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u&&e.jsx(Cs,{}),!u&&e.jsx("button",{onClick:()=>Q(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:r("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[r("title"),w>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",w,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:zt,value:Ie,onChange:t=>Le(t.target.value),placeholder:r("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),Ie&&e.jsx("button",{onClick:()=>{Le(""),Re("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),et&&!u&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:et}),e.jsx("button",{onClick:()=>{p.system.openPath(et)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:r("common:open")})]}),u&&e.jsxs("button",{onClick:()=>rs(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${Qe||Fe?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),r("filters.filtersLabel"),Fe&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${Qe?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:u&&!Qe?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:r("filters.source")}),e.jsx(xe,{label:r("filters.allSources"),value:"",current:F,onClick:()=>H("")}),e.jsx(xe,{label:r("filters.sourceAgent"),value:"agent",current:F,onClick:t=>H(t||"")}),e.jsx(xe,{label:r("filters.sourceKnowledge"),value:"knowledge",current:F,onClick:t=>H(t||"")}),e.jsxs("button",{type:"button",onClick:()=>Ge(!0),className:"ml-auto shrink-0 flex items-center gap-1 px-2 py-1 rounded text-[10px] text-fg-tertiary hover:text-brand-500 hover:bg-surface-elevated transition-colors",title:r("filters.bindKnowledgeBase"),children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r("filters.bindKnowledgeBase")]})]}),e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(xe,{label:r("filters.allTypes"),value:"",current:V||W||"",onClick:()=>{he(""),me("")}}),Ds.map(t=>e.jsx(xe,{label:`${ue[t]?.icon??""} ${t}`,value:t,current:V,onClick:s=>{he(s),me("")}},t)),["agent","team","skill"].map(t=>e.jsx(xe,{label:`${z[t].icon} ${r(`artifactTypes.${t}`)}`,value:t,current:W,onClick:s=>{me(s),he("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:r("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{yt(t)},className:`px-2 py-1 rounded text-xs transition-colors ${B===t?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:r(`groupBy.${t}`)},t)),K.length>1&&e.jsx("button",{onClick:fs,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:r(Ut?"expandAllTooltip":"collapseAllTooltip"),children:r(Ut?"expandAll":"collapseAll")})]})]}),Fe&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[fe&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",fe,"”",e.jsx("button",{onClick:()=>{Le(""),Re("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),V&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[ue[V]?.icon," ",V,e.jsx("button",{onClick:()=>he(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),W&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[z[W]?.icon," ",r(`artifactTypes.${W}`),e.jsx("button",{onClick:()=>me(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),F&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[r(F==="knowledge"?"filters.sourceKnowledge":"filters.sourceAgent"),e.jsx("button",{onClick:()=>H(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),re&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[we(re)??re,e.jsx("button",{onClick:()=>Ee(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:Kt,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:r("filters.clearAll")})]})]}),qe&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${qe.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:qe.text}),e.jsxs("div",{ref:Y,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:G?.5:1},onTouchStart:u?t=>{Nt.onTouchStart(t),hs(t)}:void 0,onTouchEnd:u?t=>{Nt.onTouchEnd(t),ms(t)}:void 0,children:[Je&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(Zt,{})," ",e.jsx("span",{className:"text-[10px]",children:r("filters.refreshing")})]}),G?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),Fe?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.noResultsHint")}),e.jsx("button",{onClick:Kt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:r("empty.subtitle")}),e.jsx("button",{onClick:()=>ee.navigate(P.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r("empty.goToWork")})]})]}):K.map(([t,s])=>{const i=_t(t);return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>xs(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${i?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:s.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[s.items.length,g.length<w?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${i?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:s.items.map(l=>e.jsx("button",{"data-deliverable-id":l.id,onClick:()=>Yt(l),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${n?.id===l.id?ae==="l1"?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[l.artifactType&&z[l.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${z[l.artifactType].color}`,children:z[l.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${ue[l.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:ue[l.type]?.icon??l.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:l.title}),I(l)==="published"&&e.jsxs("svg",{className:"shrink-0 text-green-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":r("share.published",{defaultValue:"已发布到 Hub"}),children:[e.jsx("title",{children:r("share.published",{defaultValue:"已发布到 Hub"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(l)==="pending_review"&&e.jsxs("svg",{className:"shrink-0 text-amber-500 animate-pulse",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":r("share.pendingReview",{defaultValue:"Hub 审核中"}),children:[e.jsx("title",{children:r("share.pendingReview",{defaultValue:"Hub 审核中"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(l)==="rejected"&&e.jsxs("svg",{className:"shrink-0 text-red-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":r("share.rejected",{defaultValue:"Hub 已拒绝"}),children:[e.jsx("title",{children:r("share.rejected",{defaultValue:"Hub 已拒绝"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),Bt.has(l.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:r("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Vs(l.updatedAt,r)})]})},l.id))})]},t)}),m&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[e.jsx(Zt,{})," ",e.jsx("span",{className:"text-[10px]",children:r("common:loadingMore")})]}),!G&&g.length>0&&e.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:g.length<w?r("count.partial",{loaded:g.length,total:w}):r("count.total",{total:w})})]})]}),!u&&e.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:S.onResizeStart,children:e.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!u||N)&&e.jsxs("div",{"data-no-drag":!0,className:"flex-1 overflow-hidden min-w-0 flex relative self-stretch",children:[e.jsxs("div",{ref:dt,className:"flex-1 overflow-y-auto min-w-0 h-full",children:[_&&!u&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{He.current=!0,Q(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:r("sidebar.expand"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:n?.title??r("detail.details")})]}),u&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-sm font-medium truncate",children:n?.title??r("detail.details")})]}),n?e.jsxs("div",{className:`p-6 space-y-4 ${ve?"flex flex-col min-h-0 h-full":""}`,children:[!o&&Bt.has(n.id)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[e.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("span",{children:r("detail.fileMissing")})]}),e.jsxs("div",{className:`space-y-3 ${ve?"shrink-0":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:n.title}),!o&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[Ps(n?.format)&&e.jsxs("button",{onClick:()=>Ze(!0),title:r("share.title",{defaultValue:"分享到 Markus Hub"}),"aria-label":r("share.title",{defaultValue:"分享到 Markus Hub"}),className:`relative p-1.5 rounded-lg transition-colors ${I(n)==="published"?"text-green-500 hover:text-green-400 hover:bg-green-500/10":I(n)==="pending_review"?"text-amber-500 hover:text-amber-400 hover:bg-amber-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(n)==="published"||I(n)==="pending_review"||I(n)==="rejected"?e.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 rounded-full border border-surface-primary ${I(n)==="published"?"bg-green-500":I(n)==="pending_review"?"bg-amber-500 animate-pulse":"bg-red-500"}`,"aria-hidden":!0}):null]}),e.jsx("button",{onClick:()=>Ae(n),disabled:!!jt,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:r("common:remove"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${ue[n.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[ue[n.type]?.icon??""," ",n.type]}),n.artifactType&&z[n.artifactType]&&e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${z[n.artifactType].color}`,children:[z[n.artifactType].icon," ",r("detail.builderWithType",{type:r(`artifactTypes.${n.artifactType}`)})]}),n.tags.length>0&&n.tags.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:t},t)),I(n)==="published"&&e.jsxs("a",{href:n.shareUrl??void 0,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-green-500/15 text-green-600 hover:bg-green-500/25 hover:underline",title:n.shareUrl??void 0,children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),r("share.published",{defaultValue:"已发布"})]}),I(n)==="pending_review"&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-amber-500/15 text-amber-500",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),r("share.pendingReview",{defaultValue:"审核中"})]}),I(n)==="rejected"&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-red-500/15 text-red-500",title:n.shareReason??void 0,children:[r("share.rejected",{defaultValue:"已拒绝"}),n.shareReason?e.jsxs("span",{className:"text-red-400/90 font-normal",children:["— ",n.shareReason]}):null]})]}),(n.taskId||n.agentId||we(n.projectId))&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.taskId&&e.jsx("button",{onClick:()=>ee.navigate(P.WORK,{openTask:n.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:r("links.task",{id:`${n.taskId.slice(0,12)}...`})}),n.agentId&&e.jsx("button",{onClick:()=>ee.navigate(P.TEAM,{selectAgent:n.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.agent",{name:$e.get(n.agentId)?.name??n.agentId.slice(0,12)})}),we(n.projectId)&&e.jsx("button",{onClick:()=>ee.navigate(P.WORK,{projectId:n.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:r("links.project",{name:we(n.projectId)})})]}),(n.diffStats||n.testResults)&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[n.diffStats&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("diffStats.title"),":"]}),e.jsx("span",{className:"text-fg-secondary",children:r("diffStats.files",{count:n.diffStats.filesChanged})}),e.jsxs("span",{className:"text-green-600",children:["+",n.diffStats.additions]}),e.jsxs("span",{className:"text-red-500",children:["-",n.diffStats.deletions]})]}),n.testResults&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[r("testResults.title"),":"]}),e.jsx("span",{className:"text-green-600",children:r("testResults.passed",{count:n.testResults.passed})}),e.jsx("span",{className:"text-red-500",children:r("testResults.failed",{count:n.testResults.failed})}),e.jsx("span",{className:"text-fg-secondary",children:r("testResults.skipped",{count:n.testResults.skipped})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[e.jsxs("span",{children:[r("metadata.created")," ",new Date(n.createdAt).toLocaleString()]}),e.jsxs("span",{children:[r("metadata.updated")," ",new Date(n.updatedAt).toLocaleString()]}),e.jsx("span",{className:"text-fg-muted select-all",children:n.id.slice(0,12)})]}),n.reference&&!Oe(n.reference)&&n.type==="file"&&e.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[e.jsx("button",{onClick:()=>{p.files.reveal(n.reference).catch(()=>A("error",r("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(n.reference).catch(()=>A("error",r("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:r("detail.revealInFinder"),children:r("common:open")}),e.jsx("button",{onClick:()=>Dt(n.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Me?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:r("detail.copyPath"),children:r(Me?"common:copied":"common:copy")})]}),n.reference&&!Oe(n.reference)&&n.type!=="file"&&n.type!=="directory"&&e.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:n.reference})]}),n.artifactType&&n.artifactData?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx($s,{artifact:n.artifactData,mode:n.artifactType})}),n.reference&&e.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:r("detail.artifactDirectory")}),e.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:n.reference})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:us,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInBuilder")})}),n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Ue,{content:n.summary,className:"text-fg-secondary text-sm"})})]}):n.reference&&Oe(n.reference)?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Ue,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>window.open(n.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openUrl")})]})]}):n.type==="directory"&&n.reference?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Ue,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(n.reference).catch(()=>A("error",r("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:r("detail.openInFileBrowser")})]})]}):e.jsxs("div",{className:`bg-surface-elevated rounded-xl overflow-hidden ${ve?"flex flex-col h-full":""}`,children:[(Te||n.summary)&&!Rt&&!ge&&!Tt&&n.reference&&n.type==="file"&&(Be==="markdown"||Be==="text"||Be==="html")&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[e.jsx("button",{onClick:gs,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ie?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:r("detail.preview")}),e.jsx("button",{onClick:ps,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ie?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:r("detail.edit")}),e.jsx("div",{className:"flex-1"}),ie&&e.jsx("button",{onClick:Qt,disabled:!U||st,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(st?"detail.saving":"detail.save")})]}),e.jsx("div",{className:ve?"flex-1 min-h-0 p-5 flex flex-col":"p-5",children:Rt?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),e.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):ge?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("img",{src:ge.src,alt:ge.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:ge.name})]}):ne?e.jsx("div",{className:ve?"flex-1 min-h-0":"h-[55vh]",children:e.jsx(Bs,{data:ne,reference:ne.reference,onFallback:ne.reference?()=>{p.files.reveal(ne.reference).catch(()=>{})}:void 0})}):be?e.jsxs("div",{className:"flex flex-col gap-3 py-4",children:[be.kind==="audio"?e.jsx("audio",{controls:!0,preload:"metadata",src:be.src,className:"w-full"}):e.jsx("video",{controls:!0,preload:"metadata",src:be.src,className:"w-full max-h-[60vh] rounded-lg bg-black"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:be.name})]}):Te?ie?e.jsx("div",{className:"animate-fadeIn",children:e.jsx("textarea",{ref:nt,value:ke,onChange:t=>{tt(t.target.value),X(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):e.jsx("div",{className:"animate-fadeIn",children:e.jsx(Es,{content:Te,format:Be,className:"text-fg-secondary text-sm",onHtmlSelection:ys,basePath:n?.reference?n.reference.replace(/[/\\][^/\\]+$/,""):void 0})},"preview"):Tt?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.cannotPreview",{type:n.type})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{p.files.reveal(n.reference).catch(()=>A("error",r("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:r("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(n.reference).catch(()=>A("error",r("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}),e.jsx("button",{onClick:()=>Dt(n.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Me?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:r(Me?"common:copied":"common:copy")})]})]}):n.summary?ie?e.jsx("textarea",{ref:nt,value:ke,onChange:t=>{tt(t.target.value),X(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):e.jsx(Ue,{content:n.summary,className:"text-fg-secondary text-sm"}):e.jsx("p",{className:"text-sm text-fg-tertiary italic",children:r("detail.noContent")})})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-fg-secondary",children:r("detail.selectToView")}),!u&&e.jsx("p",{className:"text-[10px] text-fg-muted",children:r("detail.keyboardHint")})]})})]}),n?.agentId&&!u&&e.jsx("button",{type:"button",onClick:()=>ut(),className:"absolute bottom-6 right-6 z-20 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-transform hover:scale-105 animate-fab-in",title:r("chat.openChat",{defaultValue:"Open in Team Chat"}),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})]}),je&&e.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:je.x,top:je.y-8},children:e.jsxs("button",{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),ut(je.text,je.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),r("contextMenu.addToConversation")]})}),ls&&n&&e.jsx(Ms,{item:n,onClose:()=>Ze(!1),onShared:ds}),ts&&e.jsx(Ws,{projects:ze,onClose:()=>Ge(!1),onBound:()=>{Ge(!1),H("knowledge"),O()}}),Xe&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Ae(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.confirmRemoveTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.confirmRemoveMessage",{name:Xe.title})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>Ae(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{const t=Xe;Ae(null),cs(t)},disabled:!!jt,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:r("common:remove")})]})]})}),rt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Z(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:r("detail.unsavedTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:r("detail.unsavedMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>Z(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("common:cancel")}),e.jsx("button",{onClick:()=>{bs(),rt.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:r("detail.discard")}),e.jsx("button",{onClick:async()=>{await Qt(),rt.action(),Z(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:r("detail.saveAndLeave")})]})]})})]})}function Ws({projects:d,onClose:o,onBound:c}){const{t:r}=Ke("deliverables"),[u,v]=a.useState(""),[S,N]=a.useState(""),[j,E]=a.useState(!1),[k,L]=a.useState(""),g=d.find(m=>m.id===u),R=typeof window<"u"&&!!window.markusDesktop?.selectDirectory,w=async()=>{try{const m=await window.markusDesktop?.selectDirectory?.(r("bindBrowseTitle",{defaultValue:"Select knowledge base directory"}));m&&N(m)}catch(m){L(String(m))}},D=async()=>{if(!(!u||!S.trim()||j)){E(!0),L("");try{const m=S.trim(),se=[...new Set([...g?.knowledgeBasePaths??[],m])];await p.projects.update(u,{knowledgeBasePaths:se}),await p.projects.syncKnowledge(u),c()}catch(m){L(String(m))}finally{E(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>{j||o()},children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-md w-full mx-4 shadow-2xl",onClick:m=>m.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary mb-1",children:r("bindKnowledgeBase")}),e.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:r("bindKnowledgeBaseHint")}),e.jsx("label",{className:"block text-[10px] text-fg-tertiary mb-1",children:r("bindProject")}),e.jsxs("select",{value:u,onChange:m=>v(m.target.value),className:"w-full mb-3 px-2.5 py-2 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary",children:[e.jsx("option",{value:"",children:r("bindProjectSelect")}),d.map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))]}),e.jsx("label",{className:"block text-[10px] text-fg-tertiary mb-1",children:r("bindPath")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:S,onChange:m=>N(m.target.value),onKeyDown:m=>{m.key==="Enter"&&D()},placeholder:r("bindPathPlaceholder"),className:"flex-1 min-w-0 px-2.5 py-2 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary font-mono"}),R&&e.jsx("button",{type:"button",onClick:()=>{w()},disabled:j,title:r("bindBrowse",{defaultValue:"Browse…"}),className:"shrink-0 px-3 py-2 text-xs bg-surface-overlay text-fg-secondary hover:text-fg-primary rounded-lg disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:r("bindBrowse",{defaultValue:"Browse…"})})]}),g&&(g.knowledgeBasePaths??[]).length>0&&e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx("div",{className:"text-[10px] text-fg-tertiary",children:r("bindCurrentPaths")}),(g.knowledgeBasePaths??[]).map((m,se)=>e.jsxs("div",{className:"text-[11px] text-fg-secondary font-mono truncate",title:m,children:["• ",m]},`${m}-${se}`))]}),k&&e.jsx("div",{className:"mb-3 px-2.5 py-1.5 text-[11px] rounded-md bg-red-500/15 text-red-500",children:k}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:o,disabled:j,className:"px-3 py-1.5 text-xs text-fg-tertiary hover:text-fg-secondary rounded-lg transition-colors",children:r("common:cancel",{defaultValue:"Cancel"})}),e.jsx("button",{onClick:()=>{D()},disabled:j||!u||!S.trim(),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:j?r("bindSaving",{defaultValue:"Saving…"}):r("bindSave",{defaultValue:"Bind directory"})})]})]})})}function xe({label:d,value:o,current:c,onClick:r}){return e.jsx("button",{onClick:()=>r(c===o?"":o),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${c===o?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:d})}function Zt(){return e.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}export{Us as DeliverablesPage};
|