bilisum 1.20.0-alpha.2 → 1.20.0-alpha.3

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/bin/bilisum.js CHANGED
@@ -180,16 +180,22 @@ function extractUrlPageParam(source) {
180
180
  }
181
181
  }
182
182
 
183
- async function ensureAuthenticatedService(options, log) {
184
- // Resolve the token first (desktop token / auth.json / --token / env) and
185
- // inject it into a service the CLI spawns, so both always agree.
183
+ function resolveServiceToken(options) {
184
+ // Resolve a token to inject into a CLI-spawned service. The standalone cli
185
+ // environment has no desktop token file, so generate one (same pattern as
186
+ // the desktop app) to avoid depending on auth.json creation timing; desktop
187
+ // mode reuses the desktop token / auth.json so both sides always agree.
186
188
  let token = readToken(options);
187
189
  if (!token && options.environment === "cli") {
188
- // Standalone cli environment: generate a token and inject it into the
189
- // service (same pattern as the desktop app), so we never depend on
190
- // auth.json creation timing.
191
190
  token = require("node:crypto").randomBytes(32).toString("hex");
192
191
  }
192
+ return token;
193
+ }
194
+
195
+ async function ensureAuthenticatedService(options, log) {
196
+ // Resolve the token first (desktop token / auth.json / --token / env) and
197
+ // inject it into a service the CLI spawns, so both always agree.
198
+ let token = resolveServiceToken(options);
193
199
  await ensureService(options, { log, accessToken: token });
194
200
  if (!token) {
195
201
  // The CLI just spawned the service, which may have created {data}/auth.json.
@@ -446,14 +452,16 @@ async function tasksCommand(args) {
446
452
  async function startService(args) {
447
453
  const { options } = parseConnectionOptions(args);
448
454
  await resolveEnvironment(options);
449
- const url = `http://${options.host}:${options.port}`;
450
- console.log(`Starting BiliSum at ${url}`);
455
+ const token = resolveServiceToken(options);
456
+ const baseUrl = `http://${options.host}:${options.port}`;
457
+ console.log(`Starting BiliSum at ${baseUrl}`);
451
458
  console.log(`Environment: ${options.environment}`);
452
459
  console.log(`Data root: ${options.data}`);
453
460
  console.log("");
454
- const { child } = spawnService(options, { background: false });
461
+ const { child } = spawnService(options, { background: false, accessToken: token });
455
462
  if (options.open) {
456
- setTimeout(() => openUrl(url), 1800);
463
+ const openTarget = token ? `${baseUrl}#token=${encodeURIComponent(token)}` : baseUrl;
464
+ setTimeout(() => openUrl(openTarget), 1800);
457
465
  }
458
466
  child.on("exit", (code, signal) => {
459
467
  if (signal) {
@@ -491,8 +499,11 @@ async function settingsCommand(args) {
491
499
  }
492
500
  const log = console.error;
493
501
  await resolveEnvironment(options);
494
- await ensureService(options, { log });
495
- const url = `http://${options.host}:${options.port}/settings`;
502
+ const token = await ensureAuthenticatedService(options, log);
503
+ // Pass the token in the URL fragment so the web UI can auto-authenticate
504
+ // (the frontend consumes it and clears the fragment). The fragment is never
505
+ // sent to the server.
506
+ const url = `http://${options.host}:${options.port}/settings#token=${encodeURIComponent(token)}`;
496
507
  log(`打开设置页:${url}`);
497
508
  openUrl(url);
498
509
  }
package/lib/server.js CHANGED
@@ -72,17 +72,20 @@ function assertSpawnablePort(options) {
72
72
  * data/cache/tasks/db from VIDEO_SUM_APP_DATA_ROOT (same as the desktop app).
73
73
  * When an access token is known, it is injected like the desktop app does
74
74
  * (VIDEO_SUM_ACCESS_TOKEN), so the CLI and the spawned service always agree.
75
+ *
76
+ * `webStaticDir` (when provided) points the service's web UI at the static
77
+ * build bundled in this npm package; a later `--env` override still wins.
75
78
  */
76
- function buildServiceEnv(options, dataRoot, accessToken = null) {
77
- const webStaticDir = join(dataRoot, "cli-web-static");
78
- mkdirSync(webStaticDir, { recursive: true });
79
+ function buildServiceEnv(options, dataRoot, accessToken = null, webStaticDir = null) {
79
80
  const env = {
80
81
  ...process.env,
81
82
  VIDEO_SUM_HOST: options.host,
82
83
  VIDEO_SUM_PORT: options.port,
83
84
  VIDEO_SUM_APP_DATA_ROOT: dataRoot,
84
- VIDEO_SUM_WEB_STATIC_DIR: webStaticDir,
85
85
  };
86
+ if (webStaticDir) {
87
+ env.VIDEO_SUM_WEB_STATIC_DIR = webStaticDir;
88
+ }
86
89
  if (accessToken) {
87
90
  env.VIDEO_SUM_ACCESS_TOKEN = accessToken;
88
91
  }
@@ -131,16 +134,18 @@ function removeCliRuntimeFile(dataRoot, port) {
131
134
  function spawnService(options, { background = false, accessToken = null, log = console.error } = {}) {
132
135
  assertSpawnablePort(options);
133
136
  const dataRoot = options.data;
134
- const env = buildServiceEnv(options, dataRoot, accessToken);
137
+ // Both desktop and cli headless services serve the web UI from the static
138
+ // build bundled in this npm package (runtime/apps/web/static): the desktop
139
+ // managed-runtime Python cannot reach the desktop app's frozen bundle, and
140
+ // the cli venv has no static of its own.
141
+ const bundledStatic = join(runtimeSourceDir(), "apps", "web", "static");
142
+ const webStaticDir = existsSync(bundledStatic) ? bundledStatic : null;
143
+ const env = buildServiceEnv(options, dataRoot, accessToken, webStaticDir);
135
144
 
136
145
  let python;
137
146
  if (options.environment === "cli") {
138
147
  // Standalone mode: the CLI venv serves the bundled runtime sources.
139
148
  python = { command: ensureCliVenv(options, log), args: [] };
140
- const staticDir = join(runtimeSourceDir(), "apps", "web", "static");
141
- if (existsSync(staticDir)) {
142
- env.VIDEO_SUM_WEB_STATIC_DIR = staticDir;
143
- }
144
149
  } else {
145
150
  python = options.python ? { command: options.python, args: [] } : findPython(dataRoot);
146
151
  if (!python) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bilisum",
3
- "version": "1.20.0-alpha.2",
3
+ "version": "1.20.0-alpha.3",
4
4
  "description": "BiliSum CLI: control the installed BiliSum app, or run standalone with its own runtime.",
5
5
  "bin": {
6
6
  "bilisum": "bin/bilisum.js"
package/runtime/VERSION CHANGED
@@ -1 +1 @@
1
- 1.20.0-alpha.2
1
+ 1.20.0-alpha.3
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "video-sum-service"
7
- version = "1.20.0-alpha.2"
7
+ version = "1.20.0-alpha.3"
8
8
  description = "Local backend service for the video summarizer."
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
@@ -354,4 +354,4 @@ Minimum version required to store current data is: `+c+`.
354
354
  ## 原文中的限制
355
355
  - ...`}),(0,L.jsx)(`p`,{children:`如果想要更短,就写"每个小节不超过 5 条要点"。如果想要课程笔记风格,就写"优先使用定义、例子、推导、复盘题"。`})]}),(0,L.jsxs)(`section`,{className:`knowledge-prompt-guide-section warning`,children:[(0,L.jsx)(`h3`,{children:`不要删掉的约束`}),(0,L.jsxs)(`p`,{children:[`最终仍必须只返回合法 JSON,并且顶层字段必须是 `,(0,L.jsx)(`code`,{children:`knowledgeNoteMarkdown`}),`。 可以改变 Markdown 内容结构,但不要让模型直接输出普通 Markdown,否则任务会解析失败。`]})]})]}),(0,L.jsx)(`footer`,{className:`update-dialog-footer`,children:(0,L.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:()=>Vt(!1),children:`知道了`})})]})}):null,Kt?(0,L.jsx)(`div`,{className:`settings-tasklist-float`,role:`dialog`,"aria-modal":`false`,"aria-label":`最近任务列表`,onClick:()=>qt(!1),children:(0,L.jsxs)(`div`,{className:`settings-tasklist-panel`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`settings-tasklist-header`,children:[(0,L.jsxs)(`div`,{className:`settings-tasklist-copy`,children:[(0,L.jsx)(`span`,{className:`settings-nav-brand-kicker`,children:`Tasklist`}),(0,L.jsx)(`strong`,{children:`最近任务队列`}),(0,L.jsxs)(`span`,{children:[`聚焦最近 `,Jq," 条任务,方便确认 `queued` 与 `running` 的分布。"]})]}),(0,L.jsxs)(`div`,{className:`settings-tasklist-actions`,children:[(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,disabled:Jt,onClick:()=>void Sr(),children:Jt?`刷新中...`:`刷新`}),(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:()=>qt(!1),children:`关闭`})]})]}),(0,L.jsxs)(`div`,{className:`settings-tasklist-summary`,children:[(0,L.jsxs)(`span`,{className:`helper-chip`,children:[`最近 `,Qt.length,` 条`]}),(0,L.jsxs)(`span`,{className:`helper-chip ${vi?`status-running`:`status-pending`}`,children:[`运行中 `,vi]}),(0,L.jsxs)(`span`,{className:`helper-chip ${_i?`status-pending`:`status-success`}`,children:[`排队中 `,_i]})]}),Xt?(0,L.jsx)(`div`,{className:`detail-error-banner`,role:`status`,children:Xt}):null,(0,L.jsxs)(`div`,{className:`settings-tasklist-body`,children:[Jt&&!Qt.length?(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`正在同步最近任务...`}):null,!Jt&&!Qt.length&&!Xt?(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前还没有任务记录。`}):null,Qt.map(e=>(0,L.jsxs)(`article`,{className:`settings-tasklist-item`,children:[(0,L.jsxs)(`div`,{className:`settings-tasklist-item-top`,children:[(0,L.jsxs)(`div`,{className:`settings-tasklist-item-meta`,children:[(0,L.jsx)(`span`,{className:`task-status ${ur(e.status)}`,children:Jr(e.status)}),e.page_number===0?(0,L.jsx)(`span`,{className:`helper-chip`,children:e.page_title||`全集总结`}):e.page_number?(0,L.jsxs)(`span`,{className:`helper-chip`,children:[`P`,e.page_number]}):null,(0,L.jsx)(`span`,{className:`helper-chip`,children:e.input_type})]}),(0,L.jsx)(`span`,{className:`task-history-id`,children:e.task_id.slice(0,8)})]}),(0,L.jsx)(`strong`,{children:e.title||`未命名任务`}),(0,L.jsxs)(`div`,{className:`settings-tasklist-item-subline`,children:[(0,L.jsx)(`span`,{children:Wr(e.created_at)}),e.task_duration_seconds==null?null:(0,L.jsxs)(`span`,{children:[`耗时 `,Math.max(0,Math.round(e.task_duration_seconds)),` 秒`]})]})]},e.task_id))]})]})}):null]})}function cJ(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement(`base`),i=n.createElement(`a`);return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}var lJ=(()=>{let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function uJ(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}var dJ=null;function fJ(e={}){return dJ||(e.includeStyleProperties?(dJ=e.includeStyleProperties,dJ):(dJ=uJ(window.getComputedStyle(document.documentElement)),dJ))}function pJ(e,t){let n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace(`px`,``)):0}function mJ(e){let t=pJ(e,`border-left-width`),n=pJ(e,`border-right-width`);return e.clientWidth+t+n}function hJ(e){let t=pJ(e,`border-top-width`),n=pJ(e,`border-bottom-width`);return e.clientHeight+t+n}function gJ(e,t={}){return{width:t.width||mJ(e),height:t.height||hJ(e)}}function _J(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}var vJ=16384;function yJ(e){(e.width>vJ||e.height>vJ)&&(e.width>vJ&&e.height>vJ?e.width>e.height?(e.height*=vJ/e.width,e.width=vJ):(e.width*=vJ/e.height,e.height=vJ):e.width>vJ?(e.height*=vJ/e.width,e.width=vJ):(e.width*=vJ/e.height,e.height=vJ))}function bJ(e,t={}){return e.toBlob?new Promise(n=>{e.toBlob(n,t.type?t.type:`image/png`,t.quality?t.quality:1)}):new Promise(n=>{let r=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(`,`)[1]),i=r.length,a=new Uint8Array(i);for(let e=0;e<i;e+=1)a[e]=r.charCodeAt(e);n(new Blob([a],{type:t.type?t.type:`image/png`}))})}function xJ(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin=`anonymous`,r.decoding=`async`,r.src=e})}async function SJ(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function CJ(e,t,n){let r=`http://www.w3.org/2000/svg`,i=document.createElementNS(r,`svg`),a=document.createElementNS(r,`foreignObject`);return i.setAttribute(`width`,`${t}`),i.setAttribute(`height`,`${n}`),i.setAttribute(`viewBox`,`0 0 ${t} ${n}`),a.setAttribute(`width`,`100%`),a.setAttribute(`height`,`100%`),a.setAttribute(`x`,`0`),a.setAttribute(`y`,`0`),a.setAttribute(`externalResourcesRequired`,`true`),i.appendChild(a),a.appendChild(e),SJ(i)}var wJ=(e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||wJ(n,t)};function TJ(e){let t=e.getPropertyValue(`content`);return`${e.cssText} content: '${t.replace(/'|"/g,``)}';`}function EJ(e,t){return fJ(t).map(t=>`${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t)?` !important`:``};`).join(` `)}function DJ(e,t,n,r){let i=`.${e}:${t}`,a=n.cssText?TJ(n):EJ(n,r);return document.createTextNode(`${i}{${a}}`)}function OJ(e,t,n,r){let i=window.getComputedStyle(e,n),a=i.getPropertyValue(`content`);if(a===``||a===`none`)return;let o=lJ();try{t.className=`${t.className} ${o}`}catch{return}let s=document.createElement(`style`);s.appendChild(DJ(o,n,i,r)),t.appendChild(s)}function kJ(e,t,n){OJ(e,t,`:before`,n),OJ(e,t,`:after`,n)}var AJ=`application/font-woff`,jJ=`image/jpeg`,MJ={woff:AJ,woff2:AJ,ttf:`application/font-truetype`,eot:`application/vnd.ms-fontobject`,png:`image/png`,jpg:jJ,jpeg:jJ,gif:`image/gif`,tiff:`image/tiff`,svg:`image/svg+xml`,webp:`image/webp`};function NJ(e){let t=/\.([^./]*?)$/g.exec(e);return t?t[1]:``}function PJ(e){return MJ[NJ(e).toLowerCase()]||``}function FJ(e){return e.split(/,/)[1]}function IJ(e){return e.search(/^(data:)/)!==-1}function LJ(e,t){return`data:${t};base64,${e}`}async function RJ(e,t,n){let r=await fetch(e,t);if(r.status===404)throw Error(`Resource "${r.url}" not found`);let i=await r.blob();return new Promise((e,t)=>{let a=new FileReader;a.onerror=t,a.onloadend=()=>{try{e(n({res:r,result:a.result}))}catch(e){t(e)}},a.readAsDataURL(i)})}var zJ={};function BJ(e,t,n){let r=e.replace(/\?.*/,``);return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,``)),t?`[${t}]${r}`:r}async function VJ(e,t,n){let r=BJ(e,t,n.includeQueryParams);if(zJ[r]!=null)return zJ[r];n.cacheBust&&(e+=(/\?/.test(e)?`&`:`?`)+new Date().getTime());let i;try{i=LJ(await RJ(e,n.fetchRequestInit,({res:e,result:n})=>(t||=e.headers.get(`Content-Type`)||``,FJ(n))),t)}catch(t){i=n.imagePlaceholder||``;let r=`Failed to fetch resource: ${e}`;t&&(r=typeof t==`string`?t:t.message),r&&console.warn(r)}return zJ[r]=i,i}async function HJ(e){let t=e.toDataURL();return t===`data:,`?e.cloneNode(!1):xJ(t)}async function UJ(e,t){if(e.currentSrc){let t=document.createElement(`canvas`),n=t.getContext(`2d`);return t.width=e.clientWidth,t.height=e.clientHeight,n?.drawImage(e,0,0,t.width,t.height),xJ(t.toDataURL())}let n=e.poster;return xJ(await VJ(n,PJ(n),t))}async function WJ(e,t){try{if(e?.contentDocument?.body)return await eY(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function GJ(e,t){return wJ(e,HTMLCanvasElement)?HJ(e):wJ(e,HTMLVideoElement)?UJ(e,t):wJ(e,HTMLIFrameElement)?WJ(e,t):e.cloneNode(qJ(e))}var KJ=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SLOT`,qJ=e=>e.tagName!=null&&e.tagName.toUpperCase()===`SVG`;async function JJ(e,t,n){if(qJ(t))return t;let r=[];return r=KJ(e)&&e.assignedNodes?uJ(e.assignedNodes()):wJ(e,HTMLIFrameElement)&&e.contentDocument?.body?uJ(e.contentDocument.body.childNodes):uJ((e.shadowRoot??e).childNodes),r.length===0||wJ(e,HTMLVideoElement)||await r.reduce((e,r)=>e.then(()=>eY(r,n)).then(e=>{e&&t.appendChild(e)}),Promise.resolve()),t}function YJ(e,t,n){let r=t.style;if(!r)return;let i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):fJ(n).forEach(n=>{let a=i.getPropertyValue(n);n===`font-size`&&a.endsWith(`px`)&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),wJ(e,HTMLIFrameElement)&&n===`display`&&a===`inline`&&(a=`block`),n===`d`&&t.getAttribute(`d`)&&(a=`path(${t.getAttribute(`d`)})`),r.setProperty(n,a,i.getPropertyPriority(n))})}function XJ(e,t){wJ(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),wJ(e,HTMLInputElement)&&t.setAttribute(`value`,e.value)}function ZJ(e,t){if(wJ(e,HTMLSelectElement)){let n=t,r=Array.from(n.children).find(t=>e.value===t.getAttribute(`value`));r&&r.setAttribute(`selected`,``)}}function QJ(e,t,n){return wJ(t,Element)&&(YJ(e,t,n),kJ(e,t,n),XJ(e,t),ZJ(e,t)),t}async function $J(e,t){let n=e.querySelectorAll?e.querySelectorAll(`use`):[];if(n.length===0)return e;let r={};for(let i=0;i<n.length;i++){let a=n[i].getAttribute(`xlink:href`);if(a){let n=e.querySelector(a),i=document.querySelector(a);!n&&i&&!r[a]&&(r[a]=await eY(i,t,!0))}}let i=Object.values(r);if(i.length){let t=`http://www.w3.org/1999/xhtml`,n=document.createElementNS(t,`svg`);n.setAttribute(`xmlns`,t),n.style.position=`absolute`,n.style.width=`0`,n.style.height=`0`,n.style.overflow=`hidden`,n.style.display=`none`;let r=document.createElementNS(t,`defs`);n.appendChild(r);for(let e=0;e<i.length;e++)r.appendChild(i[e]);e.appendChild(n)}return e}async function eY(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(e=>GJ(e,t)).then(n=>JJ(e,n,t)).then(n=>QJ(e,n,t)).then(e=>$J(e,t))}var tY=/url\((['"]?)([^'"]+?)\1\)/g,nY=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,rY=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function iY(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,`\\$1`);return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,`g`)}function aY(e){let t=[];return e.replace(tY,(e,n,r)=>(t.push(r),e)),t.filter(e=>!IJ(e))}async function oY(e,t,n,r,i){try{let a=n?cJ(t,n):t,o=PJ(t),s;return s=i?LJ(await i(a),o):await VJ(a,o,r),e.replace(iY(t),`$1${s}$3`)}catch{}return e}function sY(e,{preferredFontFormat:t}){return t?e.replace(rY,e=>{for(;;){let[n,,r]=nY.exec(e)||[];if(!r)return``;if(r===t)return`src: ${n};`}}):e}function cY(e){return e.search(tY)!==-1}async function lY(e,t,n){if(!cY(e))return e;let r=sY(e,n);return aY(r).reduce((e,r)=>e.then(e=>oY(e,r,t,n)),Promise.resolve(r))}async function uY(e,t,n){let r=t.style?.getPropertyValue(e);if(r){let i=await lY(r,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function dY(e,t){await uY(`background`,e,t)||await uY(`background-image`,e,t),await uY(`mask`,e,t)||await uY(`-webkit-mask`,e,t)||await uY(`mask-image`,e,t)||await uY(`-webkit-mask-image`,e,t)}async function fY(e,t){let n=wJ(e,HTMLImageElement);if(!(n&&!IJ(e.src))&&!(wJ(e,SVGImageElement)&&!IJ(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,i=await VJ(r,PJ(r),t);await new Promise((r,a)=>{e.onload=r,e.onerror=t.onImageErrorHandler?(...e)=>{try{r(t.onImageErrorHandler(...e))}catch(e){a(e)}}:a;let o=e;o.decode&&=r,o.loading===`lazy`&&(o.loading=`eager`),n?(e.srcset=``,e.src=i):e.href.baseVal=i})}async function pY(e,t){let n=uJ(e.childNodes).map(e=>mY(e,t));await Promise.all(n).then(()=>e)}async function mY(e,t){wJ(e,Element)&&(await dY(e,t),await fY(e,t),await pY(e,t))}function hY(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(e=>{n[e]=r[e]}),e}var gY={};async function _Y(e){let t=gY[e];return t??(t={url:e,cssText:await(await fetch(e)).text()},gY[e]=t,t)}async function vY(e,t){let n=e.cssText,r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let a=i.replace(r,`$1`);return a.startsWith(`https://`)||(a=new URL(a,e.url).href),RJ(a,t.fetchRequestInit,({result:e})=>(n=n.replace(i,`url(${e})`),[i,e]))});return Promise.all(i).then(()=>n)}function yY(e){if(e==null)return[];let t=[],n=e.replace(/(\/\*[\s\S]*?\*\/)/gi,``),r=RegExp(`((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})`,`gi`);for(;;){let e=r.exec(n);if(e===null)break;t.push(e[0])}n=n.replace(r,``);let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=RegExp(`((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})`,`gi`);for(;;){let e=i.exec(n);if(e===null){if(e=a.exec(n),e===null)break;i.lastIndex=a.lastIndex}else a.lastIndex=i.lastIndex;t.push(e[0])}return t}async function bY(e,t){let n=[],r=[];return e.forEach(n=>{if(`cssRules`in n)try{uJ(n.cssRules||[]).forEach((e,i)=>{if(e.type===CSSRule.IMPORT_RULE){let a=i+1,o=e.href,s=_Y(o).then(e=>vY(e,t)).then(e=>yY(e).forEach(e=>{try{n.insertRule(e,e.startsWith(`@import`)?a+=1:n.cssRules.length)}catch(t){console.error(`Error inserting rule from remote css`,{rule:e,error:t})}})).catch(e=>{console.error(`Error loading remote css`,e.toString())});r.push(s)}})}catch(i){let a=e.find(e=>e.href==null)||document.styleSheets[0];n.href!=null&&r.push(_Y(n.href).then(e=>vY(e,t)).then(e=>yY(e).forEach(e=>{a.insertRule(e,a.cssRules.length)})).catch(e=>{console.error(`Error loading remote stylesheet`,e)})),console.error(`Error inlining remote css file`,i)}}),Promise.all(r).then(()=>(e.forEach(e=>{if(`cssRules`in e)try{uJ(e.cssRules||[]).forEach(e=>{n.push(e)})}catch(t){console.error(`Error while reading CSS rules from ${e.href}`,t)}}),n))}function xY(e){return e.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>cY(e.style.getPropertyValue(`src`)))}async function SY(e,t){if(e.ownerDocument==null)throw Error(`Provided element is not within a Document`);return xY(await bY(uJ(e.ownerDocument.styleSheets),t))}function CY(e){return e.trim().replace(/["']/g,``)}function wY(e){let t=new Set;function n(e){(e.style.fontFamily||getComputedStyle(e).fontFamily).split(`,`).forEach(e=>{t.add(CY(e))}),Array.from(e.children).forEach(e=>{e instanceof HTMLElement&&n(e)})}return n(e),t}async function TY(e,t){let n=await SY(e,t),r=wY(e);return(await Promise.all(n.filter(e=>r.has(CY(e.style.fontFamily))).map(e=>{let n=e.parentStyleSheet?e.parentStyleSheet.href:null;return lY(e.cssText,n,t)}))).join(`
356
356
  `)}async function EY(e,t){let n=t.fontEmbedCSS==null?t.skipFonts?null:await TY(e,t):t.fontEmbedCSS;if(n){let t=document.createElement(`style`),r=document.createTextNode(n);t.appendChild(r),e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}}async function DY(e,t={}){let{width:n,height:r}=gJ(e,t),i=await eY(e,t,!0);return await EY(i,t),await mY(i,t),hY(i,t),await CJ(i,n,r)}async function OY(e,t={}){let{width:n,height:r}=gJ(e,t),i=await xJ(await DY(e,t)),a=document.createElement(`canvas`),o=a.getContext(`2d`),s=t.pixelRatio||_J(),c=t.canvasWidth||n,l=t.canvasHeight||r;return a.width=c*s,a.height=l*s,t.skipAutoScale||yJ(a),a.style.width=`${c}`,a.style.height=`${l}`,t.backgroundColor&&(o.fillStyle=t.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(i,0,0,a.width,a.height),a}async function kY(e,t={}){return await bJ(await OY(e,t))}function AY(e){return e.page_number??1}function jY(e){return e.page_number===0}function MY(e){return jY(e)?e.page_title||`全集总结`:e.page_number?`P${e.page_number}`:``}function NY(e){return e.some(e=>e.status===`running`||e.status===`queued`)?`in_progress`:e.some(e=>e.status===`completed`)?`completed`:e.some(e=>e.status===`failed`||e.status===`cancelled`)?`failed`:`not_started`}function PY(e,t){return e.map(e=>{let n=t.filter(t=>!jY(t)&&AY(t)===e.page),r=n[0]??null;return{...e,aggregate_status:NY(n),latest_task_status:r?.status??null,latest_task_updated_at:r?.updated_at??null,has_completed_result:n.some(e=>e.status===`completed`)}})}function FY(e,t){return t===0?e.filter(jY):t==null?e.filter(e=>!jY(e)):e.filter(e=>!jY(e)&&AY(e)===t)}function IY(e){let t=String(e||``).trim();if(!t)return``;let n=t.toLowerCase();return/llm request failed with status 404|http 404|status 404: not found/.test(n)?`大模型接口地址无法访问。通常是 Base URL 填写不对,或当前服务商不支持这个接口路径。请到设置页检查 LLM 的 Base URL。`:/status 401|authentication failed|unauthorized|invalid api key|incorrect api key/.test(n)?`API Key 校验失败。请检查密钥是否正确、是否过期,或是否复制了多余空格。`:/status 403|forbidden|permission denied/.test(n)?`当前账号没有访问这个模型或接口的权限。请检查服务商后台的权限、余额或模型开通状态。`:/status 429|rate limit|too many requests/.test(n)?`请求过于频繁,或当前额度不足。请稍后重试,并检查服务商后台是否有限流或余额不足。`:/status 500|status 502|status 503|status 504|server error|bad gateway|service unavailable|gateway timeout/.test(n)?`模型服务暂时不可用,通常是服务商接口异常或网络波动。建议稍后再试。`:/connect timeout|read timeout|timed out|timeout/.test(n)?`请求超时了。可能是当前网络较慢,或模型响应时间过长,建议稍后重试。`:/connection failed|connect error|network error|failed to establish|name or service not known|getaddrinfo/.test(n)?`连接模型服务失败。请检查网络是否正常,以及接口地址是否填写正确。`:/not a valid json|未返回合法 json/.test(n)?`模型接口能连通,但没有按要求返回合法 JSON,所以无法继续生成摘要。建议更换模型,或先到设置页点击测试按钮检查。`:/siliconflow asr authentication failed|asr 测试失败:认证失败/.test(n)?`语音识别 API Key 校验失败。请检查 SiliconFlow API Key 是否正确。`:/siliconflow asr request failed|asr request failed/.test(n)?`语音识别服务调用失败。请检查 SiliconFlow 的 Base URL、模型名和网络连接。`:/llm/.test(n)&&/api key/.test(n)?`LLM 的 API Key 似乎有问题。请到设置页重新检查并测试。`:t}function LY(e,t){return t&&e.some(e=>e.task_id===t)?t:e.find(e=>e.status===`completed`)?.task_id??e[0]?.task_id??null}function RY(e,t={}){if(!e)return[];let n=[],r=String(e.overview||``).trim(),i=Array.isArray(e.key_points)?e.key_points:[],a=Array.isArray(e.timeline)?e.timeline:[],o=Array.isArray(e.segment_summaries)?e.segment_summaries:[],s=a.length||o.length;return r&&n.push({id:`overview`,kind:`overview`,eyebrow:`Overview`,title:`核心概览`,content:r,meta:`${i.length} 个要点 · ${s} 个章节`}),i.map(e=>e.trim()).filter(Boolean).forEach((e,t)=>{n.push({id:`key-point-${t}`,kind:`key-point`,eyebrow:`Key Point`,title:``,content:e})}),a.length?a.forEach((e,r)=>{let i=HY(String(e.title||``).trim(),[],String(e.summary||``).trim(),`章节 ${r+1}`),a=String(e.summary||``).trim(),o=typeof e.start==`number`?e.start:null,s=t.chapterAnchor===`page`&&o!=null?Math.max(1,Math.round(o)):null;n.push({id:`chapter-${r}`,kind:`chapter`,eyebrow:`Chapter`,title:i,content:a||`当前章节暂未生成摘要。`,timestampSeconds:t.chapterAnchor===`page`?null:o,pageNumber:s,anchorLabel:s==null?void 0:`P${s}`})}):o.map(e=>e.trim()).filter(Boolean).forEach((e,t)=>{n.push({id:`chapter-${t}`,kind:`chapter`,eyebrow:`Chapter`,title:`章节 ${t+1}`,content:e})}),n}function zY(e,t,n={}){let r=Array.isArray(t?.chapter_groups)?t?.chapter_groups:[];if(r.length){let e=[];if(r.forEach((t,r)=>{if(!t||typeof t!=`object`)return;let i=(Array.isArray(t.children)?t.children:[]).map((e,t)=>BY(e,`${r}-${t}`,n)).filter(e=>!!e);if(!i.length)return;let a=HY(String(t.title||``).trim(),i.map(e=>e.title),String(t.summary||``).trim(),`主题`),o=String(t.summary||``).trim(),s=n.chapterAnchor===`page`?VY(i):[YY(typeof t.start==`number`?t.start:i[0]?.timestampSeconds),YY(i[i.length-1]?.timestampSeconds)].filter(Boolean).join(` - `),c=o||[s,`${i.length} 个小章节`].filter(Boolean).join(` · `);e.push({id:`chapter-group-${r}`,title:a,meta:c,items:i})}),e.length)return e}let i=e.filter(e=>e.kind===`chapter`);if(!i.length)return[];let a=i.length<=4?2:3,o=[];for(let e=0;e<i.length;e+=a){let t=i.slice(e,e+a),r=t[0],s=t[t.length-1],c=HY(``,t.map(e=>e.title),t.map(e=>e.title).join(`;`),`主题`),l=[n.chapterAnchor===`page`?VY(t):[YY(r.timestampSeconds),YY(s.timestampSeconds)].filter(Boolean).join(` - `),`${t.length} 个小章节`].filter(Boolean).join(` · `);o.push({id:`chapter-group-${o.length}`,title:c,meta:l,items:t})}return o}function BY(e,t,n={}){if(!e||typeof e!=`object`)return null;let r=String(e.summary||``).trim(),i=HY(String(e.title||``).trim(),[],r,`章节`),a=String(e.summary||``).trim();if(!i&&!a)return null;let o=typeof e.start==`number`?e.start:null,s=n.chapterAnchor===`page`&&o!=null?Math.max(1,Math.round(o)):null;return{id:`chapter-${t}`,kind:`chapter`,eyebrow:`Chapter`,title:i||`章节`,content:a||`当前章节暂未生成摘要。`,timestampSeconds:n.chapterAnchor===`page`?null:o,pageNumber:s,anchorLabel:s==null?void 0:`P${s}`}}function VY(e){let t=e.map(e=>e.pageNumber).filter(e=>typeof e==`number`&&Number.isFinite(e));if(!t.length)return``;let n=Math.min(...t),r=Math.max(...t);return n===r?`P${n}`:`P${n} - P${r}`}function HY(e,t,n,r){let i=UY(e);if(i&&!WY(i))return i;for(let e of t){let t=UY(e);if(t&&!WY(t))return t}return GY(n)||r}function UY(e){return e.trim().replace(/^[\-•\d.()、\s]+/,``).slice(0,24)}function WY(e){let t=e.trim().toLowerCase();return/^(大)?章节\s*\d+$/.test(e.trim())||/^第?\s*\d+\s*(章|节|部分)$/.test(e.trim())||/^(part|section|chapter)\s*[-::]?\s*\d+$/.test(t)}function GY(e){let t=e.trim().replace(/^(这一部分|本部分|这里|该部分|这一章|本章|本节|这一节)(主要)?(讲|介绍|讨论|说明|分析|围绕)?/,``).split(/[。;!!??\n]/)[0]?.trim().replace(/^[::\-]+|[,,、;;::]+$/g,``).replace(/\s+/g,``);return t?t.slice(0,24):``}function KY(e){if(!e)return``;let t=String(e.knowledge_note_markdown||``).trim();if(t)return t;let n=[],r=String(e.overview||``).trim(),i=Array.isArray(e.key_points)?e.key_points.map(e=>e.trim()).filter(Boolean):[],a=Array.isArray(e.timeline)?e.timeline:[];return r&&n.push(`## 摘要概览`,``,r),i.length&&(n.push(``,`## 关键要点`,``),n.push(...i.map(e=>`- ${e}`))),a.length&&(n.push(``,`## 时间轴`,``),a.forEach((e,t)=>{let r=String(e.title||``).trim()||`章节 ${t+1}`,i=String(e.summary||``).trim(),a=typeof e.start==`number`?e.start:null;n.push(`### ${r}`),a!=null&&n.push(``,`- 时间点:${JY(a)}`),i&&n.push(``,i),n.push(``)})),n.join(`
357
- `).trim()}function qY(e){return!e||e.status!==`completed`||!e.result?!1:!!KY(e.result).trim()}function JY(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function YY(e){return typeof e==`number`?JY(e):``}function XY(e){return e?.result?null:e?e.status===`running`||e.status===`queued`?{tone:`pending`,title:`当前任务还在处理中`,description:`可以先查看顶部任务药丸中的实时进度,结果生成后这里会自动可用。`}:e.status===`failed`||e.status===`cancelled`?{tone:`failed`,title:`当前任务未生成可用结果`,description:`可以切换到其他已完成任务,或重新发起摘要生成。`,detail:IY(e.error_message)||void 0}:{tone:`empty`,title:`当前任务还没有结果`,description:`请选择其他已完成任务,或者重新生成摘要。`}:{tone:`empty`,title:`还没有可展示的任务内容`,description:`开始处理后,这里会整理出摘要结果和知识卡片。`}}function ZY(e,t){return t?.status===`ready`&&t.mindmap?null:e?t?.status===`generating`||e.result?.mindmap_status===`generating`?{tone:`pending`,title:`思维导图正在生成`,description:`系统正在基于当前任务的摘要结果组织主题树,稍后会自动显示在这里。`,actionLabel:`生成中`,actionEnabled:!1}:t?.status===`failed`||e.result?.mindmap_status===`failed`?{tone:`failed`,title:`思维导图生成失败`,description:IY(t?.error_message||e.result?.mindmap_error_message||e.error_message)||`这次处理没有成功生成可展示的导图。`,actionLabel:`重新生成导图`,actionEnabled:!0}:e.status===`running`||e.status===`queued`?{tone:`pending`,title:`任务完成后才能生成导图`,description:`当前任务仍在处理中。等摘要和知识笔记准备好后,就可以按需生成思维导图。`,actionLabel:`处理中`,actionEnabled:!1}:e.status===`failed`||e.status===`cancelled`?{tone:`failed`,title:`当前任务暂时无法生成导图`,description:IY(e.error_message)||`这次处理没有产出可用于导图组织的结果。`,actionLabel:`等待可用结果`,actionEnabled:!1}:{tone:`accent`,title:`当前任务已可生成思维导图`,description:`导图会按主题重组知识卡片、章节结构和知识笔记,并在叶子节点保留可回看时间点。`,actionLabel:`生成思维导图`,actionEnabled:!0}:{tone:`default`,title:`当前还没有可生成导图的任务`,description:`请选择一个已完成任务。导图会基于当前任务的知识卡片和知识笔记按需生成。`,actionLabel:`等待可用任务`,actionEnabled:!1}}function QY(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.toLowerCase();if(!n.includes(`bilibili.com`)&&!n.includes(`b23.tv`))return null;let r=t.pathname.match(/\/video\/(BV[0-9A-Za-z]+)/i)?.[1]??null,i=t.pathname.match(/\/video\/av(\d+)/i)?.[1]??null,a=t.searchParams.get(`bvid`)??r,o=t.searchParams.get(`aid`)??i,s=t.searchParams.get(`p`)??`1`;if(!a&&!o)return null;let c=new URL(`https://player.bilibili.com/player.html`);return c.searchParams.set(`isOutside`,`true`),c.searchParams.set(`autoplay`,`0`),c.searchParams.set(`p`,s),a&&c.searchParams.set(`bvid`,a),o&&c.searchParams.set(`aid`,o),c.toString()}catch{return null}}function $Y(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.toLowerCase(),r=null;if(n.endsWith(`youtu.be`)?r=t.pathname.split(`/`).filter(Boolean)[0]??null:n.includes(`youtube.com`)&&(r=t.pathname===`/watch`?t.searchParams.get(`v`):t.pathname.match(/^\/shorts\/([^/?#]+)/i)?.[1]??null),!r)return null;let i=new URL(`https://www.youtube.com/embed/${r}`);return i.searchParams.set(`autoplay`,`0`),i.searchParams.set(`rel`,`0`),i.toString()}catch{return null}}function eX(e,t,n,r){let i=new URL(e);if(n!=null&&Number.isFinite(n)&&n>=0){let e=String(Math.floor(n));t===`youtube`?i.searchParams.set(`start`,e):i.searchParams.set(`t`,e)}else t===`youtube`?i.searchParams.delete(`start`):i.searchParams.delete(`t`);return i.searchParams.set(`_ts`,String(r)),i.toString()}function tX(e){let t=QY(e);if(t&&e)return{platform:`bilibili`,embedUrl:t,sourceUrl:e,openLabel:`在 Bilibili 打开`};let n=$Y(e);return n&&e?{platform:`youtube`,embedUrl:n,sourceUrl:e,openLabel:`在 YouTube 打开`}:null}var nX={stroke:`#4c9fdd`,surface:`rgba(76, 159, 221, 0.18)`,ink:`#104f7d`,shadow:`rgba(76, 159, 221, 0.24)`},rX=[{stroke:`#f2b84b`,surface:`rgba(242, 184, 75, 0.18)`,ink:`#805018`,shadow:`rgba(242, 184, 75, 0.24)`},{stroke:`#ff8c69`,surface:`rgba(255, 140, 105, 0.16)`,ink:`#91412a`,shadow:`rgba(255, 140, 105, 0.24)`},{stroke:`#8cc8ff`,surface:`rgba(140, 200, 255, 0.18)`,ink:`#285c86`,shadow:`rgba(140, 200, 255, 0.24)`},{stroke:`#f5a64a`,surface:`rgba(245, 166, 74, 0.16)`,ink:`#8a4a00`,shadow:`rgba(245, 166, 74, 0.22)`},{stroke:`#9dd8b3`,surface:`rgba(157, 216, 179, 0.18)`,ink:`#1f6a47`,shadow:`rgba(157, 216, 179, 0.22)`},{stroke:`#f7a8c2`,surface:`rgba(247, 168, 194, 0.16)`,ink:`#8e4563`,shadow:`rgba(247, 168, 194, 0.22)`}],iX=16/9,aX=220,oX=360,sX=20,cX=92,lX=62,uX=new Set([`.mp4`,`.mov`,`.mkv`,`.avi`,`.wmv`,`.webm`,`.flv`,`.m4v`,`.ts`,`.mpeg`,`.mpg`]),dX=`bilisum.summaryPreference`,fX=[{id:`knowledge`,label:`知识卡片`,description:`按概览、要点、章节整理当前任务结果。`},{id:`summary`,label:`知识笔记`,description:`查看当前任务的完整笔记、重点展开和转写全文。`},{id:`mindmap`,label:`思维导图`,description:`预留按主题组织的知识结构视图入口。`}];function pX(e,t){let n=new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime();return n===0?new Date(t.created_at).getTime()-new Date(e.created_at).getTime():n}function mX(e){return e.status===`completed`}function hX(e){return e?[{label:`创建时间`,value:Wr(e.created_at)},{label:`更新时间`,value:Wr(e.updated_at)},{label:`LLM Token`,value:qr(e.llm_total_tokens)},{label:`任务耗时`,value:Kr(e.task_duration_seconds)}]:[]}function gX(e){return dr(e.stage)===`error`||/失败|不可用|错误|异常/i.test(e.message)}function _X(e){return dr(e.stage)===`completed`||e.progress>=100||/完成|已写入|检查通过|已就绪/.test(e.message)}function vX(e){let t=e.message||``;return e.stage.startsWith(`mindmap_`)||/思维导图|导图/.test(t)?`mindmap`:/知识库|索引/.test(t)?`knowledge`:/导出|写入本地|结果整理|结果文件/.test(t)?`export`:e.stage===`downloading`||e.stage===`transcribing`||/音频|转写|字幕/.test(t)?`media`:e.stage===`summarizing`||/LLM|摘要|总结|知识卡片|知识笔记|内容块|分块|合并/.test(t)?`summary`:e.stage===`queued`||/队列|开始执行|检查|规范化|读取视频|视频信息/.test(t)?`prepare`:`other`}var yX={prepare:`准备阶段`,media:`音频与转写`,summary:`摘要生成`,export:`结果导出`,mindmap:`思维导图`,knowledge:`知识库索引`,other:`其他记录`},bX=[`prepare`,`media`,`summary`,`export`,`mindmap`,`knowledge`,`other`];function xX(e){let t=new Map;for(let n of e){let e=vX(n);t.set(e,[...t.get(e)??[],n])}let n=e.at(-1);return bX.map(e=>{let r=t.get(e)??[];if(!r.length)return null;let i=r.some(gX),a=!!(n&&r.some(e=>e.event_id===n.event_id)),o=r.every(_X);return{id:e,label:yX[e],events:r,tone:i?`failed`:a&&!o?`active`:o?`done`:`pending`}}).filter(e=>!!e)}function SX(e,t){let n=Math.max(aX,t-sX*2);return Math.min(Math.max(e,aX),n)}function CX(e,t,n){let r=SX(e.width,t),i=r/iX+lX,a=Math.max(sX,t-r-sX),o=Math.max(cX,n-i-sX);return{width:r,x:Math.min(Math.max(e.x,sX),a),y:Math.min(Math.max(e.y,cX),o)}}function wX(e,t){let n=SX(oX,e),r=n/iX+lX;return{width:n,x:Math.max(sX,e-n-28),y:Math.max(cX,t-r-28)}}function TX(e,t){if(!(t in e))return e;let n={...e};return delete n[t],n}function EX(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function DX(){if(typeof window>`u`)return`text`;try{let e=window.localStorage.getItem(dX);return e&&JSON.parse(e).noteMode===`visual`?`visual`:`text`}catch{return`text`}}function OX(e){if(!(typeof window>`u`))try{let t=window.localStorage.getItem(dX),n=t?JSON.parse(t):{};window.localStorage.setItem(dX,JSON.stringify({...n,noteMode:e}))}catch{window.localStorage.setItem(dX,JSON.stringify({noteMode:e}))}}async function kX(e){let[t,n]=await Promise.all([I.getTaskResult(e),I.getTaskEvents(e)]);return{detail:t,events:n}}function AX(e){return(0,L.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`M12 18.26 4.95 22l1.35-7.84L.6 8.71l7.87-1.14L12 0.5l3.53 7.07 7.87 1.14-5.7 5.45L19.05 22z`})})}function jX(e){return/HTTP\s*412|cookies?\.txt|B\s*站返回|Bilibili rejected|风控拦截|登录态|cookiesfrombrowser|DPAPI/i.test(e)}function MX({refreshToken:e=0,onRefresh:t,onOpenCookieSettings:n,onOpenCookieTutorial:r,onCaptureLoginCookies:i}){let{videoId:a=``}=lt(),o=st(),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)({}),[p,m]=(0,S.useState)({}),[h,g]=(0,S.useState)({}),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(`knowledge`),[x,C]=(0,S.useState)(`collapsed`),[w,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(null),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(``),[ee,M]=(0,S.useState)(!1),[te,ne]=(0,S.useState)({}),[N,P]=(0,S.useState)({}),[re,ie]=(0,S.useState)({}),[ae,oe]=(0,S.useState)({}),[F,se]=(0,S.useState)(()=>DX()),[ce,le]=(0,S.useState)(!1),[ue,de]=(0,S.useState)(!1),[fe,pe]=(0,S.useState)(!1),[me,he]=(0,S.useState)(!1),[ge,_e]=(0,S.useState)(!1),[ve,ye]=(0,S.useState)(!1),[be,xe]=(0,S.useState)(``),[Se,Ce]=(0,S.useState)(null),[we,Te]=(0,S.useState)([]),[Ee,De]=(0,S.useState)(null),[Oe,ke]=(0,S.useState)(null),[Ae,je]=(0,S.useState)(!1),[Me,Ne]=(0,S.useState)(`create`),[Pe,Fe]=(0,S.useState)({nonce:0,seconds:null}),[Ie,Le]=(0,S.useState)(null),Re=(0,S.useRef)(null),ze=(0,S.useRef)(null),Be=(0,S.useRef)(null),Ve=(0,S.useRef)(null),He=(0,S.useRef)(null),Ue=(0,S.useRef)(null),We=(0,S.useRef)(null),Ge=(0,S.useRef)(null),Ke=(0,S.useRef)(null),qe=(0,S.useRef)(null),Je=(0,S.useRef)(null),Ye=(0,S.useRef)(``),Xe=(0,S.useRef)(a),Ze=(0,S.useRef)(null),Qe=(0,S.useRef)(e),$e=(0,S.useRef)(0),et=(0,S.useRef)(new Map),tt=(0,S.useRef)(new Map),nt=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{Xe.current=a},[a]),(0,S.useEffect)(()=>{Fe({nonce:0,seconds:null})},[a]),(0,S.useEffect)(()=>{Ze.current=_},[_]),(0,S.useEffect)(()=>{let e=!1;return I.getSettings().then(t=>{e||xe(String(t.output_dir||``).trim())}).catch(()=>void 0),()=>{e=!0}},[]);async function rt(e,t={}){let{force:n=!1}=t,r=Xe.current;if(!n){let t=et.current.get(e);if(t)return f(n=>n[e]?n:{...n,[e]:t}),m(t=>TX(t,e)),t;let n=tt.current.get(e);if(n)return n}let i=(nt.current.get(e)??0)+1;nt.current.set(e,i),g(t=>t[e]?t:{...t,[e]:!0}),m(t=>TX(t,e));let a=kX(e).then(t=>nt.current.get(e)===i?(et.current.set(e,t),Xe.current===r&&f(n=>({...n,[e]:t})),t):et.current.get(e)??t).catch(t=>{if(nt.current.get(e)===i&&Xe.current===r){let n=t instanceof Error?t.message:`任务详情加载失败`;m(t=>({...t,[e]:n}))}throw t}).finally(()=>{tt.current.get(e)===a&&tt.current.delete(e),nt.current.get(e)===i&&Xe.current===r&&g(t=>TX(t,e))});return tt.current.set(e,a),a}async function it(e,t={}){if(!t.force&&te[e])return te[e];P(t=>({...t,[e]:!0}));try{let t=await I.getTaskMindMap(e);return ne(n=>({...n,[e]:t})),t}catch(t){let n={task_id:e,status:`failed`,error_message:t instanceof Error?t.message:`思维导图加载失败`,updated_at:null,mindmap:null};throw ne(t=>({...t,[e]:n})),t}finally{P(t=>TX(t,e))}}async function at(e,t={}){P(t=>({...t,[e]:!0}));try{let n=await I.generateTaskMindMap(e,{force:t.force});return ne(t=>({...t,[e]:n})),n}catch(t){let n={task_id:e,status:`failed`,error_message:t instanceof Error?t.message:`思维导图生成失败`,updated_at:null,mindmap:null};throw ne(t=>({...t,[e]:n})),t}finally{P(t=>TX(t,e))}}async function ot(e,t={}){if(!t.force&&re[e])return re[e];oe(t=>({...t,[e]:!0}));try{let t=await I.getTaskVisualEvidence(e);return ie(n=>({...n,[e]:t})),t}catch(t){let n={task_id:e,mode:`text`,status:`failed`,error_message:t instanceof Error?t.message:`图文笔记加载失败`,updated_at:null,frame_count:0,insert_count:0,visual_note_markdown:``,enhanced_note_markdown:``,context:null};throw ie(t=>({...t,[e]:n})),t}finally{oe(t=>TX(t,e))}}async function ct(e,t={}){oe(t=>({...t,[e]:!0}));try{let n=await I.generateTaskVisualEvidence(e,{force:t.force,mode:t.mode});return ie(t=>({...t,[e]:n})),n}catch(t){let n={task_id:e,mode:`frame_insert`,status:`failed`,error_message:t instanceof Error?t.message:`图文笔记生成失败`,updated_at:null,frame_count:0,insert_count:0,visual_note_markdown:``,enhanced_note_markdown:``,context:null};throw ie(t=>({...t,[e]:n})),t}finally{oe(t=>TX(t,e))}}async function ut(e={}){let{forceTaskIds:n=[],preferredTaskId:r,syncLibrary:i=!1}=e,o=++$e.current,s=a;try{let[e,a]=await Promise.all([I.getVideo(s),I.getVideoTasks(s)]);if(Xe.current!==s||$e.current!==o)return;let l=[...a].sort(pX),d=LY(l,r===void 0?Ze.current:r),p=l[0]?.task_id??null,h=[...new Set([d,p].filter(Boolean))],_=new Set(n),y=new Map;if(await Promise.all(h.map(async e=>{y.set(e,await rt(e,{force:_.has(e)}))})),Xe.current!==s||$e.current!==o)return;let b=new Set(l.map(e=>e.task_id));Ze.current=d,c(e),u(a),v(d),f(e=>{let t={};for(let n of l){let r=n.task_id,i=y.get(r)??e[r];i&&(t[r]=i)}return t}),m(e=>Object.fromEntries(Object.entries(e).filter(([e])=>b.has(e)))),g(e=>Object.fromEntries(Object.entries(e).filter(([e])=>b.has(e)))),i&&t()}catch(e){throw Xe.current===s&&$e.current===o&&j(e instanceof Error?e.message:`视频详情加载失败`),e}}function dt(e){Ze.current=e,v(e),rt(e).catch(()=>void 0)}(0,S.useEffect)(()=>{$e.current+=1,Xe.current=a,Ze.current=null,c(null),u([]),f({}),m({}),g({}),v(null),b(`knowledge`),C(`collapsed`),T(!1),j(``),ne({}),P({}),_e(!1),Ce(null),De(null),k(!1),je(!1),Ne(`create`),Le(null),ut({preferredTaskId:null}).catch(()=>void 0)},[a]),(0,S.useEffect)(()=>{a&&Qe.current!==e&&(Qe.current=e,ut({preferredTaskId:Ze.current,syncLibrary:!1}).catch(()=>void 0))},[e]);let ft=(0,S.useMemo)(()=>[...l].sort(pX),[l]),pt=s?.pages??[],mt=(0,S.useMemo)(()=>ft.filter(jY),[ft]),ht=(0,S.useMemo)(()=>{let e=new Map;for(let t of ft){if(jY(t))continue;let n=AY(t);e.set(n,!!e.get(n)||mX(t))}return e},[ft]),gt=(0,S.useMemo)(()=>PY(pt,ft),[pt,ft]),_t=(0,S.useMemo)(()=>gt.reduce((e,t)=>(e.total+=1,t.aggregate_status===`completed`?e.completed+=1:t.aggregate_status===`in_progress`?e.inProgress+=1:t.aggregate_status===`failed`?e.failed+=1:e.notStarted+=1,e),{total:0,completed:0,inProgress:0,notStarted:0,failed:0}),[gt]),vt=gt.some(e=>e.has_completed_result),yt=pt.length>0&&(mt.length>0||vt),bt=Ee??pt[0]?.page??null,xt=bt===0,St=pt.find(e=>e.page===bt)??null,Ct=(0,S.useMemo)(()=>!pt.length||bt==null?ft.filter(e=>!jY(e)):FY(ft,bt),[pt.length,bt,ft]),wt=Ct[0]?.task_id??null,Tt=Ct[0]??null,Et=wt?d[wt]??null:null,Dt=Et?.detail??null,Ot=Et?.events??[],kt=Ct.find(e=>e.task_id===_)??null,At=_?d[_]??null:null,jt=At?.detail??null,Mt=At?.events??[],Nt=!!(_&&wt&&_===wt),Pt=!!(wt&&h[wt]&&!Et),Ft=!!(_&&h[_]&&!At),It=wt?p[wt]??null:null,Lt=_?p[_]??null:null;(0,S.useEffect)(()=>{Re.current=null},[wt]),(0,S.useEffect)(()=>{if(!pt.length){Ee!==null&&De(null);return}Ee&&pt.some(e=>e.page===Ee)||Ee===0&&yt||De(ft.find(e=>e.page_number!=null&&e.page_number>0)?.page_number??pt[0]?.page??null)},[pt,yt,ft,Ee]),(0,S.useEffect)(()=>{let e=LY(Ct,Ze.current);e!==Ze.current&&(Ze.current=e,v(e),e&&rt(e).catch(()=>void 0))},[Ct]),(0,S.useEffect)(()=>{!_||y!==`mindmap`||it(_).catch(()=>void 0)},[y,_]),(0,S.useEffect)(()=>{!_||y!==`summary`||ot(_).catch(()=>void 0)},[y,_]),(0,S.useEffect)(()=>{OX(F)},[F]),(0,S.useEffect)(()=>{if(!_||!(te[_]?.status===`generating`||jt?.result?.mindmap_status===`generating`))return;let e=window.setInterval(()=>{Promise.all([it(_,{force:!0}),rt(_,{force:!0})]).catch(()=>void 0)},1500);return()=>window.clearInterval(e)},[te,jt?.result?.mindmap_status,_]),(0,S.useEffect)(()=>{if(!_||!(re[_]?.status===`generating`||jt?.result?.visual_note_status===`generating`))return;let e=window.setInterval(()=>{Promise.all([ot(_,{force:!0}),rt(_,{force:!0})]).catch(()=>void 0)},1800);return()=>window.clearInterval(e)},[jt?.result?.visual_note_status,_,re]),(0,S.useEffect)(()=>{if(!wt)return;let e=I.createTaskEventSource(wt,Ot.at(-1)?.created_at);return e.addEventListener(`progress`,e=>{let t=JSON.parse(e.data);f(e=>{let n=e[wt];if(!n)return e;let r=n.events.some(e=>e.event_id===t.event.event_id)?n.events:[...n.events,t.event],i={detail:{...n.detail,status:t.status,updated_at:t.updated_at,result:t.result===void 0?n.detail.result:t.result,llm_total_tokens:t.result?.llm_total_tokens??n.detail.llm_total_tokens},events:r};return et.current.set(wt,i),{...e,[wt]:i}}),u(e=>e.map(e=>e.task_id===wt?{...e,status:t.status,updated_at:t.updated_at,llm_total_tokens:t.result?.llm_total_tokens??e.llm_total_tokens}:e)),c(e=>e&&{...e,latest_status:t.status,updated_at:t.updated_at,latest_result:t.result===void 0?e.latest_result:t.result})}),e.onerror=()=>e.close(),()=>e.close()},[wt]),(0,S.useEffect)(()=>{if(!wt||!Ot.length)return;let e=[...Ot].reverse().find(e=>e.stage===`completed`||e.stage===`failed`||e.stage===`cancelled`||e.stage===`mindmap_completed`||e.stage===`mindmap_failed`||e.stage===`visual_completed`||e.stage===`visual_partial`||e.stage===`visual_failed`);if(!e)return;let t=`${wt}:${e.event_id}`;if(Re.current===t)return;Re.current=t;let n=window.setTimeout(()=>{ut({forceTaskIds:[wt],preferredTaskId:Ze.current,syncLibrary:!0}).catch(()=>void 0)},300);return()=>window.clearTimeout(n)},[Ot,wt]),(0,S.useEffect)(()=>{if(x!==`expanded`&&!w&&!O&&!ge&&!ce)return;function e(e){let t=e.target,n=Be.current?.contains(t),r=Ve.current?.contains(t),i=He.current?.contains(t),a=Je.current?.contains(t),o=qe.current?.contains(t),s=Ue.current?.contains(t);!n&&!s&&C(`collapsed`),r||(T(!1),D(null)),i||k(!1),a||_e(!1),o||le(!1)}function t(e){e.key===`Escape`&&(C(`collapsed`),T(!1),D(null),k(!1),_e(!1),le(!1))}return document.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[w,ge,ce,O,x]);async function Rt(){if(!Ke.current||ue)return;if(!navigator.clipboard||typeof ClipboardItem>`u`){j(`当前环境不支持将图片复制到剪贴板。`);return}let e=Ke.current,t=A,n=window.getComputedStyle(e),r=n.backgroundColor===`rgba(0, 0, 0, 0)`?window.getComputedStyle(document.body).backgroundColor:n.backgroundColor;de(!0),j(`正在导出当前知识卡片...`),e.setAttribute(`data-export-mode`,`true`);try{await document.fonts.ready,await new Promise(e=>window.requestAnimationFrame(()=>e(void 0)));let t=await kY(e,{backgroundColor:r,cacheBust:!0,pixelRatio:Math.max(window.devicePixelRatio||1,2)});if(!t)throw Error(`未能生成图片,请稍后重试。`);if(window.desktop?.clipboard){let e=await new Promise((e,n)=>{let r=new FileReader;r.onloadend=()=>{if(typeof r.result==`string`){e(r.result);return}n(Error(`图片编码失败,请稍后重试。`))},r.onerror=()=>n(r.error??Error(`图片编码失败,请稍后重试。`)),r.readAsDataURL(t)});await window.desktop.clipboard.writeImage(e)}else await navigator.clipboard.write([new ClipboardItem({[t.type]:t})]);j(`当前知识卡片已复制为图片。`)}catch(e){e instanceof Error&&e.message.includes(`Document is not focused`)?j(`复制失败:请先点一下应用窗口,再重新尝试。`):j(e instanceof Error?e.message:`导出图片失败,请稍后重试。`)}finally{e.removeAttribute(`data-export-mode`),de(!1),window.setTimeout(()=>{j(e=>e===`当前知识卡片已复制为图片。`||e===`正在导出当前知识卡片...`?t:e)},2600)}}let zt=jt?.result??null,Bt=(0,S.useMemo)(()=>Yr(Ot),[Ot]),Vt=(0,S.useMemo)(()=>Ft?{tone:`pending`,title:`正在加载所选版本`,description:`任务详情载入完成后,工作台会切换到对应的知识卡片和摘要内容。`}:Lt?{tone:`failed`,title:`所选版本加载失败`,description:`可以重新点击该版本重试,或先切换查看其他已完成任务。`,detail:IY(Lt)}:XY(jt),[Ft,jt,Lt]),Ht=!!(Vt?.detail&&jX(Vt.detail));(0,S.useEffect)(()=>{if(!_||!Vt?.detail||!jX(Vt.detail))return;let e=`${_}:${Vt.detail}`;ze.current!==e&&(ze.current=e,M(!0))},[Vt?.detail,_]);function Ut(){r?.(),r||window.open(`https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp`,`_blank`,`noopener,noreferrer`)}function Wt(){if(M(!1),n){n();return}o(`/settings`)}async function Gt(){if(!i){Wt();return}try{await i(),M(!1),j(`B 站登录态已保存。重新提交任务即可。`)}catch(e){j(e instanceof Error?e.message:`捕获 B 站登录态失败,请按教程手动导出 cookies.txt。`)}}let Kt=Ht?{onOpenTutorial:Ut,onOpenSettings:Wt}:null,qt=(0,S.useMemo)(()=>{let e=_?te[_]??null:null;return e?.status===`ready`&&(!e.mindmap||!e.mindmap.nodes?.length)?{...e,status:`failed`,error_message:e.error_message||`思维导图数据为空,请重新生成。`,mindmap:null}:e},[te,_]),Jt=(0,S.useMemo)(()=>Ft?{tone:`pending`,title:`思维导图将在版本载入后可用`,description:`当前正在同步所选内容版本的详细结果。`,actionLabel:`加载中`,actionEnabled:!1}:Lt?{tone:`failed`,title:`当前版本暂时无法打开思维导图`,description:IY(Lt),actionLabel:`稍后重试`,actionEnabled:!1}:ZY(jt,qt),[Ft,qt,jt,Lt]),Yt=(0,S.useMemo)(()=>RY(zt,{chapterAnchor:xt?`page`:`time`}),[xt,zt]),Xt=Yt.find(e=>e.kind===`overview`)??null,Zt=Yt.filter(e=>e.kind===`key-point`),Qt=Yt.filter(e=>e.kind===`chapter`),$t=(0,S.useMemo)(()=>zY(Qt,zt,{chapterAnchor:xt?`page`:`time`}),[Qt,xt,zt]),en=$t.length>0&&we.length===$t.length,tn=(0,S.useMemo)(()=>KY(zt),[zt]),nn=_?re[_]??null:null,rn=nn?.status||jt?.result?.visual_note_status||`idle`,an=nn?.enhanced_note_markdown||nn?.visual_note_markdown||``,on=!!an.trim(),sn=F===`visual`&&on?`visual`:`text`;(0,S.useEffect)(()=>{!on&&F===`visual`&&se(`text`)},[on,F]);let cn=sn===`visual`?an:tn,ln=sn===`visual`?`图文`:`纯文本`,un=rn===`generating`?`图文笔记生成中,完成后可选`:`当前任务没有图文笔记`,dn=(0,S.useMemo)(()=>IX(_,nn),[_,nn]),fn=(0,S.useMemo)(()=>qY(jt),[jt]),pn=zt?.transcript_text??``,mn=!!(jt?.status===`completed`&&(pn.trim()||zt?.artifacts?.transcript_path)),hn=Dt?.status??Tt?.status??s?.latest_status,gn=It??IY(Bt.failedEvent?.message)??Bt.currentEvent?.message??IY(Dt?.error_message)??(Tt?Jr(Tt.status):`等待开始处理`),_n=wt?.slice(0,8)??null,vn=Dt?.title||Tt?.title||s?.title||`当前任务`,yn=hX(Dt??Tt),bn=It?`同步失败`:Bt.failedEvent?`处理失败`:Bt.currentEvent?.stage?lr(Bt.currentEvent.stage):Tt?Jr(Tt.status):`等待开始`,xn=_?_.slice(0,8):null,Sn=hX(jt??kt),Cn=zt?.llm_total_tokens??jt?.llm_total_tokens??kt?.llm_total_tokens??null,wn=jt?.status??kt?.status,Tn=!!(_&&jt?.result?.transcript_text?.trim()&&jt.result.artifacts?.summary_path),Dn=!!(_&&wn===`completed`&&zt?.knowledge_note_markdown?.trim()&&!xt&&rn!==`generating`&&!ae[_]),On=Ft?`加载中`:Lt?`加载失败`:Vt?Jr(wn):`已准备`,kn=[{id:`progress`,label:`最新运行`,value:bn},{id:`content`,label:`当前查看`,value:xt?`全集总结`:St?`P${St.page}`:xn?`任务 ${xn}`:`暂无任务`,mono:!0}],An=_t.completed,jn=_t.total>0?Math.max(0,Math.min(100,Math.round(An/_t.total*100))):0,Mn=(0,S.useMemo)(()=>xt?null:tX(St?.source_url||s?.source_url),[St?.source_url,xt,s?.source_url]),Nn=(0,S.useMemo)(()=>Mn?eX(Mn.embedUrl,Mn.platform,Pe.seconds,Pe.nonce):null,[Mn,Pe]),Pn=(0,S.useMemo)(()=>{if(!s||String(s.platform||``).toLowerCase()!==`local`||xt)return null;let e=St?.source_url||s.source_url,t=(()=>{try{return`.${new URL(e,window.location.origin).pathname.split(`.`).pop()?.toLowerCase()||``}`}catch{let t=String(e||``).split(`.`);return t.length>1?`.${t[t.length-1].toLowerCase()}`:``}})();return uX.has(t)?`/api/v1/videos/${s.video_id}/media`:null},[St?.source_url,xt,s]),Fn=!!(Pn||Mn),In=qt?.status===`ready`&&jt?.result?.mindmap_status!==`generating`?qt.mindmap??null:null,Ln=(0,S.useMemo)(()=>Mt.filter(e=>e.stage.startsWith(`mindmap_`)),[Mt]),Rn=(0,S.useMemo)(()=>{if(!_)return null;let e=qt?.status===`generating`||jt?.result?.mindmap_status===`generating`,t=!!N[_],n=Ln.length?Yr(Ln):null;return!e&&!t&&!n?.filtered.length?null:{progress:Math.max(0,Math.min(100,Math.round(n?.progress??(t?6:90)))),currentLabel:n?.currentEvent?.stage?lr(n.currentEvent.stage):t?`提交生成请求`:`等待阶段回传`,message:qt?.error_message||jt?.result?.mindmap_error_message||n?.failedEvent?.message||n?.currentEvent?.message||(t?`正在向本地服务提交导图生成请求。`:`系统正在生成思维导图,阶段完成后会自动刷新。`),events:n?.filtered??[],hasError:!!n?.failedEvent}},[Ln,N,qt,jt?.result?.mindmap_error_message,jt?.result?.mindmap_status,_]),zn=(0,S.useMemo)(()=>xX(Bt.filtered),[Bt.filtered]),Bn=zn.find(e=>e.tone===`failed`)??[...zn].reverse().find(e=>e.tone===`active`)??zn.at(-1)??null,Vn=In?`主题导图视图`:Rn?`${Rn.currentLabel} · ${Rn.progress}%`:`按需生成`,Hn=(0,S.useMemo)(()=>In?In.nodes.find(e=>e.id===In.root)??In.nodes[0]??null:null,[In]),Un=(0,S.useMemo)(()=>Hn?GX(Hn,Ie,xt?`page`:`time`):{nodes:[],edges:[]},[xt,Hn,Ie]),Wn=(0,S.useMemo)(()=>!Hn||!Ie?null:PX(Hn,Ie),[Hn,Ie]);(0,S.useEffect)(()=>{let e=$t.map(e=>e.id).join(`|`),t=Ye.current!==e;Ye.current=e,Te(e=>{let n=new Set($t.map(e=>e.id)),r=e.filter(e=>n.has(e)),i=r.length===e.length&&r.every((t,n)=>t===e[n]);return $t.length===0?r.length?[]:e:r.length>0||!t?i?e:r:[$t[0].id]})},[$t]),(0,S.useEffect)(()=>{if(!Hn){Le(null);return}Le(e=>e&&PX(Hn,e)?e:null)},[Hn]);function Gn(e){if(e!=null){if(Fe(t=>({nonce:t.nonce+1,seconds:e})),y===`knowledge`&&Pn&&Ge.current)Ge.current.currentTime=e,Ge.current.play().catch(()=>{});else if(!Mn&&!Pn)return;y===`knowledge`&&We.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}function Kn(e,t){if(t==null)return;let n=pt.find(e=>e.page===t);if(!n){j(`没有找到 P${t} 对应的分 P。`);return}let r=e.currentTarget.getBoundingClientRect();ke({open:!0,pageNumber:t,title:n.title,x:r.left+r.width/2,y:r.bottom+8})}function qn(){Oe&&(De(Oe.pageNumber),b(`knowledge`),k(!1),ke(null),j(`已跳转到 P${Oe.pageNumber}「${Oe.title}」`))}function Jn(){ke(null)}(0,S.useEffect)(()=>{if(!Oe?.open)return;function e(e){let t=e.target;!t.closest(`.jump-confirm-popover`)&&!t.closest(`[data-jump-anchor]`)&&ke(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Oe?.open]);function Yn(){Te(en?[]:$t.map(e=>e.id))}function Xn(e,t){Te(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))}async function Zn(e=!1){if(_){b(`mindmap`),j(e?`已发起重新生成思维导图...`:`已发起生成思维导图...`);try{if((await at(_,{force:e})).status===`ready`){Le(null),j(`思维导图已更新`);return}j(e?`正在重新生成思维导图...`:`正在生成思维导图...`)}catch(e){j(e instanceof Error?e.message:`思维导图生成失败`)}}}async function Qn(e=!1){if(_){b(`summary`),se(`visual`),j(e?`已发起重新生成图文笔记...`:`已发起生成图文笔记...`);try{let t=await ct(_,{force:e});if(await rt(_,{force:!0}).catch(()=>void 0),t.status===`ready`||t.status===`partial`){j(`图文笔记已更新`);return}j(e?`正在重新生成图文笔记...`:`正在生成图文笔记...`)}catch(e){j(e instanceof Error?e.message:`图文笔记生成失败`)}}}async function $n(){if(!s)return;let e=s,n=!s.is_favorite;c({...s,is_favorite:n,favorite_updated_at:n?new Date().toISOString():null});try{c(await I.setVideoFavorite(s.video_id,{is_favorite:n})),t(),j(n?`已加入收藏`:`已取消收藏`)}catch(t){c(e),j(t instanceof Error?t.message:`更新收藏状态失败`)}}async function er(){if(s){T(!1),D(null),j(`正在创建全集总结任务...`);try{let e=await I.createAggregateSummaryTask(s.video_id);De(0),await ut({forceTaskIds:[e.task_id],preferredTaskId:e.task_id,syncLibrary:!0}),j(`已开始生成全集总结`)}catch(e){j(e instanceof Error?e.message:`全集总结创建失败`)}}}async function tr(e){if(!s)throw Error(`当前视频信息不可用,请稍后重试。`);j(Me===`create`?e.confirm?`正在确认批量生成...`:`正在创建批量生成任务...`:e.confirm?`正在确认批量重生成...`:`正在准备批量重生成...`);let t=Me===`create`?await I.createVideoTasksBatch(s.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm}):await I.resummarizeVideoTasksBatch(s.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm});if(t.requires_confirmation)return j(Me===`create`?`所选内容中有 ${t.conflict_pages.length} 个分 P 已有成功摘要,确认后会默认跳过。`:`所选内容中有 ${t.conflict_pages.length} 个分 P 将复用已有转写重新生成摘要,请确认继续。`),t;await ut({preferredTaskId:null,syncLibrary:!0}),je(!1);let n=t.created_tasks.length,r=t.skipped_pages.length;return j(Me===`create`?n>0?`已创建 ${n} 个批量任务${r?`,跳过 ${r} 个分 P`:``}`:`没有创建新任务${r?`,已跳过 ${r} 个分 P`:``}`:n>0?`已发起 ${n} 个批量重生成任务${r?`,跳过 ${r} 个分 P`:``}`:`没有创建新的重生成任务${r?`,已跳过 ${r} 个分 P`:``}`),t}if(!s)return(0,L.jsx)(`section`,{className:`grid-card empty-state-card`,children:`正在加载视频详情...`});let nr=St?.source_url||s.source_url,rr=String(s.platform||``).toLowerCase()===`local`,ir=rr&&!!window.desktop?.shell&&!!nr;async function ar(){if(!window.desktop?.shell||!nr)return;let e=await window.desktop.shell.openPath(nr);if(e)throw Error(e)}async function or(e=`obsidian`){if(!(!_||fe)){pe(!0),_e(!1),j(e===`obsidian`?`正在导出 Obsidian 笔记...`:`正在导出 Markdown 笔记...`);try{let t=await window.desktop?.dialog?.pickDirectory?.(be||void 0);if(window.desktop?.dialog&&!t){j(`已取消导出。`);return}let n=await I.exportTaskMarkdown(_,{target:e,include_transcript:ve,output_dir:t||void 0});Ce(n),xe(e=>e||n.directory),await ut({preferredTaskId:_,forceTaskIds:[_]}),j(`已导出到 ${n.file_name}`)}catch(e){j(e instanceof Error?e.message:`导出 Markdown 失败`)}finally{pe(!1)}}}async function sr(){if(!(!_||me)){he(!0),j(`正在导出转写文本...`);try{let e=await window.desktop?.dialog?.pickDirectory?.(be||void 0);if(window.desktop?.dialog&&!e){j(`已取消导出。`);return}let t=await I.exportTaskTranscript(_,{output_dir:e||void 0});Ce(t),xe(e=>e||t.directory),await ut({preferredTaskId:_,forceTaskIds:[_]}),j(`已导出到 ${t.file_name}`)}catch(e){j(e instanceof Error?e.message:`导出转写文本失败`)}finally{he(!1)}}}async function cr(){if(!window.desktop?.shell||!Se?.directory)return;let e=await window.desktop.shell.openPath(Se.directory);if(e)throw Error(e)}return(0,L.jsxs)(`section`,{className:`video-detail-page`,children:[(0,L.jsx)(Vx,{notices:[{id:`video-detail-status`,message:A}]}),(0,L.jsx)(Hr,{isOpen:ee,onClose:()=>M(!1),onOpenTutorial:Ut,onOpenSettings:Wt,onCaptureLoginCookies:Gt}),Oe?.open&&(0,L.jsxs)(`div`,{className:`jump-confirm-popover`,role:`dialog`,"aria-modal":`true`,style:{left:Oe.x,top:Oe.y,transform:`translateX(-50%)`},children:[(0,L.jsx)(`div`,{className:`jump-confirm-popover-arrow`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`jump-confirm-popover-content`,children:[(0,L.jsxs)(`p`,{className:`jump-confirm-popover-message`,children:[`跳转到 P`,Oe.pageNumber,`「`,Oe.title,`」?`]}),(0,L.jsxs)(`div`,{className:`jump-confirm-popover-actions`,children:[(0,L.jsx)(`button`,{className:`jump-confirm-popover-cancel`,onClick:Jn,type:`button`,children:`取消`}),(0,L.jsx)(`button`,{className:`jump-confirm-popover-ok`,onClick:qn,type:`button`,children:`跳转`})]})]})]}),(0,L.jsxs)(`div`,{className:`detail-page-shell`,children:[(0,L.jsx)(`div`,{className:`detail-page-toolbar`,children:(0,L.jsxs)(En,{className:`detail-back-button`,to:`/library`,children:[(0,L.jsx)(ZX,{className:`detail-back-icon`}),`返回视频库`]})}),(0,L.jsxs)(`article`,{className:`video-detail-hero ${_t.total>0?`has-page-batch`:`is-single-page`}`,children:[(0,L.jsx)(`div`,{className:`video-detail-media`,children:ir?(0,L.jsxs)(`button`,{className:`video-detail-cover video-detail-cover-button`,type:`button`,onClick:()=>void ar().catch(e=>{j(e instanceof Error?e.message:`打开本地视频失败`)}),children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`video-detail-cover-overlay`,children:(0,L.jsx)($X,{className:`video-detail-play-icon`})}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]}):rr?(0,L.jsxs)(`div`,{className:`video-detail-cover`,children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]}):(0,L.jsxs)(`a`,{className:`video-detail-cover`,href:nr,target:`_blank`,rel:`noreferrer`,children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`video-detail-cover-overlay`,children:(0,L.jsx)($X,{className:`video-detail-play-icon`})}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]})}),(0,L.jsxs)(`div`,{className:`video-detail-copy`,children:[(0,L.jsxs)(`div`,{className:`video-detail-copy-main`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-meta-row`,children:[(0,L.jsx)(`span`,{className:`detail-status-badge ${ur(hn)}`,children:Jr(hn)}),(0,L.jsx)(`span`,{className:`detail-hero-meta-time`,children:Wr(s.updated_at)}),_t.total>0?(0,L.jsxs)(`span`,{className:`detail-hero-meta-time`,children:[`共 `,_t.total,` P`]}):null]}),(0,L.jsx)(`h2`,{className:`video-detail-title`,children:s.title}),pt.length?(0,L.jsxs)(`div`,{className:`detail-page-switcher ${O?`is-open`:``}`,ref:He,children:[(0,L.jsx)(`span`,{className:`detail-page-switcher-label`,children:`当前内容`}),(0,L.jsxs)(`button`,{className:`detail-page-select`,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":O,onClick:()=>k(e=>!e),children:[(0,L.jsxs)(`span`,{className:`detail-page-select-value`,children:[xt?`全集总结`:St?.title||`选择分 P`,St&&ht.get(St.page)?(0,L.jsx)(`span`,{className:`detail-page-select-check`,children:`✓`}):null,xt&&mt.some(e=>e.status===`completed`)?(0,L.jsx)(`span`,{className:`detail-page-select-check`,children:`✓`}):null]}),(0,L.jsx)(QX,{className:`detail-page-select-caret`})]}),O?(0,L.jsx)(`div`,{className:`detail-page-menu`,children:(0,L.jsxs)(`div`,{className:`detail-page-menu-scroll`,role:`listbox`,"aria-label":`选择当前分 P`,children:[yt?(0,L.jsxs)(`button`,{className:`detail-page-option ${xt?`is-selected`:``}`,role:`option`,"aria-selected":xt,type:`button`,onClick:()=>{De(0),k(!1)},children:[(0,L.jsx)(`span`,{className:`detail-page-option-check ${xt?`is-selected`:``}`,children:xt?`✓`:``}),(0,L.jsxs)(`span`,{className:`detail-page-option-copy`,children:[(0,L.jsx)(`strong`,{children:`全集总结`}),mt.length?(0,L.jsxs)(`small`,{children:[`已有 `,mt.length,` 个版本`]}):(0,L.jsx)(`small`,{children:`可基于已完成分 P 生成`})]})]}):null,pt.map(e=>{let t=e.page===bt,n=ht.get(e.page);return(0,L.jsxs)(`button`,{className:`detail-page-option ${t?`is-selected`:``} ${n?`has-summary`:`is-unavailable`}`,type:`button`,role:`option`,"aria-selected":t,onClick:()=>{De(e.page),k(!1)},children:[(0,L.jsx)(`span`,{className:`detail-page-option-check ${t?`is-selected`:``}`,children:t?`✓`:``}),(0,L.jsxs)(`span`,{className:`detail-page-option-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),n?(0,L.jsx)(`small`,{children:`已生成摘要`}):(0,L.jsx)(`small`,{children:`尚未生成`})]})]},e.page)})]})}):null]}):null]}),(0,L.jsxs)(`div`,{className:`detail-task-float`,ref:Be,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule ${ur(hn)} ${x===`expanded`?`is-expanded`:``}`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule-grid`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule-item`,children:[(0,L.jsx)(`span`,{className:`detail-hero-stat-label`,children:kn[0].label}),(0,L.jsx)(`div`,{className:`detail-hero-stat-value`,children:(0,L.jsx)(`strong`,{className:kn[0].mono?`detail-hero-stat-mono`:``,children:kn[0].value})})]}),(0,L.jsxs)(`button`,{"aria-label":x===`expanded`?`收起任务详情与历史`:`展开任务详情与历史`,"aria-expanded":x===`expanded`,className:`detail-hero-capsule-item detail-task-detail-trigger ${x===`expanded`?`is-open`:``}`,title:x===`expanded`?`收起任务详情与历史`:`任务详情与历史`,type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),C(e=>e===`expanded`?`collapsed`:`expanded`)},children:[(0,L.jsxs)(`span`,{className:`detail-hero-stat-label detail-task-detail-label`,children:[kn[1].label,(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsx)(`div`,{className:`detail-hero-stat-value`,children:(0,L.jsx)(`strong`,{className:kn[1].mono?`detail-hero-stat-mono`:``,children:kn[1].value})})]})]}),(0,L.jsxs)(`div`,{className:`detail-hero-actions`,children:[(0,L.jsx)(`button`,{"aria-label":s.is_favorite?`取消收藏`:`收藏视频`,className:`detail-action-button secondary detail-action-button-compact detail-action-button-favorite ${s.is_favorite?`is-active`:``}`,title:s.is_favorite?`取消收藏`:`收藏视频`,type:`button`,onClick:()=>void $n(),children:(0,L.jsx)(AX,{className:`detail-action-icon`})}),(0,L.jsxs)(`div`,{className:`detail-action-menu`,ref:Ve,children:[(0,L.jsxs)(`button`,{"aria-label":`更多操作`,"aria-expanded":w,"aria-haspopup":`menu`,className:`detail-action-button secondary detail-action-button-compact detail-action-menu-trigger ${w?`is-open`:``}`,title:`更多操作`,type:`button`,onClick:()=>{T(e=>{let t=!e;return t||D(null),t})},children:[(0,L.jsx)(oZ,{className:`detail-action-icon`}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),w?(0,L.jsxs)(`div`,{className:`detail-action-popover`,role:`menu`,"aria-label":`视频操作设置`,children:[(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`regenerate`?`is-open`:``}`,role:`menuitem`,type:`button`,onClick:()=>D(e=>e===`regenerate`?null:`regenerate`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(iZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`重新生成`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsxs)(`div`,{className:`detail-action-submenu ${E===`regenerate`?`is-open`:``}`,role:`group`,"aria-label":`重新生成操作`,"aria-hidden":E!==`regenerate`,children:[(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!Tn,onClick:async()=>{T(!1),D(null),j(`正在基于当前版本重新生成摘要...`),await I.resummarizeVideoTask(s.video_id,{task_id:Ze.current,page_number:bt}),await ut({preferredTaskId:null,syncLibrary:!0}),j(`已开始新的摘要生成任务`)},children:[(0,L.jsx)(iZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑文本笔记`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!Dn,onClick:async()=>{T(!1),D(null),await Qn(!0)},children:[(0,L.jsx)(uZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑图文笔记`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!_||wn!==`completed`||!!(_&&N[_]),onClick:async()=>{T(!1),D(null),await Zn(!0)},children:[(0,L.jsx)(dZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑思维导图`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:xt,onClick:async()=>{T(!1),D(null),j(`正在重新转写并生成摘要...`);let e=DX()===`visual`?`frame_insert`:`text`;await I.createVideoTask(s.video_id,{page_number:bt,visual_note_mode:e}),await ut({preferredTaskId:null,syncLibrary:!0}),j(`已开始新的转写摘要任务`)},children:[(0,L.jsx)(aZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重新转写并生成`})]})]}),(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`batch`?`is-open`:``}`,role:`menuitem`,type:`button`,disabled:gt.length===0,onClick:()=>D(e=>e===`batch`?null:`batch`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(aZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`批量处理`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsxs)(`div`,{className:`detail-action-submenu ${E===`batch`?`is-open`:``}`,role:`group`,"aria-label":`批量处理操作`,"aria-hidden":E!==`batch`,children:[(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,onClick:()=>{T(!1),D(null),Ne(`create`),je(!0)},children:[(0,L.jsx)(aZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`批量生成摘要`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,onClick:()=>{T(!1),D(null),Ne(`resummary`),je(!0)},children:[(0,L.jsx)(iZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`批量重生成摘要`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,disabled:!vt,onClick:()=>void er(),children:[(0,L.jsx)(rZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`生成全集总结`})]})]}),(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`maintenance`?`is-open`:``}`,role:`menuitem`,type:`button`,onClick:()=>D(e=>e===`maintenance`?null:`maintenance`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(nZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`更多维护`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsx)(`div`,{className:`detail-action-submenu ${E===`maintenance`?`is-open`:``}`,role:`group`,"aria-label":`维护操作`,"aria-hidden":E!==`maintenance`,children:(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`maintenance`?0:-1,onClick:async()=>{T(!1),D(null),j(`正在刷新视频信息...`),await I.probeVideo({url:s.source_url,force_refresh:!0}),await ut({preferredTaskId:Ze.current,syncLibrary:!0}),j(`视频信息已刷新`)},children:[(0,L.jsx)(nZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`刷新视频信息`})]})})]}):null]}),(0,L.jsx)(`button`,{"aria-label":`从视频库删除`,className:`detail-action-button danger detail-action-button-compact`,title:`从视频库删除`,type:`button`,onClick:async()=>{window.confirm(`确定要从视频库删除这个视频吗?`)&&(await I.deleteVideo(s.video_id),t(),o(`/library`))},children:(0,L.jsx)(tZ,{className:`detail-action-icon`})})]})]}),x===`expanded`?(0,L.jsxs)(`section`,{className:`grid-card detail-task-panel`,role:`dialog`,"aria-label":`任务进度与历史`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`detail-task-panel-header`,children:[(0,L.jsx)(`div`,{className:`panel-header`,children:(0,L.jsx)(`h2`,{children:`任务进度与历史`})}),(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:()=>C(`collapsed`),children:`关闭`})]}),(0,L.jsxs)(`div`,{className:`detail-task-panel-body`,children:[(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-live`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`实时运行`}),(0,L.jsx)(`h3`,{children:`运行中任务`})]}),_n?(0,L.jsxs)(`span`,{className:`task-history-id`,children:[`任务 `,_n]}):null]}),Tt?(0,L.jsxs)(`div`,{className:`detail-task-live-grid`,children:[(0,L.jsxs)(`div`,{className:`detail-task-live-progress`,children:[(0,L.jsxs)(`div`,{className:`progress-bar-wrapper`,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(Bt.progress),"aria-label":`最新任务进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple ${Bt.hasError?`error`:Bt.isCompleted?`success`:``}`,style:{width:`${Bt.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-info-simple`,children:[(0,L.jsxs)(`span`,{className:`progress-percent-simple`,children:[Math.round(Bt.progress),`%`]}),(0,L.jsx)(`span`,{className:`progress-status-simple`,children:gn})]})]}),It?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`运行详情同步失败`}),(0,L.jsx)(`span`,{children:It})]}):null,Bt.filtered.length?(0,L.jsxs)(`details`,{className:`progress-stage-card`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:Bt.failedEvent?`需要关注`:Bt.isCompleted?`主任务已完成`:`当前进度`}),(0,L.jsx)(`span`,{children:Bn?`${Bn.label} · ${Bn.events.length} 条`:`${Bt.filtered.length} 条进度记录`})]}),(0,L.jsx)(`span`,{className:`progress-stage-toggle`,children:`查看阶段树`})]}),(0,L.jsxs)(`div`,{className:`progress-phase-view`,children:[Bn?(0,L.jsxs)(`article`,{className:`progress-focus-card tone-${Bn.tone}`,children:[(0,L.jsx)(`span`,{children:Bn.tone===`failed`?`异常阶段`:Bt.isCompleted?`完成概览`:`当前阶段`}),(0,L.jsx)(`strong`,{children:Bn.label}),(0,L.jsx)(`small`,{children:Bn.events.at(-1)?.message||gn})]}):null,(0,L.jsx)(`div`,{className:`progress-phase-tree`,children:zn.map(e=>(0,L.jsxs)(`article`,{className:`progress-phase-group tone-${e.tone}`,children:[(0,L.jsxs)(`div`,{className:`progress-phase-head`,children:[(0,L.jsx)(`strong`,{children:e.label}),(0,L.jsxs)(`span`,{children:[e.events.filter(_X).length,`/`,e.events.length]})]}),(0,L.jsx)(`div`,{className:`progress-stage-list progress-stage-tree`,children:e.events.map((t,n)=>(0,L.jsxs)(`article`,{className:`progress-event-card ${dr(t.stage)}`,children:[(0,L.jsx)(`div`,{className:`progress-event-node`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`progress-event-copy`,children:[(0,L.jsxs)(`div`,{className:`progress-event-topline`,children:[(0,L.jsxs)(`strong`,{children:[t.message,` `,(0,L.jsxs)(`span`,{className:`progress-event-count`,children:[`(`,n+1,`/`,e.events.length,`)`]})]}),(0,L.jsx)(`span`,{children:Wr(t.created_at)})]}),(0,L.jsx)(`div`,{className:`progress-event-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.progress,"aria-label":`${lr(t.stage)}阶段进度`,children:(0,L.jsx)(`span`,{style:{width:`${t.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-event-meta`,children:[lr(t.stage),` · `,t.progress,`%`]})]})]},t.event_id))})]},e.id))})]})]}):Pt?(0,L.jsx)(`div`,{className:`detail-inline-note detail-inline-note-pending`,role:`status`,children:`正在同步该任务的实时进度。`}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成进度记录。`})]}),(0,L.jsxs)(`section`,{className:`detail-task-snapshot detail-task-snapshot-emphasis`,children:[(0,L.jsxs)(`div`,{className:`detail-task-snapshot-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-snapshot-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-snapshot-kicker`,children:`当前任务概览`}),(0,L.jsx)(`strong`,{children:vn}),(0,L.jsx)(`small`,{children:_n?`任务 ${_n}`:`任务信息加载中`})]}),(0,L.jsx)(`span`,{className:`helper-chip ${ur(hn)}`,children:Jr(hn)})]}),(0,L.jsx)(`div`,{className:`detail-task-snapshot-grid`,children:yn.map(e=>(0,L.jsxs)(`div`,{className:`detail-snapshot-metric`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`strong`,{children:e.value})]},e.label))})]})]}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前分 P 还没有处理任务。`})]}),(0,L.jsxs)(`div`,{className:`detail-task-panel-grid`,children:[(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-history`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`版本列表`}),(0,L.jsx)(`h3`,{children:`内容版本`})]}),(0,L.jsx)(`span`,{className:`detail-task-section-count`,children:Ct.length})]}),Ct.length?(0,L.jsx)(`div`,{className:`detail-history-list`,children:Ct.map(e=>{let t=e.task_id===_,n=e.task_id===wt;return(0,L.jsx)(`article`,{className:`detail-history-item ${t?`active`:``}`,children:(0,L.jsxs)(`button`,{"aria-pressed":t,className:`detail-history-trigger`,type:`button`,onClick:()=>dt(e.task_id),children:[(0,L.jsxs)(`div`,{className:`detail-history-main`,children:[(0,L.jsxs)(`div`,{className:`detail-history-topline`,children:[(0,L.jsx)(`span`,{className:`task-status ${ur(e.status)}`,children:Jr(e.status)}),n?(0,L.jsx)(`span`,{className:`helper-chip`,children:`最新任务`}):null,t?(0,L.jsx)(`span`,{className:`helper-chip status-success`,children:`当前查看`}):null,MY(e)?(0,L.jsx)(`span`,{className:`helper-chip`,children:MY(e)}):null]}),(0,L.jsx)(`strong`,{children:e.title||s.title}),(0,L.jsx)(`small`,{children:Wr(e.created_at)})]}),(0,L.jsx)(`div`,{className:`detail-history-side`,children:(0,L.jsx)(`span`,{className:`task-history-id`,children:e.task_id.slice(0,8)})})]})},e.task_id)})}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前分 P 还没有可切换的内容版本。`})]}),(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-selected`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`当前查看`}),(0,L.jsx)(`h3`,{children:`查看中的内容版本`})]}),kt?(0,L.jsx)(`span`,{className:`helper-chip ${Nt?`status-success`:`status-pending`}`,children:Nt?`最新版本`:`历史版本`}):null]}),kt?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`detail-history-detail ${Nt?`detail-history-detail-live`:``}`,children:[(0,L.jsxs)(`div`,{className:`detail-history-detail-head`,children:[(0,L.jsxs)(`div`,{className:`detail-history-topline`,children:[(0,L.jsx)(`span`,{className:`task-status ${ur(kt.status)}`,children:Jr(kt.status)}),kt.task_id===wt?(0,L.jsx)(`span`,{className:`helper-chip`,children:`最新任务`}):null,(0,L.jsx)(`span`,{className:`helper-chip status-success`,children:`当前查看`})]}),(0,L.jsx)(`span`,{className:`task-history-id`,children:kt.task_id.slice(0,8)})]}),(0,L.jsxs)(`div`,{className:`detail-history-detail-copy`,children:[(0,L.jsx)(`strong`,{children:kt.title||s.title}),(0,L.jsx)(`small`,{children:Wr(kt.created_at)})]}),(0,L.jsx)(`div`,{className:`detail-history-metrics`,children:Sn.map(e=>(0,L.jsxs)(`div`,{className:`detail-snapshot-metric detail-history-metric`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`strong`,{children:e.value})]},e.label))})]}),Ft?(0,L.jsx)(`div`,{className:`detail-inline-note detail-inline-note-pending`,role:`status`,children:`正在加载该版本的详细内容,下方工作台会在同步后切换。`}):null,Lt?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`版本详情加载失败`}),(0,L.jsx)(`span`,{children:IY(Lt)})]}):null,jt?.error_message?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`任务错误`}),(0,L.jsx)(`span`,{children:IY(jt.error_message)})]}):null,!Ft&&!Lt?(0,L.jsx)(`div`,{className:`detail-inline-note`,role:`status`,children:jt?.result?`该版本的结果已同步到下方工作台。`:`该版本还没有可用结果,下方工作台会展示对应状态。`}):null,(0,L.jsx)(`div`,{className:`detail-history-actions`,children:(0,L.jsx)(`button`,{className:`tertiary-button danger`,type:`button`,onClick:async()=>{window.confirm(`确定要删除这条任务记录吗?`)&&(et.current.delete(kt.task_id),tt.current.delete(kt.task_id),f(e=>TX(e,kt.task_id)),m(e=>TX(e,kt.task_id)),g(e=>TX(e,kt.task_id)),await I.deleteTask(kt.task_id),await ut({preferredTaskId:kt.task_id===Ze.current?null:Ze.current,syncLibrary:!0}))},children:`删除任务`})})]}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`选择一个任务版本后,这里会显示该版本的元信息与可用状态。`})]})]})]})]}):null]})]}),_t.total>0?(0,L.jsxs)(`div`,{className:`detail-batch-side`,"aria-label":`批量任务统计`,ref:Ue,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple detail-batch-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":jn,"aria-label":`批量完成进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple success`,style:{width:`${jn}%`}})}),(0,L.jsx)(`div`,{className:`detail-batch-inline-meta`,children:(0,L.jsxs)(`div`,{className:`detail-batch-inline-copy`,children:[(0,L.jsxs)(`span`,{children:[An,` / `,_t.total]}),(0,L.jsxs)(`small`,{children:[`进行中 `,_t.inProgress,` · 未开始 `,_t.notStarted,_t.failed?` · 失败 ${_t.failed}`:``]})]})})]}):null]}),(0,L.jsx)(`section`,{className:`video-detail-main`,children:(0,L.jsxs)(`article`,{className:`detail-workspace-card`,children:[(0,L.jsxs)(`div`,{className:`detail-workspace-header`,children:[(0,L.jsx)(`h3`,{className:`detail-workspace-label`,children:`Knowledge Workspace`}),(0,L.jsxs)(`div`,{className:`detail-workspace-meta`,children:[(0,L.jsxs)(`span`,{className:`detail-workspace-signal ${Vt?ur(wn):`status-success`}`,children:[(0,L.jsx)(`span`,{className:`detail-workspace-signal-dot`}),On]}),xn?(0,L.jsxs)(`span`,{children:[`任务 `,xn]}):null,Cn==null?null:(0,L.jsxs)(`span`,{children:[qr(Cn),` tokens`]})]})]}),(0,L.jsx)(`nav`,{className:`detail-tab-row`,role:`tablist`,"aria-label":`详情工作台视图`,children:fX.map(e=>(0,L.jsxs)(`button`,{className:`detail-tab ${y===e.id?`active`:``}`,role:`tab`,type:`button`,"aria-selected":y===e.id,onClick:()=>b(e.id),children:[(0,L.jsxs)(`div`,{className:`detail-tab-topline`,children:[(0,L.jsx)(XX,{active:y===e.id,tab:e.id}),(0,L.jsx)(`span`,{children:e.label})]}),(0,L.jsx)(`small`,{children:e.description})]},e.id))}),y===`knowledge`?Vt?(0,L.jsx)(YX,{cookieHelpActions:Kt,state:Vt}):(0,L.jsxs)(`section`,{className:`detail-tab-panel detail-export-target`,ref:Ke,children:[(0,L.jsxs)(`div`,{className:`detail-knowledge-lead`,children:[(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-overview`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading-main`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Overview`}),Xt?.meta?(0,L.jsx)(`span`,{className:`detail-section-meta`,children:Xt.meta}):null]}),(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,onClick:Rt,disabled:ue,"aria-label":ue?`正在导出知识卡片图片`:`复制当前知识卡片为图片`,title:ue?`正在导出知识卡片图片`:`复制当前知识卡片为图片`,children:(0,L.jsx)(uZ,{})})]}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:Xt?.title||`核心概览`}),Xt?.content?(0,L.jsx)(kx,{className:`detail-section-body markdown-content-body`,compact:!0,content:Xt.content}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:`当前任务还没有生成核心概览。`}),Pn?(0,L.jsxs)(`div`,{className:`detail-overview-player`,ref:We,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Player`}),(0,L.jsx)(`span`,{className:`detail-section-meta detail-section-link`,children:`本地视频播放器`})]}),(0,L.jsxs)(`div`,{className:`detail-video-embed-frame`,children:[(0,L.jsx)(`video`,{ref:Ge,className:`detail-video-embed detail-local-video`,controls:!0,preload:`metadata`,src:Pn,poster:St?.cover_url||s.cover_url||void 0}),(0,L.jsx)(`div`,{className:`detail-video-export-mask`,"aria-hidden":`true`,children:St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{className:`detail-video-export-cover`,src:St?.cover_url||s.cover_url,alt:``}):(0,L.jsxs)(`div`,{className:`detail-video-export-mask-copy`,children:[(0,L.jsx)(`strong`,{children:s.title}),(0,L.jsx)(`span`,{children:`导出知识卡片时会保留当前视频封面,不直接导出播放器画面。`})]})})]})]}):Nn&&Mn?(0,L.jsxs)(`div`,{className:`detail-overview-player`,ref:We,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Player`}),(0,L.jsx)(`a`,{className:`detail-section-meta detail-section-link`,href:Mn.sourceUrl,target:`_blank`,rel:`noreferrer`,children:Mn.openLabel})]}),(0,L.jsxs)(`div`,{className:`detail-video-embed-frame`,children:[(0,L.jsx)(`iframe`,{allow:`accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen`,allowFullScreen:!0,className:`detail-video-embed`,referrerPolicy:`strict-origin-when-cross-origin`,scrolling:`no`,src:Nn,title:`${s.title} 播放器`}),(0,L.jsx)(`div`,{className:`detail-video-export-mask`,"aria-hidden":`true`,children:St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{className:`detail-video-export-cover`,src:St?.cover_url||s.cover_url,alt:``}):(0,L.jsxs)(`div`,{className:`detail-video-export-mask-copy`,children:[(0,L.jsx)(`strong`,{children:s.title}),(0,L.jsx)(`span`,{children:`播放器画面无法直接导出,已保留当前卡片内容与视频入口。`})]})})]})]}):null]}),(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-keypoints`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Key Points`}),(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[Zt.length,` 条`]})]}),Zt.length?(0,L.jsx)(`div`,{className:`detail-point-rail`,children:Zt.map((e,t)=>(0,L.jsx)(NX,{card:e,index:t},e.id))}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成关键要点卡。`})]})]}),(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-last`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Chapters`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[$t.length?(0,L.jsx)(`button`,{className:`detail-section-text-action`,type:`button`,onClick:Yn,children:en?`一键收起`:`一键展开`}):null,(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[Qt.length,` 条`]})]})]}),$t.length?(0,L.jsx)(`div`,{className:`detail-chapter-groups`,children:$t.map(e=>{let t=we.includes(e.id);return(0,L.jsxs)(`div`,{className:`detail-chapter-group ${t?`is-open`:``}`,children:[(0,L.jsxs)(`button`,{className:`detail-chapter-group-summary`,type:`button`,"aria-expanded":t,onClick:()=>Xn(e.id,!t),children:[(0,L.jsxs)(`div`,{className:`detail-chapter-group-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.meta})]}),(0,L.jsx)(`span`,{className:`detail-chapter-group-caret`,"aria-hidden":`true`,children:(0,L.jsx)(QX,{})})]}),(0,L.jsx)(`div`,{className:`detail-chapter-group-content`,children:(0,L.jsx)(`div`,{className:`detail-chapter-group-body`,children:e.items.map((e,t)=>(0,L.jsx)(NX,{card:e,index:t,onJumpToPage:xt?Kn:void 0,onSeekToTimestamp:!xt&&Fn?Gn:void 0},e.id))})})]},e.id)})}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成章节知识卡。`})]})]}):null,y===`summary`?Vt?(0,L.jsx)(YX,{cookieHelpActions:Kt,state:Vt}):(0,L.jsxs)(`section`,{className:`detail-tab-panel`,children:[(0,L.jsxs)(`section`,{className:`detail-content-section`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Knowledge Note`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[`完整学习视图 · `,ln]}),(0,L.jsxs)(`div`,{className:`detail-section-menu`,ref:qe,children:[(0,L.jsxs)(`button`,{className:`detail-section-icon-button detail-section-menu-trigger ${ce?`is-open`:``}`,type:`button`,onClick:()=>le(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ce,"aria-label":`选择知识笔记显示形式`,title:`笔记形式`,children:[sn===`visual`?(0,L.jsx)(uZ,{}):(0,L.jsx)(rZ,{}),(0,L.jsx)(QX,{className:`detail-section-menu-caret`})]}),ce?(0,L.jsxs)(`div`,{className:`detail-section-popover detail-note-mode-popover`,role:`menu`,"aria-label":`知识笔记显示形式`,children:[(0,L.jsxs)(`button`,{className:`detail-section-menu-item detail-note-mode-option ${sn===`visual`?`is-selected`:``}`,type:`button`,role:`menuitemradio`,"aria-checked":sn===`visual`,disabled:!on,onClick:()=>{on&&(se(`visual`),le(!1))},children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(uZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:`图文`}),(0,L.jsx)(`small`,{children:on?`显示带图片的整合笔记`:un})]})]}),(0,L.jsxs)(`button`,{className:`detail-section-menu-item detail-note-mode-option ${sn===`text`?`is-selected`:``}`,type:`button`,role:`menuitemradio`,"aria-checked":sn===`text`,onClick:()=>{se(`text`),le(!1)},children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(rZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:`纯文本`}),(0,L.jsx)(`small`,{children:`显示基础知识笔记正文`})]})]})]}):null]}),(0,L.jsxs)(`div`,{className:`detail-section-menu`,ref:Je,children:[(0,L.jsxs)(`button`,{className:`detail-section-icon-button detail-section-menu-trigger ${ge?`is-open`:``}`,type:`button`,disabled:!fn||fe,onClick:()=>_e(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ge,"aria-label":fe?`正在导出 Obsidian 笔记`:`导出知识笔记`,title:fe?`正在导出 Obsidian 笔记`:`导出知识笔记`,children:[(0,L.jsx)(cZ,{}),(0,L.jsx)(QX,{className:`detail-section-menu-caret`})]}),ge?(0,L.jsxs)(`div`,{className:`detail-section-popover`,role:`menu`,"aria-label":`知识笔记导出设置`,children:[(0,L.jsxs)(`button`,{className:`detail-section-menu-item`,type:`button`,role:`menuitem`,disabled:!fn||fe,onClick:()=>void or(`obsidian`),children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(cZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:fe?`正在导出...`:`导出到 Obsidian`}),(0,L.jsx)(`small`,{children:`选择目录后写入 Markdown 笔记`})]})]}),(0,L.jsxs)(`label`,{className:`detail-section-menu-check`,role:`menuitemcheckbox`,"aria-checked":ve,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:ve,onChange:e=>ye(e.target.checked)}),(0,L.jsx)(`span`,{children:`导出笔记时附带转写全文`})]})]}):null]}),Se?.directory&&window.desktop?.shell?(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,onClick:()=>void cr().catch(e=>{j(e instanceof Error?e.message:`打开导出目录失败`)}),"aria-label":`打开导出目录`,title:`打开导出目录`,children:(0,L.jsx)(lZ,{})}):null]})]}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:`知识笔记`}),!be&&!window.desktop?.dialog?(0,L.jsx)(`p`,{className:`detail-section-body`,children:`导出前请先在设置中填写输出目录,Markdown / Obsidian 笔记会写入该目录。`}):null,cn?(0,L.jsx)(kx,{className:`detail-note-markdown`,content:cn,imageResolver:e=>RX(_,e)}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:`当前任务还没有生成知识笔记。`}),(0,L.jsxs)(`details`,{className:`detail-visual-assets-details detail-note-assets-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(`span`,{children:`查看图片素材记录`}),(0,L.jsx)(`small`,{children:LX(rn,dn.length,nn?.insert_count??0)})]}),(0,L.jsx)(zX,{frames:dn,status:rn,errorMessage:nn?.error_message||jt?.result?.visual_note_error_message||``,loading:!!(_&&ae[_]),onSeekToTimestamp:!xt&&Fn?Gn:void 0})]})]}),(0,L.jsxs)(`section`,{className:`detail-content-section`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Transcript`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[(0,L.jsx)(`span`,{className:`detail-section-meta`,children:pn?`原始转写`:`暂无内容`}),(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,disabled:!mn||me,onClick:()=>void sr(),"aria-label":me?`正在导出转写文本`:`导出转写文本`,title:me?`正在导出转写文本`:`导出转写文本`,children:(0,L.jsx)(cZ,{})})]})]}),zt?.segments&&zt.segments.length>0?(0,L.jsx)(`div`,{className:`transcript-with-timestamps`,children:zt.segments.map((e,t)=>(0,L.jsxs)(`div`,{className:`transcript-segment`,children:[(0,L.jsxs)(`span`,{className:`transcript-timestamp`,children:[`[`,Math.floor(e.start/60),`:`,String(Math.floor(e.start%60)).padStart(2,`0`),`]`]}),(0,L.jsx)(`span`,{className:`transcript-text`,children:e.text})]},t))}):(0,L.jsx)(`pre`,{className:`transcript-full`,children:pn||`暂无转写全文。`})]})]}):null,y===`mindmap`?(0,L.jsx)(`section`,{className:`detail-tab-panel`,children:(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-last`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Mind Map`}),(0,L.jsx)(`div`,{className:`detail-section-heading-actions`,children:(0,L.jsx)(`span`,{className:`detail-section-meta`,children:Vn})})]}),In?(0,L.jsxs)(`div`,{className:`detail-mindmap-workspace`,children:[(0,L.jsx)(`div`,{className:`detail-mindmap-canvas`,role:`tree`,"aria-label":`思维导图`,children:(0,L.jsx)(`div`,{className:`detail-mindmap-flow-shell`,children:(0,L.jsx)(nP,{nodes:Un.nodes,edges:Un.edges,fitView:!0,fitViewOptions:{padding:.24},minZoom:.38,maxZoom:1.6,nodeTypes:qX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},onNodeClick:(e,t)=>Le(t.id),onPaneClick:()=>Le(null),children:(0,L.jsx)(vP,{showInteractive:!1})},`${In.root}-${In.nodes.length}`)})}),(0,L.jsx)(`div`,{className:`detail-mindmap-inspector`,children:Wn?(0,L.jsxs)(`article`,{className:`detail-mindmap-inspector-card`,children:[(0,L.jsxs)(`div`,{className:`detail-mindmap-inspector-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`detail-mindmap-inspector-kicker`,children:FX(Wn.type)}),(0,L.jsx)(`h4`,{children:Zr(Wn.label,Wn.summary)})]}),xt&&EX(Wn.time_anchor)?(0,L.jsxs)(`button`,{className:`detail-mindmap-seek-button`,type:`button`,"data-jump-anchor":!0,onClick:e=>Kn(e,Math.round(Wn.time_anchor??0)),children:[(0,L.jsx)(fZ,{className:`detail-mindmap-seek-icon`}),`查看 P`,Math.round(Wn.time_anchor??0),` 总结`]}):EX(Wn.time_anchor)&&Fn?(0,L.jsxs)(`button`,{className:`detail-mindmap-seek-button`,type:`button`,onClick:()=>Gn(Wn.time_anchor??null),children:[(0,L.jsx)(fZ,{className:`detail-mindmap-seek-icon`}),`定位到片段 `,Gr(Wn.time_anchor)]}):null]}),Wn.summary?(0,L.jsx)(kx,{className:`detail-mindmap-summary-markdown`,compact:!0,content:Wn.summary}):null,Wn.source_chapter_titles.length?(0,L.jsx)(`div`,{className:`detail-mindmap-inspector-tags`,children:Wn.source_chapter_titles.slice(0,3).map((e,t)=>{let n=Wn.source_chapter_starts[t]??null,r=xt&&EX(n),i=!xt&&EX(n)&&Fn,a=r?`P${Math.round(n)}`:EX(n)?Gr(n):``,o=`${e}${a?` · ${a}`:``}`;return r||i?(0,L.jsx)(`button`,{className:`detail-mindmap-inspector-tag is-action`,type:`button`,onClick:e=>r?Kn(e,Math.round(n)):Gn(n),children:o},`${e}-${t}`):(0,L.jsx)(`span`,{className:`detail-mindmap-inspector-tag`,children:o},`${e}-${t}`)})}):null]}):(0,L.jsxs)(`div`,{className:`detail-mindmap-inspector-hint`,children:[(0,L.jsx)(`strong`,{children:`点击节点查看摘要与来源片段`}),(0,L.jsx)(`span`,{children:`主干只保留结构和标签,避免把导图重新变成一块块内容卡片。`})]})})]}):Jt?(0,L.jsxs)(`article`,{className:`detail-mindmap-placeholder tone-${Jt.tone}`,children:[(0,L.jsxs)(`div`,{className:`detail-mindmap-copy`,children:[(0,L.jsx)(`h4`,{className:`detail-section-title`,children:Jt.title}),(0,L.jsx)(`p`,{className:`detail-section-body`,children:Jt.description}),Rn?(0,L.jsxs)(`div`,{className:`detail-mindmap-progress`,children:[(0,L.jsxs)(`div`,{className:`progress-bar-wrapper`,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Rn.progress,"aria-label":`思维导图生成进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple ${Rn.hasError?`error`:Rn.progress>=100?`success`:``}`,style:{width:`${Rn.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-info-simple`,children:[(0,L.jsxs)(`span`,{className:`progress-percent-simple`,children:[Rn.progress,`%`]}),(0,L.jsx)(`span`,{className:`progress-status-simple`,children:Rn.message})]})]}),Rn.events.length?(0,L.jsxs)(`details`,{className:`progress-stage-card`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(`strong`,{children:Rn.currentLabel}),(0,L.jsx)(`span`,{className:`progress-stage-toggle`,children:`查看导图进度`})]}),(0,L.jsx)(`div`,{className:`progress-stage-list progress-stage-tree`,children:Rn.events.map((e,t)=>(0,L.jsxs)(`article`,{className:`progress-event-card ${dr(e.stage)}`,children:[(0,L.jsx)(`div`,{className:`progress-event-node`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`progress-event-copy`,children:[(0,L.jsxs)(`div`,{className:`progress-event-topline`,children:[(0,L.jsxs)(`strong`,{children:[e.message,` `,(0,L.jsxs)(`span`,{className:`progress-event-count`,children:[`(`,t+1,`/`,Rn.events.length,`)`]})]}),(0,L.jsx)(`time`,{children:Wr(e.created_at)})]}),(0,L.jsx)(`div`,{className:`progress-event-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.progress,"aria-label":`${lr(e.stage)}阶段进度`,children:(0,L.jsx)(`span`,{style:{width:`${e.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-event-meta`,children:[lr(e.stage),` · `,e.progress,`%`]})]})]},e.event_id))})]}):null]}):null]}),Jt.actionLabel?(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,disabled:!Jt.actionEnabled||!!(_&&N[_]),"aria-disabled":!Jt.actionEnabled||!!(_&&N[_]),onClick:()=>Zn(Jt.tone===`failed`),children:_&&N[_]?`处理中...`:Jt.actionLabel}):null]}):null]})}):null,(0,L.jsx)(gi,{isOpen:Ae,mode:Me,video:s,pages:gt,onClose:()=>je(!1),onSubmit:tr}),(y===`summary`||y===`mindmap`)&&(Pn||Nn&&Mn)?(0,L.jsx)(JX,{embedUrl:Nn,localVideoUrl:Pn,openLabel:Mn?.openLabel,sourceUrl:Mn?.sourceUrl,seekTarget:Pe,title:s.title}):null]})})]})]})}function NX({card:e,index:t,onJumpToPage:n,onSeekToTimestamp:r}){if(e.kind===`chapter`){let t=typeof e.timestampSeconds==`number`&&!!r,i=typeof e.pageNumber==`number`&&!!n,a=t||i,o=(0,L.jsxs)(`div`,{className:`detail-chapter-node-shell`,children:[(0,L.jsx)(`span`,{className:`detail-chapter-node-dot`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`detail-chapter-node-meta`,children:(0,L.jsxs)(`div`,{className:`detail-chapter-time`,children:[e.anchorLabel?(0,L.jsx)(rZ,{className:`detail-inline-icon`}):(0,L.jsx)(eZ,{className:`detail-inline-icon`}),(0,L.jsx)(`span`,{children:e.anchorLabel||(e.timestampSeconds==null?`--`:Gr(e.timestampSeconds))})]})}),(0,L.jsxs)(`div`,{className:`detail-chapter-node-copy`,children:[(0,L.jsx)(`h4`,{children:e.title}),(0,L.jsx)(kx,{className:`detail-card-markdown`,compact:!0,content:e.content})]}),a?(0,L.jsxs)(`div`,{className:`detail-card-link`,children:[i?`查看分 P 总结`:`定位片段`,(0,L.jsx)(fZ,{className:`detail-inline-icon`})]}):null]});return a?(0,L.jsx)(`button`,{className:`detail-chapter-node detail-chapter-node-action`,type:`button`,"data-jump-anchor":!0,onClick:t=>{if(i){n(t,e.pageNumber??null);return}r(e.timestampSeconds??null)},children:o}):(0,L.jsx)(`article`,{className:`detail-chapter-node`,children:o})}return(0,L.jsxs)(`article`,{className:`detail-point-item`,children:[(0,L.jsx)(`div`,{className:`detail-point-marker`,"aria-hidden":`true`,children:(0,L.jsx)(`span`,{children:String(t+1).padStart(2,`0`)})}),(0,L.jsxs)(`div`,{className:`detail-point-main`,children:[e.title?(0,L.jsx)(`div`,{className:`detail-point-card-top`,children:(0,L.jsx)(`h4`,{children:e.title})}):null,(0,L.jsx)(kx,{className:`detail-card-markdown`,compact:!0,content:e.content})]})]})}function PX(e,t){if(e.id===t)return e;for(let n of e.children){let e=PX(n,t);if(e)return e}return null}function FX(e){switch(e){case`root`:return`中心主题`;case`theme`:return`一级主题`;case`topic`:return`子主题`;case`leaf`:return`知识点`;default:return`节点`}}function IX(e,t){if(!e||!t?.context?.observations?.length)return[];let n=new Map;for(let e of t.context.frames??[])e.frame_id&&n.set(e.frame_id,e);return t.context.observations.map(t=>{let r=n.get(t.frame_id)?.file_name||`${t.frame_id}.jpg`;return{key:`${t.frame_id}-${t.timestamp_seconds}`,timestampSeconds:t.timestamp_seconds,timestampLabel:Gr(t.timestamp_seconds),imageUrl:`/api/v1/tasks/${e}/visual-evidence/media/${encodeURIComponent(r)}`,caption:t.caption||`关键画面截图`,ocrText:t.ocr_text||``,scene:t.scene||``}}).filter(e=>Number.isFinite(e.timestampSeconds))}function LX(e,t,n=0){return e===`generating`?`生成中`:e===`ready`?n>0?`${n} 处插图 · ${t} 张图`:`${t} 张图`:e===`partial`?t?`${t} 张,部分降级`:`部分降级`:e===`unsupported`?`当前输入不支持`:e===`failed`?`生成失败`:`按需生成`}function RX(e,t){if(!e)return t;let n=t.startsWith(`visual://`)?t.replace(`visual://`,``).trim():t.startsWith(`frames/`)?t.replace(/^frames\//,``).trim():``;if(!n)return t;let r=n.replace(/\.jpg$/i,``);if(!r||r.includes(`/`)||r.includes(`\\`))return t;let i=n.match(/\.(jpe?g|png|webp)$/i)?n:`${r}.jpg`;return`/api/v1/tasks/${e}/visual-evidence/media/${encodeURIComponent(i)}`}function zX({frames:e,status:t,errorMessage:n,loading:r,onSeekToTimestamp:i}){return e.length?(0,L.jsx)(`div`,{className:`detail-visual-grid`,children:e.map(e=>(0,L.jsxs)(`article`,{className:`detail-visual-card`,children:[(0,L.jsx)(`img`,{alt:`${e.timestampLabel} ${e.caption}`,src:e.imageUrl,loading:`lazy`}),(0,L.jsxs)(`div`,{className:`detail-visual-card-copy`,children:[(0,L.jsxs)(`div`,{className:`detail-visual-card-head`,children:[i?(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e.timestampSeconds),children:e.timestampLabel}):(0,L.jsx)(`span`,{children:e.timestampLabel}),e.scene?(0,L.jsx)(`small`,{children:e.scene}):null]}),(0,L.jsx)(`strong`,{children:e.caption}),e.ocrText?(0,L.jsxs)(`p`,{children:[`画面文字:`,e.ocrText]}):null]})]},e.key))}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:r||t===`generating`?`正在后台生成图文笔记,完成后会自动刷新。`:t===`unsupported`?n||`音频或纯文本任务没有可截图的视频画面。`:t===`failed`?n||`图文笔记生成失败,可以稍后重试。`:`还没有生成图文笔记。`})}function BX(e,t=0){let n=t===0?132:e.type===`theme`?88:e.type===`topic`?66:56;if(!e.children.length)return n;let r=t===0?58:t===1?30:18,i=e.children.reduce((e,n)=>e+BX(n,t+1),0)+r*(e.children.length-1);return Math.max(n,i)}function VX(e,t){return e===0?112:e===1?t.type===`leaf`?78:94:t.type===`leaf`?54:68}function HX(e){switch(e.type){case`root`:return{width:252,height:112};case`theme`:return{width:208,height:44};case`topic`:return{width:212,height:40};case`leaf`:return{width:232,height:52};default:return{width:200,height:48}}}function UX(e,t){if(!t)return null;let n=new Map,r=new Map;e.forEach(e=>{e.parentId&&(n.set(e.node.id,e.parentId),r.set(e.parentId,[...r.get(e.parentId)??[],e.node.id]))});let i=new Set([t]),a=t;for(;n.has(a);)a=n.get(a),i.add(a);let o=[t];for(;o.length;){let e=o.pop();(r.get(e)??[]).forEach(e=>{i.has(e)||(i.add(e),o.push(e))})}return i}function WX(e){let t=[];t.push({node:e,depth:0,branch:`center`,x:0,y:0,accent:nX});let n=HX(e),r=[],i=[],a=0,o=0;e.children.forEach((e,t)=>{let n=rX[t%rX.length],s=BX(e,1);if(a<=o){r.push({node:e,accent:n}),a+=s;return}i.push({node:e,accent:n}),o+=s});let s=(e,n,r,i,a,o,c)=>{if(t.push({node:e,depth:n,branch:r,x:a,y:o,parentId:c,accent:i}),!e.children.length)return;let l=n===1?30:18,u=HX(e),d=r===`left`?a-u.width:a+u.width,f=e.children.map(e=>({child:e,span:BX(e,n+1)})),p=o-(f.reduce((e,t)=>e+t.span,0)+l*(f.length-1))/2;f.forEach(({child:t,span:a})=>{let o=p+a/2,c=r===`left`?d-VX(n,t):d+VX(n,t);s(t,n+1,r,i,c,o,e.id),p+=a+l})},c=(t,r)=>{if(!t.length)return;let i=t.map(e=>({...e,span:BX(e.node,1)})),a=-(i.reduce((e,t)=>e+t.span,0)+58*(i.length-1))/2;i.forEach(({node:t,accent:i,span:o})=>{let c=a+o/2;s(t,1,r,i,r===`left`?-(n.width/2+VX(0,t)):n.width/2+VX(0,t),c,e.id),a+=o+58})};c(r,`left`),c(i,`right`);let l=t.reduce((e,t)=>{let n=HX(t.node),r=t.branch===`left`?t.x-n.width:t.branch===`right`?t.x:t.x-n.width/2,i=t.branch===`left`?t.x:t.branch===`right`?t.x+n.width:t.x+n.width/2;return{left:Math.min(e.left,r),right:Math.max(e.right,i),top:Math.min(e.top,t.y-n.height/2),bottom:Math.max(e.bottom,t.y+n.height/2)}},{left:1/0,right:-1/0,top:1/0,bottom:-1/0}),u=-((l.left+l.right)/2),d=-((l.top+l.bottom)/2);return t.map(e=>({...e,x:e.x+u,y:e.y+d}))}function GX(e,t,n=`time`){let r=WX(e),i=UX(r,t),a=!!i?.size;return{nodes:r.map(e=>{let r=t===e.node.id,o=a?!i.has(e.node.id):!1,s=HX(e.node),c=e.branch===`left`?{x:e.x-s.width,y:e.y-s.height/2}:e.branch===`right`?{x:e.x,y:e.y-s.height/2}:{x:e.x-s.width/2,y:e.y-s.height/2};return{id:e.node.id,type:`mindmap`,position:c,draggable:!1,selectable:!0,sourcePosition:e.branch===`left`?lO.Left:lO.Right,targetPosition:e.branch===`left`?lO.Right:lO.Left,className:`${r?`is-active `:``}${o?`is-muted`:``}`.trim(),data:{label:e.node.label,summary:e.node.summary,tone:e.node.type,branch:e.branch,selected:r,muted:o,timeAnchor:e.node.time_anchor??null,pageAnchorLabel:n===`page`&&EX(e.node.time_anchor)?`P${Math.round(e.node.time_anchor??0)}`:void 0,sourceChapterTitles:e.node.source_chapter_titles,sourceChapterStarts:e.node.source_chapter_starts,accent:e.accent}}}),edges:r.filter(e=>e.parentId).map(e=>{let t=a?!(i.has(e.node.id)&&i.has(e.parentId)):!1;return{id:`${e.parentId}-${e.node.id}`,source:e.parentId,target:e.node.id,sourceHandle:e.branch===`left`?`source-left`:`source-right`,targetHandle:e.branch===`left`?`target-right`:`target-left`,type:`simplebezier`,animated:!1,className:`detail-mindmap-edge${t?` is-muted`:``}`,style:{stroke:e.accent.stroke,strokeWidth:e.depth<=1?2.8:2.2}}})}}function KX({data:e}){let t={"--mindmap-branch":e.accent.stroke,"--mindmap-branch-soft":e.accent.surface,"--mindmap-branch-ink":e.accent.ink,"--mindmap-branch-shadow":e.accent.shadow},n=Zr(e.label,e.summary);return(0,L.jsxs)(`div`,{className:`detail-mindmap-node-card tone-${e.tone}`,style:t,children:[e.tone===`root`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-left`,position:lO.Left,type:`source`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-right`,position:lO.Right,type:`source`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`target-left`,position:lO.Left,type:`target`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`target-right`,position:lO.Right,type:`target`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-left`,position:lO.Left,type:`source`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-right`,position:lO.Right,type:`source`})]}),(0,L.jsxs)(`div`,{className:`detail-mindmap-node-head`,children:[(0,L.jsx)(kx,{className:`detail-mindmap-node-label`,compact:!0,content:n}),e.pageAnchorLabel?(0,L.jsx)(`small`,{children:e.pageAnchorLabel}):EX(e.timeAnchor)?(0,L.jsx)(`small`,{children:Gr(e.timeAnchor)}):null]})]})}var qX={mindmap:KX};function JX({embedUrl:e,localVideoUrl:t,openLabel:n,sourceUrl:r,seekTarget:i,title:a}){let o=(0,S.useRef)(null),[s,c]=(0,S.useState)(()=>typeof window>`u`?{width:oX,x:0,y:0}:wX(window.innerWidth,window.innerHeight)),l=(0,S.useRef)(null);(0,S.useEffect)(()=>{function e(){c(e=>CX(e,window.innerWidth,window.innerHeight))}return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,S.useEffect)(()=>{function e(e){let t=o.current;if(t){if(t.mode===`drag`){c(n=>CX({...n,width:t.layout.width,x:t.layout.x+(e.clientX-t.originX),y:t.layout.y+(e.clientY-t.originY)},window.innerWidth,window.innerHeight));return}c(n=>CX({...n,width:t.layout.width+(e.clientX-t.originX)},window.innerWidth,window.innerHeight))}}function t(){o.current=null}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[]),(0,S.useEffect)(()=>{!t||!l.current||i.seconds==null||(l.current.currentTime=i.seconds,l.current.play().catch(()=>{}))},[t,i]);function u(e,t){t.button===0&&(o.current={mode:e,originX:t.clientX,originY:t.clientY,layout:s},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())}function d(){typeof window>`u`||c(wX(window.innerWidth,window.innerHeight))}return(0,L.jsxs)(`div`,{className:`detail-floating-player`,style:{width:`${s.width}px`,left:`${s.x}px`,top:`${s.y}px`},children:[(0,L.jsxs)(`div`,{className:`detail-floating-player-head`,onPointerDown:e=>u(`drag`,e),children:[(0,L.jsxs)(`div`,{className:`detail-floating-player-copy`,children:[(0,L.jsx)(`span`,{className:`detail-floating-player-kicker`,children:`Player`}),(0,L.jsx)(`strong`,{children:a})]}),r&&n?(0,L.jsx)(`a`,{className:`detail-floating-player-link`,href:r,target:`_blank`,rel:`noreferrer`,onPointerDown:e=>e.stopPropagation(),children:n}):null]}),(0,L.jsx)(`div`,{className:`detail-video-embed-frame detail-video-embed-frame-floating`,children:t?(0,L.jsx)(`video`,{ref:l,className:`detail-video-embed detail-local-video`,controls:!0,preload:`metadata`,src:t}):e?(0,L.jsx)(`iframe`,{allow:`accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen`,allowFullScreen:!0,className:`detail-video-embed`,referrerPolicy:`strict-origin-when-cross-origin`,scrolling:`no`,src:e,title:`${a} 悬浮播放器`}):null}),(0,L.jsx)(`div`,{className:`detail-floating-player-resize`,role:`presentation`,onPointerDown:e=>u(`resize`,e),onDoubleClick:d})]})}function YX({cookieHelpActions:e,state:t}){return(0,L.jsx)(`section`,{className:`detail-state-panel tone-${t.tone}`,role:`status`,children:(0,L.jsxs)(`div`,{className:`detail-state-copy`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Workspace State`}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:t.title}),(0,L.jsx)(`p`,{className:`detail-section-body`,children:t.description}),t.detail?(0,L.jsx)(`pre`,{className:`detail-state-detail`,children:t.detail}):null,e?(0,L.jsxs)(`div`,{className:`detail-state-actions`,children:[(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:e.onOpenTutorial,children:`打开导出教程`}),(0,L.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:e.onOpenSettings,children:`前往 Cookies 设置`})]}):null]})})}function XX({active:e,tab:t}){let n=`detail-tab-icon ${e?`is-active`:``}`;return t===`knowledge`?(0,L.jsx)(dZ,{className:n}):t===`summary`?(0,L.jsx)(rZ,{className:n}):(0,L.jsx)(sZ,{className:n})}function ZX(e){return(0,L.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}function QX(e){return(0,L.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function $X(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`m10 8 6 4-6 4z`})]})}function eZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M12 7v5l3 2`})]})}function tZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function nZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M20 4v6h-6`}),(0,L.jsx)(`path`,{d:`M4 20v-6h6`}),(0,L.jsx)(`path`,{d:`M7 17a8 8 0 0 0 13-5`}),(0,L.jsx)(`path`,{d:`M17 7A8 8 0 0 0 4 12`})]})}function rZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M9 13h6M9 17h6M9 9h2`})]})}function iZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M9 9h2M9 13h6`}),(0,L.jsx)(`path`,{d:`M9 17a3 3 0 1 0 3-3`}),(0,L.jsx)(`path`,{d:`M13.75 15.5H12v-1.75`})]})}function aZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M4 12a8 8 0 0 1 13-6`}),(0,L.jsx)(`path`,{d:`M20 12a8 8 0 0 1-13 6`}),(0,L.jsx)(`path`,{d:`M17 3v5h-5`}),(0,L.jsx)(`path`,{d:`M7 21v-5h5`}),(0,L.jsx)(`path`,{d:`M9 10.5a3 3 0 0 1 6 0c0 2.2-3 2.2-3 4.5`}),(0,L.jsx)(`path`,{d:`M12 18h.01`})]})}function oZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M12 3.75a1.5 1.5 0 0 1 1.471 1.206l.167.835a6.954 6.954 0 0 1 1.309.544l.716-.46a1.5 1.5 0 0 1 1.867.195l.8.8a1.5 1.5 0 0 1 .195 1.867l-.46.716c.224.417.406.856.544 1.309l.835.167A1.5 1.5 0 0 1 20.25 12a1.5 1.5 0 0 1-1.206 1.471l-.835.167a6.954 6.954 0 0 1-.544 1.309l.46.716a1.5 1.5 0 0 1-.195 1.867l-.8.8a1.5 1.5 0 0 1-1.867.195l-.716-.46a6.954 6.954 0 0 1-1.309.544l-.167.835A1.5 1.5 0 0 1 12 20.25a1.5 1.5 0 0 1-1.471-1.206l-.167-.835a6.954 6.954 0 0 1-1.309-.544l-.716.46a1.5 1.5 0 0 1-1.867-.195l-.8-.8a1.5 1.5 0 0 1-.195-1.867l.46-.716a6.954 6.954 0 0 1-.544-1.309l-.835-.167A1.5 1.5 0 0 1 3.75 12a1.5 1.5 0 0 1 1.206-1.471l.835-.167c.138-.453.32-.892.544-1.309l-.46-.716a1.5 1.5 0 0 1 .195-1.867l.8-.8a1.5 1.5 0 0 1 1.867-.195l.716.46a6.954 6.954 0 0 1 1.309-.544l.167-.835A1.5 1.5 0 0 1 12 3.75Z`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.25`})]})}function sZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M4 12v7a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-7`}),(0,L.jsx)(`path`,{d:`M12 16V4`}),(0,L.jsx)(`path`,{d:`m7 9 5-5 5 5`})]})}function cZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M12 12V6`}),(0,L.jsx)(`path`,{d:`m9.5 9.5 2.5-2.5 2.5 2.5`}),(0,L.jsx)(`path`,{d:`M9 16h6`})]})}function lZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M3 7.5A1.5 1.5 0 0 1 4.5 6h4l1.6 2H19.5A1.5 1.5 0 0 1 21 9.5v7A1.5 1.5 0 0 1 19.5 18h-15A1.5 1.5 0 0 1 3 16.5z`}),(0,L.jsx)(`path`,{d:`M3 10h18`}),(0,L.jsx)(`path`,{d:`m13 14 2-2 2 2`}),(0,L.jsx)(`path`,{d:`M17 12v5`})]})}function uZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`rect`,{x:`3.5`,y:`6.5`,width:`13`,height:`13`,rx:`2.5`}),(0,L.jsx)(`path`,{d:`M9 6V5.5A2.5 2.5 0 0 1 11.5 3H18a2.5 2.5 0 0 1 2.5 2.5V12`}),(0,L.jsx)(`path`,{d:`m6.5 16.5 3.4-3.4a1.3 1.3 0 0 1 1.84 0l1.26 1.26`}),(0,L.jsx)(`path`,{d:`m12.5 15.5 1.4-1.4a1.3 1.3 0 0 1 1.84 0l.76.76`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`10.5`,r:`1.1`})]})}function dZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M12 5a3 3 0 0 0-3 3v1H8a3 3 0 0 0 0 6h1v1a3 3 0 0 0 6 0v-1h1a3 3 0 0 0 0-6h-1V8a3 3 0 0 0-3-3Z`}),(0,L.jsx)(`path`,{d:`M12 2v3M12 19v3M4.5 12H8M16 12h3.5`})]})}function fZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M5 12h14`}),(0,L.jsx)(`path`,{d:`m13 6 6 6-6 6`})]})}var pZ=`bilisum.promptPresetId`;function mZ(e){return e instanceof fr||e instanceof Error&&e.name===`AuthRequiredError`||e instanceof Error&&/访问密钥|unauthorized|401/i.test(e.message)}function hZ(){let e=it(),t=st(),[n,r]=(0,S.useState)(Gn),[i,a]=(0,S.useState)({version:``,backend:null,logPath:``}),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(`all`),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(!1),[v,y]=(0,S.useState)(null),[b,x]=(0,S.useState)([]),[C,w]=(0,S.useState)(0),[T,E]=(0,S.useState)(0),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(null),[j,ee]=(0,S.useState)(()=>{if(typeof window>`u`)return!1;let e=localStorage.getItem(`theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}),[M,te]=(0,S.useState)(()=>typeof window>`u`?!1:localStorage.getItem(`sidebar-collapsed`)===`true`),[ne,N]=(0,S.useState)(!1),[P,re]=(0,S.useState)(!1),[ie,ae]=(0,S.useState)(!1),[oe,F]=(0,S.useState)(()=>!!window.desktop),[se,ce]=(0,S.useState)(``),[le,ue]=(0,S.useState)(``),[de,fe]=(0,S.useState)(!1),[pe,me]=(0,S.useState)(null),[he,ge]=(0,S.useState)(!1),[_e,ve]=(0,S.useState)(!1),[ye,be]=(0,S.useState)(!1),xe=(0,S.useRef)(!1),[Se,Ce]=(0,S.useState)(()=>!Rx());(0,S.useEffect)(()=>{e.pathname===`/`&&!Rx()&&Ce(!0)},[e.pathname]);let[we,Te]=(0,S.useState)({status:`idle`,version:``,releaseDate:``,releaseNotes:null,downloadProgress:0,errorMessage:null}),Ee=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=!1;async function t(){if(window.desktop){try{await I.createAuthSession(await window.desktop.backend.getAccessToken())}catch{}e||(F(!0),ae(!0));return}try{let t=await I.getAuthStatus();e||(F(!!t.authenticated),ae(!0))}catch{e||(F(!1),ae(!0))}}return t(),()=>{e=!0}},[]),(0,S.useEffect)(()=>{let e=j?`dark`:`light`;document.documentElement.setAttribute(`data-theme`,e),localStorage.setItem(`theme`,e),window.desktop?.preferences?.setTheme?.(e)},[j]),(0,S.useEffect)(()=>{localStorage.setItem(`sidebar-collapsed`,M?`true`:`false`)},[M]),(0,S.useEffect)(()=>{let e,t,n=!1;async function r(){if(!window.desktop)return;let[r,i,o,s,c]=await Promise.all([window.desktop.app.getVersion(),window.desktop.backend.status(),window.desktop.logs.getServiceLogPath(),window.desktop.update?.getStatus?.()??Promise.resolve(null),window.desktop.app.getStartupAnnouncement?.()??Promise.resolve(null)]);n||(a({version:r,backend:i,logPath:o}),me(c),s&&Te(tr(s)),e=window.desktop.backend.onStatus(e=>a(t=>({...t,backend:e}))),t=window.desktop.update?.onStatus(e=>{Te(tr(e))}))}return r(),()=>{n=!0,e?.(),t?.()}},[]),(0,S.useEffect)(()=>{let e=!1;async function t(){if(oe)try{let[t,n,i]=await Promise.all([I.getHealth(),I.getSettings(),I.getVideoLibrary()]);e||r(e=>({...e,serviceOnline:t.status===`ok`,settings:n,videos:i.videos,folders:i.folders,libraryPreferences:i.preferences,error:``}));try{let n=await I.getSystemInfo();if(!e){let e=n.runtimeStartup?.status,i=n.environment??n.runtimeStartup?.environment??null,a=e===`initializing`||i?.runtimeReady===!1;r(e=>({...e,serviceOnline:t.status===`ok`,systemInfo:n,environment:i,error:``,runtimeInitializing:a}))}}catch{e||r(e=>({...e,serviceOnline:t.status===`ok`,error:e.error,runtimeInitializing:!0}))}}catch(t){if(!e){if(mZ(t)){F(!1),ue(``);return}r(e=>({...e,serviceOnline:!1,error:t instanceof Error?t.message:`服务暂不可用`,runtimeInitializing:!1}))}}}t();let n=window.setInterval(()=>void t(),8e3);return()=>{e=!0,window.clearInterval(n)}},[oe,C]);async function De(e){e.preventDefault();let t=se.trim();if(!t){ue(`请输入访问密钥。`);return}fe(!0),ue(``);try{F(!!(await I.createAuthSession(t)).authenticated),ce(``),w(e=>e+1)}catch(e){ue(e instanceof Error?e.message:`访问密钥无效。`)}finally{fe(!1)}}function Oe(){re(!0)}function ke(){re(!1)}async function Ae(){let e=pe;me(null),e&&await window.desktop?.app.markStartupAnnouncementSeen?.(e.version)}let je=(0,S.useMemo)(()=>nr(we),[we]);(0,S.useEffect)(()=>{je&&re(!0)},[je]);async function Me(){if(!window.desktop?.update){let e=await I.getAppUpdate();return Te(tr(e)),e}let e=await window.desktop.update.check();return Te(tr(e)),e}async function Ne(){if(!window.desktop?.update)throw Error(`当前环境不支持桌面自动更新。`);let e=await window.desktop.update.download();return Te(tr(e)),e}async function Pe(){if(!window.desktop?.update)throw Error(`当前环境不支持桌面自动更新。`);await window.desktop.update.install()}let Fe=(0,S.useMemo)(()=>[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime())[0]??null,[n.videos]),Ie=(0,S.useMemo)(()=>{let e=n.videos.filter(e=>e.is_favorite).length,t=n.videos.filter(e=>e.latest_status===`completed`).length,r=n.videos.filter(e=>e.latest_status===`running`).length,i=n.videos.filter(e=>e.has_result).length;return{total:n.videos.length,favorite:e,completed:t,running:r,withResult:i}},[n.videos]),Le=(0,S.useMemo)(()=>{let e=o.trim().toLowerCase();return[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).filter(t=>e?t.title.toLowerCase().includes(e)||t.source_url.toLowerCase().includes(e):!0).filter(e=>c===`favorite`?e.is_favorite:c===`completed`?e.latest_status===`completed`:c===`running`?e.latest_status===`running`:c===`with-result`?e.has_result:!0)},[c,o,n.videos]),Re=(0,S.useMemo)(()=>[...n.videos].filter(e=>e.is_favorite).sort((e,t)=>{let n=new Date(e.favorite_updated_at||e.updated_at).getTime();return new Date(t.favorite_updated_at||t.updated_at).getTime()-n}),[n.videos]),ze=(0,S.useMemo)(()=>[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,6),[n.videos]);async function Be(e,t){let i=n.videos,a=t?new Date().toISOString():null;r(n=>({...n,videos:n.videos.map(n=>n.video_id===e?{...n,is_favorite:t,favorite_updated_at:a}:n)}));try{let n=await I.setVideoFavorite(e,{is_favorite:t});r(t=>({...t,videos:t.videos.map(t=>t.video_id===e?{...t,...n}:t)}))}catch(e){throw r(e=>({...e,videos:i})),e}}let Ve=(0,S.useMemo)(()=>Qn({transcriptionProvider:n.settings?.transcription_provider,whisperDevice:n.settings?.whisper_device,cudaAvailable:n.environment?.cudaAvailable,hasSettings:!!n.settings}),[n.environment?.cudaAvailable,n.settings]),He=(0,S.useMemo)(()=>$n(n.settings,n.environment),[n.environment,n.settings]),Ue=i.version||n.systemInfo?.application?.version||`-`,We=n.systemInfo?.runtimeStartup?.status,Ge=We===`ready`||!!n.environment&&n.environment?.runtimeReady!==!1&&!n.runtimeInitializing,Ke=(0,S.useMemo)(()=>n.runtimeInitializing?`运行环境准备中`:We===`error`?`运行环境异常`:n.environment?.runtimeReady===!1?`运行环境未就绪`:n.environment?`运行环境就绪`:n.serviceOnline?`检测中`:`等待服务`,[We,n.environment,n.runtimeInitializing,n.serviceOnline]);(0,S.useEffect)(()=>{if(!er(He,n.settings)){xe.current||ge(!1),be(!1);return}xe.current=!1,ye||ge(!0)},[He,ye,n.settings]);function qe(e){xe.current=!1,ge(!1),be(!0),O({issueKey:e,nonce:Date.now()}),t(`/settings`)}function Je(e){xe.current=!1,ge(!1),A({presetId:e,nonce:Date.now()}),t(`/settings`)}async function Ye(e){let t=await I.updateSettings({prompt_router_mode:e});r(e=>({...e,settings:t.settings,systemInfo:e.systemInfo?{...e.systemInfo,settings:t.settings}:e.systemInfo}))}function Xe(e){r(t=>{let n=new Map(e.map(e=>[e.video_id,e]));return{...t,videos:t.videos.map(e=>n.get(e.video_id)||e)}})}async function Ze(){let e=await I.getVideoLibrary();return r(t=>({...t,videos:e.videos,folders:e.folders,libraryPreferences:e.preferences})),e}async function Qe(e,t){let n=await I.createVideoFolder({name:e,parent_id:t??null});return r(e=>({...e,folders:[n,...e.folders]})),n}async function $e(e,t){let n=await I.updateVideoFolder(e,t);return r(t=>({...t,folders:t.folders.map(t=>t.folder_id===e?n:t)})),n}async function et(e){await I.deleteVideoFolder(e),await Ze()}async function tt(e,t,n){let r=await I.moveVideoToFolder(e,n?{folder_ids:n}:{folder_id:t??null});return Xe([r]),r}async function nt(e){let t=n.videos;r(t=>({...t,videos:t.videos.filter(t=>t.video_id!==e)}));try{await I.deleteVideo(e)}catch(e){throw r(e=>({...e,videos:t})),e}}async function rt(e,t){let n=await I.setVideoPin(e,t);return Xe([n]),n}async function at(e,t){Xe(await I.reorderVideos({video_ids:e,folder_id:t??null}))}async function ot(e){let t=await I.updateVideoLibraryPreferences({new_video_position:e});r(e=>({...e,libraryPreferences:t}))}function ct(e){if(e){qe(e);return}if(er(He,n.settings)){be(!1),ge(!0);return}t(`/settings`)}function lt(){xe.current=!1,ge(!1),be(!0)}function ut(){xe.current=!1,ge(!1);let e=He.blockingIssues[0]?.key||He.issues[0]?.key;if(e){qe(e);return}t(`/settings`)}function dt(e){return/HTTP\s*412|cookies?\.txt|B\s*站返回|Bilibili rejected|风控拦截|登录态|cookiesfrombrowser|DPAPI/i.test(e)}function ft(e){p(e||`B 站请求被拦截,请导出登录态 cookies 后重试。`),ve(!0)}function pt(){window.open(`https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp`,`_blank`,`noopener,noreferrer`)}function mt(){ve(!1),O({issueKey:`ytdlp_cookies_file`,nonce:Date.now()}),t(`/settings`)}async function ht(){try{let e=u.trim();if(!window.desktop?.bilibili){p(`当前环境不支持打开 B 站登录窗口,请按教程手动导出 cookies.txt。`);return}p(`请在新窗口登录 B 站,登录成功后会自动保存 cookies...`);let t=await window.desktop.bilibili.captureLoginCookies(),n=await I.updateSettings({ytdlp_cookies_file:t.cookiesFile,ytdlp_cookies_browser:``});r(e=>({...e,settings:n.settings,systemInfo:e.systemInfo?{...e.systemInfo,settings:n.settings}:e.systemInfo})),e?(await I.probeVideo({url:e,force_refresh:!0}),p(`B 站登录态已保存,捕获 ${t.cookieCount} 条 cookies。可以重新提交任务。`)):p(`B 站登录态已保存,捕获 ${t.cookieCount} 条 cookies。重新提交任务即可。`),ve(!1)}catch(e){p(e instanceof Error?e.message:`捕获 B 站登录态失败,请按教程手动导出 cookies.txt。`),ve(!0)}}function gt(){try{let e=window.localStorage.getItem(`bilisum.summaryPreference`);return e?JSON.parse(e).noteMode===`visual`?`frame_insert`:`text`:null}catch{return null}}function _t(){try{let e=window.localStorage.getItem(pZ)?.trim();return e&&e!==`general`?e:null}catch{return null}}async function vt(e){if((n.settings?.prompt_router_mode||`confirm`)!==`auto`)return _t();let t=e?.trim();if(!t)return null;try{let e=await I.matchPrompt(t);return e.preset.id&&e.preset.id!==`general`?e.preset.id:null}catch{return null}}async function yt(e,t){return{page_number:e??null,visual_note_mode:gt(),prompt_preset_id:await vt(t)}}async function bt(e,t){try{p(`正在匹配摘要 Prompt 并创建任务...`),await I.createVideoTask(e.video_id,await yt(null,t||e.title||e.source_url)),p(`视频已加入本地库并开始总结`),w(e=>e+1),E(e=>e+1)}catch(e){let t=e instanceof Error?e.message:`创建摘要任务失败`;if(dt(t)){ft(t);return}p(t)}}async function xt(e){if(e.preventDefault(),!u.trim()){p(`请输入 Bilibili / YouTube 视频链接,或直接输入 BV 号`);return}if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}p(`正在抓取视频信息并准备开始总结...`);try{let e=await I.probeVideo({url:u.trim(),force_refresh:!1});if(h(e.video),e.requires_selection&&e.pages.length>0){y(e.video),x(e.pages.map(e=>({...e,aggregate_status:`not_started`,has_completed_result:!1}))),_(!0),p(`检测到 ${e.pages.length} 个分 P,请先勾选要处理的内容`);return}p(e.cached?`已从视频库读取,正在进入详情页...`:`视频已加入本地库,正在进入详情页...`);let n=u.trim();d(``),w(e=>e+1),t(`/videos/${e.video.video_id}`),bt(e.video,e.video.title||n)}catch(e){let t=e instanceof Error?e.message:`开始总结失败`;if(dt(t)){ft(t);return}p(t)}}async function St(e){if(e.length){p(e.length>1?`正在读取 ${e.length} 个本地媒体文件并创建任务...`:`正在读取本地媒体信息并准备开始总结...`);try{let n=[];for(let t of e){let e=await I.probeVideo({url:t,force_refresh:!1});n.push(e)}let r=n[0];if(!r)throw Error(`未返回本地媒体信息。`);h(r.video),d(``),p(n.length>1?`已读取 ${n.length} 个本地媒体文件,正在后台创建摘要任务...`:r.cached?`已从本地媒体库读取,正在进入详情页...`:`本地媒体已加入视频库,正在进入详情页...`),w(e=>e+1),t(`/videos/${r.video.video_id}`),Promise.all(n.map(e=>bt(e.video,e.video.title||e.video.source_url)))}catch(e){let t=e instanceof Error?e.message:`导入本地媒体失败`;if(dt(t)){ft(t);return}p(t)}}}async function Ct(){if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}if(window.desktop?.media){await St(window.desktop.media.pickVideoFiles?await window.desktop.media.pickVideoFiles():[await window.desktop.media.pickVideoFile()].filter(e=>!!e));return}Ee.current?.click()}async function wt(e){let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&await Tt(t)}async function Tt(e){if(e.length){if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}p(e.length>1?`正在上传 ${e.length} 个本地媒体文件并创建任务...`:`正在上传本地媒体并准备开始总结...`);try{let n=e.length>1?await I.uploadBatchVideos(e):[await I.uploadLocalVideo(e[0])],r=n[0];if(!r)throw Error(`未返回上传结果。`);h(r.video),d(``),p(n.length>1?`已上传 ${n.length} 个本地媒体文件,正在后台创建摘要任务...`:r.cached?`已从本地媒体库读取,正在进入详情页...`:`本地媒体已加入视频库,正在进入详情页...`),w(e=>e+1),t(`/videos/${r.video.video_id}`),Promise.all(n.map(e=>bt(e.video,e.video.title||e.video.source_url)))}catch(e){let t=e instanceof Error?e.message:`导入本地媒体失败`;if(dt(t)){ft(t);return}p(t)}}}async function Et(e){if(!v)throw Error(`当前视频信息已失效,请重新探测。`);let n=v;p(e.confirm?`正在确认批量任务...`:`正在进入详情页并准备批量任务...`),h(n),d(``),w(e=>e+1),t(`/videos/${n.video_id}`);let r=await vt(n.title||n.source_url),i=await I.createVideoTasksBatch(n.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm,prompt_preset_id:r});if(i.requires_confirmation)return p(`所选内容中有 ${i.conflict_pages.length} 个分 P 已有成功摘要,请确认后继续。`),i;_(!1),y(null),x([]);let a=i.created_tasks.length,o=i.skipped_pages.length;return p(a>0?`已创建 ${a} 个批量任务${o?`,跳过 ${o} 个已完成分 P`:``}`:`没有创建新任务${o?`,已跳过 ${o} 个分 P`:``}`),w(e=>e+1),E(e=>e+1),i}function Dt(){_(!1),y(null),x([])}e.pathname.startsWith(`/settings`)||e.pathname.startsWith(`/library`)||e.pathname.startsWith(`/videos/`);let Ot=e.pathname.startsWith(`/settings`);e.pathname.startsWith(`/library`);let kt=!!window.desktop?.update&&!rr(we),At=!!window.desktop?.media||typeof window<`u`;if(!window.desktop&&ie&&!oe)return(0,L.jsx)(_Z,{token:se,error:le,submitting:de,onTokenChange:ce,onSubmit:De});if(!window.desktop&&!ie)return(0,L.jsx)(`div`,{className:`auth-shell`,children:(0,L.jsxs)(`section`,{className:`auth-panel`,children:[(0,L.jsxs)(`div`,{className:`auth-brand`,children:[(0,L.jsx)(`img`,{src:`/static/assets/icons/icon.svg`,alt:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`BiliSum`}),(0,L.jsx)(`h1`,{children:`正在检查访问权限`})]})]}),(0,L.jsx)(`p`,{className:`auth-muted`,children:`请稍候。`})]})});let jt=typeof window<`u`&&window.desktop?.window?.platform===`darwin`;return(0,L.jsxs)(`div`,{className:`app-shell ${M?`sidebar-collapsed`:``} ${ne?`mobile-sidebar-open`:``} ${jt?`is-macos`:``}`,children:[(0,L.jsx)(`input`,{ref:Ee,type:`file`,multiple:!0,accept:`video/mp4,video/quicktime,video/x-matroska,video/x-msvideo,video/x-ms-wmv,video/webm,video/x-flv,video/mp2t,video/mpeg,audio/mpeg,audio/wav,audio/x-wav,audio/mp4,audio/aac,audio/flac,audio/ogg,.mp4,.mov,.mkv,.avi,.wmv,.webm,.flv,.m4v,.ts,.mpeg,.mpg,.mp3,.wav,.m4a,.aac,.flac,.ogg`,style:{display:`none`},onChange:e=>void wt(e)}),(0,L.jsx)(jx,{darkMode:j,onToggleTheme:()=>ee(e=>!e),serviceOnline:n.serviceOnline,backendRunning:i.backend?.running,runtimeDeviceLabel:Ve,runtimeReady:Ge,runtimeStatusText:Ke,version:Ue,updateState:we,configHealth:He,onOpenSettings:ct,onOpenUpdateDialog:Oe}),(0,L.jsxs)(`aside`,{className:`sidebar`,children:[(0,L.jsxs)(`nav`,{className:`nav`,children:[(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/`?`active`:``}`,to:`/`,"aria-label":`首页`,title:`首页`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(jr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`首页`}),(0,L.jsx)(`small`,{children:`工作台总览`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/library`?`active`:``}`,to:`/library`,"aria-label":`视频库`,title:`视频库`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Dr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`视频库`}),(0,L.jsx)(`small`,{children:`资产管理`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/knowledge`?`active`:``}`,to:`/knowledge`,"aria-label":`知识库`,title:`知识库`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(kr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`知识库`}),(0,L.jsx)(`small`,{children:`检索与问答`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname.startsWith(`/settings`)?`active`:``}`,to:`/settings`,"aria-label":`设置`,title:`设置`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Ar,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`设置`}),(0,L.jsx)(`small`,{children:`运行配置`})]})]})]}),(0,L.jsx)(`div`,{className:`nav-section-divider`}),(0,L.jsx)(`button`,{className:`sidebar-corner-toggle`,type:`button`,onClick:()=>te(e=>!e),"aria-label":M?`展开侧边栏`:`收起侧边栏`,"aria-pressed":M,title:M?`展开侧边栏`:`收起侧边栏`,children:(0,L.jsx)(gZ,{collapsed:M})})]}),(0,L.jsx)(`button`,{className:`mobile-menu-toggle`,type:`button`,onClick:()=>N(!0),"aria-label":`打开菜单`,title:`打开菜单`,children:(0,L.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,L.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,L.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]})}),ne&&(0,L.jsx)(`div`,{className:`mobile-sidebar-overlay`,onClick:()=>N(!1),onKeyDown:e=>{e.key===`Escape`&&N(!1)},role:`button`,tabIndex:0,"aria-label":`关闭菜单`}),(0,L.jsx)(`main`,{className:`content`,children:(0,L.jsx)(`div`,{className:`content-frame ${Ot?`content-frame-settings`:``}`,children:n.error&&!n.serviceOnline?(0,L.jsxs)(`section`,{className:`grid-card empty-state-card`,children:[(0,L.jsx)(`div`,{className:`spinner`}),(0,L.jsx)(`h3`,{children:`后端暂未就绪`}),(0,L.jsx)(`p`,{children:n.error}),(0,L.jsxs)(`div`,{className:`desktop-actions`,children:[(0,L.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:async()=>{await window.desktop?.backend.start(),w(e=>e+1)},children:`重新拉起后端`}),(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:()=>w(e=>e+1),children:`重新检测`})]})]}):(0,L.jsxs)(Ft,{children:[(0,L.jsx)(Nt,{path:`/`,element:(0,L.jsx)(nS,{configHealth:He,probePreview:m,probeUrl:u,setProbeUrl:d,submitStatus:f,onProbe:xt,onImportLocalVideo:Ct,onImportLocalFiles:Tt,onImportLocalPaths:St,canImportLocalVideo:At,promptRouterMode:n.settings?.prompt_router_mode||`confirm`,onPromptRouterModeChange:Ye,onOpenSetupAssistant:ct,onOpenConfigIssue:qe,onEditPromptPreset:Je,favoriteVideos:Re,recentVideos:ze,onToggleFavorite:Be})}),(0,L.jsx)(Nt,{path:`/library`,element:(0,L.jsx)(eq,{snapshot:n,filteredVideos:Le,libraryCounts:Ie,latestVideo:Fe,query:o,setQuery:s,activeFilter:c,setLibraryFilter:l,serviceOnline:n.serviceOnline,runtimeDeviceLabel:Ve,onToggleFavorite:Be,onCreateFolder:Qe,onUpdateFolder:$e,onDeleteFolder:et,onDeleteVideo:nt,onMoveVideo:tt,onSetVideoPin:rt,onReorderVideos:at,onUpdateLibraryPreferences:ot})}),(0,L.jsx)(Nt,{path:`/knowledge`,element:(0,L.jsx)(VP,{})}),(0,L.jsx)(Nt,{path:`/videos/:videoId`,element:(0,L.jsx)(MX,{refreshToken:T,onRefresh:()=>w(e=>e+1),onOpenCookieSettings:mt,onOpenCookieTutorial:pt,onCaptureLoginCookies:ht})}),(0,L.jsx)(Nt,{path:`/settings`,element:(0,L.jsx)(sJ,{desktop:i,onOpenUpdateDialog:Oe,onCheckUpdate:Me,onDownloadUpdate:Ne,onInstallUpdate:Pe,onOpenSetupAssistant:()=>{xe.current=!0,be(!1),ge(!0),t(`/`)},onRefresh:()=>w(e=>e+1),onSettingsSaved:(e,t)=>{r(n=>({...n,settings:e,environment:t??n.environment,systemInfo:n.systemInfo?{...n.systemInfo,settings:e,environment:t??n.systemInfo.environment}:n.systemInfo}))},snapshot:n,focusIssueRequest:D,promptPresetRequest:k,updateInfo:we,canCheckUpdate:!0,canInstallUpdate:kt})})]})})}),(0,L.jsx)(Mx,{isOpen:P,updateInfo:we,currentVersion:Ue,canInstallUpdate:kt,onClose:ke,onCheck:Me,onDownload:Ne,onInstall:Pe}),(0,L.jsx)(Ax,{announcement:pe,onClose:()=>void Ae()}),(0,L.jsx)(gi,{isOpen:g,mode:`create`,video:v,pages:b,onClose:Dt,onSubmit:Et}),(0,L.jsx)(_i,{isOpen:he,force:xe.current,configHealth:He,onClose:lt,onOpenSettings:ut,onNavigateToIssue:qe}),(0,L.jsx)(Hr,{isOpen:_e,onClose:()=>ve(!1),onOpenTutorial:pt,onOpenSettings:mt,onCaptureLoginCookies:ht}),Se&&e.pathname===`/`&&!He.hasBlockingIssues?(0,L.jsx)(Lx,{onClose:()=>Ce(!1)}):null]})}function gZ({collapsed:e}){return(0,L.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`rect`,{x:`3.5`,y:`4.5`,width:`17`,height:`15`,rx:`2.5`}),(0,L.jsx)(`path`,{d:`M9 4.5v15`}),e?(0,L.jsx)(`path`,{d:`m13.5 12 3-3m-3 3 3 3`}):(0,L.jsx)(`path`,{d:`m15.5 12-3-3m3 3-3 3`})]})}function _Z({token:e,error:t,submitting:n,onTokenChange:r,onSubmit:i}){return(0,L.jsx)(`div`,{className:`auth-shell`,children:(0,L.jsxs)(`section`,{className:`auth-panel`,children:[(0,L.jsxs)(`div`,{className:`auth-brand`,children:[(0,L.jsx)(`img`,{src:`/static/assets/icons/icon.svg`,alt:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`BiliSum`}),(0,L.jsx)(`h1`,{children:`输入访问密钥`})]})]}),(0,L.jsxs)(`p`,{className:`auth-muted`,children:[`Web 端访问需要 BiliSum 服务密钥。桌面端会自动注入密钥;Docker 或 npx 部署可通过`,` `,(0,L.jsx)(`code`,{children:`VIDEO_SUM_ACCESS_TOKEN`}),` `,`配置。`]}),(0,L.jsxs)(`form`,{className:`auth-form`,onSubmit:i,children:[(0,L.jsx)(`label`,{htmlFor:`access-token`,children:`访问密钥`}),(0,L.jsx)(`input`,{id:`access-token`,type:`password`,value:e,autoComplete:`current-password`,autoFocus:!0,onChange:e=>r(e.target.value)}),t?(0,L.jsx)(`p`,{className:`auth-error`,children:t}):null,(0,L.jsx)(`button`,{type:`submit`,disabled:n,children:n?`正在验证...`:`进入 BiliSum`})]})]})})}Wn.createRoot(document.getElementById(`root`)).render((0,L.jsx)(S.StrictMode,{children:(0,L.jsx)(Cn,{children:(0,L.jsx)(hZ,{})})}));
357
+ `).trim()}function qY(e){return!e||e.status!==`completed`||!e.result?!1:!!KY(e.result).trim()}function JY(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}function YY(e){return typeof e==`number`?JY(e):``}function XY(e){return e?.result?null:e?e.status===`running`||e.status===`queued`?{tone:`pending`,title:`当前任务还在处理中`,description:`可以先查看顶部任务药丸中的实时进度,结果生成后这里会自动可用。`}:e.status===`failed`||e.status===`cancelled`?{tone:`failed`,title:`当前任务未生成可用结果`,description:`可以切换到其他已完成任务,或重新发起摘要生成。`,detail:IY(e.error_message)||void 0}:{tone:`empty`,title:`当前任务还没有结果`,description:`请选择其他已完成任务,或者重新生成摘要。`}:{tone:`empty`,title:`还没有可展示的任务内容`,description:`开始处理后,这里会整理出摘要结果和知识卡片。`}}function ZY(e,t){return t?.status===`ready`&&t.mindmap?null:e?t?.status===`generating`||e.result?.mindmap_status===`generating`?{tone:`pending`,title:`思维导图正在生成`,description:`系统正在基于当前任务的摘要结果组织主题树,稍后会自动显示在这里。`,actionLabel:`生成中`,actionEnabled:!1}:t?.status===`failed`||e.result?.mindmap_status===`failed`?{tone:`failed`,title:`思维导图生成失败`,description:IY(t?.error_message||e.result?.mindmap_error_message||e.error_message)||`这次处理没有成功生成可展示的导图。`,actionLabel:`重新生成导图`,actionEnabled:!0}:e.status===`running`||e.status===`queued`?{tone:`pending`,title:`任务完成后才能生成导图`,description:`当前任务仍在处理中。等摘要和知识笔记准备好后,就可以按需生成思维导图。`,actionLabel:`处理中`,actionEnabled:!1}:e.status===`failed`||e.status===`cancelled`?{tone:`failed`,title:`当前任务暂时无法生成导图`,description:IY(e.error_message)||`这次处理没有产出可用于导图组织的结果。`,actionLabel:`等待可用结果`,actionEnabled:!1}:{tone:`accent`,title:`当前任务已可生成思维导图`,description:`导图会按主题重组知识卡片、章节结构和知识笔记,并在叶子节点保留可回看时间点。`,actionLabel:`生成思维导图`,actionEnabled:!0}:{tone:`default`,title:`当前还没有可生成导图的任务`,description:`请选择一个已完成任务。导图会基于当前任务的知识卡片和知识笔记按需生成。`,actionLabel:`等待可用任务`,actionEnabled:!1}}function QY(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.toLowerCase();if(!n.includes(`bilibili.com`)&&!n.includes(`b23.tv`))return null;let r=t.pathname.match(/\/video\/(BV[0-9A-Za-z]+)/i)?.[1]??null,i=t.pathname.match(/\/video\/av(\d+)/i)?.[1]??null,a=t.searchParams.get(`bvid`)??r,o=t.searchParams.get(`aid`)??i,s=t.searchParams.get(`p`)??`1`;if(!a&&!o)return null;let c=new URL(`https://player.bilibili.com/player.html`);return c.searchParams.set(`isOutside`,`true`),c.searchParams.set(`autoplay`,`0`),c.searchParams.set(`p`,s),a&&c.searchParams.set(`bvid`,a),o&&c.searchParams.set(`aid`,o),c.toString()}catch{return null}}function $Y(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.toLowerCase(),r=null;if(n.endsWith(`youtu.be`)?r=t.pathname.split(`/`).filter(Boolean)[0]??null:n.includes(`youtube.com`)&&(r=t.pathname===`/watch`?t.searchParams.get(`v`):t.pathname.match(/^\/shorts\/([^/?#]+)/i)?.[1]??null),!r)return null;let i=new URL(`https://www.youtube.com/embed/${r}`);return i.searchParams.set(`autoplay`,`0`),i.searchParams.set(`rel`,`0`),i.toString()}catch{return null}}function eX(e,t,n,r){let i=new URL(e);if(n!=null&&Number.isFinite(n)&&n>=0){let e=String(Math.floor(n));t===`youtube`?i.searchParams.set(`start`,e):i.searchParams.set(`t`,e)}else t===`youtube`?i.searchParams.delete(`start`):i.searchParams.delete(`t`);return i.searchParams.set(`_ts`,String(r)),i.toString()}function tX(e){let t=QY(e);if(t&&e)return{platform:`bilibili`,embedUrl:t,sourceUrl:e,openLabel:`在 Bilibili 打开`};let n=$Y(e);return n&&e?{platform:`youtube`,embedUrl:n,sourceUrl:e,openLabel:`在 YouTube 打开`}:null}var nX={stroke:`#4c9fdd`,surface:`rgba(76, 159, 221, 0.18)`,ink:`#104f7d`,shadow:`rgba(76, 159, 221, 0.24)`},rX=[{stroke:`#f2b84b`,surface:`rgba(242, 184, 75, 0.18)`,ink:`#805018`,shadow:`rgba(242, 184, 75, 0.24)`},{stroke:`#ff8c69`,surface:`rgba(255, 140, 105, 0.16)`,ink:`#91412a`,shadow:`rgba(255, 140, 105, 0.24)`},{stroke:`#8cc8ff`,surface:`rgba(140, 200, 255, 0.18)`,ink:`#285c86`,shadow:`rgba(140, 200, 255, 0.24)`},{stroke:`#f5a64a`,surface:`rgba(245, 166, 74, 0.16)`,ink:`#8a4a00`,shadow:`rgba(245, 166, 74, 0.22)`},{stroke:`#9dd8b3`,surface:`rgba(157, 216, 179, 0.18)`,ink:`#1f6a47`,shadow:`rgba(157, 216, 179, 0.22)`},{stroke:`#f7a8c2`,surface:`rgba(247, 168, 194, 0.16)`,ink:`#8e4563`,shadow:`rgba(247, 168, 194, 0.22)`}],iX=16/9,aX=220,oX=360,sX=20,cX=92,lX=62,uX=new Set([`.mp4`,`.mov`,`.mkv`,`.avi`,`.wmv`,`.webm`,`.flv`,`.m4v`,`.ts`,`.mpeg`,`.mpg`]),dX=`bilisum.summaryPreference`,fX=[{id:`knowledge`,label:`知识卡片`,description:`按概览、要点、章节整理当前任务结果。`},{id:`summary`,label:`知识笔记`,description:`查看当前任务的完整笔记、重点展开和转写全文。`},{id:`mindmap`,label:`思维导图`,description:`预留按主题组织的知识结构视图入口。`}];function pX(e,t){let n=new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime();return n===0?new Date(t.created_at).getTime()-new Date(e.created_at).getTime():n}function mX(e){return e.status===`completed`}function hX(e){return e?[{label:`创建时间`,value:Wr(e.created_at)},{label:`更新时间`,value:Wr(e.updated_at)},{label:`LLM Token`,value:qr(e.llm_total_tokens)},{label:`任务耗时`,value:Kr(e.task_duration_seconds)}]:[]}function gX(e){return dr(e.stage)===`error`||/失败|不可用|错误|异常/i.test(e.message)}function _X(e){return dr(e.stage)===`completed`||e.progress>=100||/完成|已写入|检查通过|已就绪/.test(e.message)}function vX(e){let t=e.message||``;return e.stage.startsWith(`mindmap_`)||/思维导图|导图/.test(t)?`mindmap`:/知识库|索引/.test(t)?`knowledge`:/导出|写入本地|结果整理|结果文件/.test(t)?`export`:e.stage===`downloading`||e.stage===`transcribing`||/音频|转写|字幕/.test(t)?`media`:e.stage===`summarizing`||/LLM|摘要|总结|知识卡片|知识笔记|内容块|分块|合并/.test(t)?`summary`:e.stage===`queued`||/队列|开始执行|检查|规范化|读取视频|视频信息/.test(t)?`prepare`:`other`}var yX={prepare:`准备阶段`,media:`音频与转写`,summary:`摘要生成`,export:`结果导出`,mindmap:`思维导图`,knowledge:`知识库索引`,other:`其他记录`},bX=[`prepare`,`media`,`summary`,`export`,`mindmap`,`knowledge`,`other`];function xX(e){let t=new Map;for(let n of e){let e=vX(n);t.set(e,[...t.get(e)??[],n])}let n=e.at(-1);return bX.map(e=>{let r=t.get(e)??[];if(!r.length)return null;let i=r.some(gX),a=!!(n&&r.some(e=>e.event_id===n.event_id)),o=r.every(_X);return{id:e,label:yX[e],events:r,tone:i?`failed`:a&&!o?`active`:o?`done`:`pending`}}).filter(e=>!!e)}function SX(e,t){let n=Math.max(aX,t-sX*2);return Math.min(Math.max(e,aX),n)}function CX(e,t,n){let r=SX(e.width,t),i=r/iX+lX,a=Math.max(sX,t-r-sX),o=Math.max(cX,n-i-sX);return{width:r,x:Math.min(Math.max(e.x,sX),a),y:Math.min(Math.max(e.y,cX),o)}}function wX(e,t){let n=SX(oX,e),r=n/iX+lX;return{width:n,x:Math.max(sX,e-n-28),y:Math.max(cX,t-r-28)}}function TX(e,t){if(!(t in e))return e;let n={...e};return delete n[t],n}function EX(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function DX(){if(typeof window>`u`)return`text`;try{let e=window.localStorage.getItem(dX);return e&&JSON.parse(e).noteMode===`visual`?`visual`:`text`}catch{return`text`}}function OX(e){if(!(typeof window>`u`))try{let t=window.localStorage.getItem(dX),n=t?JSON.parse(t):{};window.localStorage.setItem(dX,JSON.stringify({...n,noteMode:e}))}catch{window.localStorage.setItem(dX,JSON.stringify({noteMode:e}))}}async function kX(e){let[t,n]=await Promise.all([I.getTaskResult(e),I.getTaskEvents(e)]);return{detail:t,events:n}}function AX(e){return(0,L.jsx)(`svg`,{fill:`currentColor`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`M12 18.26 4.95 22l1.35-7.84L.6 8.71l7.87-1.14L12 0.5l3.53 7.07 7.87 1.14-5.7 5.45L19.05 22z`})})}function jX(e){return/HTTP\s*412|cookies?\.txt|B\s*站返回|Bilibili rejected|风控拦截|登录态|cookiesfrombrowser|DPAPI/i.test(e)}function MX({refreshToken:e=0,onRefresh:t,onOpenCookieSettings:n,onOpenCookieTutorial:r,onCaptureLoginCookies:i}){let{videoId:a=``}=lt(),o=st(),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)({}),[p,m]=(0,S.useState)({}),[h,g]=(0,S.useState)({}),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(`knowledge`),[x,C]=(0,S.useState)(`collapsed`),[w,T]=(0,S.useState)(!1),[E,D]=(0,S.useState)(null),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(``),[ee,M]=(0,S.useState)(!1),[te,ne]=(0,S.useState)({}),[N,P]=(0,S.useState)({}),[re,ie]=(0,S.useState)({}),[ae,oe]=(0,S.useState)({}),[F,se]=(0,S.useState)(()=>DX()),[ce,le]=(0,S.useState)(!1),[ue,de]=(0,S.useState)(!1),[fe,pe]=(0,S.useState)(!1),[me,he]=(0,S.useState)(!1),[ge,_e]=(0,S.useState)(!1),[ve,ye]=(0,S.useState)(!1),[be,xe]=(0,S.useState)(``),[Se,Ce]=(0,S.useState)(null),[we,Te]=(0,S.useState)([]),[Ee,De]=(0,S.useState)(null),[Oe,ke]=(0,S.useState)(null),[Ae,je]=(0,S.useState)(!1),[Me,Ne]=(0,S.useState)(`create`),[Pe,Fe]=(0,S.useState)({nonce:0,seconds:null}),[Ie,Le]=(0,S.useState)(null),Re=(0,S.useRef)(null),ze=(0,S.useRef)(null),Be=(0,S.useRef)(null),Ve=(0,S.useRef)(null),He=(0,S.useRef)(null),Ue=(0,S.useRef)(null),We=(0,S.useRef)(null),Ge=(0,S.useRef)(null),Ke=(0,S.useRef)(null),qe=(0,S.useRef)(null),Je=(0,S.useRef)(null),Ye=(0,S.useRef)(``),Xe=(0,S.useRef)(a),Ze=(0,S.useRef)(null),Qe=(0,S.useRef)(e),$e=(0,S.useRef)(0),et=(0,S.useRef)(new Map),tt=(0,S.useRef)(new Map),nt=(0,S.useRef)(new Map);(0,S.useEffect)(()=>{Xe.current=a},[a]),(0,S.useEffect)(()=>{Fe({nonce:0,seconds:null})},[a]),(0,S.useEffect)(()=>{Ze.current=_},[_]),(0,S.useEffect)(()=>{let e=!1;return I.getSettings().then(t=>{e||xe(String(t.output_dir||``).trim())}).catch(()=>void 0),()=>{e=!0}},[]);async function rt(e,t={}){let{force:n=!1}=t,r=Xe.current;if(!n){let t=et.current.get(e);if(t)return f(n=>n[e]?n:{...n,[e]:t}),m(t=>TX(t,e)),t;let n=tt.current.get(e);if(n)return n}let i=(nt.current.get(e)??0)+1;nt.current.set(e,i),g(t=>t[e]?t:{...t,[e]:!0}),m(t=>TX(t,e));let a=kX(e).then(t=>nt.current.get(e)===i?(et.current.set(e,t),Xe.current===r&&f(n=>({...n,[e]:t})),t):et.current.get(e)??t).catch(t=>{if(nt.current.get(e)===i&&Xe.current===r){let n=t instanceof Error?t.message:`任务详情加载失败`;m(t=>({...t,[e]:n}))}throw t}).finally(()=>{tt.current.get(e)===a&&tt.current.delete(e),nt.current.get(e)===i&&Xe.current===r&&g(t=>TX(t,e))});return tt.current.set(e,a),a}async function it(e,t={}){if(!t.force&&te[e])return te[e];P(t=>({...t,[e]:!0}));try{let t=await I.getTaskMindMap(e);return ne(n=>({...n,[e]:t})),t}catch(t){let n={task_id:e,status:`failed`,error_message:t instanceof Error?t.message:`思维导图加载失败`,updated_at:null,mindmap:null};throw ne(t=>({...t,[e]:n})),t}finally{P(t=>TX(t,e))}}async function at(e,t={}){P(t=>({...t,[e]:!0}));try{let n=await I.generateTaskMindMap(e,{force:t.force});return ne(t=>({...t,[e]:n})),n}catch(t){let n={task_id:e,status:`failed`,error_message:t instanceof Error?t.message:`思维导图生成失败`,updated_at:null,mindmap:null};throw ne(t=>({...t,[e]:n})),t}finally{P(t=>TX(t,e))}}async function ot(e,t={}){if(!t.force&&re[e])return re[e];oe(t=>({...t,[e]:!0}));try{let t=await I.getTaskVisualEvidence(e);return ie(n=>({...n,[e]:t})),t}catch(t){let n={task_id:e,mode:`text`,status:`failed`,error_message:t instanceof Error?t.message:`图文笔记加载失败`,updated_at:null,frame_count:0,insert_count:0,visual_note_markdown:``,enhanced_note_markdown:``,context:null};throw ie(t=>({...t,[e]:n})),t}finally{oe(t=>TX(t,e))}}async function ct(e,t={}){oe(t=>({...t,[e]:!0}));try{let n=await I.generateTaskVisualEvidence(e,{force:t.force,mode:t.mode});return ie(t=>({...t,[e]:n})),n}catch(t){let n={task_id:e,mode:`frame_insert`,status:`failed`,error_message:t instanceof Error?t.message:`图文笔记生成失败`,updated_at:null,frame_count:0,insert_count:0,visual_note_markdown:``,enhanced_note_markdown:``,context:null};throw ie(t=>({...t,[e]:n})),t}finally{oe(t=>TX(t,e))}}async function ut(e={}){let{forceTaskIds:n=[],preferredTaskId:r,syncLibrary:i=!1}=e,o=++$e.current,s=a;try{let[e,a]=await Promise.all([I.getVideo(s),I.getVideoTasks(s)]);if(Xe.current!==s||$e.current!==o)return;let l=[...a].sort(pX),d=LY(l,r===void 0?Ze.current:r),p=l[0]?.task_id??null,h=[...new Set([d,p].filter(Boolean))],_=new Set(n),y=new Map;if(await Promise.all(h.map(async e=>{y.set(e,await rt(e,{force:_.has(e)}))})),Xe.current!==s||$e.current!==o)return;let b=new Set(l.map(e=>e.task_id));Ze.current=d,c(e),u(a),v(d),f(e=>{let t={};for(let n of l){let r=n.task_id,i=y.get(r)??e[r];i&&(t[r]=i)}return t}),m(e=>Object.fromEntries(Object.entries(e).filter(([e])=>b.has(e)))),g(e=>Object.fromEntries(Object.entries(e).filter(([e])=>b.has(e)))),i&&t()}catch(e){throw Xe.current===s&&$e.current===o&&j(e instanceof Error?e.message:`视频详情加载失败`),e}}function dt(e){Ze.current=e,v(e),rt(e).catch(()=>void 0)}(0,S.useEffect)(()=>{$e.current+=1,Xe.current=a,Ze.current=null,c(null),u([]),f({}),m({}),g({}),v(null),b(`knowledge`),C(`collapsed`),T(!1),j(``),ne({}),P({}),_e(!1),Ce(null),De(null),k(!1),je(!1),Ne(`create`),Le(null),ut({preferredTaskId:null}).catch(()=>void 0)},[a]),(0,S.useEffect)(()=>{a&&Qe.current!==e&&(Qe.current=e,ut({preferredTaskId:Ze.current,syncLibrary:!1}).catch(()=>void 0))},[e]);let ft=(0,S.useMemo)(()=>[...l].sort(pX),[l]),pt=s?.pages??[],mt=(0,S.useMemo)(()=>ft.filter(jY),[ft]),ht=(0,S.useMemo)(()=>{let e=new Map;for(let t of ft){if(jY(t))continue;let n=AY(t);e.set(n,!!e.get(n)||mX(t))}return e},[ft]),gt=(0,S.useMemo)(()=>PY(pt,ft),[pt,ft]),_t=(0,S.useMemo)(()=>gt.reduce((e,t)=>(e.total+=1,t.aggregate_status===`completed`?e.completed+=1:t.aggregate_status===`in_progress`?e.inProgress+=1:t.aggregate_status===`failed`?e.failed+=1:e.notStarted+=1,e),{total:0,completed:0,inProgress:0,notStarted:0,failed:0}),[gt]),vt=gt.some(e=>e.has_completed_result),yt=pt.length>0&&(mt.length>0||vt),bt=Ee??pt[0]?.page??null,xt=bt===0,St=pt.find(e=>e.page===bt)??null,Ct=(0,S.useMemo)(()=>!pt.length||bt==null?ft.filter(e=>!jY(e)):FY(ft,bt),[pt.length,bt,ft]),wt=Ct[0]?.task_id??null,Tt=Ct[0]??null,Et=wt?d[wt]??null:null,Dt=Et?.detail??null,Ot=Et?.events??[],kt=Ct.find(e=>e.task_id===_)??null,At=_?d[_]??null:null,jt=At?.detail??null,Mt=At?.events??[],Nt=!!(_&&wt&&_===wt),Pt=!!(wt&&h[wt]&&!Et),Ft=!!(_&&h[_]&&!At),It=wt?p[wt]??null:null,Lt=_?p[_]??null:null;(0,S.useEffect)(()=>{Re.current=null},[wt]),(0,S.useEffect)(()=>{if(!pt.length){Ee!==null&&De(null);return}Ee&&pt.some(e=>e.page===Ee)||Ee===0&&yt||De(ft.find(e=>e.page_number!=null&&e.page_number>0)?.page_number??pt[0]?.page??null)},[pt,yt,ft,Ee]),(0,S.useEffect)(()=>{let e=LY(Ct,Ze.current);e!==Ze.current&&(Ze.current=e,v(e),e&&rt(e).catch(()=>void 0))},[Ct]),(0,S.useEffect)(()=>{!_||y!==`mindmap`||it(_).catch(()=>void 0)},[y,_]),(0,S.useEffect)(()=>{!_||y!==`summary`||ot(_).catch(()=>void 0)},[y,_]),(0,S.useEffect)(()=>{OX(F)},[F]),(0,S.useEffect)(()=>{if(!_||!(te[_]?.status===`generating`||jt?.result?.mindmap_status===`generating`))return;let e=window.setInterval(()=>{Promise.all([it(_,{force:!0}),rt(_,{force:!0})]).catch(()=>void 0)},1500);return()=>window.clearInterval(e)},[te,jt?.result?.mindmap_status,_]),(0,S.useEffect)(()=>{if(!_||!(re[_]?.status===`generating`||jt?.result?.visual_note_status===`generating`))return;let e=window.setInterval(()=>{Promise.all([ot(_,{force:!0}),rt(_,{force:!0})]).catch(()=>void 0)},1800);return()=>window.clearInterval(e)},[jt?.result?.visual_note_status,_,re]),(0,S.useEffect)(()=>{if(!wt)return;let e=I.createTaskEventSource(wt,Ot.at(-1)?.created_at);return e.addEventListener(`progress`,e=>{let t=JSON.parse(e.data);f(e=>{let n=e[wt];if(!n)return e;let r=n.events.some(e=>e.event_id===t.event.event_id)?n.events:[...n.events,t.event],i={detail:{...n.detail,status:t.status,updated_at:t.updated_at,result:t.result===void 0?n.detail.result:t.result,llm_total_tokens:t.result?.llm_total_tokens??n.detail.llm_total_tokens},events:r};return et.current.set(wt,i),{...e,[wt]:i}}),u(e=>e.map(e=>e.task_id===wt?{...e,status:t.status,updated_at:t.updated_at,llm_total_tokens:t.result?.llm_total_tokens??e.llm_total_tokens}:e)),c(e=>e&&{...e,latest_status:t.status,updated_at:t.updated_at,latest_result:t.result===void 0?e.latest_result:t.result})}),e.onerror=()=>e.close(),()=>e.close()},[wt]),(0,S.useEffect)(()=>{if(!wt||!Ot.length)return;let e=[...Ot].reverse().find(e=>e.stage===`completed`||e.stage===`failed`||e.stage===`cancelled`||e.stage===`mindmap_completed`||e.stage===`mindmap_failed`||e.stage===`visual_completed`||e.stage===`visual_partial`||e.stage===`visual_failed`);if(!e)return;let t=`${wt}:${e.event_id}`;if(Re.current===t)return;Re.current=t;let n=window.setTimeout(()=>{ut({forceTaskIds:[wt],preferredTaskId:Ze.current,syncLibrary:!0}).catch(()=>void 0)},300);return()=>window.clearTimeout(n)},[Ot,wt]),(0,S.useEffect)(()=>{if(x!==`expanded`&&!w&&!O&&!ge&&!ce)return;function e(e){let t=e.target,n=Be.current?.contains(t),r=Ve.current?.contains(t),i=He.current?.contains(t),a=Je.current?.contains(t),o=qe.current?.contains(t),s=Ue.current?.contains(t);!n&&!s&&C(`collapsed`),r||(T(!1),D(null)),i||k(!1),a||_e(!1),o||le(!1)}function t(e){e.key===`Escape`&&(C(`collapsed`),T(!1),D(null),k(!1),_e(!1),le(!1))}return document.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[w,ge,ce,O,x]);async function Rt(){if(!Ke.current||ue)return;if(!navigator.clipboard||typeof ClipboardItem>`u`){j(`当前环境不支持将图片复制到剪贴板。`);return}let e=Ke.current,t=A,n=window.getComputedStyle(e),r=n.backgroundColor===`rgba(0, 0, 0, 0)`?window.getComputedStyle(document.body).backgroundColor:n.backgroundColor;de(!0),j(`正在导出当前知识卡片...`),e.setAttribute(`data-export-mode`,`true`);try{await document.fonts.ready,await new Promise(e=>window.requestAnimationFrame(()=>e(void 0)));let t=await kY(e,{backgroundColor:r,cacheBust:!0,pixelRatio:Math.max(window.devicePixelRatio||1,2)});if(!t)throw Error(`未能生成图片,请稍后重试。`);if(window.desktop?.clipboard){let e=await new Promise((e,n)=>{let r=new FileReader;r.onloadend=()=>{if(typeof r.result==`string`){e(r.result);return}n(Error(`图片编码失败,请稍后重试。`))},r.onerror=()=>n(r.error??Error(`图片编码失败,请稍后重试。`)),r.readAsDataURL(t)});await window.desktop.clipboard.writeImage(e)}else await navigator.clipboard.write([new ClipboardItem({[t.type]:t})]);j(`当前知识卡片已复制为图片。`)}catch(e){e instanceof Error&&e.message.includes(`Document is not focused`)?j(`复制失败:请先点一下应用窗口,再重新尝试。`):j(e instanceof Error?e.message:`导出图片失败,请稍后重试。`)}finally{e.removeAttribute(`data-export-mode`),de(!1),window.setTimeout(()=>{j(e=>e===`当前知识卡片已复制为图片。`||e===`正在导出当前知识卡片...`?t:e)},2600)}}let zt=jt?.result??null,Bt=(0,S.useMemo)(()=>Yr(Ot),[Ot]),Vt=(0,S.useMemo)(()=>Ft?{tone:`pending`,title:`正在加载所选版本`,description:`任务详情载入完成后,工作台会切换到对应的知识卡片和摘要内容。`}:Lt?{tone:`failed`,title:`所选版本加载失败`,description:`可以重新点击该版本重试,或先切换查看其他已完成任务。`,detail:IY(Lt)}:XY(jt),[Ft,jt,Lt]),Ht=!!(Vt?.detail&&jX(Vt.detail));(0,S.useEffect)(()=>{if(!_||!Vt?.detail||!jX(Vt.detail))return;let e=`${_}:${Vt.detail}`;ze.current!==e&&(ze.current=e,M(!0))},[Vt?.detail,_]);function Ut(){r?.(),r||window.open(`https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp`,`_blank`,`noopener,noreferrer`)}function Wt(){if(M(!1),n){n();return}o(`/settings`)}async function Gt(){if(!i){Wt();return}try{await i(),M(!1),j(`B 站登录态已保存。重新提交任务即可。`)}catch(e){j(e instanceof Error?e.message:`捕获 B 站登录态失败,请按教程手动导出 cookies.txt。`)}}let Kt=Ht?{onOpenTutorial:Ut,onOpenSettings:Wt}:null,qt=(0,S.useMemo)(()=>{let e=_?te[_]??null:null;return e?.status===`ready`&&(!e.mindmap||!e.mindmap.nodes?.length)?{...e,status:`failed`,error_message:e.error_message||`思维导图数据为空,请重新生成。`,mindmap:null}:e},[te,_]),Jt=(0,S.useMemo)(()=>Ft?{tone:`pending`,title:`思维导图将在版本载入后可用`,description:`当前正在同步所选内容版本的详细结果。`,actionLabel:`加载中`,actionEnabled:!1}:Lt?{tone:`failed`,title:`当前版本暂时无法打开思维导图`,description:IY(Lt),actionLabel:`稍后重试`,actionEnabled:!1}:ZY(jt,qt),[Ft,qt,jt,Lt]),Yt=(0,S.useMemo)(()=>RY(zt,{chapterAnchor:xt?`page`:`time`}),[xt,zt]),Xt=Yt.find(e=>e.kind===`overview`)??null,Zt=Yt.filter(e=>e.kind===`key-point`),Qt=Yt.filter(e=>e.kind===`chapter`),$t=(0,S.useMemo)(()=>zY(Qt,zt,{chapterAnchor:xt?`page`:`time`}),[Qt,xt,zt]),en=$t.length>0&&we.length===$t.length,tn=(0,S.useMemo)(()=>KY(zt),[zt]),nn=_?re[_]??null:null,rn=nn?.status||jt?.result?.visual_note_status||`idle`,an=nn?.enhanced_note_markdown||nn?.visual_note_markdown||``,on=!!an.trim(),sn=F===`visual`&&on?`visual`:`text`;(0,S.useEffect)(()=>{!on&&F===`visual`&&se(`text`)},[on,F]);let cn=sn===`visual`?an:tn,ln=sn===`visual`?`图文`:`纯文本`,un=rn===`generating`?`图文笔记生成中,完成后可选`:`当前任务没有图文笔记`,dn=(0,S.useMemo)(()=>IX(_,nn),[_,nn]),fn=(0,S.useMemo)(()=>qY(jt),[jt]),pn=zt?.transcript_text??``,mn=!!(jt?.status===`completed`&&(pn.trim()||zt?.artifacts?.transcript_path)),hn=Dt?.status??Tt?.status??s?.latest_status,gn=It??IY(Bt.failedEvent?.message)??Bt.currentEvent?.message??IY(Dt?.error_message)??(Tt?Jr(Tt.status):`等待开始处理`),_n=wt?.slice(0,8)??null,vn=Dt?.title||Tt?.title||s?.title||`当前任务`,yn=hX(Dt??Tt),bn=It?`同步失败`:Bt.failedEvent?`处理失败`:Bt.currentEvent?.stage?lr(Bt.currentEvent.stage):Tt?Jr(Tt.status):`等待开始`,xn=_?_.slice(0,8):null,Sn=hX(jt??kt),Cn=zt?.llm_total_tokens??jt?.llm_total_tokens??kt?.llm_total_tokens??null,wn=jt?.status??kt?.status,Tn=!!(_&&jt?.result?.transcript_text?.trim()&&jt.result.artifacts?.summary_path),Dn=!!(_&&wn===`completed`&&zt?.knowledge_note_markdown?.trim()&&!xt&&rn!==`generating`&&!ae[_]),On=Ft?`加载中`:Lt?`加载失败`:Vt?Jr(wn):`已准备`,kn=[{id:`progress`,label:`最新运行`,value:bn},{id:`content`,label:`当前查看`,value:xt?`全集总结`:St?`P${St.page}`:xn?`任务 ${xn}`:`暂无任务`,mono:!0}],An=_t.completed,jn=_t.total>0?Math.max(0,Math.min(100,Math.round(An/_t.total*100))):0,Mn=(0,S.useMemo)(()=>xt?null:tX(St?.source_url||s?.source_url),[St?.source_url,xt,s?.source_url]),Nn=(0,S.useMemo)(()=>Mn?eX(Mn.embedUrl,Mn.platform,Pe.seconds,Pe.nonce):null,[Mn,Pe]),Pn=(0,S.useMemo)(()=>{if(!s||String(s.platform||``).toLowerCase()!==`local`||xt)return null;let e=St?.source_url||s.source_url,t=(()=>{try{return`.${new URL(e,window.location.origin).pathname.split(`.`).pop()?.toLowerCase()||``}`}catch{let t=String(e||``).split(`.`);return t.length>1?`.${t[t.length-1].toLowerCase()}`:``}})();return uX.has(t)?`/api/v1/videos/${s.video_id}/media`:null},[St?.source_url,xt,s]),Fn=!!(Pn||Mn),In=qt?.status===`ready`&&jt?.result?.mindmap_status!==`generating`?qt.mindmap??null:null,Ln=(0,S.useMemo)(()=>Mt.filter(e=>e.stage.startsWith(`mindmap_`)),[Mt]),Rn=(0,S.useMemo)(()=>{if(!_)return null;let e=qt?.status===`generating`||jt?.result?.mindmap_status===`generating`,t=!!N[_],n=Ln.length?Yr(Ln):null;return!e&&!t&&!n?.filtered.length?null:{progress:Math.max(0,Math.min(100,Math.round(n?.progress??(t?6:90)))),currentLabel:n?.currentEvent?.stage?lr(n.currentEvent.stage):t?`提交生成请求`:`等待阶段回传`,message:qt?.error_message||jt?.result?.mindmap_error_message||n?.failedEvent?.message||n?.currentEvent?.message||(t?`正在向本地服务提交导图生成请求。`:`系统正在生成思维导图,阶段完成后会自动刷新。`),events:n?.filtered??[],hasError:!!n?.failedEvent}},[Ln,N,qt,jt?.result?.mindmap_error_message,jt?.result?.mindmap_status,_]),zn=(0,S.useMemo)(()=>xX(Bt.filtered),[Bt.filtered]),Bn=zn.find(e=>e.tone===`failed`)??[...zn].reverse().find(e=>e.tone===`active`)??zn.at(-1)??null,Vn=In?`主题导图视图`:Rn?`${Rn.currentLabel} · ${Rn.progress}%`:`按需生成`,Hn=(0,S.useMemo)(()=>In?In.nodes.find(e=>e.id===In.root)??In.nodes[0]??null:null,[In]),Un=(0,S.useMemo)(()=>Hn?GX(Hn,Ie,xt?`page`:`time`):{nodes:[],edges:[]},[xt,Hn,Ie]),Wn=(0,S.useMemo)(()=>!Hn||!Ie?null:PX(Hn,Ie),[Hn,Ie]);(0,S.useEffect)(()=>{let e=$t.map(e=>e.id).join(`|`),t=Ye.current!==e;Ye.current=e,Te(e=>{let n=new Set($t.map(e=>e.id)),r=e.filter(e=>n.has(e)),i=r.length===e.length&&r.every((t,n)=>t===e[n]);return $t.length===0?r.length?[]:e:r.length>0||!t?i?e:r:[$t[0].id]})},[$t]),(0,S.useEffect)(()=>{if(!Hn){Le(null);return}Le(e=>e&&PX(Hn,e)?e:null)},[Hn]);function Gn(e){if(e!=null){if(Fe(t=>({nonce:t.nonce+1,seconds:e})),y===`knowledge`&&Pn&&Ge.current)Ge.current.currentTime=e,Ge.current.play().catch(()=>{});else if(!Mn&&!Pn)return;y===`knowledge`&&We.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}function Kn(e,t){if(t==null)return;let n=pt.find(e=>e.page===t);if(!n){j(`没有找到 P${t} 对应的分 P。`);return}let r=e.currentTarget.getBoundingClientRect();ke({open:!0,pageNumber:t,title:n.title,x:r.left+r.width/2,y:r.bottom+8})}function qn(){Oe&&(De(Oe.pageNumber),b(`knowledge`),k(!1),ke(null),j(`已跳转到 P${Oe.pageNumber}「${Oe.title}」`))}function Jn(){ke(null)}(0,S.useEffect)(()=>{if(!Oe?.open)return;function e(e){let t=e.target;!t.closest(`.jump-confirm-popover`)&&!t.closest(`[data-jump-anchor]`)&&ke(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Oe?.open]);function Yn(){Te(en?[]:$t.map(e=>e.id))}function Xn(e,t){Te(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))}async function Zn(e=!1){if(_){b(`mindmap`),j(e?`已发起重新生成思维导图...`:`已发起生成思维导图...`);try{if((await at(_,{force:e})).status===`ready`){Le(null),j(`思维导图已更新`);return}j(e?`正在重新生成思维导图...`:`正在生成思维导图...`)}catch(e){j(e instanceof Error?e.message:`思维导图生成失败`)}}}async function Qn(e=!1){if(_){b(`summary`),se(`visual`),j(e?`已发起重新生成图文笔记...`:`已发起生成图文笔记...`);try{let t=await ct(_,{force:e});if(await rt(_,{force:!0}).catch(()=>void 0),t.status===`ready`||t.status===`partial`){j(`图文笔记已更新`);return}j(e?`正在重新生成图文笔记...`:`正在生成图文笔记...`)}catch(e){j(e instanceof Error?e.message:`图文笔记生成失败`)}}}async function $n(){if(!s)return;let e=s,n=!s.is_favorite;c({...s,is_favorite:n,favorite_updated_at:n?new Date().toISOString():null});try{c(await I.setVideoFavorite(s.video_id,{is_favorite:n})),t(),j(n?`已加入收藏`:`已取消收藏`)}catch(t){c(e),j(t instanceof Error?t.message:`更新收藏状态失败`)}}async function er(){if(s){T(!1),D(null),j(`正在创建全集总结任务...`);try{let e=await I.createAggregateSummaryTask(s.video_id);De(0),await ut({forceTaskIds:[e.task_id],preferredTaskId:e.task_id,syncLibrary:!0}),j(`已开始生成全集总结`)}catch(e){j(e instanceof Error?e.message:`全集总结创建失败`)}}}async function tr(e){if(!s)throw Error(`当前视频信息不可用,请稍后重试。`);j(Me===`create`?e.confirm?`正在确认批量生成...`:`正在创建批量生成任务...`:e.confirm?`正在确认批量重生成...`:`正在准备批量重生成...`);let t=Me===`create`?await I.createVideoTasksBatch(s.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm}):await I.resummarizeVideoTasksBatch(s.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm});if(t.requires_confirmation)return j(Me===`create`?`所选内容中有 ${t.conflict_pages.length} 个分 P 已有成功摘要,确认后会默认跳过。`:`所选内容中有 ${t.conflict_pages.length} 个分 P 将复用已有转写重新生成摘要,请确认继续。`),t;await ut({preferredTaskId:null,syncLibrary:!0}),je(!1);let n=t.created_tasks.length,r=t.skipped_pages.length;return j(Me===`create`?n>0?`已创建 ${n} 个批量任务${r?`,跳过 ${r} 个分 P`:``}`:`没有创建新任务${r?`,已跳过 ${r} 个分 P`:``}`:n>0?`已发起 ${n} 个批量重生成任务${r?`,跳过 ${r} 个分 P`:``}`:`没有创建新的重生成任务${r?`,已跳过 ${r} 个分 P`:``}`),t}if(!s)return(0,L.jsx)(`section`,{className:`grid-card empty-state-card`,children:`正在加载视频详情...`});let nr=St?.source_url||s.source_url,rr=String(s.platform||``).toLowerCase()===`local`,ir=rr&&!!window.desktop?.shell&&!!nr;async function ar(){if(!window.desktop?.shell||!nr)return;let e=await window.desktop.shell.openPath(nr);if(e)throw Error(e)}async function or(e=`obsidian`){if(!(!_||fe)){pe(!0),_e(!1),j(e===`obsidian`?`正在导出 Obsidian 笔记...`:`正在导出 Markdown 笔记...`);try{let t=await window.desktop?.dialog?.pickDirectory?.(be||void 0);if(window.desktop?.dialog&&!t){j(`已取消导出。`);return}let n=await I.exportTaskMarkdown(_,{target:e,include_transcript:ve,output_dir:t||void 0});Ce(n),xe(e=>e||n.directory),await ut({preferredTaskId:_,forceTaskIds:[_]}),j(`已导出到 ${n.file_name}`)}catch(e){j(e instanceof Error?e.message:`导出 Markdown 失败`)}finally{pe(!1)}}}async function sr(){if(!(!_||me)){he(!0),j(`正在导出转写文本...`);try{let e=await window.desktop?.dialog?.pickDirectory?.(be||void 0);if(window.desktop?.dialog&&!e){j(`已取消导出。`);return}let t=await I.exportTaskTranscript(_,{output_dir:e||void 0});Ce(t),xe(e=>e||t.directory),await ut({preferredTaskId:_,forceTaskIds:[_]}),j(`已导出到 ${t.file_name}`)}catch(e){j(e instanceof Error?e.message:`导出转写文本失败`)}finally{he(!1)}}}async function cr(){if(!window.desktop?.shell||!Se?.directory)return;let e=await window.desktop.shell.openPath(Se.directory);if(e)throw Error(e)}return(0,L.jsxs)(`section`,{className:`video-detail-page`,children:[(0,L.jsx)(Vx,{notices:[{id:`video-detail-status`,message:A}]}),(0,L.jsx)(Hr,{isOpen:ee,onClose:()=>M(!1),onOpenTutorial:Ut,onOpenSettings:Wt,onCaptureLoginCookies:Gt}),Oe?.open&&(0,L.jsxs)(`div`,{className:`jump-confirm-popover`,role:`dialog`,"aria-modal":`true`,style:{left:Oe.x,top:Oe.y,transform:`translateX(-50%)`},children:[(0,L.jsx)(`div`,{className:`jump-confirm-popover-arrow`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`jump-confirm-popover-content`,children:[(0,L.jsxs)(`p`,{className:`jump-confirm-popover-message`,children:[`跳转到 P`,Oe.pageNumber,`「`,Oe.title,`」?`]}),(0,L.jsxs)(`div`,{className:`jump-confirm-popover-actions`,children:[(0,L.jsx)(`button`,{className:`jump-confirm-popover-cancel`,onClick:Jn,type:`button`,children:`取消`}),(0,L.jsx)(`button`,{className:`jump-confirm-popover-ok`,onClick:qn,type:`button`,children:`跳转`})]})]})]}),(0,L.jsxs)(`div`,{className:`detail-page-shell`,children:[(0,L.jsx)(`div`,{className:`detail-page-toolbar`,children:(0,L.jsxs)(En,{className:`detail-back-button`,to:`/library`,children:[(0,L.jsx)(ZX,{className:`detail-back-icon`}),`返回视频库`]})}),(0,L.jsxs)(`article`,{className:`video-detail-hero ${_t.total>0?`has-page-batch`:`is-single-page`}`,children:[(0,L.jsx)(`div`,{className:`video-detail-media`,children:ir?(0,L.jsxs)(`button`,{className:`video-detail-cover video-detail-cover-button`,type:`button`,onClick:()=>void ar().catch(e=>{j(e instanceof Error?e.message:`打开本地视频失败`)}),children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`video-detail-cover-overlay`,children:(0,L.jsx)($X,{className:`video-detail-play-icon`})}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]}):rr?(0,L.jsxs)(`div`,{className:`video-detail-cover`,children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]}):(0,L.jsxs)(`a`,{className:`video-detail-cover`,href:nr,target:`_blank`,rel:`noreferrer`,children:[St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{src:St?.cover_url||s.cover_url,alt:St?`P${St.page} ${s.title}`:s.title,loading:`lazy`}):(0,L.jsx)(`div`,{className:`video-detail-cover-placeholder`,children:`VIDEO`}),(0,L.jsx)(`div`,{className:`video-detail-cover-overlay`,children:(0,L.jsx)($X,{className:`video-detail-play-icon`})}),(0,L.jsx)(`div`,{className:`detail-duration-badge`,children:Gr(St?.duration??s.duration)})]})}),(0,L.jsxs)(`div`,{className:`video-detail-copy`,children:[(0,L.jsxs)(`div`,{className:`video-detail-copy-main`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-meta-row`,children:[(0,L.jsx)(`span`,{className:`detail-status-badge ${ur(hn)}`,children:Jr(hn)}),(0,L.jsx)(`span`,{className:`detail-hero-meta-time`,children:Wr(s.updated_at)}),_t.total>0?(0,L.jsxs)(`span`,{className:`detail-hero-meta-time`,children:[`共 `,_t.total,` P`]}):null]}),(0,L.jsx)(`h2`,{className:`video-detail-title`,children:s.title}),pt.length?(0,L.jsxs)(`div`,{className:`detail-page-switcher ${O?`is-open`:``}`,ref:He,children:[(0,L.jsx)(`span`,{className:`detail-page-switcher-label`,children:`当前内容`}),(0,L.jsxs)(`button`,{className:`detail-page-select`,type:`button`,"aria-haspopup":`listbox`,"aria-expanded":O,onClick:()=>k(e=>!e),children:[(0,L.jsxs)(`span`,{className:`detail-page-select-value`,children:[xt?`全集总结`:St?.title||`选择分 P`,St&&ht.get(St.page)?(0,L.jsx)(`span`,{className:`detail-page-select-check`,children:`✓`}):null,xt&&mt.some(e=>e.status===`completed`)?(0,L.jsx)(`span`,{className:`detail-page-select-check`,children:`✓`}):null]}),(0,L.jsx)(QX,{className:`detail-page-select-caret`})]}),O?(0,L.jsx)(`div`,{className:`detail-page-menu`,children:(0,L.jsxs)(`div`,{className:`detail-page-menu-scroll`,role:`listbox`,"aria-label":`选择当前分 P`,children:[yt?(0,L.jsxs)(`button`,{className:`detail-page-option ${xt?`is-selected`:``}`,role:`option`,"aria-selected":xt,type:`button`,onClick:()=>{De(0),k(!1)},children:[(0,L.jsx)(`span`,{className:`detail-page-option-check ${xt?`is-selected`:``}`,children:xt?`✓`:``}),(0,L.jsxs)(`span`,{className:`detail-page-option-copy`,children:[(0,L.jsx)(`strong`,{children:`全集总结`}),mt.length?(0,L.jsxs)(`small`,{children:[`已有 `,mt.length,` 个版本`]}):(0,L.jsx)(`small`,{children:`可基于已完成分 P 生成`})]})]}):null,pt.map(e=>{let t=e.page===bt,n=ht.get(e.page);return(0,L.jsxs)(`button`,{className:`detail-page-option ${t?`is-selected`:``} ${n?`has-summary`:`is-unavailable`}`,type:`button`,role:`option`,"aria-selected":t,onClick:()=>{De(e.page),k(!1)},children:[(0,L.jsx)(`span`,{className:`detail-page-option-check ${t?`is-selected`:``}`,children:t?`✓`:``}),(0,L.jsxs)(`span`,{className:`detail-page-option-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),n?(0,L.jsx)(`small`,{children:`已生成摘要`}):(0,L.jsx)(`small`,{children:`尚未生成`})]})]},e.page)})]})}):null]}):null]}),(0,L.jsxs)(`div`,{className:`detail-task-float`,ref:Be,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule ${ur(hn)} ${x===`expanded`?`is-expanded`:``}`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule-grid`,children:[(0,L.jsxs)(`div`,{className:`detail-hero-capsule-item`,children:[(0,L.jsx)(`span`,{className:`detail-hero-stat-label`,children:kn[0].label}),(0,L.jsx)(`div`,{className:`detail-hero-stat-value`,children:(0,L.jsx)(`strong`,{className:kn[0].mono?`detail-hero-stat-mono`:``,children:kn[0].value})})]}),(0,L.jsxs)(`button`,{"aria-label":x===`expanded`?`收起任务详情与历史`:`展开任务详情与历史`,"aria-expanded":x===`expanded`,className:`detail-hero-capsule-item detail-task-detail-trigger ${x===`expanded`?`is-open`:``}`,title:x===`expanded`?`收起任务详情与历史`:`任务详情与历史`,type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),C(e=>e===`expanded`?`collapsed`:`expanded`)},children:[(0,L.jsxs)(`span`,{className:`detail-hero-stat-label detail-task-detail-label`,children:[kn[1].label,(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsx)(`div`,{className:`detail-hero-stat-value`,children:(0,L.jsx)(`strong`,{className:kn[1].mono?`detail-hero-stat-mono`:``,children:kn[1].value})})]})]}),(0,L.jsxs)(`div`,{className:`detail-hero-actions`,children:[(0,L.jsx)(`button`,{"aria-label":s.is_favorite?`取消收藏`:`收藏视频`,className:`detail-action-button secondary detail-action-button-compact detail-action-button-favorite ${s.is_favorite?`is-active`:``}`,title:s.is_favorite?`取消收藏`:`收藏视频`,type:`button`,onClick:()=>void $n(),children:(0,L.jsx)(AX,{className:`detail-action-icon`})}),(0,L.jsxs)(`div`,{className:`detail-action-menu`,ref:Ve,children:[(0,L.jsxs)(`button`,{"aria-label":`更多操作`,"aria-expanded":w,"aria-haspopup":`menu`,className:`detail-action-button secondary detail-action-button-compact detail-action-menu-trigger ${w?`is-open`:``}`,title:`更多操作`,type:`button`,onClick:()=>{T(e=>{let t=!e;return t||D(null),t})},children:[(0,L.jsx)(oZ,{className:`detail-action-icon`}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),w?(0,L.jsxs)(`div`,{className:`detail-action-popover`,role:`menu`,"aria-label":`视频操作设置`,children:[(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`regenerate`?`is-open`:``}`,role:`menuitem`,type:`button`,onClick:()=>D(e=>e===`regenerate`?null:`regenerate`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(iZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`重新生成`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsxs)(`div`,{className:`detail-action-submenu ${E===`regenerate`?`is-open`:``}`,role:`group`,"aria-label":`重新生成操作`,"aria-hidden":E!==`regenerate`,children:[(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!Tn,onClick:async()=>{T(!1),D(null),j(`正在基于当前版本重新生成摘要...`),await I.resummarizeVideoTask(s.video_id,{task_id:Ze.current,page_number:bt}),await ut({preferredTaskId:null,syncLibrary:!0}),j(`已开始新的摘要生成任务`)},children:[(0,L.jsx)(iZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑文本笔记`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!Dn,onClick:async()=>{T(!1),D(null),await Qn(!0)},children:[(0,L.jsx)(uZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑图文笔记`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:!_||wn!==`completed`||!!(_&&N[_]),onClick:async()=>{T(!1),D(null),await Zn(!0)},children:[(0,L.jsx)(dZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重跑思维导图`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`regenerate`?0:-1,disabled:xt,onClick:async()=>{T(!1),D(null),j(`正在重新转写并生成摘要...`);let e=DX()===`visual`?`frame_insert`:`text`;await I.createVideoTask(s.video_id,{page_number:bt,visual_note_mode:e}),await ut({preferredTaskId:null,syncLibrary:!0}),j(`已开始新的转写摘要任务`)},children:[(0,L.jsx)(aZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`重新转写并生成`})]})]}),(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`batch`?`is-open`:``}`,role:`menuitem`,type:`button`,disabled:gt.length===0,onClick:()=>D(e=>e===`batch`?null:`batch`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(aZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`批量处理`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsxs)(`div`,{className:`detail-action-submenu ${E===`batch`?`is-open`:``}`,role:`group`,"aria-label":`批量处理操作`,"aria-hidden":E!==`batch`,children:[(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,onClick:()=>{T(!1),D(null),Ne(`create`),je(!0)},children:[(0,L.jsx)(aZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`批量生成摘要`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,onClick:()=>{T(!1),D(null),Ne(`resummary`),je(!0)},children:[(0,L.jsx)(iZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`批量重生成摘要`})]}),(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`batch`?0:-1,disabled:!vt,onClick:()=>void er(),children:[(0,L.jsx)(rZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`生成全集总结`})]})]}),(0,L.jsxs)(`button`,{className:`detail-action-menu-item detail-action-menu-group ${E===`maintenance`?`is-open`:``}`,role:`menuitem`,type:`button`,onClick:()=>D(e=>e===`maintenance`?null:`maintenance`),children:[(0,L.jsx)(`span`,{className:`detail-action-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(nZ,{className:`detail-action-icon`})}),(0,L.jsx)(`span`,{className:`detail-action-menu-copy`,children:(0,L.jsx)(`strong`,{children:`更多维护`})}),(0,L.jsx)(QX,{className:`detail-action-caret`})]}),(0,L.jsx)(`div`,{className:`detail-action-submenu ${E===`maintenance`?`is-open`:``}`,role:`group`,"aria-label":`维护操作`,"aria-hidden":E!==`maintenance`,children:(0,L.jsxs)(`button`,{className:`detail-action-subitem`,role:`menuitem`,type:`button`,tabIndex:E===`maintenance`?0:-1,onClick:async()=>{T(!1),D(null),j(`正在刷新视频信息...`),await I.probeVideo({url:s.source_url,force_refresh:!0}),await ut({preferredTaskId:Ze.current,syncLibrary:!0}),j(`视频信息已刷新`)},children:[(0,L.jsx)(nZ,{className:`detail-action-icon`}),(0,L.jsx)(`span`,{children:`刷新视频信息`})]})})]}):null]}),(0,L.jsx)(`button`,{"aria-label":`从视频库删除`,className:`detail-action-button danger detail-action-button-compact`,title:`从视频库删除`,type:`button`,onClick:async()=>{window.confirm(`确定要从视频库删除这个视频吗?`)&&(await I.deleteVideo(s.video_id),t(),o(`/library`))},children:(0,L.jsx)(tZ,{className:`detail-action-icon`})})]})]}),x===`expanded`?(0,L.jsxs)(`section`,{className:`grid-card detail-task-panel`,role:`dialog`,"aria-label":`任务进度与历史`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`detail-task-panel-header`,children:[(0,L.jsx)(`div`,{className:`panel-header`,children:(0,L.jsx)(`h2`,{children:`任务进度与历史`})}),(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:()=>C(`collapsed`),children:`关闭`})]}),(0,L.jsxs)(`div`,{className:`detail-task-panel-body`,children:[(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-live`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`实时运行`}),(0,L.jsx)(`h3`,{children:`运行中任务`})]}),_n?(0,L.jsxs)(`span`,{className:`task-history-id`,children:[`任务 `,_n]}):null]}),Tt?(0,L.jsxs)(`div`,{className:`detail-task-live-grid`,children:[(0,L.jsxs)(`div`,{className:`detail-task-live-progress`,children:[(0,L.jsxs)(`div`,{className:`progress-bar-wrapper`,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(Bt.progress),"aria-label":`最新任务进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple ${Bt.hasError?`error`:Bt.isCompleted?`success`:``}`,style:{width:`${Bt.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-info-simple`,children:[(0,L.jsxs)(`span`,{className:`progress-percent-simple`,children:[Math.round(Bt.progress),`%`]}),(0,L.jsx)(`span`,{className:`progress-status-simple`,children:gn})]})]}),It?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`运行详情同步失败`}),(0,L.jsx)(`span`,{children:It})]}):null,Bt.filtered.length?(0,L.jsxs)(`details`,{className:`progress-stage-card`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:Bt.failedEvent?`需要关注`:Bt.isCompleted?`主任务已完成`:`当前进度`}),(0,L.jsx)(`span`,{children:Bn?`${Bn.label} · ${Bn.events.length} 条`:`${Bt.filtered.length} 条进度记录`})]}),(0,L.jsx)(`span`,{className:`progress-stage-toggle`,children:`查看阶段树`})]}),(0,L.jsxs)(`div`,{className:`progress-phase-view`,children:[Bn?(0,L.jsxs)(`article`,{className:`progress-focus-card tone-${Bn.tone}`,children:[(0,L.jsx)(`span`,{children:Bn.tone===`failed`?`异常阶段`:Bt.isCompleted?`完成概览`:`当前阶段`}),(0,L.jsx)(`strong`,{children:Bn.label}),(0,L.jsx)(`small`,{children:Bn.events.at(-1)?.message||gn})]}):null,(0,L.jsx)(`div`,{className:`progress-phase-tree`,children:zn.map(e=>(0,L.jsxs)(`article`,{className:`progress-phase-group tone-${e.tone}`,children:[(0,L.jsxs)(`div`,{className:`progress-phase-head`,children:[(0,L.jsx)(`strong`,{children:e.label}),(0,L.jsxs)(`span`,{children:[e.events.filter(_X).length,`/`,e.events.length]})]}),(0,L.jsx)(`div`,{className:`progress-stage-list progress-stage-tree`,children:e.events.map((t,n)=>(0,L.jsxs)(`article`,{className:`progress-event-card ${dr(t.stage)}`,children:[(0,L.jsx)(`div`,{className:`progress-event-node`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`progress-event-copy`,children:[(0,L.jsxs)(`div`,{className:`progress-event-topline`,children:[(0,L.jsxs)(`strong`,{children:[t.message,` `,(0,L.jsxs)(`span`,{className:`progress-event-count`,children:[`(`,n+1,`/`,e.events.length,`)`]})]}),(0,L.jsx)(`span`,{children:Wr(t.created_at)})]}),(0,L.jsx)(`div`,{className:`progress-event-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.progress,"aria-label":`${lr(t.stage)}阶段进度`,children:(0,L.jsx)(`span`,{style:{width:`${t.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-event-meta`,children:[lr(t.stage),` · `,t.progress,`%`]})]})]},t.event_id))})]},e.id))})]})]}):Pt?(0,L.jsx)(`div`,{className:`detail-inline-note detail-inline-note-pending`,role:`status`,children:`正在同步该任务的实时进度。`}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成进度记录。`})]}),(0,L.jsxs)(`section`,{className:`detail-task-snapshot detail-task-snapshot-emphasis`,children:[(0,L.jsxs)(`div`,{className:`detail-task-snapshot-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-snapshot-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-snapshot-kicker`,children:`当前任务概览`}),(0,L.jsx)(`strong`,{children:vn}),(0,L.jsx)(`small`,{children:_n?`任务 ${_n}`:`任务信息加载中`})]}),(0,L.jsx)(`span`,{className:`helper-chip ${ur(hn)}`,children:Jr(hn)})]}),(0,L.jsx)(`div`,{className:`detail-task-snapshot-grid`,children:yn.map(e=>(0,L.jsxs)(`div`,{className:`detail-snapshot-metric`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`strong`,{children:e.value})]},e.label))})]})]}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前分 P 还没有处理任务。`})]}),(0,L.jsxs)(`div`,{className:`detail-task-panel-grid`,children:[(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-history`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`版本列表`}),(0,L.jsx)(`h3`,{children:`内容版本`})]}),(0,L.jsx)(`span`,{className:`detail-task-section-count`,children:Ct.length})]}),Ct.length?(0,L.jsx)(`div`,{className:`detail-history-list`,children:Ct.map(e=>{let t=e.task_id===_,n=e.task_id===wt;return(0,L.jsx)(`article`,{className:`detail-history-item ${t?`active`:``}`,children:(0,L.jsxs)(`button`,{"aria-pressed":t,className:`detail-history-trigger`,type:`button`,onClick:()=>dt(e.task_id),children:[(0,L.jsxs)(`div`,{className:`detail-history-main`,children:[(0,L.jsxs)(`div`,{className:`detail-history-topline`,children:[(0,L.jsx)(`span`,{className:`task-status ${ur(e.status)}`,children:Jr(e.status)}),n?(0,L.jsx)(`span`,{className:`helper-chip`,children:`最新任务`}):null,t?(0,L.jsx)(`span`,{className:`helper-chip status-success`,children:`当前查看`}):null,MY(e)?(0,L.jsx)(`span`,{className:`helper-chip`,children:MY(e)}):null]}),(0,L.jsx)(`strong`,{children:e.title||s.title}),(0,L.jsx)(`small`,{children:Wr(e.created_at)})]}),(0,L.jsx)(`div`,{className:`detail-history-side`,children:(0,L.jsx)(`span`,{className:`task-history-id`,children:e.task_id.slice(0,8)})})]})},e.task_id)})}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前分 P 还没有可切换的内容版本。`})]}),(0,L.jsxs)(`article`,{className:`detail-task-panel-card detail-task-panel-card-selected`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-head`,children:[(0,L.jsxs)(`div`,{className:`detail-task-section-copy`,children:[(0,L.jsx)(`span`,{className:`detail-task-section-kicker`,children:`当前查看`}),(0,L.jsx)(`h3`,{children:`查看中的内容版本`})]}),kt?(0,L.jsx)(`span`,{className:`helper-chip ${Nt?`status-success`:`status-pending`}`,children:Nt?`最新版本`:`历史版本`}):null]}),kt?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`detail-history-detail ${Nt?`detail-history-detail-live`:``}`,children:[(0,L.jsxs)(`div`,{className:`detail-history-detail-head`,children:[(0,L.jsxs)(`div`,{className:`detail-history-topline`,children:[(0,L.jsx)(`span`,{className:`task-status ${ur(kt.status)}`,children:Jr(kt.status)}),kt.task_id===wt?(0,L.jsx)(`span`,{className:`helper-chip`,children:`最新任务`}):null,(0,L.jsx)(`span`,{className:`helper-chip status-success`,children:`当前查看`})]}),(0,L.jsx)(`span`,{className:`task-history-id`,children:kt.task_id.slice(0,8)})]}),(0,L.jsxs)(`div`,{className:`detail-history-detail-copy`,children:[(0,L.jsx)(`strong`,{children:kt.title||s.title}),(0,L.jsx)(`small`,{children:Wr(kt.created_at)})]}),(0,L.jsx)(`div`,{className:`detail-history-metrics`,children:Sn.map(e=>(0,L.jsxs)(`div`,{className:`detail-snapshot-metric detail-history-metric`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`strong`,{children:e.value})]},e.label))})]}),Ft?(0,L.jsx)(`div`,{className:`detail-inline-note detail-inline-note-pending`,role:`status`,children:`正在加载该版本的详细内容,下方工作台会在同步后切换。`}):null,Lt?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`版本详情加载失败`}),(0,L.jsx)(`span`,{children:IY(Lt)})]}):null,jt?.error_message?(0,L.jsxs)(`div`,{className:`detail-error-banner`,role:`status`,children:[(0,L.jsx)(`strong`,{children:`任务错误`}),(0,L.jsx)(`span`,{children:IY(jt.error_message)})]}):null,!Ft&&!Lt?(0,L.jsx)(`div`,{className:`detail-inline-note`,role:`status`,children:jt?.result?`该版本的结果已同步到下方工作台。`:`该版本还没有可用结果,下方工作台会展示对应状态。`}):null,(0,L.jsx)(`div`,{className:`detail-history-actions`,children:(0,L.jsx)(`button`,{className:`tertiary-button danger`,type:`button`,onClick:async()=>{window.confirm(`确定要删除这条任务记录吗?`)&&(et.current.delete(kt.task_id),tt.current.delete(kt.task_id),f(e=>TX(e,kt.task_id)),m(e=>TX(e,kt.task_id)),g(e=>TX(e,kt.task_id)),await I.deleteTask(kt.task_id),await ut({preferredTaskId:kt.task_id===Ze.current?null:Ze.current,syncLibrary:!0}))},children:`删除任务`})})]}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`选择一个任务版本后,这里会显示该版本的元信息与可用状态。`})]})]})]})]}):null]})]}),_t.total>0?(0,L.jsxs)(`div`,{className:`detail-batch-side`,"aria-label":`批量任务统计`,ref:Ue,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple detail-batch-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":jn,"aria-label":`批量完成进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple success`,style:{width:`${jn}%`}})}),(0,L.jsx)(`div`,{className:`detail-batch-inline-meta`,children:(0,L.jsxs)(`div`,{className:`detail-batch-inline-copy`,children:[(0,L.jsxs)(`span`,{children:[An,` / `,_t.total]}),(0,L.jsxs)(`small`,{children:[`进行中 `,_t.inProgress,` · 未开始 `,_t.notStarted,_t.failed?` · 失败 ${_t.failed}`:``]})]})})]}):null]}),(0,L.jsx)(`section`,{className:`video-detail-main`,children:(0,L.jsxs)(`article`,{className:`detail-workspace-card`,children:[(0,L.jsxs)(`div`,{className:`detail-workspace-header`,children:[(0,L.jsx)(`h3`,{className:`detail-workspace-label`,children:`Knowledge Workspace`}),(0,L.jsxs)(`div`,{className:`detail-workspace-meta`,children:[(0,L.jsxs)(`span`,{className:`detail-workspace-signal ${Vt?ur(wn):`status-success`}`,children:[(0,L.jsx)(`span`,{className:`detail-workspace-signal-dot`}),On]}),xn?(0,L.jsxs)(`span`,{children:[`任务 `,xn]}):null,Cn==null?null:(0,L.jsxs)(`span`,{children:[qr(Cn),` tokens`]})]})]}),(0,L.jsx)(`nav`,{className:`detail-tab-row`,role:`tablist`,"aria-label":`详情工作台视图`,children:fX.map(e=>(0,L.jsxs)(`button`,{className:`detail-tab ${y===e.id?`active`:``}`,role:`tab`,type:`button`,"aria-selected":y===e.id,onClick:()=>b(e.id),children:[(0,L.jsxs)(`div`,{className:`detail-tab-topline`,children:[(0,L.jsx)(XX,{active:y===e.id,tab:e.id}),(0,L.jsx)(`span`,{children:e.label})]}),(0,L.jsx)(`small`,{children:e.description})]},e.id))}),y===`knowledge`?Vt?(0,L.jsx)(YX,{cookieHelpActions:Kt,state:Vt}):(0,L.jsxs)(`section`,{className:`detail-tab-panel detail-export-target`,ref:Ke,children:[(0,L.jsxs)(`div`,{className:`detail-knowledge-lead`,children:[(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-overview`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading-main`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Overview`}),Xt?.meta?(0,L.jsx)(`span`,{className:`detail-section-meta`,children:Xt.meta}):null]}),(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,onClick:Rt,disabled:ue,"aria-label":ue?`正在导出知识卡片图片`:`复制当前知识卡片为图片`,title:ue?`正在导出知识卡片图片`:`复制当前知识卡片为图片`,children:(0,L.jsx)(uZ,{})})]}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:Xt?.title||`核心概览`}),Xt?.content?(0,L.jsx)(kx,{className:`detail-section-body markdown-content-body`,compact:!0,content:Xt.content}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:`当前任务还没有生成核心概览。`}),Pn?(0,L.jsxs)(`div`,{className:`detail-overview-player`,ref:We,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Player`}),(0,L.jsx)(`span`,{className:`detail-section-meta detail-section-link`,children:`本地视频播放器`})]}),(0,L.jsxs)(`div`,{className:`detail-video-embed-frame`,children:[(0,L.jsx)(`video`,{ref:Ge,className:`detail-video-embed detail-local-video`,controls:!0,preload:`metadata`,src:Pn,poster:St?.cover_url||s.cover_url||void 0}),(0,L.jsx)(`div`,{className:`detail-video-export-mask`,"aria-hidden":`true`,children:St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{className:`detail-video-export-cover`,src:St?.cover_url||s.cover_url,alt:``}):(0,L.jsxs)(`div`,{className:`detail-video-export-mask-copy`,children:[(0,L.jsx)(`strong`,{children:s.title}),(0,L.jsx)(`span`,{children:`导出知识卡片时会保留当前视频封面,不直接导出播放器画面。`})]})})]})]}):Nn&&Mn?(0,L.jsxs)(`div`,{className:`detail-overview-player`,ref:We,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Player`}),(0,L.jsx)(`a`,{className:`detail-section-meta detail-section-link`,href:Mn.sourceUrl,target:`_blank`,rel:`noreferrer`,children:Mn.openLabel})]}),(0,L.jsxs)(`div`,{className:`detail-video-embed-frame`,children:[(0,L.jsx)(`iframe`,{allow:`accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen`,allowFullScreen:!0,className:`detail-video-embed`,referrerPolicy:`strict-origin-when-cross-origin`,scrolling:`no`,src:Nn,title:`${s.title} 播放器`}),(0,L.jsx)(`div`,{className:`detail-video-export-mask`,"aria-hidden":`true`,children:St?.cover_url||s.cover_url?(0,L.jsx)(`img`,{className:`detail-video-export-cover`,src:St?.cover_url||s.cover_url,alt:``}):(0,L.jsxs)(`div`,{className:`detail-video-export-mask-copy`,children:[(0,L.jsx)(`strong`,{children:s.title}),(0,L.jsx)(`span`,{children:`播放器画面无法直接导出,已保留当前卡片内容与视频入口。`})]})})]})]}):null]}),(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-keypoints`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Key Points`}),(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[Zt.length,` 条`]})]}),Zt.length?(0,L.jsx)(`div`,{className:`detail-point-rail`,children:Zt.map((e,t)=>(0,L.jsx)(NX,{card:e,index:t},e.id))}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成关键要点卡。`})]})]}),(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-last`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Chapters`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[$t.length?(0,L.jsx)(`button`,{className:`detail-section-text-action`,type:`button`,onClick:Yn,children:en?`一键收起`:`一键展开`}):null,(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[Qt.length,` 条`]})]})]}),$t.length?(0,L.jsx)(`div`,{className:`detail-chapter-groups`,children:$t.map(e=>{let t=we.includes(e.id);return(0,L.jsxs)(`div`,{className:`detail-chapter-group ${t?`is-open`:``}`,children:[(0,L.jsxs)(`button`,{className:`detail-chapter-group-summary`,type:`button`,"aria-expanded":t,onClick:()=>Xn(e.id,!t),children:[(0,L.jsxs)(`div`,{className:`detail-chapter-group-copy`,children:[(0,L.jsx)(`strong`,{children:e.title}),(0,L.jsx)(`span`,{children:e.meta})]}),(0,L.jsx)(`span`,{className:`detail-chapter-group-caret`,"aria-hidden":`true`,children:(0,L.jsx)(QX,{})})]}),(0,L.jsx)(`div`,{className:`detail-chapter-group-content`,children:(0,L.jsx)(`div`,{className:`detail-chapter-group-body`,children:e.items.map((e,t)=>(0,L.jsx)(NX,{card:e,index:t,onJumpToPage:xt?Kn:void 0,onSeekToTimestamp:!xt&&Fn?Gn:void 0},e.id))})})]},e.id)})}):(0,L.jsx)(`div`,{className:`empty-placeholder`,children:`当前任务还没有生成章节知识卡。`})]})]}):null,y===`summary`?Vt?(0,L.jsx)(YX,{cookieHelpActions:Kt,state:Vt}):(0,L.jsxs)(`section`,{className:`detail-tab-panel`,children:[(0,L.jsxs)(`section`,{className:`detail-content-section`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Knowledge Note`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[(0,L.jsxs)(`span`,{className:`detail-section-meta`,children:[`完整学习视图 · `,ln]}),(0,L.jsxs)(`div`,{className:`detail-section-menu`,ref:qe,children:[(0,L.jsxs)(`button`,{className:`detail-section-icon-button detail-section-menu-trigger ${ce?`is-open`:``}`,type:`button`,onClick:()=>le(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ce,"aria-label":`选择知识笔记显示形式`,title:`笔记形式`,children:[sn===`visual`?(0,L.jsx)(uZ,{}):(0,L.jsx)(rZ,{}),(0,L.jsx)(QX,{className:`detail-section-menu-caret`})]}),ce?(0,L.jsxs)(`div`,{className:`detail-section-popover detail-note-mode-popover`,role:`menu`,"aria-label":`知识笔记显示形式`,children:[(0,L.jsxs)(`button`,{className:`detail-section-menu-item detail-note-mode-option ${sn===`visual`?`is-selected`:``}`,type:`button`,role:`menuitemradio`,"aria-checked":sn===`visual`,disabled:!on,onClick:()=>{on&&(se(`visual`),le(!1))},children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(uZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:`图文`}),(0,L.jsx)(`small`,{children:on?`显示带图片的整合笔记`:un})]})]}),(0,L.jsxs)(`button`,{className:`detail-section-menu-item detail-note-mode-option ${sn===`text`?`is-selected`:``}`,type:`button`,role:`menuitemradio`,"aria-checked":sn===`text`,onClick:()=>{se(`text`),le(!1)},children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(rZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:`纯文本`}),(0,L.jsx)(`small`,{children:`显示基础知识笔记正文`})]})]})]}):null]}),(0,L.jsxs)(`div`,{className:`detail-section-menu`,ref:Je,children:[(0,L.jsxs)(`button`,{className:`detail-section-icon-button detail-section-menu-trigger ${ge?`is-open`:``}`,type:`button`,disabled:!fn||fe,onClick:()=>_e(e=>!e),"aria-haspopup":`menu`,"aria-expanded":ge,"aria-label":fe?`正在导出 Obsidian 笔记`:`导出知识笔记`,title:fe?`正在导出 Obsidian 笔记`:`导出知识笔记`,children:[(0,L.jsx)(cZ,{}),(0,L.jsx)(QX,{className:`detail-section-menu-caret`})]}),ge?(0,L.jsxs)(`div`,{className:`detail-section-popover`,role:`menu`,"aria-label":`知识笔记导出设置`,children:[(0,L.jsxs)(`button`,{className:`detail-section-menu-item`,type:`button`,role:`menuitem`,disabled:!fn||fe,onClick:()=>void or(`obsidian`),children:[(0,L.jsx)(`span`,{className:`detail-section-menu-item-icon`,"aria-hidden":`true`,children:(0,L.jsx)(cZ,{})}),(0,L.jsxs)(`span`,{className:`detail-section-menu-copy`,children:[(0,L.jsx)(`strong`,{children:fe?`正在导出...`:`导出到 Obsidian`}),(0,L.jsx)(`small`,{children:`选择目录后写入 Markdown 笔记`})]})]}),(0,L.jsxs)(`label`,{className:`detail-section-menu-check`,role:`menuitemcheckbox`,"aria-checked":ve,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:ve,onChange:e=>ye(e.target.checked)}),(0,L.jsx)(`span`,{children:`导出笔记时附带转写全文`})]})]}):null]}),Se?.directory&&window.desktop?.shell?(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,onClick:()=>void cr().catch(e=>{j(e instanceof Error?e.message:`打开导出目录失败`)}),"aria-label":`打开导出目录`,title:`打开导出目录`,children:(0,L.jsx)(lZ,{})}):null]})]}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:`知识笔记`}),!be&&!window.desktop?.dialog?(0,L.jsx)(`p`,{className:`detail-section-body`,children:`导出前请先在设置中填写输出目录,Markdown / Obsidian 笔记会写入该目录。`}):null,cn?(0,L.jsx)(kx,{className:`detail-note-markdown`,content:cn,imageResolver:e=>RX(_,e)}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:`当前任务还没有生成知识笔记。`}),(0,L.jsxs)(`details`,{className:`detail-visual-assets-details detail-note-assets-details`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(`span`,{children:`查看图片素材记录`}),(0,L.jsx)(`small`,{children:LX(rn,dn.length,nn?.insert_count??0)})]}),(0,L.jsx)(zX,{frames:dn,status:rn,errorMessage:nn?.error_message||jt?.result?.visual_note_error_message||``,loading:!!(_&&ae[_]),onSeekToTimestamp:!xt&&Fn?Gn:void 0})]})]}),(0,L.jsxs)(`section`,{className:`detail-content-section`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Transcript`}),(0,L.jsxs)(`div`,{className:`detail-section-heading-actions`,children:[(0,L.jsx)(`span`,{className:`detail-section-meta`,children:pn?`原始转写`:`暂无内容`}),(0,L.jsx)(`button`,{className:`detail-section-icon-button`,type:`button`,disabled:!mn||me,onClick:()=>void sr(),"aria-label":me?`正在导出转写文本`:`导出转写文本`,title:me?`正在导出转写文本`:`导出转写文本`,children:(0,L.jsx)(cZ,{})})]})]}),zt?.segments&&zt.segments.length>0?(0,L.jsx)(`div`,{className:`transcript-with-timestamps`,children:zt.segments.map((e,t)=>(0,L.jsxs)(`div`,{className:`transcript-segment`,children:[(0,L.jsxs)(`span`,{className:`transcript-timestamp`,children:[`[`,Math.floor(e.start/60),`:`,String(Math.floor(e.start%60)).padStart(2,`0`),`]`]}),(0,L.jsx)(`span`,{className:`transcript-text`,children:e.text})]},t))}):(0,L.jsx)(`pre`,{className:`transcript-full`,children:pn||`暂无转写全文。`})]})]}):null,y===`mindmap`?(0,L.jsx)(`section`,{className:`detail-tab-panel`,children:(0,L.jsxs)(`section`,{className:`detail-content-section detail-content-section-last`,children:[(0,L.jsxs)(`div`,{className:`detail-section-heading`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Mind Map`}),(0,L.jsx)(`div`,{className:`detail-section-heading-actions`,children:(0,L.jsx)(`span`,{className:`detail-section-meta`,children:Vn})})]}),In?(0,L.jsxs)(`div`,{className:`detail-mindmap-workspace`,children:[(0,L.jsx)(`div`,{className:`detail-mindmap-canvas`,role:`tree`,"aria-label":`思维导图`,children:(0,L.jsx)(`div`,{className:`detail-mindmap-flow-shell`,children:(0,L.jsx)(nP,{nodes:Un.nodes,edges:Un.edges,fitView:!0,fitViewOptions:{padding:.24},minZoom:.38,maxZoom:1.6,nodeTypes:qX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,proOptions:{hideAttribution:!0},onNodeClick:(e,t)=>Le(t.id),onPaneClick:()=>Le(null),children:(0,L.jsx)(vP,{showInteractive:!1})},`${In.root}-${In.nodes.length}`)})}),(0,L.jsx)(`div`,{className:`detail-mindmap-inspector`,children:Wn?(0,L.jsxs)(`article`,{className:`detail-mindmap-inspector-card`,children:[(0,L.jsxs)(`div`,{className:`detail-mindmap-inspector-head`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`detail-mindmap-inspector-kicker`,children:FX(Wn.type)}),(0,L.jsx)(`h4`,{children:Zr(Wn.label,Wn.summary)})]}),xt&&EX(Wn.time_anchor)?(0,L.jsxs)(`button`,{className:`detail-mindmap-seek-button`,type:`button`,"data-jump-anchor":!0,onClick:e=>Kn(e,Math.round(Wn.time_anchor??0)),children:[(0,L.jsx)(fZ,{className:`detail-mindmap-seek-icon`}),`查看 P`,Math.round(Wn.time_anchor??0),` 总结`]}):EX(Wn.time_anchor)&&Fn?(0,L.jsxs)(`button`,{className:`detail-mindmap-seek-button`,type:`button`,onClick:()=>Gn(Wn.time_anchor??null),children:[(0,L.jsx)(fZ,{className:`detail-mindmap-seek-icon`}),`定位到片段 `,Gr(Wn.time_anchor)]}):null]}),Wn.summary?(0,L.jsx)(kx,{className:`detail-mindmap-summary-markdown`,compact:!0,content:Wn.summary}):null,Wn.source_chapter_titles.length?(0,L.jsx)(`div`,{className:`detail-mindmap-inspector-tags`,children:Wn.source_chapter_titles.slice(0,3).map((e,t)=>{let n=Wn.source_chapter_starts[t]??null,r=xt&&EX(n),i=!xt&&EX(n)&&Fn,a=r?`P${Math.round(n)}`:EX(n)?Gr(n):``,o=`${e}${a?` · ${a}`:``}`;return r||i?(0,L.jsx)(`button`,{className:`detail-mindmap-inspector-tag is-action`,type:`button`,onClick:e=>r?Kn(e,Math.round(n)):Gn(n),children:o},`${e}-${t}`):(0,L.jsx)(`span`,{className:`detail-mindmap-inspector-tag`,children:o},`${e}-${t}`)})}):null]}):(0,L.jsxs)(`div`,{className:`detail-mindmap-inspector-hint`,children:[(0,L.jsx)(`strong`,{children:`点击节点查看摘要与来源片段`}),(0,L.jsx)(`span`,{children:`主干只保留结构和标签,避免把导图重新变成一块块内容卡片。`})]})})]}):Jt?(0,L.jsxs)(`article`,{className:`detail-mindmap-placeholder tone-${Jt.tone}`,children:[(0,L.jsxs)(`div`,{className:`detail-mindmap-copy`,children:[(0,L.jsx)(`h4`,{className:`detail-section-title`,children:Jt.title}),(0,L.jsx)(`p`,{className:`detail-section-body`,children:Jt.description}),Rn?(0,L.jsxs)(`div`,{className:`detail-mindmap-progress`,children:[(0,L.jsxs)(`div`,{className:`progress-bar-wrapper`,children:[(0,L.jsx)(`div`,{className:`progress-bar-simple`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Rn.progress,"aria-label":`思维导图生成进度`,children:(0,L.jsx)(`div`,{className:`progress-fill-simple ${Rn.hasError?`error`:Rn.progress>=100?`success`:``}`,style:{width:`${Rn.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-info-simple`,children:[(0,L.jsxs)(`span`,{className:`progress-percent-simple`,children:[Rn.progress,`%`]}),(0,L.jsx)(`span`,{className:`progress-status-simple`,children:Rn.message})]})]}),Rn.events.length?(0,L.jsxs)(`details`,{className:`progress-stage-card`,children:[(0,L.jsxs)(`summary`,{children:[(0,L.jsx)(`strong`,{children:Rn.currentLabel}),(0,L.jsx)(`span`,{className:`progress-stage-toggle`,children:`查看导图进度`})]}),(0,L.jsx)(`div`,{className:`progress-stage-list progress-stage-tree`,children:Rn.events.map((e,t)=>(0,L.jsxs)(`article`,{className:`progress-event-card ${dr(e.stage)}`,children:[(0,L.jsx)(`div`,{className:`progress-event-node`,"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`progress-event-copy`,children:[(0,L.jsxs)(`div`,{className:`progress-event-topline`,children:[(0,L.jsxs)(`strong`,{children:[e.message,` `,(0,L.jsxs)(`span`,{className:`progress-event-count`,children:[`(`,t+1,`/`,Rn.events.length,`)`]})]}),(0,L.jsx)(`time`,{children:Wr(e.created_at)})]}),(0,L.jsx)(`div`,{className:`progress-event-bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.progress,"aria-label":`${lr(e.stage)}阶段进度`,children:(0,L.jsx)(`span`,{style:{width:`${e.progress}%`}})}),(0,L.jsxs)(`div`,{className:`progress-event-meta`,children:[lr(e.stage),` · `,e.progress,`%`]})]})]},e.event_id))})]}):null]}):null]}),Jt.actionLabel?(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,disabled:!Jt.actionEnabled||!!(_&&N[_]),"aria-disabled":!Jt.actionEnabled||!!(_&&N[_]),onClick:()=>Zn(Jt.tone===`failed`),children:_&&N[_]?`处理中...`:Jt.actionLabel}):null]}):null]})}):null,(0,L.jsx)(gi,{isOpen:Ae,mode:Me,video:s,pages:gt,onClose:()=>je(!1),onSubmit:tr}),(y===`summary`||y===`mindmap`)&&(Pn||Nn&&Mn)?(0,L.jsx)(JX,{embedUrl:Nn,localVideoUrl:Pn,openLabel:Mn?.openLabel,sourceUrl:Mn?.sourceUrl,seekTarget:Pe,title:s.title}):null]})})]})]})}function NX({card:e,index:t,onJumpToPage:n,onSeekToTimestamp:r}){if(e.kind===`chapter`){let t=typeof e.timestampSeconds==`number`&&!!r,i=typeof e.pageNumber==`number`&&!!n,a=t||i,o=(0,L.jsxs)(`div`,{className:`detail-chapter-node-shell`,children:[(0,L.jsx)(`span`,{className:`detail-chapter-node-dot`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`detail-chapter-node-meta`,children:(0,L.jsxs)(`div`,{className:`detail-chapter-time`,children:[e.anchorLabel?(0,L.jsx)(rZ,{className:`detail-inline-icon`}):(0,L.jsx)(eZ,{className:`detail-inline-icon`}),(0,L.jsx)(`span`,{children:e.anchorLabel||(e.timestampSeconds==null?`--`:Gr(e.timestampSeconds))})]})}),(0,L.jsxs)(`div`,{className:`detail-chapter-node-copy`,children:[(0,L.jsx)(`h4`,{children:e.title}),(0,L.jsx)(kx,{className:`detail-card-markdown`,compact:!0,content:e.content})]}),a?(0,L.jsxs)(`div`,{className:`detail-card-link`,children:[i?`查看分 P 总结`:`定位片段`,(0,L.jsx)(fZ,{className:`detail-inline-icon`})]}):null]});return a?(0,L.jsx)(`button`,{className:`detail-chapter-node detail-chapter-node-action`,type:`button`,"data-jump-anchor":!0,onClick:t=>{if(i){n(t,e.pageNumber??null);return}r(e.timestampSeconds??null)},children:o}):(0,L.jsx)(`article`,{className:`detail-chapter-node`,children:o})}return(0,L.jsxs)(`article`,{className:`detail-point-item`,children:[(0,L.jsx)(`div`,{className:`detail-point-marker`,"aria-hidden":`true`,children:(0,L.jsx)(`span`,{children:String(t+1).padStart(2,`0`)})}),(0,L.jsxs)(`div`,{className:`detail-point-main`,children:[e.title?(0,L.jsx)(`div`,{className:`detail-point-card-top`,children:(0,L.jsx)(`h4`,{children:e.title})}):null,(0,L.jsx)(kx,{className:`detail-card-markdown`,compact:!0,content:e.content})]})]})}function PX(e,t){if(e.id===t)return e;for(let n of e.children){let e=PX(n,t);if(e)return e}return null}function FX(e){switch(e){case`root`:return`中心主题`;case`theme`:return`一级主题`;case`topic`:return`子主题`;case`leaf`:return`知识点`;default:return`节点`}}function IX(e,t){if(!e||!t?.context?.observations?.length)return[];let n=new Map;for(let e of t.context.frames??[])e.frame_id&&n.set(e.frame_id,e);return t.context.observations.map(t=>{let r=n.get(t.frame_id)?.file_name||`${t.frame_id}.jpg`;return{key:`${t.frame_id}-${t.timestamp_seconds}`,timestampSeconds:t.timestamp_seconds,timestampLabel:Gr(t.timestamp_seconds),imageUrl:`/api/v1/tasks/${e}/visual-evidence/media/${encodeURIComponent(r)}`,caption:t.caption||`关键画面截图`,ocrText:t.ocr_text||``,scene:t.scene||``}}).filter(e=>Number.isFinite(e.timestampSeconds))}function LX(e,t,n=0){return e===`generating`?`生成中`:e===`ready`?n>0?`${n} 处插图 · ${t} 张图`:`${t} 张图`:e===`partial`?t?`${t} 张,部分降级`:`部分降级`:e===`unsupported`?`当前输入不支持`:e===`failed`?`生成失败`:`按需生成`}function RX(e,t){if(!e)return t;let n=t.startsWith(`visual://`)?t.replace(`visual://`,``).trim():t.startsWith(`frames/`)?t.replace(/^frames\//,``).trim():``;if(!n)return t;let r=n.replace(/\.jpg$/i,``);if(!r||r.includes(`/`)||r.includes(`\\`))return t;let i=n.match(/\.(jpe?g|png|webp)$/i)?n:`${r}.jpg`;return`/api/v1/tasks/${e}/visual-evidence/media/${encodeURIComponent(i)}`}function zX({frames:e,status:t,errorMessage:n,loading:r,onSeekToTimestamp:i}){return e.length?(0,L.jsx)(`div`,{className:`detail-visual-grid`,children:e.map(e=>(0,L.jsxs)(`article`,{className:`detail-visual-card`,children:[(0,L.jsx)(`img`,{alt:`${e.timestampLabel} ${e.caption}`,src:e.imageUrl,loading:`lazy`}),(0,L.jsxs)(`div`,{className:`detail-visual-card-copy`,children:[(0,L.jsxs)(`div`,{className:`detail-visual-card-head`,children:[i?(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e.timestampSeconds),children:e.timestampLabel}):(0,L.jsx)(`span`,{children:e.timestampLabel}),e.scene?(0,L.jsx)(`small`,{children:e.scene}):null]}),(0,L.jsx)(`strong`,{children:e.caption}),e.ocrText?(0,L.jsxs)(`p`,{children:[`画面文字:`,e.ocrText]}):null]})]},e.key))}):(0,L.jsx)(`p`,{className:`detail-section-body`,children:r||t===`generating`?`正在后台生成图文笔记,完成后会自动刷新。`:t===`unsupported`?n||`音频或纯文本任务没有可截图的视频画面。`:t===`failed`?n||`图文笔记生成失败,可以稍后重试。`:`还没有生成图文笔记。`})}function BX(e,t=0){let n=t===0?132:e.type===`theme`?88:e.type===`topic`?66:56;if(!e.children.length)return n;let r=t===0?58:t===1?30:18,i=e.children.reduce((e,n)=>e+BX(n,t+1),0)+r*(e.children.length-1);return Math.max(n,i)}function VX(e,t){return e===0?112:e===1?t.type===`leaf`?78:94:t.type===`leaf`?54:68}function HX(e){switch(e.type){case`root`:return{width:252,height:112};case`theme`:return{width:208,height:44};case`topic`:return{width:212,height:40};case`leaf`:return{width:232,height:52};default:return{width:200,height:48}}}function UX(e,t){if(!t)return null;let n=new Map,r=new Map;e.forEach(e=>{e.parentId&&(n.set(e.node.id,e.parentId),r.set(e.parentId,[...r.get(e.parentId)??[],e.node.id]))});let i=new Set([t]),a=t;for(;n.has(a);)a=n.get(a),i.add(a);let o=[t];for(;o.length;){let e=o.pop();(r.get(e)??[]).forEach(e=>{i.has(e)||(i.add(e),o.push(e))})}return i}function WX(e){let t=[];t.push({node:e,depth:0,branch:`center`,x:0,y:0,accent:nX});let n=HX(e),r=[],i=[],a=0,o=0;e.children.forEach((e,t)=>{let n=rX[t%rX.length],s=BX(e,1);if(a<=o){r.push({node:e,accent:n}),a+=s;return}i.push({node:e,accent:n}),o+=s});let s=(e,n,r,i,a,o,c)=>{if(t.push({node:e,depth:n,branch:r,x:a,y:o,parentId:c,accent:i}),!e.children.length)return;let l=n===1?30:18,u=HX(e),d=r===`left`?a-u.width:a+u.width,f=e.children.map(e=>({child:e,span:BX(e,n+1)})),p=o-(f.reduce((e,t)=>e+t.span,0)+l*(f.length-1))/2;f.forEach(({child:t,span:a})=>{let o=p+a/2,c=r===`left`?d-VX(n,t):d+VX(n,t);s(t,n+1,r,i,c,o,e.id),p+=a+l})},c=(t,r)=>{if(!t.length)return;let i=t.map(e=>({...e,span:BX(e.node,1)})),a=-(i.reduce((e,t)=>e+t.span,0)+58*(i.length-1))/2;i.forEach(({node:t,accent:i,span:o})=>{let c=a+o/2;s(t,1,r,i,r===`left`?-(n.width/2+VX(0,t)):n.width/2+VX(0,t),c,e.id),a+=o+58})};c(r,`left`),c(i,`right`);let l=t.reduce((e,t)=>{let n=HX(t.node),r=t.branch===`left`?t.x-n.width:t.branch===`right`?t.x:t.x-n.width/2,i=t.branch===`left`?t.x:t.branch===`right`?t.x+n.width:t.x+n.width/2;return{left:Math.min(e.left,r),right:Math.max(e.right,i),top:Math.min(e.top,t.y-n.height/2),bottom:Math.max(e.bottom,t.y+n.height/2)}},{left:1/0,right:-1/0,top:1/0,bottom:-1/0}),u=-((l.left+l.right)/2),d=-((l.top+l.bottom)/2);return t.map(e=>({...e,x:e.x+u,y:e.y+d}))}function GX(e,t,n=`time`){let r=WX(e),i=UX(r,t),a=!!i?.size;return{nodes:r.map(e=>{let r=t===e.node.id,o=a?!i.has(e.node.id):!1,s=HX(e.node),c=e.branch===`left`?{x:e.x-s.width,y:e.y-s.height/2}:e.branch===`right`?{x:e.x,y:e.y-s.height/2}:{x:e.x-s.width/2,y:e.y-s.height/2};return{id:e.node.id,type:`mindmap`,position:c,draggable:!1,selectable:!0,sourcePosition:e.branch===`left`?lO.Left:lO.Right,targetPosition:e.branch===`left`?lO.Right:lO.Left,className:`${r?`is-active `:``}${o?`is-muted`:``}`.trim(),data:{label:e.node.label,summary:e.node.summary,tone:e.node.type,branch:e.branch,selected:r,muted:o,timeAnchor:e.node.time_anchor??null,pageAnchorLabel:n===`page`&&EX(e.node.time_anchor)?`P${Math.round(e.node.time_anchor??0)}`:void 0,sourceChapterTitles:e.node.source_chapter_titles,sourceChapterStarts:e.node.source_chapter_starts,accent:e.accent}}}),edges:r.filter(e=>e.parentId).map(e=>{let t=a?!(i.has(e.node.id)&&i.has(e.parentId)):!1;return{id:`${e.parentId}-${e.node.id}`,source:e.parentId,target:e.node.id,sourceHandle:e.branch===`left`?`source-left`:`source-right`,targetHandle:e.branch===`left`?`target-right`:`target-left`,type:`simplebezier`,animated:!1,className:`detail-mindmap-edge${t?` is-muted`:``}`,style:{stroke:e.accent.stroke,strokeWidth:e.depth<=1?2.8:2.2}}})}}function KX({data:e}){let t={"--mindmap-branch":e.accent.stroke,"--mindmap-branch-soft":e.accent.surface,"--mindmap-branch-ink":e.accent.ink,"--mindmap-branch-shadow":e.accent.shadow},n=Zr(e.label,e.summary);return(0,L.jsxs)(`div`,{className:`detail-mindmap-node-card tone-${e.tone}`,style:t,children:[e.tone===`root`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-left`,position:lO.Left,type:`source`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-right`,position:lO.Right,type:`source`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`target-left`,position:lO.Left,type:`target`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`target-right`,position:lO.Right,type:`target`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-left`,position:lO.Left,type:`source`}),(0,L.jsx)(CM,{className:`detail-mindmap-handle`,id:`source-right`,position:lO.Right,type:`source`})]}),(0,L.jsxs)(`div`,{className:`detail-mindmap-node-head`,children:[(0,L.jsx)(kx,{className:`detail-mindmap-node-label`,compact:!0,content:n}),e.pageAnchorLabel?(0,L.jsx)(`small`,{children:e.pageAnchorLabel}):EX(e.timeAnchor)?(0,L.jsx)(`small`,{children:Gr(e.timeAnchor)}):null]})]})}var qX={mindmap:KX};function JX({embedUrl:e,localVideoUrl:t,openLabel:n,sourceUrl:r,seekTarget:i,title:a}){let o=(0,S.useRef)(null),[s,c]=(0,S.useState)(()=>typeof window>`u`?{width:oX,x:0,y:0}:wX(window.innerWidth,window.innerHeight)),l=(0,S.useRef)(null);(0,S.useEffect)(()=>{function e(){c(e=>CX(e,window.innerWidth,window.innerHeight))}return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,S.useEffect)(()=>{function e(e){let t=o.current;if(t){if(t.mode===`drag`){c(n=>CX({...n,width:t.layout.width,x:t.layout.x+(e.clientX-t.originX),y:t.layout.y+(e.clientY-t.originY)},window.innerWidth,window.innerHeight));return}c(n=>CX({...n,width:t.layout.width+(e.clientX-t.originX)},window.innerWidth,window.innerHeight))}}function t(){o.current=null}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[]),(0,S.useEffect)(()=>{!t||!l.current||i.seconds==null||(l.current.currentTime=i.seconds,l.current.play().catch(()=>{}))},[t,i]);function u(e,t){t.button===0&&(o.current={mode:e,originX:t.clientX,originY:t.clientY,layout:s},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())}function d(){typeof window>`u`||c(wX(window.innerWidth,window.innerHeight))}return(0,L.jsxs)(`div`,{className:`detail-floating-player`,style:{width:`${s.width}px`,left:`${s.x}px`,top:`${s.y}px`},children:[(0,L.jsxs)(`div`,{className:`detail-floating-player-head`,onPointerDown:e=>u(`drag`,e),children:[(0,L.jsxs)(`div`,{className:`detail-floating-player-copy`,children:[(0,L.jsx)(`span`,{className:`detail-floating-player-kicker`,children:`Player`}),(0,L.jsx)(`strong`,{children:a})]}),r&&n?(0,L.jsx)(`a`,{className:`detail-floating-player-link`,href:r,target:`_blank`,rel:`noreferrer`,onPointerDown:e=>e.stopPropagation(),children:n}):null]}),(0,L.jsx)(`div`,{className:`detail-video-embed-frame detail-video-embed-frame-floating`,children:t?(0,L.jsx)(`video`,{ref:l,className:`detail-video-embed detail-local-video`,controls:!0,preload:`metadata`,src:t}):e?(0,L.jsx)(`iframe`,{allow:`accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen`,allowFullScreen:!0,className:`detail-video-embed`,referrerPolicy:`strict-origin-when-cross-origin`,scrolling:`no`,src:e,title:`${a} 悬浮播放器`}):null}),(0,L.jsx)(`div`,{className:`detail-floating-player-resize`,role:`presentation`,onPointerDown:e=>u(`resize`,e),onDoubleClick:d})]})}function YX({cookieHelpActions:e,state:t}){return(0,L.jsx)(`section`,{className:`detail-state-panel tone-${t.tone}`,role:`status`,children:(0,L.jsxs)(`div`,{className:`detail-state-copy`,children:[(0,L.jsx)(`h3`,{className:`detail-section-label`,children:`Workspace State`}),(0,L.jsx)(`h4`,{className:`detail-section-title`,children:t.title}),(0,L.jsx)(`p`,{className:`detail-section-body`,children:t.description}),t.detail?(0,L.jsx)(`pre`,{className:`detail-state-detail`,children:t.detail}):null,e?(0,L.jsxs)(`div`,{className:`detail-state-actions`,children:[(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:e.onOpenTutorial,children:`打开导出教程`}),(0,L.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:e.onOpenSettings,children:`前往 Cookies 设置`})]}):null]})})}function XX({active:e,tab:t}){let n=`detail-tab-icon ${e?`is-active`:``}`;return t===`knowledge`?(0,L.jsx)(dZ,{className:n}):t===`summary`?(0,L.jsx)(rZ,{className:n}):(0,L.jsx)(sZ,{className:n})}function ZX(e){return(0,L.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}function QX(e){return(0,L.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function $X(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`m10 8 6 4-6 4z`})]})}function eZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M12 7v5l3 2`})]})}function tZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function nZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M20 4v6h-6`}),(0,L.jsx)(`path`,{d:`M4 20v-6h6`}),(0,L.jsx)(`path`,{d:`M7 17a8 8 0 0 0 13-5`}),(0,L.jsx)(`path`,{d:`M17 7A8 8 0 0 0 4 12`})]})}function rZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M9 13h6M9 17h6M9 9h2`})]})}function iZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M9 9h2M9 13h6`}),(0,L.jsx)(`path`,{d:`M9 17a3 3 0 1 0 3-3`}),(0,L.jsx)(`path`,{d:`M13.75 15.5H12v-1.75`})]})}function aZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M4 12a8 8 0 0 1 13-6`}),(0,L.jsx)(`path`,{d:`M20 12a8 8 0 0 1-13 6`}),(0,L.jsx)(`path`,{d:`M17 3v5h-5`}),(0,L.jsx)(`path`,{d:`M7 21v-5h5`}),(0,L.jsx)(`path`,{d:`M9 10.5a3 3 0 0 1 6 0c0 2.2-3 2.2-3 4.5`}),(0,L.jsx)(`path`,{d:`M12 18h.01`})]})}function oZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M12 3.75a1.5 1.5 0 0 1 1.471 1.206l.167.835a6.954 6.954 0 0 1 1.309.544l.716-.46a1.5 1.5 0 0 1 1.867.195l.8.8a1.5 1.5 0 0 1 .195 1.867l-.46.716c.224.417.406.856.544 1.309l.835.167A1.5 1.5 0 0 1 20.25 12a1.5 1.5 0 0 1-1.206 1.471l-.835.167a6.954 6.954 0 0 1-.544 1.309l.46.716a1.5 1.5 0 0 1-.195 1.867l-.8.8a1.5 1.5 0 0 1-1.867.195l-.716-.46a6.954 6.954 0 0 1-1.309.544l-.167.835A1.5 1.5 0 0 1 12 20.25a1.5 1.5 0 0 1-1.471-1.206l-.167-.835a6.954 6.954 0 0 1-1.309-.544l-.716.46a1.5 1.5 0 0 1-1.867-.195l-.8-.8a1.5 1.5 0 0 1-.195-1.867l.46-.716a6.954 6.954 0 0 1-.544-1.309l-.835-.167A1.5 1.5 0 0 1 3.75 12a1.5 1.5 0 0 1 1.206-1.471l.835-.167c.138-.453.32-.892.544-1.309l-.46-.716a1.5 1.5 0 0 1 .195-1.867l.8-.8a1.5 1.5 0 0 1 1.867-.195l.716.46a6.954 6.954 0 0 1 1.309-.544l.167-.835A1.5 1.5 0 0 1 12 3.75Z`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3.25`})]})}function sZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M4 12v7a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-7`}),(0,L.jsx)(`path`,{d:`M12 16V4`}),(0,L.jsx)(`path`,{d:`m7 9 5-5 5 5`})]})}function cZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M12 12V6`}),(0,L.jsx)(`path`,{d:`m9.5 9.5 2.5-2.5 2.5 2.5`}),(0,L.jsx)(`path`,{d:`M9 16h6`})]})}function lZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M3 7.5A1.5 1.5 0 0 1 4.5 6h4l1.6 2H19.5A1.5 1.5 0 0 1 21 9.5v7A1.5 1.5 0 0 1 19.5 18h-15A1.5 1.5 0 0 1 3 16.5z`}),(0,L.jsx)(`path`,{d:`M3 10h18`}),(0,L.jsx)(`path`,{d:`m13 14 2-2 2 2`}),(0,L.jsx)(`path`,{d:`M17 12v5`})]})}function uZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`rect`,{x:`3.5`,y:`6.5`,width:`13`,height:`13`,rx:`2.5`}),(0,L.jsx)(`path`,{d:`M9 6V5.5A2.5 2.5 0 0 1 11.5 3H18a2.5 2.5 0 0 1 2.5 2.5V12`}),(0,L.jsx)(`path`,{d:`m6.5 16.5 3.4-3.4a1.3 1.3 0 0 1 1.84 0l1.26 1.26`}),(0,L.jsx)(`path`,{d:`m12.5 15.5 1.4-1.4a1.3 1.3 0 0 1 1.84 0l.76.76`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`10.5`,r:`1.1`})]})}function dZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M12 5a3 3 0 0 0-3 3v1H8a3 3 0 0 0 0 6h1v1a3 3 0 0 0 6 0v-1h1a3 3 0 0 0 0-6h-1V8a3 3 0 0 0-3-3Z`}),(0,L.jsx)(`path`,{d:`M12 2v3M12 19v3M4.5 12H8M16 12h3.5`})]})}function fZ(e){return(0,L.jsxs)(`svg`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.8`,viewBox:`0 0 24 24`,...e,children:[(0,L.jsx)(`path`,{d:`M5 12h14`}),(0,L.jsx)(`path`,{d:`m13 6 6 6-6 6`})]})}var pZ=`bilisum.promptPresetId`;function mZ(e){return e instanceof fr||e instanceof Error&&e.name===`AuthRequiredError`||e instanceof Error&&/访问密钥|unauthorized|401/i.test(e.message)}function hZ(){if(typeof window>`u`)return null;let e=window.location.hash.match(/[#&]token=([^&]+)/);return e?decodeURIComponent(e[1]):null}function gZ(){typeof window>`u`||window.history.replaceState(window.history.state,``,window.location.pathname+window.location.search)}function _Z(){let e=it(),t=st(),[n,r]=(0,S.useState)(Gn),[i,a]=(0,S.useState)({version:``,backend:null,logPath:``}),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(`all`),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(!1),[v,y]=(0,S.useState)(null),[b,x]=(0,S.useState)([]),[C,w]=(0,S.useState)(0),[T,E]=(0,S.useState)(0),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(null),[j,ee]=(0,S.useState)(()=>{if(typeof window>`u`)return!1;let e=localStorage.getItem(`theme`);return e===`dark`?!0:e===`light`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}),[M,te]=(0,S.useState)(()=>typeof window>`u`?!1:localStorage.getItem(`sidebar-collapsed`)===`true`),[ne,N]=(0,S.useState)(!1),[P,re]=(0,S.useState)(!1),[ie,ae]=(0,S.useState)(!1),[oe,F]=(0,S.useState)(()=>!!window.desktop),[se,ce]=(0,S.useState)(``),[le,ue]=(0,S.useState)(``),[de,fe]=(0,S.useState)(!1),[pe,me]=(0,S.useState)(null),[he,ge]=(0,S.useState)(!1),[_e,ve]=(0,S.useState)(!1),[ye,be]=(0,S.useState)(!1),xe=(0,S.useRef)(!1),[Se,Ce]=(0,S.useState)(()=>!Rx());(0,S.useEffect)(()=>{e.pathname===`/`&&!Rx()&&Ce(!0)},[e.pathname]);let[we,Te]=(0,S.useState)({status:`idle`,version:``,releaseDate:``,releaseNotes:null,downloadProgress:0,errorMessage:null}),Ee=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=!1;async function t(){if(window.desktop){try{await I.createAuthSession(await window.desktop.backend.getAccessToken())}catch{}e||(F(!0),ae(!0));return}let t=hZ();if(t){try{let n=await I.createAuthSession(t);e||(F(!!n.authenticated),ae(!0))}catch{e||(F(!1),ae(!0))}gZ();return}try{let t=await I.getAuthStatus();e||(F(!!t.authenticated),ae(!0))}catch{e||(F(!1),ae(!0))}}return t(),()=>{e=!0}},[]),(0,S.useEffect)(()=>{let e=j?`dark`:`light`;document.documentElement.setAttribute(`data-theme`,e),localStorage.setItem(`theme`,e),window.desktop?.preferences?.setTheme?.(e)},[j]),(0,S.useEffect)(()=>{localStorage.setItem(`sidebar-collapsed`,M?`true`:`false`)},[M]),(0,S.useEffect)(()=>{let e,t,n=!1;async function r(){if(!window.desktop)return;let[r,i,o,s,c]=await Promise.all([window.desktop.app.getVersion(),window.desktop.backend.status(),window.desktop.logs.getServiceLogPath(),window.desktop.update?.getStatus?.()??Promise.resolve(null),window.desktop.app.getStartupAnnouncement?.()??Promise.resolve(null)]);n||(a({version:r,backend:i,logPath:o}),me(c),s&&Te(tr(s)),e=window.desktop.backend.onStatus(e=>a(t=>({...t,backend:e}))),t=window.desktop.update?.onStatus(e=>{Te(tr(e))}))}return r(),()=>{n=!0,e?.(),t?.()}},[]),(0,S.useEffect)(()=>{let e=!1;async function t(){if(oe)try{let[t,n,i]=await Promise.all([I.getHealth(),I.getSettings(),I.getVideoLibrary()]);e||r(e=>({...e,serviceOnline:t.status===`ok`,settings:n,videos:i.videos,folders:i.folders,libraryPreferences:i.preferences,error:``}));try{let n=await I.getSystemInfo();if(!e){let e=n.runtimeStartup?.status,i=n.environment??n.runtimeStartup?.environment??null,a=e===`initializing`||i?.runtimeReady===!1;r(e=>({...e,serviceOnline:t.status===`ok`,systemInfo:n,environment:i,error:``,runtimeInitializing:a}))}}catch{e||r(e=>({...e,serviceOnline:t.status===`ok`,error:e.error,runtimeInitializing:!0}))}}catch(t){if(!e){if(mZ(t)){F(!1),ue(``);return}r(e=>({...e,serviceOnline:!1,error:t instanceof Error?t.message:`服务暂不可用`,runtimeInitializing:!1}))}}}t();let n=window.setInterval(()=>void t(),8e3);return()=>{e=!0,window.clearInterval(n)}},[oe,C]);async function De(e){e.preventDefault();let t=se.trim();if(!t){ue(`请输入访问密钥。`);return}fe(!0),ue(``);try{F(!!(await I.createAuthSession(t)).authenticated),ce(``),w(e=>e+1)}catch(e){ue(e instanceof Error?e.message:`访问密钥无效。`)}finally{fe(!1)}}function Oe(){re(!0)}function ke(){re(!1)}async function Ae(){let e=pe;me(null),e&&await window.desktop?.app.markStartupAnnouncementSeen?.(e.version)}let je=(0,S.useMemo)(()=>nr(we),[we]);(0,S.useEffect)(()=>{je&&re(!0)},[je]);async function Me(){if(!window.desktop?.update){let e=await I.getAppUpdate();return Te(tr(e)),e}let e=await window.desktop.update.check();return Te(tr(e)),e}async function Ne(){if(!window.desktop?.update)throw Error(`当前环境不支持桌面自动更新。`);let e=await window.desktop.update.download();return Te(tr(e)),e}async function Pe(){if(!window.desktop?.update)throw Error(`当前环境不支持桌面自动更新。`);await window.desktop.update.install()}let Fe=(0,S.useMemo)(()=>[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime())[0]??null,[n.videos]),Ie=(0,S.useMemo)(()=>{let e=n.videos.filter(e=>e.is_favorite).length,t=n.videos.filter(e=>e.latest_status===`completed`).length,r=n.videos.filter(e=>e.latest_status===`running`).length,i=n.videos.filter(e=>e.has_result).length;return{total:n.videos.length,favorite:e,completed:t,running:r,withResult:i}},[n.videos]),Le=(0,S.useMemo)(()=>{let e=o.trim().toLowerCase();return[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).filter(t=>e?t.title.toLowerCase().includes(e)||t.source_url.toLowerCase().includes(e):!0).filter(e=>c===`favorite`?e.is_favorite:c===`completed`?e.latest_status===`completed`:c===`running`?e.latest_status===`running`:c===`with-result`?e.has_result:!0)},[c,o,n.videos]),Re=(0,S.useMemo)(()=>[...n.videos].filter(e=>e.is_favorite).sort((e,t)=>{let n=new Date(e.favorite_updated_at||e.updated_at).getTime();return new Date(t.favorite_updated_at||t.updated_at).getTime()-n}),[n.videos]),ze=(0,S.useMemo)(()=>[...n.videos].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,6),[n.videos]);async function Be(e,t){let i=n.videos,a=t?new Date().toISOString():null;r(n=>({...n,videos:n.videos.map(n=>n.video_id===e?{...n,is_favorite:t,favorite_updated_at:a}:n)}));try{let n=await I.setVideoFavorite(e,{is_favorite:t});r(t=>({...t,videos:t.videos.map(t=>t.video_id===e?{...t,...n}:t)}))}catch(e){throw r(e=>({...e,videos:i})),e}}let Ve=(0,S.useMemo)(()=>Qn({transcriptionProvider:n.settings?.transcription_provider,whisperDevice:n.settings?.whisper_device,cudaAvailable:n.environment?.cudaAvailable,hasSettings:!!n.settings}),[n.environment?.cudaAvailable,n.settings]),He=(0,S.useMemo)(()=>$n(n.settings,n.environment),[n.environment,n.settings]),Ue=i.version||n.systemInfo?.application?.version||`-`,We=n.systemInfo?.runtimeStartup?.status,Ge=We===`ready`||!!n.environment&&n.environment?.runtimeReady!==!1&&!n.runtimeInitializing,Ke=(0,S.useMemo)(()=>n.runtimeInitializing?`运行环境准备中`:We===`error`?`运行环境异常`:n.environment?.runtimeReady===!1?`运行环境未就绪`:n.environment?`运行环境就绪`:n.serviceOnline?`检测中`:`等待服务`,[We,n.environment,n.runtimeInitializing,n.serviceOnline]);(0,S.useEffect)(()=>{if(!er(He,n.settings)){xe.current||ge(!1),be(!1);return}xe.current=!1,ye||ge(!0)},[He,ye,n.settings]);function qe(e){xe.current=!1,ge(!1),be(!0),O({issueKey:e,nonce:Date.now()}),t(`/settings`)}function Je(e){xe.current=!1,ge(!1),A({presetId:e,nonce:Date.now()}),t(`/settings`)}async function Ye(e){let t=await I.updateSettings({prompt_router_mode:e});r(e=>({...e,settings:t.settings,systemInfo:e.systemInfo?{...e.systemInfo,settings:t.settings}:e.systemInfo}))}function Xe(e){r(t=>{let n=new Map(e.map(e=>[e.video_id,e]));return{...t,videos:t.videos.map(e=>n.get(e.video_id)||e)}})}async function Ze(){let e=await I.getVideoLibrary();return r(t=>({...t,videos:e.videos,folders:e.folders,libraryPreferences:e.preferences})),e}async function Qe(e,t){let n=await I.createVideoFolder({name:e,parent_id:t??null});return r(e=>({...e,folders:[n,...e.folders]})),n}async function $e(e,t){let n=await I.updateVideoFolder(e,t);return r(t=>({...t,folders:t.folders.map(t=>t.folder_id===e?n:t)})),n}async function et(e){await I.deleteVideoFolder(e),await Ze()}async function tt(e,t,n){let r=await I.moveVideoToFolder(e,n?{folder_ids:n}:{folder_id:t??null});return Xe([r]),r}async function nt(e){let t=n.videos;r(t=>({...t,videos:t.videos.filter(t=>t.video_id!==e)}));try{await I.deleteVideo(e)}catch(e){throw r(e=>({...e,videos:t})),e}}async function rt(e,t){let n=await I.setVideoPin(e,t);return Xe([n]),n}async function at(e,t){Xe(await I.reorderVideos({video_ids:e,folder_id:t??null}))}async function ot(e){let t=await I.updateVideoLibraryPreferences({new_video_position:e});r(e=>({...e,libraryPreferences:t}))}function ct(e){if(e){qe(e);return}if(er(He,n.settings)){be(!1),ge(!0);return}t(`/settings`)}function lt(){xe.current=!1,ge(!1),be(!0)}function ut(){xe.current=!1,ge(!1);let e=He.blockingIssues[0]?.key||He.issues[0]?.key;if(e){qe(e);return}t(`/settings`)}function dt(e){return/HTTP\s*412|cookies?\.txt|B\s*站返回|Bilibili rejected|风控拦截|登录态|cookiesfrombrowser|DPAPI/i.test(e)}function ft(e){p(e||`B 站请求被拦截,请导出登录态 cookies 后重试。`),ve(!0)}function pt(){window.open(`https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp`,`_blank`,`noopener,noreferrer`)}function mt(){ve(!1),O({issueKey:`ytdlp_cookies_file`,nonce:Date.now()}),t(`/settings`)}async function ht(){try{let e=u.trim();if(!window.desktop?.bilibili){p(`当前环境不支持打开 B 站登录窗口,请按教程手动导出 cookies.txt。`);return}p(`请在新窗口登录 B 站,登录成功后会自动保存 cookies...`);let t=await window.desktop.bilibili.captureLoginCookies(),n=await I.updateSettings({ytdlp_cookies_file:t.cookiesFile,ytdlp_cookies_browser:``});r(e=>({...e,settings:n.settings,systemInfo:e.systemInfo?{...e.systemInfo,settings:n.settings}:e.systemInfo})),e?(await I.probeVideo({url:e,force_refresh:!0}),p(`B 站登录态已保存,捕获 ${t.cookieCount} 条 cookies。可以重新提交任务。`)):p(`B 站登录态已保存,捕获 ${t.cookieCount} 条 cookies。重新提交任务即可。`),ve(!1)}catch(e){p(e instanceof Error?e.message:`捕获 B 站登录态失败,请按教程手动导出 cookies.txt。`),ve(!0)}}function gt(){try{let e=window.localStorage.getItem(`bilisum.summaryPreference`);return e?JSON.parse(e).noteMode===`visual`?`frame_insert`:`text`:null}catch{return null}}function _t(){try{let e=window.localStorage.getItem(pZ)?.trim();return e&&e!==`general`?e:null}catch{return null}}async function vt(e){if((n.settings?.prompt_router_mode||`confirm`)!==`auto`)return _t();let t=e?.trim();if(!t)return null;try{let e=await I.matchPrompt(t);return e.preset.id&&e.preset.id!==`general`?e.preset.id:null}catch{return null}}async function yt(e,t){return{page_number:e??null,visual_note_mode:gt(),prompt_preset_id:await vt(t)}}async function bt(e,t){try{p(`正在匹配摘要 Prompt 并创建任务...`),await I.createVideoTask(e.video_id,await yt(null,t||e.title||e.source_url)),p(`视频已加入本地库并开始总结`),w(e=>e+1),E(e=>e+1)}catch(e){let t=e instanceof Error?e.message:`创建摘要任务失败`;if(dt(t)){ft(t);return}p(t)}}async function xt(e){if(e.preventDefault(),!u.trim()){p(`请输入 Bilibili / YouTube 视频链接,或直接输入 BV 号`);return}if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}p(`正在抓取视频信息并准备开始总结...`);try{let e=await I.probeVideo({url:u.trim(),force_refresh:!1});if(h(e.video),e.requires_selection&&e.pages.length>0){y(e.video),x(e.pages.map(e=>({...e,aggregate_status:`not_started`,has_completed_result:!1}))),_(!0),p(`检测到 ${e.pages.length} 个分 P,请先勾选要处理的内容`);return}p(e.cached?`已从视频库读取,正在进入详情页...`:`视频已加入本地库,正在进入详情页...`);let n=u.trim();d(``),w(e=>e+1),t(`/videos/${e.video.video_id}`),bt(e.video,e.video.title||n)}catch(e){let t=e instanceof Error?e.message:`开始总结失败`;if(dt(t)){ft(t);return}p(t)}}async function St(e){if(e.length){p(e.length>1?`正在读取 ${e.length} 个本地媒体文件并创建任务...`:`正在读取本地媒体信息并准备开始总结...`);try{let n=[];for(let t of e){let e=await I.probeVideo({url:t,force_refresh:!1});n.push(e)}let r=n[0];if(!r)throw Error(`未返回本地媒体信息。`);h(r.video),d(``),p(n.length>1?`已读取 ${n.length} 个本地媒体文件,正在后台创建摘要任务...`:r.cached?`已从本地媒体库读取,正在进入详情页...`:`本地媒体已加入视频库,正在进入详情页...`),w(e=>e+1),t(`/videos/${r.video.video_id}`),Promise.all(n.map(e=>bt(e.video,e.video.title||e.video.source_url)))}catch(e){let t=e instanceof Error?e.message:`导入本地媒体失败`;if(dt(t)){ft(t);return}p(t)}}}async function Ct(){if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}if(window.desktop?.media){await St(window.desktop.media.pickVideoFiles?await window.desktop.media.pickVideoFiles():[await window.desktop.media.pickVideoFile()].filter(e=>!!e));return}Ee.current?.click()}async function wt(e){let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&await Tt(t)}async function Tt(e){if(e.length){if(He.hasBlockingIssues){p(`当前缺少必需配置:${He.blockingIssues.map(e=>e.title).join(`、`)}。请先完成设置。`),er(He,n.settings)?(be(!1),ge(!0)):t(`/settings`);return}p(e.length>1?`正在上传 ${e.length} 个本地媒体文件并创建任务...`:`正在上传本地媒体并准备开始总结...`);try{let n=e.length>1?await I.uploadBatchVideos(e):[await I.uploadLocalVideo(e[0])],r=n[0];if(!r)throw Error(`未返回上传结果。`);h(r.video),d(``),p(n.length>1?`已上传 ${n.length} 个本地媒体文件,正在后台创建摘要任务...`:r.cached?`已从本地媒体库读取,正在进入详情页...`:`本地媒体已加入视频库,正在进入详情页...`),w(e=>e+1),t(`/videos/${r.video.video_id}`),Promise.all(n.map(e=>bt(e.video,e.video.title||e.video.source_url)))}catch(e){let t=e instanceof Error?e.message:`导入本地媒体失败`;if(dt(t)){ft(t);return}p(t)}}}async function Et(e){if(!v)throw Error(`当前视频信息已失效,请重新探测。`);let n=v;p(e.confirm?`正在确认批量任务...`:`正在进入详情页并准备批量任务...`),h(n),d(``),w(e=>e+1),t(`/videos/${n.video_id}`);let r=await vt(n.title||n.source_url),i=await I.createVideoTasksBatch(n.video_id,{page_numbers:e.pageNumbers,confirm:e.confirm,prompt_preset_id:r});if(i.requires_confirmation)return p(`所选内容中有 ${i.conflict_pages.length} 个分 P 已有成功摘要,请确认后继续。`),i;_(!1),y(null),x([]);let a=i.created_tasks.length,o=i.skipped_pages.length;return p(a>0?`已创建 ${a} 个批量任务${o?`,跳过 ${o} 个已完成分 P`:``}`:`没有创建新任务${o?`,已跳过 ${o} 个分 P`:``}`),w(e=>e+1),E(e=>e+1),i}function Dt(){_(!1),y(null),x([])}e.pathname.startsWith(`/settings`)||e.pathname.startsWith(`/library`)||e.pathname.startsWith(`/videos/`);let Ot=e.pathname.startsWith(`/settings`);e.pathname.startsWith(`/library`);let kt=!!window.desktop?.update&&!rr(we),At=!!window.desktop?.media||typeof window<`u`;if(!window.desktop&&ie&&!oe)return(0,L.jsx)(yZ,{token:se,error:le,submitting:de,onTokenChange:ce,onSubmit:De});if(!window.desktop&&!ie)return(0,L.jsx)(`div`,{className:`auth-shell`,children:(0,L.jsxs)(`section`,{className:`auth-panel`,children:[(0,L.jsxs)(`div`,{className:`auth-brand`,children:[(0,L.jsx)(`img`,{src:`/static/assets/icons/icon.svg`,alt:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`BiliSum`}),(0,L.jsx)(`h1`,{children:`正在检查访问权限`})]})]}),(0,L.jsx)(`p`,{className:`auth-muted`,children:`请稍候。`})]})});let jt=typeof window<`u`&&window.desktop?.window?.platform===`darwin`;return(0,L.jsxs)(`div`,{className:`app-shell ${M?`sidebar-collapsed`:``} ${ne?`mobile-sidebar-open`:``} ${jt?`is-macos`:``}`,children:[(0,L.jsx)(`input`,{ref:Ee,type:`file`,multiple:!0,accept:`video/mp4,video/quicktime,video/x-matroska,video/x-msvideo,video/x-ms-wmv,video/webm,video/x-flv,video/mp2t,video/mpeg,audio/mpeg,audio/wav,audio/x-wav,audio/mp4,audio/aac,audio/flac,audio/ogg,.mp4,.mov,.mkv,.avi,.wmv,.webm,.flv,.m4v,.ts,.mpeg,.mpg,.mp3,.wav,.m4a,.aac,.flac,.ogg`,style:{display:`none`},onChange:e=>void wt(e)}),(0,L.jsx)(jx,{darkMode:j,onToggleTheme:()=>ee(e=>!e),serviceOnline:n.serviceOnline,backendRunning:i.backend?.running,runtimeDeviceLabel:Ve,runtimeReady:Ge,runtimeStatusText:Ke,version:Ue,updateState:we,configHealth:He,onOpenSettings:ct,onOpenUpdateDialog:Oe}),(0,L.jsxs)(`aside`,{className:`sidebar`,children:[(0,L.jsxs)(`nav`,{className:`nav`,children:[(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/`?`active`:``}`,to:`/`,"aria-label":`首页`,title:`首页`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(jr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`首页`}),(0,L.jsx)(`small`,{children:`工作台总览`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/library`?`active`:``}`,to:`/library`,"aria-label":`视频库`,title:`视频库`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Dr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`视频库`}),(0,L.jsx)(`small`,{children:`资产管理`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname===`/knowledge`?`active`:``}`,to:`/knowledge`,"aria-label":`知识库`,title:`知识库`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(kr,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`知识库`}),(0,L.jsx)(`small`,{children:`检索与问答`})]})]}),(0,L.jsxs)(En,{className:`nav-item ${e.pathname.startsWith(`/settings`)?`active`:``}`,to:`/settings`,"aria-label":`设置`,title:`设置`,onClick:()=>N(!1),children:[(0,L.jsx)(`span`,{className:`nav-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Ar,{})}),(0,L.jsxs)(`span`,{className:`nav-copy`,children:[(0,L.jsx)(`strong`,{children:`设置`}),(0,L.jsx)(`small`,{children:`运行配置`})]})]})]}),(0,L.jsx)(`div`,{className:`nav-section-divider`}),(0,L.jsx)(`button`,{className:`sidebar-corner-toggle`,type:`button`,onClick:()=>te(e=>!e),"aria-label":M?`展开侧边栏`:`收起侧边栏`,"aria-pressed":M,title:M?`展开侧边栏`:`收起侧边栏`,children:(0,L.jsx)(vZ,{collapsed:M})})]}),(0,L.jsx)(`button`,{className:`mobile-menu-toggle`,type:`button`,onClick:()=>N(!0),"aria-label":`打开菜单`,title:`打开菜单`,children:(0,L.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,L.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,L.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]})}),ne&&(0,L.jsx)(`div`,{className:`mobile-sidebar-overlay`,onClick:()=>N(!1),onKeyDown:e=>{e.key===`Escape`&&N(!1)},role:`button`,tabIndex:0,"aria-label":`关闭菜单`}),(0,L.jsx)(`main`,{className:`content`,children:(0,L.jsx)(`div`,{className:`content-frame ${Ot?`content-frame-settings`:``}`,children:n.error&&!n.serviceOnline?(0,L.jsxs)(`section`,{className:`grid-card empty-state-card`,children:[(0,L.jsx)(`div`,{className:`spinner`}),(0,L.jsx)(`h3`,{children:`后端暂未就绪`}),(0,L.jsx)(`p`,{children:n.error}),(0,L.jsxs)(`div`,{className:`desktop-actions`,children:[(0,L.jsx)(`button`,{className:`primary-button`,type:`button`,onClick:async()=>{await window.desktop?.backend.start(),w(e=>e+1)},children:`重新拉起后端`}),(0,L.jsx)(`button`,{className:`secondary-button`,type:`button`,onClick:()=>w(e=>e+1),children:`重新检测`})]})]}):(0,L.jsxs)(Ft,{children:[(0,L.jsx)(Nt,{path:`/`,element:(0,L.jsx)(nS,{configHealth:He,probePreview:m,probeUrl:u,setProbeUrl:d,submitStatus:f,onProbe:xt,onImportLocalVideo:Ct,onImportLocalFiles:Tt,onImportLocalPaths:St,canImportLocalVideo:At,promptRouterMode:n.settings?.prompt_router_mode||`confirm`,onPromptRouterModeChange:Ye,onOpenSetupAssistant:ct,onOpenConfigIssue:qe,onEditPromptPreset:Je,favoriteVideos:Re,recentVideos:ze,onToggleFavorite:Be})}),(0,L.jsx)(Nt,{path:`/library`,element:(0,L.jsx)(eq,{snapshot:n,filteredVideos:Le,libraryCounts:Ie,latestVideo:Fe,query:o,setQuery:s,activeFilter:c,setLibraryFilter:l,serviceOnline:n.serviceOnline,runtimeDeviceLabel:Ve,onToggleFavorite:Be,onCreateFolder:Qe,onUpdateFolder:$e,onDeleteFolder:et,onDeleteVideo:nt,onMoveVideo:tt,onSetVideoPin:rt,onReorderVideos:at,onUpdateLibraryPreferences:ot})}),(0,L.jsx)(Nt,{path:`/knowledge`,element:(0,L.jsx)(VP,{})}),(0,L.jsx)(Nt,{path:`/videos/:videoId`,element:(0,L.jsx)(MX,{refreshToken:T,onRefresh:()=>w(e=>e+1),onOpenCookieSettings:mt,onOpenCookieTutorial:pt,onCaptureLoginCookies:ht})}),(0,L.jsx)(Nt,{path:`/settings`,element:(0,L.jsx)(sJ,{desktop:i,onOpenUpdateDialog:Oe,onCheckUpdate:Me,onDownloadUpdate:Ne,onInstallUpdate:Pe,onOpenSetupAssistant:()=>{xe.current=!0,be(!1),ge(!0),t(`/`)},onRefresh:()=>w(e=>e+1),onSettingsSaved:(e,t)=>{r(n=>({...n,settings:e,environment:t??n.environment,systemInfo:n.systemInfo?{...n.systemInfo,settings:e,environment:t??n.systemInfo.environment}:n.systemInfo}))},snapshot:n,focusIssueRequest:D,promptPresetRequest:k,updateInfo:we,canCheckUpdate:!0,canInstallUpdate:kt})})]})})}),(0,L.jsx)(Mx,{isOpen:P,updateInfo:we,currentVersion:Ue,canInstallUpdate:kt,onClose:ke,onCheck:Me,onDownload:Ne,onInstall:Pe}),(0,L.jsx)(Ax,{announcement:pe,onClose:()=>void Ae()}),(0,L.jsx)(gi,{isOpen:g,mode:`create`,video:v,pages:b,onClose:Dt,onSubmit:Et}),(0,L.jsx)(_i,{isOpen:he,force:xe.current,configHealth:He,onClose:lt,onOpenSettings:ut,onNavigateToIssue:qe}),(0,L.jsx)(Hr,{isOpen:_e,onClose:()=>ve(!1),onOpenTutorial:pt,onOpenSettings:mt,onCaptureLoginCookies:ht}),Se&&e.pathname===`/`&&!He.hasBlockingIssues?(0,L.jsx)(Lx,{onClose:()=>Ce(!1)}):null]})}function vZ({collapsed:e}){return(0,L.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`rect`,{x:`3.5`,y:`4.5`,width:`17`,height:`15`,rx:`2.5`}),(0,L.jsx)(`path`,{d:`M9 4.5v15`}),e?(0,L.jsx)(`path`,{d:`m13.5 12 3-3m-3 3 3 3`}):(0,L.jsx)(`path`,{d:`m15.5 12-3-3m3 3-3 3`})]})}function yZ({token:e,error:t,submitting:n,onTokenChange:r,onSubmit:i}){return(0,L.jsx)(`div`,{className:`auth-shell`,children:(0,L.jsxs)(`section`,{className:`auth-panel`,children:[(0,L.jsxs)(`div`,{className:`auth-brand`,children:[(0,L.jsx)(`img`,{src:`/static/assets/icons/icon.svg`,alt:``}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{children:`BiliSum`}),(0,L.jsx)(`h1`,{children:`输入访问密钥`})]})]}),(0,L.jsxs)(`p`,{className:`auth-muted`,children:[`Web 端访问需要 BiliSum 服务密钥。桌面端会自动注入密钥;Docker 或 npx 部署可通过`,` `,(0,L.jsx)(`code`,{children:`VIDEO_SUM_ACCESS_TOKEN`}),` `,`配置。`]}),(0,L.jsxs)(`form`,{className:`auth-form`,onSubmit:i,children:[(0,L.jsx)(`label`,{htmlFor:`access-token`,children:`访问密钥`}),(0,L.jsx)(`input`,{id:`access-token`,type:`password`,value:e,autoComplete:`current-password`,autoFocus:!0,onChange:e=>r(e.target.value)}),t?(0,L.jsx)(`p`,{className:`auth-error`,children:t}):null,(0,L.jsx)(`button`,{type:`submit`,disabled:n,children:n?`正在验证...`:`进入 BiliSum`})]})]})})}Wn.createRoot(document.getElementById(`root`)).render((0,L.jsx)(S.StrictMode,{children:(0,L.jsx)(Cn,{children:(0,L.jsx)(_Z,{})})}));
@@ -28,7 +28,7 @@
28
28
  :root[data-theme="light"] { --bg-base: #fafbfc; --bg-card: #ffffff; }
29
29
  html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg-base); }
30
30
  </style>
31
- <script type="module" crossorigin src="/static/assets/index-POgEkQWf.js"></script>
31
+ <script type="module" crossorigin src="/static/assets/index-DHuJPoLi.js"></script>
32
32
  <link rel="stylesheet" crossorigin href="/static/assets/index-S9QooflZ.css">
33
33
  </head>
34
34
  <body>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "video-sum-core"
7
- version = "1.20.0-alpha.2"
7
+ version = "1.20.0-alpha.3"
8
8
  description = "Core domain logic for the local video summarizer."
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "video-sum-infra"
7
- version = "1.20.0-alpha.2"
7
+ version = "1.20.0-alpha.3"
8
8
  description = "Infrastructure layer for the local video summarizer."
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [