stratagate-dsh 0.3.46 → 0.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +2 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -322,7 +322,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
322
322
|
\r
|
|
323
323
|
`,STAR_REPOSITORY_URL="https://github.com/diqierjia/StrataGate-AgentMemory",ISSUE_URL=STAR_REPOSITORY_URL+"/issues/new",DISCUSSION_URL=STAR_REPOSITORY_URL+"/discussions/categories/q-a",FEEDBACK_AI_PROMPT="\u8BF7\u6839\u636E\u5F53\u524D\u4F1A\u8BDD\u4E2D StrataGate \u63D2\u4EF6\u7684\u6545\u969C\u3001\u4F7F\u7528\u7591\u95EE\u6216\u6539\u8FDB\u5EFA\u8BAE\u6574\u7406\u53CD\u9988\u3002\u53EA\u7528\u5DF2\u77E5\u4E8B\u5B9E\uFF0C\u4E0D\u8981\u731C\u6D4B\uFF0C\u672A\u77E5\u7559\u7A7A\uFF0C\u53BB\u9664\u51ED\u636E\u3002\u8C03\u7528 feedback_prepare \u4FDD\u5B58\u672C\u5730\u8349\u7A3F\uFF1B\u65B0\u95EE\u9898\u4F20 new_draft=true\u3002\u8BCA\u65AD\u7531\u7A0B\u5E8F\u81EA\u52A8\u8865\u5145\u3002\u7ED9\u6211\u201C\u6253\u5F00\u53CD\u9988\u8349\u7A3F\u201D\u7684\u94FE\u63A5\uFF0C\u6211\u4F1A\u68C0\u67E5\u540E\u624B\u52A8\u53D1\u90AE\u4EF6\u3002",FEEDBACK_SETTINGS_ID="stratagate-memory",FEEDBACK_VIEW_ID="feedback",MEMORY_PANEL_ID="stratagate-memory",SIDEBAR_PROMPT_STORAGE_KEY="stratagate-dsh.sidebar-prompt.v1",SIDEBAR_PROMPT_STYLES=".sg-sidebar-panel-icon{display:block;flex-shrink:0}.sg-sidebar-placement-prompt{display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;max-width:100%;font-size:11px;line-height:1.5;color:var(--sg-muted)}.sg-sidebar-placement-text{min-width:0}.sg-memory .sg-sidebar-placement-action{padding:0;border:0;background:transparent;color:var(--sg-accent);font-size:11px;line-height:1.5;cursor:pointer;white-space:nowrap}.sg-sidebar-placement-action:hover{text-decoration:underline}.sg-memory .sg-sidebar-placement-close{display:inline-grid;place-items:center;width:20px;height:20px;flex:none;padding:0;border:0;border-radius:4px;background:transparent;color:var(--sg-muted);font-size:15px;line-height:1;cursor:pointer}.sg-sidebar-placement-close:hover{background:var(--sg-soft);color:var(--sg-text)}",pendingFeedbackNavigation=null,feedbackNavigationListeners=new Set;function setFeedbackNavigation(state){pendingFeedbackNavigation=state;for(let listener of feedbackNavigationListeners)listener(state);feedbackNavigationListeners.size&&(pendingFeedbackNavigation=null)}function FeedbackSettingsPage(props){let[navigationState,setNavigationState]=React.useState(()=>pendingFeedbackNavigation);return React.useEffect(()=>(feedbackNavigationListeners.add(setNavigationState),pendingFeedbackNavigation&&setNavigationState(pendingFeedbackNavigation),pendingFeedbackNavigation=null,()=>feedbackNavigationListeners.delete(setNavigationState)),[]),h(MemoryPage,{...props,navigationState:navigationState||props.navigationState})}let ISSUE_BODY_HINT=`> \u8BF7\u5728\u4E0B\u65B9\u7C98\u8D34 StrataGate \u53CD\u9988\u62A5\u544A\uFF08Ctrl+V / \u2318V\uFF09\uFF0C\u68C0\u67E5\u540E\u63D0\u4EA4\u3002\u82E5\u65E0\u6CD5\u7C98\u8D34\uFF0C\u8BF7\u8FD4\u56DE StrataGate \u624B\u52A8\u590D\u5236\u62A5\u544A\u3002
|
|
324
324
|
|
|
325
|
-
`,STRATAGATE_CLIENT_VERSION="0.3.46",MEMORY_CITATIONS_KIND="stratagate-memory-citations",MEMORY_RETRIEVAL_TOOLS=new Set(["memory_search_events","memory_search_graph","memory_expand_graph_node","memory_search_elements","memory_search_raw","memory_get_blocks","memory_expand_block","memory_expand_event","memory_expand_element"]);function readFeedbackDeepLink(locationRef=window.location){let params=new URLSearchParams(String(locationRef?.search||""));if(params.get("settings")!==FEEDBACK_SETTINGS_ID||params.get("stratagateView")!==FEEDBACK_VIEW_ID)return null;let namespace=String(params.get("namespace")||"").trim();return namespace?{namespace}:null}function readFeedbackNavigationState(state){if(!state||state.view!==FEEDBACK_VIEW_ID)return null;let namespace=String(state.namespace||"").trim();return namespace?{namespace}:null}function readNewFeedbackNavigationState(previousState,state){return state===previousState?null:readFeedbackNavigationState(state)}function readGraphNodeNavigationState(state){if(!state||state.view!=="graph-node")return null;let namespace=String(state.namespace||"").trim(),nodeId=String(state.nodeId||"").trim();return namespace&&nodeId?{namespace,nodeId}:null}function readGraphNodeDeepLink(locationRef=window.location){let params=new URLSearchParams(String(locationRef?.search||""));if(params.get("settings")!==FEEDBACK_SETTINGS_ID||params.get("stratagateView")!=="graph-node")return null;let namespace=String(params.get("namespace")||"").trim(),nodeId=String(params.get("nodeId")||"").trim();return namespace&&nodeId?{namespace,nodeId}:null}function consumeFeedbackDeepLink(locationRef=window.location,historyRef=window.history){let params=new URLSearchParams(String(locationRef?.search||""));params.delete("settings"),params.delete("stratagateView"),params.delete("namespace");let search=params.toString(),next2=String(locationRef?.pathname||"/")+(search?"?"+search:"")+String(locationRef?.hash||"");return historyRef?.replaceState?.(historyRef.state,"",next2),next2}function consumeGraphNodeDeepLink(locationRef=window.location,historyRef=window.history){let params=new URLSearchParams(String(locationRef?.search||""));params.delete("settings"),params.delete("stratagateView"),params.delete("namespace"),params.delete("nodeId");let search=params.toString(),next2=String(locationRef?.pathname||"/")+(search?"?"+search:"")+String(locationRef?.hash||"");return historyRef?.replaceState?.(historyRef.state,"",next2),next2}function isDesktopFeedbackSurface(locationRef){try{let url=new URL(String(locationRef?.href||""));return url.protocol==="dsh-app:"&&url.hostname==="app"}catch{return!1}}function desktopFeedbackOrigin(value){try{let url=new URL(String(value||""));return url.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(url.hostname)&&!url.username&&!url.password&&url.pathname==="/"&&!url.search&&!url.hash?url.origin:""}catch{return""}}function feedbackAnchorTarget(target,locationRef){let anchor=target?.closest?.("a[href]")||target?.parentElement?.closest?.("a[href]");if(!anchor)return null;let url;try{url=new URL(String(anchor.getAttribute?.("href")||""),String(locationRef?.href||""))}catch{return null}return!readFeedbackDeepLink(url)||url.pathname!=="/"||url.username||url.password?null:{anchor,url}}function feedbackLinkTarget(target,locationRef=window.location,desktopHostOrigin=""){let match2=feedbackAnchorTarget(target,locationRef);return match2&&(match2.url.origin===String(locationRef?.origin||"")||isDesktopFeedbackSurface(locationRef)&&desktopFeedbackOrigin(desktopHostOrigin)===match2.url.origin)?match2:null}function navigateToFeedback(ctx,targetUrl,locationRef=window.location,allowHttpFallback=!0){let feedback=readFeedbackDeepLink(targetUrl);if(!feedback)return"ignored";let navigation=ctx?.get?.("settingsNavigation");if(typeof navigation?.openSection=="function")return navigation.openSection(FEEDBACK_SETTINGS_ID,{view:FEEDBACK_VIEW_ID,namespace:feedback.namespace}),"host";let shell=ctx?.get?.("slots")?.entries?.("sidebar.settings")?.find(entry=>typeof entry.store?.create=="function")?.store.create();return typeof shell?.actions?.openSection=="function"?(setFeedbackNavigation({view:FEEDBACK_VIEW_ID,namespace:feedback.namespace}),shell.actions.openSection(FEEDBACK_SETTINGS_ID),"host"):(allowHttpFallback&&locationRef.assign(targetUrl.href),"http")}function navigateToGraphNode(ctx,namespace,nodeId,locationRef=window.location,allowHttpFallback=!0){let targetNamespace=String(namespace||"").trim(),targetNodeId=String(nodeId||"").trim();if(!targetNamespace||!targetNodeId)return Promise.resolve(!1);let navigation=ctx?.get?.("settingsNavigation");if(typeof navigation?.openSection!="function"){if(!allowHttpFallback||typeof locationRef?.assign!="function")return Promise.resolve(!1);try{let targetUrl=new URL(String(locationRef.href||""));return targetUrl.searchParams.set("settings",FEEDBACK_SETTINGS_ID),targetUrl.searchParams.set("stratagateView","graph-node"),targetUrl.searchParams.set("namespace",targetNamespace),targetUrl.searchParams.set("nodeId",targetNodeId),locationRef.assign(targetUrl.href),Promise.resolve(!0)}catch{return Promise.resolve(!1)}}try{return Promise.resolve(navigation.openSection(FEEDBACK_SETTINGS_ID,{view:"graph-node",namespace:targetNamespace,nodeId:targetNodeId})).then(result=>result!==!1,()=>!1)}catch{return Promise.resolve(!1)}}function installFeedbackLinkNavigation(ctx,documentRef=document,locationRef=window.location){let desktop=isDesktopFeedbackSurface(locationRef),active=!0,desktopHostOrigin="",bootPending=desktop&&typeof window.dshDesktopBoot?.ready=="function",replayingAnchor=null,bootReady=bootPending?Promise.resolve().then(()=>window.dshDesktopBoot.ready()).then(boot=>{active&&(desktopHostOrigin=desktopFeedbackOrigin(boot?.streamBaseUrl))}).catch(()=>{}).finally(()=>{bootPending=!1}):Promise.resolve(),takeClick=event3=>{event3.preventDefault(),event3.stopPropagation()},onClick=event3=>{if(event3.defaultPrevented||typeof event3.button=="number"&&event3.button!==0||event3.metaKey||event3.ctrlKey||event3.shiftKey||event3.altKey)return;let candidate=feedbackAnchorTarget(event3.target,locationRef);if(!candidate||candidate.anchor===replayingAnchor)return;let match2=feedbackLinkTarget(event3.target,locationRef,desktopHostOrigin);match2?(takeClick(event3),navigateToFeedback(ctx,match2.url,locationRef,!desktop)):bootPending&&desktopFeedbackOrigin(candidate.url.origin)&&(takeClick(event3),bootReady.then(()=>{if(active)if(candidate.url.origin===desktopHostOrigin)navigateToFeedback(ctx,candidate.url,locationRef,!1);else{replayingAnchor=candidate.anchor;try{candidate.anchor.click()}finally{replayingAnchor=null}}}))};return documentRef.addEventListener("click",onClick,!0),()=>{active=!1,documentRef.removeEventListener("click",onClick,!0)}}function exactInteractiveControl(labels,documentRef){let selector='button,[role="button"],[role="tab"],a',matches33=element3=>{let values=[element3.getAttribute?.("aria-label"),element3.getAttribute?.("title"),element3.textContent].map(value=>String(value||"").trim());return labels.some(label=>values.includes(label))},visible=element3=>!element3.hidden&&element3.getAttribute?.("aria-hidden")!=="true"&&(typeof element3.getClientRects!="function"||element3.getClientRects().length>0),direct=Array.from(documentRef.querySelectorAll(selector)).find(element3=>visible(element3)&&matches33(element3));if(direct)return direct;for(let element3 of Array.from(documentRef.querySelectorAll("*"))){if(String(element3.textContent||"").trim()!==labels[0])continue;let control=element3.closest?.(selector)||element3;if(visible(control)&&typeof control.click=="function")return control}return null}function openLegacyFeedbackDeepLink(documentRef=document){let observer=null,timer=null,settingsClicked=!1,sectionClicked=!1,cleanup=()=>{observer?.disconnect?.(),timer!==null&&window.clearTimeout(timer)},attempt=()=>{if(documentRef.querySelector('[data-testid="stratagate-memory-ui"]')){cleanup();return}if(!sectionClicked){let section=exactInteractiveControl(["StrataGate-AgentMemory"],documentRef);if(section){sectionClicked=!0,section.click();return}}if(!settingsClicked){let settings=exactInteractiveControl(["\u8BBE\u7F6E","Settings"],documentRef);settings&&(settingsClicked=!0,settings.click())}},Observer=window.MutationObserver||globalThis.MutationObserver;return typeof Observer=="function"&&(observer=new Observer(attempt),observer.observe(documentRef.documentElement||documentRef.body,{childList:!0,subtree:!0})),timer=window.setTimeout(cleanup,12e3),attempt(),cleanup}function openFeedbackDeepLink(ctx,documentRef=document,locationRef=window.location,historyRef=window.history){if(!readFeedbackDeepLink(locationRef))return()=>{};if(navigateToFeedback(ctx,locationRef,locationRef,!1)==="host")return consumeFeedbackDeepLink(locationRef,historyRef),()=>{};let legacyCleanup=()=>{},timer=window.setTimeout(()=>{legacyCleanup=openLegacyFeedbackDeepLink(documentRef)},250);return ctx?.inject?.(["settingsNavigation"],scope=>{navigateToFeedback(scope,locationRef,locationRef,!1)==="host"&&(window.clearTimeout(timer),legacyCleanup(),consumeFeedbackDeepLink(locationRef,historyRef))}),()=>{window.clearTimeout(timer),legacyCleanup()}}function openGraphNodeDeepLink(ctx,documentRef=document,locationRef=window.location,historyRef=window.history){let graphLink=readGraphNodeDeepLink(locationRef);if(!graphLink)return()=>{};if(typeof ctx?.get?.("settingsNavigation")?.openSection=="function")return navigateToGraphNode(ctx,graphLink.namespace,graphLink.nodeId,locationRef,!1).then(opened=>{opened&&consumeGraphNodeDeepLink(locationRef,historyRef)}),()=>{};let legacyCleanup=()=>{},timer=window.setTimeout(()=>{legacyCleanup=openLegacyFeedbackDeepLink(documentRef)},250);return ctx?.inject?.(["settingsNavigation"],scope=>{navigateToGraphNode(scope,graphLink.namespace,graphLink.nodeId,locationRef,!1).then(opened=>{opened&&(window.clearTimeout(timer),legacyCleanup(),consumeGraphNodeDeepLink(locationRef,historyRef))})}),()=>{window.clearTimeout(timer),legacyCleanup()}}let eventDetailCss=`
|
|
325
|
+
`,STRATAGATE_CLIENT_VERSION="0.3.47",MEMORY_CITATIONS_KIND="stratagate-memory-citations",MEMORY_RETRIEVAL_TOOLS=new Set(["memory_search_events","memory_search_graph","memory_expand_graph_node","memory_search_elements","memory_search_raw","memory_get_blocks","memory_expand_block","memory_expand_event","memory_expand_element"]);function readFeedbackDeepLink(locationRef=window.location){let params=new URLSearchParams(String(locationRef?.search||""));if(params.get("settings")!==FEEDBACK_SETTINGS_ID||params.get("stratagateView")!==FEEDBACK_VIEW_ID)return null;let namespace=String(params.get("namespace")||"").trim();return namespace?{namespace}:null}function readFeedbackNavigationState(state){if(!state||state.view!==FEEDBACK_VIEW_ID)return null;let namespace=String(state.namespace||"").trim();return namespace?{namespace}:null}function readNewFeedbackNavigationState(previousState,state){return state===previousState?null:readFeedbackNavigationState(state)}function readGraphNodeNavigationState(state){if(!state||state.view!=="graph-node")return null;let namespace=String(state.namespace||"").trim(),nodeId=String(state.nodeId||"").trim();return namespace&&nodeId?{namespace,nodeId}:null}function readGraphNodeDeepLink(locationRef=window.location){let params=new URLSearchParams(String(locationRef?.search||""));if(params.get("settings")!==FEEDBACK_SETTINGS_ID||params.get("stratagateView")!=="graph-node")return null;let namespace=String(params.get("namespace")||"").trim(),nodeId=String(params.get("nodeId")||"").trim();return namespace&&nodeId?{namespace,nodeId}:null}function consumeFeedbackDeepLink(locationRef=window.location,historyRef=window.history){let params=new URLSearchParams(String(locationRef?.search||""));params.delete("settings"),params.delete("stratagateView"),params.delete("namespace");let search=params.toString(),next2=String(locationRef?.pathname||"/")+(search?"?"+search:"")+String(locationRef?.hash||"");return historyRef?.replaceState?.(historyRef.state,"",next2),next2}function consumeGraphNodeDeepLink(locationRef=window.location,historyRef=window.history){let params=new URLSearchParams(String(locationRef?.search||""));params.delete("settings"),params.delete("stratagateView"),params.delete("namespace"),params.delete("nodeId");let search=params.toString(),next2=String(locationRef?.pathname||"/")+(search?"?"+search:"")+String(locationRef?.hash||"");return historyRef?.replaceState?.(historyRef.state,"",next2),next2}function isDesktopFeedbackSurface(locationRef){try{let url=new URL(String(locationRef?.href||""));return url.protocol==="dsh-app:"&&url.hostname==="app"}catch{return!1}}function desktopFeedbackOrigin(value){try{let url=new URL(String(value||""));return url.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(url.hostname)&&!url.username&&!url.password&&url.pathname==="/"&&!url.search&&!url.hash?url.origin:""}catch{return""}}function feedbackAnchorTarget(target,locationRef){let anchor=target?.closest?.("a[href]")||target?.parentElement?.closest?.("a[href]");if(!anchor)return null;let url;try{url=new URL(String(anchor.getAttribute?.("href")||""),String(locationRef?.href||""))}catch{return null}return!readFeedbackDeepLink(url)||url.pathname!=="/"||url.username||url.password?null:{anchor,url}}function feedbackLinkTarget(target,locationRef=window.location,desktopHostOrigin=""){let match2=feedbackAnchorTarget(target,locationRef);return match2&&(match2.url.origin===String(locationRef?.origin||"")||isDesktopFeedbackSurface(locationRef)&&desktopFeedbackOrigin(desktopHostOrigin)===match2.url.origin)?match2:null}function navigateToFeedback(ctx,targetUrl,locationRef=window.location,allowHttpFallback=!0){let feedback=readFeedbackDeepLink(targetUrl);if(!feedback)return"ignored";let navigation=ctx?.get?.("settingsNavigation");if(typeof navigation?.openSection=="function")return navigation.openSection(FEEDBACK_SETTINGS_ID,{view:FEEDBACK_VIEW_ID,namespace:feedback.namespace}),"host";let shell=ctx?.get?.("slots")?.entries?.("sidebar.settings")?.find(entry=>typeof entry.store?.create=="function")?.store.create();return typeof shell?.actions?.openSection=="function"?(setFeedbackNavigation({view:FEEDBACK_VIEW_ID,namespace:feedback.namespace}),shell.actions.openSection(FEEDBACK_SETTINGS_ID),"host"):(allowHttpFallback&&locationRef.assign(targetUrl.href),"http")}function navigateToGraphNode(ctx,namespace,nodeId,locationRef=window.location,allowHttpFallback=!0){let targetNamespace=String(namespace||"").trim(),targetNodeId=String(nodeId||"").trim();if(!targetNamespace||!targetNodeId)return Promise.resolve(!1);let navigation=ctx?.get?.("settingsNavigation");if(typeof navigation?.openSection!="function"){if(!allowHttpFallback||typeof locationRef?.assign!="function")return Promise.resolve(!1);try{let targetUrl=new URL(String(locationRef.href||""));return targetUrl.searchParams.set("settings",FEEDBACK_SETTINGS_ID),targetUrl.searchParams.set("stratagateView","graph-node"),targetUrl.searchParams.set("namespace",targetNamespace),targetUrl.searchParams.set("nodeId",targetNodeId),locationRef.assign(targetUrl.href),Promise.resolve(!0)}catch{return Promise.resolve(!1)}}try{return Promise.resolve(navigation.openSection(FEEDBACK_SETTINGS_ID,{view:"graph-node",namespace:targetNamespace,nodeId:targetNodeId})).then(result=>result!==!1,()=>!1)}catch{return Promise.resolve(!1)}}function installFeedbackLinkNavigation(ctx,documentRef=document,locationRef=window.location){let desktop=isDesktopFeedbackSurface(locationRef),active=!0,desktopHostOrigin="",bootPending=desktop&&typeof window.dshDesktopBoot?.ready=="function",replayingAnchor=null,bootReady=bootPending?Promise.resolve().then(()=>window.dshDesktopBoot.ready()).then(boot=>{active&&(desktopHostOrigin=desktopFeedbackOrigin(boot?.streamBaseUrl))}).catch(()=>{}).finally(()=>{bootPending=!1}):Promise.resolve(),takeClick=event3=>{event3.preventDefault(),event3.stopPropagation()},onClick=event3=>{if(event3.defaultPrevented||typeof event3.button=="number"&&event3.button!==0||event3.metaKey||event3.ctrlKey||event3.shiftKey||event3.altKey)return;let candidate=feedbackAnchorTarget(event3.target,locationRef);if(!candidate||candidate.anchor===replayingAnchor)return;let match2=feedbackLinkTarget(event3.target,locationRef,desktopHostOrigin);match2?(takeClick(event3),navigateToFeedback(ctx,match2.url,locationRef,!desktop)):bootPending&&desktopFeedbackOrigin(candidate.url.origin)&&(takeClick(event3),bootReady.then(()=>{if(active)if(candidate.url.origin===desktopHostOrigin)navigateToFeedback(ctx,candidate.url,locationRef,!1);else{replayingAnchor=candidate.anchor;try{candidate.anchor.click()}finally{replayingAnchor=null}}}))};return documentRef.addEventListener("click",onClick,!0),()=>{active=!1,documentRef.removeEventListener("click",onClick,!0)}}function exactInteractiveControl(labels,documentRef){let selector='button,[role="button"],[role="tab"],a',matches33=element3=>{let values=[element3.getAttribute?.("aria-label"),element3.getAttribute?.("title"),element3.textContent].map(value=>String(value||"").trim());return labels.some(label=>values.includes(label))},visible=element3=>!element3.hidden&&element3.getAttribute?.("aria-hidden")!=="true"&&(typeof element3.getClientRects!="function"||element3.getClientRects().length>0),direct=Array.from(documentRef.querySelectorAll(selector)).find(element3=>visible(element3)&&matches33(element3));if(direct)return direct;for(let element3 of Array.from(documentRef.querySelectorAll("*"))){if(String(element3.textContent||"").trim()!==labels[0])continue;let control=element3.closest?.(selector)||element3;if(visible(control)&&typeof control.click=="function")return control}return null}function openLegacyFeedbackDeepLink(documentRef=document){let observer=null,timer=null,settingsClicked=!1,sectionClicked=!1,cleanup=()=>{observer?.disconnect?.(),timer!==null&&window.clearTimeout(timer)},attempt=()=>{if(documentRef.querySelector('[data-testid="stratagate-memory-ui"]')){cleanup();return}if(!sectionClicked){let section=exactInteractiveControl(["StrataGate-AgentMemory"],documentRef);if(section){sectionClicked=!0,section.click();return}}if(!settingsClicked){let settings=exactInteractiveControl(["\u8BBE\u7F6E","Settings"],documentRef);settings&&(settingsClicked=!0,settings.click())}},Observer=window.MutationObserver||globalThis.MutationObserver;return typeof Observer=="function"&&(observer=new Observer(attempt),observer.observe(documentRef.documentElement||documentRef.body,{childList:!0,subtree:!0})),timer=window.setTimeout(cleanup,12e3),attempt(),cleanup}function openFeedbackDeepLink(ctx,documentRef=document,locationRef=window.location,historyRef=window.history){if(!readFeedbackDeepLink(locationRef))return()=>{};if(navigateToFeedback(ctx,locationRef,locationRef,!1)==="host")return consumeFeedbackDeepLink(locationRef,historyRef),()=>{};let legacyCleanup=()=>{},timer=window.setTimeout(()=>{legacyCleanup=openLegacyFeedbackDeepLink(documentRef)},250);return ctx?.inject?.(["settingsNavigation"],scope=>{navigateToFeedback(scope,locationRef,locationRef,!1)==="host"&&(window.clearTimeout(timer),legacyCleanup(),consumeFeedbackDeepLink(locationRef,historyRef))}),()=>{window.clearTimeout(timer),legacyCleanup()}}function openGraphNodeDeepLink(ctx,documentRef=document,locationRef=window.location,historyRef=window.history){let graphLink=readGraphNodeDeepLink(locationRef);if(!graphLink)return()=>{};if(typeof ctx?.get?.("settingsNavigation")?.openSection=="function")return navigateToGraphNode(ctx,graphLink.namespace,graphLink.nodeId,locationRef,!1).then(opened=>{opened&&consumeGraphNodeDeepLink(locationRef,historyRef)}),()=>{};let legacyCleanup=()=>{},timer=window.setTimeout(()=>{legacyCleanup=openLegacyFeedbackDeepLink(documentRef)},250);return ctx?.inject?.(["settingsNavigation"],scope=>{navigateToGraphNode(scope,graphLink.namespace,graphLink.nodeId,locationRef,!1).then(opened=>{opened&&(window.clearTimeout(timer),legacyCleanup(),consumeGraphNodeDeepLink(locationRef,historyRef))})}),()=>{window.clearTimeout(timer),legacyCleanup()}}let eventDetailCss=`
|
|
326
326
|
.sg-event-metadata{display:flex;align-items:center;gap:7px 16px;flex-wrap:wrap;margin-top:8px;color:var(--sg-muted);font-size:12px;line-height:1.45}.sg-event-metadata-item{display:inline-flex;align-items:center;gap:5px;min-width:0}.sg-event-metadata b{color:var(--sg-muted);font-weight:620}.sg-event-participants{display:inline-flex;align-items:center;gap:5px;flex-wrap:wrap}.sg-event-metadata .sg-entity-pill{padding:2px 7px}.sg-entity-pill-static{cursor:default;opacity:.82}.sg-entity-pill-static:hover{transform:none!important;background:transparent!important}.sg-event-section{display:grid;gap:9px;padding:17px 0;border-bottom:1px solid var(--sg-border)}.sg-event-section-title{margin:0;color:var(--sg-text);font-size:14px;font-weight:730}.sg-event-memory-copy{max-width:65ch;margin:0;color:var(--sg-text);font-size:14px;line-height:1.72;white-space:pre-wrap;overflow-wrap:anywhere;text-wrap:pretty}.sg-event-weight-section{gap:0}
|
|
327
327
|
.sg-weight-header{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin-bottom:9px}.sg-weight-header .sg-section-title,.sg-long-detail .sg-weight-header h3{margin:0}.sg-weight-metrics{display:grid!important;grid-template-columns:1fr!important;gap:0!important;margin:0 0 13px!important}.sg-weight-metric{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:14px;min-width:0;padding:7px 2px!important;border-bottom:1px solid color-mix(in srgb,var(--sg-border) 72%,transparent);border-radius:0!important;background:transparent!important}.sg-weight-metric:last-child{border-bottom:0}.sg-weight-metric>span:first-child{color:var(--sg-muted);font-size:12px}.sg-weight-metric strong{margin:0!important;color:var(--sg-text);font-size:15px!important;font-weight:740;font-variant-numeric:tabular-nums;white-space:nowrap}.sg-weight-value{display:inline-flex!important;align-items:center;justify-content:flex-end;gap:6px;color:var(--sg-text)!important}
|
|
328
328
|
.sg-info-disclosure{position:relative;display:inline-flex}.sg-info-trigger{display:grid;place-items:center;width:19px;height:19px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--sg-muted);font-size:13px;line-height:1;cursor:pointer}.sg-info-trigger:hover,.sg-info-trigger[aria-expanded="true"]{background:var(--sg-soft);color:var(--sg-text)}.sg-info-popover{position:absolute;right:0;top:calc(100% + 7px);z-index:20;width:min(320px,calc(100vw - 40px));padding:13px 14px;border:1px solid color-mix(in srgb,var(--sg-accent) 20%,var(--sg-border));border-radius:9px;background:var(--sg-page);color:var(--sg-text);box-shadow:0 14px 36px color-mix(in srgb,var(--sg-text) 18%,transparent);font-size:12px;line-height:1.58;text-align:left}.sg-info-title{display:block;margin-bottom:7px;font-size:13px}.sg-info-popover p{margin:0;color:var(--sg-muted)}.sg-info-popover p+p{margin-top:7px}.sg-adoption-history{display:grid;gap:10px;margin:0;padding:0;list-style:none;counter-reset:history}.sg-adoption-history li{display:grid;gap:1px;padding-bottom:9px;border-bottom:1px solid var(--sg-border)}.sg-adoption-history li:last-child{padding-bottom:0;border-bottom:0}.sg-adoption-history time,.sg-adoption-history span{color:var(--sg-muted)}.sg-floor-table{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 14px;margin:10px 0 0;padding-top:9px;border-top:1px solid var(--sg-border)}.sg-floor-table dt,.sg-floor-table dd{margin:0;color:var(--sg-muted)}.sg-floor-table .current{color:var(--sg-accent);font-weight:720}
|
|
@@ -1185,7 +1185,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1185
1185
|
|
|
1186
1186
|
`)||"\u8FD9\u4E00\u8282\u6682\u65F6\u6CA1\u6709\u6982\u8981\u3002")),(part.paragraphs||[]).length?h("div",{className:"sg-topic-overview"},h("h4",{className:"sg-topic-overview-heading"},h("button",{type:"button",className:"sg-topic-overview-toggle","aria-expanded":overviewOpen,"aria-controls":regionId+"-overview",onClick:()=>setOverviewOpen(current=>!current)},h("span",{className:"sg-directory-number"},sectionNumber+".0"),h("span",null,"\u603B\u89C8"),h("span",{className:"sg-directory-chevron","aria-hidden":"true"},"\u203A"))),h(DirectoryFold,{open:overviewOpen,id:regionId+"-overview"},(part.paragraphs||[]).map((paragraph,paragraphIndex)=>h("p",{key:paragraphIndex,className:"sg-topic-overview-text","data-overview-paragraph-index":String(paragraphIndex)},paragraph.text||"\u6682\u65E0\u603B\u89C8")))):null,h(TopicEventList,{namespace,revision,topicId,sectionKey:part.uiKey,total:sourceCount,active:active&&open,openEvent,numberPrefix:sectionNumber,onDirectoryChanged}),h("div",{className:"sg-leaf-folio","aria-hidden":"true"},"\u2014 \u7B2C"+chapterOrdinal(chapter)+"\u7AE0 \xB7 "+sectionNumber+" \u2014"))))}function TopicChapter({topic,number:number3,namespace,revision,active,openEvent,onDirectoryChanged,expandRequest=0,openSection="",onSectionToggle}){let[open,setOpen]=React.useState(!0),[otherOpen,setOtherOpen]=React.useState(!1);React.useEffect(()=>{expandRequest>0&&setOpen(!0)},[expandRequest]);let regionId="sg-topic-chapter-"+encodeURIComponent(topic.id),chapterLabel="\u7B2C"+chapterOrdinal(number3)+"\u7AE0",chapterEvents=topicSections(topic).reduce((sum,part)=>sum+Number(part.sourceEventCount||0),0);return h("article",{className:"sg-topic-chapter","data-topic-id":topic.id},h("header",{className:"sg-topic-chapter-header"},h("span",{className:"sg-topic-chapter-number","aria-hidden":"true"},String(number3).padStart(2,"0")),h("div",{className:"sg-topic-chapter-copy"},h("h2",null,h("button",{type:"button",className:"sg-topic-chapter-toggle",title:topic.title,"data-count":String(chapterEvents),"aria-expanded":open,"aria-controls":regionId,"aria-label":chapterLabel+" "+topic.title,onClick:()=>setOpen(current=>!current)},h("span",{className:"sg-topic-chapter-label"},chapterLabel),h("span",{className:"sg-topic-chapter-title"},topic.title),h("span",{className:"sg-toc-lead","aria-hidden":"true"}),h("span",{className:"sg-toc-cnt",title:chapterEvents+" \u6761\u4E8B\u4EF6"},String(chapterEvents)),h("span",{className:"sg-directory-chevron","aria-hidden":"true"},"\u203A"))),topic.description?h("p",{className:"sg-topic-description"},topic.description):null)),h(DirectoryFold,{open,id:regionId},h("div",{className:"sg-topic-sections"},topicSections(topic).map((part,index)=>h(TopicSection,{key:part.uiKey,part,chapter:number3,index:index+1,topicId:topic.id,namespace,revision,open:openSection===part.uiKey,onToggle:key=>onSectionToggle?.(key,part),active:active&&open,openEvent,onDirectoryChanged})),(topic.sections||[]).length?null:h("p",{className:"sg-topic-no-overview"},"\u8FD9\u4E2A\u4E3B\u9898\u8FD8\u6CA1\u6709\u5C0F\u8282\u3002"),(()=>{let remaining=Number(topic.coverage?.unassignedEvents??topic.coverage?.omittedEvents??0);return remaining?h("details",{className:"sg-topic-other-events",open:otherOpen,onToggle:event3=>setOtherOpen(event3.currentTarget.open)},h("summary",null,"\u5F85\u5F52\u7C7B\u4E8B\u4EF6 \xB7 "+remaining),h(TopicEventList,{namespace,revision,topicId:topic.id,sectionKey:"uncovered",total:remaining,active:active&&open&&otherOpen,openEvent,onDirectoryChanged})):null})())))}function TopicRetryButton({failure,namespace,revision,onDirectoryChanged}){let scope=JSON.stringify([namespace,revision,failure.jobId]),[state,setState]=React.useState({scope,busy:!1,error:""}),current=state.scope===scope?state:{scope,busy:!1,error:""},request=React.useRef(null),scopeRef=React.useRef(scope);scopeRef.current!==scope&&(request.current?.abort(),request.current=null,scopeRef.current=scope),React.useEffect(()=>()=>{scopeRef.current===scope&&(request.current?.abort(),request.current=null)},[scope]);let retry=async()=>{if(request.current)return;let controller=new AbortController;request.current=controller,setState({scope,busy:!0,error:""});try{if(await api2("topics/retry",{namespace,jobId:failure.jobId,expectedRevision:revision},{method:"POST",signal:controller.signal}),request.current!==controller||controller.signal.aborted)return;await onDirectoryChanged?.()}catch(reason){if(request.current!==controller||controller.signal.aborted)return;reason?.status===409?await onDirectoryChanged?.():setState({scope,busy:!1,error:"\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"})}finally{request.current===controller&&(request.current=null,setState(previous=>previous.scope===scope?{...previous,busy:!1}:previous))}};return h("div",{className:"sg-topic-retry"},h("button",{type:"button",className:"sg-topic-status-details",disabled:current.busy||!revision,onClick:retry},current.busy?"\u6B63\u5728\u63D0\u4EA4\u2026":"\u91CD\u65B0\u6574\u7406\u8FD9 "+Number(failure.eventCount||0)+" \u6761"),current.error?h("p",{role:"alert"},current.error):null)}function TopicBootstrapNotice({directory}){if(!directory)return null;let bootstrap=directory.bootstrap,working=bootstrap?.status==="pending"||bootstrap?.status==="running",total=bootstrap?.total,completed2=bootstrap?.completed,counted=Number.isSafeInteger(total)&&total>0&&Number.isSafeInteger(completed2)&&completed2>=0&&completed2<=total;return!working||bootstrap?.total===0?null:h("aside",{className:"sg-topic-bootstrap","aria-label":"\u5386\u53F2\u8BB0\u5FC6\u6574\u7406\u72B6\u6001"},h("p",{className:"sg-muted"},"\u5386\u53F2\u8BB0\u5FC6\u6574\u7406\u4E2D"+(counted?" \xB7 \u5DF2\u5904\u7406 "+completed2+" / "+total+" \u6761\u4E8B\u4EF6":"")))}let DREAMING_STYLES=".sg-dreaming{margin:0 0 20px;padding:14px 16px;border:1px solid var(--sg-border);border-radius:12px;background:var(--sg-surface)}.sg-dreaming-row{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.sg-dreaming-animation{position:relative;width:48px;height:48px;flex:0 0 48px;color:var(--sg-accent)}.sg-dreaming-moon{display:block;font-size:43px;line-height:48px;animation:sg-dream-breathe 4s ease-in-out infinite}.sg-dreaming-star{position:absolute;right:0;top:1px;font-size:12px;animation:sg-dream-twinkle 3s ease-in-out infinite}.sg-dreaming-sleep{position:absolute;right:4px;bottom:1px;font-size:13px;animation:sg-dream-float 3s ease-in-out infinite}.sg-dreaming.resting .sg-dreaming-animation span{animation-play-state:paused}.sg-dreaming-copy{display:grid;gap:5px;flex:1;min-width:150px}.sg-dreaming-copy strong{font-size:14px;color:var(--sg-text)}.sg-dreaming-copy>span,.sg-dreaming p{font-size:12px;color:var(--sg-muted);line-height:1.6}.sg-dreaming-actions{display:flex;gap:8px;flex-wrap:wrap}.sg-dreaming button{padding:7px 12px;border:1px solid var(--sg-border);border-radius:7px;background:var(--sg-page);color:var(--sg-text);cursor:pointer}.sg-dreaming button:hover{border-color:var(--sg-accent)}.sg-dreaming button:disabled{opacity:.5;cursor:default}.sg-dreaming .sg-dreaming-stop{color:var(--sg-danger)}.sg-dreaming-progress{display:flex;align-items:center;gap:12px;margin-top:12px;color:var(--sg-muted);font-size:11px}.sg-dreaming-progress progress{width:100%;height:7px;accent-color:var(--sg-accent);flex:1;min-width:0}@keyframes sg-dream-breathe{50%{opacity:.6;transform:translateY(-2px)}}@keyframes sg-dream-twinkle{50%{opacity:.25;transform:scale(.7)}}@keyframes sg-dream-float{50%{opacity:.4;transform:translate(2px,-5px)}}@media(prefers-reduced-motion:reduce){.sg-dreaming-animation span{animation:none!important}}",DIRECTORY_PREVIEW_STYLES=".sg-topic-directory-intro{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding-bottom:14px}.sg-context-trigger{display:inline-flex;align-items:center;gap:7px;padding:5px 0;border:0;background:transparent;color:var(--sg-muted);font-size:12px;cursor:pointer}.sg-context-trigger:hover,.sg-context-trigger[aria-expanded=true]{color:var(--sg-accent)}.sg-dreaming-start{padding:6px 12px;border:0;border-radius:7px;background:var(--sg-soft);color:var(--sg-accent);font-size:12px;cursor:pointer}.sg-dreaming-start:disabled{opacity:.5;cursor:default}.sg-dreaming{flex:1 0 100%;margin:0;border:0;background:var(--sg-soft);padding:12px 14px}.sg-dreaming-animation{width:36px;height:40px;flex-basis:36px}.sg-dreaming-moon{font-size:34px;line-height:40px}.sg-dreaming-copy strong{font-size:13px}.sg-dreaming-copy>span{font-size:12px;color:var(--sg-muted)}.sg-dreaming-progress{margin-top:9px}.sg-dreaming-session{margin:5px 0 0 50px;padding:2px 0!important;border:0!important;background:transparent!important;color:var(--sg-accent)!important;font-size:12px!important}.sg-context-overlay{position:fixed;inset:0;z-index:2147483020;background:transparent}.sg-context-window{position:fixed;display:flex;flex-direction:column;width:min(520px,calc(100vw - 24px));padding:16px;border:1px solid var(--sg-border);border-radius:11px;background:var(--sg-page);color:var(--sg-text);box-shadow:0 12px 42px rgba(0,0,0,.25);overflow:auto}.sg-context-window-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.sg-context-window-head h3{font-size:14px;margin:0;font-weight:600}.sg-context-close{display:grid;place-items:center;width:29px;height:29px;padding:0;border:0;border-radius:5px;background:transparent;color:var(--sg-muted);cursor:pointer}.sg-context-subtitle{font-size:12px;color:var(--sg-muted);margin:3px 0 13px}.sg-context-injection{margin:0;padding:13px;background:var(--sg-soft);border-radius:7px;font:12px/1.8 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--sg-text)}@media(max-width:600px){.sg-context-overlay{background:rgba(0,0,0,.32)}.sg-context-window{left:12px!important;right:12px!important;top:auto!important;bottom:12px;width:auto;border-radius:13px;max-height:80vh!important}.sg-dreaming-actions{margin-left:50px}.sg-dreaming-copy{min-width:140px}}";function DirectoryContextPreview({context,active}){let[open,setOpen]=React.useState(!1),[position3,setPosition]=React.useState({left:12,top:12,maxHeight:"70vh"}),trigger=React.useRef(null),closeButton=React.useRef(null),close=()=>{setOpen(!1),trigger.current?.focus?.()};return React.useEffect(()=>{(!active||!context)&&setOpen(!1)},[active,context]),React.useEffect(()=>{if(!open||typeof window>"u")return;let place=()=>{let rect=trigger.current?.getBoundingClientRect?.(),width2=window.innerWidth||800,height2=window.innerHeight||700,top=Math.max(12,Math.min((rect?.bottom||80)+8,height2-220));setPosition({left:Math.max(12,Math.min(rect?.left||12,width2-Math.min(520,width2-24)-12)),top,maxHeight:Math.max(180,height2-top-20)})};place(),closeButton.current?.focus?.(),window.addEventListener("resize",place);let key=event3=>{event3.key==="Escape"&&close(),event3.key==="Tab"&&(event3.preventDefault(),closeButton.current?.focus?.())};return window.addEventListener("keydown",key),()=>{window.removeEventListener("resize",place),window.removeEventListener("keydown",key)}},[open]),h(React.Fragment,null,h("button",{type:"button",ref:trigger,className:"sg-context-trigger","aria-haspopup":"dialog","aria-expanded":open,disabled:!context,onClick:()=>setOpen(value=>!value)},"AI \u4F1A\u770B\u5230\u7684\u76EE\u5F55",h("span",{"aria-hidden":"true"},"\u2197")),open?h("div",{className:"sg-context-overlay",onClick:close},h("section",{className:"sg-context-window",style:position3,role:"dialog","aria-modal":!0,"aria-label":"AI \u4F1A\u770B\u5230\u7684\u76EE\u5F55",onClick:event3=>event3.stopPropagation()},h("div",{className:"sg-context-window-head"},h("h3",null,"AI \u4F1A\u770B\u5230\u7684\u76EE\u5F55"),h("button",{type:"button",ref:closeButton,className:"sg-context-close","aria-label":"\u5173\u95ED\u76EE\u5F55\u9884\u89C8",onClick:close},"\xD7")),h("p",{className:"sg-context-subtitle"},"\u4EE5\u4E0B\u76EE\u5F55\u5185\u5BB9\u9ED8\u8BA4\u63D0\u4F9B\u7ED9 AI"),h("pre",{className:"sg-context-injection"},context))):null)}function DreamingPanel({namespace,initialRun,active,available,inline=!1,onDirectoryChanged,onOpenDreamingSession}){let[run,setRun]=React.useState(initialRun||null),[busy,setBusy]=React.useState(!1),[error3,setError]=React.useState(""),[confirmStop,setConfirmStop]=React.useState(!1),stopDialog=React.useRef(null),stopTrigger=React.useRef(null);React.useEffect(()=>{if(!confirmStop)return;let previous=stopTrigger.current;stopDialog.current?.querySelector("button")?.focus?.();let onKeyDown=event3=>{if(event3.key==="Escape"&&!busy&&(event3.preventDefault(),setConfirmStop(!1)),event3.key!=="Tab")return;let buttons=[...stopDialog.current?.querySelectorAll("button:not(:disabled)")||[]];if(!buttons.length)return;let first2=buttons[0],last2=buttons.at(-1);event3.shiftKey&&document.activeElement===first2?(event3.preventDefault(),last2.focus()):!event3.shiftKey&&document.activeElement===last2&&(event3.preventDefault(),first2.focus())};return document.addEventListener("keydown",onKeyDown),()=>{document.removeEventListener("keydown",onKeyDown),previous?.isConnected&&previous.focus?.()}},[confirmStop,busy]);let request=React.useRef(null),previousStatus=React.useRef(initialRun?.status),[toast,setToast]=React.useState("");React.useEffect(()=>{initialRun&&(!run||initialRun.updatedAt>run.updatedAt)&&(initialRun.status==="completed"&&previousStatus.current&&previousStatus.current!=="completed"&&(setToast("\u76EE\u5F55\u5DF2\u6574\u7406\u597D"),previousStatus.current="completed"),setRun(initialRun))},[initialRun]),React.useEffect(()=>{if(!toast)return;let timer=window.setTimeout(()=>setToast(""),3600);return()=>window.clearTimeout(timer)},[toast]);let accept=React.useCallback(value=>{let next2=value?.run||null;next2&&previousStatus.current!==next2.status&&["completed","paused","terminated"].includes(next2.status)&&onDirectoryChanged?.(),next2?.status==="completed"&&previousStatus.current!=="completed"&&setToast("\u76EE\u5F55\u5DF2\u6574\u7406\u597D"),previousStatus.current=next2?.status,setRun(next2),setError("")},[onDirectoryChanged]);React.useEffect(()=>{if(!active||!run||!["running","pausing"].includes(run.status))return;let controller=new AbortController,timer,poll=()=>api2("dreaming",{namespace},{signal:controller.signal}).then(accept).catch(()=>{controller.signal.aborted||setError("\u72B6\u6001\u8BFB\u53D6\u5931\u8D25\uFF0C\u53EF\u91CD\u65B0\u8BFB\u53D6\u3002")}).finally(()=>{controller.signal.aborted||(timer=window.setTimeout(poll,2e3))});return timer=window.setTimeout(poll,1500),()=>{controller.abort(),window.clearTimeout(timer)}},[active,namespace,run?.id,run?.status,accept]),React.useEffect(()=>()=>request.current?.abort(),[]);let control=async action=>{if(request.current)return;let controller=new AbortController;request.current=controller,setBusy(!0),setError("");try{let params={namespace,action};action!=="start"&&(params.id=run.id),accept(await api2("dreaming",params,{method:"POST",signal:controller.signal}))}catch(reason){controller.signal.aborted||setError(reason?.message||"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002")}finally{request.current===controller&&(request.current=null,setBusy(!1))}},running=run?.status==="running",pausing=run?.status==="pausing",paused=run?.status==="paused",outstanding=running||pausing||paused,openSession=async()=>{if(!busy){setBusy(!0),setError("");try{let response=await api2("dreaming",{namespace,action:"open-session",id:run.id},{method:"POST"});if(!response.sessionId||!onOpenDreamingSession)throw new Error("\u5F53\u524D\u5BBF\u4E3B\u65E0\u6CD5\u6253\u5F00 Dreaming \u4F1A\u8BDD");await onOpenDreamingSession(response.sessionId)}catch(reason){setError(reason?.message||"\u65E0\u6CD5\u6253\u5F00\u4F1A\u8BDD\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002")}finally{setBusy(!1)}}};return!!run&&["running","pausing","paused"].includes(run.status)?h("aside",{className:"sg-dreaming "+(running?"running":"resting")+(inline?" inline":""),"aria-label":"Dreaming \u76EE\u5F55\u6574\u7406","data-testid":"stratagate-dreaming"},h("style",null,DREAMING_STYLES+DIRECTORY_PREVIEW_STYLES),toast?h("p",{className:"sg-dreaming-toast",role:"status","aria-live":"polite"},toast):null,h("div",{className:"sg-dreaming-row"},h("div",{className:"sg-dreaming-animation","aria-hidden":"true"},h("span",{className:"sg-dreaming-moon"},"\u263E"),h("span",{className:"sg-dreaming-star"},"\u2726"),h("span",{className:"sg-dreaming-sleep"},"z")),h("div",{className:"sg-dreaming-copy",role:"status","aria-live":"polite"},h("strong",null,running?run.waitingForProjection?"Dreaming \u6B63\u5728\u51C6\u5907\u2026":"\u6B63\u5728\u505A\u68A6\u2026":pausing?"\u6B63\u5728\u6682\u505C\u2026":"Dreaming \u5DF2\u6682\u505C"),h("span",null,run?.activity||"\u6574\u7406\u76EE\u5F55\u3001\u603B\u89C8\u4E0E\u7ECF\u9A8C")),h("div",{className:"sg-dreaming-actions"},running||pausing?h("button",{type:"button",disabled:busy||pausing,onClick:()=>control("pause")},pausing?"\u6B63\u5728\u6682\u505C\u2026":"\u6682\u505C"):null,paused&&!run.replanRequired?h("button",{type:"button",disabled:busy,onClick:()=>control("resume")},"\u7EE7\u7EED"):null,outstanding?h("button",{type:"button",className:"sg-dreaming-stop",disabled:busy,onClick:event3=>{stopTrigger.current=event3.currentTarget,setConfirmStop(!0)}},"\u7EC8\u6B62"):null)),run?h("div",{className:"sg-dreaming-progress"},h("progress",{max:Math.max(1,run.total),value:run.completed,"aria-label":"Dreaming \u6574\u7406\u8FDB\u5EA6\uFF08\u6279\u6B21\uFF09"}),h("span",null,Math.round(100*run.completed/Math.max(1,run.total))+"% \xB7 "+run.completed+"/"+run.total+" \u6279\u6B21")):null,h("button",{type:"button",className:"sg-dreaming-session",disabled:busy||!run.sessionId,onClick:openSession},run.sessionId?"\u6253\u5F00 Dreaming \u4F1A\u8BDD \u2197":running||pausing?"\u4F1A\u8BDD\u51C6\u5907\u4E2D\u2026":"\u672C\u8F6E\u672A\u521B\u5EFA\u4F1A\u8BDD"),run?.reason?h("p",null,run.reason):null,error3?h("p",{className:"sg-dreaming-failure",role:"alert"},error3,h("button",{type:"button",className:"sg-dreaming-retry",disabled:busy,onClick:()=>api2("dreaming",{namespace}).then(accept).catch(()=>setError("\u72B6\u6001\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"))},"\u91CD\u8BD5")):null,confirmStop?h("div",{className:"sg-import-overlay",role:"presentation"},h("section",{ref:stopDialog,className:"sg-dlg",role:"alertdialog","aria-modal":"true","aria-labelledby":"sg-stop-title","aria-describedby":"sg-stop-copy"},h("h3",{id:"sg-stop-title"},"\u7EC8\u6B62\u8FD9\u6B21\u6574\u7406\uFF1F"),h("div",{className:"sg-steps","aria-hidden":"true"},Array.from({length:7},(_,index)=>h("i",{key:index,className:index<Math.min(7,Math.max(0,Math.round(run.completed/Math.max(1,run.total)*7)))?"":"todo"}))),h("div",{className:"sg-steps-l",id:"sg-stop-copy"},h("span",null,h("b",null,Math.min(7,Math.max(0,Math.round(run.completed/Math.max(1,run.total)*7)))+" \u7AE0"),"\u6574\u7406\u597D\u7684\u4F1A\u4FDD\u7559"),h("span",null,7-Math.min(7,Math.max(0,Math.round(run.completed/Math.max(1,run.total)*7)))+" \u7AE0\u4FDD\u6301\u539F\u6837")),h("div",{className:"sg-dlg-acts"},h("button",{type:"button",className:"sg-btn ghost",disabled:busy,onClick:()=>setConfirmStop(!1)},"\u7EE7\u7EED\u6574\u7406"),h("button",{type:"button",className:"sg-btn danger",disabled:busy,onClick:async()=>{await control("terminate"),setConfirmStop(!1)}},"\u7EC8\u6B62")))):null):h(React.Fragment,null,h("style",null,DREAMING_STYLES+DIRECTORY_PREVIEW_STYLES),toast?h("p",{className:"sg-dreaming-toast",role:"status","aria-live":"polite"},toast):null,h("button",{type:"button",className:"sg-dreaming-start"+(inline?" sg-dreaming-arrange":""),disabled:busy||!available,onClick:()=>control("start")},inline?"\u6574\u7406\u8FD9\u4E9B":"\u{1F319} Dreaming"),error3?h("p",{className:"sg-dreaming-failure",role:"alert"},error3,h("button",{type:"button",className:"sg-dreaming-retry",disabled:busy,onClick:()=>api2("dreaming",{namespace}).then(accept).catch(()=>setError("\u72B6\u6001\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"))},"\u91CD\u8BD5")):null)}function TopicDirectory({directory,namespace,active=!0,openEvent,onDirectoryChanged,onOpenDreamingSession}){let[pendingOpen,setPendingOpen]=React.useState(!1),[invalidatedRevision,setInvalidatedRevision]=React.useState(null),[expandRequest,setExpandRequest]=React.useState(0),[selectedSection,setSelectedSection]=React.useState(""),[summaryBusy,setSummaryBusy]=React.useState(!1),[summaryError,setSummaryError]=React.useState(""),chaptersRef=React.useRef(null),revision=directory?.revision||"",blocked=invalidatedRevision===revision;React.useEffect(()=>{setInvalidatedRevision(null)},[directory]);let pageRevision=blocked?"":revision,invalidate=React.useCallback(()=>(setInvalidatedRevision(revision),onDirectoryChanged?.()),[revision,onDirectoryChanged]),topics=directory?.topics||[],pendingTotal=Number(directory?.pending?.total||0),unassignedTotal=pendingTotal,firstSection=topics.flatMap(topic=>topicSections(topic).map(part=>({topic,part})))[0],openSection=selectedSection,[dreamHidden,setDreamHidden]=React.useState(()=>dreamDismissed(directory?.dreaming?.id)),dreamRun=!dreamHidden&&directory?.dreaming&&["completed","terminated"].includes(directory.dreaming.status)?directory.dreaming:null,openDreamRun=async()=>{if(!(summaryBusy||!dreamRun?.sessionId||!onOpenDreamingSession)){setSummaryBusy(!0),setSummaryError("");try{let response=await api2("dreaming",{namespace,action:"open-session",id:dreamRun.id},{method:"POST"});if(!response.sessionId)throw new Error("\u5F53\u524D\u5BBF\u4E3B\u65E0\u6CD5\u6253\u5F00 Dreaming \u4F1A\u8BDD");await onOpenDreamingSession(response.sessionId)}catch(reason){setSummaryError(reason?.message||"\u65E0\u6CD5\u6253\u5F00\u4F1A\u8BDD\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002")}finally{setSummaryBusy(!1)}}},dreamSummary=()=>{if(!dreamRun?.updatedAt)return h("span",null,"\u76EE\u5F55\u4F1A\u968F\u6574\u7406\u66F4\u65B0");let changed=Math.max(0,Number(dreamRun.changedBatches||0)),sections=topics.reduce((sum,topic)=>sum+topicSections(topic).length,0),[,month,day]=eventDayKey(dreamRun.updatedAt).split("-"),stamp=month&&day?month+"/"+day:formatTime(dreamRun.updatedAt);return h("span",{className:"sg-toc-dream"},h("button",{type:"button",className:"sg-toc-dream-run",disabled:summaryBusy||!dreamRun.sessionId||!onOpenDreamingSession,onClick:openDreamRun,title:dreamRun.sessionId?"\u6253\u5F00\u5F53\u8F6E Dreaming \u4F1A\u8BDD":"\u672C\u8F6E\u6CA1\u6709\u521B\u5EFA\u4F1A\u8BDD"},"\u4E0A\u6B21\u6574\u7406 "+stamp+(changed?" \xB7 "+changed+" \u8282 \u2192 "+sections+" \u8282":"")+(dreamRun.status==="terminated"?" \xB7 \u5DF2\u7EC8\u6B62":"")),h("span",{className:"sg-toc-dream-merge","aria-hidden":"true"},Array.from({length:4},(_,index)=>h("i",{key:"f"+index})),h("span",null,"\u2192"),Array.from({length:2},(_,index)=>h("i",{key:"t"+index,className:"o"}))),dreamRun.status==="terminated"?h("span",{className:"sg-toc-dream-note"},"\u5DF2\u6574\u7406\u7684\u7AE0\u8282\u5DF2\u4FDD\u7559"):null,h("button",{type:"button",className:"sg-toc-dream-close","aria-label":"\u5173\u95ED\u8FD9\u6B21\u6574\u7406\u8BB0\u5F55",onClick:()=>{dismissDream(dreamRun.id),setDreamHidden(!0)}},"\xD7"),summaryError?h("span",{className:"sg-toc-dream-error",role:"alert"},summaryError,h("button",{type:"button",className:"sg-toc-dream-retry",onClick:openDreamRun,disabled:summaryBusy},"\u91CD\u8BD5")):null)};return h("section",{className:"sg-topic-directory","data-testid":"stratagate-topic-directory","aria-label":"\u4E3B\u9898\u76EE\u5F55"},blocked?h("p",{className:"sg-topic-read-error",role:"status"},"\u76EE\u5F55\u5DF2\u6709\u66F4\u65B0\uFF0C\u6B63\u5728\u91CD\u65B0\u8BFB\u53D6\u3002",h("button",{type:"button",onClick:onDirectoryChanged},"\u91CD\u65B0\u8BFB\u53D6\u76EE\u5F55")):null,h("div",{hidden:blocked},h(TopicBootstrapNotice,{directory}),directory?!topics.length&&!pendingTotal?h("div",{className:"sg-topic-empty"},h("h3",null,"\u8FD8\u6CA1\u6709\u957F\u671F\u8BB0\u5FC6"),h("p",null,"\u4EA7\u751F\u957F\u671F\u4E8B\u4EF6\u540E\uFF0C\u4E3B\u9898\u4F1A\u5728\u8FD9\u91CC\u9010\u6B65\u6574\u7406\u6210\u76EE\u5F55\u3002")):null:h("p",{className:"sg-topic-empty",role:"status"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u4E3B\u9898\u76EE\u5F55\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u3002"),topics.length||pendingTotal?h("div",{className:"sg-how"},h("i",{className:"sg-sw moss","aria-hidden":"true"}),"\u76EE\u5F55\u4E00\u76F4\u5E26\u7740",h("span",{"aria-hidden":"true"},"\u2192"),h("i",{className:"sg-sw lib","aria-hidden":"true"}),"\u9700\u8981\u65F6\u7FFB\u5230\u5177\u4F53\u4E8B\u4EF6"):null,h("div",{className:"sg-book"},h("div",{className:"sg-leaf"},h("h3",{className:"sg-toc-title"},"\u76EE\u5F55"),h("div",{className:"sg-toc-col"},"\u4E8B\u4EF6"),h("div",{ref:chaptersRef},topics.map((topic,index)=>h(TopicChapter,{key:topic.id,topic,number:index+1,namespace,revision:pageRevision,active:active&&!blocked,openEvent,onDirectoryChanged:invalidate,expandRequest,openSection,onSectionToggle:(key,part)=>setSelectedSection(key)}))),!selectedSection&&firstSection?h("div",{className:"sg-book-preview","aria-label":"\u9ED8\u8BA4\u6253\u5F00\u7684\u7AE0\u8282"},h("span",{className:"sg-leaf-k"},"1.1"),h("h3",null,firstSection.part.uiTitle),h("p",{className:"sg-leaf-sum"},(firstSection.part.paragraphs||[]).map(paragraph=>paragraph.text||"").filter(Boolean).join(`
|
|
1187
1187
|
|
|
1188
|
-
`)||"\u70B9\u5DE6\u4FA7\u5C0F\u8282\uFF0C\u7FFB\u5F00\u5177\u4F53\u4E8B\u4EF6\u3002")):null,unassignedTotal?h("section",{className:"sg-topic-pending","aria-label":"\u5F85\u6574\u7406\u4E8B\u4EF6"},h("div",{className:"sg-topic-pending-heading"},h("button",{type:"button",className:"sg-topic-pending-toggle","aria-expanded":pendingOpen,"aria-controls":"sg-topic-pending-events",onClick:()=>setPendingOpen(value=>!value)},h("span",{className:"sg-topic-pending-label"},"\u5F85\u6574\u7406"),h("span",null,unassignedTotal+" \u6761"),h("span",{className:"sg-directory-chevron","aria-hidden":"true"},"\u203A")),h(DreamingPanel,{key:namespace,namespace,initialRun:directory?.dreaming,active,available:unassignedTotal>0&&!blocked,inline:!0,onDirectoryChanged,onOpenDreamingSession})),h(DirectoryFold,{open:pendingOpen,id:"sg-topic-pending-events"},h("p",null,"\u8FD9\u4E9B\u8BB0\u5FC6\u5C1A\u672A\u5F62\u6210\u7A33\u5B9A\u4E3B\u9898\uFF0C\u4ECD\u53EF\u76F4\u63A5\u67E5\u770B\u539F\u4E8B\u4EF6\u3002"),h(TopicEventList,{namespace,revision:pageRevision,topicId:"pending",total:pendingTotal,active:active&&!blocked&&pendingOpen,openEvent,onDirectoryChanged:invalidate,expandLabel:"\u67E5\u770B\u5168\u90E8\u5F85\u6574\u7406",collapseLabel:"\u6536\u8D77\u5F85\u6574\u7406\u4E8B\u4EF6"}))):null,h("div",{className:"sg-toc-foot sg-leaf-foot"},dreamSummary(),h(DirectoryContextPreview,{context:blocked?"":directory?.context,active}))))))}function LongTermPage({events,eventPage,graph,graphSettings={},project,query,setQuery,openEvent,namespace,focusNodeId,onFocusHandled,topicDirectory,onDirectoryChanged,onOpenDreamingSession,extractionGap=!1,active=!0,refresh}){let graphVisible=graphSettings.enabled===!0||graphSettings.noticeSeen!==!0,[mode,setMode]=React.useState("topics"),[selectedNodeId,setSelectedNodeId]=React.useState(""),[selectedEventId,setSelectedEventId]=React.useState(""),[graphNodeLimit,setGraphNodeLimit]=React.useState(100),[eventFilters,setEventFilters]=React.useState({time:"",node:"",type:"",status:""}),[nodeType,setNodeType]=React.useState(""),[nodeTag,setNodeTag]=React.useState(""),[filtersOpen,setFiltersOpen]=React.useState(!1),[fullScreen,setFullScreen]=React.useState(!1),[graphMenuOpen,setGraphMenuOpen]=React.useState(!1),graphMenuRef=React.useRef(null),debouncedQuery=useDebouncedValue(query),timelineParams=mode==="timeline"?{timeline:"true",...debouncedQuery.trim()?{q:debouncedQuery.trim()}:{},...eventFilters.time?{time:eventFilters.time}:{},...eventFilters.node?{participant:eventFilters.node}:{},...eventFilters.type?{eventType:eventFilters.type}:{},...eventFilters.status?{eventStatus:eventFilters.status}:{}}:{},pagedEvents=usePagedMemory({namespace,kind:"events",initialItems:events,initialPage:eventPage,fallbackLimit:40,extraParams:timelineParams,reloadOnParamsChange:mode==="timeline"}),timelineEvents=pagedEvents.items,nodes3=graph.nodes||[],edges3=graph.edges||[],clusters=graph.clusters||[],normalized=query.trim().toLocaleLowerCase(),nodeImportance=React.useMemo(()=>graphNodeImportance(nodes3,edges3,project),[nodes3,edges3,project]),nodeTags=[...new Set(nodes3.flatMap(node=>node.tags||[]))].sort((left,right)=>left.localeCompare(right));React.useEffect(()=>{if(!graphVisible||!focusNodeId||!nodes3.some(node=>node.id===focusNodeId))return;setMode("graph"),setNodeType(""),setNodeTag("");let rank=[...nodes3].sort((left,right)=>(nodeImportance.get(right.id)?.score||0)-(nodeImportance.get(left.id)?.score||0)).findIndex(node=>node.id===focusNodeId);rank>=0&&setGraphNodeLimit(current=>Math.max(current,rank+1)),setSelectedNodeId(focusNodeId),setFullScreen(!0),onFocusHandled?.()},[graphVisible,focusNodeId,nodes3,nodeImportance,onFocusHandled]),React.useEffect(()=>{if(!fullScreen||!active)return;let previous=document.body.style.overflow;document.body.style.overflow="hidden";let onKeyDown=event3=>{event3.key==="Escape"&&(document.querySelector('.sg-long-explorer .sg-info-trigger[aria-expanded="true"]')||(setFullScreen(!1),setFiltersOpen(!1)))};return window.addEventListener("keydown",onKeyDown),()=>{document.body.style.overflow=previous,window.removeEventListener("keydown",onKeyDown)}},[fullScreen,active]),React.useEffect(()=>{if(!graphMenuOpen)return;let onPointerDown=event3=>{graphMenuRef.current?.contains(event3.target)||setGraphMenuOpen(!1)},onKeyDown=event3=>{event3.key==="Escape"&&setGraphMenuOpen(!1)};return document.addEventListener("pointerdown",onPointerDown),document.addEventListener("keydown",onKeyDown),()=>{document.removeEventListener("pointerdown",onPointerDown),document.removeEventListener("keydown",onKeyDown)}},[graphMenuOpen]);let visibleNodes=nodes3.filter(node=>node.status!=="archived").filter(node=>!nodeType||node.type===nodeType).filter(node=>!nodeTag||(node.tags||[]).includes(nodeTag)).filter(node=>!normalized||JSON.stringify(node).toLocaleLowerCase().includes(normalized)),visibleGraphIds=new Set(visibleNodes.map(node=>node.id)),displayedGraphIds=new Set([...visibleNodes].sort((left,right)=>(nodeImportance.get(right.id)?.score||0)-(nodeImportance.get(left.id)?.score||0)).slice(0,graphNodeLimit).map(node=>node.id)),activeEdges=edges3.filter(edge=>edge.status==="active"&&visibleGraphIds.has(edge.fromNodeId)&&visibleGraphIds.has(edge.toNodeId)),displayedEdgeCount=activeEdges.filter(edge=>displayedGraphIds.has(edge.fromNodeId)&&displayedGraphIds.has(edge.toNodeId)).length,displayedNodeCount=Math.min(graphNodeLimit,visibleNodes.length),countText=(shown,total,unit)=>(shown===total?String(total):shown+" / "+total)+" "+unit,resultCount=mode==="graph"?countText(displayedNodeCount,visibleNodes.length,"\u4E2A\u8282\u70B9")+" \xB7 "+countText(displayedEdgeCount,activeEdges.length,"\u6761\u5173\u7CFB"):countText(timelineEvents.length,pagedEvents.page.total,"\u6761\u4E8B\u4EF6"),selectEvent=id2=>{setSelectedEventId(id2),setMode("timeline")},selectNode=id2=>{setSelectedNodeId(id2),setMode("graph")},openExplorer=()=>{mode==="graph"&&!selectedNodeId&&visibleNodes[0]&&setSelectedNodeId(visibleNodes[0].id),mode==="timeline"&&!selectedEventId&&timelineEvents[0]&&setSelectedEventId(timelineEvents[0].id),setFiltersOpen(!0),setFullScreen(!0)},migrationNotice=graphMigrationNotice(graph.migration),activeFilterCount=mode==="graph"?+!!nodeType+ +!!nodeTag:Object.values(eventFilters).filter(Boolean).length,filterControls=mode==="graph"?h("div",{className:"sg-filterbar"},h("select",{value:nodeType,onChange:event3=>setNodeType(event3.target.value),"aria-label":"\u8282\u70B9\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u8282\u70B9\u7C7B\u578B"),Object.entries(NODE_META).map(([value,meta3])=>h("option",{key:value,value},meta3[0]))),h("select",{value:nodeTag,onChange:event3=>setNodeTag(event3.target.value),"aria-label":"\u8BED\u4E49\u6807\u7B7E"},h("option",{value:""},"\u5168\u90E8\u8BED\u4E49\u6807\u7B7E"),nodeTags.map(tag=>h("option",{key:tag,value:tag},tag)))):h("div",{className:"sg-filterbar"},h("select",{value:eventFilters.time,onChange:event3=>setEventFilters({...eventFilters,time:event3.target.value}),"aria-label":"\u65F6\u95F4\u8303\u56F4"},h("option",{value:""},"\u5168\u90E8\u65F6\u95F4"),h("option",{value:"today"},"\u4ECA\u5929"),h("option",{value:"week"},"\u672C\u5468"),h("option",{value:"unknown"},"\u53D1\u751F\u65F6\u95F4\u672A\u77E5")),h("select",{value:eventFilters.node,onChange:event3=>setEventFilters({...eventFilters,node:event3.target.value}),"aria-label":"\u53C2\u4E0E\u5B9E\u4F53"},h("option",{value:""},"\u5168\u90E8\u5B9E\u4F53"),nodes3.map(node=>h("option",{key:node.id,value:node.id},node.name))),h("select",{value:eventFilters.type,onChange:event3=>setEventFilters({...eventFilters,type:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u7C7B\u578B"),Object.entries(EVENT_TYPE_TEXT).map(([value,label])=>h("option",{key:value,value},label))),h("select",{value:eventFilters.status,onChange:event3=>setEventFilters({...eventFilters,status:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u72B6\u6001"},h("option",{value:""},"\u5168\u90E8\u72B6\u6001"),Object.entries(EVENT_STATUS_TEXT).map(([value,label])=>h("option",{key:value,value},label)))),longTabs=[["topics","\u76EE\u5F55"],...graphSettings.enabled===!0?[["graph","\u77E5\u8BC6\u56FE\u8C31"]]:[],["timeline","\u65F6\u95F4\u7EBF"]],tabButton=([id2,label])=>h("button",{key:id2,type:"button",className:mode===id2?"active":"","aria-current":mode===id2?"page":void 0,"aria-pressed":mode===id2,"aria-label":id2==="graph-add"?"\u91CD\u65B0\u6253\u5F00\u77E5\u8BC6\u56FE\u8C31":label,onClick:()=>{setMode(id2==="graph-add"?"graph":id2),setGraphMenuOpen(id2==="graph-add"||id2==="graph"&&graphSettings.enabled!==!0&&graphSettings.noticeSeen!==!0),id2==="topics"&&(setFullScreen(!1),setFiltersOpen(!1))}},label),graphMenu=h("div",{ref:graphMenuRef,className:"sg-graph-menu"},h("button",{type:"button",className:"sg-graph-menu-trigger","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u8BBE\u7F6E","aria-expanded":graphMenuOpen,onClick:()=>setGraphMenuOpen(value=>!value)},h("svg",{width:16,height:16,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"},h("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}))),graphMenuOpen?h("div",{className:"sg-graph-menu-popover"},h(GraphControlPanel,{state:graphSettings,refresh,page:!0,onOpenGraph:()=>{setGraphMenuOpen(!1),setMode("graph")},onGraphHidden:()=>{setGraphMenuOpen(!1),setMode("topics")}})):null),tabChildren=[...longTabs.map(tabButton),graphMenu];return h("section",{className:"sg-long-explorer "+(fullScreen?"fullscreen":""),"aria-label":fullScreen?"\u957F\u671F\u8BB0\u5FC6\u5168\u5C4F\u63A2\u7D22":"\u957F\u671F\u8BB0\u5FC6\u6D4F\u89C8"},h("div",{className:"sg-pg-head"},h("h2",null,"\u957F\u671F\u8BB0\u5FC6"),h("span",{className:"sg-pg-end"},h("nav",{className:"sg-long-tabs sg-seg","aria-label":"\u957F\u671F\u8BB0\u5FC6\u89C6\u89D2"},tabChildren))),h("div",{hidden:mode!=="topics"},h(TopicDirectory,{directory:topicDirectory,namespace,active:active&&mode==="topics",openEvent,onDirectoryChanged,onOpenDreamingSession})),mode==="topics"?null:h(React.Fragment,null,mode==="graph"&&migrationNotice?h("p",{className:"sg-muted"},migrationNotice):null,mode==="timeline"&&extractionGap?h("p",{className:"sg-muted"},"\u90E8\u5206\u5BF9\u8BDD\u5C1A\u672A\u5F62\u6210\u957F\u671F\u8BB0\u5FC6\uFF0C\u6682\u4E0D\u80FD\u901A\u8FC7\u957F\u671F\u8BB0\u5FC6\u68C0\u7D22\u3002"):null,h("div",{className:"sg-long-toolbar"},h(SearchBox,{value:query,onChange:setQuery,placeholder:mode==="graph"?"\u641C\u7D22\u4EBA\u7269\u3001\u9879\u76EE\u3001\u6982\u5FF5\u2026":"\u641C\u7D22\u4E8B\u4EF6\u2026"}),h("button",{type:"button",className:"sg-toolbar-button","aria-expanded":filtersOpen?"true":"false",onClick:()=>setFiltersOpen(!filtersOpen)},"\u7B5B\u9009 \u25BE",activeFilterCount?h("span",{className:"sg-active-filter-count"},activeFilterCount):null),mode==="graph"&&graphNodeLimit<visibleNodes.length?h("button",{type:"button",className:"sg-toolbar-button",onClick:()=>setGraphNodeLimit(current=>Math.min(visibleNodes.length,current+100))},"\u518D\u663E\u793A 100 \u4E2A"):null,h("button",{type:"button",className:"sg-toolbar-button",onClick:fullScreen?()=>{setFullScreen(!1),setFiltersOpen(!1)}:openExplorer},fullScreen?"\u9000\u51FA\u5168\u5C4F":"\u26F6 \u5168\u5C4F\u67E5\u770B"+(mode==="graph"?"\u56FE\u8C31":"\u65F6\u95F4\u7EBF"))),h("div",{className:"sg-toolbar-count"},resultCount),filtersOpen?filterControls:null,mode==="graph"?h("div",{className:"sg-long-layout "+(fullScreen?"":"sg-summary-layout"),"aria-disabled":!graphSettings.enabled,inert:graphSettings.enabled?void 0:"",style:graphSettings.enabled?void 0:{filter:"grayscale(1)",opacity:.4,pointerEvents:"none"}},h(GraphCanvas,{nodes:visibleNodes,edges:edges3,clusters,importance:nodeImportance,selectedId:selectedNodeId,onSelect:setSelectedNodeId,nodeLimit:graphNodeLimit,showSummary:!fullScreen,onViewDetails:openExplorer}),fullScreen?h(NodeDetailPanel,{node:nodes3.find(node=>node.id===selectedNodeId),nodes:nodes3,edges:edges3,events,onEvent:selectEvent}):null):h(React.Fragment,null,h("div",{className:"sg-long-layout "+(fullScreen?"sg-timeline-layout":"sg-summary-layout")},h(TimelineList,{events:timelineEvents,nodes:nodes3,onSelect:setSelectedEventId,selectedId:selectedEventId,floating:!fullScreen,onNode:selectNode,openSource:openEvent,dreaming:topicDirectory?.dreaming}),fullScreen?h(EventDetailPanel,{event:timelineEvents.find(event3=>event3.id===selectedEventId),nodes:nodes3,events:timelineEvents,onNode:selectNode,openSource:openEvent}):null),h(Pagination,{page:pagedEvents.page,loading:pagedEvents.loading,error:pagedEvents.error,onOffset:pagedEvents.loadOffset}))))}function previewText(value){let text=String(value||"").replace(/\s+/g," ").trim()||"\u6682\u65E0\u5185\u5BB9";return text.length>200?text.slice(0,200)+"\u2026":text}function turnRangeText(range){return!Array.isArray(range)||range.length<2||range[1]<range[0]?"\u7B49\u5F85\u65B0\u5BF9\u8BDD":"Turn "+range[0]+"\u2013"+range[1]}function LayerPreview({layer,currentLevel,expanding,busy,pendingSelection,allowExpand,onExpand}){let itemRef=React.useRef(null),hideTimer=React.useRef(null),popoverRef=React.useRef(null),level=Number(layer.level),actionable=allowExpand&&Number.isInteger(level)&&(level!==currentLevel||pendingSelection),cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},removePopover=()=>{popoverRef.current?.remove(),popoverRef.current=null},showPopover=()=>{cancelHide();let rect=itemRef.current?.getBoundingClientRect();if(!rect)return;let inline=window.innerWidth<860,width2=Math.min(390,Math.max(240,window.innerWidth-24)),maxHeight=Math.min(520,window.innerHeight*.7),right=rect.right+12,left=right+width2<=window.innerWidth-12?right:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));if(!popoverRef.current){let popover=document.createElement("aside"),title=document.createElement("strong"),content=document.createElement("p"),theme=window.getComputedStyle(itemRef.current),pageTheme=window.getComputedStyle(itemRef.current.closest(".sg-memory"));popover.className="sg-layer-popover",popover.setAttribute("role","tooltip"),popover.style.background=pageTheme.backgroundColor,popover.style.color=pageTheme.color,popover.style.borderColor=theme.borderColor,title.textContent="L"+level+" \u5B8C\u6574\u5185\u5BB9",content.className="sg-layer-full",content.textContent=String(layer.content||"\u6682\u65E0\u5185\u5BB9"),popover.append(title,content),popover.addEventListener("mouseenter",cancelHide),popover.addEventListener("mouseleave",scheduleHide),inline?itemRef.current.parentElement.appendChild(popover):document.body.appendChild(popover),popoverRef.current=popover}popoverRef.current.style.setProperty("position",inline?"relative":"fixed","important"),popoverRef.current.style.width=inline?"auto":width2+"px",popoverRef.current.style.left=inline?"0":left+"px",popoverRef.current.style.top=inline?"0":top+"px",popoverRef.current.style.maxHeight=inline?"240px":maxHeight+"px"},scheduleHide=()=>{cancelHide(),hideTimer.current=window.setTimeout(removePopover,140)};return React.useEffect(()=>()=>{cancelHide(),removePopover()},[]),h("div",{className:"sg-layer-hover"},h("div",{ref:itemRef,className:"sg-layer-item "+(level===currentLevel?"current":""),"data-level":String(level)},h("span",{className:"sg-layer-label"},"L"+level),h("span",{className:"sg-layer-preview",tabIndex:0,onMouseEnter:showPopover,onMouseLeave:scheduleHide,onFocus:showPopover,onBlur:scheduleHide},previewText(layer.content)),actionable?h("button",{className:"sg-layer-use",type:"button",disabled:busy,onMouseEnter:removePopover,onFocus:removePopover,onClick:event3=>{event3.stopPropagation(),onExpand(level)}},expanding?"\u6B63\u5728\u5E94\u7528\u2026":"\u8BA9\u52A9\u624B\u53C2\u8003 L"+level):h("span",{className:"sg-layer-using"},level===currentLevel?"\u52A9\u624B\u53EF\u89C1":"\u4EC5\u4F9B\u9884\u89C8")))}function BlockLayerPanel({block,detail,loading,expandingLevel,selectionBusy,onExpand}){if(loading)return h("div",{className:"sg-layer-panel"},h(Loading));let layers=Array.isArray(detail?.layers)?detail.layers:[],visibleLevel=visibleBlockLevel(block);return h("div",{className:"sg-layer-panel"},h("div",{className:"sg-layer-heading"},h("strong",null,"\u5206\u5C42\u5185\u5BB9\u9884\u89C8"),h("span",null,"\u52A9\u624B\u53EF\u89C1\uFF1A"+(visibleLevel===null?"\u5C1A\u672A\u786E\u8BA4":"L"+visibleLevel))),h("p",{className:"sg-layer-hint"},"\u9884\u89C8\u4E0D\u4F1A\u6539\u53D8\u52A9\u624B\u53EF\u89C1\u7684\u5185\u5BB9\u3002\u60AC\u505C\u6216\u805A\u7126\u53EF\u67E5\u770B\u5B8C\u6574\u5185\u5BB9\u3002"),block.virtual?h("div",{className:"sg-virtual-note"},"\u65E7\u4F1A\u8BDD\u5C55\u793A\u7247\u6BB5\u4E3A\u53EA\u8BFB\u5185\u5BB9\uFF0C\u4E0D\u4F1A\u6539\u5199\u539F\u59CB\u6570\u636E\u5E93\u3002"):null,layers.length?h("div",{className:"sg-layer-stack"},layers.slice().sort((a,b)=>a.level-b.level).map(layer=>h(LayerPreview,{key:layer.level,layer,currentLevel:visibleLevel,expanding:expandingLevel===layer.level,busy:selectionBusy||expandingLevel>=0,pendingSelection:block.surfaceSync?.status==="pending"||block.surfaceSync?.status==="blocked",allowExpand:!block.virtual,onExpand}))):h("div",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5386\u53F2\u7684\u5206\u5C42\u5185\u5BB9\u3002"))}function visibleBlockLevel(block){return block.surfaceLevelKnown===!1||!Number.isInteger(block.currentLevel)?null:block.currentLevel}function BlockSelectionFeedback({block,feedback,onRefresh}){let value=feedback||block.surfaceSync;if(!value||value.status==="applied"&&!feedback)return null;let visible=visibleBlockLevel(block),current=visible===null?"\u52A9\u624B\u53EF\u89C1\u7684\u5C42\u7EA7\u5C1A\u672A\u786E\u8BA4\u3002":(value.uncertain?"\u4E0A\u6B21\u786E\u8BA4\u52A9\u624B\u53EF\u89C1 L":"\u52A9\u624B\u5F53\u524D\u53EF\u89C1 L")+visible+"\u3002",level=value.level??block.targetLevel,selected=Number.isInteger(level)?"L"+level:"\u6240\u9009\u5185\u5BB9",message=value.status==="applied"?value.message:(value.status==="pending"?"\u5DF2\u9009\u62E9 "+selected+"\u3002":"\u6682\u65F6\u65E0\u6CD5\u5E94\u7528 "+selected+"\u3002")+value.message+" "+current;return h("div",{className:"sg-selection-feedback"+(value.status==="blocked"?" error":""),role:value.status==="blocked"?"alert":"status"},message,value.uncertain&&onRefresh?h("button",{type:"button",className:"sg-quiet-button",onClick:onRefresh},"\u5237\u65B0\u72B6\u6001"):null)}function SummaryUnavailable({namespace,block}){let[source,setSource]=React.useState(null),[readError,setReadError]=React.useState(null),[loading,setLoading]=React.useState(!1),[open,setOpen]=React.useState(!1),request=React.useRef(null);React.useEffect(()=>()=>request.current?.abort(),[]);let openRaw=async()=>{if(request.current)return;if(source){setOpen(!0);return}let controller=new AbortController;request.current=controller,setLoading(!0),setReadError(null);try{let value=await api2("sources",{namespace,blockId:block.id},{signal:controller.signal});if(controller.signal.aborted)return;if(value.namespace!==namespace||!Array.isArray(value.messages)){setReadError({kind:"temporary",text:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u539F\u6587\u3002"});return}if(!value.messages.some(message=>String(message.content||"").trim())){setReadError({kind:"unavailable",text:"\u5F53\u524D\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u539F\u6587\u3002"});return}setSource(value),setOpen(!0)}catch(reason){controller.signal.aborted||setReadError({kind:[401,403,404,410].includes(reason?.status)?"unavailable":"temporary",text:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u539F\u6587\u3002"})}finally{request.current===controller&&(request.current=null,controller.signal.aborted||setLoading(!1))}},rawId="sg-summary-raw-"+block.id;return h("div",{className:"sg-block-expanded sg-muted"},h("p",null,"\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u6458\u8981\u6682\u4E0D\u53EF\u7528\u3002"),(block.rawAvailable||source)&&readError?.kind!=="unavailable"?h("button",{type:"button",className:"sg-quiet-button",disabled:loading,"aria-expanded":open,"aria-controls":rawId,onClick:open?()=>setOpen(!1):openRaw},open?"\u6536\u8D77\u539F\u59CB\u5BF9\u8BDD":loading?"\u6B63\u5728\u8BFB\u53D6\u2026":readError?.kind==="temporary"?"\u91CD\u65B0\u8BFB\u53D6\u539F\u6587":"\u67E5\u770B\u539F\u59CB\u5BF9\u8BDD"):null,readError?h("p",{role:"status"},readError.text):null,open&&source?h("div",{id:rawId,className:"sg-summary-raw"},source.messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},message.role+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||""))))):null)}let DAILY_WEEK=["\u5468\u65E5","\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D"];function dailyParts(date){let[year,month,day]=date.split("-").map(Number);return{year,month,day,week:DAILY_WEEK[new Date(Date.UTC(year,month-1,day)).getUTCDay()]}}function dailyRelative(date,today){let days=Math.round((Date.parse(today+"T00:00:00Z")-Date.parse(date+"T00:00:00Z"))/864e5);return days===0?"\u4ECA\u5929":days===1?"\u6628\u5929":days>1?days+" \u5929\u524D":Math.abs(days)+" \u5929\u540E"}function DailyIcon({name}){let paths={calendar:["M8 2v4","M16 2v4","M3 10h18","M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2"],folder:["M6 14 7.5 11a2 2 0 0 1 1.8-1H20a2 2 0 0 1 1.9 2.6l-2.2 7A2 2 0 0 1 17.8 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v2"],left:["m15 18-6-6 6-6"],right:["m9 18 6-6-6-6"],refresh:["M3 12a9 9 0 0 1 15.4-6.4L21 8","M21 3v5h-5","M21 12a9 9 0 0 1-15.4 6.4L3 16","M8 16H3v5"],notebook:["M2 6h4","M2 10h4","M2 14h4","M2 18h4","M8 2v20","M6 2h13a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2"],alert:["M12 8v4","M12 16h.01"],pause:["M10 8v8","M14 8v8"]};return h("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},["alert","pause"].includes(name)?h("circle",{cx:12,cy:12,r:10}):null,(paths[name]||[]).map((d,key)=>h("path",{key,d})))}function dailyInline(text){return String(text).split(/(`[^`\n]+`)/g).map((part,key)=>/^`[^`\n]+`$/.test(part)?h("code",{key},part.slice(1,-1)):part)}function renderDailyMarkdown(markdown){let output2=[],children=[],title=null,list=[],flushList=()=>{list.length&&(children.push(h("ul",{key:"list-"+children.length},list)),list=[])},flushItem=()=>{flushList(),(children.length||title!==null)&&output2.push(h("article",{className:"sg-daily-item",key:output2.length},title!==null?h("h4",null,dailyInline(title)):null,children)),children=[],title=null};for(let raw of String(markdown).split(/\r?\n/)){let line=raw.trimEnd();if(/^# \d{4}-\d{2}-\d{2}$/.test(line))continue;if(line.startsWith("## ")){flushItem(),title=line.slice(3);continue}if(line.startsWith("- ")){list.push(h("li",{key:list.length},dailyInline(line.slice(2))));continue}if(flushList(),!line)continue;let status=line.match(/^(当前|已完成):\s*(.*)$/);children.push(status?h("p",{key:children.length,className:"sg-daily-status"+(status[1]==="\u5DF2\u5B8C\u6210"?" done":"")},h("b",null,status[1]),h("span",null,dailyInline(status[2]))):h("p",{key:children.length},dailyInline(line)))}return flushItem(),output2}function dailyNoteDigest(markdown){let items=[],current=null;for(let raw of String(markdown||"").split(/\r?\n/)){let line=raw.trim();if(!line||/^# \d{4}-\d{2}-\d{2}$/.test(line))continue;if(line.startsWith("## ")){current={title:line.slice(3),detail:"",time:""},items.push(current);continue}if(!current)continue;let clock=line.match(/\b([01]?\d|2[0-3]):([0-5]\d)\b/);clock&&!current.time&&(current.time=clock[1].padStart(2,"0")+":"+clock[2]),current.detail||(current.detail=line.replace(/^(当前|已完成):\s*/,"").replace(/^[-*]\s+/,""))}return items}function DailyNotesPage({namespace,setDailyInjectionDays}){let[index,setIndex]=React.useState(null),[indexLoading,setIndexLoading]=React.useState(!0),[indexError,setIndexError]=React.useState(""),[selected,setSelected]=React.useState(""),[note,setNote]=React.useState({loading:!1,date:"",markdown:"",error:""}),[revision,setRevision]=React.useState(0),[noteRevision,setNoteRevision]=React.useState(0),[dayDigests,setDayDigests]=React.useState({}),[daySaving,setDaySaving]=React.useState(!1),[dayError,setDayError]=React.useState(""),[daysOverride,setDaysOverride]=React.useState(null),[openDay,setOpenDay]=React.useState(!1);React.useEffect(()=>{let abort=new AbortController;return setIndexLoading(!0),setIndexError(""),setOpenDay(!1),namespace?(api2("daily",{namespace},{signal:abort.signal}).then(data4=>{abort.signal.aborted||(setDaysOverride(null),setIndex(data4),setSelected(current=>data4.dates.includes(current)?current:data4.injectedDates[0]||data4.dates[0]||""))}).catch(error3=>{abort.signal.aborted||setIndexError(String(error3.message||error3))}).finally(()=>{abort.signal.aborted||setIndexLoading(!1)}),()=>abort.abort()):(setIndex(null),setSelected(""),setIndexLoading(!1),()=>abort.abort())},[namespace,revision]),React.useEffect(()=>{let abort=new AbortController;return setNote({loading:!!selected,date:selected,markdown:"",error:""}),selected&&api2("daily/note",{namespace,date:selected},{signal:abort.signal}).then(data4=>{abort.signal.aborted||setNote({loading:!1,date:selected,markdown:data4.markdown,error:""})}).catch(error3=>{abort.signal.aborted||setNote({loading:!1,date:selected,markdown:"",error:String(error3.message||error3)})}),()=>abort.abort()},[namespace,selected,noteRevision]);let choose=date2=>{setSelected(date2),setOpenDay(!0)},dates=index?.dates||[],injected=index?.injectedDates||[],enabled=index?.enabled!==!1,savedInjectionDays=index?.injectionDays??3,injectionDays=daysOverride??savedInjectionDays,digests=dayDigests&&typeof dayDigests=="object"?dayDigests:{};React.useEffect(()=>{let active=!0,controller=new AbortController,wanted=dates.slice(0,14).filter(date2=>!(date2 in digests));return!wanted.length||indexError||!namespace?()=>controller.abort():(Promise.all(wanted.map(async date2=>{try{let value=await api2("daily/note",{namespace,date:date2},{signal:controller.signal});return[date2,dailyNoteDigest(value?.markdown)]}catch{return[date2,null]}})).then(entries=>{!active||controller.signal.aborted||setDayDigests(current=>{let next2={...current};for(let[date2,items]of entries)next2[date2]=items;return next2})}),()=>{active=!1,controller.abort()})},[namespace,indexError,dates.join(",")]);let stepDays=async delta=>{if(!setDailyInjectionDays||daySaving)return;let next2=Math.min(30,Math.max(1,injectionDays+delta));if(next2!==injectionDays){setDaysOverride(next2),setDaySaving(!0),setDayError("");try{await setDailyInjectionDays(next2)||(setDaysOverride(null),setDayError("\u5929\u6570\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002"))}catch(reason){setDaysOverride(null),setDayError("\u5929\u6570\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason))}finally{setDaySaving(!1)}}},failure=error3=>h("div",{className:"sg-daily-state error",role:"alert"},h("span",{className:"sg-daily-icon-wrap"},h(DailyIcon,{name:"alert"})),h("h3",null,"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u7B14\u8BB0"),h("p",null,"\u6587\u4EF6\u53EF\u80FD\u88AB\u5360\u7528\u6216\u6743\u9650\u4E0D\u8DB3\uFF0C\u5DF2\u6709\u7B14\u8BB0\u4E0D\u4F1A\u4E22\u5931\u3002"),h("button",{type:"button",className:"sg-daily-retry",onClick:()=>indexError?setRevision(v=>v+1):setNoteRevision(v=>v+1)},h(DailyIcon,{name:"refresh"}),"\u91CD\u65B0\u8BFB\u53D6"),h("details",null,h("summary",null,"\u9519\u8BEF\u8BE6\u60C5"),error3)),date=selected?dailyParts(selected):null,days=dates.slice(0,14),dayRows=()=>{let rows=[],cutShown=!1;return days.forEach((day,position3)=>{let parts=dailyParts(day),isInjected=enabled&&injected.includes(day),items=digests[day];enabled&&!cutShown&&!isInjected&&days.slice(0,position3).some(earlier=>injected.includes(earlier))&&(cutShown=!0,rows.push(h("div",{key:day+"-cut",className:"sg-day-cut"},h("span",null,"\u4EE5\u4E0B\u4E0D\u5E26\u5165"))));let lines=(Array.isArray(items)&&items.length?items:[{title:"\u67E5\u770B\u5F53\u5929\u7B14\u8BB0",detail:"",time:""}]).slice(0,6).map((item,key)=>h("li",{key},h("span",{className:"sg-day-t"},item.time||""),h("button",{type:"button",className:"sg-day-s",onClick:()=>choose(day),"aria-label":parts.month+"\u6708"+parts.day+"\u65E5 "+item.title+"\uFF0C\u67E5\u770B\u5F53\u5929\u7B14\u8BB0"},item.title),h("span")));rows.push(h("div",{key:day,className:"sg-day"+(isInjected?"":" out"),style:{animationDelay:position3*40+"ms"}},h("button",{type:"button",role:"tab",id:"sg-day-tab-"+day,"aria-controls":"sg-day-note","data-day":day,"aria-selected":selected===day,tabIndex:selected===day||!days.includes(selected)&&position3===0?0:-1,className:"sg-day-d",onClick:()=>choose(day),onKeyDown:event3=>{let next2=event3.key==="ArrowDown"?(position3+1)%days.length:event3.key==="ArrowUp"?(position3+days.length-1)%days.length:event3.key==="Home"?0:event3.key==="End"?days.length-1:-1;next2>=0&&(event3.preventDefault(),choose(days[next2]),event3.currentTarget.closest(".sg-days")?.querySelector('[data-day="'+days[next2]+'"]')?.focus())}},h("b",null,parts.day),h("span",null,parts.week),h("span",{className:"sg-visually-hidden"},parts.month+"\u6708 \xB7 "+dailyRelative(day,index.today))),h("div",{className:"sg-day-rail","aria-hidden":"true"}),h("ul",null,lines)))}),rows};return h("div",{className:"sg-daily"},h("div",{className:"sg-pg-head"},h("h2",null,"\u77ED\u671F\u8BB0\u5FC6"),h("span",{className:"sg-pg-tag"},h("i",{className:"sg-sw sand","aria-hidden":"true"}),enabled?"\u65B0\u4F1A\u8BDD\u5E26\u5165\u6700\u8FD1 "+injectionDays+" \u4E2A\u6709\u7B14\u8BB0\u65E5\u671F":"\u5DF2\u6682\u505C\u6CE8\u5165"),h("span",{className:"sg-pg-end"},setDailyInjectionDays?h("span",{className:"sg-stp",role:"group","aria-label":"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u5929\u6570"},h("button",{type:"button","aria-label":"\u51CF\u5C11\u4E00\u5929",disabled:daySaving||injectionDays<=1,onClick:()=>{stepDays(-1)}},"\u2212"),h("span",{"aria-live":"polite"},injectionDays+" \u5929"),h("button",{type:"button","aria-label":"\u589E\u52A0\u4E00\u5929",disabled:daySaving||injectionDays>=30,onClick:()=>{stepDays(1)}},"+")):null,null),dayError?h("p",{className:"sg-storage-feedback failed",role:"alert"},dayError):null,indexLoading?h(Loading):indexError?failure(indexError):h(React.Fragment,null,enabled?null:h("div",{className:"sg-daily-off"},h(DailyIcon,{name:"pause"}),"\u5DF2\u5173\u95ED\uFF0C\u4E0D\u518D\u5199\u5165\uFF0C\u4E5F\u4E0D\u4F1A\u5E26\u5165\u65B0\u4F1A\u8BDD\u3002"),dates.length?h(React.Fragment,null,h("div",{className:"sg-days",role:"tablist","aria-label":"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u7B14\u8BB0"},dayRows()),openDay?note.loading||note.date!==selected?h(Loading):note.error?failure(note.error):date?h("article",{key:selected,id:"sg-day-note",role:"tabpanel","aria-labelledby":"sg-day-tab-"+selected,className:"sg-daily-note"},h("div",{className:"sg-daily-note-date"},h("h3",null,date.month+" \u6708 "+date.day+" \u65E5"),h("span",null,date.week+" \xB7 "+dailyRelative(selected,index.today))),h("div",{className:"sg-daily-meta"},h("button",{type:"button",className:"sg-daily-back",onClick:()=>setOpenDay(!1)},"\u6536\u8D77\u7B14\u8BB0"),h("span",{className:"sg-daily-pill"+(!enabled||!injected.includes(selected)?" muted":"")},enabled?injected.includes(selected)?"\u4F1A\u5E26\u5165\u65B0\u4F1A\u8BDD":"\u4E0D\u5728\u5E26\u5165\u8303\u56F4\u5185":"\u5DF2\u6682\u505C\u6CE8\u5165"),!injected.includes(selected)&&enabled?h("button",{type:"button",className:"sg-daily-back",onClick:()=>choose(injected[0])},"\u56DE\u5230\u6700\u8FD1\u7B14\u8BB0"):null),renderDailyMarkdown(note.markdown)):null:null):h("div",{className:"sg-daily-state"},h("span",{className:"sg-daily-icon-wrap"},h(DailyIcon,{name:"notebook"})),h("h3",null,"\u8FD8\u6CA1\u6709\u7B14\u8BB0"),h("p",null,"Agent \u63A8\u8FDB\u5DE5\u4F5C\u65F6\u4F1A\u81EA\u52A8\u8BB0\u5F55\u3002")))))}function ShortTermPage({blocks,blockPage,openBlock,conversations,activeThreadId,namespace,onConversationChange,refresh,blockTurnSize=6}){let pagedBlocks=usePagedMemory({namespace,kind:"blocks",initialItems:blocks,initialPage:blockPage,fallbackLimit:40,extraParams:{threadId:activeThreadId}}),visible=[...pagedBlocks.items].sort((a,b)=>Number(a.sequence||0)-Number(b.sequence||0)||String(a.createdAt).localeCompare(String(b.createdAt))),[expandedId,setExpandedId]=React.useState(""),[detailBlockId,setDetailBlockId]=React.useState(""),[details,setDetails]=React.useState({}),[loadingId,setLoadingId]=React.useState(""),[expanding,setExpanding]=React.useState({blockId:"",level:-1}),[previewError,setPreviewError]=React.useState(null),[selectionFeedback,setSelectionFeedback]=React.useState({}),scope=namespace+"\0"+activeThreadId,activeScope=React.useRef(scope);activeScope.current=scope;let selectionRequest=React.useRef(null),currentOpen=openBlock||{turnRange:null,messages:0,status:"open"};React.useEffect(()=>{setExpandedId(""),setDetailBlockId(""),setDetails({}),setLoadingId(""),setPreviewError(null),setSelectionFeedback({})},[scope]),React.useEffect(()=>{let applied=Object.entries(selectionFeedback).filter(([,value])=>value?.status==="applied");if(!applied.length)return;let timer=window.setTimeout(()=>setSelectionFeedback(current=>{let next2={...current};for(let[id2,value]of applied)next2[id2]===value&&delete next2[id2];return next2}),4e3);return()=>window.clearTimeout(timer)},[selectionFeedback]);let toggleBlock=block=>{if(expandedId===block.id){setExpandedId("");return}setExpandedId(block.id),setPreviewError(null),!details[block.id]&&(setLoadingId(block.id),api2("sources",{namespace,blockId:block.id}).then(value=>{activeScope.current===scope&&setDetails(current=>({...current,[block.id]:value}))}).catch(()=>{activeScope.current===scope&&setPreviewError({scope,blockId:block.id,message:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u9884\u89C8\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u3002"})}).finally(()=>{activeScope.current===scope&&setLoadingId(current=>current===block.id?"":current)}))},expandTo=async(block,level)=>{if(selectionRequest.current?.scope===scope)return;let request={scope,blockId:block.id,level};selectionRequest.current=request;let isCurrent=()=>activeScope.current===scope&&selectionRequest.current===request;setSelectionFeedback(current=>({...current,[block.id]:null})),setExpanding(request);let result;try{result=await api2("blocks/expand",{namespace,blockId:block.id,level:"L"+level},{method:"PATCH"})}catch(reason){let rejected=reason?.code==="BLOCK_SELECTION_REJECTED"||[400,403,404,409].includes(reason?.status);isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:{scope,level,status:rejected?"blocked":"pending",uncertain:!rejected,message:rejected?/[\u4e00-\u9fff]/.test(reason?.message||"")?reason.message.replace("\uFF08blocks/expand\uFF09",""):"\u8FD9\u6B21\u9009\u62E9\u672A\u80FD\u5E94\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u5E94\u7528\u7ED3\u679C\uFF0C\u8BF7\u5237\u65B0\u540E\u67E5\u770B\u3002"}}))}if(isCurrent())try{await refresh(),isCurrent()&&pagedBlocks.page.offset>0&&await pagedBlocks.loadOffset(pagedBlocks.page.offset),result&&isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:result.surfaceSync?.status==="applied"?{scope,level,status:"applied",message:"\u5DF2\u5E94\u7528 L"+level+"\uFF0C\u4F9B\u52A9\u624B\u540E\u7EED\u56DE\u590D\u53C2\u8003\u3002"}:null}))}catch{isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:{scope,level,status:"pending",uncertain:!0,message:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u5E94\u7528\u7ED3\u679C\uFF0C\u8BF7\u5237\u65B0\u540E\u67E5\u770B\u3002"}}))}selectionRequest.current===request&&(selectionRequest.current=null,setExpanding({blockId:"",level:-1}))},selectedBlock=visible.find(block=>block.id===expandedId)||visible[visible.length-1]||null,levelOf=block=>{let level=visibleBlockLevel(block);return level===null?0:Math.min(5,Math.max(0,level))},openCapacity=Math.max(1,Number(currentOpen.capacity||blockTurnSize||6)),openUsed=Math.min(openCapacity,Math.max(0,Number(currentOpen.turns||0))),remainingDots=Math.max(1,openCapacity-openUsed),firstTurn=visible.length?visible[0].turnRange?.[0]:null,lastTurn=visible.length?visible[visible.length-1].turnRange?.[1]:null,turnSpan=Number.isInteger(firstTurn)&&Number.isInteger(lastTurn)?" \xB7 \u7B2C "+firstTurn+"\u2013"+lastTurn+" \u8F6E":"",narrow=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(max-width: 680px)").matches===!0:!1,detailBlock=narrow&&detailBlockId?visible.find(block=>block.id===detailBlockId):null;return detailBlock?h("div",{className:"sg-ss-detail-page"},h(BackBar,{label:"\u4F1A\u8BDD\u8BB0\u5FC6",onBack:()=>setDetailBlockId("")}),h(ShortTermMemoryBlockDetail,{key:namespace+":"+detailBlock.id,namespace,block:detailBlock})):h(React.Fragment,null,h("div",{className:"sg-pg-head"},h("h2",null,"\u4F1A\u8BDD\u8BB0\u5FC6"),h("span",{className:"sg-pg-tag"},h("i",{className:"sg-sw water","aria-hidden":"true"}),pagedBlocks.page.total+" \u5757"+turnSpan),conversations.length?h("span",{className:"sg-pg-end"},h("label",{className:"sg-conversation"},h("span",null,"\u5F53\u524D\u5BF9\u8BDD\uFF1A"),h("select",{value:activeThreadId||"",onChange:event3=>onConversationChange(event3.target.value),"aria-label":"\u5F53\u524D\u5BF9\u8BDD"},conversations.map(conversation=>h("option",{key:conversation.id,value:conversation.id},conversation.label))))):null),h("section",{className:"sg-block-list sg-ss-list","aria-label":"Block \u5217\u8868"},h("section",{className:"sg-visually-hidden","aria-labelledby":"sg-decay-title"},h("h2",{id:"sg-decay-title"},"\u5757\u8870\u51CF\u603B\u89C8"),h("div",{className:"sg-distribution","aria-label":"Block \u5F53\u524D\u5C42\u7EA7\u5206\u5E03"},visible.map(block=>h("span",{key:block.id,className:"sg-level-chip","data-level":visibleBlockLevel(block)===null?void 0:String(block.currentLevel),title:"Block #"+block.sequence},visibleBlockLevel(block)===null?"\u5C1A\u672A\u786E\u8BA4":"L"+block.currentLevel)),h("span",{className:"sg-level-chip sg-open-chip"},"\u5F00\u653E\u5757 \xB7 \u672A\u5C01\u5B58")),h("input",{className:"sg-distribution-rail",type:"range",min:"0",max:"0",step:"1",value:"0",disabled:!0,readOnly:!0,"aria-label":"Block \u5206\u5E03\u6ED1\u8F68"})),h("div",{className:"sg-block-header sg-visually-hidden","aria-hidden":"true"},h("span",null,"\u52A9\u624B\u53EF\u89C1\u5C42\u7EA7"),h("span",null,"Block"),h("span",null,"\u8986\u76D6 Turn"),h("span",null,"\u8DDD\u6700\u65B0\u5C01\u5B58\u5757"),h("span")),h("div",{className:"sg-ss-scale"},h("span",null,"\u66F4\u65E9"),h("span",{className:"sg-r","aria-hidden":"true"},[0,1,2,3,4,5].map(level=>h("i",{key:level,style:{height:5+level*3+"px",opacity:.3+level*.14}}))),h("span",null,"\u6700\u8FD1"),h("span",null,"\u8D8A\u65E9\u7684\u5BF9\u8BDD\u538B\u5F97\u8D8A\u8584")),h("div",{className:"sg-ss"},h("div",{className:"sg-ss-main"},visible.map(block=>h("div",{key:block.id,className:"sg-block-unit"},h("button",{className:"sg-block-toggle",type:"button",onClick:()=>narrow?setDetailBlockId(block.id):toggleBlock(block),"aria-expanded":narrow?void 0:expandedId===block.id?"true":"false","aria-label":"\u8BB0\u5FC6\u5757 "+block.sequence+"\uFF0C"+turnRangeText(block.turnRange)+(narrow?"\uFF0C\u6253\u5F00\u8BE6\u60C5":"")},h("span",{className:"sg-ss-num"},String(block.sequence)),h("span",{className:"sg-ss-bar",style:{height:20+levelOf(block)*5+"px",background:"color-mix(in srgb, var(--sg-water) "+(14+levelOf(block)*14)+"%, var(--sg-page))"}},h("span",null,block.title||(block.virtual?"\u65E7 Block #":"Block #")+block.sequence)),h("span",{className:"sg-ss-use"}),h("span",{className:"sg-block-turn"},turnRangeText(block.turnRange)),h("span",{className:"sg-block-distance"},block.distanceFromLatest===0?"0\uFF08\u6700\u65B0\uFF09":block.distanceFromLatest+" \u4E2A Block"),null),h(BlockSelectionFeedback,{block,feedback:selectionFeedback[block.id]?.scope===scope?selectionFeedback[block.id]:null,onRefresh:async()=>{try{if(await refresh(),activeScope.current!==scope)return;pagedBlocks.page.offset>0&&await pagedBlocks.loadOffset(pagedBlocks.page.offset),activeScope.current===scope&&setSelectionFeedback(current=>({...current,[block.id]:null}))}catch{}}}),previewError?.scope===scope&&previewError.blockId===block.id?h("div",{role:"alert",className:"sg-selection-feedback error"},previewError.message):null,summaryUnavailable(block)?h(SummaryUnavailable,{key:namespace+":"+block.id,namespace,block}):null,expandedId===block.id?h("div",{className:"sg-block-expanded"},h(BlockLayerPanel,{block,detail:details[block.id],loading:loadingId===block.id,selectionBusy:expanding.scope===scope&&expanding.level>=0,expandingLevel:expanding.scope===scope&&expanding.blockId===block.id?expanding.level:-1,onExpand:level=>expandTo(block,level)})):null)),h("div",{className:"sg-block-unit"},h("div",{className:"sg-ss-open"},h("span",{className:"sg-ss-num"},"\xB7"),h("div",{className:"sg-ss-bar"},h("span",null,"\u6B63\u5728\u8BB0\u5F55"),h("span",{className:"sg-ss-dots",role:"img","aria-label":"\u8FD8\u5DEE "+remainingDots+" \u8F6E\u5C01\u5B58","aria-hidden":void 0},Array.from({length:remainingDots},(_,index)=>h("i",{key:index,className:index<Math.min(remainingDots,Math.max(0,openCapacity-openUsed))?"":"o"})))),h("span")))),selectedBlock?h("aside",{className:"sg-ss-side","aria-label":"\u9009\u4E2D\u8BB0\u5FC6\u5757\u8BE6\u60C5"},h("h3",null,selectedBlock.title||"Block #"+selectedBlock.sequence),h("span",{className:"sg-k"},"\u8BB0\u5FC6\u5757 "+selectedBlock.sequence+" \xB7 "+turnRangeText(selectedBlock.turnRange)),h("div",{className:"sg-lvl","aria-hidden":"true"},[0,1,2,3,4,5].map(level=>h("i",{key:level,className:level<=levelOf(selectedBlock)?"on":""}))),h("div",{className:"sg-lvl-l"},h("span",null,"\u53EA\u7559\u6807\u9898"),h("span",null,"\u539F\u6587")),h("p",null,selectedBlock.summary||(selectedBlock.keypoints||[]).join("\uFF1B")||"\u8FD9\u4E00\u5757\u6682\u65F6\u6CA1\u6709\u6458\u8981\u3002"),h("button",{type:"button",className:"sg-btn",onClick:()=>toggleBlock(selectedBlock)},expandedId===selectedBlock.id?"\u6536\u8D77\u8BE6\u60C5":"\u770B\u539F\u6587")):null)),h(Pagination,{page:pagedBlocks.page,loading:pagedBlocks.loading,error:pagedBlocks.error,onOffset:pagedBlocks.loadOffset}))}function SourceDetails({item,source,kind}){let messages=source?.messages||[];return h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u6765\u6E90"),h("div",{className:"sg-source-label"},h("span",{className:"sg-source-icon","aria-hidden":"true"},"\u25A3"),h("span",null,"\u5F53\u524D DeepSeek \u5BF9\u8BDD")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-tech-body"},h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},kind==="block"?"Block ID":"Event ID"),h("span",{className:"sg-code"},item.id)),kind==="block"&&item.turnRange?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,item.turnRange.join(" - "))):null,messages.length?messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},String(message.role||"")+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||"")))):h("div",{className:"sg-muted"},"\u5F53\u524D\u6570\u636E\u4E2D\u6CA1\u6709\u53EF\u663E\u793A\u7684\u6765\u6E90\u6D88\u606F\u3002"))))}function EventDetail({event:event3,project,source,onBack,backLabel,onNode}){let detailedEvent=source?.events?.find(item=>item.id===event3.id)||event3;return h(InfoPopoverGroup,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header sg-event-page-header"},h("span",{className:"sg-event-detail-kicker"},"Event"),h("h2",{className:"sg-detail-title"},detailedEvent.title||"\u8BB0\u5FC6\u8BE6\u60C5"),h(EventMetadata,{event:detailedEvent,nodes:source?.relatedNodes||[],onNode})),h(EventMemoryDetails,{event:detailedEvent,sourceMessages:source?.messages||[]}))}function ElementDetail({element:element3,events,source,openEvent,onBack,backLabel}){let facts=[];element3.currentState&&facts.push(element3.currentState);for(let fact of element3.facts||[]){let value=Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value;value&&!facts.includes(String(value))&&facts.push(String(value))}let related=events.filter(event3=>(element3.sourceEventIds||[]).includes(event3.id)).sort((a,b)=>String(b.updatedAt).localeCompare(String(a.updatedAt)));return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},element3.name||"\u76F8\u5173\u4E8B\u7269"),h("p",{className:"sg-detail-subtitle"},"AI \u5173\u4E8E\u5B83\u76EE\u524D\u77E5\u9053\u8FD9\u4E9B"),h("div",{className:"sg-meta"},h("span",null,"\u76F8\u5173\u7ECF\u5386 "+related.length+" \u6761"),h("span",{className:"sg-meta-sep"},"\u6700\u8FD1\u66F4\u65B0 "+formatTime(element3.updatedAt)))),h("div",{className:"sg-detail-section"},facts.length?h("ul",{className:"sg-facts"},facts.map((fact,index)=>h("li",{key:index},fact))):h("div",{className:"sg-muted"},"\u6682\u65F6\u6CA1\u6709\u5F62\u6210\u53EF\u5C55\u793A\u7684\u8BA4\u8BC6\u3002")),h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u76F8\u5173\u7ECF\u5386"),related.length?h("div",{className:"sg-related-list"},related.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",{className:"sg-related-name"},event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt||event3.createdAt))))):h("div",{className:"sg-muted"},"\u6CA1\u6709\u5173\u8054\u7ECF\u5386\u3002")),h(SourceDetails,{item:element3,source,kind:"element"}))}function processingFingerprint(overview){return JSON.stringify({failedJobs:Number(overview?.failedJobs||0),duplicateRepair:overview?.duplicateRepair??null,processingJobs:Number(overview?.processingJobs||0),failures:(overview?.failedJobDetails||[]).map(({kind,id:id2,attempts,updatedAt,lastError})=>({kind,id:id2,attempts,updatedAt,lastError})),processing:(overview?.processingJobDetails||[]).map(({kind,id:id2,status,attempts,updatedAt})=>({kind,id:id2,status,attempts,updatedAt}))})}function ProcessingStatus({overview,blocks,conversations,namespace,serverVersion,onBack,backLabel="\u8FD4\u56DE",refresh}){let failures=overview.failedJobDetails||[],failedKeys=new Set(failures.map(statusJobKey)),terminalFailedKeys=new Set(failures.filter(job=>job.state==="terminal-failed"||!job.state&&!job.nextRetryAt).map(statusJobKey)),hasProcessingDetails=Array.isArray(overview.processingJobDetails),rawProcessingCount=activeProcessingCount(overview),jobsByKey=new Map((overview.processingJobDetails||[]).map(job=>[statusJobKey(job),job]));for(let job of failures)jobsByKey.set(statusJobKey(job),job);let[refreshing,setRefreshing]=React.useState(!1),[feedback,setFeedback]=React.useState({kind:"",text:""}),[retrying,setRetrying]=React.useState(""),retryRequest=React.useRef(!1),[retryErrors,setRetryErrors]=React.useState({}),blockById=new Map(blocks.map(block=>[block.id,block])),conversationById=new Map((conversations||[]).map(conversation=>[conversation.id,conversation]));if(!hasProcessingDetails&&rawProcessingCount>0){let addLegacyJob=(block,kind,status,details={})=>{let job={id:"legacy:"+block.id+":"+kind,kind,status,attempts:details.attempts??0,nextRetryAt:details.nextRetryAt??null,updatedAt:details.updatedAt||block.createdAt,legacy:!0,blockIds:[block.id],blockDetails:[{id:block.id,sourceId:block.sourceId||block.id,sequence:block.sequence||block.blockIndex,title:block.title||block.l0Title,threadId:block.threadId,turnRange:block.turnRange,shouldExtract:block.shouldExtract}]};jobsByKey.set(statusJobKey(job),job)};for(let block of blocks){if(!(block.status==="processing"||block.processingStatus==="pending"))continue;let found=!1;(["pending","running"].includes(block.summaryJob?.status)||block.processingStatus==="pending")&&(addLegacyJob(block,"block-summary",block.summaryJob?.status||"pending",block.summaryJob),found=!0),block.eventExtraction?.status==="running"&&(addLegacyJob(block,"event-extraction","running",block.eventExtraction),found=!0),["pending","running"].includes(block.graphProjection?.status)&&(addLegacyJob(block,"graph-projection",block.graphProjection.status,block.graphProjection),found=!0),found||addLegacyJob(block,"event-extraction","running")}}let taskLabel=kind=>kind==="block-summary"?"\u4F1A\u8BDD\u8BB0\u5FC6\u538B\u7F29":kind==="event-extraction"?"\u957F\u671F\u8BB0\u5FC6\u63D0\u53D6":kind==="topic-projection"?"\u4E3B\u9898\u6574\u7406":"\u77E5\u8BC6\u56FE\u8C31\u66F4\u65B0",retryKey=statusJobKey,technicalStatusText=(status,job)=>job?.state==="terminal-failed"?"\u7EC8\u6001\u5931\u8D25":job?.state==="retryable"?"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5":status==="running"?"\u8FD0\u884C\u4E2D":status==="pending"?"\u6392\u961F\u4E2D":status==="failed"?"\u5931\u8D25":status==="succeeded"||status==="completed"?"\u5DF2\u5B8C\u6210":String(status||"\u672A\u77E5"),workItems=new Map;for(let job of jobsByKey.values()){let details=Array.isArray(job.blockDetails)?job.blockDetails:[];details.length||(details=(Array.isArray(job.blockIds)&&job.blockIds.length?job.blockIds:job.id&&!["graph-projection","topic-projection"].includes(job.kind)?[job.id]:[]).map(id2=>blockById.get(id2)).filter(Boolean).map(block=>({id:block.id,sourceId:block.id,sequence:block.sequence,title:block.title||block.l0Title,threadId:block.threadId,turnRange:block.turnRange,shouldExtract:block.shouldExtract,rawAvailable:block.rawAvailable}))),details.length||(details=[{id:statusJobKey(job),sourceId:"",sequence:null,title:"",threadId:job.threadId||"",turnRange:job.turnRange,shouldExtract:null}]);for(let detail of details){let key=String(detail.threadId||"")+":"+String(detail.id||detail.sourceId||statusJobKey(job)),item=workItems.get(key)||{...detail,jobs:[]};item.jobs.some(candidate=>statusJobKey(candidate)===statusJobKey(job))||item.jobs.push(job),workItems.set(key,item)}}let items=[...workItems.values()].sort((left,right)=>{let threadOrder=String(left.threadId||"").localeCompare(String(right.threadId||""));return threadOrder||Number(left.turnRange?.[0]||left.sequence||0)-Number(right.turnRange?.[0]||right.sequence||0)}),itemState=item=>item.jobs.some(job=>terminalFailedKeys.has(statusJobKey(job)))?{kind:"failed",label:"\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5",mark:"!"}:item.jobs.some(job=>job.status==="running")?{kind:"processing",label:"\u6B63\u5728\u6574\u7406",mark:"\u25CF"}:item.jobs.some(job=>job.state==="retryable"||failedKeys.has(statusJobKey(job))&&job.nextRetryAt)?{kind:"processing",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5",mark:"\u21BB"}:{kind:"waiting",label:"\u7B49\u5F85\u6574\u7406",mark:"\u25CB"},itemStages=item=>{let summaryJob=item.jobs.find(job=>job.kind==="block-summary"),extractionJobs=item.jobs.filter(job=>job.kind==="event-extraction"),graphJobs=item.jobs.filter(job=>job.kind==="graph-projection"),topicJobs=item.jobs.filter(job=>job.kind==="topic-projection"),summaryFailed=summaryJob&&terminalFailedKeys.has(statusJobKey(summaryJob)),extractionFailed=extractionJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),graphFailed=graphJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),shortStage=summaryFailed?{kind:"failed",mark:"!",label:"\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5"}:summaryJob?.status==="running"?{kind:"processing",mark:"\u25CF",label:"\u5904\u7406\u4E2D"}:summaryJob?.state==="retryable"?{kind:"processing",mark:"\u21BB",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5"}:summaryJob?{kind:"waiting",mark:"\u25CB",label:"\u6392\u961F\u4E2D"}:{kind:"done",mark:"\u2713",label:"\u5DF2\u5B8C\u6210"},stageForJobs=(jobs,failed,emptyLabel,failedLabel="\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5")=>failed?{kind:"failed",mark:"!",label:failedLabel}:jobs.some(job=>job.status==="running")?{kind:"processing",mark:"\u25CF",label:"\u5904\u7406\u4E2D"}:jobs.some(job=>job.state==="retryable")?{kind:"processing",mark:"\u21BB",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5"}:jobs.length?{kind:"waiting",mark:"\u25CB",label:"\u6392\u961F\u4E2D"}:{kind:"waiting",mark:"\u25CB",label:emptyLabel};if(topicJobs.length===item.jobs.length)return[["\u4E3B\u9898\u6574\u7406",stageForJobs(topicJobs,topicJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),"\u7B49\u5F85\u6574\u7406")]];let extractionStage=extractionFailed?stageForJobs(extractionJobs,!0,"\u7B49\u5F85\u63D0\u53D6"):extractionJobs.length?stageForJobs(extractionJobs,!1,"\u7B49\u5F85\u63D0\u53D6"):graphJobs.length?{kind:"done",mark:"\u2713",label:"\u5DF2\u5B8C\u6210"}:shortStage.kind!=="done"?{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u77ED\u671F\u6458\u8981"}:item.shouldExtract===!1?{kind:"skipped",mark:"\u2013",label:"\u65E0\u9700\u63D0\u53D6"}:{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u63D0\u53D6"},graphStage=graphFailed?stageForJobs(graphJobs,!0,"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0","\u66F4\u65B0\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5"):graphJobs.length?stageForJobs(graphJobs,!1,"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0"):extractionStage.kind==="failed"||extractionStage.kind==="waiting"||extractionStage.kind==="processing"?{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u957F\u671F\u8BB0\u5FC6\u63D0\u53D6"}:{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0"};return[["\u539F\u59CB\u5BF9\u8BDD",item.rawAvailable===!0?{kind:"done",mark:"\u2713",label:"\u5F53\u524D\u53EF\u8BFB\u53D6"}:{kind:"waiting",mark:"\u25CB",label:item.rawAvailable===!1?"\u5F53\u524D\u65E0\u53EF\u8BFB\u53D6\u539F\u6587":"\u65E0\u6CD5\u786E\u8BA4\u662F\u5426\u53EF\u8BFB\u53D6"}],["\u538B\u7F29\u4F1A\u8BDD\u8BB0\u5FC6",shortStage],["\u63D0\u53D6\u957F\u671F\u8BB0\u5FC6",extractionStage],["\u66F4\u65B0\u77E5\u8BC6\u56FE\u8C31",graphStage]]},conversationLabel=threadId=>threadId==="__legacy__"?"\u5386\u53F2\u5BF9\u8BDD":conversationById.get(threadId)?.label||(threadId?"\u5BF9\u8BDD "+String(threadId).slice(0,8):"\u5386\u53F2\u6216\u672A\u77E5\u5BF9\u8BDD"),groups=[];for(let item of items){let key=item.threadId||"__unknown__",group2=groups.find(candidate=>candidate.key===key);group2||(group2={key,label:conversationLabel(item.threadId),items:[]},groups.push(group2)),group2.items.push(item)}let checkStatus=()=>{let before=processingFingerprint(overview);return setRefreshing(!0),setFeedback({kind:"",text:"\u6B63\u5728\u8BFB\u53D6\u2026"}),refresh({propagateError:!0}).then(next2=>{let selected=next2?.overview?.namespaces?.find(item=>item.namespace===namespace),changed=selected&&processingFingerprint(selected)!==before;setFeedback({kind:"done",text:changed?"\u72B6\u6001\u5DF2\u66F4\u65B0":"\u72B6\u6001\u6CA1\u6709\u53D8\u5316"})}).catch(reason=>{setFeedback({kind:"failed",text:"\u8BFB\u53D6\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}).finally(()=>setRefreshing(!1))},retryJob=job=>{if(retryRequest.current)return;retryRequest.current=!0;let key=retryKey(job);return setRetrying(key),setRetryErrors(current=>({...current,[key]:""})),setFeedback({kind:"",text:taskLabel(job.kind)+" \u6B63\u5728\u5904\u7406\u2026"}),api2("jobs/retry",{namespace,kind:job.kind,jobId:job.id},{method:"POST"}).then(()=>refresh({propagateError:!0})).then(()=>setFeedback({kind:"done",text:job.kind==="topic-projection"?"\u5DF2\u91CD\u65B0\u6392\u961F\uFF0C\u6309\u5386\u53F2\u989D\u5EA6\u7EE7\u7EED\u6574\u7406":"\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u72B6\u6001\u5DF2\u66F4\u65B0"})).catch(async reason=>{let message=String(reason?.message||reason);setRetryErrors(current=>({...current,[key]:message})),setFeedback({kind:"failed",text:"\u91CD\u8BD5\u5931\u8D25\uFF1A"+message});try{await refresh({propagateError:!0})}catch{}}).finally(()=>{retryRequest.current=!1,setRetrying("")})},failedItems=items.filter(item=>item.jobs.some(job=>terminalFailedKeys.has(statusJobKey(job)))).length,activeItems=Math.max(0,items.length-failedItems),unresolvedProcessingCount=hasProcessingDetails?0:Math.max(0,rawProcessingCount-activeItems),detailsUnavailable=!hasProcessingDetails&&rawProcessingCount>0,versionMismatch=!!(serverVersion&&serverVersion!==STRATAGATE_CLIENT_VERSION),summary=items.length?groups.length+" \u4E2A\u4F1A\u8BDD \xB7 "+(activeItems?activeItems+" \u4E2A\u6B63\u5728\u6574\u7406":"")+(activeItems&&failedItems?" \xB7 ":"")+(failedItems?failedItems+" \u4E2A\u9700\u8981\u91CD\u8BD5":"")+(unresolvedProcessingCount?" \xB7 \u53E6\u6709 "+unresolvedProcessingCount+" \u4E2A\u8BE6\u60C5\u6682\u4E0D\u53EF\u7528":""):detailsUnavailable?"\u4ECD\u6709 "+rawProcessingCount+" \u4E2A\u540E\u53F0\u4EFB\u52A1\u6B63\u5728\u6574\u7406":hasProcessingDetails?"\u5F53\u524D\u6CA1\u6709\u5F85\u5904\u7406\u6216\u5931\u8D25\u7684\u4EFB\u52A1":"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u540E\u53F0\u4EFB\u52A1\u72B6\u6001";return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u540E\u53F0\u4EFB\u52A1"),h("p",null,summary)),h("div",{className:"sg-process-summary"},h("strong",null,"\u540E\u53F0\u6574\u7406\u72B6\u6001"),h("span",null,"\u5DF2\u6709\u8BB0\u5FC6\u53EF\u7EE7\u7EED\u67E5\u770B\uFF1B\u5177\u4F53\u6765\u6E90\u4EE5\u5B9E\u9645\u53EF\u8BFB\u53D6\u5185\u5BB9\u4E3A\u51C6\u3002")),detailsUnavailable?h("div",{className:"sg-process-notice",role:"status"},h("strong",null,versionMismatch?"\u524D\u540E\u7AEF\u7248\u672C\u5C1A\u672A\u540C\u6B65":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B8C\u6574\u4EFB\u52A1\u8BE6\u60C5"),h("span",null,versionMismatch?"\u5F53\u524D\u9875\u9762\u4E3A "+STRATAGATE_CLIENT_VERSION+"\uFF0C\u540E\u53F0\u4E3A "+serverVersion+"\u3002\u8BF7\u786E\u8BA4\u5B89\u88C5\u65B0\u5305\u540E\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u542F\u52A8 DSH\u3002":"\u540E\u53F0\u53EA\u8FD4\u56DE\u4E86\u4EFB\u52A1\u6570\u91CF\uFF0C\u6CA1\u6709\u8FD4\u56DE\u4F1A\u8BDD\u548C\u8F6E\u6B21\u3002\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u542F\u52A8 DSH \u540E\u518D\u68C0\u67E5\u3002")):null,groups.length?h("div",{className:"sg-process-groups"},groups.map(group2=>h("section",{key:group2.key,className:"sg-process-group"},h("header",{className:"sg-process-group-head"},h("h3",{className:"sg-process-group-title"},group2.label),h("span",{className:"sg-process-group-count"},group2.items.length+" \u4E2A\u5BF9\u8BDD\u7247\u6BB5")),group2.items.map(item=>{let state=itemState(item),range=Array.isArray(item.turnRange)?"\u7B2C "+item.turnRange[0]+"\u2013"+item.turnRange[1]+" \u8F6E":item.title||"\u5BF9\u8BDD\u7247\u6BB5",technicalJobs=item.jobs.filter(job=>!job.legacy);return h("article",{key:String(item.id||item.sourceId),className:"sg-process-card"},h("div",{className:"sg-process-card-head"},h("span",{className:"sg-process-range"},range),h("span",{className:"sg-process-state "+state.kind},h("span",{"aria-hidden":"true"},state.mark),state.label)),h("div",{className:"sg-process-stages"},itemStages(item).map(([name,stage])=>h("div",{key:name,className:"sg-process-stage"},h("span",{className:"sg-process-stage-state "+stage.kind,"aria-hidden":"true"},stage.mark),h("span",{className:"sg-process-stage-name"},name),h("span",{className:"sg-process-stage-state "+stage.kind},stage.label)))),technicalJobs.length?h("details",{className:"sg-process-tech"},h("summary",null,"\u67E5\u770B\u6280\u672F\u8BE6\u60C5"),technicalJobs.map(job=>{let key=retryKey(job),failed=terminalFailedKeys.has(key),busy=retrying===key;return h("div",{key,className:"sg-process-job"},h("div",{className:"sg-process-job-head"},h("strong",null,taskLabel(job.kind)),h("span",{className:"sg-stage-value "+(terminalFailedKeys.has(key)?"failed":job.status==="running"||job.state==="retryable"?"processing":"waiting")},technicalStatusText(job.status,job))),h("div",{className:"sg-process-job-meta sg-code"},"\u4EFB\u52A1 "+job.id+" \xB7 \u5DF2\u5C1D\u8BD5 "+String(job.attempts??0)+" \u6B21 \xB7 \u66F4\u65B0\u4E8E "+formatTime(job.updatedAt)),job.nextRetryAt?h("div",{className:"sg-process-job-meta"},"\u8BA1\u5212\u91CD\u8BD5\uFF1A"+formatTime(job.nextRetryAt)):null,failed&&!job.nextRetryAt?h("div",{className:"sg-process-job-meta"},"\u81EA\u52A8\u91CD\u8BD5\u5DF2\u505C\u6B62"):null,failed?h("pre",{className:"sg-job-error sg-code"},job.lastErrorFull||job.lastError||"\u6CA1\u6709\u8BB0\u5F55\u6280\u672F\u9519\u8BEF\u3002"):null,job.kind==="topic-projection"&&job.diagnostics?h("pre",{className:"sg-code"},JSON.stringify(job.diagnostics,null,2)):null,job.kind==="topic-projection"&&overview.topicDirectoryReadError?h("p",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u76EE\u5F55\u72B6\u6001\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u72B6\u6001\u3002"):null,failed?h("div",{className:"sg-process-job-actions"},h("span",{className:"sg-status-feedback failed",role:retryErrors[key]?"alert":void 0},retryErrors[key]||""),job.kind==="topic-projection"?h(TopicRetryButton,{failure:{jobId:job.id,eventCount:job.eventCount},namespace,revision:overview.topicDirectoryRevision,onDirectoryChanged:()=>refresh({propagateError:!0})}):h("button",{type:"button",className:"sg-save-button",disabled:!!retrying,onClick:()=>{retryJob(job)}},busy?"\u6B63\u5728\u5904\u7406\u2026":"\u91CD\u8BD5\u6B64\u4EFB\u52A1")):null)})):null)})))):detailsUnavailable?h("div",{className:"sg-process-unavailable"},h("strong",null,"\u4EFB\u52A1\u4ECD\u5728\u6574\u7406\uFF0C\u5177\u4F53\u4F1A\u8BDD\u6682\u4E0D\u53EF\u7528"),h("span",null,"\u8FD9\u4E0D\u4EE3\u8868\u5BF9\u8BDD\u4E22\u5931\uFF1B\u91CD\u542F\u5E76\u52A0\u8F7D\u540C\u4E00\u7248\u672C\u540E\u5373\u53EF\u663E\u793A\u8BE6\u60C5\u3002")):h(Empty,{title:hasProcessingDetails?"\u5F53\u524D\u6CA1\u6709\u5F85\u5904\u7406\u6216\u5931\u8D25\u7684\u4EFB\u52A1":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u4EFB\u52A1\u8BE6\u60C5",copy:"\u76EE\u5F55\u4E0E\u56FE\u8C31\u7684\u8986\u76D6\u60C5\u51B5\u8BF7\u4EE5\u5BF9\u5E94\u9875\u9762\u4E3A\u51C6\u3002"}),h("div",{className:"sg-process-footer"},h("button",{type:"button",className:"sg-quiet-button",disabled:refreshing,onClick:()=>{checkStatus()}},refreshing?"\u6B63\u5728\u8BFB\u53D6\u2026":"\u21BB \u91CD\u65B0\u68C0\u67E5\u72B6\u6001"),h("span",{className:"sg-muted"},"\u53EA\u8BFB\u53D6\u6700\u65B0\u72B6\u6001\uFF0C\u4E0D\u4F1A\u89E6\u53D1\u6A21\u578B\u8C03\u7528\u3002"),feedback.text?h("span",{className:"sg-status-feedback "+feedback.kind,role:feedback.kind==="failed"?"alert":"status"},feedback.text):null))}let profilePageMemory=new Map,profileFieldDrafts=new Map,importDrafts=new Map,importRequests=new Map;function usePageMemoryState(cache3,key,initial){cache3.has(key)||cache3.set(key,initial);let[value,setValue]=React.useState(cache3.get(key));return[value,next2=>{let resolved=typeof next2=="function"?next2(cache3.get(key)):next2;cache3.set(key,resolved),setValue(resolved)}]}function ImportPage({namespace,onBack,refresh}){let[draft,setDraft]=usePageMemoryState(importDrafts,namespace,{text:""}),text=draft.text,setText=value=>setDraft({text:value}),[prompt,setPrompt]=React.useState(""),[promptLoading,setPromptLoading]=React.useState(!0),[copied,setCopied]=React.useState(!1),[busy,setBusy]=React.useState(!1),[job,setJob]=React.useState(null),[choices,setChoices]=React.useState({}),[result,setResult]=React.useState(null),[error3,setError]=React.useState(""),[connectionError,setConnectionError]=React.useState(""),[restoring,setRestoring]=React.useState(!0),lifecycle=React.useRef(null);React.useEffect(()=>{let active=!0,restoreTimer,controller=new AbortController;lifecycle.current=controller,api2("import",{},{signal:controller.signal}).then(value=>{active&&setPrompt(String(value.prompt||""))}).catch(reason=>{active&&setError(String(reason?.message||reason))}).finally(()=>{active&&setPromptLoading(!1)});let restore=async()=>{if(await importRequests.get(namespace)?.catch(()=>{}),!!active)return api2("import",{operation:"status",namespace},{signal:controller.signal}).then(value=>{active&&(setConnectionError(""),setRestoring(!1),value?.jobId&&!["undone","abandoned"].includes(value.status)&&(setJob(value),value.status==="committed"&&(setResult(value),clearCommittedDraft(value))))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),restoreTimer=window.setTimeout(restore,2500))})};restore();let onKeyDown=event3=>{event3.key==="Escape"&&onBack()};return window.addEventListener("keydown",onKeyDown),()=>{active=!1,controller.abort(),lifecycle.current=null,window.clearTimeout(restoreTimer),window.removeEventListener("keydown",onKeyDown)}},[]),React.useEffect(()=>{if(!job?.jobId||!["extracting","processing"].includes(job.status))return;let active=!0,timer,controller=new AbortController,poll=()=>api2("import",{operation:"status",namespace,jobId:job.jobId},{signal:controller.signal}).then(next2=>{active&&(setConnectionError(""),setJob(next2),["extracting","processing"].includes(next2.status)&&(timer=window.setTimeout(poll,1200)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),timer=window.setTimeout(poll,2500))});return timer=window.setTimeout(poll,600),()=>{active=!1,controller.abort(),window.clearTimeout(timer)}},[job?.jobId,job?.status,namespace]);let copyPrompt=()=>{if(!prompt)return;(navigator.clipboard?.writeText?navigator.clipboard.writeText(prompt):Promise.reject(new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236"))).then(()=>{setCopied(!0),window.setTimeout(()=>setCopied(!1),1600)}).catch(reason=>setError(String(reason?.message||reason)))},clearCommittedDraft=next2=>{let current=importDrafts.get(namespace);next2.status==="committed"&¤t?.jobId===next2.jobId&¤t.text.trim()===next2.text&&setText("")},mutate=(body,onResult,submission)=>{if(importRequests.has(namespace))return;let controller=lifecycle.current,valid2=()=>controller&&lifecycle.current===controller&&!controller.signal.aborted;setBusy(!0),setError("");let request=api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...body,namespace})});return importRequests.set(namespace,request),request.then(next2=>{if(submission&&importDrafts.get(namespace)===submission&&next2?.jobId&&(submission.jobId=next2.jobId),valid2())return onResult(next2)}).catch(reason=>{valid2()&&setError(String(reason?.message||reason))}).finally(()=>{importRequests.get(namespace)===request&&importRequests.delete(namespace),valid2()&&setBusy(!1)})},analyze=()=>{if(!(!text.trim()||busy||restoring||job&&job.status!=="failed"))return setResult(null),setJob(null),setChoices({}),mutate({operation:"preview",text},setJob,draft)},commit=()=>{if(!job||busy)return;let requestedChoices=(job.decisions||[]).flatMap((decision,index)=>decision.requiresConfirmation?[{index,action:choices[index]||decision.action||"IGNORE"}]:[]);return draft.text.trim()===job.text&&(draft.jobId=job.jobId),mutate({operation:"commit",jobId:job.jobId,choices:requestedChoices},next2=>(clearCommittedDraft(next2),setResult(next2),setJob(next2),refresh()))},retry=()=>{if(!(!job?.jobId||busy))return mutate({operation:"retry",jobId:job.jobId},setJob)},abandon=()=>{if(!(!job?.jobId||busy))return mutate({operation:"abandon",jobId:job.jobId},()=>{setJob(null),setText(""),setChoices({})})},undo=()=>{if(!(!result?.sourceBlockId||busy))return mutate({operation:"undo",sourceBlockId:result.sourceBlockId},()=>(setResult(null),setJob(null),refresh()))},reset2=()=>{setResult(null),setJob(null),setChoices({}),setError("")},actionLabel={ADD:"\u65B0\u589E",MERGE:"\u5408\u5E76",SUPERSEDE:"\u53D6\u4EE3\u65E7\u8BB0\u5FC6",CONFLICT:"\u4FDD\u7559\u5E76\u6807\u8BB0\u51B2\u7A81",IGNORE:"\u5FFD\u7565"},running=job&&["extracting","processing"].includes(job.status),reviewable=job&&["ready","awaiting_confirmation"].includes(job.status),emptyJob=reviewable&&Number(job.totalCount||0)===0,percent=job?job.status==="extracting"?5:job.totalCount?Math.round(job.processedCount/job.totalCount*100):100:0;return h("div",{className:"sg-import-overlay",role:"presentation",onMouseDown:event3=>{event3.target===event3.currentTarget&&onBack()}},h("section",{className:"sg-import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sg-import-title"},h("header",{className:"sg-import-dialog-head"},h("h2",{id:"sg-import-title",className:"sg-import-dialog-title"},"\u5C06\u8BB0\u5FC6\u5BFC\u5165 StrataGate"),h("button",{type:"button",className:"sg-icon-button",onClick:onBack,"aria-label":"\u5173\u95ED"},"\xD7")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"1"),h("span",{className:"sg-import-step-title"},"\u590D\u5236\u4EE5\u4E0B\u63D0\u793A\u8BCD\u5230\u5176\u4ED6 AI \u5BF9\u8BDD\u4E2D"),h("button",{type:"button",className:"sg-import-copy",disabled:promptLoading||!prompt,onClick:copyPrompt},copied?"\u5DF2\u590D\u5236":"\u590D\u5236")),promptLoading?h("div",{className:"sg-import-loading"},"\u6B63\u5728\u52A0\u8F7D\u63D0\u793A\u8BCD\u2026"):h("div",{className:"sg-import-prompt",tabIndex:"0"},prompt||"\u63D0\u793A\u8BCD\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"2"),h("span",{className:"sg-import-step-title"},"\u7C98\u8D34\u7ED3\u679C\uFF0C\u5148\u5206\u6790\u518D\u5BFC\u5165")),h("div",{className:"sg-import-card"},h("textarea",{value:text,disabled:restoring||busy||!!result||!!job&&job.status!=="failed",onChange:event3=>setText(event3.target.value),placeholder:"\u7C98\u8D34 JSON\uFF1B\u683C\u5F0F\u4E0D\u5408\u683C\u65F6\u4F1A\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D","aria-label":"\u5916\u90E8 AI \u8BB0\u5FC6 JSON"})),!job&&!result?h("div",{className:"sg-import-hint"},restoring?"\u6B63\u5728\u68C0\u67E5\u5DF2\u6709\u5BFC\u5165\u4EFB\u52A1\u2026":"\u5173\u95ED\u540E\u53EF\u7EE7\u7EED\u7F16\u8F91\uFF1B\u8349\u7A3F\u4EC5\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u9875\u9762\u4FDD\u7559\uFF0C\u5237\u65B0\u540E\u6E05\u7A7A\u3002"):null),running?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},job.status==="extracting"?"\u6B63\u5728\u4FEE\u590D\u5E76\u63D0\u53D6\u5019\u9009\u8BB0\u5FC6":"\u6B63\u5728\u68C0\u6D4B\u91CD\u590D\u4E0E\u51B2\u7A81")),h("div",{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":percent,style:{height:"9px",overflow:"hidden",borderRadius:"999px",background:"var(--sg-border)"}},h("div",{style:{width:percent+"%",height:"100%",background:"var(--sg-accent)",transition:"width .25s ease"}})),h("div",{className:"sg-import-hint",style:{marginTop:"8px"}},job.status==="extracting"?"\u539F JSON \u4E0D\u5408\u683C\uFF0C\u6B63\u5728\u4F7F\u7528\u6A21\u578B\u515C\u5E95\u3002\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u4EFB\u52A1\u4F1A\u7EE7\u7EED\u3002":"\u5DF2\u5B8C\u6210 "+job.processedCount+"/"+job.totalCount+"\uFF0C\u6B63\u5728\u5224\u65AD\u7B2C "+Math.min(job.processedCount+1,job.totalCount)+" \u6761\uFF1B\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u67E5\u770B\u3002")):null,reviewable?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},"\u5BFC\u5165\u9884\u89C8")),h("div",{className:"sg-import-hint"},emptyJob?"\u6CA1\u6709\u53D1\u73B0\u53EF\u5BFC\u5165\u7684\u957F\u671F\u8BB0\u5FC6\u3002":job.recoveredFromInvalidJson?"\u8FD9\u4E9B\u5019\u9009\u7531\u515C\u5E95\u6A21\u578B\u6062\u590D\uFF0C\u5168\u90E8\u9700\u8981\u4EBA\u5DE5\u786E\u8BA4\u3002":"\u9AD8\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u81EA\u52A8\u91C7\u7528\uFF1B\u4F4E\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u8BF7\u4EBA\u5DE5\u9009\u62E9\u5904\u7406\u65B9\u5F0F\u3002"),h("div",{className:"sg-import-preview"},(job.decisions||[]).map((decision,index)=>h("div",{key:index,className:"sg-import-preview-item"},h("div",{className:"sg-import-preview-title"},decision.candidate?.title||"\u672A\u547D\u540D\u8BB0\u5FC6"),h("div",{className:"sg-import-preview-content"},h("strong",null,"\u65B0\u8BB0\u5FC6\uFF1A"),h("span",null,decision.candidate?.summary||"\u65E0\u5185\u5BB9"),decision.candidate?.narrative?h("div",null,decision.candidate.narrative):null),decision.mergedCandidate?h("div",{className:"sg-import-preview-content"},h("strong",null,"\u5408\u5E76\u540E\uFF1A"),h("span",null,decision.mergedCandidate.title+"\uFF1A"+decision.mergedCandidate.summary)):null,decision.existingEventIds?.length&&decision.matches?.length?h("div",{className:"sg-import-preview-content"},h("strong",null,"\u53D7\u5F71\u54CD\u7684\u65E7\u8BB0\u5FC6\uFF1A"),decision.matches.filter(match2=>decision.existingEventIds.includes(match2.event.id)).map(match2=>h("div",{key:match2.event.id},match2.event.title+"\uFF1A"+match2.event.summary))):null,h("div",{className:"sg-import-preview-meta"},h("span",null,actionLabel[decision.action]||decision.action),h("span",null,"\u7F6E\u4FE1\u5EA6 "+Math.round(Number(decision.confidence||0)*100)+"%"),decision.existingEventIds?.length?h("span",null,"\u5173\u8054 "+decision.existingEventIds.length+" \u6761"):null),decision.reason?h("div",{className:"sg-import-preview-reason"},decision.reason):null,decision.requiresConfirmation?h("label",{className:"sg-import-review"},h("span",null,"\u4EBA\u5DE5\u9009\u62E9"),h("select",{value:choices[index]||decision.action,onChange:event3=>setChoices(current=>({...current,[index]:event3.target.value}))},(decision.existingEventIds?.length?["ADD","MERGE","SUPERSEDE","CONFLICT","IGNORE"]:["ADD","IGNORE"]).map(action=>h("option",{key:action,value:action},actionLabel[action])))):null)))):null,job?.status==="failed"?h("div",{className:"sg-import-error"},"\u4EFB\u52A1\u5931\u8D25\uFF1A"+(job.lastError||"\u672A\u77E5\u9519\u8BEF")):null,connectionError?h("div",{className:"sg-import-hint"},connectionError):null,error3?h("div",{className:"sg-import-error"},error3):null,result?h("div",{className:"sg-import-result"},"\u5BFC\u5165\u5B8C\u6210\uFF1A\u65B0\u589E "+Number(result.importedCount||0)+" \u6761\u8BB0\u5FC6\u3002\u53EF\u7ACB\u5373\u64A4\u9500\u672C\u6279\u6B21\u3002"):null,h("footer",{className:"sg-import-dialog-foot"},result?h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:undo},busy?"\u6B63\u5728\u64A4\u9500\u2026":"\u64A4\u9500\u672C\u6B21\u5BFC\u5165"):h("button",{type:"button",className:"sg-import-cancel",onClick:onBack},running?"\u5173\u95ED\uFF0C\u540E\u53F0\u7EE7\u7EED":"\u5173\u95ED"),!job&&!result&&text?h("button",{type:"button",className:"sg-import-cancel",disabled:restoring||busy,onClick:()=>{setText(""),setError("")}},"\u653E\u5F03\u8349\u7A3F"):null,result?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):job?.status==="failed"?h(React.Fragment,null,h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:()=>{setJob(null),setChoices({}),setError("")}},"\u4FEE\u6539\u540E\u91CD\u65B0\u5206\u6790"),h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:abandon},"\u653E\u5F03\u672C\u6B21\u5BFC\u5165"),h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:retry},busy?"\u6B63\u5728\u91CD\u8BD5\u2026":"\u91CD\u8BD5")):emptyJob?h("button",{type:"button",className:"sg-import-button",onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):reviewable?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:commit},busy?"\u6B63\u5728\u5BFC\u5165\u2026":"\u786E\u8BA4\u5BFC\u5165"):running?h("button",{type:"button",className:"sg-import-button",disabled:!0},"\u540E\u53F0\u5904\u7406\u4E2D"):h("button",{type:"button",className:"sg-import-button",disabled:restoring||busy||!text.trim(),onClick:analyze},busy?"\u6B63\u5728\u521B\u5EFA\u4EFB\u52A1\u2026":"\u5206\u6790\u5E76\u9884\u89C8"))))}function SettingStepper({value,unit="",min:min4=1,max:max5=30,step:step3=1,disabled=!1,label,onChange}){let current=Number(value),bump=direction=>{if(!Number.isFinite(current)||disabled)return;let next2=Math.min(max5,Math.max(min4,Number((current+direction*step3).toFixed(2))));next2!==current&&onChange(next2)};return h("span",{className:"sg-stp",role:"group","aria-label":label},h("button",{type:"button","aria-label":"\u51CF\u5C11"+label,disabled:disabled||!Number.isFinite(current)||current<=min4,onClick:()=>bump(-1)},"\u2212"),h("span",{"aria-live":"polite",className:"sg-stp-value"},(Number.isFinite(current)?String(current):"")+unit),h("button",{type:"button","aria-label":"\u589E\u52A0"+label,disabled:disabled||!Number.isFinite(current)||current>=max5,onClick:()=>bump(1)},"+"))}function MoreHome({setView,selected,overview={},namespace,dataDirectory,updateSettings,savingSettings,usePluginSettings,setStrataGateStatus,setShortTermStatus,setRetrievalStatus,setSidebarEntry,setDailyEnabled,setDailyInjectionDays}){let pluginSettings=usePluginSettings?usePluginSettings(state=>state):null,settingsWritable=pluginSettings?.writable===!0,[pending,setPending]=React.useState({}),[settingError,setSettingError]=React.useState({key:"",text:""}),[savingKey,setSavingKey]=React.useState(""),[copyState,setCopyState]=React.useState("");React.useEffect(()=>{setPending({blockTurnSize:String(selected?.blockTurnSize??6),blockDecayLambda:String(selected?.blockDecayLambda??.3),agentMemoryRetrievalWeight:String(selected?.agentMemoryRetrievalWeight??1)})},[selected?.blockTurnSize,selected?.blockDecayLambda,selected?.agentMemoryRetrievalWeight]);let engine=[["blockTurnSize","\u6BCF\u5757\u8F6E\u6570","",1,30,1],["blockDecayLambda","\u8870\u51CF\u7CFB\u6570","",0,.4,.05],["agentMemoryRetrievalWeight","\u4E3B\u52A8\u68C0\u7D22\u5360\u6BD4","",0,5,.05]],saved=key=>Number(selected?.[key]??(key==="blockTurnSize"?6:key==="blockDecayLambda"?.3:1)),changedKeys=engine.map(([key])=>key).filter(key=>pending[key]!==void 0&&Number(pending[key])!==saved(key)&&pending[key]!==""),validEngine=engine.every(([key])=>{let raw=pending[key];return raw!==void 0&&raw!==""&&Number.isFinite(Number(raw))}),saveEngine=async()=>{if(!(!changedKeys.length||!validEngine||savingSettings)){setSettingError({key:"",text:""});try{await updateSettings({blockTurnSize:Number(pending.blockTurnSize),blockDecayLambda:Number(pending.blockDecayLambda),agentMemoryRetrievalWeight:Number(pending.agentMemoryRetrievalWeight)})}catch(reason){setSettingError({key:"engine",text:"\u672A\u80FD\u4FDD\u5B58\u5F15\u64CE\u53C2\u6570\uFF1A"+String(reason?.message||reason)})}}},discardEngine=()=>setPending({blockTurnSize:String(saved("blockTurnSize")),blockDecayLambda:String(saved("blockDecayLambda")),agentMemoryRetrievalWeight:String(saved("agentMemoryRetrievalWeight"))}),toggle=async(key,setter,next2)=>{if(setter){setSavingKey(key),setSettingError({key:"",text:""});try{await setter(next2)||setSettingError({key,text:"\u672A\u80FD\u4FDD\u5B58\u8FD9\u9879\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key,text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}finally{setSavingKey("")}}},stepDays=async next2=>{if(setDailyInjectionDays){setSavingKey("dailyDays"),setSettingError({key:"",text:""});try{await setDailyInjectionDays(next2)||setSettingError({key:"dailyDays",text:"\u5929\u6570\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key:"dailyDays",text:"\u5929\u6570\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}finally{setSavingKey("")}}},copyWorkspace=async()=>{if(navigator?.clipboard?.writeText)try{await navigator.clipboard.writeText(namespace||""),setCopyState("\u5DF2\u590D\u5236"),setSettingError({key:"",text:""})}catch{setSettingError({key:"workspace",text:"\u590D\u5236\u5DE5\u4F5C\u533A ID \u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236\u3002"})}},retry=async(key,apply3)=>{setSettingError({key:"",text:""});try{await apply3()||setSettingError({key,text:"\u4ECD\u7136\u65E0\u6CD5\u4FDD\u5B58\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key,text:"\u4ECD\u7136\u65E0\u6CD5\u4FDD\u5B58\uFF1A"+String(reason?.message||reason)})}},rowError=(key,apply3)=>settingError.key===key?h("p",{className:"sg-more-error",role:"alert"},settingError.text,apply3?h("button",{type:"button",className:"sg-more-retry",onClick:()=>{retry(key,apply3)}},"\u91CD\u8BD5"):null):null,switchRow=({key,title,description,checked,setter,disabled=!1,child=!1})=>h("li",{key,className:"sg-more-row sg-more-switch"+(child?" child":"")},h("div",null,h("span",{className:"sg-k2"},title),description?h("span",{className:"sg-s2"},description):null,rowError(key,()=>setter(!checked))),h("button",{type:"button",className:"sg-setting-switch",role:"switch","aria-label":title,"aria-checked":checked,disabled:disabled||!settingsWritable||savingKey===key,onClick:()=>{toggle(key,setter,!checked)}})),goRow=(key,title,description,view)=>h("li",{key,className:"sg-more-row"},h("button",{type:"button",className:"sg-more-go",onClick:()=>setView({name:view})},h("div",null,h("span",{className:"sg-k2"},title),description?h("span",{className:"sg-s2"},description):null),h("span",{className:"sg-row-go","aria-hidden":"true"},"\u203A"))),group2=(title,rows,extra="")=>h("section",{key:title,className:"sg-profile-group","aria-label":title},h("h4",null,title),h("ul",null,rows,extra)),duplicates=Number(selected?.duplicateRepair?.needsReview||0),failed=Number(selected?.failedJobs||0),processing=Number(selected?.processingJobs||0),statusRows=[h("li",{key:"kpi",className:"sg-more-kpi"},h("div",null,["blocks","events","graphNodes"].map((key,index)=>h("div",{key},h("b",null,String(Number(selected?.[key]||0))),h("span",null,["\u8BB0\u5FC6\u5757","\u4E8B\u4EF6","\u56FE\u8C31\u8282\u70B9"][index]))))),goRow("system","\u7CFB\u7EDF\u72B6\u6001",failed?failed+" \u4E2A\u4EFB\u52A1\u9700\u8981\u91CD\u8BD5":processing?processing+" \u4E2A\u4EFB\u52A1\u8FDB\u884C\u4E2D":"\u8FD0\u884C\u6B63\u5E38","system"),goRow("duplicates","\u91CD\u590D\u8BB0\u5FC6",duplicates?duplicates+" \u7EC4\u7B49\u4F60\u786E\u8BA4":"\u6CA1\u6709\u9700\u8981\u786E\u8BA4\u7684\u5206\u7EC4","duplicates")],dataRows=[goRow("import","\u5BFC\u5165\u5176\u4ED6 AI \u7684\u8BB0\u5FC6","\u628A\u522B\u7684 AI \u7684\u5386\u53F2\u8BB0\u5FC6\u5E26\u8FDB\u6765","import"),h("li",{key:"directory",className:"sg-more-row sg-more-row-path"},h("div",{className:"sg-more-path"},h("span",{className:"sg-k2"},"\u6570\u636E\u76EE\u5F55"),h("span",{className:"sg-s2 sg-mono sg-path",title:dataDirectory||void 0},dataDirectory||"\u5F53\u524D\u4F7F\u7528\u5185\u5B58\u5B58\u50A8")),h("button",{type:"button",className:"sg-quiet-button",disabled:!dataDirectory,onClick:()=>{api2("storage/open-directory",{},{method:"POST"}).catch(reason=>setSettingError({key:"directory",text:"\u6253\u5F00\u5931\u8D25\uFF1A"+String(reason?.message||reason)}))}},"\u6253\u5F00")),h("li",{key:"workspace",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"\u5F53\u524D\u5DE5\u4F5C\u533A"),h("span",{className:"sg-s2 sg-mono"},selected?.workspaceName||"\u5F53\u524D\u5DE5\u4F5C\u533A")),h("button",{type:"button",className:"sg-quiet-button",disabled:!namespace,onClick:copyWorkspace},copyState||"\u590D\u5236 ID"))],feedbackRows=[h("li",{key:"issue",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"GitHub Issue"),h("span",{className:"sg-s2"},"\u95EE\u9898\u548C\u5EFA\u8BAE\u63D0\u5230 GitHub")),h("a",{className:"sg-quiet-button",href:ISSUE_URL,target:"_blank",rel:"noopener noreferrer"},"\u63D0 Issue")),goRow("support","\u751F\u6210\u53CD\u9988\u62A5\u544A","\u53D1\u51FA\u524D\u53EF\u4EE5\u5148\u770B\u5B8C\u6574\u5185\u5BB9","support")],displayRows=[switchRow({key:"sidebar",title:"\u653E\u5230\u5DE6\u4FA7\u680F",checked:pluginSettings?.value?.showSidebarEntry===!0,setter:setSidebarEntry}),switchRow({key:"shortStatus",title:"\u4F1A\u8BDD\u8BB0\u5FC6\u72B6\u6001",checked:pluginSettings?.value?.showShortTermStatus!==!1,setter:setShortTermStatus}),switchRow({key:"retrievalStatus",title:"\u8BB0\u5FC6\u68C0\u7D22\u72B6\u6001",checked:pluginSettings?.value?.showRetrievalStatus!==!1,setter:setRetrievalStatus}),pluginSettings?.value?.showStrataGateStatus===!1?switchRow({key:"master",title:"\u6062\u590D\u72B6\u6001\u63D0\u793A",description:"\u4E4B\u524D\u6574\u4F53\u5173\u95ED\u4E86\u804A\u5929\u754C\u9762\u7684\u72B6\u6001\u63D0\u793A",checked:!1,setter:setStrataGateStatus}):null].filter(Boolean),dailyRows=[switchRow({key:"daily",title:"\u5199\u6BCF\u65E5\u7B14\u8BB0",description:"\u5173\u95ED\u540E\u4E0D\u518D\u5199\u5165\uFF0C\u5DF2\u6709\u7B14\u8BB0\u4FDD\u7559",checked:pluginSettings?.value?.dailyNotesEnabled!==!1,setter:setDailyEnabled}),h("li",{key:"days",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"\u5E26\u5165\u5929\u6570"),h("span",{className:"sg-s2"},"\u53D6\u6700\u8FD1\u6709\u7B14\u8BB0\u7684\u65E5\u671F")),SettingStepper({value:pluginSettings?.value?.dailyNotesInjectionDays??3,unit:" \u5929",min:1,max:30,disabled:!settingsWritable||savingKey==="dailyDays",label:"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u5929\u6570",onChange:next2=>{stepDays(next2)}}))],engineRows=engine.map(([key,title,unit,min4,max5,step3])=>{let dirty=changedKeys.includes(key);return h("li",{key,className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"+(dirty?" dirty":"")},title)),h("span",{className:"sg-engine-value"+(dirty?" dirty":"")},SettingStepper({value:pending[key]??saved(key),unit,min:min4,max:max5,step:step3,disabled:savingSettings,label:title,onChange:next2=>setPending(current=>({...current,[key]:String(next2)}))})))});return h(React.Fragment,null,h("div",{className:"sg-pg-head"},h("h2",null,"\u66F4\u591A")),h("div",{className:"sg-more"},h("div",{className:"sg-more-col"},group2("\u8FD0\u884C\u72B6\u6001",statusRows),group2("\u6570\u636E",dataRows),group2("\u53CD\u9988",feedbackRows)),h("div",{className:"sg-more-col"},group2("\u663E\u793A",displayRows),group2("\u77ED\u671F\u8BB0\u5FC6",dailyRows),group2("\u5F15\u64CE\u53C2\u6570",engineRows,h(React.Fragment,null,rowError("engine",()=>updateSettings({blockTurnSize:Number(pending.blockTurnSize),blockDecayLambda:Number(pending.blockDecayLambda),agentMemoryRetrievalWeight:Number(pending.agentMemoryRetrievalWeight)})),changedKeys.length?h("li",{className:"sg-dirty"},h("span",null,changedKeys.length+" \u9879\u672A\u4FDD\u5B58"),h("button",{type:"button",className:"sg-quiet-button",disabled:savingSettings,onClick:discardEngine},"\u653E\u5F03"),h("button",{type:"button",className:"sg-save-button",disabled:savingSettings||!validEngine,onClick:()=>{saveEngine()}},savingSettings?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58")):null)))))}function DisplayPage({onBack,usePluginSettings,setStrataGateStatus,setShortTermStatus,setRetrievalStatus,setSidebarEntry}){let pluginSettings=usePluginSettings?usePluginSettings(state=>state):null,settingsWritable=pluginSettings?.writable===!0,[sidebarSaving,setSidebarSaving]=React.useState(!1),[sidebarError,setSidebarError]=React.useState(""),changeSidebar=async visible=>{setSidebarSaving(!0),setSidebarError("");try{await setSidebarEntry?.(visible)||setSidebarError("\u672A\u80FD\u4FDD\u5B58\u4FA7\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002")}catch{setSidebarError("\u672A\u80FD\u4FDD\u5B58\u4FA7\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002")}finally{setSidebarSaving(!1)}},showStrataGateStatus=strataGateStatusVisible(pluginSettings),showShortTermStatus=pluginSettings?.value?.showShortTermStatus!==!1,showRetrievalStatus=pluginSettings?.value?.showRetrievalStatus!==!1,setting=({title,description,checked,disabled=!1,onChange,child=!1})=>h("div",{className:"sg-display-setting "+(child?"child ":"")+(disabled?"sg-display-disabled":"")},h("span",{className:"sg-display-setting-copy"},h("span",{className:"sg-display-setting-title"},title),h("span",{className:"sg-display-setting-description"},description)),h("button",{type:"button",className:"sg-setting-switch",role:"switch","aria-checked":checked,"aria-label":title,disabled:!settingsWritable||disabled,onClick:()=>{onChange&&onChange(!checked)}}));return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-pg-head"},h("h2",null,"\u754C\u9762\u4E0E\u663E\u793A")),h("p",{className:"sg-settings-group-copy"},"\u63A7\u5236\u4FA7\u680F\u5165\u53E3\u548C\u804A\u5929\u754C\u9762\u4E2D\u7684\u663E\u793A\u4FE1\u606F\u3002\u8BBE\u7F6E\u5BF9\u6240\u6709\u5DE5\u4F5C\u533A\u751F\u6548\u3002"),h("div",{className:"sg-settings-panel sg-display-settings"},setting({title:"\u5728\u5DE6\u4FA7\u680F\u663E\u793A StrataGate",description:"\u5173\u95ED\u540E\u9690\u85CF\u4FA7\u680F\u5165\u53E3\uFF0C\u4ECD\u53EF\u4ECE\u8BBE\u7F6E\u6253\u5F00\uFF1B\u8BB0\u5FC6\u3001\u68C0\u7D22\u548C\u540E\u53F0\u5904\u7406\u4E0D\u53D7\u5F71\u54CD\u3002",checked:pluginSettings?.value?.showSidebarEntry===!0,disabled:sidebarSaving||!setSidebarEntry,onChange:changeSidebar}),sidebarError?h("p",{role:"alert",className:"sg-error-note"},sidebarError):null,setting({title:"\u663E\u793A StrataGate \u72B6\u6001\u63D0\u793A",description:"\u5173\u95ED\u540E\u9690\u85CF\u804A\u5929\u754C\u9762\u4E2D\u7684 StrataGate \u72B6\u6001\u4FE1\u606F\uFF0C\u4E0D\u5F71\u54CD\u8BB0\u5FC6\u3001\u68C0\u7D22\u548C\u540E\u53F0\u5904\u7406\u3002",checked:showStrataGateStatus,onChange:setStrataGateStatus}),setting({title:"\u4F1A\u8BDD\u8BB0\u5FC6\u72B6\u6001",description:"\u663E\u793A Block \u8FDB\u5EA6\u3001\u5C01\u5B58\u7ED3\u679C\u548C\u6B63\u5728\u6574\u7406\u4F1A\u8BDD\u8BB0\u5FC6\u7B49\u72B6\u6001\u3002",checked:showShortTermStatus,disabled:!showStrataGateStatus,onChange:setShortTermStatus,child:!0}),setting({title:"\u8BB0\u5FC6\u68C0\u7D22\u72B6\u6001",description:"\u663E\u793A\u68C0\u7D22\u6B21\u6570\u3001\u8FD4\u56DE\u6570\u91CF\uFF0C\u4EE5\u53CA\u56DE\u7B54\u4E0B\u65B9\u7684\u8BB0\u5FC6\u91C7\u7528\u4FE1\u606F\u3002",checked:showRetrievalStatus,disabled:!showStrataGateStatus,onChange:setRetrievalStatus,child:!0})))}function redactText(value){return String(value??"").split(/\nRaw response(?: preview| \(full\))/i)[0].replace(/\b(?:sk[-_]|gh[opasu]_|github_pat_)[A-Za-z0-9_-]{8,}\b/g,"[REDACTED]").replace(/(["']?\b(?:api[_-]?key|token|password|passwd|access[_-]?token|refresh[_-]?token|secret|authorization)["']?\s*[:=]\s*)(["'])([\s\S]*?)\2/gi,"$1$2[REDACTED]$2").replace(/(\bauthorization\s*[:=]\s*)(Bearer|Basic|Token)\s+[^\s,;}]+/gi,"$1$2 [REDACTED]").replace(/\bBearer\s+[A-Za-z0-9._~+\/-]{8,}={0,2}\b/gi,"Bearer [REDACTED]").replace(/\b(?:Basic|Token)\s+[^\s,;}]+/gi,match2=>match2.replace(/\s+[^\s,;}]+$/," [REDACTED]")).replace(/(["']?\b(?:api[_-]?key|token|password|passwd|access[_-]?token|refresh[_-]?token|secret|authorization)["']?\s*[:=]\s*)([^\s,;}]+)/gi,"$1[REDACTED]").replace(/https?:\/\/[^\s<>"']+/gi,"[url]").replace(/[A-Z]:[\\/][^\s"'<>]+/gi,"[path]").replace(/\\\\[^\s"'<>\\]+\\[^\s"'<>]+/g,"[path]").replace(/(^|[\s"'(=:])\/(?:[^\s"'<>/]+\/)+[^\s"'<>]*/g,"$1[path]").replace(/[\w.+-]+@[\w.-]+\.[a-z]{2,}/gi,"[email]")}function redactedJson(value){let sensitive=/^(password|passwd|token|access[_-]?token|refresh[_-]?token|api[_-]?key|secret|authorization)$/i,visit=(current,key="")=>sensitive.test(String(key))?"[REDACTED]":typeof current=="string"?redactText(current):Array.isArray(current)?current.map(item=>visit(item)):current&&typeof current=="object"?Object.fromEntries(Object.entries(current).map(([name,item])=>[name,visit(item,name)])):current;return JSON.stringify(visit(value),null,2)??"null"}function restoreFeedbackDraftValues(draft,touched={}){return{title:touched.title?void 0:String(draft?.title||""),problemContent:touched.body?void 0:feedbackDraftMarkdown(draft)}}function whitelistedMessage(message){return{id:message?.id,role:message?.role,content:message?.content,createdAt:message?.createdAt,threadId:message?.threadId,toolCalls:Array.isArray(message?.toolCalls)?message.toolCalls.map(call=>({name:call?.name,arguments:call?.arguments,result:call?.result})):void 0}}function whitelistedEvent(event3){let temporal=event3?.temporal,weight8=event3?.weight;return{id:event3?.id,formedTurn:event3?.formedTurn,title:event3?.title,summary:event3?.summary,tags:event3?.tags,quotes:event3?.quotes,sourceBlockId:event3?.sourceBlockId,sourceMessageIds:event3?.sourceMessageIds,temporal:temporal?{mentionedAt:temporal.mentionedAt,happenedStart:temporal.happenedStart,happenedEnd:temporal.happenedEnd,originalText:temporal.originalText,precision:temporal.precision,basis:temporal.basis,status:temporal.status,participants:temporal.participants,participantNodeIds:temporal.participantNodeIds,eventType:temporal.eventType,threadId:temporal.threadId,sameEventId:temporal.sameEventId,beforeEventIds:temporal.beforeEventIds,afterEventIds:temporal.afterEventIds,supersedesEventIds:temporal.supersedesEventIds,conflictsWithEventIds:temporal.conflictsWithEventIds,relatedEventIds:temporal.relatedEventIds}:void 0,scope:event3?.scope,criticality:event3?.criticality,status:event3?.status,supersededBy:event3?.supersededBy,weight:weight8?{mentionCount:weight8.mentionCount,lastAdoptedTurn:weight8.lastAdoptedTurn,lastRetrievedAt:weight8.lastRetrievedAt,pinned:weight8.pinned,floorWeight:weight8.floorWeight,forcedCap:weight8.forcedCap}:void 0,createdAt:event3?.createdAt,updatedAt:event3?.updatedAt}}function whitelistedBlock(block){let source=block?.source||block||{},messages=block?.messages||block?.l5Raw||source?.l5Raw;return{id:block?.id??source?.id,threadId:block?.threadId??source?.threadId,sequence:block?.sequence??source?.sequence,blockIndex:block?.blockIndex,turnRange:block?.turnRange||(source?.startTurn!==void 0&&source?.endTurn!==void 0?[source.startTurn,source.endTurn]:void 0),title:block?.title??source?.l0Title,tags:block?.tags??source?.l0Tags,summary:block?.summary??source?.l1Summary,keypoints:block?.keypoints??source?.l2Keypoints,condensed:source?.l3Condensed,readable:source?.l4Readable,messages:Array.isArray(messages)?messages.map(whitelistedMessage):void 0,layers:Array.isArray(block?.layers)?block.layers.map(layer=>({level:layer?.level,content:layer?.content,tokens:layer?.tokens,percentOfL5:layer?.percentOfL5})):void 0,currentLevel:block?.currentLevel??source?.pointerCurrentLevel,currentTokens:block?.currentTokens,l5Tokens:block?.l5Tokens,compressionPercent:block?.compressionPercent,layerTokens:block?.layerTokens,distanceFromLatest:block?.distanceFromLatest,expansionSource:block?.expansionSource,lastLiftedAt:block?.lastLiftedAt??source?.lastLiftedAt,sourceMessages:block?.sourceMessages,createdAt:block?.createdAt??source?.createdAt,virtual:block?.virtual,processingStatus:block?.processingStatus??source?.processingStatus,summaryJob:block?.summaryJob?{status:block.summaryJob.status,attempts:block.summaryJob.attempts,nextRetryAt:block.summaryJob.nextRetryAt,updatedAt:block.summaryJob.updatedAt}:void 0,eventExtraction:block?.eventExtraction?{status:block.eventExtraction.status,attempts:block.eventExtraction.attempts,updatedAt:block.eventExtraction.updatedAt,lastError:block.eventExtraction.lastError}:void 0,graphProjection:block?.graphProjection?{status:block.graphProjection.status,jobs:block.graphProjection.jobs,lastError:block.graphProjection.lastError}:void 0,relatedEvents:Array.isArray(block?.relatedEvents)?block.relatedEvents.map(whitelistedEvent):void 0,relatedNodes:Array.isArray(block?.relatedNodes)?block.relatedNodes.map(node=>({id:node?.id,name:node?.name,type:node?.type})):void 0}}function whitelistedGraphNode(node){return{id:node?.id,name:node?.name,type:node?.type,aliases:node?.aliases,tags:node?.tags,currentState:node?.currentState,facts:Array.isArray(node?.facts)?node.facts.map(fact=>({id:fact?.id,key:fact?.key,value:fact?.value,status:fact?.status,validFrom:fact?.validFrom,validTo:fact?.validTo,confidence:fact?.confidence,sourceEventIds:fact?.sourceEventIds,createdAt:fact?.createdAt,updatedAt:fact?.updatedAt})):void 0,status:node?.status,confidence:node?.confidence,sourceEventIds:node?.sourceEventIds,supportingEvents:Array.isArray(node?.supportingEvents)?node.supportingEvents.map(whitelistedEvent):void 0,createdAt:node?.createdAt,updatedAt:node?.updatedAt}}function whitelistedGraph(graph){return{projectorVersion:graph?.projectorVersion,nodes:Array.isArray(graph?.nodes)?graph.nodes.map(whitelistedGraphNode):[],edges:Array.isArray(graph?.edges)?graph.edges.map(edge=>({id:edge?.id,fromNodeId:edge?.fromNodeId,toNodeId:edge?.toNodeId,relation:edge?.relation,status:edge?.status,validFrom:edge?.validFrom,validTo:edge?.validTo,confidence:edge?.confidence,sourceEventIds:edge?.sourceEventIds,createdAt:edge?.createdAt,updatedAt:edge?.updatedAt})):[],clusters:Array.isArray(graph?.clusters)?graph.clusters.map(cluster=>({id:cluster?.id,label:cluster?.label,nodeIds:cluster?.nodeIds,tags:cluster?.tags})):[],migration:graph?.migration?{projected:graph.migration.projected,total:graph.migration.total,pending:graph.migration.pending,running:graph.migration.running,failed:graph.migration.failed,retryable:graph.migration.retryable,processing:graph.migration.processing,state:graph.migration.state,complete:graph.migration.complete}:null}}function feedbackDraftMarkdown(draft={}){if(String(draft.bodyMarkdown||"").trim())return String(draft.bodyMarkdown).trim();let lines=[],section=(heading,value)=>{let text=String(value||"").trim();text&&lines.push("## "+heading,"",text,"")};section("\u95EE\u9898\u63CF\u8FF0",draft.description);let steps=Array.isArray(draft.reproduction)?draft.reproduction.map(value=>String(value||"").trim()).filter(Boolean):[];return steps.length&&lines.push("## \u590D\u73B0\u6B65\u9AA4","",...steps.map((value,index)=>index+1+". "+value),""),section("\u9884\u671F\u884C\u4E3A",draft.expected),section("\u5B9E\u9645\u884C\u4E3A",draft.actual),section("\u76F8\u5173\u9519\u8BEF\u4FE1\u606F",draft.errorContext),lines.join(`
|
|
1188
|
+
`)||"\u70B9\u5DE6\u4FA7\u5C0F\u8282\uFF0C\u7FFB\u5F00\u5177\u4F53\u4E8B\u4EF6\u3002")):null,unassignedTotal?h("section",{className:"sg-topic-pending","aria-label":"\u5F85\u6574\u7406\u4E8B\u4EF6"},h("div",{className:"sg-topic-pending-heading"},h("button",{type:"button",className:"sg-topic-pending-toggle","aria-expanded":pendingOpen,"aria-controls":"sg-topic-pending-events",onClick:()=>setPendingOpen(value=>!value)},h("span",{className:"sg-topic-pending-label"},"\u5F85\u6574\u7406"),h("span",null,unassignedTotal+" \u6761"),h("span",{className:"sg-directory-chevron","aria-hidden":"true"},"\u203A")),h(DreamingPanel,{key:namespace,namespace,initialRun:directory?.dreaming,active,available:unassignedTotal>0&&!blocked,inline:!0,onDirectoryChanged,onOpenDreamingSession})),h(DirectoryFold,{open:pendingOpen,id:"sg-topic-pending-events"},h("p",null,"\u8FD9\u4E9B\u8BB0\u5FC6\u5C1A\u672A\u5F62\u6210\u7A33\u5B9A\u4E3B\u9898\uFF0C\u4ECD\u53EF\u76F4\u63A5\u67E5\u770B\u539F\u4E8B\u4EF6\u3002"),h(TopicEventList,{namespace,revision:pageRevision,topicId:"pending",total:pendingTotal,active:active&&!blocked&&pendingOpen,openEvent,onDirectoryChanged:invalidate,expandLabel:"\u67E5\u770B\u5168\u90E8\u5F85\u6574\u7406",collapseLabel:"\u6536\u8D77\u5F85\u6574\u7406\u4E8B\u4EF6"}))):null,h("div",{className:"sg-toc-foot sg-leaf-foot"},dreamSummary(),h(DirectoryContextPreview,{context:blocked?"":directory?.context,active}))))))}function LongTermPage({events,eventPage,graph,graphSettings={},project,query,setQuery,openEvent,namespace,focusNodeId,onFocusHandled,topicDirectory,onDirectoryChanged,onOpenDreamingSession,extractionGap=!1,active=!0,refresh}){let graphVisible=graphSettings.enabled===!0||graphSettings.noticeSeen!==!0,[mode,setMode]=React.useState("topics"),[selectedNodeId,setSelectedNodeId]=React.useState(""),[selectedEventId,setSelectedEventId]=React.useState(""),[graphNodeLimit,setGraphNodeLimit]=React.useState(100),[eventFilters,setEventFilters]=React.useState({time:"",node:"",type:"",status:""}),[nodeType,setNodeType]=React.useState(""),[nodeTag,setNodeTag]=React.useState(""),[filtersOpen,setFiltersOpen]=React.useState(!1),[fullScreen,setFullScreen]=React.useState(!1),[graphMenuOpen,setGraphMenuOpen]=React.useState(!1),graphMenuRef=React.useRef(null),debouncedQuery=useDebouncedValue(query),timelineParams=mode==="timeline"?{timeline:"true",...debouncedQuery.trim()?{q:debouncedQuery.trim()}:{},...eventFilters.time?{time:eventFilters.time}:{},...eventFilters.node?{participant:eventFilters.node}:{},...eventFilters.type?{eventType:eventFilters.type}:{},...eventFilters.status?{eventStatus:eventFilters.status}:{}}:{},pagedEvents=usePagedMemory({namespace,kind:"events",initialItems:events,initialPage:eventPage,fallbackLimit:40,extraParams:timelineParams,reloadOnParamsChange:mode==="timeline"}),timelineEvents=pagedEvents.items,nodes3=graph.nodes||[],edges3=graph.edges||[],clusters=graph.clusters||[],normalized=query.trim().toLocaleLowerCase(),nodeImportance=React.useMemo(()=>graphNodeImportance(nodes3,edges3,project),[nodes3,edges3,project]),nodeTags=[...new Set(nodes3.flatMap(node=>node.tags||[]))].sort((left,right)=>left.localeCompare(right));React.useEffect(()=>{if(!graphVisible||!focusNodeId||!nodes3.some(node=>node.id===focusNodeId))return;setMode("graph"),setNodeType(""),setNodeTag("");let rank=[...nodes3].sort((left,right)=>(nodeImportance.get(right.id)?.score||0)-(nodeImportance.get(left.id)?.score||0)).findIndex(node=>node.id===focusNodeId);rank>=0&&setGraphNodeLimit(current=>Math.max(current,rank+1)),setSelectedNodeId(focusNodeId),setFullScreen(!0),onFocusHandled?.()},[graphVisible,focusNodeId,nodes3,nodeImportance,onFocusHandled]),React.useEffect(()=>{if(!fullScreen||!active)return;let previous=document.body.style.overflow;document.body.style.overflow="hidden";let onKeyDown=event3=>{event3.key==="Escape"&&(document.querySelector('.sg-long-explorer .sg-info-trigger[aria-expanded="true"]')||(setFullScreen(!1),setFiltersOpen(!1)))};return window.addEventListener("keydown",onKeyDown),()=>{document.body.style.overflow=previous,window.removeEventListener("keydown",onKeyDown)}},[fullScreen,active]),React.useEffect(()=>{if(!graphMenuOpen)return;let onPointerDown=event3=>{graphMenuRef.current?.contains(event3.target)||setGraphMenuOpen(!1)},onKeyDown=event3=>{event3.key==="Escape"&&setGraphMenuOpen(!1)};return document.addEventListener("pointerdown",onPointerDown),document.addEventListener("keydown",onKeyDown),()=>{document.removeEventListener("pointerdown",onPointerDown),document.removeEventListener("keydown",onKeyDown)}},[graphMenuOpen]);let visibleNodes=nodes3.filter(node=>node.status!=="archived").filter(node=>!nodeType||node.type===nodeType).filter(node=>!nodeTag||(node.tags||[]).includes(nodeTag)).filter(node=>!normalized||JSON.stringify(node).toLocaleLowerCase().includes(normalized)),visibleGraphIds=new Set(visibleNodes.map(node=>node.id)),displayedGraphIds=new Set([...visibleNodes].sort((left,right)=>(nodeImportance.get(right.id)?.score||0)-(nodeImportance.get(left.id)?.score||0)).slice(0,graphNodeLimit).map(node=>node.id)),activeEdges=edges3.filter(edge=>edge.status==="active"&&visibleGraphIds.has(edge.fromNodeId)&&visibleGraphIds.has(edge.toNodeId)),displayedEdgeCount=activeEdges.filter(edge=>displayedGraphIds.has(edge.fromNodeId)&&displayedGraphIds.has(edge.toNodeId)).length,displayedNodeCount=Math.min(graphNodeLimit,visibleNodes.length),countText=(shown,total,unit)=>(shown===total?String(total):shown+" / "+total)+" "+unit,resultCount=mode==="graph"?countText(displayedNodeCount,visibleNodes.length,"\u4E2A\u8282\u70B9")+" \xB7 "+countText(displayedEdgeCount,activeEdges.length,"\u6761\u5173\u7CFB"):countText(timelineEvents.length,pagedEvents.page.total,"\u6761\u4E8B\u4EF6"),selectEvent=id2=>{setSelectedEventId(id2),setMode("timeline")},selectNode=id2=>{setSelectedNodeId(id2),setMode("graph")},openExplorer=()=>{mode==="graph"&&!selectedNodeId&&visibleNodes[0]&&setSelectedNodeId(visibleNodes[0].id),mode==="timeline"&&!selectedEventId&&timelineEvents[0]&&setSelectedEventId(timelineEvents[0].id),setFiltersOpen(!0),setFullScreen(!0)},migrationNotice=graphMigrationNotice(graph.migration),activeFilterCount=mode==="graph"?+!!nodeType+ +!!nodeTag:Object.values(eventFilters).filter(Boolean).length,filterControls=mode==="graph"?h("div",{className:"sg-filterbar"},h("select",{value:nodeType,onChange:event3=>setNodeType(event3.target.value),"aria-label":"\u8282\u70B9\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u8282\u70B9\u7C7B\u578B"),Object.entries(NODE_META).map(([value,meta3])=>h("option",{key:value,value},meta3[0]))),h("select",{value:nodeTag,onChange:event3=>setNodeTag(event3.target.value),"aria-label":"\u8BED\u4E49\u6807\u7B7E"},h("option",{value:""},"\u5168\u90E8\u8BED\u4E49\u6807\u7B7E"),nodeTags.map(tag=>h("option",{key:tag,value:tag},tag)))):h("div",{className:"sg-filterbar"},h("select",{value:eventFilters.time,onChange:event3=>setEventFilters({...eventFilters,time:event3.target.value}),"aria-label":"\u65F6\u95F4\u8303\u56F4"},h("option",{value:""},"\u5168\u90E8\u65F6\u95F4"),h("option",{value:"today"},"\u4ECA\u5929"),h("option",{value:"week"},"\u672C\u5468"),h("option",{value:"unknown"},"\u53D1\u751F\u65F6\u95F4\u672A\u77E5")),h("select",{value:eventFilters.node,onChange:event3=>setEventFilters({...eventFilters,node:event3.target.value}),"aria-label":"\u53C2\u4E0E\u5B9E\u4F53"},h("option",{value:""},"\u5168\u90E8\u5B9E\u4F53"),nodes3.map(node=>h("option",{key:node.id,value:node.id},node.name))),h("select",{value:eventFilters.type,onChange:event3=>setEventFilters({...eventFilters,type:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u7C7B\u578B"),Object.entries(EVENT_TYPE_TEXT).map(([value,label])=>h("option",{key:value,value},label))),h("select",{value:eventFilters.status,onChange:event3=>setEventFilters({...eventFilters,status:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u72B6\u6001"},h("option",{value:""},"\u5168\u90E8\u72B6\u6001"),Object.entries(EVENT_STATUS_TEXT).map(([value,label])=>h("option",{key:value,value},label)))),longTabs=[["topics","\u76EE\u5F55"],...graphSettings.enabled===!0?[["graph","\u77E5\u8BC6\u56FE\u8C31"]]:[],["timeline","\u65F6\u95F4\u7EBF"]],tabButton=([id2,label])=>h("button",{key:id2,type:"button",className:mode===id2?"active":"","aria-current":mode===id2?"page":void 0,"aria-pressed":mode===id2,"aria-label":id2==="graph-add"?"\u91CD\u65B0\u6253\u5F00\u77E5\u8BC6\u56FE\u8C31":label,onClick:()=>{setMode(id2==="graph-add"?"graph":id2),setGraphMenuOpen(id2==="graph-add"||id2==="graph"&&graphSettings.enabled!==!0&&graphSettings.noticeSeen!==!0),id2==="topics"&&(setFullScreen(!1),setFiltersOpen(!1))}},label),graphMenu=h("div",{ref:graphMenuRef,className:"sg-graph-menu"},h("button",{type:"button",className:"sg-graph-menu-trigger","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u8BBE\u7F6E","aria-expanded":graphMenuOpen,onClick:()=>setGraphMenuOpen(value=>!value)},h("svg",{width:16,height:16,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false"},h("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}))),graphMenuOpen?h("div",{className:"sg-graph-menu-popover"},h(GraphControlPanel,{state:graphSettings,refresh,page:!0,onOpenGraph:()=>{setGraphMenuOpen(!1),setMode("graph")},onGraphHidden:()=>{setGraphMenuOpen(!1),setMode("topics")}})):null),tabChildren=[...longTabs.map(tabButton),graphMenu];return h("section",{className:"sg-long-explorer "+(fullScreen?"fullscreen":""),"aria-label":fullScreen?"\u957F\u671F\u8BB0\u5FC6\u5168\u5C4F\u63A2\u7D22":"\u957F\u671F\u8BB0\u5FC6\u6D4F\u89C8"},h("div",{className:"sg-pg-head"},h("h2",null,"\u957F\u671F\u8BB0\u5FC6"),h("span",{className:"sg-pg-end"},h("nav",{className:"sg-long-tabs sg-seg","aria-label":"\u957F\u671F\u8BB0\u5FC6\u89C6\u89D2"},tabChildren))),h("div",{hidden:mode!=="topics"},h(TopicDirectory,{directory:topicDirectory,namespace,active:active&&mode==="topics",openEvent,onDirectoryChanged,onOpenDreamingSession})),mode==="topics"?null:h(React.Fragment,null,mode==="graph"&&migrationNotice?h("p",{className:"sg-muted"},migrationNotice):null,mode==="timeline"&&extractionGap?h("p",{className:"sg-muted"},"\u90E8\u5206\u5BF9\u8BDD\u5C1A\u672A\u5F62\u6210\u957F\u671F\u8BB0\u5FC6\uFF0C\u6682\u4E0D\u80FD\u901A\u8FC7\u957F\u671F\u8BB0\u5FC6\u68C0\u7D22\u3002"):null,h("div",{className:"sg-long-toolbar"},h(SearchBox,{value:query,onChange:setQuery,placeholder:mode==="graph"?"\u641C\u7D22\u4EBA\u7269\u3001\u9879\u76EE\u3001\u6982\u5FF5\u2026":"\u641C\u7D22\u4E8B\u4EF6\u2026"}),h("button",{type:"button",className:"sg-toolbar-button","aria-expanded":filtersOpen?"true":"false",onClick:()=>setFiltersOpen(!filtersOpen)},"\u7B5B\u9009 \u25BE",activeFilterCount?h("span",{className:"sg-active-filter-count"},activeFilterCount):null),mode==="graph"&&graphNodeLimit<visibleNodes.length?h("button",{type:"button",className:"sg-toolbar-button",onClick:()=>setGraphNodeLimit(current=>Math.min(visibleNodes.length,current+100))},"\u518D\u663E\u793A 100 \u4E2A"):null,h("button",{type:"button",className:"sg-toolbar-button",onClick:fullScreen?()=>{setFullScreen(!1),setFiltersOpen(!1)}:openExplorer},fullScreen?"\u9000\u51FA\u5168\u5C4F":"\u26F6 \u5168\u5C4F\u67E5\u770B"+(mode==="graph"?"\u56FE\u8C31":"\u65F6\u95F4\u7EBF"))),h("div",{className:"sg-toolbar-count"},resultCount),filtersOpen?filterControls:null,mode==="graph"?h("div",{className:"sg-long-layout "+(fullScreen?"":"sg-summary-layout"),"aria-disabled":!graphSettings.enabled,inert:graphSettings.enabled?void 0:"",style:graphSettings.enabled?void 0:{filter:"grayscale(1)",opacity:.4,pointerEvents:"none"}},h(GraphCanvas,{nodes:visibleNodes,edges:edges3,clusters,importance:nodeImportance,selectedId:selectedNodeId,onSelect:setSelectedNodeId,nodeLimit:graphNodeLimit,showSummary:!fullScreen,onViewDetails:openExplorer}),fullScreen?h(NodeDetailPanel,{node:nodes3.find(node=>node.id===selectedNodeId),nodes:nodes3,edges:edges3,events,onEvent:selectEvent}):null):h(React.Fragment,null,h("div",{className:"sg-long-layout "+(fullScreen?"sg-timeline-layout":"sg-summary-layout")},h(TimelineList,{events:timelineEvents,nodes:nodes3,onSelect:setSelectedEventId,selectedId:selectedEventId,floating:!fullScreen,onNode:selectNode,openSource:openEvent,dreaming:topicDirectory?.dreaming}),fullScreen?h(EventDetailPanel,{event:timelineEvents.find(event3=>event3.id===selectedEventId),nodes:nodes3,events:timelineEvents,onNode:selectNode,openSource:openEvent}):null),h(Pagination,{page:pagedEvents.page,loading:pagedEvents.loading,error:pagedEvents.error,onOffset:pagedEvents.loadOffset}))))}function previewText(value){let text=String(value||"").replace(/\s+/g," ").trim()||"\u6682\u65E0\u5185\u5BB9";return text.length>200?text.slice(0,200)+"\u2026":text}function turnRangeText(range){return!Array.isArray(range)||range.length<2||range[1]<range[0]?"\u7B49\u5F85\u65B0\u5BF9\u8BDD":"Turn "+range[0]+"\u2013"+range[1]}function LayerPreview({layer,currentLevel,expanding,busy,pendingSelection,allowExpand,onExpand}){let itemRef=React.useRef(null),hideTimer=React.useRef(null),popoverRef=React.useRef(null),level=Number(layer.level),actionable=allowExpand&&Number.isInteger(level)&&(level!==currentLevel||pendingSelection),cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},removePopover=()=>{popoverRef.current?.remove(),popoverRef.current=null},showPopover=()=>{cancelHide();let rect=itemRef.current?.getBoundingClientRect();if(!rect)return;let inline=window.innerWidth<860,width2=Math.min(390,Math.max(240,window.innerWidth-24)),maxHeight=Math.min(520,window.innerHeight*.7),right=rect.right+12,left=right+width2<=window.innerWidth-12?right:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));if(!popoverRef.current){let popover=document.createElement("aside"),title=document.createElement("strong"),content=document.createElement("p"),theme=window.getComputedStyle(itemRef.current),pageTheme=window.getComputedStyle(itemRef.current.closest(".sg-memory"));popover.className="sg-layer-popover",popover.setAttribute("role","tooltip"),popover.style.background=pageTheme.backgroundColor,popover.style.color=pageTheme.color,popover.style.borderColor=theme.borderColor,title.textContent="L"+level+" \u5B8C\u6574\u5185\u5BB9",content.className="sg-layer-full",content.textContent=String(layer.content||"\u6682\u65E0\u5185\u5BB9"),popover.append(title,content),popover.addEventListener("mouseenter",cancelHide),popover.addEventListener("mouseleave",scheduleHide),inline?itemRef.current.parentElement.appendChild(popover):document.body.appendChild(popover),popoverRef.current=popover}popoverRef.current.style.setProperty("position",inline?"relative":"fixed","important"),popoverRef.current.style.width=inline?"auto":width2+"px",popoverRef.current.style.left=inline?"0":left+"px",popoverRef.current.style.top=inline?"0":top+"px",popoverRef.current.style.maxHeight=inline?"240px":maxHeight+"px"},scheduleHide=()=>{cancelHide(),hideTimer.current=window.setTimeout(removePopover,140)};return React.useEffect(()=>()=>{cancelHide(),removePopover()},[]),h("div",{className:"sg-layer-hover"},h("div",{ref:itemRef,className:"sg-layer-item "+(level===currentLevel?"current":""),"data-level":String(level)},h("span",{className:"sg-layer-label"},"L"+level),h("span",{className:"sg-layer-preview",tabIndex:0,onMouseEnter:showPopover,onMouseLeave:scheduleHide,onFocus:showPopover,onBlur:scheduleHide},previewText(layer.content)),actionable?h("button",{className:"sg-layer-use",type:"button",disabled:busy,onMouseEnter:removePopover,onFocus:removePopover,onClick:event3=>{event3.stopPropagation(),onExpand(level)}},expanding?"\u6B63\u5728\u5E94\u7528\u2026":"\u8BA9\u52A9\u624B\u53C2\u8003 L"+level):h("span",{className:"sg-layer-using"},level===currentLevel?"\u52A9\u624B\u53EF\u89C1":"\u4EC5\u4F9B\u9884\u89C8")))}function BlockLayerPanel({block,detail,loading,expandingLevel,selectionBusy,onExpand}){if(loading)return h("div",{className:"sg-layer-panel"},h(Loading));let layers=Array.isArray(detail?.layers)?detail.layers:[],visibleLevel=visibleBlockLevel(block);return h("div",{className:"sg-layer-panel"},h("div",{className:"sg-layer-heading"},h("strong",null,"\u5206\u5C42\u5185\u5BB9\u9884\u89C8"),h("span",null,"\u52A9\u624B\u53EF\u89C1\uFF1A"+(visibleLevel===null?"\u5C1A\u672A\u786E\u8BA4":"L"+visibleLevel))),h("p",{className:"sg-layer-hint"},"\u9884\u89C8\u4E0D\u4F1A\u6539\u53D8\u52A9\u624B\u53EF\u89C1\u7684\u5185\u5BB9\u3002\u60AC\u505C\u6216\u805A\u7126\u53EF\u67E5\u770B\u5B8C\u6574\u5185\u5BB9\u3002"),block.virtual?h("div",{className:"sg-virtual-note"},"\u65E7\u4F1A\u8BDD\u5C55\u793A\u7247\u6BB5\u4E3A\u53EA\u8BFB\u5185\u5BB9\uFF0C\u4E0D\u4F1A\u6539\u5199\u539F\u59CB\u6570\u636E\u5E93\u3002"):null,layers.length?h("div",{className:"sg-layer-stack"},layers.slice().sort((a,b)=>a.level-b.level).map(layer=>h(LayerPreview,{key:layer.level,layer,currentLevel:visibleLevel,expanding:expandingLevel===layer.level,busy:selectionBusy||expandingLevel>=0,pendingSelection:block.surfaceSync?.status==="pending"||block.surfaceSync?.status==="blocked",allowExpand:!block.virtual,onExpand}))):h("div",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5386\u53F2\u7684\u5206\u5C42\u5185\u5BB9\u3002"))}function visibleBlockLevel(block){return block.surfaceLevelKnown===!1||!Number.isInteger(block.currentLevel)?null:block.currentLevel}function BlockSelectionFeedback({block,feedback,onRefresh}){let value=feedback||block.surfaceSync;if(!value||value.status==="applied"&&!feedback)return null;let visible=visibleBlockLevel(block),current=visible===null?"\u52A9\u624B\u53EF\u89C1\u7684\u5C42\u7EA7\u5C1A\u672A\u786E\u8BA4\u3002":(value.uncertain?"\u4E0A\u6B21\u786E\u8BA4\u52A9\u624B\u53EF\u89C1 L":"\u52A9\u624B\u5F53\u524D\u53EF\u89C1 L")+visible+"\u3002",level=value.level??block.targetLevel,selected=Number.isInteger(level)?"L"+level:"\u6240\u9009\u5185\u5BB9",message=value.status==="applied"?value.message:(value.status==="pending"?"\u5DF2\u9009\u62E9 "+selected+"\u3002":"\u6682\u65F6\u65E0\u6CD5\u5E94\u7528 "+selected+"\u3002")+value.message+" "+current;return h("div",{className:"sg-selection-feedback"+(value.status==="blocked"?" error":""),role:value.status==="blocked"?"alert":"status"},message,value.uncertain&&onRefresh?h("button",{type:"button",className:"sg-quiet-button",onClick:onRefresh},"\u5237\u65B0\u72B6\u6001"):null)}function SummaryUnavailable({namespace,block}){let[source,setSource]=React.useState(null),[readError,setReadError]=React.useState(null),[loading,setLoading]=React.useState(!1),[open,setOpen]=React.useState(!1),request=React.useRef(null);React.useEffect(()=>()=>request.current?.abort(),[]);let openRaw=async()=>{if(request.current)return;if(source){setOpen(!0);return}let controller=new AbortController;request.current=controller,setLoading(!0),setReadError(null);try{let value=await api2("sources",{namespace,blockId:block.id},{signal:controller.signal});if(controller.signal.aborted)return;if(value.namespace!==namespace||!Array.isArray(value.messages)){setReadError({kind:"temporary",text:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u539F\u6587\u3002"});return}if(!value.messages.some(message=>String(message.content||"").trim())){setReadError({kind:"unavailable",text:"\u5F53\u524D\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u539F\u6587\u3002"});return}setSource(value),setOpen(!0)}catch(reason){controller.signal.aborted||setReadError({kind:[401,403,404,410].includes(reason?.status)?"unavailable":"temporary",text:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u539F\u6587\u3002"})}finally{request.current===controller&&(request.current=null,controller.signal.aborted||setLoading(!1))}},rawId="sg-summary-raw-"+block.id;return h("div",{className:"sg-block-expanded sg-muted"},h("p",null,"\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u6458\u8981\u6682\u4E0D\u53EF\u7528\u3002"),(block.rawAvailable||source)&&readError?.kind!=="unavailable"?h("button",{type:"button",className:"sg-quiet-button",disabled:loading,"aria-expanded":open,"aria-controls":rawId,onClick:open?()=>setOpen(!1):openRaw},open?"\u6536\u8D77\u539F\u59CB\u5BF9\u8BDD":loading?"\u6B63\u5728\u8BFB\u53D6\u2026":readError?.kind==="temporary"?"\u91CD\u65B0\u8BFB\u53D6\u539F\u6587":"\u67E5\u770B\u539F\u59CB\u5BF9\u8BDD"):null,readError?h("p",{role:"status"},readError.text):null,open&&source?h("div",{id:rawId,className:"sg-summary-raw"},source.messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},message.role+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||""))))):null)}let DAILY_WEEK=["\u5468\u65E5","\u5468\u4E00","\u5468\u4E8C","\u5468\u4E09","\u5468\u56DB","\u5468\u4E94","\u5468\u516D"];function dailyParts(date){let[year,month,day]=date.split("-").map(Number);return{year,month,day,week:DAILY_WEEK[new Date(Date.UTC(year,month-1,day)).getUTCDay()]}}function dailyRelative(date,today){let days=Math.round((Date.parse(today+"T00:00:00Z")-Date.parse(date+"T00:00:00Z"))/864e5);return days===0?"\u4ECA\u5929":days===1?"\u6628\u5929":days>1?days+" \u5929\u524D":Math.abs(days)+" \u5929\u540E"}function DailyIcon({name}){let paths={calendar:["M8 2v4","M16 2v4","M3 10h18","M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2"],folder:["M6 14 7.5 11a2 2 0 0 1 1.8-1H20a2 2 0 0 1 1.9 2.6l-2.2 7A2 2 0 0 1 17.8 21H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h7a2 2 0 0 1 2 2v2"],left:["m15 18-6-6 6-6"],right:["m9 18 6-6-6-6"],refresh:["M3 12a9 9 0 0 1 15.4-6.4L21 8","M21 3v5h-5","M21 12a9 9 0 0 1-15.4 6.4L3 16","M8 16H3v5"],notebook:["M2 6h4","M2 10h4","M2 14h4","M2 18h4","M8 2v20","M6 2h13a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2"],alert:["M12 8v4","M12 16h.01"],pause:["M10 8v8","M14 8v8"]};return h("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},["alert","pause"].includes(name)?h("circle",{cx:12,cy:12,r:10}):null,(paths[name]||[]).map((d,key)=>h("path",{key,d})))}function dailyInline(text){return String(text).split(/(`[^`\n]+`)/g).map((part,key)=>/^`[^`\n]+`$/.test(part)?h("code",{key},part.slice(1,-1)):part)}function renderDailyMarkdown(markdown){let output2=[],children=[],title=null,list=[],flushList=()=>{list.length&&(children.push(h("ul",{key:"list-"+children.length},list)),list=[])},flushItem=()=>{flushList(),(children.length||title!==null)&&output2.push(h("article",{className:"sg-daily-item",key:output2.length},title!==null?h("h4",null,dailyInline(title)):null,children)),children=[],title=null};for(let raw of String(markdown).split(/\r?\n/)){let line=raw.trimEnd();if(/^# \d{4}-\d{2}-\d{2}$/.test(line))continue;if(line.startsWith("## ")){flushItem(),title=line.slice(3);continue}if(line.startsWith("- ")){list.push(h("li",{key:list.length},dailyInline(line.slice(2))));continue}if(flushList(),!line)continue;let status=line.match(/^(当前|已完成):\s*(.*)$/);children.push(status?h("p",{key:children.length,className:"sg-daily-status"+(status[1]==="\u5DF2\u5B8C\u6210"?" done":"")},h("b",null,status[1]),h("span",null,dailyInline(status[2]))):h("p",{key:children.length},dailyInline(line)))}return flushItem(),output2}function dailyNoteDigest(markdown){let items=[],current=null;for(let raw of String(markdown||"").split(/\r?\n/)){let line=raw.trim();if(!line||/^# \d{4}-\d{2}-\d{2}$/.test(line))continue;if(line.startsWith("## ")){current={title:line.slice(3),detail:"",time:""},items.push(current);continue}if(!current)continue;let clock=line.match(/\b([01]?\d|2[0-3]):([0-5]\d)\b/);clock&&!current.time&&(current.time=clock[1].padStart(2,"0")+":"+clock[2]),current.detail||(current.detail=line.replace(/^(当前|已完成):\s*/,"").replace(/^[-*]\s+/,""))}return items}function DailyNotesPage({namespace,setDailyInjectionDays}){let[index,setIndex]=React.useState(null),[indexLoading,setIndexLoading]=React.useState(!0),[indexError,setIndexError]=React.useState(""),[selected,setSelected]=React.useState(""),[note,setNote]=React.useState({loading:!1,date:"",markdown:"",error:""}),[revision,setRevision]=React.useState(0),[noteRevision,setNoteRevision]=React.useState(0),[dayDigests,setDayDigests]=React.useState({}),[daySaving,setDaySaving]=React.useState(!1),[dayError,setDayError]=React.useState(""),[daysOverride,setDaysOverride]=React.useState(null),[openDay,setOpenDay]=React.useState(!1);React.useEffect(()=>{let abort=new AbortController;return setIndexLoading(!0),setIndexError(""),setOpenDay(!1),namespace?(api2("daily",{namespace},{signal:abort.signal}).then(data4=>{abort.signal.aborted||(setDaysOverride(null),setIndex(data4),setSelected(current=>data4.dates.includes(current)?current:data4.injectedDates[0]||data4.dates[0]||""))}).catch(error3=>{abort.signal.aborted||setIndexError(String(error3.message||error3))}).finally(()=>{abort.signal.aborted||setIndexLoading(!1)}),()=>abort.abort()):(setIndex(null),setSelected(""),setIndexLoading(!1),()=>abort.abort())},[namespace,revision]),React.useEffect(()=>{let abort=new AbortController;return setNote({loading:!!selected,date:selected,markdown:"",error:""}),selected&&api2("daily/note",{namespace,date:selected},{signal:abort.signal}).then(data4=>{abort.signal.aborted||setNote({loading:!1,date:selected,markdown:data4.markdown,error:""})}).catch(error3=>{abort.signal.aborted||setNote({loading:!1,date:selected,markdown:"",error:String(error3.message||error3)})}),()=>abort.abort()},[namespace,selected,noteRevision]);let choose=date2=>{setSelected(date2),setOpenDay(!0)},dates=index?.dates||[],injected=index?.injectedDates||[],enabled=index?.enabled!==!1,savedInjectionDays=index?.injectionDays??3,injectionDays=daysOverride??savedInjectionDays,digests=dayDigests&&typeof dayDigests=="object"?dayDigests:{};React.useEffect(()=>{let active=!0,controller=new AbortController,wanted=dates.slice(0,14).filter(date2=>!(date2 in digests));return!wanted.length||indexError||!namespace?()=>controller.abort():(Promise.all(wanted.map(async date2=>{try{let value=await api2("daily/note",{namespace,date:date2},{signal:controller.signal});return[date2,dailyNoteDigest(value?.markdown)]}catch{return[date2,null]}})).then(entries=>{!active||controller.signal.aborted||setDayDigests(current=>{let next2={...current};for(let[date2,items]of entries)next2[date2]=items;return next2})}),()=>{active=!1,controller.abort()})},[namespace,indexError,dates.join(",")]);let stepDays=async delta=>{if(!setDailyInjectionDays||daySaving)return;let next2=Math.min(30,Math.max(1,injectionDays+delta));if(next2!==injectionDays){setDaysOverride(next2),setDaySaving(!0),setDayError("");try{await setDailyInjectionDays(next2)||(setDaysOverride(null),setDayError("\u5929\u6570\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002"))}catch(reason){setDaysOverride(null),setDayError("\u5929\u6570\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason))}finally{setDaySaving(!1)}}},failure=error3=>h("div",{className:"sg-daily-state error",role:"alert"},h("span",{className:"sg-daily-icon-wrap"},h(DailyIcon,{name:"alert"})),h("h3",null,"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u7B14\u8BB0"),h("p",null,"\u6587\u4EF6\u53EF\u80FD\u88AB\u5360\u7528\u6216\u6743\u9650\u4E0D\u8DB3\uFF0C\u5DF2\u6709\u7B14\u8BB0\u4E0D\u4F1A\u4E22\u5931\u3002"),h("button",{type:"button",className:"sg-daily-retry",onClick:()=>indexError?setRevision(v=>v+1):setNoteRevision(v=>v+1)},h(DailyIcon,{name:"refresh"}),"\u91CD\u65B0\u8BFB\u53D6"),h("details",null,h("summary",null,"\u9519\u8BEF\u8BE6\u60C5"),error3)),date=selected?dailyParts(selected):null,days=dates.slice(0,14),dayRows=()=>{let rows=[],cutShown=!1;return days.forEach((day,position3)=>{let parts=dailyParts(day),isInjected=enabled&&injected.includes(day),items=digests[day];enabled&&!cutShown&&!isInjected&&days.slice(0,position3).some(earlier=>injected.includes(earlier))&&(cutShown=!0,rows.push(h("div",{key:day+"-cut",className:"sg-day-cut"},h("span",null,"\u4EE5\u4E0B\u4E0D\u5E26\u5165"))));let lines=(Array.isArray(items)&&items.length?items:[{title:"\u67E5\u770B\u5F53\u5929\u7B14\u8BB0",detail:"",time:""}]).slice(0,6).map((item,key)=>h("li",{key},h("span",{className:"sg-day-t"},item.time||""),h("button",{type:"button",className:"sg-day-s",onClick:()=>choose(day),"aria-label":parts.month+"\u6708"+parts.day+"\u65E5 "+item.title+"\uFF0C\u67E5\u770B\u5F53\u5929\u7B14\u8BB0"},item.title),h("span")));rows.push(h("div",{key:day,className:"sg-day"+(isInjected?"":" out"),style:{animationDelay:position3*40+"ms"}},h("button",{type:"button",role:"tab",id:"sg-day-tab-"+day,"aria-controls":"sg-day-note","data-day":day,"aria-selected":selected===day,tabIndex:selected===day||!days.includes(selected)&&position3===0?0:-1,className:"sg-day-d",onClick:()=>choose(day),onKeyDown:event3=>{let next2=event3.key==="ArrowDown"?(position3+1)%days.length:event3.key==="ArrowUp"?(position3+days.length-1)%days.length:event3.key==="Home"?0:event3.key==="End"?days.length-1:-1;next2>=0&&(event3.preventDefault(),choose(days[next2]),event3.currentTarget.closest(".sg-days")?.querySelector('[data-day="'+days[next2]+'"]')?.focus())}},h("b",null,parts.day),h("span",null,parts.week),h("span",{className:"sg-visually-hidden"},parts.month+"\u6708 \xB7 "+dailyRelative(day,index.today))),h("div",{className:"sg-day-rail","aria-hidden":"true"}),h("ul",null,lines)))}),rows};return h("div",{className:"sg-daily"},h("div",{className:"sg-pg-head"},h("h2",null,"\u77ED\u671F\u8BB0\u5FC6"),h("span",{className:"sg-pg-tag"},h("i",{className:"sg-sw sand","aria-hidden":"true"}),enabled?"\u65B0\u4F1A\u8BDD\u5E26\u5165\u6700\u8FD1 "+injectionDays+" \u4E2A\u6709\u7B14\u8BB0\u65E5\u671F":"\u5DF2\u6682\u505C\u6CE8\u5165"),h("span",{className:"sg-pg-end"},setDailyInjectionDays?h("span",{className:"sg-stp",role:"group","aria-label":"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u5929\u6570"},h("button",{type:"button","aria-label":"\u51CF\u5C11\u4E00\u5929",disabled:daySaving||injectionDays<=1,onClick:()=>{stepDays(-1)}},"\u2212"),h("span",{"aria-live":"polite"},injectionDays+" \u5929"),h("button",{type:"button","aria-label":"\u589E\u52A0\u4E00\u5929",disabled:daySaving||injectionDays>=30,onClick:()=>{stepDays(1)}},"+")):null,null),dayError?h("p",{className:"sg-storage-feedback failed",role:"alert"},dayError):null,indexLoading?h(Loading):indexError?failure(indexError):h(React.Fragment,null,enabled?null:h("div",{className:"sg-daily-off"},h(DailyIcon,{name:"pause"}),"\u5DF2\u5173\u95ED\uFF0C\u4E0D\u518D\u5199\u5165\uFF0C\u4E5F\u4E0D\u4F1A\u5E26\u5165\u65B0\u4F1A\u8BDD\u3002"),dates.length?h(React.Fragment,null,h("div",{className:"sg-days",role:"tablist","aria-label":"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u7B14\u8BB0"},dayRows()),openDay?note.loading||note.date!==selected?h(Loading):note.error?failure(note.error):date?h("article",{key:selected,id:"sg-day-note",role:"tabpanel","aria-labelledby":"sg-day-tab-"+selected,className:"sg-daily-note"},h("div",{className:"sg-daily-note-date"},h("h3",null,date.month+" \u6708 "+date.day+" \u65E5"),h("span",null,date.week+" \xB7 "+dailyRelative(selected,index.today))),h("div",{className:"sg-daily-meta"},h("button",{type:"button",className:"sg-daily-back",onClick:()=>setOpenDay(!1)},"\u6536\u8D77\u7B14\u8BB0"),h("span",{className:"sg-daily-pill"+(!enabled||!injected.includes(selected)?" muted":"")},enabled?injected.includes(selected)?"\u4F1A\u5E26\u5165\u65B0\u4F1A\u8BDD":"\u4E0D\u5728\u5E26\u5165\u8303\u56F4\u5185":"\u5DF2\u6682\u505C\u6CE8\u5165"),!injected.includes(selected)&&enabled?h("button",{type:"button",className:"sg-daily-back",onClick:()=>choose(injected[0])},"\u56DE\u5230\u6700\u8FD1\u7B14\u8BB0"):null),renderDailyMarkdown(note.markdown)):null:null):h("div",{className:"sg-daily-state"},h("span",{className:"sg-daily-icon-wrap"},h(DailyIcon,{name:"notebook"})),h("h3",null,"\u8FD8\u6CA1\u6709\u7B14\u8BB0"),h("p",null,"Agent \u63A8\u8FDB\u5DE5\u4F5C\u65F6\u4F1A\u81EA\u52A8\u8BB0\u5F55\u3002")))))}function ShortTermPage({blocks,blockPage,openBlock,conversations,activeThreadId,namespace,onConversationChange,refresh,blockTurnSize=6}){let pagedBlocks=usePagedMemory({namespace,kind:"blocks",initialItems:blocks,initialPage:blockPage,fallbackLimit:40,extraParams:{threadId:activeThreadId}}),visible=[...pagedBlocks.items].sort((a,b)=>Number(a.sequence||0)-Number(b.sequence||0)||String(a.createdAt).localeCompare(String(b.createdAt))),[expandedId,setExpandedId]=React.useState(""),[detailBlockId,setDetailBlockId]=React.useState(""),[details,setDetails]=React.useState({}),[loadingId,setLoadingId]=React.useState(""),[expanding,setExpanding]=React.useState({blockId:"",level:-1}),[previewError,setPreviewError]=React.useState(null),[selectionFeedback,setSelectionFeedback]=React.useState({}),scope=namespace+"\0"+activeThreadId,activeScope=React.useRef(scope);activeScope.current=scope;let selectionRequest=React.useRef(null),currentOpen=openBlock||{turnRange:null,messages:0,status:"open"};React.useEffect(()=>{setExpandedId(""),setDetailBlockId(""),setDetails({}),setLoadingId(""),setPreviewError(null),setSelectionFeedback({})},[scope]),React.useEffect(()=>{let applied=Object.entries(selectionFeedback).filter(([,value])=>value?.status==="applied");if(!applied.length)return;let timer=window.setTimeout(()=>setSelectionFeedback(current=>{let next2={...current};for(let[id2,value]of applied)next2[id2]===value&&delete next2[id2];return next2}),4e3);return()=>window.clearTimeout(timer)},[selectionFeedback]);let toggleBlock=block=>{if(expandedId===block.id){setExpandedId("");return}setExpandedId(block.id),setPreviewError(null),!details[block.id]&&(setLoadingId(block.id),api2("sources",{namespace,blockId:block.id}).then(value=>{activeScope.current===scope&&setDetails(current=>({...current,[block.id]:value}))}).catch(()=>{activeScope.current===scope&&setPreviewError({scope,blockId:block.id,message:"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u9884\u89C8\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u3002"})}).finally(()=>{activeScope.current===scope&&setLoadingId(current=>current===block.id?"":current)}))},expandTo=async(block,level)=>{if(selectionRequest.current?.scope===scope)return;let request={scope,blockId:block.id,level};selectionRequest.current=request;let isCurrent=()=>activeScope.current===scope&&selectionRequest.current===request;setSelectionFeedback(current=>({...current,[block.id]:null})),setExpanding(request);let result;try{result=await api2("blocks/expand",{namespace,blockId:block.id,level:"L"+level},{method:"PATCH"})}catch(reason){let rejected=reason?.code==="BLOCK_SELECTION_REJECTED"||[400,403,404,409].includes(reason?.status);isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:{scope,level,status:rejected?"blocked":"pending",uncertain:!rejected,message:rejected?/[\u4e00-\u9fff]/.test(reason?.message||"")?reason.message.replace("\uFF08blocks/expand\uFF09",""):"\u8FD9\u6B21\u9009\u62E9\u672A\u80FD\u5E94\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u5E94\u7528\u7ED3\u679C\uFF0C\u8BF7\u5237\u65B0\u540E\u67E5\u770B\u3002"}}))}if(isCurrent())try{await refresh(),isCurrent()&&pagedBlocks.page.offset>0&&await pagedBlocks.loadOffset(pagedBlocks.page.offset),result&&isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:result.surfaceSync?.status==="applied"?{scope,level,status:"applied",message:"\u5DF2\u5E94\u7528 L"+level+"\uFF0C\u4F9B\u52A9\u624B\u540E\u7EED\u56DE\u590D\u53C2\u8003\u3002"}:null}))}catch{isCurrent()&&setSelectionFeedback(current=>({...current,[block.id]:{scope,level,status:"pending",uncertain:!0,message:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u5E94\u7528\u7ED3\u679C\uFF0C\u8BF7\u5237\u65B0\u540E\u67E5\u770B\u3002"}}))}selectionRequest.current===request&&(selectionRequest.current=null,setExpanding({blockId:"",level:-1}))},selectedBlock=visible.find(block=>block.id===expandedId)||visible[visible.length-1]||null,levelOf=block=>{let level=visibleBlockLevel(block);return level===null?0:Math.min(5,Math.max(0,level))},openCapacity=Math.max(1,Number(currentOpen.capacity||blockTurnSize||6)),openUsed=Math.min(openCapacity,Math.max(0,Number(currentOpen.turns||0))),remainingDots=Math.max(1,openCapacity-openUsed),firstTurn=visible.length?visible[0].turnRange?.[0]:null,lastTurn=visible.length?visible[visible.length-1].turnRange?.[1]:null,turnSpan=Number.isInteger(firstTurn)&&Number.isInteger(lastTurn)?" \xB7 \u7B2C "+firstTurn+"\u2013"+lastTurn+" \u8F6E":"",narrow=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(max-width: 680px)").matches===!0:!1,detailBlock=narrow&&detailBlockId?visible.find(block=>block.id===detailBlockId):null;return detailBlock?h("div",{className:"sg-ss-detail-page"},h(BackBar,{label:"\u4F1A\u8BDD\u8BB0\u5FC6",onBack:()=>setDetailBlockId("")}),h(ShortTermMemoryBlockDetail,{key:namespace+":"+detailBlock.id,namespace,block:detailBlock})):h(React.Fragment,null,h("div",{className:"sg-pg-head"},h("h2",null,"\u4F1A\u8BDD\u8BB0\u5FC6"),h("span",{className:"sg-pg-tag"},h("i",{className:"sg-sw water","aria-hidden":"true"}),pagedBlocks.page.total+" \u5757"+turnSpan),conversations.length?h("span",{className:"sg-pg-end"},h("label",{className:"sg-conversation"},h("span",null,"\u5F53\u524D\u5BF9\u8BDD\uFF1A"),h("select",{value:activeThreadId||"",onChange:event3=>onConversationChange(event3.target.value),"aria-label":"\u5F53\u524D\u5BF9\u8BDD"},conversations.map(conversation=>h("option",{key:conversation.id,value:conversation.id},conversation.label))))):null),h("section",{className:"sg-block-list sg-ss-list","aria-label":"Block \u5217\u8868"},h("section",{className:"sg-visually-hidden","aria-labelledby":"sg-decay-title"},h("h2",{id:"sg-decay-title"},"\u5757\u8870\u51CF\u603B\u89C8"),h("div",{className:"sg-distribution","aria-label":"Block \u5F53\u524D\u5C42\u7EA7\u5206\u5E03"},visible.map(block=>h("span",{key:block.id,className:"sg-level-chip","data-level":visibleBlockLevel(block)===null?void 0:String(block.currentLevel),title:"Block #"+block.sequence},visibleBlockLevel(block)===null?"\u5C1A\u672A\u786E\u8BA4":"L"+block.currentLevel)),h("span",{className:"sg-level-chip sg-open-chip"},"\u5F00\u653E\u5757 \xB7 \u672A\u5C01\u5B58")),h("input",{className:"sg-distribution-rail",type:"range",min:"0",max:"0",step:"1",value:"0",disabled:!0,readOnly:!0,"aria-label":"Block \u5206\u5E03\u6ED1\u8F68"})),h("div",{className:"sg-block-header sg-visually-hidden","aria-hidden":"true"},h("span",null,"\u52A9\u624B\u53EF\u89C1\u5C42\u7EA7"),h("span",null,"Block"),h("span",null,"\u8986\u76D6 Turn"),h("span",null,"\u8DDD\u6700\u65B0\u5C01\u5B58\u5757"),h("span")),h("div",{className:"sg-ss-scale"},h("span",null,"\u66F4\u65E9"),h("span",{className:"sg-r","aria-hidden":"true"},[0,1,2,3,4,5].map(level=>h("i",{key:level,style:{height:5+level*3+"px",opacity:.3+level*.14}}))),h("span",null,"\u6700\u8FD1"),h("span",null,"\u8D8A\u65E9\u7684\u5BF9\u8BDD\u538B\u5F97\u8D8A\u8584")),h("div",{className:"sg-ss"},h("div",{className:"sg-ss-main"},visible.map(block=>h("div",{key:block.id,className:"sg-block-unit"},h("button",{className:"sg-block-toggle",type:"button",onClick:()=>narrow?setDetailBlockId(block.id):toggleBlock(block),"aria-expanded":narrow?void 0:expandedId===block.id?"true":"false","aria-label":"\u8BB0\u5FC6\u5757 "+block.sequence+"\uFF0C"+turnRangeText(block.turnRange)+(narrow?"\uFF0C\u6253\u5F00\u8BE6\u60C5":"")},h("span",{className:"sg-ss-num"},String(block.sequence)),h("span",{className:"sg-ss-bar",style:{height:20+levelOf(block)*5+"px",background:"color-mix(in srgb, var(--sg-water) "+(14+levelOf(block)*14)+"%, var(--sg-page))"}},h("span",null,block.title||(block.virtual?"\u65E7 Block #":"Block #")+block.sequence)),h("span",{className:"sg-ss-use"}),h("span",{className:"sg-block-turn"},turnRangeText(block.turnRange)),h("span",{className:"sg-block-distance"},block.distanceFromLatest===0?"0\uFF08\u6700\u65B0\uFF09":block.distanceFromLatest+" \u4E2A Block"),null),h(BlockSelectionFeedback,{block,feedback:selectionFeedback[block.id]?.scope===scope?selectionFeedback[block.id]:null,onRefresh:async()=>{try{if(await refresh(),activeScope.current!==scope)return;pagedBlocks.page.offset>0&&await pagedBlocks.loadOffset(pagedBlocks.page.offset),activeScope.current===scope&&setSelectionFeedback(current=>({...current,[block.id]:null}))}catch{}}}),previewError?.scope===scope&&previewError.blockId===block.id?h("div",{role:"alert",className:"sg-selection-feedback error"},previewError.message):null,summaryUnavailable(block)?h(SummaryUnavailable,{key:namespace+":"+block.id,namespace,block}):null,expandedId===block.id?h("div",{className:"sg-block-expanded"},h(BlockLayerPanel,{block,detail:details[block.id],loading:loadingId===block.id,selectionBusy:expanding.scope===scope&&expanding.level>=0,expandingLevel:expanding.scope===scope&&expanding.blockId===block.id?expanding.level:-1,onExpand:level=>expandTo(block,level)})):null)),h("div",{className:"sg-block-unit"},h("div",{className:"sg-ss-open"},h("span",{className:"sg-ss-num"},"\xB7"),h("div",{className:"sg-ss-bar"},h("span",null,"\u6B63\u5728\u8BB0\u5F55"),h("span",{className:"sg-ss-dots",role:"img","aria-label":"\u8FD8\u5DEE "+remainingDots+" \u8F6E\u5C01\u5B58","aria-hidden":void 0},Array.from({length:remainingDots},(_,index)=>h("i",{key:index,className:index<Math.min(remainingDots,Math.max(0,openCapacity-openUsed))?"":"o"})))),h("span")))),selectedBlock?h("aside",{className:"sg-ss-side","aria-label":"\u9009\u4E2D\u8BB0\u5FC6\u5757\u8BE6\u60C5"},h("h3",null,selectedBlock.title||"Block #"+selectedBlock.sequence),h("span",{className:"sg-k"},"\u8BB0\u5FC6\u5757 "+selectedBlock.sequence+" \xB7 "+turnRangeText(selectedBlock.turnRange)),h("div",{className:"sg-lvl","aria-hidden":"true"},[0,1,2,3,4,5].map(level=>h("i",{key:level,className:level<=levelOf(selectedBlock)?"on":""}))),h("div",{className:"sg-lvl-l"},h("span",null,"\u53EA\u7559\u6807\u9898"),h("span",null,"\u539F\u6587")),h("p",null,selectedBlock.summary||(selectedBlock.keypoints||[]).join("\uFF1B")||"\u8FD9\u4E00\u5757\u6682\u65F6\u6CA1\u6709\u6458\u8981\u3002"),h("button",{type:"button",className:"sg-btn",onClick:()=>toggleBlock(selectedBlock)},expandedId===selectedBlock.id?"\u6536\u8D77\u8BE6\u60C5":"\u770B\u539F\u6587")):null)),h(Pagination,{page:pagedBlocks.page,loading:pagedBlocks.loading,error:pagedBlocks.error,onOffset:pagedBlocks.loadOffset}))}function SourceDetails({item,source,kind}){let messages=source?.messages||[];return h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u6765\u6E90"),h("div",{className:"sg-source-label"},h("span",{className:"sg-source-icon","aria-hidden":"true"},"\u25A3"),h("span",null,"\u5F53\u524D DeepSeek \u5BF9\u8BDD")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-tech-body"},h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},kind==="block"?"Block ID":"Event ID"),h("span",{className:"sg-code"},item.id)),kind==="block"&&item.turnRange?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,item.turnRange.join(" - "))):null,messages.length?messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},String(message.role||"")+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||"")))):h("div",{className:"sg-muted"},"\u5F53\u524D\u6570\u636E\u4E2D\u6CA1\u6709\u53EF\u663E\u793A\u7684\u6765\u6E90\u6D88\u606F\u3002"))))}function EventDetail({event:event3,project,source,onBack,backLabel,onNode}){let detailedEvent=source?.events?.find(item=>item.id===event3.id)||event3;return h(InfoPopoverGroup,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header sg-event-page-header"},h("span",{className:"sg-event-detail-kicker"},"Event"),h("h2",{className:"sg-detail-title"},detailedEvent.title||"\u8BB0\u5FC6\u8BE6\u60C5"),h(EventMetadata,{event:detailedEvent,nodes:source?.relatedNodes||[],onNode})),h(EventMemoryDetails,{event:detailedEvent,sourceMessages:source?.messages||[]}))}function ElementDetail({element:element3,events,source,openEvent,onBack,backLabel}){let facts=[];element3.currentState&&facts.push(element3.currentState);for(let fact of element3.facts||[]){let value=Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value;value&&!facts.includes(String(value))&&facts.push(String(value))}let related=events.filter(event3=>(element3.sourceEventIds||[]).includes(event3.id)).sort((a,b)=>String(b.updatedAt).localeCompare(String(a.updatedAt)));return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},element3.name||"\u76F8\u5173\u4E8B\u7269"),h("p",{className:"sg-detail-subtitle"},"AI \u5173\u4E8E\u5B83\u76EE\u524D\u77E5\u9053\u8FD9\u4E9B"),h("div",{className:"sg-meta"},h("span",null,"\u76F8\u5173\u7ECF\u5386 "+related.length+" \u6761"),h("span",{className:"sg-meta-sep"},"\u6700\u8FD1\u66F4\u65B0 "+formatTime(element3.updatedAt)))),h("div",{className:"sg-detail-section"},facts.length?h("ul",{className:"sg-facts"},facts.map((fact,index)=>h("li",{key:index},fact))):h("div",{className:"sg-muted"},"\u6682\u65F6\u6CA1\u6709\u5F62\u6210\u53EF\u5C55\u793A\u7684\u8BA4\u8BC6\u3002")),h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u76F8\u5173\u7ECF\u5386"),related.length?h("div",{className:"sg-related-list"},related.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",{className:"sg-related-name"},event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt||event3.createdAt))))):h("div",{className:"sg-muted"},"\u6CA1\u6709\u5173\u8054\u7ECF\u5386\u3002")),h(SourceDetails,{item:element3,source,kind:"element"}))}function processingFingerprint(overview){return JSON.stringify({failedJobs:Number(overview?.failedJobs||0),duplicateRepair:overview?.duplicateRepair??null,processingJobs:Number(overview?.processingJobs||0),failures:(overview?.failedJobDetails||[]).map(({kind,id:id2,attempts,updatedAt,lastError})=>({kind,id:id2,attempts,updatedAt,lastError})),processing:(overview?.processingJobDetails||[]).map(({kind,id:id2,status,attempts,updatedAt})=>({kind,id:id2,status,attempts,updatedAt}))})}function ProcessingStatus({overview,blocks,conversations,namespace,serverVersion,onBack,backLabel="\u8FD4\u56DE",refresh}){let failures=overview.failedJobDetails||[],failedKeys=new Set(failures.map(statusJobKey)),terminalFailedKeys=new Set(failures.filter(job=>job.state==="terminal-failed"||!job.state&&!job.nextRetryAt).map(statusJobKey)),hasProcessingDetails=Array.isArray(overview.processingJobDetails),rawProcessingCount=activeProcessingCount(overview),jobsByKey=new Map((overview.processingJobDetails||[]).map(job=>[statusJobKey(job),job]));for(let job of failures)jobsByKey.set(statusJobKey(job),job);let[refreshing,setRefreshing]=React.useState(!1),[feedback,setFeedback]=React.useState({kind:"",text:""}),[retrying,setRetrying]=React.useState(""),retryRequest=React.useRef(!1),[retryErrors,setRetryErrors]=React.useState({}),blockById=new Map(blocks.map(block=>[block.id,block])),conversationById=new Map((conversations||[]).map(conversation=>[conversation.id,conversation]));if(!hasProcessingDetails&&rawProcessingCount>0){let addLegacyJob=(block,kind,status,details={})=>{let job={id:"legacy:"+block.id+":"+kind,kind,status,attempts:details.attempts??0,nextRetryAt:details.nextRetryAt??null,updatedAt:details.updatedAt||block.createdAt,legacy:!0,blockIds:[block.id],blockDetails:[{id:block.id,sourceId:block.sourceId||block.id,sequence:block.sequence||block.blockIndex,title:block.title||block.l0Title,threadId:block.threadId,turnRange:block.turnRange,shouldExtract:block.shouldExtract}]};jobsByKey.set(statusJobKey(job),job)};for(let block of blocks){if(!(block.status==="processing"||block.processingStatus==="pending"))continue;let found=!1;(["pending","running"].includes(block.summaryJob?.status)||block.processingStatus==="pending")&&(addLegacyJob(block,"block-summary",block.summaryJob?.status||"pending",block.summaryJob),found=!0),block.eventExtraction?.status==="running"&&(addLegacyJob(block,"event-extraction","running",block.eventExtraction),found=!0),["pending","running"].includes(block.graphProjection?.status)&&(addLegacyJob(block,"graph-projection",block.graphProjection.status,block.graphProjection),found=!0),found||addLegacyJob(block,"event-extraction","running")}}let taskLabel=kind=>kind==="block-summary"?"\u4F1A\u8BDD\u8BB0\u5FC6\u538B\u7F29":kind==="event-extraction"?"\u957F\u671F\u8BB0\u5FC6\u63D0\u53D6":kind==="topic-projection"?"\u4E3B\u9898\u6574\u7406":"\u77E5\u8BC6\u56FE\u8C31\u66F4\u65B0",retryKey=statusJobKey,technicalStatusText=(status,job)=>job?.state==="terminal-failed"?"\u7EC8\u6001\u5931\u8D25":job?.state==="retryable"?"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5":status==="running"?"\u8FD0\u884C\u4E2D":status==="pending"?"\u6392\u961F\u4E2D":status==="failed"?"\u5931\u8D25":status==="succeeded"||status==="completed"?"\u5DF2\u5B8C\u6210":String(status||"\u672A\u77E5"),workItems=new Map;for(let job of jobsByKey.values()){let details=Array.isArray(job.blockDetails)?job.blockDetails:[];details.length||(details=(Array.isArray(job.blockIds)&&job.blockIds.length?job.blockIds:job.id&&!["graph-projection","topic-projection"].includes(job.kind)?[job.id]:[]).map(id2=>blockById.get(id2)).filter(Boolean).map(block=>({id:block.id,sourceId:block.id,sequence:block.sequence,title:block.title||block.l0Title,threadId:block.threadId,turnRange:block.turnRange,shouldExtract:block.shouldExtract,rawAvailable:block.rawAvailable}))),details.length||(details=[{id:statusJobKey(job),sourceId:"",sequence:null,title:"",threadId:job.threadId||"",turnRange:job.turnRange,shouldExtract:null}]);for(let detail of details){let key=String(detail.threadId||"")+":"+String(detail.id||detail.sourceId||statusJobKey(job)),item=workItems.get(key)||{...detail,jobs:[]};item.jobs.some(candidate=>statusJobKey(candidate)===statusJobKey(job))||item.jobs.push(job),workItems.set(key,item)}}let items=[...workItems.values()].sort((left,right)=>{let threadOrder=String(left.threadId||"").localeCompare(String(right.threadId||""));return threadOrder||Number(left.turnRange?.[0]||left.sequence||0)-Number(right.turnRange?.[0]||right.sequence||0)}),itemState=item=>item.jobs.some(job=>terminalFailedKeys.has(statusJobKey(job)))?{kind:"failed",label:"\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5",mark:"!"}:item.jobs.some(job=>job.status==="running")?{kind:"processing",label:"\u6B63\u5728\u6574\u7406",mark:"\u25CF"}:item.jobs.some(job=>job.state==="retryable"||failedKeys.has(statusJobKey(job))&&job.nextRetryAt)?{kind:"processing",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5",mark:"\u21BB"}:{kind:"waiting",label:"\u7B49\u5F85\u6574\u7406",mark:"\u25CB"},itemStages=item=>{let summaryJob=item.jobs.find(job=>job.kind==="block-summary"),extractionJobs=item.jobs.filter(job=>job.kind==="event-extraction"),graphJobs=item.jobs.filter(job=>job.kind==="graph-projection"),topicJobs=item.jobs.filter(job=>job.kind==="topic-projection"),summaryFailed=summaryJob&&terminalFailedKeys.has(statusJobKey(summaryJob)),extractionFailed=extractionJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),graphFailed=graphJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),shortStage=summaryFailed?{kind:"failed",mark:"!",label:"\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5"}:summaryJob?.status==="running"?{kind:"processing",mark:"\u25CF",label:"\u5904\u7406\u4E2D"}:summaryJob?.state==="retryable"?{kind:"processing",mark:"\u21BB",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5"}:summaryJob?{kind:"waiting",mark:"\u25CB",label:"\u6392\u961F\u4E2D"}:{kind:"done",mark:"\u2713",label:"\u5DF2\u5B8C\u6210"},stageForJobs=(jobs,failed,emptyLabel,failedLabel="\u7EC8\u6001\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5")=>failed?{kind:"failed",mark:"!",label:failedLabel}:jobs.some(job=>job.status==="running")?{kind:"processing",mark:"\u25CF",label:"\u5904\u7406\u4E2D"}:jobs.some(job=>job.state==="retryable")?{kind:"processing",mark:"\u21BB",label:"\u8BA1\u5212\u81EA\u52A8\u91CD\u8BD5"}:jobs.length?{kind:"waiting",mark:"\u25CB",label:"\u6392\u961F\u4E2D"}:{kind:"waiting",mark:"\u25CB",label:emptyLabel};if(topicJobs.length===item.jobs.length)return[["\u4E3B\u9898\u6574\u7406",stageForJobs(topicJobs,topicJobs.some(job=>terminalFailedKeys.has(statusJobKey(job))),"\u7B49\u5F85\u6574\u7406")]];let extractionStage=extractionFailed?stageForJobs(extractionJobs,!0,"\u7B49\u5F85\u63D0\u53D6"):extractionJobs.length?stageForJobs(extractionJobs,!1,"\u7B49\u5F85\u63D0\u53D6"):graphJobs.length?{kind:"done",mark:"\u2713",label:"\u5DF2\u5B8C\u6210"}:shortStage.kind!=="done"?{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u77ED\u671F\u6458\u8981"}:item.shouldExtract===!1?{kind:"skipped",mark:"\u2013",label:"\u65E0\u9700\u63D0\u53D6"}:{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u63D0\u53D6"},graphStage=graphFailed?stageForJobs(graphJobs,!0,"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0","\u66F4\u65B0\u5931\u8D25\uFF0C\u53EF\u91CD\u8BD5"):graphJobs.length?stageForJobs(graphJobs,!1,"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0"):extractionStage.kind==="failed"||extractionStage.kind==="waiting"||extractionStage.kind==="processing"?{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u957F\u671F\u8BB0\u5FC6\u63D0\u53D6"}:{kind:"waiting",mark:"\u25CB",label:"\u7B49\u5F85\u56FE\u8C31\u66F4\u65B0"};return[["\u539F\u59CB\u5BF9\u8BDD",item.rawAvailable===!0?{kind:"done",mark:"\u2713",label:"\u5F53\u524D\u53EF\u8BFB\u53D6"}:{kind:"waiting",mark:"\u25CB",label:item.rawAvailable===!1?"\u5F53\u524D\u65E0\u53EF\u8BFB\u53D6\u539F\u6587":"\u65E0\u6CD5\u786E\u8BA4\u662F\u5426\u53EF\u8BFB\u53D6"}],["\u538B\u7F29\u4F1A\u8BDD\u8BB0\u5FC6",shortStage],["\u63D0\u53D6\u957F\u671F\u8BB0\u5FC6",extractionStage],["\u66F4\u65B0\u77E5\u8BC6\u56FE\u8C31",graphStage]]},conversationLabel=threadId=>threadId==="__legacy__"?"\u5386\u53F2\u5BF9\u8BDD":conversationById.get(threadId)?.label||(threadId?"\u5BF9\u8BDD "+String(threadId).slice(0,8):"\u5386\u53F2\u6216\u672A\u77E5\u5BF9\u8BDD"),groups=[];for(let item of items){let key=item.threadId||"__unknown__",group2=groups.find(candidate=>candidate.key===key);group2||(group2={key,label:conversationLabel(item.threadId),items:[]},groups.push(group2)),group2.items.push(item)}let checkStatus=()=>{let before=processingFingerprint(overview);return setRefreshing(!0),setFeedback({kind:"",text:"\u6B63\u5728\u8BFB\u53D6\u2026"}),refresh({propagateError:!0}).then(next2=>{let selected=next2?.overview?.namespaces?.find(item=>item.namespace===namespace),changed=selected&&processingFingerprint(selected)!==before;setFeedback({kind:"done",text:changed?"\u72B6\u6001\u5DF2\u66F4\u65B0":"\u72B6\u6001\u6CA1\u6709\u53D8\u5316"})}).catch(reason=>{setFeedback({kind:"failed",text:"\u8BFB\u53D6\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}).finally(()=>setRefreshing(!1))},retryJob=job=>{if(retryRequest.current)return;retryRequest.current=!0;let key=retryKey(job);return setRetrying(key),setRetryErrors(current=>({...current,[key]:""})),setFeedback({kind:"",text:taskLabel(job.kind)+" \u6B63\u5728\u5904\u7406\u2026"}),api2("jobs/retry",{namespace,kind:job.kind,jobId:job.id},{method:"POST"}).then(()=>refresh({propagateError:!0})).then(()=>setFeedback({kind:"done",text:job.kind==="topic-projection"?"\u5DF2\u91CD\u65B0\u6392\u961F\uFF0C\u6309\u5386\u53F2\u989D\u5EA6\u7EE7\u7EED\u6574\u7406":"\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u72B6\u6001\u5DF2\u66F4\u65B0"})).catch(async reason=>{let message=String(reason?.message||reason);setRetryErrors(current=>({...current,[key]:message})),setFeedback({kind:"failed",text:"\u91CD\u8BD5\u5931\u8D25\uFF1A"+message});try{await refresh({propagateError:!0})}catch{}}).finally(()=>{retryRequest.current=!1,setRetrying("")})},failedItems=items.filter(item=>item.jobs.some(job=>terminalFailedKeys.has(statusJobKey(job)))).length,activeItems=Math.max(0,items.length-failedItems),unresolvedProcessingCount=hasProcessingDetails?0:Math.max(0,rawProcessingCount-activeItems),detailsUnavailable=!hasProcessingDetails&&rawProcessingCount>0,versionMismatch=!!(serverVersion&&serverVersion!==STRATAGATE_CLIENT_VERSION),summary=items.length?groups.length+" \u4E2A\u4F1A\u8BDD \xB7 "+(activeItems?activeItems+" \u4E2A\u6B63\u5728\u6574\u7406":"")+(activeItems&&failedItems?" \xB7 ":"")+(failedItems?failedItems+" \u4E2A\u9700\u8981\u91CD\u8BD5":"")+(unresolvedProcessingCount?" \xB7 \u53E6\u6709 "+unresolvedProcessingCount+" \u4E2A\u8BE6\u60C5\u6682\u4E0D\u53EF\u7528":""):detailsUnavailable?"\u4ECD\u6709 "+rawProcessingCount+" \u4E2A\u540E\u53F0\u4EFB\u52A1\u6B63\u5728\u6574\u7406":hasProcessingDetails?"\u5F53\u524D\u6CA1\u6709\u5F85\u5904\u7406\u6216\u5931\u8D25\u7684\u4EFB\u52A1":"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u540E\u53F0\u4EFB\u52A1\u72B6\u6001";return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u540E\u53F0\u4EFB\u52A1"),h("p",null,summary)),h("div",{className:"sg-process-summary"},h("strong",null,"\u540E\u53F0\u6574\u7406\u72B6\u6001"),h("span",null,"\u5DF2\u6709\u8BB0\u5FC6\u53EF\u7EE7\u7EED\u67E5\u770B\uFF1B\u5177\u4F53\u6765\u6E90\u4EE5\u5B9E\u9645\u53EF\u8BFB\u53D6\u5185\u5BB9\u4E3A\u51C6\u3002")),detailsUnavailable?h("div",{className:"sg-process-notice",role:"status"},h("strong",null,versionMismatch?"\u524D\u540E\u7AEF\u7248\u672C\u5C1A\u672A\u540C\u6B65":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B8C\u6574\u4EFB\u52A1\u8BE6\u60C5"),h("span",null,versionMismatch?"\u5F53\u524D\u9875\u9762\u4E3A "+STRATAGATE_CLIENT_VERSION+"\uFF0C\u540E\u53F0\u4E3A "+serverVersion+"\u3002\u8BF7\u786E\u8BA4\u5B89\u88C5\u65B0\u5305\u540E\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u542F\u52A8 DSH\u3002":"\u540E\u53F0\u53EA\u8FD4\u56DE\u4E86\u4EFB\u52A1\u6570\u91CF\uFF0C\u6CA1\u6709\u8FD4\u56DE\u4F1A\u8BDD\u548C\u8F6E\u6B21\u3002\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u542F\u52A8 DSH \u540E\u518D\u68C0\u67E5\u3002")):null,groups.length?h("div",{className:"sg-process-groups"},groups.map(group2=>h("section",{key:group2.key,className:"sg-process-group"},h("header",{className:"sg-process-group-head"},h("h3",{className:"sg-process-group-title"},group2.label),h("span",{className:"sg-process-group-count"},group2.items.length+" \u4E2A\u5BF9\u8BDD\u7247\u6BB5")),group2.items.map(item=>{let state=itemState(item),range=Array.isArray(item.turnRange)?"\u7B2C "+item.turnRange[0]+"\u2013"+item.turnRange[1]+" \u8F6E":item.title||"\u5BF9\u8BDD\u7247\u6BB5",technicalJobs=item.jobs.filter(job=>!job.legacy);return h("article",{key:String(item.id||item.sourceId),className:"sg-process-card"},h("div",{className:"sg-process-card-head"},h("span",{className:"sg-process-range"},range),h("span",{className:"sg-process-state "+state.kind},h("span",{"aria-hidden":"true"},state.mark),state.label)),h("div",{className:"sg-process-stages"},itemStages(item).map(([name,stage])=>h("div",{key:name,className:"sg-process-stage"},h("span",{className:"sg-process-stage-state "+stage.kind,"aria-hidden":"true"},stage.mark),h("span",{className:"sg-process-stage-name"},name),h("span",{className:"sg-process-stage-state "+stage.kind},stage.label)))),technicalJobs.length?h("details",{className:"sg-process-tech"},h("summary",null,"\u67E5\u770B\u6280\u672F\u8BE6\u60C5"),technicalJobs.map(job=>{let key=retryKey(job),failed=terminalFailedKeys.has(key),busy=retrying===key;return h("div",{key,className:"sg-process-job"},h("div",{className:"sg-process-job-head"},h("strong",null,taskLabel(job.kind)),h("span",{className:"sg-stage-value "+(terminalFailedKeys.has(key)?"failed":job.status==="running"||job.state==="retryable"?"processing":"waiting")},technicalStatusText(job.status,job))),h("div",{className:"sg-process-job-meta sg-code"},"\u4EFB\u52A1 "+job.id+" \xB7 \u5DF2\u5C1D\u8BD5 "+String(job.attempts??0)+" \u6B21 \xB7 \u66F4\u65B0\u4E8E "+formatTime(job.updatedAt)),job.nextRetryAt?h("div",{className:"sg-process-job-meta"},"\u8BA1\u5212\u91CD\u8BD5\uFF1A"+formatTime(job.nextRetryAt)):null,failed&&!job.nextRetryAt?h("div",{className:"sg-process-job-meta"},"\u81EA\u52A8\u91CD\u8BD5\u5DF2\u505C\u6B62"):null,failed?h("pre",{className:"sg-job-error sg-code"},job.lastErrorFull||job.lastError||"\u6CA1\u6709\u8BB0\u5F55\u6280\u672F\u9519\u8BEF\u3002"):null,job.kind==="topic-projection"&&job.diagnostics?h("pre",{className:"sg-code"},JSON.stringify(job.diagnostics,null,2)):null,job.kind==="topic-projection"&&overview.topicDirectoryReadError?h("p",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u76EE\u5F55\u72B6\u6001\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u72B6\u6001\u3002"):null,failed?h("div",{className:"sg-process-job-actions"},h("span",{className:"sg-status-feedback failed",role:retryErrors[key]?"alert":void 0},retryErrors[key]||""),job.kind==="topic-projection"?h(TopicRetryButton,{failure:{jobId:job.id,eventCount:job.eventCount},namespace,revision:overview.topicDirectoryRevision,onDirectoryChanged:()=>refresh({propagateError:!0})}):h("button",{type:"button",className:"sg-save-button",disabled:!!retrying,onClick:()=>{retryJob(job)}},busy?"\u6B63\u5728\u5904\u7406\u2026":"\u91CD\u8BD5\u6B64\u4EFB\u52A1")):null)})):null)})))):detailsUnavailable?h("div",{className:"sg-process-unavailable"},h("strong",null,"\u4EFB\u52A1\u4ECD\u5728\u6574\u7406\uFF0C\u5177\u4F53\u4F1A\u8BDD\u6682\u4E0D\u53EF\u7528"),h("span",null,"\u8FD9\u4E0D\u4EE3\u8868\u5BF9\u8BDD\u4E22\u5931\uFF1B\u91CD\u542F\u5E76\u52A0\u8F7D\u540C\u4E00\u7248\u672C\u540E\u5373\u53EF\u663E\u793A\u8BE6\u60C5\u3002")):h(Empty,{title:hasProcessingDetails?"\u5F53\u524D\u6CA1\u6709\u5F85\u5904\u7406\u6216\u5931\u8D25\u7684\u4EFB\u52A1":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u4EFB\u52A1\u8BE6\u60C5",copy:"\u76EE\u5F55\u4E0E\u56FE\u8C31\u7684\u8986\u76D6\u60C5\u51B5\u8BF7\u4EE5\u5BF9\u5E94\u9875\u9762\u4E3A\u51C6\u3002"}),h("div",{className:"sg-process-footer"},h("button",{type:"button",className:"sg-quiet-button",disabled:refreshing,onClick:()=>{checkStatus()}},refreshing?"\u6B63\u5728\u8BFB\u53D6\u2026":"\u21BB \u91CD\u65B0\u68C0\u67E5\u72B6\u6001"),h("span",{className:"sg-muted"},"\u53EA\u8BFB\u53D6\u6700\u65B0\u72B6\u6001\uFF0C\u4E0D\u4F1A\u89E6\u53D1\u6A21\u578B\u8C03\u7528\u3002"),feedback.text?h("span",{className:"sg-status-feedback "+feedback.kind,role:feedback.kind==="failed"?"alert":"status"},feedback.text):null))}let profilePageMemory=new Map,profileFieldDrafts=new Map,importDrafts=new Map,importRequests=new Map;function usePageMemoryState(cache3,key,initial){cache3.has(key)||cache3.set(key,initial);let[value,setValue]=React.useState(cache3.get(key));return[value,next2=>{let resolved=typeof next2=="function"?next2(cache3.get(key)):next2;cache3.set(key,resolved),setValue(resolved)}]}function ImportPage({namespace,onBack,refresh}){let[draft,setDraft]=usePageMemoryState(importDrafts,namespace,{text:""}),text=draft.text,setText=value=>setDraft({text:value}),[prompt,setPrompt]=React.useState(""),[promptLoading,setPromptLoading]=React.useState(!0),[copied,setCopied]=React.useState(!1),[busy,setBusy]=React.useState(!1),[job,setJob]=React.useState(null),[choices,setChoices]=React.useState({}),[result,setResult]=React.useState(null),[error3,setError]=React.useState(""),[connectionError,setConnectionError]=React.useState(""),[restoring,setRestoring]=React.useState(!0),lifecycle=React.useRef(null);React.useEffect(()=>{let active=!0,restoreTimer,controller=new AbortController;lifecycle.current=controller,api2("import",{},{signal:controller.signal}).then(value=>{active&&setPrompt(String(value.prompt||""))}).catch(reason=>{active&&setError(String(reason?.message||reason))}).finally(()=>{active&&setPromptLoading(!1)});let restore=async()=>{if(await importRequests.get(namespace)?.catch(()=>{}),!!active)return api2("import",{operation:"status",namespace},{signal:controller.signal}).then(value=>{active&&(setConnectionError(""),setRestoring(!1),value?.jobId&&!["undone","abandoned"].includes(value.status)&&(setJob(value),value.status==="committed"&&(setResult(value),clearCommittedDraft(value))))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),restoreTimer=window.setTimeout(restore,2500))})};restore();let onKeyDown=event3=>{event3.key==="Escape"&&onBack()};return window.addEventListener("keydown",onKeyDown),()=>{active=!1,controller.abort(),lifecycle.current=null,window.clearTimeout(restoreTimer),window.removeEventListener("keydown",onKeyDown)}},[]),React.useEffect(()=>{if(!job?.jobId||!["extracting","processing"].includes(job.status))return;let active=!0,timer,controller=new AbortController,poll=()=>api2("import",{operation:"status",namespace,jobId:job.jobId},{signal:controller.signal}).then(next2=>{active&&(setConnectionError(""),setJob(next2),["extracting","processing"].includes(next2.status)&&(timer=window.setTimeout(poll,1200)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),timer=window.setTimeout(poll,2500))});return timer=window.setTimeout(poll,600),()=>{active=!1,controller.abort(),window.clearTimeout(timer)}},[job?.jobId,job?.status,namespace]);let copyPrompt=()=>{if(!prompt)return;(navigator.clipboard?.writeText?navigator.clipboard.writeText(prompt):Promise.reject(new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236"))).then(()=>{setCopied(!0),window.setTimeout(()=>setCopied(!1),1600)}).catch(reason=>setError(String(reason?.message||reason)))},clearCommittedDraft=next2=>{let current=importDrafts.get(namespace);next2.status==="committed"&¤t?.jobId===next2.jobId&¤t.text.trim()===next2.text&&setText("")},mutate=(body,onResult,submission)=>{if(importRequests.has(namespace))return;let controller=lifecycle.current,valid2=()=>controller&&lifecycle.current===controller&&!controller.signal.aborted;setBusy(!0),setError("");let request=api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...body,namespace})});return importRequests.set(namespace,request),request.then(next2=>{if(submission&&importDrafts.get(namespace)===submission&&next2?.jobId&&(submission.jobId=next2.jobId),valid2())return onResult(next2)}).catch(reason=>{valid2()&&setError(String(reason?.message||reason))}).finally(()=>{importRequests.get(namespace)===request&&importRequests.delete(namespace),valid2()&&setBusy(!1)})},analyze=()=>{if(!(!text.trim()||busy||restoring||job&&job.status!=="failed"))return setResult(null),setJob(null),setChoices({}),mutate({operation:"preview",text},setJob,draft)},commit=()=>{if(!job||busy)return;let requestedChoices=(job.decisions||[]).flatMap((decision,index)=>decision.requiresConfirmation?[{index,action:choices[index]||decision.action||"IGNORE"}]:[]);return draft.text.trim()===job.text&&(draft.jobId=job.jobId),mutate({operation:"commit",jobId:job.jobId,choices:requestedChoices},next2=>(clearCommittedDraft(next2),setResult(next2),setJob(next2),refresh()))},retry=()=>{if(!(!job?.jobId||busy))return mutate({operation:"retry",jobId:job.jobId},setJob)},abandon=()=>{if(!(!job?.jobId||busy))return mutate({operation:"abandon",jobId:job.jobId},()=>{setJob(null),setText(""),setChoices({})})},undo=()=>{if(!(!result?.sourceBlockId||busy))return mutate({operation:"undo",sourceBlockId:result.sourceBlockId},()=>(setResult(null),setJob(null),refresh()))},reset2=()=>{setResult(null),setJob(null),setChoices({}),setError("")},actionLabel={ADD:"\u65B0\u589E",MERGE:"\u5408\u5E76",SUPERSEDE:"\u53D6\u4EE3\u65E7\u8BB0\u5FC6",CONFLICT:"\u4FDD\u7559\u5E76\u6807\u8BB0\u51B2\u7A81",IGNORE:"\u5FFD\u7565"},running=job&&["extracting","processing"].includes(job.status),reviewable=job&&["ready","awaiting_confirmation"].includes(job.status),emptyJob=reviewable&&Number(job.totalCount||0)===0,percent=job?job.status==="extracting"?5:job.totalCount?Math.round(job.processedCount/job.totalCount*100):100:0;return h("div",{className:"sg-import-overlay",role:"presentation",onMouseDown:event3=>{event3.target===event3.currentTarget&&onBack()}},h("section",{className:"sg-import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sg-import-title"},h("header",{className:"sg-import-dialog-head"},h("h2",{id:"sg-import-title",className:"sg-import-dialog-title"},"\u5C06\u8BB0\u5FC6\u5BFC\u5165 StrataGate"),h("button",{type:"button",className:"sg-icon-button",onClick:onBack,"aria-label":"\u5173\u95ED"},"\xD7")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"1"),h("span",{className:"sg-import-step-title"},"\u590D\u5236\u4EE5\u4E0B\u63D0\u793A\u8BCD\u5230\u5176\u4ED6 AI \u5BF9\u8BDD\u4E2D"),h("button",{type:"button",className:"sg-import-copy",disabled:promptLoading||!prompt,onClick:copyPrompt},copied?"\u5DF2\u590D\u5236":"\u590D\u5236")),promptLoading?h("div",{className:"sg-import-loading"},"\u6B63\u5728\u52A0\u8F7D\u63D0\u793A\u8BCD\u2026"):h("div",{className:"sg-import-prompt",tabIndex:"0"},prompt||"\u63D0\u793A\u8BCD\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"2"),h("span",{className:"sg-import-step-title"},"\u7C98\u8D34\u7ED3\u679C\uFF0C\u5148\u5206\u6790\u518D\u5BFC\u5165")),h("div",{className:"sg-import-card"},h("textarea",{value:text,disabled:restoring||busy||!!result||!!job&&job.status!=="failed",onChange:event3=>setText(event3.target.value),placeholder:"\u7C98\u8D34 JSON\uFF1B\u683C\u5F0F\u4E0D\u5408\u683C\u65F6\u4F1A\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D","aria-label":"\u5916\u90E8 AI \u8BB0\u5FC6 JSON"})),!job&&!result?h("div",{className:"sg-import-hint"},restoring?"\u6B63\u5728\u68C0\u67E5\u5DF2\u6709\u5BFC\u5165\u4EFB\u52A1\u2026":"\u5173\u95ED\u540E\u53EF\u7EE7\u7EED\u7F16\u8F91\uFF1B\u8349\u7A3F\u4EC5\u5728\u5F53\u524D\u6D4F\u89C8\u5668\u9875\u9762\u4FDD\u7559\uFF0C\u5237\u65B0\u540E\u6E05\u7A7A\u3002"):null),running?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},job.status==="extracting"?"\u6B63\u5728\u4FEE\u590D\u5E76\u63D0\u53D6\u5019\u9009\u8BB0\u5FC6":"\u6B63\u5728\u68C0\u6D4B\u91CD\u590D\u4E0E\u51B2\u7A81")),h("div",{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":percent,style:{height:"9px",overflow:"hidden",borderRadius:"999px",background:"var(--sg-border)"}},h("div",{style:{width:percent+"%",height:"100%",background:"var(--sg-accent)",transition:"width .25s ease"}})),h("div",{className:"sg-import-hint",style:{marginTop:"8px"}},job.status==="extracting"?"\u539F JSON \u4E0D\u5408\u683C\uFF0C\u6B63\u5728\u4F7F\u7528\u6A21\u578B\u515C\u5E95\u3002\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u4EFB\u52A1\u4F1A\u7EE7\u7EED\u3002":"\u5DF2\u5B8C\u6210 "+job.processedCount+"/"+job.totalCount+"\uFF0C\u6B63\u5728\u5224\u65AD\u7B2C "+Math.min(job.processedCount+1,job.totalCount)+" \u6761\uFF1B\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u67E5\u770B\u3002")):null,reviewable?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},"\u5BFC\u5165\u9884\u89C8")),h("div",{className:"sg-import-hint"},emptyJob?"\u6CA1\u6709\u53D1\u73B0\u53EF\u5BFC\u5165\u7684\u957F\u671F\u8BB0\u5FC6\u3002":job.recoveredFromInvalidJson?"\u8FD9\u4E9B\u5019\u9009\u7531\u515C\u5E95\u6A21\u578B\u6062\u590D\uFF0C\u5168\u90E8\u9700\u8981\u4EBA\u5DE5\u786E\u8BA4\u3002":"\u9AD8\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u81EA\u52A8\u91C7\u7528\uFF1B\u4F4E\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u8BF7\u4EBA\u5DE5\u9009\u62E9\u5904\u7406\u65B9\u5F0F\u3002"),h("div",{className:"sg-import-preview"},(job.decisions||[]).map((decision,index)=>h("div",{key:index,className:"sg-import-preview-item"},h("div",{className:"sg-import-preview-title"},decision.candidate?.title||"\u672A\u547D\u540D\u8BB0\u5FC6"),h("div",{className:"sg-import-preview-content"},h("strong",null,"\u65B0\u8BB0\u5FC6\uFF1A"),h("span",null,decision.candidate?.summary||"\u65E0\u5185\u5BB9"),decision.candidate?.narrative?h("div",null,decision.candidate.narrative):null),decision.mergedCandidate?h("div",{className:"sg-import-preview-content"},h("strong",null,"\u5408\u5E76\u540E\uFF1A"),h("span",null,decision.mergedCandidate.title+"\uFF1A"+decision.mergedCandidate.summary)):null,decision.existingEventIds?.length&&decision.matches?.length?h("div",{className:"sg-import-preview-content"},h("strong",null,"\u53D7\u5F71\u54CD\u7684\u65E7\u8BB0\u5FC6\uFF1A"),decision.matches.filter(match2=>decision.existingEventIds.includes(match2.event.id)).map(match2=>h("div",{key:match2.event.id},match2.event.title+"\uFF1A"+match2.event.summary))):null,h("div",{className:"sg-import-preview-meta"},h("span",null,actionLabel[decision.action]||decision.action),h("span",null,"\u7F6E\u4FE1\u5EA6 "+Math.round(Number(decision.confidence||0)*100)+"%"),decision.existingEventIds?.length?h("span",null,"\u5173\u8054 "+decision.existingEventIds.length+" \u6761"):null),decision.reason?h("div",{className:"sg-import-preview-reason"},decision.reason):null,decision.requiresConfirmation?h("label",{className:"sg-import-review"},h("span",null,"\u4EBA\u5DE5\u9009\u62E9"),h("select",{value:choices[index]||decision.action,onChange:event3=>setChoices(current=>({...current,[index]:event3.target.value}))},(decision.existingEventIds?.length?["ADD","MERGE","SUPERSEDE","CONFLICT","IGNORE"]:["ADD","IGNORE"]).map(action=>h("option",{key:action,value:action},actionLabel[action])))):null)))):null,job?.status==="failed"?h("div",{className:"sg-import-error"},"\u4EFB\u52A1\u5931\u8D25\uFF1A"+(job.lastError||"\u672A\u77E5\u9519\u8BEF")):null,connectionError?h("div",{className:"sg-import-hint"},connectionError):null,error3?h("div",{className:"sg-import-error"},error3):null,result?h("div",{className:"sg-import-result"},"\u5BFC\u5165\u5B8C\u6210\uFF1A\u65B0\u589E "+Number(result.importedCount||0)+" \u6761\u8BB0\u5FC6\u3002\u53EF\u7ACB\u5373\u64A4\u9500\u672C\u6279\u6B21\u3002"):null,h("footer",{className:"sg-import-dialog-foot"},result?h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:undo},busy?"\u6B63\u5728\u64A4\u9500\u2026":"\u64A4\u9500\u672C\u6B21\u5BFC\u5165"):h("button",{type:"button",className:"sg-import-cancel",onClick:onBack},running?"\u5173\u95ED\uFF0C\u540E\u53F0\u7EE7\u7EED":"\u5173\u95ED"),!job&&!result&&text?h("button",{type:"button",className:"sg-import-cancel",disabled:restoring||busy,onClick:()=>{setText(""),setError("")}},"\u653E\u5F03\u8349\u7A3F"):null,result?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):job?.status==="failed"?h(React.Fragment,null,h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:()=>{setJob(null),setChoices({}),setError("")}},"\u4FEE\u6539\u540E\u91CD\u65B0\u5206\u6790"),h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:abandon},"\u653E\u5F03\u672C\u6B21\u5BFC\u5165"),h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:retry},busy?"\u6B63\u5728\u91CD\u8BD5\u2026":"\u91CD\u8BD5")):emptyJob?h("button",{type:"button",className:"sg-import-button",onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):reviewable?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:commit},busy?"\u6B63\u5728\u5BFC\u5165\u2026":"\u786E\u8BA4\u5BFC\u5165"):running?h("button",{type:"button",className:"sg-import-button",disabled:!0},"\u540E\u53F0\u5904\u7406\u4E2D"):h("button",{type:"button",className:"sg-import-button",disabled:restoring||busy||!text.trim(),onClick:analyze},busy?"\u6B63\u5728\u521B\u5EFA\u4EFB\u52A1\u2026":"\u5206\u6790\u5E76\u9884\u89C8"))))}function SettingStepper({value,unit="",min:min4=1,max:max5=30,step:step3=1,disabled=!1,label,onChange}){let current=Number(value),bump=direction=>{if(!Number.isFinite(current)||disabled)return;let next2=Math.min(max5,Math.max(min4,Number((current+direction*step3).toFixed(2))));next2!==current&&onChange(next2)};return h("span",{className:"sg-stp",role:"group","aria-label":label},h("button",{type:"button","aria-label":"\u51CF\u5C11"+label,disabled:disabled||!Number.isFinite(current)||current<=min4,onClick:()=>bump(-1)},"\u2212"),h("span",{"aria-live":"polite",className:"sg-stp-value"},(Number.isFinite(current)?String(current):"")+unit),h("button",{type:"button","aria-label":"\u589E\u52A0"+label,disabled:disabled||!Number.isFinite(current)||current>=max5,onClick:()=>bump(1)},"+"))}function MoreHome({setView,selected,overview={},namespace,dataDirectory,updateSettings,savingSettings,usePluginSettings,setStrataGateStatus,setShortTermStatus,setRetrievalStatus,setSidebarEntry,setDailyEnabled,setDailyInjectionDays}){let pluginSettings=usePluginSettings?usePluginSettings(state=>state):null,settingsWritable=pluginSettings?.writable===!0,[pending,setPending]=React.useState({}),[settingError,setSettingError]=React.useState({key:"",text:""}),[savingKey,setSavingKey]=React.useState(""),[copyState,setCopyState]=React.useState("");React.useEffect(()=>{setPending({blockTurnSize:String(selected?.blockTurnSize??6),blockDecayLambda:String(selected?.blockDecayLambda??.3),agentMemoryRetrievalWeight:String(selected?.agentMemoryRetrievalWeight??1)})},[selected?.blockTurnSize,selected?.blockDecayLambda,selected?.agentMemoryRetrievalWeight]);let engine=[["blockTurnSize","\u6BCF\u5757\u8F6E\u6570","",1,30,1],["blockDecayLambda","\u8870\u51CF\u7CFB\u6570","",0,.4,.05],["agentMemoryRetrievalWeight","\u4E3B\u52A8\u68C0\u7D22\u5360\u6BD4","",0,5,.05]],saved=key=>Number(selected?.[key]??(key==="blockTurnSize"?6:key==="blockDecayLambda"?.3:1)),changedKeys=engine.map(([key])=>key).filter(key=>pending[key]!==void 0&&Number(pending[key])!==saved(key)&&pending[key]!==""),validEngine=engine.every(([key])=>{let raw=pending[key];return raw!==void 0&&raw!==""&&Number.isFinite(Number(raw))}),saveEngine=async()=>{if(!(!changedKeys.length||!validEngine||savingSettings)){setSettingError({key:"",text:""});try{await updateSettings({blockTurnSize:Number(pending.blockTurnSize),blockDecayLambda:Number(pending.blockDecayLambda),agentMemoryRetrievalWeight:Number(pending.agentMemoryRetrievalWeight)})}catch(reason){setSettingError({key:"engine",text:"\u672A\u80FD\u4FDD\u5B58\u5F15\u64CE\u53C2\u6570\uFF1A"+String(reason?.message||reason)})}}},discardEngine=()=>setPending({blockTurnSize:String(saved("blockTurnSize")),blockDecayLambda:String(saved("blockDecayLambda")),agentMemoryRetrievalWeight:String(saved("agentMemoryRetrievalWeight"))}),toggle=async(key,setter,next2)=>{if(setter){setSavingKey(key),setSettingError({key:"",text:""});try{await setter(next2)||setSettingError({key,text:"\u672A\u80FD\u4FDD\u5B58\u8FD9\u9879\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key,text:"\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}finally{setSavingKey("")}}},stepDays=async next2=>{if(setDailyInjectionDays){setSavingKey("dailyDays"),setSettingError({key:"",text:""});try{await setDailyInjectionDays(next2)||setSettingError({key:"dailyDays",text:"\u5929\u6570\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key:"dailyDays",text:"\u5929\u6570\u4FDD\u5B58\u5931\u8D25\uFF1A"+String(reason?.message||reason)})}finally{setSavingKey("")}}},copyWorkspace=async()=>{if(navigator?.clipboard?.writeText)try{await navigator.clipboard.writeText(namespace||""),setCopyState("\u5DF2\u590D\u5236"),setSettingError({key:"",text:""})}catch{setSettingError({key:"workspace",text:"\u590D\u5236\u5DE5\u4F5C\u533A ID \u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236\u3002"})}},retry=async(key,apply3)=>{setSettingError({key:"",text:""});try{await apply3()||setSettingError({key,text:"\u4ECD\u7136\u65E0\u6CD5\u4FDD\u5B58\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"})}catch(reason){setSettingError({key,text:"\u4ECD\u7136\u65E0\u6CD5\u4FDD\u5B58\uFF1A"+String(reason?.message||reason)})}},rowError=(key,apply3)=>settingError.key===key?h("p",{className:"sg-more-error",role:"alert"},settingError.text,apply3?h("button",{type:"button",className:"sg-more-retry",onClick:()=>{retry(key,apply3)}},"\u91CD\u8BD5"):null):null,switchRow=({key,title,description,checked,setter,disabled=!1,child=!1})=>h("li",{key,className:"sg-more-row sg-more-switch"+(child?" child":"")},h("div",null,h("span",{className:"sg-k2"},title),description?h("span",{className:"sg-s2"},description):null,rowError(key,()=>setter(!checked))),h("button",{type:"button",className:"sg-setting-switch",role:"switch","aria-label":title,"aria-checked":checked,disabled:disabled||!settingsWritable||savingKey===key,onClick:()=>{toggle(key,setter,!checked)}})),goRow=(key,title,description,view)=>h("li",{key,className:"sg-more-row"},h("button",{type:"button",className:"sg-more-go",onClick:()=>setView({name:view})},h("div",null,h("span",{className:"sg-k2"},title),description?h("span",{className:"sg-s2"},description):null),h("span",{className:"sg-row-go","aria-hidden":"true"},"\u203A"))),group2=(title,rows,extra="")=>h("section",{key:title,className:"sg-profile-group","aria-label":title},h("h4",null,title),h("ul",null,rows,extra)),duplicates=Number(selected?.duplicateRepair?.needsReview||0),failed=Number(selected?.failedJobs||0),processing=Number(selected?.processingJobs||0),statusRows=[h("li",{key:"kpi",className:"sg-more-kpi"},h("div",null,["blocks","events","graphNodes"].map((key,index)=>h("div",{key},h("b",null,String(Number(selected?.[key]||0))),h("span",null,["\u8BB0\u5FC6\u5757","\u4E8B\u4EF6","\u56FE\u8C31\u8282\u70B9"][index]))))),goRow("system","\u7CFB\u7EDF\u72B6\u6001",failed?failed+" \u4E2A\u4EFB\u52A1\u9700\u8981\u91CD\u8BD5":processing?processing+" \u4E2A\u4EFB\u52A1\u8FDB\u884C\u4E2D":"\u8FD0\u884C\u6B63\u5E38","system"),goRow("duplicates","\u91CD\u590D\u8BB0\u5FC6",duplicates?duplicates+" \u7EC4\u7B49\u4F60\u786E\u8BA4":"\u6CA1\u6709\u9700\u8981\u786E\u8BA4\u7684\u5206\u7EC4","duplicates")],dataRows=[goRow("import","\u5BFC\u5165\u5176\u4ED6 AI \u7684\u8BB0\u5FC6","\u628A\u522B\u7684 AI \u7684\u5386\u53F2\u8BB0\u5FC6\u5E26\u8FDB\u6765","import"),goRow("settings","\u9AD8\u7EA7\u8BBE\u7F6E","\u5411\u91CF\u68C0\u7D22\u3001\u7CBE\u6392\u4E0E\u8BB0\u5FC6\u914D\u7F6E","settings"),h("li",{key:"directory",className:"sg-more-row sg-more-row-path"},h("div",{className:"sg-more-path"},h("span",{className:"sg-k2"},"\u6570\u636E\u76EE\u5F55"),h("span",{className:"sg-s2 sg-mono sg-path",title:dataDirectory||void 0},dataDirectory||"\u5F53\u524D\u4F7F\u7528\u5185\u5B58\u5B58\u50A8")),h("button",{type:"button",className:"sg-quiet-button",disabled:!dataDirectory,onClick:()=>{api2("storage/open-directory",{},{method:"POST"}).catch(reason=>setSettingError({key:"directory",text:"\u6253\u5F00\u5931\u8D25\uFF1A"+String(reason?.message||reason)}))}},"\u6253\u5F00")),h("li",{key:"workspace",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"\u5F53\u524D\u5DE5\u4F5C\u533A"),h("span",{className:"sg-s2 sg-mono"},selected?.workspaceName||"\u5F53\u524D\u5DE5\u4F5C\u533A")),h("button",{type:"button",className:"sg-quiet-button",disabled:!namespace,onClick:copyWorkspace},copyState||"\u590D\u5236 ID"))],feedbackRows=[h("li",{key:"issue",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"GitHub Issue"),h("span",{className:"sg-s2"},"\u95EE\u9898\u548C\u5EFA\u8BAE\u63D0\u5230 GitHub")),h("a",{className:"sg-quiet-button",href:ISSUE_URL,target:"_blank",rel:"noopener noreferrer"},"\u63D0 Issue")),goRow("support","\u751F\u6210\u53CD\u9988\u62A5\u544A","\u53D1\u51FA\u524D\u53EF\u4EE5\u5148\u770B\u5B8C\u6574\u5185\u5BB9","support")],displayRows=[switchRow({key:"sidebar",title:"\u653E\u5230\u5DE6\u4FA7\u680F",checked:pluginSettings?.value?.showSidebarEntry===!0,setter:setSidebarEntry}),switchRow({key:"shortStatus",title:"\u4F1A\u8BDD\u8BB0\u5FC6\u72B6\u6001",checked:pluginSettings?.value?.showShortTermStatus!==!1,setter:setShortTermStatus}),switchRow({key:"retrievalStatus",title:"\u8BB0\u5FC6\u68C0\u7D22\u72B6\u6001",checked:pluginSettings?.value?.showRetrievalStatus!==!1,setter:setRetrievalStatus}),pluginSettings?.value?.showStrataGateStatus===!1?switchRow({key:"master",title:"\u6062\u590D\u72B6\u6001\u63D0\u793A",description:"\u4E4B\u524D\u6574\u4F53\u5173\u95ED\u4E86\u804A\u5929\u754C\u9762\u7684\u72B6\u6001\u63D0\u793A",checked:!1,setter:setStrataGateStatus}):null].filter(Boolean),dailyRows=[switchRow({key:"daily",title:"\u5199\u6BCF\u65E5\u7B14\u8BB0",description:"\u5173\u95ED\u540E\u4E0D\u518D\u5199\u5165\uFF0C\u5DF2\u6709\u7B14\u8BB0\u4FDD\u7559",checked:pluginSettings?.value?.dailyNotesEnabled!==!1,setter:setDailyEnabled}),h("li",{key:"days",className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"},"\u5E26\u5165\u5929\u6570"),h("span",{className:"sg-s2"},"\u53D6\u6700\u8FD1\u6709\u7B14\u8BB0\u7684\u65E5\u671F")),SettingStepper({value:pluginSettings?.value?.dailyNotesInjectionDays??3,unit:" \u5929",min:1,max:30,disabled:!settingsWritable||savingKey==="dailyDays",label:"\u5E26\u5165\u65B0\u4F1A\u8BDD\u7684\u5929\u6570",onChange:next2=>{stepDays(next2)}}))],engineRows=engine.map(([key,title,unit,min4,max5,step3])=>{let dirty=changedKeys.includes(key);return h("li",{key,className:"sg-more-row"},h("div",null,h("span",{className:"sg-k2"+(dirty?" dirty":"")},title)),h("span",{className:"sg-engine-value"+(dirty?" dirty":"")},SettingStepper({value:pending[key]??saved(key),unit,min:min4,max:max5,step:step3,disabled:savingSettings,label:title,onChange:next2=>setPending(current=>({...current,[key]:String(next2)}))})))});return h(React.Fragment,null,h("div",{className:"sg-pg-head"},h("h2",null,"\u66F4\u591A")),h("div",{className:"sg-more"},h("div",{className:"sg-more-col"},group2("\u8FD0\u884C\u72B6\u6001",statusRows),group2("\u6570\u636E",dataRows),group2("\u53CD\u9988",feedbackRows)),h("div",{className:"sg-more-col"},group2("\u663E\u793A",displayRows),group2("\u77ED\u671F\u8BB0\u5FC6",dailyRows),group2("\u5F15\u64CE\u53C2\u6570",engineRows,h(React.Fragment,null,rowError("engine",()=>updateSettings({blockTurnSize:Number(pending.blockTurnSize),blockDecayLambda:Number(pending.blockDecayLambda),agentMemoryRetrievalWeight:Number(pending.agentMemoryRetrievalWeight)})),changedKeys.length?h("li",{className:"sg-dirty"},h("span",null,changedKeys.length+" \u9879\u672A\u4FDD\u5B58"),h("button",{type:"button",className:"sg-quiet-button",disabled:savingSettings,onClick:discardEngine},"\u653E\u5F03"),h("button",{type:"button",className:"sg-save-button",disabled:savingSettings||!validEngine,onClick:()=>{saveEngine()}},savingSettings?"\u4FDD\u5B58\u4E2D\u2026":"\u4FDD\u5B58")):null)))))}function DisplayPage({onBack,usePluginSettings,setStrataGateStatus,setShortTermStatus,setRetrievalStatus,setSidebarEntry}){let pluginSettings=usePluginSettings?usePluginSettings(state=>state):null,settingsWritable=pluginSettings?.writable===!0,[sidebarSaving,setSidebarSaving]=React.useState(!1),[sidebarError,setSidebarError]=React.useState(""),changeSidebar=async visible=>{setSidebarSaving(!0),setSidebarError("");try{await setSidebarEntry?.(visible)||setSidebarError("\u672A\u80FD\u4FDD\u5B58\u4FA7\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002")}catch{setSidebarError("\u672A\u80FD\u4FDD\u5B58\u4FA7\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002")}finally{setSidebarSaving(!1)}},showStrataGateStatus=strataGateStatusVisible(pluginSettings),showShortTermStatus=pluginSettings?.value?.showShortTermStatus!==!1,showRetrievalStatus=pluginSettings?.value?.showRetrievalStatus!==!1,setting=({title,description,checked,disabled=!1,onChange,child=!1})=>h("div",{className:"sg-display-setting "+(child?"child ":"")+(disabled?"sg-display-disabled":"")},h("span",{className:"sg-display-setting-copy"},h("span",{className:"sg-display-setting-title"},title),h("span",{className:"sg-display-setting-description"},description)),h("button",{type:"button",className:"sg-setting-switch",role:"switch","aria-checked":checked,"aria-label":title,disabled:!settingsWritable||disabled,onClick:()=>{onChange&&onChange(!checked)}}));return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-pg-head"},h("h2",null,"\u754C\u9762\u4E0E\u663E\u793A")),h("p",{className:"sg-settings-group-copy"},"\u63A7\u5236\u4FA7\u680F\u5165\u53E3\u548C\u804A\u5929\u754C\u9762\u4E2D\u7684\u663E\u793A\u4FE1\u606F\u3002\u8BBE\u7F6E\u5BF9\u6240\u6709\u5DE5\u4F5C\u533A\u751F\u6548\u3002"),h("div",{className:"sg-settings-panel sg-display-settings"},setting({title:"\u5728\u5DE6\u4FA7\u680F\u663E\u793A StrataGate",description:"\u5173\u95ED\u540E\u9690\u85CF\u4FA7\u680F\u5165\u53E3\uFF0C\u4ECD\u53EF\u4ECE\u8BBE\u7F6E\u6253\u5F00\uFF1B\u8BB0\u5FC6\u3001\u68C0\u7D22\u548C\u540E\u53F0\u5904\u7406\u4E0D\u53D7\u5F71\u54CD\u3002",checked:pluginSettings?.value?.showSidebarEntry===!0,disabled:sidebarSaving||!setSidebarEntry,onChange:changeSidebar}),sidebarError?h("p",{role:"alert",className:"sg-error-note"},sidebarError):null,setting({title:"\u663E\u793A StrataGate \u72B6\u6001\u63D0\u793A",description:"\u5173\u95ED\u540E\u9690\u85CF\u804A\u5929\u754C\u9762\u4E2D\u7684 StrataGate \u72B6\u6001\u4FE1\u606F\uFF0C\u4E0D\u5F71\u54CD\u8BB0\u5FC6\u3001\u68C0\u7D22\u548C\u540E\u53F0\u5904\u7406\u3002",checked:showStrataGateStatus,onChange:setStrataGateStatus}),setting({title:"\u4F1A\u8BDD\u8BB0\u5FC6\u72B6\u6001",description:"\u663E\u793A Block \u8FDB\u5EA6\u3001\u5C01\u5B58\u7ED3\u679C\u548C\u6B63\u5728\u6574\u7406\u4F1A\u8BDD\u8BB0\u5FC6\u7B49\u72B6\u6001\u3002",checked:showShortTermStatus,disabled:!showStrataGateStatus,onChange:setShortTermStatus,child:!0}),setting({title:"\u8BB0\u5FC6\u68C0\u7D22\u72B6\u6001",description:"\u663E\u793A\u68C0\u7D22\u6B21\u6570\u3001\u8FD4\u56DE\u6570\u91CF\uFF0C\u4EE5\u53CA\u56DE\u7B54\u4E0B\u65B9\u7684\u8BB0\u5FC6\u91C7\u7528\u4FE1\u606F\u3002",checked:showRetrievalStatus,disabled:!showStrataGateStatus,onChange:setRetrievalStatus,child:!0})))}function redactText(value){return String(value??"").split(/\nRaw response(?: preview| \(full\))/i)[0].replace(/\b(?:sk[-_]|gh[opasu]_|github_pat_)[A-Za-z0-9_-]{8,}\b/g,"[REDACTED]").replace(/(["']?\b(?:api[_-]?key|token|password|passwd|access[_-]?token|refresh[_-]?token|secret|authorization)["']?\s*[:=]\s*)(["'])([\s\S]*?)\2/gi,"$1$2[REDACTED]$2").replace(/(\bauthorization\s*[:=]\s*)(Bearer|Basic|Token)\s+[^\s,;}]+/gi,"$1$2 [REDACTED]").replace(/\bBearer\s+[A-Za-z0-9._~+\/-]{8,}={0,2}\b/gi,"Bearer [REDACTED]").replace(/\b(?:Basic|Token)\s+[^\s,;}]+/gi,match2=>match2.replace(/\s+[^\s,;}]+$/," [REDACTED]")).replace(/(["']?\b(?:api[_-]?key|token|password|passwd|access[_-]?token|refresh[_-]?token|secret|authorization)["']?\s*[:=]\s*)([^\s,;}]+)/gi,"$1[REDACTED]").replace(/https?:\/\/[^\s<>"']+/gi,"[url]").replace(/[A-Z]:[\\/][^\s"'<>]+/gi,"[path]").replace(/\\\\[^\s"'<>\\]+\\[^\s"'<>]+/g,"[path]").replace(/(^|[\s"'(=:])\/(?:[^\s"'<>/]+\/)+[^\s"'<>]*/g,"$1[path]").replace(/[\w.+-]+@[\w.-]+\.[a-z]{2,}/gi,"[email]")}function redactedJson(value){let sensitive=/^(password|passwd|token|access[_-]?token|refresh[_-]?token|api[_-]?key|secret|authorization)$/i,visit=(current,key="")=>sensitive.test(String(key))?"[REDACTED]":typeof current=="string"?redactText(current):Array.isArray(current)?current.map(item=>visit(item)):current&&typeof current=="object"?Object.fromEntries(Object.entries(current).map(([name,item])=>[name,visit(item,name)])):current;return JSON.stringify(visit(value),null,2)??"null"}function restoreFeedbackDraftValues(draft,touched={}){return{title:touched.title?void 0:String(draft?.title||""),problemContent:touched.body?void 0:feedbackDraftMarkdown(draft)}}function whitelistedMessage(message){return{id:message?.id,role:message?.role,content:message?.content,createdAt:message?.createdAt,threadId:message?.threadId,toolCalls:Array.isArray(message?.toolCalls)?message.toolCalls.map(call=>({name:call?.name,arguments:call?.arguments,result:call?.result})):void 0}}function whitelistedEvent(event3){let temporal=event3?.temporal,weight8=event3?.weight;return{id:event3?.id,formedTurn:event3?.formedTurn,title:event3?.title,summary:event3?.summary,tags:event3?.tags,quotes:event3?.quotes,sourceBlockId:event3?.sourceBlockId,sourceMessageIds:event3?.sourceMessageIds,temporal:temporal?{mentionedAt:temporal.mentionedAt,happenedStart:temporal.happenedStart,happenedEnd:temporal.happenedEnd,originalText:temporal.originalText,precision:temporal.precision,basis:temporal.basis,status:temporal.status,participants:temporal.participants,participantNodeIds:temporal.participantNodeIds,eventType:temporal.eventType,threadId:temporal.threadId,sameEventId:temporal.sameEventId,beforeEventIds:temporal.beforeEventIds,afterEventIds:temporal.afterEventIds,supersedesEventIds:temporal.supersedesEventIds,conflictsWithEventIds:temporal.conflictsWithEventIds,relatedEventIds:temporal.relatedEventIds}:void 0,scope:event3?.scope,criticality:event3?.criticality,status:event3?.status,supersededBy:event3?.supersededBy,weight:weight8?{mentionCount:weight8.mentionCount,lastAdoptedTurn:weight8.lastAdoptedTurn,lastRetrievedAt:weight8.lastRetrievedAt,pinned:weight8.pinned,floorWeight:weight8.floorWeight,forcedCap:weight8.forcedCap}:void 0,createdAt:event3?.createdAt,updatedAt:event3?.updatedAt}}function whitelistedBlock(block){let source=block?.source||block||{},messages=block?.messages||block?.l5Raw||source?.l5Raw;return{id:block?.id??source?.id,threadId:block?.threadId??source?.threadId,sequence:block?.sequence??source?.sequence,blockIndex:block?.blockIndex,turnRange:block?.turnRange||(source?.startTurn!==void 0&&source?.endTurn!==void 0?[source.startTurn,source.endTurn]:void 0),title:block?.title??source?.l0Title,tags:block?.tags??source?.l0Tags,summary:block?.summary??source?.l1Summary,keypoints:block?.keypoints??source?.l2Keypoints,condensed:source?.l3Condensed,readable:source?.l4Readable,messages:Array.isArray(messages)?messages.map(whitelistedMessage):void 0,layers:Array.isArray(block?.layers)?block.layers.map(layer=>({level:layer?.level,content:layer?.content,tokens:layer?.tokens,percentOfL5:layer?.percentOfL5})):void 0,currentLevel:block?.currentLevel??source?.pointerCurrentLevel,currentTokens:block?.currentTokens,l5Tokens:block?.l5Tokens,compressionPercent:block?.compressionPercent,layerTokens:block?.layerTokens,distanceFromLatest:block?.distanceFromLatest,expansionSource:block?.expansionSource,lastLiftedAt:block?.lastLiftedAt??source?.lastLiftedAt,sourceMessages:block?.sourceMessages,createdAt:block?.createdAt??source?.createdAt,virtual:block?.virtual,processingStatus:block?.processingStatus??source?.processingStatus,summaryJob:block?.summaryJob?{status:block.summaryJob.status,attempts:block.summaryJob.attempts,nextRetryAt:block.summaryJob.nextRetryAt,updatedAt:block.summaryJob.updatedAt}:void 0,eventExtraction:block?.eventExtraction?{status:block.eventExtraction.status,attempts:block.eventExtraction.attempts,updatedAt:block.eventExtraction.updatedAt,lastError:block.eventExtraction.lastError}:void 0,graphProjection:block?.graphProjection?{status:block.graphProjection.status,jobs:block.graphProjection.jobs,lastError:block.graphProjection.lastError}:void 0,relatedEvents:Array.isArray(block?.relatedEvents)?block.relatedEvents.map(whitelistedEvent):void 0,relatedNodes:Array.isArray(block?.relatedNodes)?block.relatedNodes.map(node=>({id:node?.id,name:node?.name,type:node?.type})):void 0}}function whitelistedGraphNode(node){return{id:node?.id,name:node?.name,type:node?.type,aliases:node?.aliases,tags:node?.tags,currentState:node?.currentState,facts:Array.isArray(node?.facts)?node.facts.map(fact=>({id:fact?.id,key:fact?.key,value:fact?.value,status:fact?.status,validFrom:fact?.validFrom,validTo:fact?.validTo,confidence:fact?.confidence,sourceEventIds:fact?.sourceEventIds,createdAt:fact?.createdAt,updatedAt:fact?.updatedAt})):void 0,status:node?.status,confidence:node?.confidence,sourceEventIds:node?.sourceEventIds,supportingEvents:Array.isArray(node?.supportingEvents)?node.supportingEvents.map(whitelistedEvent):void 0,createdAt:node?.createdAt,updatedAt:node?.updatedAt}}function whitelistedGraph(graph){return{projectorVersion:graph?.projectorVersion,nodes:Array.isArray(graph?.nodes)?graph.nodes.map(whitelistedGraphNode):[],edges:Array.isArray(graph?.edges)?graph.edges.map(edge=>({id:edge?.id,fromNodeId:edge?.fromNodeId,toNodeId:edge?.toNodeId,relation:edge?.relation,status:edge?.status,validFrom:edge?.validFrom,validTo:edge?.validTo,confidence:edge?.confidence,sourceEventIds:edge?.sourceEventIds,createdAt:edge?.createdAt,updatedAt:edge?.updatedAt})):[],clusters:Array.isArray(graph?.clusters)?graph.clusters.map(cluster=>({id:cluster?.id,label:cluster?.label,nodeIds:cluster?.nodeIds,tags:cluster?.tags})):[],migration:graph?.migration?{projected:graph.migration.projected,total:graph.migration.total,pending:graph.migration.pending,running:graph.migration.running,failed:graph.migration.failed,retryable:graph.migration.retryable,processing:graph.migration.processing,state:graph.migration.state,complete:graph.migration.complete}:null}}function feedbackDraftMarkdown(draft={}){if(String(draft.bodyMarkdown||"").trim())return String(draft.bodyMarkdown).trim();let lines=[],section=(heading,value)=>{let text=String(value||"").trim();text&&lines.push("## "+heading,"",text,"")};section("\u95EE\u9898\u63CF\u8FF0",draft.description);let steps=Array.isArray(draft.reproduction)?draft.reproduction.map(value=>String(value||"").trim()).filter(Boolean):[];return steps.length&&lines.push("## \u590D\u73B0\u6B65\u9AA4","",...steps.map((value,index)=>index+1+". "+value),""),section("\u9884\u671F\u884C\u4E3A",draft.expected),section("\u5B9E\u9645\u884C\u4E3A",draft.actual),section("\u76F8\u5173\u9519\u8BEF\u4FE1\u606F",draft.errorContext),lines.join(`
|
|
1189
1189
|
`).trim()}function issueUrl(title=""){let value=String(title||"").trim(),params=new URLSearchParams;return value&¶ms.set("title",value),params.set("body",ISSUE_BODY_HINT),ISSUE_URL+"?"+params.toString()}function feedbackEmailUrl(title=""){let value=String(title||"").replace(/[\uD800-\uDFFF]/gu,"\uFFFD").replace(/[\u0000-\u001F\u007F-\u009F]+/g," ").trim().slice(0,240).replace(/[\uD800-\uDBFF]$/,""),subject="StrataGate \u53CD\u9988"+(value?"\uFF1A"+value:"");return"mailto:"+FEEDBACK_EMAIL+"?subject="+encodeURIComponent(subject)+"&body="+encodeURIComponent(EMAIL_BODY_HINT)}async function copyReportAndComposeEmail(report,clipboard=navigator?.clipboard,compose=url=>{window.location.href=url},title=""){let copyPromise=null,copyError="";if(!clipboard?.writeText)copyError="\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236\u3002";else try{copyPromise=Promise.resolve(clipboard.writeText(report))}catch(reason){copyError="\u590D\u5236\u5931\u8D25\uFF1A"+String(reason?.message||reason)}let composeRequested=!1;try{compose(feedbackEmailUrl(title)),composeRequested=!0}catch{}if(copyError)return{copied:!1,composeRequested,error:copyError};try{return await copyPromise,{copied:!0,composeRequested,error:""}}catch(reason){return{copied:!1,composeRequested,error:"\u590D\u5236\u5931\u8D25\uFF1A"+String(reason?.message||reason)}}}function handleFeedbackEmailResult(result,callbacks={}){if(result?.copied)callbacks.setStatus?.(result.composeRequested?"\u62A5\u544A\u5DF2\u590D\u5236\u3002\u8BF7\u5728\u90AE\u4EF6\u64B0\u5199\u7A97\u53E3\u4E2D\u7C98\u8D34\u3001\u68C0\u67E5\u5E76\u53D1\u9001\uFF1B\u82E5\u672A\u6253\u5F00\uFF0C\u8BF7\u590D\u5236\u4E0B\u65B9\u90AE\u7BB1\u81EA\u884C\u53D1\u9001\u3002":"\u62A5\u544A\u5DF2\u590D\u5236\u3002\u8BF7\u70B9\u51FB\u4E0B\u65B9\u90AE\u4EF6\u94FE\u63A5\uFF0C\u6216\u590D\u5236\u90AE\u7BB1\u81EA\u884C\u53D1\u9001\u3002");else{callbacks.setPreviewOpen?.(!0);let message=(result?.error||"\u590D\u5236\u62A5\u544A\u5931\u8D25\u3002")+" \u62A5\u544A\u4ECD\u4FDD\u7559\u5728\u9884\u89C8\u4E2D\uFF0C\u53EF\u624B\u52A8\u590D\u5236\u6216\u4E0B\u8F7D\u540E\u53D1\u9001\u81F3 "+FEEDBACK_EMAIL+"\u3002";callbacks.setError?.(current=>current?current+" "+message:message)}return result}let GITHUB_STARS_FALLBACK=128,GITHUB_STARS=(()=>{let value=Number(globalThis.__STRATAGATE_GITHUB_STARS__);return Number.isSafeInteger(value)&&value>=0?value:GITHUB_STARS_FALLBACK})();function formatStarCount(value){return typeof value=="number"&&Number.isFinite(value)&&value>=0?Math.floor(value).toLocaleString("en-US"):""}function loadStarCount(){return Promise.resolve(formatStarCount(GITHUB_STARS))}function GitHubMarkIcon(){return h("svg",{className:"sg-ghstar-icon",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",focusable:"false"},h("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"}))}function StrataGateMark(){return h("svg",{className:"sg-logo",viewBox:"0 0 32 32",role:"img","aria-label":"StrataGate",focusable:"false"},h("rect",{className:"sg-logo-back",x:10,y:5,width:16,height:17,rx:3,strokeWidth:1.5}),h("rect",{className:"sg-logo-middle",x:7,y:8,width:16,height:17,rx:3,strokeWidth:1.5}),h("rect",{className:"sg-logo-front",x:4,y:11,width:16,height:17,rx:3,strokeWidth:1.8}),h("path",{className:"sg-logo-rule",d:"M8 17h8M8 21h5",fill:"none",strokeWidth:1.8,strokeLinecap:"round"}))}function HeaderStarLink(){let shown=formatStarCount(GITHUB_STARS),label=shown?"\u5728 GitHub \u4E0A\u7ED9 StrataGate \u70B9 Star\uFF0C\u5F53\u524D "+shown+" \u4E2A":"\u5728 GitHub \u4E0A\u7ED9 StrataGate \u70B9 Star";return h("a",{className:"sg-ghstar",href:STAR_REPOSITORY_URL,target:"_blank",rel:"noopener noreferrer",title:label,"aria-label":label},h("span",{className:"sg-ghstar-label"},h(GitHubMarkIcon),h("b",null,"Star")),shown?h("span",{className:"sg-ghstar-count","aria-hidden":"true"},shown):null)}function buildSupportReport({problemContent="",overview={},selected={},data:data4={},recentError="",includeLogs=!1,includeMemory=!1,willingToContribute=!1,diagnostics=null}={}){let problem=redactText(String(problemContent||"").trim());if(!problem)return"";let reportDiagnostics=diagnostics&&!includeLogs?{...diagnostics,records:Array.isArray(diagnostics.records)?diagnostics.records.filter(record=>record&&typeof record=="object").map(({detail:_detail,...record})=>record):[]}:diagnostics,lines=["# StrataGate \u95EE\u9898\u62A5\u544A","",problem,"","## \u81EA\u52A8\u8BCA\u65AD\u4FE1\u606F","","- StrataGate \u7248\u672C\uFF1A"+(overview.pluginVersion||"unknown"),"- Harness \u7248\u672C\uFF1A"+(overview.harnessVersion||"unknown"),"- blockTurnSize\uFF1A"+(selected?.blockTurnSize??"unknown"),"- \u5DF2\u5C01\u5B58\u5757\uFF1A"+(selected?.blocks??"unknown"),"- Event / Graph Node \u6570\u91CF\uFF1A"+(selected?.events??"unknown")+" / "+(selected?.graphNodes??"unknown"),"- \u5F02\u5E38\u6458\u8981\uFF1A\u89C1\u4E0B\u65B9\u7ED3\u6784\u5316\u7EDF\u8BA1\u4E0E\u8BCA\u65AD\u3002","","> \u6B64\u62A5\u544A\u5728\u6D4F\u89C8\u5668\u672C\u5730\u751F\u6210\u3002\u9ED8\u8BA4\u8BCA\u65AD\u4E0D\u5305\u542B\u539F\u59CB\u804A\u5929\u3001L5\u3001Event \u6216 Graph \u5185\u5BB9\u3002\u6B63\u5219\u8131\u654F\u4EC5\u662F\u7EB5\u6DF1\u9632\u5FA1\uFF0C\u63D0\u4EA4\u524D\u4ECD\u9700\u4EBA\u5DE5\u68C0\u67E5\u3002"];if(lines.push("","## \u8FD1\u671F\u8FD0\u884C\u6458\u8981","","> \u8FD0\u884C\u6570\u636E\u5728\u672C\u5730\u91C7\u96C6\uFF1B\u65F6\u95F4\u8303\u56F4\u3001\u7F3A\u5931\u6570\u636E\u4E0E\u7EDF\u8BA1\u53E3\u5F84\u89C1\u4E0B\u65B9\u3002"),diagnostics){let totals=diagnostics.totals||{},shown=key=>typeof totals[key]=="number"?totals[key]:"\u672A\u53D6\u5F97";lines.push("","- \u7EDF\u8BA1\u8303\u56F4\uFF1A"+(diagnostics.since||"\u672A\u53D6\u5F97")+" \u81F3 "+(diagnostics.through||"\u672A\u53D6\u5F97")+"\uFF08UTC\uFF09","- \u6A21\u578B\u8BF7\u6C42\u6B21\u6570\uFF1A"+shown("modelCalls")+"\uFF1B\u5176\u4E2D\u7F3A\u5C11\u7528\u91CF\u8BB0\u5F55\uFF1A"+shown("missingUsageCalls"),"- \u5DF2\u62A5\u544A Token \u5408\u8BA1\uFF1A"+shown("totalTokens")+"\uFF1B\u5B8C\u6574\u603B\u91CF\u8BB0\u5F55\u7684\u8BF7\u6C42\u6570\uFF1A"+shown("totalTokenCalls"),"- \u8BB0\u5FC6\u64CD\u4F5C\u6210\u529F / \u5931\u8D25\uFF1A"+shown("operationsSucceeded")+" / "+shown("operationsFailed"))}if(lines.push("","### \u7ED3\u6784\u5316\u7EDF\u8BA1\u4E0E\u8BCA\u65AD","","```json",redactedJson(reportDiagnostics||{coverage:{available:!1,note:"\u8FD0\u884C\u7EDF\u8BA1\u5C1A\u672A\u53D6\u5F97\u3002"}}),"```"),willingToContribute&&lines.push("","## \u8D21\u732E\u610F\u613F","","- [x] \u6211\u613F\u610F\u5C1D\u8BD5\u4FEE\u590D\u5E76\u63D0\u4EA4 PR\u3002"),includeLogs){let failedJobs=Array.isArray(selected?.failedJobDetails)?selected.failedJobDetails.map(job=>({id:job?.id,kind:job?.kind,attempts:job?.attempts,lastError:job?.lastErrorFull||job?.lastError,updatedAt:job?.updatedAt,...job?.kind==="topic-projection"?{diagnostics:job?.diagnostics}:{}})):[];lines.push("","## \u8BCA\u65AD\u65E5\u5FD7","","```json",redactedJson({frontendError:recentError||null,failedJobs}),"```")}return includeMemory&&lines.push("","## \u7528\u6237\u4E3B\u52A8\u9644\u52A0\u7684\u8BB0\u5FC6\u6570\u636E\uFF08\u53EF\u80FD\u5305\u542B\u79C1\u4EBA\u5BF9\u8BDD\uFF09","","> \u8B66\u544A\uFF1A\u8FD9\u4E9B\u5185\u5BB9\u53EF\u80FD\u5305\u542B\u79C1\u4EBA\u5BF9\u8BDD\u3002\u81EA\u52A8\u8131\u654F\u4E0D\u80FD\u4FDD\u8BC1\u8BC6\u522B\u6240\u6709\u654F\u611F\u4FE1\u606F\uFF0C\u63D0\u4EA4\u524D\u5FC5\u987B\u4EBA\u5DE5\u68C0\u67E5\u3002","","```json",redactedJson({blocks:Array.isArray(data4?.blocks)?data4.blocks.map(whitelistedBlock):[],events:Array.isArray(data4?.events)?data4.events.map(whitelistedEvent):[],graph:whitelistedGraph(data4?.graph)}),"```"),lines.join(`
|
|
1190
1190
|
`)}async function copyReportAndOpenIssue(report,clipboard=navigator?.clipboard,openWindow=url=>window.open(url,"_blank"),title=""){let copyPromise=null,copyError="";if(!clipboard?.writeText)copyError="\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236\u3002";else try{copyPromise=Promise.resolve(clipboard.writeText(report))}catch(reason){copyError="\u590D\u5236\u5931\u8D25\uFF1A"+String(reason?.message||reason)}let opened=!1;try{let issueWindow=openWindow(issueUrl(title));opened=!!issueWindow,issueWindow&&(issueWindow.opener=null)}catch{}if(copyError)return{copied:!1,opened,error:copyError};try{return await copyPromise,{copied:!0,opened,error:""}}catch(reason){return{copied:!1,opened,error:"\u590D\u5236\u5931\u8D25\uFF1A"+String(reason?.message||reason)}}}function shouldExpandFeedbackPreview(result){return result?.copied===!1}function handleFeedbackIssueResult(result,callbacks={}){let messages=[];return result?.copied?callbacks.setStatus?.(result.opened?"\u62A5\u544A\u5DF2\u590D\u5236\u3002\u8BF7\u5728\u65B0\u6253\u5F00\u7684 Issue \u4E2D\u7C98\u8D34\u3001\u68C0\u67E5\u5E76\u63D0\u4EA4\u3002":"\u62A5\u544A\u5DF2\u590D\u5236\uFF0C\u4F46\u6D4F\u89C8\u5668\u53EF\u80FD\u62E6\u622A\u4E86\u65B0\u7A97\u53E3\u3002\u8BF7\u70B9\u51FB\u4E0B\u65B9\u666E\u901A\u94FE\u63A5\u6253\u5F00 Issue\u3002"):(shouldExpandFeedbackPreview(result)&&callbacks.setPreviewOpen?.(!0),messages.push((result?.error||"\u590D\u5236\u6216\u6253\u5F00 Issue \u5931\u8D25")+" \u62A5\u544A\u4ECD\u4FDD\u7559\u5728\u9884\u89C8\u4E2D\uFF1B\u8BF7\u624B\u52A8\u590D\u5236\u6216\u4E0B\u8F7D\u8BCA\u65AD\u6587\u4EF6\u3002"+(result?.opened?"":" \u4E5F\u53EF\u70B9\u51FB\u4E0B\u65B9\u666E\u901A\u94FE\u63A5\u6253\u5F00 Issue\u3002")),callbacks.setError?.(current=>current?current+" "+messages.join(" "):messages.join(" "))),result}function downloadSupportReport(report,documentRef=document,urlRef=URL){let blob=new Blob([report],{type:"text/plain;charset=utf-8"}),objectUrl=urlRef.createObjectURL(blob),link=documentRef.createElement("a");link.href=objectUrl,link.download="stratagate-diagnostics.txt",link.style.display="none";try{documentRef.body?.appendChild(link),link.click()}finally{link.remove(),urlRef.revokeObjectURL(objectUrl)}return blob}function SupportPage({namespace,overview,selected,data:data4,recentError,onBack}){let[includeLogs,setIncludeLogs]=React.useState(!1),[includeMemory,setIncludeMemory]=React.useState(!1),[willingToContribute,setWillingToContribute]=React.useState(!1),[status,setStatus]=React.useState(""),[error3,setError]=React.useState(""),[title,setTitle]=React.useState(""),[problemContent,setProblemContent]=React.useState(""),[draftLoading,setDraftLoading]=React.useState(!0),titleTouchedRef=React.useRef(!1),bodyTouchedRef=React.useRef(!1),[aiPromptCopied,setAiPromptCopied]=React.useState(!1),[previewOpen,setPreviewOpen]=React.useState(!1),[feedbackStep,setFeedbackStep]=React.useState(0),[reviewedReport,setReviewedReport]=React.useState(null),feedbackHeadingRef=React.useRef(null),previousFeedbackStepRef=React.useRef(0),aiNoticeRef=React.useRef(null),diagnosticsRef=React.useRef(null);React.useEffect(()=>{previousFeedbackStepRef.current!==feedbackStep&&feedbackHeadingRef.current?.focus({preventScroll:!0}),previousFeedbackStepRef.current=feedbackStep},[feedbackStep]),React.useEffect(()=>{let active=!0;return titleTouchedRef.current=!1,bodyTouchedRef.current=!1,setDraftLoading(!0),Promise.resolve().then(()=>api2("feedback",{namespace})).then(result=>{if(!active||(diagnosticsRef.current=result?.diagnostics||null,!result?.draft))return;let restored=restoreFeedbackDraftValues(result.draft,{title:titleTouchedRef.current,body:bodyTouchedRef.current});titleTouchedRef.current||setTitle(restored.title),bodyTouchedRef.current||setProblemContent(restored.problemContent),result.draft.aiPrepared&&restored.problemContent&&!titleTouchedRef.current&&!bodyTouchedRef.current&&(setReviewedReport(Object.freeze({title:restored.title,text:buildSupportReport({problemContent:restored.problemContent,overview,selected,data:data4,recentError,diagnostics:diagnosticsRef.current})})),setFeedbackStep(1))}).catch(reason=>{active&&setError("\u8BFB\u53D6\u53CD\u9988\u8349\u7A3F\u5931\u8D25\uFF1A"+String(reason?.message||reason))}).finally(()=>{active&&setDraftLoading(!1)}),()=>{active=!1}},[namespace]),React.useEffect(()=>{if(!aiPromptCopied)return;let reveal=()=>aiNoticeRef.current?.scrollIntoView({behavior:"smooth",block:"start"});if(typeof window.requestAnimationFrame!="function"){reveal();return}let frame=window.requestAnimationFrame(reveal);return()=>window.cancelAnimationFrame?.(frame)},[aiPromptCopied]);let saveDraft=async()=>{namespace&&await api2("feedback",{},{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({namespace,title,bodyMarkdown:problemContent})})},reportSnapshot=Object.freeze({text:buildSupportReport({problemContent,overview,selected,data:data4,recentError,includeLogs,includeMemory,willingToContribute,diagnostics:diagnosticsRef.current}),title}),reportBytes=reportSnapshot.text?new Blob([reportSnapshot.text]).size:0,hasProblem=!!problemContent.trim(),persistDraft=()=>{setStatus(""),setError(""),saveDraft().then(()=>setStatus("\u53CD\u9988\u8349\u7A3F\u5DF2\u4FDD\u5B58\u5728\u672C\u5730\u3002")).catch(reason=>setError("\u4FDD\u5B58\u53CD\u9988\u8349\u7A3F\u5931\u8D25\uFF1A"+String(reason?.message||reason)))},copyAndOpen=()=>{setStatus(""),setError(""),saveDraft().catch(reason=>setError(current=>{let message="\u4FDD\u5B58\u53CD\u9988\u8349\u7A3F\u5931\u8D25\uFF1A"+String(reason?.message||reason);return current?current+" "+message:message})),copyReportAndOpenIssue(reportSnapshot.text,navigator?.clipboard,url=>window.open(url,"_blank"),title).then(result=>handleFeedbackIssueResult(result,{setStatus,setError,setPreviewOpen})).catch(reason=>setError(current=>{let message="\u590D\u5236\u6216\u6253\u5F00 Issue \u5931\u8D25\uFF1A"+String(reason?.message||reason);return current?current+" "+message:message}))},copyAndEmail=()=>{setStatus(""),setError(""),saveDraft().catch(reason=>setError(current=>{let message="\u4FDD\u5B58\u53CD\u9988\u8349\u7A3F\u5931\u8D25\uFF1A"+String(reason?.message||reason);return current?current+" "+message:message})),copyReportAndComposeEmail(reportSnapshot.text,navigator?.clipboard,void 0,title).then(result=>handleFeedbackEmailResult(result,{setStatus,setError,setPreviewOpen})).catch(reason=>setError(current=>{let message="\u51C6\u5907\u90AE\u4EF6\u53CD\u9988\u5931\u8D25\uFF1A"+String(reason?.message||reason);return current?current+" "+message:message}))},copyEmail=async()=>{if(setStatus(""),GITHUB_FEEDBACK_ENABLED&&setError(""),!navigator?.clipboard?.writeText){setError("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236\uFF0C\u8BF7\u624B\u52A8\u590D\u5236\u90AE\u7BB1\uFF1A"+FEEDBACK_EMAIL);return}try{await navigator.clipboard.writeText(FEEDBACK_EMAIL),setStatus("\u90AE\u7BB1\u5DF2\u590D\u5236\uFF1A"+FEEDBACK_EMAIL)}catch{setError("\u590D\u5236\u90AE\u7BB1\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u590D\u5236\uFF1A"+FEEDBACK_EMAIL)}},copyAiPrompt=()=>{if(setStatus(""),setError(""),!navigator?.clipboard?.writeText){setError("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236\u3002\u8BF7\u5C55\u5F00\u4E0B\u65B9\u63D0\u793A\u8BCD\u5E76\u624B\u52A8\u590D\u5236\u3002");return}navigator.clipboard.writeText(FEEDBACK_AI_PROMPT).then(()=>setAiPromptCopied(!0)).catch(reason=>setError("\u590D\u5236 AI \u63D0\u793A\u8BCD\u5931\u8D25\uFF1A"+String(reason?.message||reason)))},download=()=>{setStatus(""),setError("");try{downloadSupportReport(GITHUB_FEEDBACK_ENABLED?reportSnapshot.text:reviewedReport?.text||""),setStatus("\u8BCA\u65AD\u6587\u4EF6\u5DF2\u4E0B\u8F7D\u3002\u6587\u4EF6\u5185\u5BB9\u4E0E\u5F53\u524D\u9884\u89C8\u5B8C\u5168\u4E00\u81F4\u3002")}catch(reason){setError("\u4E0B\u8F7D\u5931\u8D25\uFF1A"+String(reason?.message||reason)+"\u3002\u62A5\u544A\u4ECD\u4FDD\u7559\u5728\u9884\u89C8\u4E2D\uFF0C\u53EF\u624B\u52A8\u590D\u5236\u3002")}};if(!GITHUB_FEEDBACK_ENABLED){let review=()=>{!hasProblem||draftLoading||(setStatus(""),setError(""),setReviewedReport(reportSnapshot),setFeedbackStep(1),saveDraft().catch(reason=>setError("\u4FDD\u5B58\u53CD\u9988\u8349\u7A3F\u5931\u8D25\uFF1A"+String(reason?.message||reason))))},edit=()=>{setFeedbackStep(0),setReviewedReport(null),setStatus(""),setError("")},copyReport=async()=>{if(reviewedReport?.text){setStatus("");try{if(!globalThis.navigator?.clipboard?.writeText)throw new Error("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236");await globalThis.navigator.clipboard.writeText(reviewedReport.text),setStatus("\u62A5\u544A\u5DF2\u590D\u5236\u3002\u8BF7\u5728\u81EA\u5DF1\u7684\u90AE\u7BB1\u4E2D\u7C98\u8D34\u3001\u68C0\u67E5\u5E76\u53D1\u9001\u3002")}catch{setError("\u65E0\u6CD5\u81EA\u52A8\u590D\u5236\u3002\u4E0B\u65B9\u4FDD\u7559\u5B8C\u6574\u62A5\u544A\uFF0C\u53EF\u9009\u4E2D\u624B\u52A8\u590D\u5236\uFF0C\u6216\u4E0B\u8F7D\u62A5\u544A\u3002")}}};return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("section",{className:"sg-feedback-wizard","aria-label":"StrataGate \u63D2\u4EF6\u53CD\u9988"},h("div",{className:"sg-feedback-heading"},h("h2",{ref:feedbackHeadingRef,tabIndex:-1},"\u53CD\u9988 StrataGate"),h("p",null,feedbackStep===0?"\u8BA9 AI \u6839\u636E\u521A\u624D\u7684\u4F1A\u8BDD\u6574\u7406\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u8865\u5145\u4E00\u4E24\u53E5\u3002\u8FD0\u884C\u6458\u8981\u4F1A\u81EA\u52A8\u52A0\u5165\u62A5\u544A\u3002":"\u68C0\u67E5\u4E0B\u9762\u7684\u5B8C\u6574\u62A5\u544A\uFF0C\u518D\u590D\u5236\u5230\u81EA\u5DF1\u7684\u90AE\u7BB1\u53D1\u9001\u3002")),draftLoading?h("p",{className:"sg-support-sync",role:"status"},"\u6B63\u5728\u8BFB\u53D6\u672C\u5730\u53CD\u9988\u8349\u7A3F\u2026"):null,feedbackStep===0?h("section",{className:"sg-feedback-stage","aria-label":"\u7F16\u8F91\u53CD\u9988"},AGENT_FEEDBACK_ENABLED?h("div",{className:"sg-feedback-actions"},h("button",{type:"button",className:"sg-quiet-button",onClick:copyAiPrompt},"\u8BA9 AI \u6574\u7406\u53CD\u9988")):null,AGENT_FEEDBACK_ENABLED?h("details",null,h("summary",null,"\u67E5\u770B AI \u63D0\u793A\u8BCD"),h("pre",{className:"sg-raw-json sg-code"},FEEDBACK_AI_PROMPT)):null,aiPromptCopied?h("p",{ref:aiNoticeRef,role:"status"},"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\u3002\u56DE\u5230\u521A\u624D\u7684\u4F1A\u8BDD\uFF0C\u7C98\u8D34\u5E76\u53D1\u9001\uFF0CAI \u4F1A\u751F\u6210\u672C\u5730\u8349\u7A3F\u3002"):null,h("label",{className:"sg-support-field"},h("span",null,"\u95EE\u9898\u5185\u5BB9"),h("textarea",{className:"sg-support-description",rows:7,value:problemContent,onChange:event3=>{bodyTouchedRef.current=!0,setProblemContent(event3.target.value)},onBlur:persistDraft,placeholder:"\u53EF\u4EE5\u8BA9 AI \u6574\u7406\u540E\u518D\u8865\u5145\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u63CF\u8FF0\u95EE\u9898\u3001\u5EFA\u8BAE\u6216\u7591\u95EE\u3002","aria-label":"\u95EE\u9898\u5185\u5BB9"})),h("label",{className:"sg-support-field"},h("span",null,"\u90AE\u4EF6\u4E3B\u9898\uFF08\u53EF\u9009\uFF09"),h("input",{className:"sg-support-input",value:title,onChange:event3=>{titleTouchedRef.current=!0,setTitle(event3.target.value)},onBlur:persistDraft})),h("fieldset",{className:"sg-feedback-options"},h("legend",null,"\u9644\u52A0\u4FE1\u606F"),h("p",null,"\u9ED8\u8BA4\u5305\u542B\u57FA\u7840\u8BCA\u65AD\u3001\u8FD1\u671F\u8FD0\u884C\u7EDF\u8BA1\u548C\u5F02\u5E38\u5206\u7C7B\uFF1B\u4EE5\u4E0B\u5185\u5BB9\u7531\u4F60\u9009\u62E9\u52A0\u5165\u3002"),h("div",{className:"sg-feedback-checks"},h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeLogs,onChange:event3=>setIncludeLogs(event3.target.checked),"aria-label":"\u52A0\u5165\u65E5\u5FD7"}),h("span",null,"\u52A0\u5165\u8BE6\u7EC6\u9519\u8BEF\u65E5\u5FD7")),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeMemory,onChange:event3=>setIncludeMemory(event3.target.checked),"aria-label":"\u52A0\u5165\u8BB0\u5FC6\u5185\u5BB9"}),h("span",null,"\u52A0\u5165\u8BB0\u5FC6\u5185\u5BB9"))),includeMemory?h("p",{className:"sg-error-note"},"\u8BB0\u5FC6\u5185\u5BB9\u53EF\u80FD\u5305\u542B\u79C1\u4EBA\u5BF9\u8BDD\uFF0C\u8BF7\u9010\u9879\u68C0\u67E5\u540E\u53D1\u9001\u3002"):null),hasProblem?null:h("p",{className:"sg-support-empty"},"\u6709\u4E86\u95EE\u9898\u63CF\u8FF0\u540E\uFF0C\u5373\u53EF\u68C0\u67E5\u62A5\u544A\u3002"),h("div",{className:"sg-feedback-actions"},h("button",{type:"button",className:"sg-primary-link",disabled:!hasProblem||draftLoading,onClick:review},"\u68C0\u67E5\u62A5\u544A"))):null,feedbackStep>0&&reviewedReport?h("section",{className:"sg-feedback-stage","aria-label":"\u68C0\u67E5\u5E76\u53D1\u9001\u53CD\u9988"},h("div",{className:"sg-feedback-ready"},h("span",{className:"sg-feedback-unsent"},"\u5C1A\u672A\u53D1\u9001"),h("p",null,"\u62A5\u544A\u5305\u542B\u95EE\u9898\u63CF\u8FF0\u548C\u672C\u5730\u8FD0\u884C\u6458\u8981\u3002\u8BF7\u68C0\u67E5\u51ED\u636E\u4E0E\u79C1\u4EBA\u5185\u5BB9\uFF1B\u53EF\u8FD4\u56DE\u4FEE\u6539\u3002")),h("label",{className:"sg-support-field"},h("span",null,"\u5B8C\u6574\u62A5\u544A \xB7 "+new Blob([reviewedReport.text]).size+" \u5B57\u8282"),h("textarea",{className:"sg-support-preview",readOnly:!0,value:reviewedReport.text,spellCheck:!1,"aria-label":"\u672C\u5730\u53CD\u9988\u62A5\u544A\u9884\u89C8"})),h("div",{className:"sg-feedback-actions"},h("button",{type:"button",className:"sg-primary-link",onClick:copyReport},"\u590D\u5236\u62A5\u544A"),h("button",{type:"button",className:"sg-quiet-button",onClick:edit},"\u4FEE\u6539\u6216\u8865\u5145"),h("button",{type:"button",className:"sg-quiet-button",onClick:download},"\u4E0B\u8F7D\u62A5\u544A")),h("section",{className:"sg-feedback-contact","aria-label":"\u90AE\u4EF6\u53D1\u9001\u4FE1\u606F"},h("p",{className:"sg-feedback-email"},FEEDBACK_EMAIL),h("button",{type:"button",className:"sg-quiet-button",onClick:copyEmail},"\u590D\u5236\u90AE\u7BB1"),h("p",null,"\u90AE\u4EF6\u4E3B\u9898\uFF1AStrataGate \u53CD\u9988"+(reviewedReport.title?"\uFF1A"+reviewedReport.title:"")),h("p",{className:"sg-feedback-caption"},"\u5728\u81EA\u5DF1\u7684\u90AE\u7BB1\u586B\u5199\u6536\u4EF6\u5730\u5740\uFF0C\u7C98\u8D34\u62A5\u544A\u540E\u53D1\u9001\u3002")),h("p",{className:"sg-feedback-caption"},"\u8D44\u6599\u4FDD\u5B58\u5728\u672C\u5730\uFF1B\u4F5C\u8005\u5728\u6536\u5230\u4F60\u53D1\u9001\u7684\u90AE\u4EF6\u540E\u624D\u80FD\u67E5\u770B\u3002")):null,status?h("p",{className:"sg-support-status",role:"status","aria-live":"polite"},status):null,error3?h("p",{className:"sg-support-error",role:"alert"},error3):null))}return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u53CD\u9988\u4E0E\u652F\u6301"),h("p",null,GITHUB_FEEDBACK_ENABLED?"\u62A5\u544A\u53EA\u5728\u672C\u5730\u751F\u6210\u3002\u53EA\u6709\u4F60\u4E3B\u52A8\u7C98\u8D34\u6216\u4E0A\u4F20\u540E\uFF0C\u5185\u5BB9\u624D\u4F1A\u8FDB\u5165 GitHub\u3002":"\u62A5\u544A\u53EA\u5728\u672C\u5730\u751F\u6210\u3002\u8BF7\u901A\u8FC7\u90AE\u4EF6\u53CD\u9988\u95EE\u9898\uFF0C\u68C0\u67E5\u5185\u5BB9\u540E\u81EA\u884C\u53D1\u9001\u3002")),GITHUB_FEEDBACK_ENABLED&&aiPromptCopied?h("div",{ref:aiNoticeRef,className:"sg-support-ai-notice",role:"status","aria-live":"polite"},h("span",{className:"sg-support-ai-notice-mark","aria-hidden":"true"},"\u2713"),h("div",null,h("strong",null,"AI \u63D0\u793A\u8BCD\u5DF2\u590D\u5236"),h("p",null,"\u4E0B\u4E00\u6B65\uFF1A\u56DE\u5230\u521A\u624D\u51FA\u73B0\u95EE\u9898\u7684\u4F1A\u8BDD\uFF0C\u76F4\u63A5\u7C98\u8D34\u5E76\u53D1\u9001\u3002"),h("p",null,"Agent \u4F1A\u6839\u636E\u521A\u624D\u7684\u4F1A\u8BDD\u6574\u7406\u95EE\u9898\uFF0C\u5E76\u81EA\u52A8\u521B\u5EFA\u53CD\u9988\u8349\u7A3F\u3002"),h("button",{type:"button",className:"sg-quiet-button",onClick:copyAiPrompt},"\u518D\u6B21\u590D\u5236\u63D0\u793A\u8BCD")),h("button",{type:"button",className:"sg-support-ai-notice-close",onClick:()=>setAiPromptCopied(!1),"aria-label":"\u5173\u95ED AI \u63D0\u793A\u8BCD\u63D0\u793A"},"\xD7")):null,h("div",{className:"sg-privacy-note"},GITHUB_FEEDBACK_ENABLED?"GitHub \u94FE\u63A5\u4E0D\u5305\u542B\u62A5\u544A\u6B63\u6587\u3001\u8BCA\u65AD\u65E5\u5FD7\u6216\u8BB0\u5FC6\u6570\u636E\u3002StrataGate \u6C38\u8FDC\u4E0D\u4F1A\u81EA\u52A8\u63D0\u4EA4 Issue\u3002":"\u90AE\u4EF6\u94FE\u63A5\u53EA\u9884\u586B\u4E3B\u9898\u548C\u7C98\u8D34\u63D0\u793A\uFF0C\u4E0D\u5305\u542B\u62A5\u544A\u6B63\u6587\u3001\u8BCA\u65AD\u65E5\u5FD7\u6216\u8BB0\u5FC6\u6570\u636E\u3002StrataGate \u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\u90AE\u4EF6\u3002"),GITHUB_FEEDBACK_ENABLED?null:h("section",{className:"sg-support-card"},h("h3",null,"\u53CD\u9988\u90AE\u7BB1"),h("p",null,h("a",{className:"sg-link",href:feedbackEmailUrl(title)},FEEDBACK_EMAIL)),h("button",{type:"button",className:"sg-quiet-button",onClick:copyEmail},"\u590D\u5236\u90AE\u7BB1"),h("p",null,"\u82E5\u70B9\u51FB\u94FE\u63A5\u540E\u6CA1\u6709\u6253\u5F00\u90AE\u4EF6\u5E94\u7528\uFF0C\u53EF\u590D\u5236\u90AE\u7BB1\uFF0C\u5728\u5E38\u7528\u90AE\u7BB1\u4E2D\u64B0\u5199\u90AE\u4EF6\uFF1B\u8BCA\u65AD\u6587\u4EF6\u53EF\u624B\u52A8\u6DFB\u52A0\u4E3A\u9644\u4EF6\u3002")),h("section",{className:"sg-support-card sg-support-compose"},h("div",{className:"sg-support-compose-head"},h("div",null,h("h3",null,"\u63CF\u8FF0\u95EE\u9898"),h("p",null,"\u81EA\u7531\u63CF\u8FF0\u5373\u53EF\uFF0C\u4E0D\u9700\u8981\u586B\u5199\u591A\u7EC4\u5FC5\u586B\u8868\u5355\u3002")),GITHUB_FEEDBACK_ENABLED?h("button",{type:"button",className:"sg-support-ai",onClick:copyAiPrompt},"AI \u5E2E\u6211\u586B"):null),h("label",{className:"sg-support-field"},h("span",null,GITHUB_FEEDBACK_ENABLED?"Issue \u6807\u9898\uFF08\u53EF\u9009\uFF09":"\u90AE\u4EF6\u4E3B\u9898\uFF08\u53EF\u9009\uFF09"),h("input",{className:"sg-support-input",value:title,onChange:event3=>{titleTouchedRef.current=!0,setTitle(event3.target.value)},onBlur:persistDraft,placeholder:"\u7B80\u77ED\u6982\u62EC\u95EE\u9898"})),h("label",{className:"sg-support-field"},h("span",null,"\u95EE\u9898\u5185\u5BB9"),h("textarea",{className:"sg-support-description",value:problemContent,onChange:event3=>{bodyTouchedRef.current=!0,setProblemContent(event3.target.value)},onBlur:persistDraft,placeholder:GITHUB_FEEDBACK_ENABLED?"\u63CF\u8FF0\u521A\u624D\u53D1\u751F\u4E86\u4EC0\u4E48\uFF1B\u4E5F\u53EF\u4EE5\u70B9\u51FB\u201CAI \u5E2E\u6211\u586B\u201D\u3002":"\u63CF\u8FF0\u53D1\u751F\u4E86\u4EC0\u4E48\u3001\u590D\u73B0\u6B65\u9AA4\uFF0C\u4EE5\u53CA\u9884\u671F\u548C\u5B9E\u9645\u7ED3\u679C\u3002","aria-label":"\u95EE\u9898\u5185\u5BB9"})),GITHUB_FEEDBACK_ENABLED?h("details",null,h("summary",null,"\u67E5\u770B\u53EF\u624B\u52A8\u590D\u5236\u7684 AI \u63D0\u793A\u8BCD"),h("pre",{className:"sg-raw-json sg-code"},FEEDBACK_AI_PROMPT)):null,draftLoading?h("div",{className:"sg-support-sync"},"\u6B63\u5728\u8BFB\u53D6\u672C\u5730\u53CD\u9988\u8349\u7A3F\u2026"):null),h("section",{className:"sg-support-card"},h("h3",null,"\u9644\u52A0\u4FE1\u606F"),h("p",null,"\u57FA\u7840\u8BCA\u65AD\u9ED8\u8BA4\u5305\u542B\uFF1B\u65E5\u5FD7\u548C\u8BB0\u5FC6\u6570\u636E\u53EA\u6709\u5728\u4F60\u4E3B\u52A8\u52FE\u9009\u540E\u624D\u4F1A\u52A0\u5165\u3002"),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:!0,disabled:!0}),h("span",null,"\u9ED8\u8BA4\u57FA\u7840\u8BCA\u65AD")),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeLogs,onChange:event3=>setIncludeLogs(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BCA\u65AD\u65E5\u5FD7")),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeMemory,onChange:event3=>setIncludeMemory(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BB0\u5FC6\u6570\u636E\uFF08\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\uFF09")),includeMemory?h("div",{className:"sg-error-note"},"\u8B66\u544A\uFF1A\u5185\u5BB9\u53EF\u80FD\u5305\u542B\u79C1\u4EBA\u5BF9\u8BDD\uFF1B\u81EA\u52A8\u8131\u654F\u4E0D\u80FD\u4FDD\u8BC1\u8BC6\u522B\u6240\u6709\u654F\u611F\u4FE1\u606F\uFF1B\u63D0\u4EA4\u524D\u5FC5\u987B\u4EBA\u5DE5\u68C0\u67E5\u3002"):null,GITHUB_FEEDBACK_ENABLED?h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:willingToContribute,onChange:event3=>setWillingToContribute(event3.target.checked)}),h("span",null,"\u6211\u613F\u610F\u5C1D\u8BD5\u4FEE\u590D\u5E76\u63D0\u4EA4 PR")):null,hasProblem?null:h("div",{className:"sg-support-empty"},GITHUB_FEEDBACK_ENABLED?"\u8BF7\u5148\u63CF\u8FF0\u95EE\u9898\uFF0C\u6216\u4F7F\u7528 AI \u5E2E\u4F60\u586B\u5199\u3002":"\u8BF7\u5148\u63CF\u8FF0\u95EE\u9898\uFF0C\u518D\u590D\u5236\u62A5\u544A\u5E76\u901A\u8FC7\u90AE\u4EF6\u53D1\u9001\u3002"),h("div",{className:"sg-support-actions"},h("button",{type:"button",className:"sg-primary-link",disabled:!hasProblem,onClick:GITHUB_FEEDBACK_ENABLED?copyAndOpen:copyAndEmail},GITHUB_FEEDBACK_ENABLED?"\u590D\u5236\u62A5\u544A\u5E76\u6253\u5F00 GitHub Issue":"\u590D\u5236\u62A5\u544A\u5E76\u64B0\u5199\u90AE\u4EF6"),h("button",{type:"button",className:"sg-quiet-button",disabled:!hasProblem,onClick:()=>setPreviewOpen(open=>!open),"aria-expanded":previewOpen},previewOpen?"\u6536\u8D77\u5C06\u590D\u5236\u7684\u5185\u5BB9":"\u67E5\u770B\u5C06\u590D\u5236\u7684\u5185\u5BB9"),h("button",{type:"button",className:"sg-quiet-button",disabled:!hasProblem,onClick:download},"\u4E0B\u8F7D\u8BCA\u65AD\u6587\u4EF6"),GITHUB_FEEDBACK_ENABLED?h("a",{className:"sg-link",href:issueUrl(title),target:"_blank",rel:"noopener noreferrer"},"\u4EC5\u6253\u5F00 GitHub Issue"):h("a",{className:"sg-link",href:feedbackEmailUrl(title)},"\u4EC5\u64B0\u5199\u90AE\u4EF6")),hasProblem&&previewOpen?h("div",{className:"sg-support-preview-panel",role:"region","aria-label":"\u5C06\u590D\u5236\u7684\u53CD\u9988\u62A5\u544A"},h("div",{className:"sg-support-preview-head"},h("strong",null,"\u5C06\u590D\u5236\u7684\u5185\u5BB9"),h("div",{className:"sg-support-metrics"},reportSnapshot.text.length+" \u4E2A\u5B57\u7B26 \xB7 "+reportBytes+" \u5B57\u8282")),includeMemory?h("div",{className:"sg-error-note"},"\u5DF2\u5305\u542B\u4F60\u4E3B\u52A8\u52FE\u9009\u7684 Memory \u6570\u636E\uFF0C\u8BF7\u9010\u9879\u68C0\u67E5\u8131\u654F\u7ED3\u679C\u548C\u79C1\u4EBA\u5BF9\u8BDD\u3002"):null,h("textarea",{id:"sg-support-preview",className:"sg-support-preview",readOnly:!0,value:reportSnapshot.text,spellCheck:!1,"aria-label":"\u672C\u5730\u53CD\u9988\u62A5\u544A\u9884\u89C8"})):null,status?h("div",{className:"sg-support-status",role:"status"},status):null,error3?h("div",{className:"sg-support-error",role:"alert"},error3):null),GITHUB_FEEDBACK_ENABLED?h("section",{className:"sg-support-card"},h("h3",null,"\u529F\u80FD\u5EFA\u8BAE"),h("p",null,"GitHub \u5165\u53E3\u4E0D\u4F1A\u9884\u586B\u6B63\u6587\uFF0C\u8BF7\u5728\u9875\u9762\u4E2D\u4E3B\u52A8\u586B\u5199\u5E76\u63D0\u4EA4\u3002"),h("a",{className:"sg-link",href:ISSUE_URL,target:"_blank",rel:"noopener noreferrer"},"\u521B\u5EFA Feature Request \u2192")):h("section",{className:"sg-support-card"},h("h3",null,"\u529F\u80FD\u5EFA\u8BAE"),h("p",null,"\u6B22\u8FCE\u901A\u8FC7\u90AE\u4EF6\u63D0\u51FA\u529F\u80FD\u5EFA\u8BAE\u3002"),h("a",{className:"sg-link",href:feedbackEmailUrl("\u529F\u80FD\u5EFA\u8BAE")},"\u53D1\u9001\u529F\u80FD\u5EFA\u8BAE \u2192")),GITHUB_FEEDBACK_ENABLED?h("section",{className:"sg-support-card"},h("h3",null,"\u4F7F\u7528\u7591\u95EE"),h("p",null,"\u5728 GitHub Discussion \u7684 Q&A \u533A\u4EA4\u6D41\u4F7F\u7528\u65B9\u6CD5\u3002"),h("a",{className:"sg-link",href:DISCUSSION_URL,target:"_blank",rel:"noopener noreferrer"},"\u524D\u5F80 Discussion / Q&A \u2192")):h("section",{className:"sg-support-card"},h("h3",null,"\u4F7F\u7528\u7591\u95EE"),h("p",null,"\u6B22\u8FCE\u901A\u8FC7\u90AE\u4EF6\u54A8\u8BE2\u4F7F\u7528\u65B9\u6CD5\u3002"),h("a",{className:"sg-link",href:feedbackEmailUrl("\u4F7F\u7528\u7591\u95EE")},"\u90AE\u4EF6\u54A8\u8BE2 \u2192")))}function StructurePage({events,eventPage,graph,openEvent,namespace,onBack}){let pagedEvents=usePagedMemory({namespace,kind:"events",initialItems:events,initialPage:eventPage,fallbackLimit:40});return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u8BB0\u5FC6\u7ED3\u6784"),h("p",null,"\u5B8C\u6574\u6D4F\u89C8\u73B0\u6709\u7ED3\u6784\u5316\u8BB0\u5FC6")),h("div",{className:"sg-counts"},h("div",null,h("div",{className:"sg-count-value"},pagedEvents.page.total),h("div",{className:"sg-count-label"},"\u7ECF\u5386 / Event")),h("div",null,h("div",{className:"sg-count-value"},graph.nodes.length),h("div",{className:"sg-count-label"},"\u77E5\u8BC6\u56FE\u8C31\u8282\u70B9"))),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u7ECF\u5386"),pagedEvents.items.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",null,event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt))))),h(Pagination,{page:pagedEvents.page,loading:pagedEvents.loading,error:pagedEvents.error,onOffset:pagedEvents.loadOffset}),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u56FE\u8C31\u8282\u70B9"),graph.nodes.map(node=>h("div",{key:node.id,className:"sg-related"},h("span",null,node.name),h("span",{className:"sg-related-time"},(node.sourceEventIds||[]).length+" \u6761\u652F\u6491\u4E8B\u4EF6")))))}let DUPLICATE_STYLES=`
|
|
1191
1191
|
.sg-memory-review .sg-header{padding:10px 12px;margin-bottom:12px}.sg-memory-review .sg-logo{width:28px;height:28px}.sg-memory-review .sg-brand-name{font-size:14px}.sg-memory-review .sg-header-row-secondary{margin-top:4px}.sg-memory-review .sg-tabs{margin-bottom:12px}.sg-memory-review .sg-dup-heading h2{font-size:21px}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stratagate-dsh",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.47",
|
|
4
4
|
"description": "Recent conversations stay vivid. Older ones fade into summaries, not oblivion. StrataGate gives DeepSeek Harness six-layer, time-decaying memory, while lasting events and relationships settle into a knowledge graph. Bring your memories from other AIs with you—no need to start over.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|