pisper 0.6.29 → 0.6.30
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/package.json +5 -5
- package/web/.vite/manifest.json +635 -635
- package/web/assets/{AppDialog-CX0n4qav.js → AppDialog-CkcKXNVx.js} +1 -1
- package/web/assets/{AppOverlays-J_rOhlw3.js → AppOverlays-8_a8G80q.js} +1 -1
- package/web/assets/{AssetsPage-BuAZJf2M.js → AssetsPage-CZ7QjoFZ.js} +1 -1
- package/web/assets/{BoardPage-BT684h8Y.js → BoardPage-UwrtEMkO.js} +3 -3
- package/web/assets/{ChannelsPage-CznKEDyh.js → ChannelsPage-v1or6g85.js} +1 -1
- package/web/assets/{ChatAppearancePage-BrZ30LfD.js → ChatAppearancePage-BWiw5pd9.js} +1 -1
- package/web/assets/{ChatHistoryPage-BEJbiMs3.js → ChatHistoryPage-BDFnmYkk.js} +1 -1
- package/web/assets/{ChatPage-CCL8A95i.js → ChatPage-DzQO0hD7.js} +3 -3
- package/web/assets/{ConfigPage-_YQZcZlC.js → ConfigPage-CfXNpwBp.js} +2 -2
- package/web/assets/{DesktopWindowControls-C-LzcrLu.js → DesktopWindowControls-Cz8Wg_hN.js} +1 -1
- package/web/assets/{FeaturePage-C4fMefC-.js → FeaturePage-CoalHN81.js} +1 -1
- package/web/assets/{FileAttachmentPreview-DCdc0GFC.js → FileAttachmentPreview-1U8-b6EF.js} +1 -1
- package/web/assets/{FloatingWidgets-C5PMwmK1.js → FloatingWidgets-g5sPCtIK.js} +1 -1
- package/web/assets/{FocusRuntimeControls-D6Rj2AHK.js → FocusRuntimeControls-DtXWdr8l.js} +1 -1
- package/web/assets/{GitDiffViewer-D2QUzasQ.js → GitDiffViewer-Dc46yAUc.js} +1 -1
- package/web/assets/{ManageProjectsDialog-CCg0vZ07.js → ManageProjectsDialog-5QL6Rsyx.js} +1 -1
- package/web/assets/{MarkdownMessage-DbPFHAG0.js → MarkdownMessage-BYQ5qUjo.js} +1 -1
- package/web/assets/{McpPage-DAg9VlnU.js → McpPage-CMMyexGW.js} +1 -1
- package/web/assets/{MemoryEvolution-CVF6CYuV.js → MemoryEvolution-DPD3_wye.js} +1 -1
- package/web/assets/{MemoryPage-C4C8Efhi.js → MemoryPage-Ba_yfJPT.js} +2 -2
- package/web/assets/{MobileNavigation-EsJOtmUl.js → MobileNavigation-CWfgl4Om.js} +1 -1
- package/web/assets/{MorePage-BslKLMFa.js → MorePage-D7Ez-MdJ.js} +1 -1
- package/web/assets/{NewFolderDialog-Bb4T0UPO.js → NewFolderDialog-CvV_ioYA.js} +1 -1
- package/web/assets/{PageHeader-DjJ0Ab6e.js → PageHeader-DeZrNdHv.js} +1 -1
- package/web/assets/{PhoneDrawer-Cu2FDUc1.js → PhoneDrawer-DrKWtKrk.js} +1 -1
- package/web/assets/{PhoneMenuButton-C8pYulkt.js → PhoneMenuButton-CKS9DzOB.js} +1 -1
- package/web/assets/{PhoneTopBar-CvMWkksM.js → PhoneTopBar-l-4k9nw_.js} +1 -1
- package/web/assets/{PluginsPage-DxjMMa05.js → PluginsPage-BsBzoPyO.js} +1 -1
- package/web/assets/{SafeModePrompt-DG64bady.js → SafeModePrompt-BBqKG3rI.js} +1 -1
- package/web/assets/{SchedulesPage-Bd0sjkiZ.js → SchedulesPage-C9VdDHsU.js} +1 -1
- package/web/assets/{SessionBrowserPane-CigWhKGU.js → SessionBrowserPane-Dsf4QuHa.js} +2 -2
- package/web/assets/{SessionContextPanel-HfjETMcF.js → SessionContextPanel-D_DlmWUB.js} +2 -2
- package/web/assets/{SessionHome-DtzbkF19.js → SessionHome-xbtukAlf.js} +1 -1
- package/web/assets/{SessionInspector-BZyFstFl.js → SessionInspector-iJDqtJQH.js} +1 -1
- package/web/assets/{SessionShell-BCIVsKr9.js → SessionShell-CgbIeUd0.js} +1 -1
- package/web/assets/{SettingsSidebar-F20r1qhh.js → SettingsSidebar-l2Fq0Fjv.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-BSiv5k3S.js → ShortcutHelpDialog-C9Cg-rDI.js} +1 -1
- package/web/assets/{ShortcutKeys-BWYkyL77.js → ShortcutKeys-COCK3Z1P.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-BA3cyY6N.js → SidebarUpdateStatus-Db5HG75S.js} +1 -1
- package/web/assets/{SkillsPage-C6cF2A7j.js → SkillsPage-bUxTQh3g.js} +1 -1
- package/web/assets/{TaskProcessesPane-B6O5Mirv.js → TaskProcessesPane-CepFj3M9.js} +1 -1
- package/web/assets/{TaskTerminalView-IR5bGXk7.js → TaskTerminalView-B3uXJaXz.js} +1 -1
- package/web/assets/{TerminalPanel-BAl1Ytmx.js → TerminalPanel-WjT3RQwU.js} +1 -1
- package/web/assets/{WebDesktopPet-CLjE98zM.js → WebDesktopPet-C0tCcQDc.js} +1 -1
- package/web/assets/{WorkflowsPage-5kMzkdP5.js → WorkflowsPage-CjYNxv4V.js} +1 -1
- package/web/assets/{WorkspacePicker-Dy3QRSbL.js → WorkspacePicker-B5zEAngW.js} +1 -1
- package/web/assets/{api-BhPOJ07B.js → api-CHqbIMkc.js} +1 -1
- package/web/assets/{app-update-DK-2lnli.js → app-update-K5RbjYD1.js} +1 -1
- package/web/assets/{approval-confirm-BiKVYJXn.js → approval-confirm-By4nwBEC.js} +1 -1
- package/web/assets/{board-projects-BmfKMy9W.js → board-projects-Cn6F0I5D.js} +1 -1
- package/web/assets/{bots-store-sXgxSYjm.js → bots-store-Cf4rK-qw.js} +1 -1
- package/web/assets/{chat-api-CdqM-TFw.js → chat-api-H18lBlnu.js} +1 -1
- package/web/assets/{client-store-CkmBBzE5.js → client-store-DtL9pe9n.js} +1 -1
- package/web/assets/{config-search-DTHZrqfb.js → config-search-CYSyHqnu.js} +1 -1
- package/web/assets/{desktop-hosts-BzI81G6K.js → desktop-hosts-Coceul_o.js} +1 -1
- package/web/assets/{dialog-BVAtioHy.js → dialog-C_ew2HiI.js} +1 -1
- package/web/assets/{event-stream-B9eeQcgA.js → event-stream-CJDJ_f9g.js} +1 -1
- package/web/assets/{events-CcKmvwE6.js → events-S66w92oA.js} +1 -1
- package/web/assets/{focus-session-composer-bits-BuYWKdXR.js → focus-session-composer-bits-CVCWWebM.js} +1 -1
- package/web/assets/{folder-paths-D8nYAh7q.js → folder-paths-CptXLCCu.js} +1 -1
- package/web/assets/{hosts-BRNTbndS.js → hosts-DPhLIJU_.js} +1 -1
- package/web/assets/{http-CXQuFoDX.js → http-Clt0jbV2.js} +1 -1
- package/web/assets/{http-response-scdqC11Q.js → http-response-C_f1S2cS.js} +1 -1
- package/web/assets/{i18n-D5XUOwJ3.js → i18n-Zs9wBTpa.js} +1 -1
- package/web/assets/{index-at6jiRd2.js → index-BpFQSLJJ.js} +2 -2
- package/web/assets/{machine-messages-BhLpbeyp.js → machine-messages-0-CA3CIF.js} +1 -1
- package/web/assets/{machines-api-c4gyvYeB.js → machines-api-C6W1eWgQ.js} +1 -1
- package/web/assets/{memory-api-BZLLcIF1.js → memory-api-BdiBvhoi.js} +1 -1
- package/web/assets/{mount-app-713eDAlJ.js → mount-app-Cx_t3TyS.js} +3 -3
- package/web/assets/{permission-rules-api-BoggV-So.js → permission-rules-api-B3tMaJim.js} +1 -1
- package/web/assets/{pick-system-directory-COxOQmRm.js → pick-system-directory-nvVGfFRB.js} +1 -1
- package/web/assets/{placements-CWg24KPB.js → placements-DQgsRjpv.js} +2 -2
- package/web/assets/{popover-BKEwGK6p.js → popover-CXY-wqxd.js} +1 -1
- package/web/assets/{public-Ds92tfxs.js → public-BFJhCijs.js} +2 -2
- package/web/assets/{public-DyoA5qbn.js → public-Cy9CZkvX.js} +2 -2
- package/web/assets/{public-CFmAK4C5.js → public-DftK6qxa.js} +1 -1
- package/web/assets/{public-components-CiFLJxlo.js → public-components-Dy2rT6tl.js} +1 -1
- package/web/assets/public-diff-DpqhuEMa.js +1 -0
- package/web/assets/public-events-DeehiuZW.js +1 -0
- package/web/assets/{public-flags-wwqdZl3u.js → public-flags-C0MjuPsC.js} +1 -1
- package/web/assets/{public-folder-dialog-MYvmKYka.js → public-folder-dialog-B_ho2Tuq.js} +1 -1
- package/web/assets/{public-greeting-DFC9u9sY.js → public-greeting-CuNs0758.js} +1 -1
- package/web/assets/{public-_SuCE3iR.js → public-ha8Otx14.js} +1 -1
- package/web/assets/{public-session-qSMh175y.js → public-session-B9nhW7qH.js} +1 -1
- package/web/assets/{public-sidebar-WFoUZVnB.js → public-sidebar-CWBvWdYQ.js} +1 -1
- package/web/assets/{runtime-capabilities-store-D0EC-a9c.js → runtime-capabilities-store-DoZOSQiv.js} +1 -1
- package/web/assets/{safe-mode-instance-Ct43-TDv.js → safe-mode-instance-B9F0Xu3o.js} +1 -1
- package/web/assets/safe-mode-sentinel-Bk2p-CVG.js +1 -0
- package/web/assets/{session-change-summary-api-CyghX14t.js → session-change-summary-api-BbviMo7L.js} +1 -1
- package/web/assets/{session-home-DY7RkKbH.js → session-home-D75yfsOZ.js} +1 -1
- package/web/assets/{session-inspector-store-BocK0l86.js → session-inspector-store-D8oaLlKH.js} +1 -1
- package/web/assets/{session-organization-api-CGRK7VMP.js → session-organization-api-DyiM7H-D.js} +1 -1
- package/web/assets/{session-scope-DDZF_AQ6.js → session-scope-D4AVO880.js} +1 -1
- package/web/assets/{session-tree-actions-g769G3qz.js → session-tree-actions-BiZreN0W.js} +1 -1
- package/web/assets/{session-tree-summary-CqrRroey.js → session-tree-summary-DZk4xiEt.js} +1 -1
- package/web/assets/{shortcuts-BsrTXPiU.js → shortcuts-1-ySiY-G.js} +1 -1
- package/web/assets/{side-chat-context-DNQ3tThq.js → side-chat-context-BXN0j7F9.js} +4 -4
- package/web/assets/{sidebar-R690QKPw.js → sidebar-6NqiNUCV.js} +1 -1
- package/web/assets/{sidebar-store-QvX0w7hQ.js → sidebar-store-CRSu48Er.js} +1 -1
- package/web/assets/{speech-session-DnBIZldd.js → speech-session-LPLnrut8.js} +1 -1
- package/web/assets/{startup-queries-BpV9-ykp.js → startup-queries-D4Xgj-oO.js} +1 -1
- package/web/assets/{use-i18n-AM3jlRYR.js → use-i18n-D6tl7SDi.js} +1 -1
- package/web/assets/{use-open-bot-BDco631W.js → use-open-bot-DFkiPFzc.js} +1 -1
- package/web/assets/{use-studio-actions-C7W6Soh6.js → use-studio-actions-DUeKLKcG.js} +1 -1
- package/web/assets/{useCatalogProjects-DCT51aGo.js → useCatalogProjects-Cv6RLD5k.js} +1 -1
- package/web/assets/{useMachines-BJtbuUVt.js → useMachines-5sQYc73a.js} +1 -1
- package/web/assets/{useNewProjectPicker-B85EuCYh.js → useNewProjectPicker-B058VLdC.js} +2 -2
- package/web/assets/{useNow-BUhFR4QI.js → useNow-v0wgDYcL.js} +1 -1
- package/web/assets/{usePhoneShell-CK9XBtgf.js → usePhoneShell-CcoVb1v0.js} +1 -1
- package/web/assets/{useSessionListQuery-B4Xmcfwa.js → useSessionListQuery-BaBpkejJ.js} +1 -1
- package/web/assets/{useSessionRowActions-BMestf2F.js → useSessionRowActions-B-TF8WrJ.js} +1 -1
- package/web/assets/{useSidebarModel-BDfzya9Z.js → useSidebarModel-B5Mjqu8a.js} +1 -1
- package/web/assets/{workspace-order-store-C_t43Zgq.js → workspace-order-store-DTeP4wAO.js} +1 -1
- package/web/index.html +1 -1
- package/web/assets/public-diff-ByaSqbeU.js +0 -1
- package/web/assets/public-events-BZoQRupR.js +0 -1
- package/web/assets/safe-mode-sentinel-BKPGGJEL.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-AM3jlRYR.js";import{C as i,O as a,S as o,g as s,o as c,u as l,y as u}from"./query-DFQayLF5.js";import{r as d,t as f}from"./useQuery-DfOU-27z.js";import{n as p}from"./mutation-b4pPvB7p.js";import{t as m}from"./queryOptions-Dfvzj6n2.js";import{t as h}from"./http-response-scdqC11Q.js";import{n as g}from"./http-CXQuFoDX.js";import{t as _}from"./check-2vYc6QaP.js";import{t as v}from"./copy-DHmIFc52.js";import{t as ee}from"./key-round-C29uZbsf.js";import{t as y}from"./plus-fQbSqB1n.js";import{t as b}from"./refresh-cw-TbWxTY4K.js";import{t as x}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as S}from"./server-BgNvmqwJ.js";import{t as C}from"./trash-2-CNrPOoPR.js";import{t as w}from"./wrench-6pg6_bqI.js";import{t as T}from"./x-07u4-129.js";import{t as E}from"./more-pages-D_PnxLN0.js";import{t as D}from"./switch-D_G8wFhs.js";import{t as O}from"./utils-C8uzG5AZ.js";import{n as k,t as A}from"./button-CCcCN8tE.js";import{s as te}from"./shortcuts-BsrTXPiU.js";import{a as j}from"./format-DMJQzoZ7.js";import{a as M,i as N,l as P,o as F,s as ne,t as re}from"./dialog-BVAtioHy.js";import{t as I}from"./textarea-DmATpOqT.js";import{n as L,t as R}from"./PageState-Cz6vFMXv.js";import{t as z}from"./alert-DRIrgNI4.js";import{a as ie,i as B,n as V,o as ae,r as oe,s as se}from"./FeaturePage-C4fMefC-.js";var ce=class extends a{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),o(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??p();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){c.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},H=e(t(),1);function le(e,t){let n=d(t);return ue({filters:{...e,status:`pending`}},n).length}function U(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function ue(e={},t){let n=d(t).getMutationCache(),r=H.useRef(e),i=H.useRef(null);return i.current===null&&(i.current=U(n,e)),H.useEffect(()=>{r.current=e}),H.useSyncExternalStore(H.useCallback(e=>n.subscribe(()=>{let t=u(i.current,U(n,r.current));i.current!==t&&(i.current=t,c.schedule(e))}),[n]),()=>i.current,()=>i.current)}function de(e,t){let n=d(t),[r]=H.useState(()=>new ce(n,e));H.useEffect(()=>{r.setOptions(e)},[r,e]);let a=H.useSyncExternalStore(H.useCallback(e=>r.subscribe(c.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=H.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(a.error&&i(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function W(e){if(!e||typeof e!=`object`||Array.isArray(e))throw h();return Object.fromEntries(Object.entries(e))}function G(e,t=!1){if(e==null&&!t)return``;if(typeof e!=`string`||t&&!e)throw h();return e}function K(e,t=0){if(e==null)return t;if(typeof e!=`number`||!Number.isFinite(e))throw h();return e}function q(e){if(typeof e!=`boolean`)throw h();return e}function fe(e,t){if(e===void 0)return[];if(!Array.isArray(e))throw h();return e.map(t)}function pe(e){let t=W(e);return{id:G(t.id,!0),name:G(t.name,!0),status:G(t.status),transport:G(t.transport),endpoint:G(t.endpoint),command:G(t.command),workingDirectory:G(t.workingDirectory),enabled:q(t.enabled),error:G(t.error),latencyMs:t.latencyMs==null?null:K(t.latencyMs),lastPingAt:G(t.lastPingAt),auth:G(t.auth),authCount:K(t.authCount)}}function me(e){let t=W(e);return{serviceId:G(t.serviceId,!0),serviceName:G(t.serviceName),name:G(t.name,!0),piName:G(t.piName,!0),description:G(t.description),enabled:q(t.enabled),serviceEnabled:q(t.serviceEnabled),risk:G(t.risk)}}function he(e){let t=W(e);return{id:G(t.id,!0),serviceId:G(t.serviceId,!0),toolName:G(t.toolName),timestamp:G(t.timestamp),status:G(t.status),error:G(t.error),durationMs:K(t.durationMs)}}function J(e){let t=W(e);if(!Array.isArray(t.services))throw h();let n=t.metrics===void 0?{}:W(t.metrics);return{services:t.services.map(pe),tools:fe(t.tools,me),calls:fe(t.calls,he),metrics:{totalServices:K(n.totalServices),onlineServices:K(n.onlineServices),availableTools:K(n.availableTools),restrictedTools:K(n.restrictedTools),errorRate:K(n.errorRate)}}}var Y=e=>`/api/mcp/${encodeURIComponent(e)}`,X={dashboard:e=>g(`/api/mcp?refresh=0`,{signal:e,parse:J}),add:e=>g(`/api/mcp`,{method:`POST`,body:{spec:e},parse:J}),setServerEnabled:(e,t)=>g(Y(e),{method:`PATCH`,body:{enabled:t},parse:J}),setToolEnabled:(e,t,n)=>g(`${Y(e)}/tools/${encodeURIComponent(t)}`,{method:`PATCH`,body:{enabled:n},parse:J}),test:e=>g(`${Y(e)}/test`,{method:`POST`,body:{},parse:J}),remove:async e=>(await g(Y(e),{method:`DELETE`}),X.dashboard())};function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))throw h();return Object.fromEntries(Object.entries(e))}function _e(e){let t=ge(e);if(typeof t.enabled!=`boolean`||typeof t.listening!=`boolean`||typeof t.host!=`string`||typeof t.port!=`number`||!Number.isInteger(t.port)||typeof t.url!=`string`||t.error!==null&&typeof t.error!=`string`)throw h();return{enabled:t.enabled,listening:t.listening,host:t.host,port:t.port,url:t.url,error:t.error}}function ve(e){let t=ge(e);if(typeof t.url!=`string`||!t.url||typeof t.token!=`string`||!t.token)throw h();return{url:t.url,token:t.token}}var Z={status:e=>g(`/api/mcp-host`,{signal:e,parse:_e}),setEnabled:e=>g(`/api/mcp-host`,{method:`PATCH`,body:{enabled:e},parse:_e}),credentials:e=>g(`/api/mcp-host/credentials`,{method:`POST`,body:{},signal:e,parse:ve}),rotateToken:e=>g(`/api/mcp-host/rotate-token`,{method:`POST`,body:{},signal:e,parse:ve})},Q=n(),ye=[`mcp-host`,`status`];function be(e){return JSON.stringify({mcpServers:{pisper:{url:e.url,headers:{Authorization:`Bearer ${e.token}`}}}},null,2)}function xe({notify:e,requestConfirm:t}){let{t:n}=r(),i=d(),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),_=(0,H.useRef)(null),y=(0,H.useRef)(null),x=typeof window<`u`&&!!window.__PISPER_MOBILE_APP__,C=f({queryKey:ye,queryFn:({signal:e})=>Z.status(e),enabled:!x&&!a,refetchInterval:15e3});if((0,H.useEffect)(()=>()=>{_.current?.abort()},[]),x)return null;let w=C.data,T=p?be(p):``,E=()=>{_.current?.abort(),_.current=null,m(null),g(``),u(!1)},te=async()=>{_.current?.abort();let e=new AbortController;_.current=e,c(!0),m(null),g(``),u(!0);try{let t=await Z.credentials(e.signal);e.signal.aborted||m(t)}catch(t){e.signal.aborted||g(t instanceof Error?t.message:n(`mcp:hostLoadFailed`))}finally{_.current===e&&(_.current=null,c(!1))}},j=async t=>{o(!0);try{let r=await Z.setEnabled(t);i.setQueryData(ye,r),t||E(),e(r.error||n(t?`mcp:hostEnabledNotice`:`mcp:hostDisabledNotice`),r.error?`error`:`success`)}catch(t){e(t instanceof Error?t.message:n(`mcp:hostUpdateFailed`),`error`)}finally{o(!1)}},L=async()=>{if(t&&!await t({title:n(`mcp:hostRotateTitle`),message:n(`mcp:hostRotateWarning`),confirmLabel:n(`mcp:hostRotate`),tone:`danger`}))return;_.current?.abort();let r=new AbortController;_.current=r,c(!0),g(``),m(null);try{let t=await Z.rotateToken(r.signal);r.signal.aborted||(m(t),e(n(`mcp:hostRotatedNotice`),`success`))}catch(e){r.signal.aborted||g(e instanceof Error?e.message:n(`mcp:hostRotateFailed`))}finally{_.current===r&&(_.current=null,c(!1))}},R=async()=>{try{await navigator.clipboard.writeText(T),e(n(`mcp:hostCopied`),`success`)}catch{y.current?.select(),e(n(`mcp:hostCopyManually`),`error`)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{className:`mcp-host mt-7`,children:(0,Q.jsx)(B,{"data-mcp-host":!0,icon:(0,Q.jsx)(S,{}),name:n(`mcp:hostTitle`),description:n(`mcp:hostDescription`),status:w&&(0,Q.jsxs)(`span`,{className:O(`flex items-center gap-1.5`,!w.listening&&w.enabled&&`font-medium text-st-attn`),children:[!w.listening&&w.enabled&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),w.listening?n(`mcp:hostReady`):w.enabled?n(`mcp:hostUnavailable`):n(`mcp:disabled`)]}),actions:(0,Q.jsx)(D,{checked:!!w?.enabled,disabled:!w||a,"aria-label":n(`mcp:hostEnabled`),title:n(`mcp:hostEnabled`),onCheckedChange:e=>void j(e)}),detail:C.isPending||C.error||w?.error||w?.listening?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[C.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:n(`mcp:loading`)}),C.error&&(0,Q.jsxs)(z,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:C.error.message}),(0,Q.jsx)(A,{size:`sm`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:()=>void C.refetch(),children:n(`mcp:retry`)})]}),w?.error&&(0,Q.jsx)(z,{role:`status`,className:`text-xs text-muted-foreground`,children:w.error}),w?.listening&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`code`,{className:`max-w-full min-w-0 rounded-xs border border-stroke bg-code px-2 py-0.5 font-mono text-xs break-all text-content`,children:w.url}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void te(),children:[(0,Q.jsx)(ee,{"data-icon":`inline-start`}),n(`mcp:hostShowConfig`)]})]})]}):void 0})}),(0,Q.jsx)(re,{open:l,onOpenChange:e=>!e&&E(),children:(0,Q.jsxs)(N,{className:`min-w-0 grid-cols-[minmax(0,1fr)] sm:max-w-xl`,children:[(0,Q.jsxs)(ne,{className:`min-w-0 pr-8 text-left`,children:[(0,Q.jsx)(P,{children:n(`mcp:hostConfigTitle`)}),(0,Q.jsx)(M,{className:`leading-5`,children:n(`mcp:hostConfigDescription`)})]}),s&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-content-muted`,children:[(0,Q.jsx)(k,{}),n(`mcp:hostLoadingConfig`)]}),h&&(0,Q.jsx)(z,{role:`alert`,className:`text-sm text-muted-foreground`,children:h}),p&&(0,Q.jsx)(I,{ref:y,value:T,readOnly:!0,spellCheck:!1,"aria-label":n(`mcp:hostConfigTitle`),className:`h-52 max-h-[45dvh] resize-y bg-code font-mono text-xs [overflow-wrap:anywhere]`,onFocus:e=>e.currentTarget.select()}),(0,Q.jsxs)(F,{className:`min-w-0 flex-wrap`,children:[(0,Q.jsxs)(A,{variant:`secondary`,disabled:s,onClick:()=>void L(),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),n(`mcp:hostRotate`)]}),(0,Q.jsxs)(A,{disabled:!p||s,onClick:()=>void R(),children:[(0,Q.jsx)(v,{"data-icon":`inline-start`}),n(`mcp:hostCopyConfig`)]})]})]})})]})}var $=[`mcp`,`dashboard`],Se=[`mcp`,`change`];function Ce(){return m({queryKey:$,queryFn:({signal:e})=>X.dashboard(e),staleTime:0,retry:!1})}function we(e){return{mutationKey:Se,scope:{id:`mcp-dashboard`},retry:!1,mutationFn:async t=>(await e.cancelQueries({queryKey:$}),t()),onSuccess:t=>e.setQueryData($,t),onSettled:()=>e.invalidateQueries({queryKey:$})}}function Te(){let e=d(),t=le({mutationKey:Se})>0,n=f({...Ce(),enabled:!t,refetchInterval:!t&&1e4}),r=de(we(e));return{data:n.data,loading:n.isPending,error:r.error||n.error,busy:t,change:r.mutateAsync,reload:()=>(r.reset(),n.refetch())}}var Ee=`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`;function De(e,t){return e===`online`?[t(`mcp:online`),!1]:e===`connecting`?[t(`mcp:connecting`),!1]:e===`unauthorized`?[t(`mcp:unauthorized`),!0]:e===`disabled`?[t(`mcp:disabled`),!1]:[t(`mcp:offline`),!0]}function Oe(e,t){return e===`high`||e===`高风险`?t(`mcp:highRisk`):e===`medium`||e===`中风险`?t(`mcp:mediumRisk`):e===`low`||e===`低风险`?t(`mcp:lowRisk`):String(e||``)}function ke(e,t){return e.auth===`headers`?t(`mcp:countRequestHeaders`,{count:e.authCount}):e.auth===`environment`?t(`mcp:configuredEnvironmentVariables`):e.auth===`local`?t(`mcp:localProcess`):t(`mcp:none`)}function Ae({notify:e,onBack:t,requestText:n,requestConfirm:i}){let{t:a,language:o}=r(),s=te(`focusSearch`),{data:c,busy:l,loading:u,error:d,change:f,reload:p}=Te(),[m,h]=(0,H.useState)(``),[g,v]=(0,H.useState)(``),ee=(0,H.useCallback)(async()=>{let t=await n?.({title:a(`mcp:addMCPService`),message:a(`mcp:enterAStreamableHTTPURLAStdioCommandOrJSONContainingHeadersEnv`),inputLabel:a(`mcp:serverConfiguration`),placeholder:`https://server.example.com/mcp`,maxLength:12e3,confirmLabel:a(`mcp:continue`)});if(t?.trim()&&await i?.({title:a(`mcp:connectMCPServer`),message:a(`mcp:mcpServersCanExposeToolsThatPerformExternalActionsConnectOnlyToServersYouTrust`),confirmLabel:a(`mcp:connect`),tone:`danger`})!==!1)try{let n=await f(()=>X.add(t));v(n.services.at(-1)?.id||``),e(a(`mcp:mcpServerAdded`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},[f,e,i,n,a]),k=m.trim().toLowerCase(),M=c?.services||[],N=M.filter(e=>`${e.name} ${e.endpoint}`.toLowerCase().includes(k)),P=(c?.tools||[]).filter(e=>`${e.name} ${e.serviceName} ${e.description}`.toLowerCase().includes(k)),F=c?.metrics||{totalServices:0,onlineServices:0,availableTools:0,restrictedTools:0,errorRate:0},ne=async(t,n)=>{try{await f(()=>X.setToolEnabled(t.serviceId,t.name,n))}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},re=async(t,n)=>{try{await f(()=>X.setServerEnabled(t.id,n)),e(a(n?`mcp:mcpServerEnabled`:`mcp:mcpServerDisabled`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},I=async t=>{try{await f(()=>X.test(t.id)),e(a(`mcp:mcpConnectionTestPassed`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},ce=async t=>{if(await i?.({title:a(`mcp:deleteMCPServer`),message:a(`mcp:afterDeletionToolsFromThisServerWillBeRemovedFromSubsequentAgentRuns`),confirmLabel:a(`mcp:delete`),tone:`danger`})!==!1)try{await f(()=>X.remove(t.id)),v(``),e(a(`mcp:mcpServerDeleted`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},le=e=>{let t=(c?.calls||[]).filter(t=>t.serviceId===e.id);return(0,Q.jsxs)(`div`,{className:`mcp-service-detail grid gap-3`,children:[(0,Q.jsx)(`p`,{className:O(`text-xs leading-normal [overflow-wrap:anywhere]`,e.error?`font-mono text-content-secondary`:`text-content-muted`),children:e.error||a(`mcp:thisServerExposesToolsThroughAStandardMCPTransportEnabledToolsAreRegisteredInNewAgentRuntimes`)}),(0,Q.jsx)(`dl`,{className:Ee,children:[[a(`mcp:transport`),e.transport===`stdio`?`stdio`:e.transport===`sse`?`HTTP + SSE`:`Streamable HTTP`,!1],...e.transport===`stdio`?[[a(`mcp:executable`),e.command||`—`,!0],[a(`mcp:workingDirectory`),e.workingDirectory||`—`,!0]]:[[a(`mcp:serverAddress`),e.endpoint||`—`,!0]],[a(`mcp:latency`),e.latencyMs==null?`—`:`${e.latencyMs} ms`,!1],[a(`mcp:lastPing`),e.lastPingAt?j(e.lastPingAt,o):`—`,!1],[a(`mcp:authentication`),ke(e,a),!1]].map(([e,t,n])=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:e}),(0,Q.jsx)(`dd`,{className:n?`font-mono`:`tabular-nums`,children:t})]},e))}),(0,Q.jsxs)(`section`,{className:`mcp-calls-panel min-w-0`,"aria-label":a(`mcp:recentCalls`),children:[(0,Q.jsxs)(`h3`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[a(`mcp:recentCalls`),t.length>0&&(0,Q.jsxs)(`span`,{children:[` · `,Math.min(t.length,8)]})]}),t.length?(0,Q.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.slice(0,8).map(e=>{let t=e.status===`ok`;return(0,Q.jsxs)(`li`,{className:O(`activity-row grid min-h-10 min-w-0 grid-cols-[16px_minmax(0,1fr)_auto] items-center gap-2.5 py-1.5`,t?`completed`:`failed`),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 place-items-center text-content-muted [&_svg]:size-3.5 [&_svg]:stroke-[2]`,children:t?(0,Q.jsx)(_,{}):(0,Q.jsx)(T,{})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`strong`,{className:`truncate font-mono text-xs font-medium text-content`,children:e.toolName}),(0,Q.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:t?a(`mcp:callSucceeded`):e.error||a(`mcp:callFailed`)})]}),(0,Q.jsxs)(`span`,{className:`flex flex-col items-end text-xs text-content-muted tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-content-secondary`,children:[e.durationMs,` ms`]}),(0,Q.jsx)(`span`,{children:j(e.timestamp,o)})]})]},e.id)})}):(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 py-1 text-xs text-content-muted`,children:[(0,Q.jsx)(x,{className:`size-3.5`,"aria-hidden":`true`}),a(`mcp:noRecentCalls`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsxs)(A,{size:`sm`,variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:l,onClick:()=>void ce(e),children:[(0,Q.jsx)(C,{"data-icon":`inline-start`}),a(`mcp:delete`)]}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,loading:l,disabled:!e.enabled||l,onClick:()=>void I(e),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),a(`mcp:testConnection`)]})]})]})};return(0,Q.jsxs)(oe,{title:a(`navigation:navigation.mcp`),description:a(`mcp:lede`),back:t&&{label:a(`navigation:sidebar.features`),ariaLabel:a(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,Q.jsx)(se,{search:(0,Q.jsx)(ie,{id:E,value:m,onValueChange:h,placeholder:a(`navigation:pageHeader.searchServicesOrTools`),shortcut:s,clearLabel:a(`navigation:more.clearSearch`)}),actions:(0,Q.jsxs)(A,{type:`button`,className:`h-9`,"data-mcp-add":!0,disabled:l,onClick:()=>void ee(),children:[(0,Q.jsx)(y,{}),a(`navigation:pageHeader.addService`)]})}),children:[(0,Q.jsx)(xe,{notify:e,requestConfirm:i}),u&&!c&&!d?(0,Q.jsx)(L,{kind:`loading`,title:a(`mcp:loading`)}):!c&&d?(0,Q.jsx)(L,{kind:`error`,title:a(`mcp:loadFailed`),description:d.message,action:(0,Q.jsx)(A,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})}):c&&(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsxs)(z,{role:`status`,className:`mt-4 flex min-w-0 items-center justify-between gap-3 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{children:d.message}),(0,Q.jsx)(A,{variant:`ghost`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})]}),(0,Q.jsx)(ae,{className:`mcp-services`,title:a(`mcp:services`),count:N.length,meta:M.length>0&&a(`mcp:serviceSummary`,{online:F.onlineServices,total:F.totalServices,rate:F.errorRate}),children:N.length?(0,Q.jsx)(V,{children:N.map(e=>{let[t,n]=De(e.status,a),r=e.transport===`stdio`?e.workingDirectory||e.command:e.endpoint;return(0,Q.jsx)(B,{className:`service-row`,"data-mcp-service":e.id,icon:(0,Q.jsx)(S,{}),name:e.name,description:(0,Q.jsx)(`span`,{className:`font-mono text-xs`,title:r,children:r}),status:(0,Q.jsxs)(`span`,{"data-mcp-status":e.status||`offline`,className:O(`flex items-center gap-1.5`,n&&`font-medium text-st-attn`),children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),t]}),actions:(0,Q.jsx)(D,{checked:e.enabled,disabled:l,"aria-label":a(`mcp:toggleServiceName`,{name:e.name}),onCheckedChange:t=>void re(e,t)}),expanded:g===e.id,onExpandedChange:t=>v(t?e.id:``),toggleLabel:a(`mcp:toggleServiceDetails`,{name:e.name}),detail:le(e)},e.id)})}):(0,Q.jsx)(R,{icon:S,title:a(`mcp:noServerConfigured`),description:M.length?void 0:a(`mcp:emptyAddHint`)})}),(0,Q.jsx)(ae,{className:`mcp-tools-panel`,title:a(`mcp:toolCapabilities`),count:P.length,meta:F.restrictedTools>0&&a(`mcp:toolSummary`,{count:F.restrictedTools}),children:P.length?(0,Q.jsx)(V,{children:P.map(e=>(0,Q.jsx)(B,{className:`tool-row`,"data-mcp-tool":e.piName,icon:(0,Q.jsx)(w,{}),name:(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),description:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.serviceName}),e.description&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e.description]})]}),status:Oe(e.risk,a),actions:(0,Q.jsx)(D,{checked:!!e.enabled,disabled:l||!e.serviceEnabled,"aria-label":a(`mcp:toggleToolName`,{name:e.name}),onCheckedChange:t=>void ne(e,t)})},e.piName))}):(0,Q.jsx)(R,{compact:!0,icon:w,title:a(`mcp:noToolsAvailable`)})})]})]})}export{Ae as McpPage};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-D6tl7SDi.js";import{C as i,O as a,S as o,g as s,o as c,u as l,y as u}from"./query-DFQayLF5.js";import{r as d,t as f}from"./useQuery-DfOU-27z.js";import{n as p}from"./mutation-b4pPvB7p.js";import{t as m}from"./queryOptions-Dfvzj6n2.js";import{t as h}from"./http-response-C_f1S2cS.js";import{n as g}from"./http-Clt0jbV2.js";import{t as _}from"./check-2vYc6QaP.js";import{t as v}from"./copy-DHmIFc52.js";import{t as ee}from"./key-round-C29uZbsf.js";import{t as y}from"./plus-fQbSqB1n.js";import{t as b}from"./refresh-cw-TbWxTY4K.js";import{t as x}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as S}from"./server-BgNvmqwJ.js";import{t as C}from"./trash-2-CNrPOoPR.js";import{t as w}from"./wrench-6pg6_bqI.js";import{t as T}from"./x-07u4-129.js";import{t as E}from"./more-pages-D_PnxLN0.js";import{t as D}from"./switch-D_G8wFhs.js";import{t as O}from"./utils-C8uzG5AZ.js";import{n as k,t as A}from"./button-CCcCN8tE.js";import{s as te}from"./shortcuts-1-ySiY-G.js";import{a as j}from"./format-DMJQzoZ7.js";import{a as M,i as N,l as P,o as F,s as ne,t as re}from"./dialog-C_ew2HiI.js";import{t as I}from"./textarea-DmATpOqT.js";import{n as L,t as R}from"./PageState-Cz6vFMXv.js";import{t as z}from"./alert-DRIrgNI4.js";import{a as ie,i as B,n as V,o as ae,r as oe,s as se}from"./FeaturePage-CoalHN81.js";var ce=class extends a{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),o(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??p();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){c.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},H=e(t(),1);function le(e,t){let n=d(t);return ue({filters:{...e,status:`pending`}},n).length}function U(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function ue(e={},t){let n=d(t).getMutationCache(),r=H.useRef(e),i=H.useRef(null);return i.current===null&&(i.current=U(n,e)),H.useEffect(()=>{r.current=e}),H.useSyncExternalStore(H.useCallback(e=>n.subscribe(()=>{let t=u(i.current,U(n,r.current));i.current!==t&&(i.current=t,c.schedule(e))}),[n]),()=>i.current,()=>i.current)}function de(e,t){let n=d(t),[r]=H.useState(()=>new ce(n,e));H.useEffect(()=>{r.setOptions(e)},[r,e]);let a=H.useSyncExternalStore(H.useCallback(e=>r.subscribe(c.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=H.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(a.error&&i(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function W(e){if(!e||typeof e!=`object`||Array.isArray(e))throw h();return Object.fromEntries(Object.entries(e))}function G(e,t=!1){if(e==null&&!t)return``;if(typeof e!=`string`||t&&!e)throw h();return e}function K(e,t=0){if(e==null)return t;if(typeof e!=`number`||!Number.isFinite(e))throw h();return e}function q(e){if(typeof e!=`boolean`)throw h();return e}function fe(e,t){if(e===void 0)return[];if(!Array.isArray(e))throw h();return e.map(t)}function pe(e){let t=W(e);return{id:G(t.id,!0),name:G(t.name,!0),status:G(t.status),transport:G(t.transport),endpoint:G(t.endpoint),command:G(t.command),workingDirectory:G(t.workingDirectory),enabled:q(t.enabled),error:G(t.error),latencyMs:t.latencyMs==null?null:K(t.latencyMs),lastPingAt:G(t.lastPingAt),auth:G(t.auth),authCount:K(t.authCount)}}function me(e){let t=W(e);return{serviceId:G(t.serviceId,!0),serviceName:G(t.serviceName),name:G(t.name,!0),piName:G(t.piName,!0),description:G(t.description),enabled:q(t.enabled),serviceEnabled:q(t.serviceEnabled),risk:G(t.risk)}}function he(e){let t=W(e);return{id:G(t.id,!0),serviceId:G(t.serviceId,!0),toolName:G(t.toolName),timestamp:G(t.timestamp),status:G(t.status),error:G(t.error),durationMs:K(t.durationMs)}}function J(e){let t=W(e);if(!Array.isArray(t.services))throw h();let n=t.metrics===void 0?{}:W(t.metrics);return{services:t.services.map(pe),tools:fe(t.tools,me),calls:fe(t.calls,he),metrics:{totalServices:K(n.totalServices),onlineServices:K(n.onlineServices),availableTools:K(n.availableTools),restrictedTools:K(n.restrictedTools),errorRate:K(n.errorRate)}}}var Y=e=>`/api/mcp/${encodeURIComponent(e)}`,X={dashboard:e=>g(`/api/mcp?refresh=0`,{signal:e,parse:J}),add:e=>g(`/api/mcp`,{method:`POST`,body:{spec:e},parse:J}),setServerEnabled:(e,t)=>g(Y(e),{method:`PATCH`,body:{enabled:t},parse:J}),setToolEnabled:(e,t,n)=>g(`${Y(e)}/tools/${encodeURIComponent(t)}`,{method:`PATCH`,body:{enabled:n},parse:J}),test:e=>g(`${Y(e)}/test`,{method:`POST`,body:{},parse:J}),remove:async e=>(await g(Y(e),{method:`DELETE`}),X.dashboard())};function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))throw h();return Object.fromEntries(Object.entries(e))}function _e(e){let t=ge(e);if(typeof t.enabled!=`boolean`||typeof t.listening!=`boolean`||typeof t.host!=`string`||typeof t.port!=`number`||!Number.isInteger(t.port)||typeof t.url!=`string`||t.error!==null&&typeof t.error!=`string`)throw h();return{enabled:t.enabled,listening:t.listening,host:t.host,port:t.port,url:t.url,error:t.error}}function ve(e){let t=ge(e);if(typeof t.url!=`string`||!t.url||typeof t.token!=`string`||!t.token)throw h();return{url:t.url,token:t.token}}var Z={status:e=>g(`/api/mcp-host`,{signal:e,parse:_e}),setEnabled:e=>g(`/api/mcp-host`,{method:`PATCH`,body:{enabled:e},parse:_e}),credentials:e=>g(`/api/mcp-host/credentials`,{method:`POST`,body:{},signal:e,parse:ve}),rotateToken:e=>g(`/api/mcp-host/rotate-token`,{method:`POST`,body:{},signal:e,parse:ve})},Q=n(),ye=[`mcp-host`,`status`];function be(e){return JSON.stringify({mcpServers:{pisper:{url:e.url,headers:{Authorization:`Bearer ${e.token}`}}}},null,2)}function xe({notify:e,requestConfirm:t}){let{t:n}=r(),i=d(),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),_=(0,H.useRef)(null),y=(0,H.useRef)(null),x=typeof window<`u`&&!!window.__PISPER_MOBILE_APP__,C=f({queryKey:ye,queryFn:({signal:e})=>Z.status(e),enabled:!x&&!a,refetchInterval:15e3});if((0,H.useEffect)(()=>()=>{_.current?.abort()},[]),x)return null;let w=C.data,T=p?be(p):``,E=()=>{_.current?.abort(),_.current=null,m(null),g(``),u(!1)},te=async()=>{_.current?.abort();let e=new AbortController;_.current=e,c(!0),m(null),g(``),u(!0);try{let t=await Z.credentials(e.signal);e.signal.aborted||m(t)}catch(t){e.signal.aborted||g(t instanceof Error?t.message:n(`mcp:hostLoadFailed`))}finally{_.current===e&&(_.current=null,c(!1))}},j=async t=>{o(!0);try{let r=await Z.setEnabled(t);i.setQueryData(ye,r),t||E(),e(r.error||n(t?`mcp:hostEnabledNotice`:`mcp:hostDisabledNotice`),r.error?`error`:`success`)}catch(t){e(t instanceof Error?t.message:n(`mcp:hostUpdateFailed`),`error`)}finally{o(!1)}},L=async()=>{if(t&&!await t({title:n(`mcp:hostRotateTitle`),message:n(`mcp:hostRotateWarning`),confirmLabel:n(`mcp:hostRotate`),tone:`danger`}))return;_.current?.abort();let r=new AbortController;_.current=r,c(!0),g(``),m(null);try{let t=await Z.rotateToken(r.signal);r.signal.aborted||(m(t),e(n(`mcp:hostRotatedNotice`),`success`))}catch(e){r.signal.aborted||g(e instanceof Error?e.message:n(`mcp:hostRotateFailed`))}finally{_.current===r&&(_.current=null,c(!1))}},R=async()=>{try{await navigator.clipboard.writeText(T),e(n(`mcp:hostCopied`),`success`)}catch{y.current?.select(),e(n(`mcp:hostCopyManually`),`error`)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{className:`mcp-host mt-7`,children:(0,Q.jsx)(B,{"data-mcp-host":!0,icon:(0,Q.jsx)(S,{}),name:n(`mcp:hostTitle`),description:n(`mcp:hostDescription`),status:w&&(0,Q.jsxs)(`span`,{className:O(`flex items-center gap-1.5`,!w.listening&&w.enabled&&`font-medium text-st-attn`),children:[!w.listening&&w.enabled&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),w.listening?n(`mcp:hostReady`):w.enabled?n(`mcp:hostUnavailable`):n(`mcp:disabled`)]}),actions:(0,Q.jsx)(D,{checked:!!w?.enabled,disabled:!w||a,"aria-label":n(`mcp:hostEnabled`),title:n(`mcp:hostEnabled`),onCheckedChange:e=>void j(e)}),detail:C.isPending||C.error||w?.error||w?.listening?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[C.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:n(`mcp:loading`)}),C.error&&(0,Q.jsxs)(z,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:C.error.message}),(0,Q.jsx)(A,{size:`sm`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:()=>void C.refetch(),children:n(`mcp:retry`)})]}),w?.error&&(0,Q.jsx)(z,{role:`status`,className:`text-xs text-muted-foreground`,children:w.error}),w?.listening&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`code`,{className:`max-w-full min-w-0 rounded-xs border border-stroke bg-code px-2 py-0.5 font-mono text-xs break-all text-content`,children:w.url}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void te(),children:[(0,Q.jsx)(ee,{"data-icon":`inline-start`}),n(`mcp:hostShowConfig`)]})]})]}):void 0})}),(0,Q.jsx)(re,{open:l,onOpenChange:e=>!e&&E(),children:(0,Q.jsxs)(N,{className:`min-w-0 grid-cols-[minmax(0,1fr)] sm:max-w-xl`,children:[(0,Q.jsxs)(ne,{className:`min-w-0 pr-8 text-left`,children:[(0,Q.jsx)(P,{children:n(`mcp:hostConfigTitle`)}),(0,Q.jsx)(M,{className:`leading-5`,children:n(`mcp:hostConfigDescription`)})]}),s&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-content-muted`,children:[(0,Q.jsx)(k,{}),n(`mcp:hostLoadingConfig`)]}),h&&(0,Q.jsx)(z,{role:`alert`,className:`text-sm text-muted-foreground`,children:h}),p&&(0,Q.jsx)(I,{ref:y,value:T,readOnly:!0,spellCheck:!1,"aria-label":n(`mcp:hostConfigTitle`),className:`h-52 max-h-[45dvh] resize-y bg-code font-mono text-xs [overflow-wrap:anywhere]`,onFocus:e=>e.currentTarget.select()}),(0,Q.jsxs)(F,{className:`min-w-0 flex-wrap`,children:[(0,Q.jsxs)(A,{variant:`secondary`,disabled:s,onClick:()=>void L(),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),n(`mcp:hostRotate`)]}),(0,Q.jsxs)(A,{disabled:!p||s,onClick:()=>void R(),children:[(0,Q.jsx)(v,{"data-icon":`inline-start`}),n(`mcp:hostCopyConfig`)]})]})]})})]})}var $=[`mcp`,`dashboard`],Se=[`mcp`,`change`];function Ce(){return m({queryKey:$,queryFn:({signal:e})=>X.dashboard(e),staleTime:0,retry:!1})}function we(e){return{mutationKey:Se,scope:{id:`mcp-dashboard`},retry:!1,mutationFn:async t=>(await e.cancelQueries({queryKey:$}),t()),onSuccess:t=>e.setQueryData($,t),onSettled:()=>e.invalidateQueries({queryKey:$})}}function Te(){let e=d(),t=le({mutationKey:Se})>0,n=f({...Ce(),enabled:!t,refetchInterval:!t&&1e4}),r=de(we(e));return{data:n.data,loading:n.isPending,error:r.error||n.error,busy:t,change:r.mutateAsync,reload:()=>(r.reset(),n.refetch())}}var Ee=`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`;function De(e,t){return e===`online`?[t(`mcp:online`),!1]:e===`connecting`?[t(`mcp:connecting`),!1]:e===`unauthorized`?[t(`mcp:unauthorized`),!0]:e===`disabled`?[t(`mcp:disabled`),!1]:[t(`mcp:offline`),!0]}function Oe(e,t){return e===`high`||e===`高风险`?t(`mcp:highRisk`):e===`medium`||e===`中风险`?t(`mcp:mediumRisk`):e===`low`||e===`低风险`?t(`mcp:lowRisk`):String(e||``)}function ke(e,t){return e.auth===`headers`?t(`mcp:countRequestHeaders`,{count:e.authCount}):e.auth===`environment`?t(`mcp:configuredEnvironmentVariables`):e.auth===`local`?t(`mcp:localProcess`):t(`mcp:none`)}function Ae({notify:e,onBack:t,requestText:n,requestConfirm:i}){let{t:a,language:o}=r(),s=te(`focusSearch`),{data:c,busy:l,loading:u,error:d,change:f,reload:p}=Te(),[m,h]=(0,H.useState)(``),[g,v]=(0,H.useState)(``),ee=(0,H.useCallback)(async()=>{let t=await n?.({title:a(`mcp:addMCPService`),message:a(`mcp:enterAStreamableHTTPURLAStdioCommandOrJSONContainingHeadersEnv`),inputLabel:a(`mcp:serverConfiguration`),placeholder:`https://server.example.com/mcp`,maxLength:12e3,confirmLabel:a(`mcp:continue`)});if(t?.trim()&&await i?.({title:a(`mcp:connectMCPServer`),message:a(`mcp:mcpServersCanExposeToolsThatPerformExternalActionsConnectOnlyToServersYouTrust`),confirmLabel:a(`mcp:connect`),tone:`danger`})!==!1)try{let n=await f(()=>X.add(t));v(n.services.at(-1)?.id||``),e(a(`mcp:mcpServerAdded`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},[f,e,i,n,a]),k=m.trim().toLowerCase(),M=c?.services||[],N=M.filter(e=>`${e.name} ${e.endpoint}`.toLowerCase().includes(k)),P=(c?.tools||[]).filter(e=>`${e.name} ${e.serviceName} ${e.description}`.toLowerCase().includes(k)),F=c?.metrics||{totalServices:0,onlineServices:0,availableTools:0,restrictedTools:0,errorRate:0},ne=async(t,n)=>{try{await f(()=>X.setToolEnabled(t.serviceId,t.name,n))}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},re=async(t,n)=>{try{await f(()=>X.setServerEnabled(t.id,n)),e(a(n?`mcp:mcpServerEnabled`:`mcp:mcpServerDisabled`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},I=async t=>{try{await f(()=>X.test(t.id)),e(a(`mcp:mcpConnectionTestPassed`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},ce=async t=>{if(await i?.({title:a(`mcp:deleteMCPServer`),message:a(`mcp:afterDeletionToolsFromThisServerWillBeRemovedFromSubsequentAgentRuns`),confirmLabel:a(`mcp:delete`),tone:`danger`})!==!1)try{await f(()=>X.remove(t.id)),v(``),e(a(`mcp:mcpServerDeleted`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},le=e=>{let t=(c?.calls||[]).filter(t=>t.serviceId===e.id);return(0,Q.jsxs)(`div`,{className:`mcp-service-detail grid gap-3`,children:[(0,Q.jsx)(`p`,{className:O(`text-xs leading-normal [overflow-wrap:anywhere]`,e.error?`font-mono text-content-secondary`:`text-content-muted`),children:e.error||a(`mcp:thisServerExposesToolsThroughAStandardMCPTransportEnabledToolsAreRegisteredInNewAgentRuntimes`)}),(0,Q.jsx)(`dl`,{className:Ee,children:[[a(`mcp:transport`),e.transport===`stdio`?`stdio`:e.transport===`sse`?`HTTP + SSE`:`Streamable HTTP`,!1],...e.transport===`stdio`?[[a(`mcp:executable`),e.command||`—`,!0],[a(`mcp:workingDirectory`),e.workingDirectory||`—`,!0]]:[[a(`mcp:serverAddress`),e.endpoint||`—`,!0]],[a(`mcp:latency`),e.latencyMs==null?`—`:`${e.latencyMs} ms`,!1],[a(`mcp:lastPing`),e.lastPingAt?j(e.lastPingAt,o):`—`,!1],[a(`mcp:authentication`),ke(e,a),!1]].map(([e,t,n])=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:e}),(0,Q.jsx)(`dd`,{className:n?`font-mono`:`tabular-nums`,children:t})]},e))}),(0,Q.jsxs)(`section`,{className:`mcp-calls-panel min-w-0`,"aria-label":a(`mcp:recentCalls`),children:[(0,Q.jsxs)(`h3`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[a(`mcp:recentCalls`),t.length>0&&(0,Q.jsxs)(`span`,{children:[` · `,Math.min(t.length,8)]})]}),t.length?(0,Q.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.slice(0,8).map(e=>{let t=e.status===`ok`;return(0,Q.jsxs)(`li`,{className:O(`activity-row grid min-h-10 min-w-0 grid-cols-[16px_minmax(0,1fr)_auto] items-center gap-2.5 py-1.5`,t?`completed`:`failed`),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 place-items-center text-content-muted [&_svg]:size-3.5 [&_svg]:stroke-[2]`,children:t?(0,Q.jsx)(_,{}):(0,Q.jsx)(T,{})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`strong`,{className:`truncate font-mono text-xs font-medium text-content`,children:e.toolName}),(0,Q.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:t?a(`mcp:callSucceeded`):e.error||a(`mcp:callFailed`)})]}),(0,Q.jsxs)(`span`,{className:`flex flex-col items-end text-xs text-content-muted tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-content-secondary`,children:[e.durationMs,` ms`]}),(0,Q.jsx)(`span`,{children:j(e.timestamp,o)})]})]},e.id)})}):(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 py-1 text-xs text-content-muted`,children:[(0,Q.jsx)(x,{className:`size-3.5`,"aria-hidden":`true`}),a(`mcp:noRecentCalls`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsxs)(A,{size:`sm`,variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:l,onClick:()=>void ce(e),children:[(0,Q.jsx)(C,{"data-icon":`inline-start`}),a(`mcp:delete`)]}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,loading:l,disabled:!e.enabled||l,onClick:()=>void I(e),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),a(`mcp:testConnection`)]})]})]})};return(0,Q.jsxs)(oe,{title:a(`navigation:navigation.mcp`),description:a(`mcp:lede`),back:t&&{label:a(`navigation:sidebar.features`),ariaLabel:a(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,Q.jsx)(se,{search:(0,Q.jsx)(ie,{id:E,value:m,onValueChange:h,placeholder:a(`navigation:pageHeader.searchServicesOrTools`),shortcut:s,clearLabel:a(`navigation:more.clearSearch`)}),actions:(0,Q.jsxs)(A,{type:`button`,className:`h-9`,"data-mcp-add":!0,disabled:l,onClick:()=>void ee(),children:[(0,Q.jsx)(y,{}),a(`navigation:pageHeader.addService`)]})}),children:[(0,Q.jsx)(xe,{notify:e,requestConfirm:i}),u&&!c&&!d?(0,Q.jsx)(L,{kind:`loading`,title:a(`mcp:loading`)}):!c&&d?(0,Q.jsx)(L,{kind:`error`,title:a(`mcp:loadFailed`),description:d.message,action:(0,Q.jsx)(A,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})}):c&&(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsxs)(z,{role:`status`,className:`mt-4 flex min-w-0 items-center justify-between gap-3 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{children:d.message}),(0,Q.jsx)(A,{variant:`ghost`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})]}),(0,Q.jsx)(ae,{className:`mcp-services`,title:a(`mcp:services`),count:N.length,meta:M.length>0&&a(`mcp:serviceSummary`,{online:F.onlineServices,total:F.totalServices,rate:F.errorRate}),children:N.length?(0,Q.jsx)(V,{children:N.map(e=>{let[t,n]=De(e.status,a),r=e.transport===`stdio`?e.workingDirectory||e.command:e.endpoint;return(0,Q.jsx)(B,{className:`service-row`,"data-mcp-service":e.id,icon:(0,Q.jsx)(S,{}),name:e.name,description:(0,Q.jsx)(`span`,{className:`font-mono text-xs`,title:r,children:r}),status:(0,Q.jsxs)(`span`,{"data-mcp-status":e.status||`offline`,className:O(`flex items-center gap-1.5`,n&&`font-medium text-st-attn`),children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),t]}),actions:(0,Q.jsx)(D,{checked:e.enabled,disabled:l,"aria-label":a(`mcp:toggleServiceName`,{name:e.name}),onCheckedChange:t=>void re(e,t)}),expanded:g===e.id,onExpandedChange:t=>v(t?e.id:``),toggleLabel:a(`mcp:toggleServiceDetails`,{name:e.name}),detail:le(e)},e.id)})}):(0,Q.jsx)(R,{icon:S,title:a(`mcp:noServerConfigured`),description:M.length?void 0:a(`mcp:emptyAddHint`)})}),(0,Q.jsx)(ae,{className:`mcp-tools-panel`,title:a(`mcp:toolCapabilities`),count:P.length,meta:F.restrictedTools>0&&a(`mcp:toolSummary`,{count:F.restrictedTools}),children:P.length?(0,Q.jsx)(V,{children:P.map(e=>(0,Q.jsx)(B,{className:`tool-row`,"data-mcp-tool":e.piName,icon:(0,Q.jsx)(w,{}),name:(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),description:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.serviceName}),e.description&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e.description]})]}),status:Oe(e.risk,a),actions:(0,Q.jsx)(D,{checked:!!e.enabled,disabled:l||!e.serviceEnabled,"aria-label":a(`mcp:toggleToolName`,{name:e.name}),onCheckedChange:t=>void ne(e,t)})},e.piName))}):(0,Q.jsx)(R,{compact:!0,icon:w,title:a(`mcp:noToolsAvailable`)})})]})]})}export{Ae as McpPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-AM3jlRYR.js";import{t as i}from"./createLucideIcon-Cd-3GVxJ.js";import{t as a}from"./info-DATxy0fb.js";import{t as o}from"./pause-CYWpPg1R.js";import{t as s}from"./play-DNDjDNGn.js";import{t as c}from"./x-07u4-129.js";import{i as l,n as u,t as d}from"./popover-BKEwGK6p.js";import{t as f}from"./slider-De8rWVNs.js";import{t as p}from"./segmented-control-xkrEOP_d.js";import{t as m}from"./utils-C8uzG5AZ.js";import{n as h,t as g}from"./button-CCcCN8tE.js";import{n as ee,t as te}from"./PageState-Cz6vFMXv.js";import{t as _}from"./motion-DTR4ZVle.js";import{d as v,l as y}from"./memory-api-BZLLcIF1.js";var ne=i(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),b=e(t(),1);function re(e={}){let{rootMargin:t=`96px 0px`,threshold:n=0}=e,[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(()=>!document.hidden),[s,c]=(0,b.useState)(!0),l=(0,b.useCallback)(e=>{i(e)},[]);return(0,b.useEffect)(()=>{let e=()=>o(!document.hidden);return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),(0,b.useEffect)(()=>{if(!r||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(([e])=>{e&&c(e.isIntersecting)},{rootMargin:t,threshold:n});return e.observe(r),()=>e.disconnect()},[r,t,n]),{ref:l,playing:a&&s}}var x=864e5,S=Math.PI*2,C=.055,ie=.85,w=1e3,T=.72,E=2.6,ae=1.75,oe=30,se=1.1,D=.34,ce=6e3,le=[`decision`,`preference`,`fact`,`concept`,`risk`,`file`,`task`];function O(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var ue=e=>O(e)/4294967296,k=e=>Math.min(1,Math.max(0,e));function A(e,t){let n=Date.parse(String(e||``));return Number.isNaN(n)?t:n}function de(e,t){let n=Math.max(1,e.end-e.start);return C+.945*k((t-e.start)/n)**ie}function fe(e,t){return t*(1+.046*(.62*Math.sin(3*e+1.1+1.9*t)+.28*Math.sin(5*e+4.2-2.7*t)+.1*Math.sin(11*e+2.3+5.1*t))*Math.min(1,t*2.2))}var j=.042,pe=-.03;function M(e,t){return fe(e,t)*Math.cos(e)+j*(1-t)}function N(e,t){return fe(e,t)*Math.sin(e)+pe*(1-t)}function me(e){let t=(e.end-e.start)/x;return t<=21?`day`:t<=120?`week`:t<=1e3?`month`:t<=3e3?`quarter`:`year`}function he(e,t){let n=new Date(e);if(t===`day`)return new Date(n.getFullYear(),n.getMonth(),n.getDate()+1);if(t===`week`){let e=(8-n.getDay())%7||7;return new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)}return t===`month`?new Date(n.getFullYear(),n.getMonth()+1,1):t===`quarter`?new Date(n.getFullYear(),Math.floor(n.getMonth()/3)*3+3,1):new Date(n.getFullYear()+1,0,1)}function ge(e,t){return t===`day`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+1):t===`week`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+7):t===`month`?new Date(e.getFullYear(),e.getMonth()+1,1):t===`quarter`?new Date(e.getFullYear(),e.getMonth()+3,1):new Date(e.getFullYear()+1,0,1)}function _e(e,t){return t===`day`?e.getDay()===1:t===`week`?e.getDate()<=7:t===`month`?e.getMonth()%3==0:t!==`quarter`||e.getMonth()===0}function ve(e,t,n){let r=[],i=he(e.start,t);for(;i.getTime()<e.end&&r.length<400;)r.push(i),i=ge(i,t);let a=Array(r.length).fill(0);for(let e of n){let t=0,n=r.length;for(;t<n;){let i=t+n>>1;r[i].getTime()<e?t=i+1:n=i}t<a.length&&(a[t]+=1)}let o=Math.max(1,...a);return r.map((n,r)=>{let i=n.getTime();return{at:i,rho:de(e,i),major:_e(n,t),activity:a[r]/o}})}var ye=new Set([`project`,`projects`,`user`,`users`,`global`,`repo`,`app`,`pisper`,`general`,`misc`,`title`]);function be(e){let t=String(e||``).split(`.`).filter(Boolean);for(;t.length>1&&ye.has(t[0]);)t.shift();return t[0]||``}function P(e,t){let n=A(e.createdAt,t),r=A(e.validFrom,n);return{created:n,valid:r,appear:Math.max(n,r)}}function xe(e,t){if(!e.length)return{start:t-180*x,end:t};let n=1/0,r=t;for(let i of e){let{valid:e,appear:a}=P(i,t);n=Math.min(n,e,a),a<=t&&(r=Math.max(r,a))}let i=Math.max(x,r-n);return{start:Math.min(n-Math.max(i*.02,x/4),r-7*x),end:r}}function Se(e){let t=new Map,n=e.map(e=>be(e.topicKey));e.forEach((e,r)=>{let i=`${e.spaceId}\u0000${n[r]}`,a=t.get(i);a?a.push(r):t.set(i,[r])});let r=Math.max(2,Math.ceil(e.length*.012)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])},o=new Map,s=new Map,c=[...t.entries()].sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0]));for(let[t,n]of c){let[i,c]=t.split(`\0`),l=s.get(i)||0;if(c&&n.length>=r&&l<16){s.set(i,l+1),a(i,{key:t,label:c,kind:`topic`,spaceId:i,members:n});continue}for(let t of n){let n=`${i}\u0000type:${e[t].type}`,r=o.get(n);r?r.push(t):o.set(n,[t])}}for(let[e,t]of o){let[n,r]=e.split(`\0`);a(n,{key:e,label:r.slice(5),kind:`type`,spaceId:n,members:t})}return i}function Ce(e,t,n){let r=Se(e),i=[...r.keys()].sort((e,t)=>e===`global`?-1:t===`global`?1:O(e)-O(t)),a=[],o=new Int16Array(e.length),s=new Float32Array(e.length),c=[],l=i.length>1?.09:0,u=i.reduce((e,t)=>e+(r.get(t)?.length||0),0),d=Math.min(.022,S*.25/Math.max(1,u)),f=e=>(r.get(e)||[]).reduce((e,t)=>e+Math.sqrt(t.members.length)+.6,0),p=i.reduce((e,t)=>e+f(t),0)||1,m=S-l*i.length-d*u,h=-Math.PI/2+l/2;for(let u of i){let i=[...r.get(u)||[]].sort((e,t)=>O(e.key)-O(t.key)),f=h;for(let n of i){let r=m*(Math.sqrt(n.members.length)+.6)/p,i=a.length;a.push({key:n.key.split(`\0`)[1],label:n.label,kind:n.kind,spaceId:u,start:h,end:h+r,count:n.members.length});let c=[...n.members].sort((n,r)=>t[n]-t[r]||e[n].id.localeCompare(e[r].id)),l=ue(n.key);c.forEach((e,t)=>{o[e]=i;let n=(l+t*.61803398875)%1;s[e]=h+r*(.05+.9*n)}),h+=r+d}c.push({spaceId:u,name:n.find(e=>e.id===u)?.name||u,start:f,end:h-d}),h+=l}return{sectors:a,sectorOf:o,theta:s,spaceArcs:i.length>1?c:[]}}function we(e){return Float64Array.from(e).sort()}function Te(e,{histogramBins:t=160}={}){let n=A(e.now,Date.now()),r=[...e.facts].sort((e,t)=>e.id.localeCompare(t.id)),i=r.length,a=xe(r,n),o=a.end-a.start,s=Math.max(x,o*.015),c=new Map(r.map((e,t)=>[e.id,t])),l=new Float64Array(i),u=new Float64Array(i),d=new Float64Array(i).fill(1/0),f=new Float64Array(i).fill(1/0),p=new Int32Array(i).fill(-1),m=new Uint8Array(i),h=new Uint8Array(i),g=new Map;r.forEach((e,t)=>{let{created:r,valid:i,appear:a}=P(e,n);l[t]=i,u[t]=a;let o=le.indexOf(e.type);h[t]=o>=0?o:le.indexOf(`concept`);let d=0;e.pinned&&(d|=1),e.tainted&&(d|=2),e.status===`stale`&&(d|=8),r-i>s&&(d|=4),m[t]=d;let f=e.supersededBy?c.get(e.supersededBy):void 0;if(f!==void 0&&f!==t){p[t]=f;let e=g.get(f);e?e.push(t):g.set(f,[t])}}),r.forEach((e,t)=>{let n=A(e.supersededAt,NaN)||A(e.validTo,NaN)||(e.status===`superseded`?p[t]>=0?u[p[t]]:a.end:NaN);Number.isFinite(n)&&(d[t]=Math.max(n,u[t]));let r=A(e.archivedAt,NaN)||(e.status===`archived`?a.end:NaN);Number.isFinite(r)&&(f[t]=Math.max(r,u[t]))});let{sectors:ee,sectorOf:te,theta:_,spaceArcs:v}=Ce(r,u,e.spaces),y=new Float32Array(i),ne=new Float32Array(i),b=new Float32Array(i),re=new Float32Array(i),C=new Float32Array(i),ie=new Float32Array(i),w=new Float32Array(i);r.forEach((e,t)=>{y[t]=de(a,l[t]),ne[t]=M(_[t],y[t]),b[t]=N(_[t],y[t]);let n=k(Number(e.importance)||0),r=k((Number(e.authority)||0)/100);C[t]=.16+.84*n**1.5,ie[t]=(.4+.22*r+.38*n)*(e.tainted?.6:1),re[t]=.016+.105*n**1.5+(e.pinned?.03:0),w[t]=ue(e.id)*S});let T=[];r.forEach((e,t)=>{Number.isFinite(d[t])&&T.push({at:d[t],from:t,to:p[t]})}),T.sort((e,t)=>e.at-t.at||e.from-t.from);let E=Math.max(1,t),ae=new Uint16Array(E),oe=new Uint16Array(E),se=e=>Math.min(E-1,Math.floor(k((e-a.start)/o)*E));for(let e=0;e<i;e+=1)u[e]<=a.end&&(ae[se(u[e])]+=1);for(let e of T)e.at<=a.end&&(oe[se(e.at)]+=1);let D=[...u],ce=[],O=[];for(let e=0;e<i;e+=1){let t=Math.min(d[e],f[e]);Number.isFinite(t)&&ce.push(t),Number.isFinite(f[e])&&O.push(f[e])}let fe=e.digests.map(e=>{let t=A(e.windowEnd,a.end),n=A(e.windowStart,t),r=v.find(t=>t.spaceId===e.spaceId),i=r?.start??-Math.PI,o=(r?.end??Math.PI)-i,s=o*(e.level===`month`?.16:e.level===`week`?.085:.045),c=i+ue(e.id)*Math.max(0,o-s);return{id:e.id,level:e.level,at:t,rho:de(a,(n+t)/2),start:c,end:c+s}}),j=me(a);return{facts:r,count:i,indexById:c,domain:a,unit:j,rings:ve(a,j,D),bornWindow:Math.max(o*.012,1),validAt:l,appearAt:u,replacedAt:d,archivedAt:f,theta:_,rho:y,x:ne,y:b,lift:re,size:C,brightness:ie,phase:w,typeIndex:h,sector:te,flags:m,successor:p,predecessors:g,replacements:T,sectors:ee,spaceArcs:v,digests:fe,histogram:ae,histogramReplacements:oe,truncated:!!e.truncated,sortedAppear:we(D),sortedEnded:we(ce),sortedArchived:we(O)}}function Ee(e,t,n){return n<e.appearAt[t]?0:n>=e.archivedAt[t]?3:n>=e.replacedAt[t]?2:1}function De(e,t,n,r=e.bornWindow){let i=Ee(e,t,n);return i===0?`hidden`:i===3?`archived`:i===2?`superseded`:n-e.appearAt[t]<r?`born`:`active`}function Oe(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<=t?n=i+1:r=i}return n}function ke(e,t){let n=Oe(e.sortedAppear,t),r=Oe(e.sortedEnded,t),i=Oe(e.sortedArchived,t);return{active:n-r,superseded:r-i,archived:i,known:n}}function Ae(e,t){let n=new Set([t]),r=[],i=[t];for(;i.length;)for(let t of e.predecessors.get(i.pop())||[])n.has(t)||(n.add(t),r.push(t),i.push(t));let a=[],o=e.successor[t];for(;o>=0&&!n.has(o);)n.add(o),a.push(o),o=e.successor[o];return[...r,t,...a].sort((t,n)=>e.appearAt[t]-e.appearAt[n]||t-n)}function je(e){return Math.min(E,Math.max(T,e))}function Me(e,t){return e<720&&t>=oe?ae:1}function Ne(e){let t=k((e-1)/.5);return t*t*(3-2*t)}function Pe(e,t){return Math.max(1,e/t)*se}function F(e,t){let n=k(e/Math.max(t,.001));return D+.6599999999999999*n*n*(3-2*n)}function Fe(e,t,n){return je(e*n/Math.max(1,t))}function Ie(e,t){return e.start+(e.end-e.start)*k(t/w)}function Le(e,t){let n=Math.max(1,e.end-e.start);return Math.round(k((t-e.start)/n)*w)}function Re(e,t=ce){let n=k(e/t);return n<.5?4*n*n*n:1-(-2*n+2)**3/2}var I=Math.PI*2,ze=144,L=72,Be=.2,R=96,z=620,B=55e5,Ve=[{inner:.965,alpha:.05},{inner:.9,alpha:.032},{inner:.78,alpha:.018}],V=.0012,He=.6,Ue={decision:[255,196,92],preference:[186,164,255],fact:[176,214,255],concept:[104,176,255],risk:[255,104,158],file:[92,226,176],task:[92,222,240]},H=[255,96,44],U=[96,118,164],We=[156,164,178],W=[236,208,164],Ge=[255,232,192],Ke=[255,176,104],qe=[255,236,204],G=[255,206,138],K=[255,222,180],Je=[176,202,255],q=([e,t,n],r=1)=>`rgba(${e}, ${t}, ${n}, ${r})`;function J(e,t,n){let r=Math.min(1,Math.max(0,(e-t)/(n-t)));return r*r*(3-2*r)}function Y(e,t){let n=document.createElement(`canvas`);return n.width=Math.max(1,Math.round(e)),n.height=Math.max(1,Math.round(t)),n}function Ye([e,t,n]){let r=Y(R,R),i=r.getContext(`2d`);if(!i)return r;let a=R/2,o=i.createRadialGradient(a,a,0,a,a,a),s=r=>[255+(e-255)*r,255+(t-255)*r,255+(n-255)*r],c=(e,t)=>{let[n,r,i]=s(e);return`rgba(${n|0}, ${r|0}, ${i|0}, ${t})`};return o.addColorStop(0,c(.12,1)),o.addColorStop(.08,c(.5,.96)),o.addColorStop(.16,c(1,.62)),o.addColorStop(.3,c(1,.22)),o.addColorStop(.56,c(1,.06)),o.addColorStop(1,c(1,0)),i.fillStyle=o,i.fillRect(0,0,R,R),r}function Xe([e,t,n]){let r=Y(R,R),i=r.getContext(`2d`);if(!i)return r;let a=R/2,o=i.createRadialGradient(a,a,0,a,a,a);return o.addColorStop(0,`rgba(${e}, ${t}, ${n}, 0.55)`),o.addColorStop(.35,`rgba(${e}, ${t}, ${n}, 0.16)`),o.addColorStop(.7,`rgba(${e}, ${t}, ${n}, 0.035)`),o.addColorStop(1,`rgba(${e}, ${t}, ${n}, 0)`),i.fillStyle=o,i.fillRect(0,0,R,R),r}var Ze=class{canvas;ctx;camera={yaw:0,tilt:.92,zoom:1,rim:0};quality;scene=null;width=1;height=1;dpr=1;maxDpr=2;insets={top:0,right:0,bottom:0,left:0};targetInsets={top:0,right:0,bottom:0,left:0};typeSprites;emberSprite;archiveSprite;untrustedSprite;pulseSprite;coreSprite;discSprite;pinnedHalo;background=null;bloomA=null;bloomB=null;ringPaths=[];grainPaths=[];frontierPath=new Float32Array(288);rimPath=new Float32Array(288);bandPaths=Ve.map(()=>new Float32Array(288));screenX=new Float32Array;screenY=new Float32Array;screenR=new Float32Array;liftNow=new Float32Array;worldX=new Float32Array;worldY=new Float32Array;morphX=null;morphY=null;morphStart=0;slowWindows=0;chainMask=new Uint8Array;ringLabels=[];sectorOrder=[];selected=-1;selectedSector=-1;hovered=-1;ringFormatter=()=>``;dust;rippleQueue=new Int32Array(48);lateQueue=new Int32Array(24);typeCss;ambientPulses=[];nextAmbientPulse=0;frameTimes=0;frameCount=0;px=0;py=0;ps=1;cx=0;cy=0;unit=1;cosYaw=1;sinYaw=0;cosTilt=1;sinTilt=0;constructor(e,{quality:t=3}={}){this.canvas=e;let n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`canvas 2d unavailable`);this.ctx=n,this.quality=t,this.typeSprites=le.map(e=>Ye(Ue[e])),this.typeCss=le.map(e=>q(Ue[e])),this.emberSprite=Ye(H),this.archiveSprite=Ye(U),this.untrustedSprite=Ye(We),this.pulseSprite=Ye(qe),this.coreSprite=Xe(G),this.discSprite=Xe([206,158,104]),this.pinnedHalo=Xe(Ge),this.dust=new Float32Array(1e3);let r=20261105,i=()=>(r=Math.imul(r,1664525)+1013904223>>>0,r/4294967296);for(let e=0;e<200;e+=1){let t=i()*I,n=.08+Math.sqrt(i())*1.42;this.dust[e*5]=Math.cos(t)*n,this.dust[e*5+1]=Math.sin(t)*n,this.dust[e*5+2]=(i()-.35)*.42,this.dust[e*5+3]=i()*I,this.dust[e*5+4]=.15+i()*.55}}setRingFormatter(e){this.ringFormatter=e,this.refreshLabels()}setScene(e,{animate:t=!1,now:n=0}={}){let r=this.scene,i=this.worldX,a=this.worldY;if(this.scene=e,this.ambientPulses=[],this.morphX=null,this.morphY=null,!e)return!1;let o=!1;if(t&&r&&r.count&&e.count){let t=Float32Array.from(e.x),s=Float32Array.from(e.y),c=0;e.facts.forEach((e,n)=>{let o=r.indexById.get(e.id);o!==void 0&&(t[n]=i[o],s[n]=a[o],c+=1)}),c>=Math.max(1,e.count*.3)&&(this.morphX=t,this.morphY=s,this.morphStart=n,o=!0)}return this.worldX=Float32Array.from(this.morphX??e.x),this.worldY=Float32Array.from(this.morphY??e.y),this.screenX=new Float32Array(e.count),this.screenY=new Float32Array(e.count),this.screenR=new Float32Array(e.count),this.liftNow=new Float32Array(e.count),this.chainMask=new Uint8Array(e.count),this.ringPaths=e.rings.map(e=>{let t=new Float32Array(288);return this.fillRingPath(t,e.rho),t}),this.fillRingPath(this.rimPath,1),this.grainPaths=this.buildGrain(),this.sectorOrder=e.sectors.map((e,t)=>({sector:e,index:t})).filter(({sector:e})=>e.kind===`topic`).sort((e,t)=>t.sector.count-e.sector.count).slice(0,10).map(e=>e.index),this.refreshLabels(),this.setSelection(this.selected<e.count?this.selected:-1),this.hovered=-1,o}buildGrain(){let e=[],t=7;for(let n=.07;n<1;n+=.0115){t=Math.imul(t,1664525)+1013904223>>>0;let r=((t>>>8)/16777216-.5)*.006,i=new Float32Array(144);for(let e=0;e<L;e+=1){let t=e/L*I;i[e*2]=M(t,n+r),i[e*2+1]=N(t,n+r)}e.push({rho:n+r,path:i})}return e}refreshLabels(){this.ringLabels=this.scene?this.scene.rings.map(e=>this.ringFormatter(e.at)):[]}setSelection(e){let{scene:t}=this;if(this.selected=e,this.chainMask.fill(0),this.selectedSector=-1,!t||e<0||e>=t.count){this.selected=-1;return}for(let n of Ae(t,e))this.chainMask[n]=1;this.selectedSector=t.sector[e]}setHover(e){this.hovered=e}resize(e,t,n){let r=Math.max(1,e),i=Math.max(1,t);(r!==this.width||i!==this.height||n!==this.maxDpr)&&(this.width=r,this.height=i,this.maxDpr=n,this.applyResolution())}setInsets(e,{animate:t=!1}={}){this.targetInsets=e,t||(this.insets=e)}get settling(){let{insets:e,targetInsets:t}=this;return e.top!==t.top||e.right!==t.right||e.bottom!==t.bottom||e.left!==t.left}stepInsets(){let e=(e,t)=>Math.abs(t-e)<.5?t:e+(t-e)*.14,{insets:t,targetInsets:n}=this;this.settling&&(this.insets={top:e(t.top,n.top),right:e(t.right,n.right),bottom:e(t.bottom,n.bottom),left:e(t.left,n.left)})}applyResolution(){let e=typeof devicePixelRatio==`number`?devicePixelRatio:1,t=this.quality===1?1:this.maxDpr,n=Math.sqrt(B/(this.width*this.height));this.dpr=Math.max(1,Math.min(e||1,t,n)),this.canvas.width=Math.max(1,Math.round(this.width*this.dpr)),this.canvas.height=Math.max(1,Math.round(this.height*this.dpr)),this.background=this.paintBackground(),this.bloomA=Y(this.canvas.width/4,this.canvas.height/4),this.bloomB=Y(this.canvas.width/10,this.canvas.height/10)}noteFrameInterval(e){if(this.frameTimes+=e,this.frameCount+=1,this.frameCount<45)return;let t=this.frameTimes/this.frameCount;this.frameTimes=0,this.frameCount=0,this.slowWindows=t>30?this.slowWindows+1:0,this.slowWindows>=2&&this.quality>1&&(this.slowWindows=0,--this.quality,this.applyResolution())}paintBackground(){let e=Y(Math.min(1024,this.width),Math.min(1024,this.height)),t=e.getContext(`2d`);if(!t)return e;let{width:n,height:r}=e;t.fillStyle=`#05060a`,t.fillRect(0,0,n,r);let i=this.layoutCenter(),a=t.createRadialGradient(i.x/this.width*n,i.y/this.height*r,0,i.x/this.width*n,i.y/this.height*r,Math.max(n,r)*.72);return a.addColorStop(0,`rgba(30, 27, 32, 0.8)`),a.addColorStop(.42,`rgba(10, 13, 22, 0.7)`),a.addColorStop(1,`rgba(3, 4, 8, 0)`),t.fillStyle=a,t.fillRect(0,0,n,r),e}layoutCenter(){let{top:e,bottom:t,left:n,right:r}=this.insets;return{x:n+(this.width-n-r)/2,y:e+(this.height-e-t)/2}}fillRingPath(e,t){for(let n=0;n<ze;n+=1){let r=n/ze*I;e[n*2]=M(r,t),e[n*2+1]=N(r,t)}}project(e,t,n){let r=e*this.cosYaw-t*this.sinYaw,i=e*this.sinYaw+t*this.cosYaw,a=1/(1-Be*(i*this.sinTilt+n*this.cosTilt));this.px=this.cx+this.unit*r*a,this.py=this.cy+this.unit*(i*this.cosTilt-n*this.sinTilt)*a,this.ps=a}traceRing(e){let{ctx:t}=this;for(let n=0;n<ze;n+=1)this.project(e[n*2],e[n*2+1],0),n===0?t.moveTo(this.px,this.py):t.lineTo(this.px,this.py);t.closePath()}applyCamera(e){let{camera:t}=this;this.stepInsets(),this.cosYaw=Math.cos(t.yaw),this.sinYaw=Math.sin(t.yaw),this.cosTilt=Math.cos(t.tilt),this.sinTilt=Math.sin(t.tilt);let{top:n,bottom:r,left:i,right:a}=this.insets,o=Math.max(40,this.width-i-a),s=Math.max(40,this.height-n-r),c=this.layoutCenter(),l=1+Be*this.sinTilt*.55,u=Math.min(o/(2.08*l),s/(2.08*Math.max(this.cosTilt,.34)*l+.14*this.sinTilt)),d=1+.72*(1-e)**2;this.unit=u*t.zoom*d,this.cx=c.x,this.cy=c.y+this.sinTilt*this.unit*.02;let f=J(e,.35,.75),p=t.rim*f;if(p>0){let t=this.unit*e*this.cosTilt/(1-Be*e*this.sinTilt),r=n+s*.94-t;this.cy+=(Math.min(this.cy,r)-this.cy)*p}}pick(e,t,n,r){let{scene:i}=this;if(!i)return-1;let a=-1,o=n*n;for(let n=0;n<i.count;n+=1){let s=this.screenX[n];if(Number.isNaN(s))continue;let c=s-e,l=this.screenY[n]-t,u=c*c+l*l;(r>=i.replacedAt[n]||r>=i.archivedAt[n])&&(u*=1.8),u<o&&(o=u,a=n)}return a}screenPosition(e){let t=this.screenX[e];return t===void 0||Number.isNaN(t)?null:{x:t,y:this.screenY[e]}}draw(e){let{ctx:t,scene:n,dpr:r}=this;t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,this.background?t.drawImage(this.background,0,0,this.width,this.height):(t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height));let i=n?de(n.domain,e.at):1;this.applyCamera(i),t.globalCompositeOperation=`lighter`,t.lineCap=`round`,t.lineJoin=`round`,this.drawDust(e),n&&(this.stepMorph(n,e),this.drawDiscBody(n,e,i),this.drawNewestBand(e,i),this.drawDigests(n,e,i),this.computePositions(n,e),this.drawThreads(n,e,i),this.drawStems(n,e,i),this.drawFacts(n,e,i),this.drawPulses(n,e),this.drawFrontier(e,i)),this.applyBloom(),t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,n&&this.drawLabels(n,e,i),e.fade<1&&(t.globalAlpha=1-e.fade,t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height),t.globalAlpha=1)}stepMorph(e,t){let{morphX:n,morphY:r}=this;if(!n||!r)return;let i=Math.min(1,Math.max(0,(t.wall-this.morphStart)/z)),a=i*i*(3-2*i);for(let t=0;t<e.count;t+=1)this.worldX[t]=n[t]+(e.x[t]-n[t])*a,this.worldY[t]=r[t]+(e.y[t]-r[t])*a;i>=1&&(this.morphX=null,this.morphY=null)}get morphing(){return this.morphX!==null}drawDust(e){let{ctx:t,dust:n}=this,r=this.quality===3?200:this.quality===2?110:40,i=e.ambient?e.wall*12e-6:0;for(let a=0;a<r;a+=1){let r=a*5,o=.55+a%7*.05,s=Math.cos(i*o),c=Math.sin(i*o),l=n[r]*s-n[r+1]*c,u=n[r]*c+n[r+1]*s;if(this.project(l,u,n[r+2]),this.px<-4||this.py<-4||this.px>this.width+4||this.py>this.height+4)continue;let d=e.ambient?.55+.45*Math.sin(e.wall*7e-4+n[r+3]):.7,f=(.7+n[r+4]*1.1)*this.ps;t.globalAlpha=n[r+4]*d*.5,t.fillStyle=q(a%3==0?Je:K),t.fillRect(this.px-f/2,this.py-f/2,f,f)}t.globalAlpha=1}drawDiscBody(e,t,n){let{ctx:r}=this,i=this.selected>=0?.55:1;this.project(M(0,0),N(0,0),0);let a=this.px,o=this.py,s=1-.72*J(n,.2,.7),c=this.unit*Math.max(n,.1)*1.32;if(r.globalAlpha=.5*s*i,r.drawImage(this.discSprite,this.cx-c,this.cy-c*this.cosTilt,c*2,c*2*this.cosTilt),n<.995&&(r.beginPath(),this.traceRing(this.rimPath),r.globalAlpha=.06,r.strokeStyle=q(W),r.lineWidth=.8,r.stroke()),this.quality>=2){let e=this.quality===3?1:2;r.strokeStyle=q(W),r.lineWidth=.5;let t=n*He;for(let a of[!1,!0]){r.globalAlpha=(a?.075:.03)*e*i,r.beginPath();for(let i=0;i<this.grainPaths.length;i+=e){let{rho:e,path:o}=this.grainPaths[i];if(e>n)break;if(e>=t===a){for(let e=0;e<L;e+=1)this.project(o[e*2],o[e*2+1],0),e===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py);r.closePath()}}r.stroke()}}let{rings:l}=e,u=-1;for(let e=0;e<l.length&&!(l[e].at>t.at);e+=1)u=e;r.fillStyle=q(W);for(let e=0;e<=u;e+=2){let t=l[e];r.beginPath(),this.traceRing(this.ringPaths[e]),e>0&&this.traceRing(this.ringPaths[e-1]),r.globalAlpha=(.012+.03*t.activity)*i*F(t.rho,n),r.fill(`evenodd`)}r.strokeStyle=q(W);for(let e=0;e<=u;e+=1){let t=l[e];r.beginPath(),this.traceRing(this.ringPaths[e]),r.globalAlpha=(.11+.17*t.activity+(t.major?.13:0))*i*F(t.rho,n),r.lineWidth=t.major?1:.65,r.stroke()}let d=this.knownCount(e,t.at),f=t.ambient?1+.08*Math.sin(t.wall*.0011):1,p=this.unit*(.17+.028*Math.log1p(d))*f;r.globalAlpha=.62*s*i,r.drawImage(this.coreSprite,a-p,o-p,p*2,p*2),r.globalAlpha=1}drawNewestBand(e,t){let{ctx:n}=this,r=(e.ambient?.82+.18*Math.sin(e.wall*V):.9)*(e.moving?1.2:1)*(this.selected>=0?.35:1),i=this.quality===1?1:Ve.length;n.fillStyle=q(W),this.fillRingPath(this.frontierPath,t);for(let e=0;e<i;e+=1){let{inner:i,alpha:a}=Ve[e],o=this.bandPaths[e];this.fillRingPath(o,t*i),n.beginPath(),this.traceRing(this.frontierPath),this.traceRing(o),n.globalAlpha=a*r,n.fill(`evenodd`)}n.globalAlpha=1}knownCount(e,t){let n=0,r=e.sortedAppear.length;for(;n<r;){let i=n+r>>1;e.sortedAppear[i]<=t?n=i+1:r=i}return n}drawDigests(e,t,n){let{ctx:r}=this;if(!e.digests.length)return;r.strokeStyle=q(Ge),r.lineWidth=1.25;let i=n*He;for(let n of[!1,!0]){r.globalAlpha=this.selected>=0?.1:n?.34:.14,r.beginPath();for(let a of e.digests){if(a.at>t.at||a.rho>=i!==n)continue;let e=Math.max(4,Math.ceil((a.end-a.start)/I*ze));for(let t=0;t<=e;t+=1){let n=a.start+(a.end-a.start)*t/e;this.project(M(n,a.rho),N(n,a.rho),0),t===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py)}}r.stroke()}r.globalAlpha=1}computePositions(e,t){let{at:n,effectWindow:r}=t,{appearAt:i,replacedAt:a,archivedAt:o,lift:s,count:c}=e,{worldX:l,worldY:u}=this;for(let e=0;e<c;e+=1){if(n<i[e]){this.screenX[e]=NaN;continue}let t=s[e],c=Math.min(a[e],o[e]);if(n>=c){let i=Math.min(1,(n-c)/(r*1.6)),a=i*i*(3-2*i);t=n>=o[e]?s[e]*(1-a)-.035*a:s[e]*(1-a)}this.liftNow[e]=t,this.project(l[e],u[e],t),this.screenX[e]=this.px,this.screenY[e]=this.py,this.screenR[e]=this.ps}}threadControl(e,t){let n=this.worldX[e],r=this.worldY[e],i=this.worldX[t],a=this.worldY[t],o=i-n,s=a-r,c=Math.sqrt(o*o+s*s);this.project((n+i)/2,(r+a)/2,(this.liftNow[e]+this.liftNow[t])/2+.018+c*.46)}drawThreads(e,t,n){let{ctx:r,selected:i,chainMask:a}=this,{at:o}=t;r.strokeStyle=q(Ke),r.lineWidth=.95;let s=n*He;for(let t of[!1,!0]){r.globalAlpha=i>=0?.06:t?.42:.16,r.beginPath();for(let n of e.replacements){if(n.at>o)break;n.to<0||o<e.appearAt[n.to]||i>=0&&a[n.from]&&a[n.to]||e.rho[n.to]>=s===t&&(this.threadControl(n.from,n.to),r.moveTo(this.screenX[n.from],this.screenY[n.from]),r.quadraticCurveTo(this.px,this.py,this.screenX[n.to],this.screenY[n.to]))}r.stroke()}if(i>=0){r.strokeStyle=q(Ge),r.lineWidth=1.5,r.globalAlpha=.8,r.beginPath();for(let t of e.replacements){if(t.at>o)break;t.to<0||o<e.appearAt[t.to]||!a[t.from]||!a[t.to]||(this.threadControl(t.from,t.to),r.moveTo(this.screenX[t.from],this.screenY[t.from]),r.quadraticCurveTo(this.px,this.py,this.screenX[t.to],this.screenY[t.to]))}r.stroke()}r.globalAlpha=1}drawStems(e,t,n){if(this.sinTilt<.2||this.quality<2||this.quality===2&&e.count>800)return;let{ctx:r,selected:i}=this,{at:a}=t,{appearAt:o,replacedAt:s,archivedAt:c,count:l}=e,{worldX:u,worldY:d}=this;r.strokeStyle=q(W),r.lineWidth=.6;let f=n*He;for(let t of[!1,!0]){r.globalAlpha=i>=0?.05:t?.3:.12,r.beginPath();for(let n=0;n<l;n+=1)a<o[n]||a>=s[n]||a>=c[n]||e.rho[n]>=f===t&&(this.project(u[n],d[n],0),r.moveTo(this.px,this.py),r.lineTo(this.screenX[n],this.screenY[n]));r.stroke()}if(this.quality===3&&l<=1500&&i<0){let t=Math.max(.2,this.cosTilt);for(let i=0;i<l;i+=1){if(a<o[i]||a>=s[i]||a>=c[i])continue;this.project(u[i],d[i],0);let l=12*(.5+e.size[i])*this.ps;r.globalAlpha=.2*F(e.rho[i],n),r.drawImage(this.typeSprites[e.typeIndex[i]],this.px-l/2,this.py-l*t/2,l,l*t)}}r.globalAlpha=1}drawFacts(e,t,n){let{ctx:r,selected:i,selectedSector:a,chainMask:o,hovered:s}=this,{at:c,effectWindow:l,wall:u,ambient:d}=t,{appearAt:f,replacedAt:p,archivedAt:m,size:h,brightness:g,phase:ee,typeIndex:te,flags:_,count:v}=e,y=Math.min(1.75,Math.max(.74,(420/Math.max(1,v))**.26)),ne=Math.min(1.35,Math.max(.7,this.unit/330))*y,b=this.quality===3?48:this.quality===2?24:8,re=v>2200||v>800&&this.quality<3?.34:this.quality===1&&v>300?.26:0,x=0,S=0;for(let y=0;y<v;y+=1){if(c<f[y])continue;let v=this.screenX[y],C=this.screenY[y],ie=this.screenR[y],w=1;i>=0&&(w=o[y]?1.3:e.sector[y]===a?.5:.11),y===s&&(w=Math.max(w,1.5)),w*=.62+.42*Math.min(1,Math.max(0,(ie-.84)/.3));let T=i>=0||y===s||_[y]&1?1:F(e.rho[y],n),E=(6+19*h[y])*ne*ie*(.72+.28*T),ae=Math.min(p[y],m[y]);if(c>=m[y]){let e=Math.min(1,(c-m[y])/(l*1.6)),t=E*(.62+.25*(1-e));r.globalAlpha=Math.min(1,(.2*T+.4*(1-e))*w),r.drawImage(this.archiveSprite,v-t/2,C-t/2,t,t);continue}if(c>=ae){let e=Math.min(1,(c-ae)/l),t=d?.82+.18*Math.sin(u*.0016+ee[y]):.9,n=E*(.86+.9*(1-e)*(1-e));if(e<1){r.globalAlpha=Math.min(1,(1-e)*g[y]*w);let t=this.spriteFor(y,te,_);r.drawImage(t,v-n/2,C-n/2,n,n)}r.globalAlpha=Math.min(1,(.62*T+.38*(1-e))*t*w),r.drawImage(this.emberSprite,v-n/2,C-n/2,n,n);continue}let oe=c-f[y],se=oe<l?(1-oe/l)*t.effectGain:0;if(h[y]<re&&se===0&&y!==s&&i<0){let e=1.7*ie;r.globalAlpha=Math.min(1,g[y]*w*T),r.fillStyle=this.typeCss[te[y]],r.fillRect(v-e/2,C-e/2,e,e);continue}let D=.08+.1*T,ce=d?1-D+D*Math.sin(u*.0013+ee[y]):.95,le=g[y]*ce*w*T;_[y]&8&&(le*=.72);let O=E*(1+2.4*se*se);r.globalAlpha=Math.min(1,le+se*.5);let ue=this.spriteFor(y,te,_);if(r.drawImage(ue,v-O/2,C-O/2,O,O),_[y]&1){let e=E*2.9;r.globalAlpha=Math.min(1,.5*w*ce),r.drawImage(this.pinnedHalo,v-e/2,C-e/2,e,e)}se>0&&(x<b&&(this.rippleQueue[x++]=y),_[y]&4&&S<this.lateQueue.length&&(this.lateQueue[S++]=y))}r.globalAlpha=1,this.drawRipples(e,t,x),this.drawLateBeams(e,t,S),this.drawSelectionMarks(e,t)}spriteFor(e,t,n){return n[e]&2?this.untrustedSprite:this.typeSprites[t[e]]}drawRipples(e,t,n){if(!n)return;let{ctx:r}=this;r.lineWidth=1;for(let i=0;i<n;i+=1){let n=this.rippleQueue[i],a=(t.at-e.appearAt[n])/t.effectWindow;if(a<0||a>=1)continue;this.project(this.worldX[n],this.worldY[n],0);let o=this.unit*(.006+.052*Math.sqrt(a))*this.ps;r.globalAlpha=(1-a)*(1-a)*.42*t.effectGain,r.strokeStyle=q(Ue[le[e.typeIndex[n]]]),r.beginPath(),r.ellipse(this.px,this.py,o,o*Math.max(.2,this.cosTilt),0,0,I),r.stroke()}r.globalAlpha=1}drawLateBeams(e,t,n){if(!n)return;let{ctx:r}=this,i=de(e.domain,t.at);r.strokeStyle=q(Ge),r.lineWidth=1.2;for(let a=0;a<n;a+=1){let n=this.lateQueue[a],o=(t.at-e.appearAt[n])/t.effectWindow;if(o<0||o>=1)continue;let s=e.theta[n];this.project(M(s,i),N(s,i),0),r.globalAlpha=(1-o)*.8*t.effectGain,r.beginPath(),r.moveTo(this.px,this.py),r.lineTo(this.screenX[n],this.screenY[n]),r.stroke()}r.globalAlpha=1}drawSelectionMarks(e,t){let{ctx:n,selected:r,hovered:i,chainMask:a}=this,o=(r,i,a)=>{r<0||r>=e.count||t.at<e.appearAt[r]||(n.globalAlpha=a,n.beginPath(),n.arc(this.screenX[r],this.screenY[r],i,0,I),n.stroke())};if(n.strokeStyle=q(Ge),n.lineWidth=1,r>=0)for(let t=0;t<e.count;t+=1)a[t]&&o(t,t===r?12:7,t===r?.95:.55);i>=0&&i!==r&&o(i,9,.7),n.globalAlpha=1}drawPulseAlong(e,t,n,r){let{ctx:i}=this;this.threadControl(e,t);let a=this.px,o=this.py,s=this.screenX[e],c=this.screenY[e],l=this.screenX[t],u=this.screenY[t],d=e=>{let t=1-e;this.px=t*t*s+2*t*e*a+e*e*l,this.py=t*t*c+2*t*e*o+e*e*u},f=Math.min(1,n*1.3),p=Math.max(0,f-.42),m=r*(n>.75?(1-n)/.25:1);i.strokeStyle=q(qe);for(let e=0;e<9;e+=1){let t=p+(f-p)*e/9,n=p+(f-p)*(e+1)/9;d(t);let r=this.px,a=this.py;d(n),i.globalAlpha=Math.min(1,((e+1)/9)**2*m),i.lineWidth=.7+1.5*((e+1)/9),i.beginPath(),i.moveTo(r,a),i.lineTo(this.px,this.py),i.stroke()}d(f);let h=20*Math.min(1.2,this.unit/300);i.globalAlpha=Math.min(1,m),i.drawImage(this.pulseSprite,this.px-h/2,this.py-h/2,h,h)}drawPulses(e,t){let{at:n,effectWindow:r,wall:i,ambient:a}=t,{replacements:o}=e;if(!o.length)return;let s=this.quality===3?36:this.quality===2?18:6,c=0,l=o.length;for(;c<l;){let e=c+l>>1;o[e].at<=n?c=e+1:l=e}let u=c,d=r*1.8,f=0;for(let r=u-1;r>=0&&f<s;--r){let i=o[r],a=(n-i.at)/d;if(a>=1)break;i.to<0||n<e.appearAt[i.to]||(t.effectGain>.02&&this.drawPulseAlong(i.from,i.to,a,t.effectGain),f+=1)}if(!a){this.ctx.globalAlpha=1;return}if(this.selected>=0){let e=0;for(let t of o){if(t.to<0||t.at>n||!this.chainMask[t.from]||!this.chainMask[t.to])continue;let r=((i*45e-5+e*.27)%1+1)%1;this.drawPulseAlong(t.from,t.to,r,.9),e+=1}}else if(u){if(i>=this.nextAmbientPulse&&this.ambientPulses.length<3){this.nextAmbientPulse=i+650+(Math.sin(i)+1)*500;let e=Math.floor(Math.abs(Math.sin(i*12.9898))*u)%u;this.ambientPulses.push({replacement:e,start:i})}for(let t=this.ambientPulses.length-1;t>=0;--t){let r=this.ambientPulses[t],a=(i-r.start)/1900,s=o[r.replacement];if(a>=1||!s||s.at>n){this.ambientPulses.splice(t,1);continue}s.to<0||n<e.appearAt[s.to]||this.drawPulseAlong(s.from,s.to,a,.55)}}this.ctx.globalAlpha=1}drawFrontier(e,t){let{ctx:n}=this,r=this.frontierPath;n.strokeStyle=q(Ge);let i=e.ambient?.78+.22*Math.sin(e.wall*V):.85,a=(e.moving?1.1:i)*(this.selected>=0?.5:1),o=this.quality===1?1:3;for(let e=0;e<o;e+=1)n.beginPath(),this.traceRing(r),e===o-1?(n.lineWidth=1.1,n.globalAlpha=.72*a):e===0?(n.lineWidth=9,n.globalAlpha=.035*a):(n.lineWidth=3.6,n.globalAlpha=.09*a),n.stroke();if(e.ambient&&this.quality>=2){let r=Math.min(46,this.unit*.11)*(e.moving?1.25:1);for(let i=0;i<3;i+=1){let o=e.wall*17e-5*(i===1?-1:1)+i*2.1;this.project(M(o,t),N(o,t),0),n.globalAlpha=(.32+.3*Math.max(0,Math.sin(e.wall*6e-4+i*2)))*a,n.drawImage(this.pulseSprite,this.px-r/2,this.py-r/2,r,r)}}n.globalAlpha=1}applyBloom(){let{ctx:e,canvas:t}=this;if(this.quality<2||!this.bloomA)return;let n=this.bloomA.getContext(`2d`);if(n){if(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(t,0,0,this.bloomA.width,this.bloomA.height),e.setTransform(1,0,0,1,0,0),e.imageSmoothingEnabled=!0,e.globalCompositeOperation=`lighter`,e.globalAlpha=.34,e.drawImage(this.bloomA,0,0,t.width,t.height),this.quality>=3&&this.bloomB){let n=this.bloomB.getContext(`2d`);n&&(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(this.bloomA,0,0,this.bloomB.width,this.bloomB.height),e.globalAlpha=.3,e.drawImage(this.bloomB,0,0,t.width,t.height))}e.globalAlpha=1}}drawLabels(e,t,n){let{ctx:r}=this;if(this.width<280||!e.count)return;r.textBaseline=`middle`,r.textAlign=`left`,r.font=`10.5px ui-sans-serif, system-ui, sans-serif`;let i=this.selected>=0?.45:1,a=Math.PI*.2-this.camera.yaw,o=1/0,s=1/0;for(let c=e.rings.length-1;c>=0;--c){let l=e.rings[c];if(l.at>t.at||!l.major||(this.project(M(a,l.rho),N(a,l.rho),0),Math.hypot(this.px-o,this.py-s)<34))continue;o=this.px,s=this.py,r.globalAlpha=.62*i*F(l.rho,n),r.fillStyle=q(W);let u=this.ringLabels[c]||``;r.fillText(u,Math.min(this.px+4,this.width-8-r.measureText(u).width),this.py)}let c=Math.min(1.09,n+.07),l=Math.min(1.14,n+.12);if(this.width>=560&&n>.32){r.textAlign=`center`;for(let t of this.sectorOrder){let i=e.sectors[t],a=(i.start+i.end)/2;if(e.spaceArcs.some(e=>e.name.includes(i.label)))continue;this.project(M(a,c),N(a,c),0);let o=(.14+.5*Math.min(1,Math.max(0,(this.ps-.86)/.24)))*Math.min(1,(n-.32)*4);this.selected>=0&&(o=t===this.selectedSector?.95:.1),r.globalAlpha=o,r.fillStyle=q(W),r.fillText(i.label.slice(0,18),this.px,this.py)}}if(e.spaceArcs.length){r.textAlign=`center`;for(let t of e.spaceArcs){let e=Math.max(6,Math.ceil((t.end-t.start)/I*ze));r.beginPath();for(let n=0;n<=e;n+=1){let i=t.start+(t.end-t.start)*n/e;this.project(M(i,l),N(i,l),0),n===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py)}r.strokeStyle=q(W),r.lineWidth=1,r.globalAlpha=.34*i,r.stroke();let n=(t.start+t.end)/2;this.project(M(n,l+.035),N(n,l+.035),0),r.globalAlpha=.72*i,r.fillStyle=q(Ge),r.fillText(t.name.slice(0,22),this.px,this.py)}}r.globalAlpha=1}};function Qe(e,t,n,r,i){let a=e.getContext(`2d`);if(!a)return;let o=Math.min((typeof devicePixelRatio==`number`?devicePixelRatio:1)||1,2),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o));(e.width!==s||e.height!==c)&&(e.width=s,e.height=c),a.setTransform(o,0,0,o,0,0),a.clearRect(0,0,r,i);let{histogram:l,histogramReplacements:u,domain:d}=t,f=l.length,p=Math.max(1,d.end-d.start),m=Math.min(1,Math.max(0,(n-d.start)/p))*r,h=1;for(let e=0;e<f;e+=1)h=Math.max(h,l[e]);let g=r/f,ee=i-5;for(let e=0;e<f;e+=1){let t=l[e],n=e*g,r=n+g/2<=m;if(t){let e=Math.max(1.5,Math.sqrt(t/h)*ee);a.fillStyle=r?q(W,.78):q(W,.2),a.fillRect(n+.5,i-e,Math.max(1,g-1),e)}if(u[e]){let t=Math.min(ee,3+u[e]*1.5);a.fillStyle=r?q(H,.95):q(H,.34),a.fillRect(n+g/2-.75,0,1.5,t)}}}var X=n(),$e=400,et=540,tt=880,nt=16,rt={colorScheme:`dark`,"--text":`rgba(246, 240, 228, 0.96)`,"--foreground":`rgba(246, 240, 228, 0.96)`,"--text-soft":`rgba(246, 240, 228, 0.86)`,"--text-secondary":`rgba(240, 232, 218, 0.74)`,"--text-muted":`rgba(232, 224, 208, 0.58)`,"--text-faint":`rgba(232, 224, 208, 0.38)`,"--surface-hover":`rgba(255, 244, 224, 0.1)`,"--surface-active":`rgba(255, 244, 224, 0.17)`,"--surface-muted":`rgba(255, 244, 224, 0.07)`,"--surface-subtle":`rgba(255, 244, 224, 0.1)`,"--stroke":`rgba(255, 244, 224, 0.13)`,"--stroke-soft":`rgba(255, 244, 224, 0.08)`,"--stroke-strong":`rgba(255, 244, 224, 0.22)`,"--solid":`rgba(255, 244, 224, 0.14)`,"--star":`rgba(255, 232, 192, 0.92)`,"--star-hover":`rgba(255, 240, 214, 1)`,"--key-bg":`rgba(255, 240, 214, 1)`,"--key-border":`rgba(255, 244, 224, 0.2)`,"--key-shadow":`0 0 14px rgba(255, 214, 150, 0.55)`,"--control-border":`rgba(255, 240, 214, 0.9)`,"--focus":`rgba(255, 222, 170, 1)`,"--focus-ring":`rgba(255, 222, 170, 0.32)`,"--danger":`rgba(255, 150, 130, 1)`,"--evo-panel":`rgba(13, 14, 19, 0.74)`,"--evo-line":`rgba(255, 244, 224, 0.13)`,"--evo-scrim":`rgba(5, 6, 10, 0.86)`,"--evo-scrim-clear":`rgba(5, 6, 10, 0)`,"--evo-base":`rgba(5, 6, 10, 1)`,"--evo-active":`rgba(255, 232, 192, 1)`},it=q(H),at=q(U),ot=24e3,st=[`0.5`,`1`,`2`],ct=-.38,lt=.94,ut=.68,dt=.24,ft=26e-6,pt=450,mt=2e4,ht=Math.PI*.62,gt=320,_t=30,vt=30,yt=7,bt=!1;function xt(e){let t=navigator.deviceMemory;return t!==void 0&&t<=2?1:e||t!==void 0&&t<=4?2:3}function St(e){let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)}var Ct=e=>e instanceof Error?e.message:String(e),wt=e=>e instanceof DOMException&&e.name===`AbortError`;function Tt({spaceId:e,refreshKey:t=0,selectedId:n=null,onSelect:i}){let{t:x,language:S}=r(),[C,ie]=(0,b.useState)(null),[w,T]=(0,b.useState)(!0),[E,ae]=(0,b.useState)(``),[oe,se]=(0,b.useState)(0),[D,ce]=(0,b.useState)(0),[O,ue]=(0,b.useState)(0),[k,A]=(0,b.useState)(!1),[de,fe]=(0,b.useState)(`1`),[j,pe]=(0,b.useState)(null),[M,N]=(0,b.useState)(null),[me,he]=(0,b.useState)(null),[ge,_e]=(0,b.useState)(0),[ve,ye]=(0,b.useState)(0),be=(0,b.useRef)(null),P=(0,b.useRef)(null),xe=(0,b.useRef)(null),Se=(0,b.useRef)(null),Ce=(0,b.useRef)(null),we=(0,b.useRef)(null),Ee=(0,b.useRef)(null),Oe=(0,b.useRef)(null),F=(0,b.useRef)(null),I=(0,b.useRef)(null),ze=(0,b.useRef)(-1),L=(0,b.useRef)(-1),Be=(0,b.useRef)(`1`),R=(0,b.useRef)(0),z=(0,b.useRef)(0),B=(0,b.useRef)(`idle`),Ve=(0,b.useRef)(0),V=(0,b.useRef)(1),He=(0,b.useRef)(0),H=(0,b.useRef)(!0),U=(0,b.useRef)(0),We=(0,b.useRef)(!1),W=(0,b.useRef)(0),Ge=(0,b.useRef)(0),Ke=(0,b.useRef)(0),qe=(0,b.useRef)(0),G=(0,b.useRef)(ct),K=(0,b.useRef)(lt),Je=(0,b.useRef)(!1),J=(0,b.useRef)(null),Y=(0,b.useRef)(1),Ye=(0,b.useRef)(1),Xe=(0,b.useRef)(!1),Tt=(0,b.useRef)(null),Et=(0,b.useRef)(null),Dt=(0,b.useRef)(()=>{}),Ot=(0,b.useRef)(null),kt=(0,b.useRef)(!1),{ref:At,playing:jt}=re(),Mt=(0,b.useCallback)(e=>{P.current=e,At(e)},[At]),Nt=(0,b.useCallback)((e=!1)=>{if(!I.current)return;let t=performance.now();!e&&t-Ke.current<33||(Ke.current=t,ce(R.current))},[]),Pt=(0,b.useCallback)(e=>{U.current=0;let t=F.current;if(!t)return;let n=I.current,r=kt.current,i=W.current?Math.min(64,e-W.current):16;W.current=e;let a=!1;if(n){let{start:e,end:o}=n.domain,s=Math.max(1,o-e);if(B.current===`opening`){Ve.current+=i;let n=Re(Ve.current);R.current=e+s*n,t.camera.tilt=dt+(K.current-dt)*St(n*1.15),t.camera.yaw=G.current-1.3*(1-n)**2,a=!0,Ve.current>=6e3&&(R.current=o,B.current=`idle`,A(!1),Nt(!0))}else B.current===`play`&&(R.current+=i*s*Number(Be.current)/ot,a=!0,R.current>=o&&(R.current=o,B.current=`idle`,A(!1),Nt(!0)));let c=z.current,l=R.current-c;B.current!==`idle`||Math.abs(l)<s*2e-4?z.current=R.current:z.current=c+l*(1-Math.exp(-i/85)),z.current!==c&&(a=!0);let u=Math.abs(z.current-c)/Math.max(1,i),d=Math.min(s*.08,Math.max(s*.002,u*520)),f=d>V.current?90:420;r?V.current=s*.002:(V.current+=(d-V.current)*(1-Math.exp(-i/f)),Math.abs(d-V.current)>s*2e-4&&(a=!0))}let o=!!(Ot.current?.moved||Tt.current);if(!r&&!o&&B.current!==`opening`&&L.current<0&&ze.current<0&&(G.current+=i*ft),J.current!==null&&!o){let e=Math.atan2(Math.sin(J.current-G.current),Math.cos(J.current-G.current));Math.abs(e)<.002||r?(G.current=J.current,J.current=null):(G.current+=e*(1-Math.exp(-i/240)),a=!0)}let s=ze.current>=0,c=s?Pe(Y.current,Ye.current):Y.current,l=s?0:Ne(Y.current);if((Math.abs(t.camera.zoom-c)>.001||Math.abs(t.camera.rim-l)>.001)&&!r){let e=1-Math.exp(-i/(Tt.current?50:240));t.camera.zoom+=(c-t.camera.zoom)*e,t.camera.rim+=(l-t.camera.rim)*e,a=!0}else t.camera.zoom=c,t.camera.rim=l;t.settling&&(a=!0),B.current!==`opening`&&(t.camera.yaw=G.current);let u=Math.min(1,(e-He.current)/pt);(a||o)&&(qe.current=e);let d=e-qe.current>mt?66:t.quality===3?32:48;(a||H.current||o||u<1||t.morphing||!r&&e-Ge.current>=d)&&(t.draw({at:z.current,wall:e,effectWindow:V.current,effectGain:n?Math.min(1,Math.max(0,(V.current/(Math.max(1,n.domain.end-n.domain.start)*.002)-1.05)/1.6)):0,ambient:!r,fade:r?1:u,moving:B.current!==`idle`||o}),Ge.current=e,H.current=!1),r||t.noteFrameInterval(i),a&&Nt(),We.current&&(!r||a||u<1||H.current||t.morphing)?U.current=requestAnimationFrame(Pt):a||Nt(!0)},[Nt]),Z=(0,b.useCallback)(()=>{H.current=!0,We.current&&!U.current&&(U.current=requestAnimationFrame(Pt))},[Pt]),Ft=(0,b.useCallback)(()=>{let e=P.current;e&&(Ye.current=Me(e.clientWidth,I.current?.count??0),!Xe.current&&(Y.current=Ye.current,e.setAttribute(`data-zoom`,Y.current.toFixed(2))))},[]),It=(0,b.useCallback)(e=>{let t=je(e);Xe.current=!0,Y.current=t,P.current?.setAttribute(`data-zoom`,t.toFixed(2)),Z()},[Z]),Lt=(0,b.useCallback)(()=>{let e=F.current;B.current===`opening`&&e&&(e.camera.tilt=K.current,e.camera.yaw=G.current),B.current!==`idle`&&(B.current=`idle`,A(!1))},[]),Rt=(0,b.useCallback)(e=>{let t=I.current;t&&(Lt(),R.current=Math.min(t.domain.end,Math.max(t.domain.start,e)),Nt(!0),Z())},[Nt,Lt,Z]),zt=(0,b.useCallback)(()=>{let e=I.current;if(!e||!e.count)return;if(B.current!==`idle`){Lt(),Nt(!0),Z();return}let{start:t,end:n}=e.domain;R.current>=n-(n-t)*.002&&(R.current=t,z.current=t),B.current=`play`,A(!0),Z()},[Nt,Lt,Z]);(0,b.useLayoutEffect)(()=>{let e=be.current;if(!e)return;let t=e.closest(`[data-feature-scroller]`);if(!t)return;let n=()=>{let n=t.clientWidth,r=Math.min(n-(n<=650?0:24)*2,1280),i=e.clientWidth;he(r>i?{width:r,offset:(i-r)/2}:{width:i,offset:0});let a=P.current;if(a){let e=a.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop,r=t.clientHeight-e-nt;_e(Math.round(Math.min(tt,Math.max(n<=650?et:$e,r))))}};n();let r=new ResizeObserver(n);return r.observe(t),r.observe(e),()=>r.disconnect()},[]),(0,b.useLayoutEffect)(()=>{let e=xe.current;if(!e)return;let t=matchMedia(`(pointer: coarse)`).matches;kt.current=_();let n;try{n=new Ze(e,{quality:xt(t)})}catch{return}n.camera.yaw=G.current,F.current=n;let r=(e=!1)=>{let r=P.current;if(!r)return;let i=r.clientWidth,a=r.clientHeight,o=i>=720,s=Se.current?.offsetHeight??0,c=we.current?.offsetHeight??0;r.style.setProperty(`--evo-controls`,`${c}px`),Je.current||(K.current=o?lt:ut,B.current!==`opening`&&(n.camera.tilt=K.current)),Ft(),n.resize(i,a,t?1.5:2);let l=o?0:Ce.current?.offsetHeight??0;n.setInsets({top:o?18:s+10,bottom:c+4+(l?l+4:0),left:o?28:6,right:o?28:6},{animate:e&&!kt.current}),H.current=!0,We.current&&(U.current&&cancelAnimationFrame(U.current),U.current=0,Pt(performance.now()))};r(),Dt.current=r;let i=new ResizeObserver(()=>r());return P.current&&i.observe(P.current),Se.current&&i.observe(Se.current),we.current&&i.observe(we.current),()=>{i.disconnect(),F.current=null}},[Ft,Pt]),(0,b.useEffect)(()=>(We.current=jt,jt&&(W.current=0,Z()),()=>{We.current=!1,U.current&&cancelAnimationFrame(U.current),U.current=0}),[jt,Z]),(0,b.useEffect)(()=>{let e=xe.current;if(!e)return;let t=e=>{!e.ctrlKey&&!e.metaKey||(e.preventDefault(),F.current&&It(Y.current*Math.exp(-e.deltaY*.0022)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[It]),(0,b.useEffect)(()=>{let e=xe.current;if(!e)return;let t=e=>{Tt.current=e.length>=2?{spread:Math.hypot(e[0].clientX-e[1].clientX,e[0].clientY-e[1].clientY),zoom:Y.current}:null},n=e=>{e.targetTouches.length<2||e.cancelable&&(e.preventDefault(),Ot.current=null,t(e.targetTouches),B.current===`opening`&&Lt(),Z())},r=e=>{let t=Tt.current;if(!t||e.targetTouches.length<2)return;e.cancelable&&e.preventDefault();let[n,r]=[e.targetTouches[0],e.targetTouches[1]];It(Fe(t.zoom,t.spread,Math.hypot(n.clientX-r.clientX,n.clientY-r.clientY)))},i=e=>{Tt.current&&t(e.targetTouches)},a=new AbortController,o={passive:!1,signal:a.signal};return e.addEventListener(`touchstart`,n,o),e.addEventListener(`touchmove`,r,o),e.addEventListener(`touchend`,i,{signal:a.signal}),e.addEventListener(`touchcancel`,i,{signal:a.signal}),()=>{a.abort(),Tt.current=null}},[It,Lt,Z]),(0,b.useEffect)(()=>{let t=new AbortController;return T(!0),ae(``),v(e,t.signal).then(e=>{t.signal.aborted||(ie(Te(e)),T(!1))}).catch(e=>{t.signal.aborted||wt(e)||(ae(Ct(e)),T(!1))}),()=>t.abort()},[e,t,oe]);let Bt=(0,b.useMemo)(()=>{let e=C?.unit===`day`||C?.unit===`week`?{month:`short`,day:`numeric`}:{year:`numeric`,month:`short`};return new Intl.DateTimeFormat(S,e)},[S,C?.unit]),Vt=(0,b.useMemo)(()=>new Intl.DateTimeFormat(S,{year:`numeric`,month:`long`,day:`numeric`}),[S]),Ht=(0,b.useMemo)(()=>new Intl.DateTimeFormat(S,{year:`numeric`,month:`2-digit`,day:`2-digit`}),[S]);(0,b.useEffect)(()=>{let e=F.current;e&&(e.setRingFormatter(e=>Bt.format(e)),H.current=!0)},[Bt]),(0,b.useEffect)(()=>{if(!C)return;let e=I.current,t=F.current,{start:n,end:r}=C.domain,i=r;if(e){let t=e.domain.end-e.domain.start;R.current>=e.domain.end-t*.002||(i=Math.min(r,Math.max(n,R.current))),B.current!==`idle`&&(B.current=`idle`,A(!1))}else!bt&&!kt.current&&C.count>0&&(bt=!0,B.current=`opening`,Ve.current=0,i=n,A(!0));I.current=C,R.current=i,z.current=i,V.current=(r-n)*.002;let a=performance.now();t?.setScene(C,{animate:!!e&&!kt.current,now:a})||(He.current=a),Ft(),!e&&t&&(t.camera.zoom=Y.current,t.camera.rim=Ne(Y.current)),ce(i),ue(i),pe(null),L.current=-1,Z()},[C,Ft,Z]);let Q=(0,b.useMemo)(()=>!C||!n?-1:C.indexById.get(n)??-1,[C,n]);(0,b.useEffect)(()=>{let e=F.current;ze.current=Q,e?.setSelection(Q);let t=I.current;t&&Q>=0?(J.current=ht-t.theta[Q],R.current<t.appearAt[Q]&&Rt(t.appearAt[Q])):J.current=null,Z()},[Rt,Q,Z]),(0,b.useEffect)(()=>{if(N(null),!n)return;let e=new AbortController;return y(n,e.signal).then(t=>{e.signal.aborted||N(t)}).catch(()=>{}),()=>e.abort()},[n,t]);let Ut=(0,b.useMemo)(()=>C&&Q>=0?Ae(C,Q):[],[C,Q]);(0,b.useLayoutEffect)(()=>{Dt.current(!0),Z()},[Ut,M,Z]),(0,b.useEffect)(()=>{if(!n)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role="dialog"], [data-slot="popover-content"]`)||i(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]),(0,b.useEffect)(()=>{if(k)return;let e=window.setTimeout(()=>ue(D),700);return()=>window.clearTimeout(e)},[D,k]),(0,b.useEffect)(()=>{let e=Oe.current;if(!e)return;let t=new ResizeObserver(()=>ye(e.clientWidth));return t.observe(e),ye(e.clientWidth),()=>t.disconnect()},[]),(0,b.useEffect)(()=>{let e=Ee.current;!e||!C||!ve||Qe(e,C,D,ve,vt)},[D,ve,C]);let Wt=(0,b.useMemo)(()=>C?ke(C,D):{active:0,superseded:0,archived:0,known:0},[D,C]),Gt=(0,b.useMemo)(()=>C?ke(C,O):Wt,[O,C,Wt]),$=!!C?.count,Kt=!C||D>=C.domain.end-(C.domain.end-C.domain.start)*.002,qt=C?Vt.format(D):``,Jt=x(`memory:memoryEvolution.stageLabel`,{date:C?Vt.format(O):``,active:Gt.active,superseded:Gt.superseded,archived:Gt.archived}),Yt=e=>x(e===`decision`?`memory:memoryEvolution.typeDecision`:e===`preference`?`memory:memoryEvolution.typePreference`:e===`fact`?`memory:memoryEvolution.typeFact`:e===`risk`?`memory:memoryEvolution.typeRisk`:e===`file`?`memory:memoryEvolution.typeFile`:e===`task`?`memory:memoryEvolution.typeTask`:`memory:memoryEvolution.typeConcept`),Xt=e=>x(e===`superseded`?`memory:memoryEvolution.superseded`:e===`archived`?`memory:memoryEvolution.archived`:e===`hidden`?`memory:memoryEvolution.notYet`:`memory:memoryEvolution.active`),Zt=e=>{let t=e.target,n=!!t.closest(`[data-slot="segmented-control"], [data-slot="popover-content"]`);if(e.key===` `){if(t.closest(`button, a, [role="radio"]`))return;e.preventDefault(),zt();return}let r=I.current;if(!r||!r.count||n)return;let i=(r.domain.end-r.domain.start)*(e.shiftKey?.05:.01),a=null;e.key===`ArrowLeft`?a=R.current-i:e.key===`ArrowRight`?a=R.current+i:e.key===`Home`?a=r.domain.start:e.key===`End`&&(a=r.domain.end),a!==null&&(e.preventDefault(),e.stopPropagation(),Rt(a))},Qt=e=>{e.button!==0||!e.isPrimary||(Ot.current={id:e.pointerId,x:e.clientX,y:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId))},$t=e=>{let t=F.current;if(!t)return;let n=Ot.current;if(n&&n.id===e.pointerId){let r=e.clientX-n.lastX,i=e.clientY-n.lastY;if(!n.moved&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<5)return;n.moved=!0,J.current=null,n.lastX=e.clientX,n.lastY=e.clientY,G.current+=r*.0062,e.pointerType===`mouse`&&(Je.current=!0,K.current=Math.min(1.16,Math.max(0,K.current-i*.0042)),t.camera.tilt=K.current),B.current===`opening`&&Lt(),L.current=-1,t.setHover(-1),pe(null),Z();return}if(e.pointerType!==`mouse`)return;let r=e.currentTarget.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=t.pick(i,a,15,z.current);o!==L.current&&(L.current=o,t.setHover(o),Z()),pe(o>=0?{index:o,x:i,y:a}:null)},en=e=>{let t=Ot.current;Ot.current=null;let n=F.current;if(!n||!I.current||!t||t.moved)return;if(e.pointerType!==`mouse`){let t=Et.current,n=t!==null&&e.timeStamp-t.at<gt&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<_t;if(Et.current=n?null:{at:e.timeStamp,x:e.clientX,y:e.clientY},n){nn();return}}let r=e.currentTarget.getBoundingClientRect(),a=n.pick(e.clientX-r.left,e.clientY-r.top,e.pointerType===`mouse`?16:28,z.current);i(a>=0?I.current.facts[a].id:null)},tn=()=>{L.current>=0&&(L.current=-1,F.current?.setHover(-1),Z()),pe(null)},nn=()=>{let e=F.current;e&&(It(Ye.current),Xe.current=!1,Je.current=!1,K.current=(P.current?.clientWidth??800)>=720?lt:ut,e.camera.tilt=K.current,Z())},rn=j&&C?C.facts[j.index]:null,an=(0,b.useMemo)(()=>{let e=new Map;M?.item&&e.set(M.item.id,M.item.content);for(let t of M?.history||[])e.set(t.id,t.content);return e},[M]),on=e=>(0,X.jsx)(p,{size:`sm`,className:e,"aria-label":x(`memory:memoryEvolution.speed`),value:de,onValueChange:e=>{Be.current=e,fe(e)},options:st.map(e=>({value:e,label:`${e}×`}))}),sn=me?.width??null,cn=(()=>{if(!j)return;let e=P.current?.clientWidth??800,t=P.current?.clientHeight??600;return{left:Math.min(e-272,j.x+16),...j.y>t-150?{bottom:t-j.y+16}:{top:j.y+16}}})();return(0,X.jsx)(`div`,{ref:be,className:`min-w-0`,children:(0,X.jsxs)(`div`,{ref:Mt,role:`group`,"aria-label":x(`memory:memoryEvolution.regionLabel`),"data-memory-evolution":!0,"data-at":C?new Date(D).toISOString():void 0,"data-active-count":Wt.active,"data-playing":k||void 0,onKeyDownCapture:Zt,style:{...rt,...sn?{width:sn,marginLeft:me?.offset??0}:{},...ge?{height:ge}:{}},className:`@container relative isolate h-[clamp(560px,calc(100dvh-196px),880px)] overflow-hidden rounded-xl bg-[var(--evo-base)] text-content select-none max-[650px]:h-[clamp(540px,calc(100dvh-132px),780px)] max-[650px]:rounded-none`,children:[(0,X.jsx)(`canvas`,{ref:xe,role:`img`,"aria-label":Jt,tabIndex:0,onPointerDown:Qt,onPointerMove:$t,onPointerUp:en,onPointerCancel:()=>{Ot.current=null},onPointerLeave:tn,onDoubleClick:nn,className:`absolute inset-0 size-full cursor-grab touch-pan-y outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset active:cursor-grabbing`}),(0,X.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,role:`status`,children:C&&!k?Jt:``}),(0,X.jsxs)(`div`,{ref:Se,className:`pointer-events-none absolute top-5 left-6 z-10 flex max-w-[min(70%,420px)] flex-col gap-1.5 @max-[719px]:top-3.5 @max-[719px]:right-4 @max-[719px]:left-4 @max-[719px]:max-w-none`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2.5`,children:[$&&(0,X.jsx)(`span`,{"data-memory-evolution-date":!0,className:`text-[30px] leading-9 font-light tracking-[-0.015em] text-content tabular-nums @max-[719px]:text-2xl @max-[719px]:leading-8`,children:qt}),$&&Kt&&(0,X.jsx)(`span`,{className:`text-xs text-[var(--evo-active)]`,children:x(`memory:memoryEvolution.now`)})]}),$&&(0,X.jsxs)(`dl`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-content-muted tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-[var(--evo-active)] shadow-[0_0_8px_var(--evo-active)]`}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.active`)}),(0,X.jsx)(`dd`,{"data-memory-evolution-active":!0,className:`font-medium text-content`,children:Wt.active})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:it,boxShadow:`0 0 8px ${it}`}}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.superseded`)}),(0,X.jsx)(`dd`,{className:`font-medium text-content`,children:Wt.superseded})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:at}}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.archived`)}),(0,X.jsx)(`dd`,{className:`font-medium text-content`,children:Wt.archived})]})]}),C?.truncated&&(0,X.jsx)(`p`,{className:`m-0 text-xs text-content-faint`,children:x(`memory:memoryEvolution.truncated`,{count:C.count})}),E&&C&&(0,X.jsx)(`p`,{className:`m-0 text-xs text-danger`,children:E})]}),$&&Q<0&&(0,X.jsx)(`ul`,{"aria-label":x(`memory:memoryEvolution.legend`),className:`pointer-events-none absolute top-1/2 right-6 z-10 hidden -translate-y-[62%] list-none flex-col gap-1.5 p-0 text-[11px] text-content-muted @min-[880px]:flex`,children:le.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-end gap-2`,children:[Yt(e),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:q(Ue[e]),boxShadow:`0 0 7px ${q(Ue[e])}`}})]},e))}),$&&(0,X.jsx)(`div`,{className:`absolute top-3.5 right-4 z-10 @max-[719px]:top-2.5 @max-[719px]:right-2.5`,children:(0,X.jsxs)(d,{children:[(0,X.jsx)(l,{asChild:!0,children:(0,X.jsx)(g,{variant:`ghost`,size:`icon-sm`,"aria-label":x(`memory:memoryEvolution.howToRead`),title:x(`memory:memoryEvolution.howToRead`),children:(0,X.jsx)(a,{"aria-hidden":`true`})})}),(0,X.jsxs)(u,{align:`end`,className:`w-80 gap-2 text-xs`,children:[(0,X.jsx)(`p`,{className:`m-0 leading-relaxed`,children:x(`memory:memoryEvolution.howToReadBody`)}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-2 gap-x-3 gap-y-1 p-0`,children:le.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 text-content-secondary`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:q(Ue[e])}}),Yt(e)]},e))}),(0,X.jsx)(`p`,{className:`m-0 leading-relaxed text-content-muted`,children:x(`memory:memoryEvolution.gestures`)})]})]})}),rn&&j&&C&&j.index!==Q&&(0,X.jsxs)(`div`,{role:`tooltip`,"data-memory-evolution-tooltip":!0,style:cn,className:`pointer-events-none absolute z-20 flex w-max max-w-64 flex-col gap-0.5 rounded-md border border-[var(--evo-line)] bg-[var(--evo-panel)] px-2.5 py-1.5 text-xs backdrop-blur-md`,children:[(0,X.jsx)(`strong`,{className:`line-clamp-2 font-medium text-content`,children:rn.title}),(0,X.jsxs)(`span`,{className:`text-content-muted tabular-nums`,children:[Yt(rn.type),` · `,Ht.format(C.validAt[j.index]),` ·`,` `,Xt(De(C,j.index,D))]}),!!(C.flags[j.index]&4)&&(0,X.jsx)(`span`,{className:`text-content-muted tabular-nums`,children:x(`memory:memoryEvolution.learnedLate`,{date:Ht.format(C.appearAt[j.index])})})]}),C&&Q>=0&&(0,X.jsxs)(`section`,{ref:Ce,"data-memory-evolution-card":!0,"aria-label":C.facts[Q].title,className:`absolute top-14 right-4 z-20 flex max-h-[calc(100%-230px)] w-[320px] flex-col gap-2 overflow-y-auto rounded-lg border border-[var(--evo-line)] bg-[var(--evo-panel)] p-3 backdrop-blur-md @max-[719px]:top-auto @max-[719px]:right-2.5 @max-[719px]:bottom-[calc(var(--evo-controls,160px)+4px)] @max-[719px]:left-2.5 @max-[719px]:max-h-[32%] @max-[719px]:w-auto`,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`m-0 min-w-0 text-[13px] leading-5 font-medium break-words text-content`,children:C.facts[Q].title}),(0,X.jsx)(g,{variant:`ghost`,size:`icon-sm`,className:`-mt-1 -mr-1 flex-none`,"aria-label":x(`memory:memoryEvolution.closeCard`),onClick:()=>i(null),children:(0,X.jsx)(c,{"aria-hidden":`true`})})]}),(0,X.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-2 text-[11px] text-content-muted`,children:[(0,X.jsx)(`span`,{children:Yt(C.facts[Q].type)}),!!(C.flags[Q]&1)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.pinned`)}),!!(C.flags[Q]&2)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.untrusted`)}),!!(C.flags[Q]&8)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.stale`)})]}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:Ut.map(e=>{let t=C.facts[e],n=De(C,e,D),r=an.get(t.id);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-current":e===Q||void 0,onClick:()=>{Rt(C.appearAt[e]),i(t.id)},className:m(`flex w-full min-w-0 flex-col gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none pointer-coarse:min-h-11`,e===Q&&`bg-surface-muted`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-content-muted tabular-nums`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full`,style:{backgroundColor:n===`superseded`?it:n===`archived`?at:q(Ue[t.type]??Ue.concept)}}),Ht.format(C.validAt[e]),` · `,Xt(n)]}),(0,X.jsx)(`span`,{className:`line-clamp-3 text-xs leading-[1.45] break-words text-content-soft`,children:r||t.title})]})},t.id)})})]}),C&&!$&&(0,X.jsx)(`div`,{className:`absolute inset-x-0 bottom-5 z-10 flex justify-center px-6`,children:(0,X.jsx)(te,{compact:!0,illustration:(0,X.jsx)(`span`,{}),title:x(`memory:memoryEvolution.emptyTitle`),description:x(`memory:memoryEvolution.emptyDescription`)})}),!C&&w&&(0,X.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center text-xs text-content-muted`,children:(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(h,{className:`size-4`}),x(`memory:memoryEvolution.loading`)]})}),!C&&!w&&E&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center`,children:(0,X.jsx)(ee,{kind:`error`,title:x(`memory:memoryEvolution.loadFailed`),description:E,action:(0,X.jsx)(g,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>se(e=>e+1),children:x(`memory:memoryEvolution.retry`)})})}),(0,X.jsx)(`div`,{ref:we,className:m(`absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-[var(--evo-scrim)] via-[var(--evo-scrim)] via-40% to-[var(--evo-scrim-clear)] px-5 pt-7 pb-3.5 @max-[719px]:px-3 @max-[719px]:pt-5 @max-[719px]:pb-3`,!$&&`invisible`),children:(0,X.jsxs)(`div`,{className:`flex items-end gap-3 @max-[719px]:flex-col @max-[719px]:items-stretch @max-[719px]:gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-none items-center gap-1 pb-1 @max-[719px]:order-2 @max-[719px]:justify-between @max-[719px]:pb-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(g,{variant:`ghost`,size:`icon`,"data-memory-evolution-play":!0,className:`max-[650px]:size-11`,"aria-label":x(k?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),title:x(k?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),disabled:!$,onClick:zt,children:k?(0,X.jsx)(o,{"aria-hidden":`true`}):(0,X.jsx)(s,{"aria-hidden":`true`})}),(0,X.jsxs)(g,{variant:`ghost`,size:`sm`,"data-memory-evolution-now":!0,className:`aria-disabled:opacity-50 max-[650px]:h-11`,"aria-disabled":!$||Kt&&!k,onClick:()=>{C&&!(Kt&&!k)&&Rt(C.domain.end)},children:[(0,X.jsx)(ne,{"aria-hidden":`true`}),x(`memory:memoryEvolution.backToNow`)]})]}),on(`hidden @max-[719px]:inline-flex`)]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 @max-[719px]:order-1`,children:[(0,X.jsx)(`div`,{ref:Oe,"aria-hidden":`true`,style:{marginLeft:yt,marginRight:yt,height:vt},children:(0,X.jsx)(`canvas`,{ref:Ee,className:`block size-full`})}),C&&(0,X.jsx)(f,{"aria-label":x(`memory:memoryEvolution.timelineLabel`),valueText:qt,min:0,max:1e3,step:1,value:[Le(C.domain,D)],disabled:!$,className:`h-5 pointer-coarse:h-11 max-[650px]:h-11`,onValueChange:([e])=>Rt(Ie(C.domain,e))}),C&&(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`flex justify-between px-[7px] text-[11px] text-content-faint tabular-nums`,children:[(0,X.jsx)(`span`,{children:Ht.format(C.domain.start)}),(0,X.jsx)(`span`,{children:Ht.format(C.domain.end)})]})]}),on(`mb-1 flex-none @max-[719px]:hidden`)]})})]})})}export{Tt as MemoryEvolution,Tt as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-D6tl7SDi.js";import{t as i}from"./createLucideIcon-Cd-3GVxJ.js";import{t as a}from"./info-DATxy0fb.js";import{t as o}from"./pause-CYWpPg1R.js";import{t as s}from"./play-DNDjDNGn.js";import{t as c}from"./x-07u4-129.js";import{i as l,n as u,t as d}from"./popover-CXY-wqxd.js";import{t as f}from"./slider-De8rWVNs.js";import{t as p}from"./segmented-control-xkrEOP_d.js";import{t as m}from"./utils-C8uzG5AZ.js";import{n as h,t as g}from"./button-CCcCN8tE.js";import{n as ee,t as te}from"./PageState-Cz6vFMXv.js";import{t as _}from"./motion-DTR4ZVle.js";import{d as v,l as y}from"./memory-api-BdiBvhoi.js";var ne=i(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),b=e(t(),1);function re(e={}){let{rootMargin:t=`96px 0px`,threshold:n=0}=e,[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(()=>!document.hidden),[s,c]=(0,b.useState)(!0),l=(0,b.useCallback)(e=>{i(e)},[]);return(0,b.useEffect)(()=>{let e=()=>o(!document.hidden);return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),(0,b.useEffect)(()=>{if(!r||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(([e])=>{e&&c(e.isIntersecting)},{rootMargin:t,threshold:n});return e.observe(r),()=>e.disconnect()},[r,t,n]),{ref:l,playing:a&&s}}var x=864e5,S=Math.PI*2,C=.055,ie=.85,w=1e3,T=.72,E=2.6,ae=1.75,oe=30,se=1.1,D=.34,ce=6e3,le=[`decision`,`preference`,`fact`,`concept`,`risk`,`file`,`task`];function O(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var ue=e=>O(e)/4294967296,k=e=>Math.min(1,Math.max(0,e));function A(e,t){let n=Date.parse(String(e||``));return Number.isNaN(n)?t:n}function de(e,t){let n=Math.max(1,e.end-e.start);return C+.945*k((t-e.start)/n)**ie}function fe(e,t){return t*(1+.046*(.62*Math.sin(3*e+1.1+1.9*t)+.28*Math.sin(5*e+4.2-2.7*t)+.1*Math.sin(11*e+2.3+5.1*t))*Math.min(1,t*2.2))}var j=.042,pe=-.03;function M(e,t){return fe(e,t)*Math.cos(e)+j*(1-t)}function N(e,t){return fe(e,t)*Math.sin(e)+pe*(1-t)}function me(e){let t=(e.end-e.start)/x;return t<=21?`day`:t<=120?`week`:t<=1e3?`month`:t<=3e3?`quarter`:`year`}function he(e,t){let n=new Date(e);if(t===`day`)return new Date(n.getFullYear(),n.getMonth(),n.getDate()+1);if(t===`week`){let e=(8-n.getDay())%7||7;return new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)}return t===`month`?new Date(n.getFullYear(),n.getMonth()+1,1):t===`quarter`?new Date(n.getFullYear(),Math.floor(n.getMonth()/3)*3+3,1):new Date(n.getFullYear()+1,0,1)}function ge(e,t){return t===`day`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+1):t===`week`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+7):t===`month`?new Date(e.getFullYear(),e.getMonth()+1,1):t===`quarter`?new Date(e.getFullYear(),e.getMonth()+3,1):new Date(e.getFullYear()+1,0,1)}function _e(e,t){return t===`day`?e.getDay()===1:t===`week`?e.getDate()<=7:t===`month`?e.getMonth()%3==0:t!==`quarter`||e.getMonth()===0}function ve(e,t,n){let r=[],i=he(e.start,t);for(;i.getTime()<e.end&&r.length<400;)r.push(i),i=ge(i,t);let a=Array(r.length).fill(0);for(let e of n){let t=0,n=r.length;for(;t<n;){let i=t+n>>1;r[i].getTime()<e?t=i+1:n=i}t<a.length&&(a[t]+=1)}let o=Math.max(1,...a);return r.map((n,r)=>{let i=n.getTime();return{at:i,rho:de(e,i),major:_e(n,t),activity:a[r]/o}})}var ye=new Set([`project`,`projects`,`user`,`users`,`global`,`repo`,`app`,`pisper`,`general`,`misc`,`title`]);function be(e){let t=String(e||``).split(`.`).filter(Boolean);for(;t.length>1&&ye.has(t[0]);)t.shift();return t[0]||``}function P(e,t){let n=A(e.createdAt,t),r=A(e.validFrom,n);return{created:n,valid:r,appear:Math.max(n,r)}}function xe(e,t){if(!e.length)return{start:t-180*x,end:t};let n=1/0,r=t;for(let i of e){let{valid:e,appear:a}=P(i,t);n=Math.min(n,e,a),a<=t&&(r=Math.max(r,a))}let i=Math.max(x,r-n);return{start:Math.min(n-Math.max(i*.02,x/4),r-7*x),end:r}}function Se(e){let t=new Map,n=e.map(e=>be(e.topicKey));e.forEach((e,r)=>{let i=`${e.spaceId}\u0000${n[r]}`,a=t.get(i);a?a.push(r):t.set(i,[r])});let r=Math.max(2,Math.ceil(e.length*.012)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])},o=new Map,s=new Map,c=[...t.entries()].sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0]));for(let[t,n]of c){let[i,c]=t.split(`\0`),l=s.get(i)||0;if(c&&n.length>=r&&l<16){s.set(i,l+1),a(i,{key:t,label:c,kind:`topic`,spaceId:i,members:n});continue}for(let t of n){let n=`${i}\u0000type:${e[t].type}`,r=o.get(n);r?r.push(t):o.set(n,[t])}}for(let[e,t]of o){let[n,r]=e.split(`\0`);a(n,{key:e,label:r.slice(5),kind:`type`,spaceId:n,members:t})}return i}function Ce(e,t,n){let r=Se(e),i=[...r.keys()].sort((e,t)=>e===`global`?-1:t===`global`?1:O(e)-O(t)),a=[],o=new Int16Array(e.length),s=new Float32Array(e.length),c=[],l=i.length>1?.09:0,u=i.reduce((e,t)=>e+(r.get(t)?.length||0),0),d=Math.min(.022,S*.25/Math.max(1,u)),f=e=>(r.get(e)||[]).reduce((e,t)=>e+Math.sqrt(t.members.length)+.6,0),p=i.reduce((e,t)=>e+f(t),0)||1,m=S-l*i.length-d*u,h=-Math.PI/2+l/2;for(let u of i){let i=[...r.get(u)||[]].sort((e,t)=>O(e.key)-O(t.key)),f=h;for(let n of i){let r=m*(Math.sqrt(n.members.length)+.6)/p,i=a.length;a.push({key:n.key.split(`\0`)[1],label:n.label,kind:n.kind,spaceId:u,start:h,end:h+r,count:n.members.length});let c=[...n.members].sort((n,r)=>t[n]-t[r]||e[n].id.localeCompare(e[r].id)),l=ue(n.key);c.forEach((e,t)=>{o[e]=i;let n=(l+t*.61803398875)%1;s[e]=h+r*(.05+.9*n)}),h+=r+d}c.push({spaceId:u,name:n.find(e=>e.id===u)?.name||u,start:f,end:h-d}),h+=l}return{sectors:a,sectorOf:o,theta:s,spaceArcs:i.length>1?c:[]}}function we(e){return Float64Array.from(e).sort()}function Te(e,{histogramBins:t=160}={}){let n=A(e.now,Date.now()),r=[...e.facts].sort((e,t)=>e.id.localeCompare(t.id)),i=r.length,a=xe(r,n),o=a.end-a.start,s=Math.max(x,o*.015),c=new Map(r.map((e,t)=>[e.id,t])),l=new Float64Array(i),u=new Float64Array(i),d=new Float64Array(i).fill(1/0),f=new Float64Array(i).fill(1/0),p=new Int32Array(i).fill(-1),m=new Uint8Array(i),h=new Uint8Array(i),g=new Map;r.forEach((e,t)=>{let{created:r,valid:i,appear:a}=P(e,n);l[t]=i,u[t]=a;let o=le.indexOf(e.type);h[t]=o>=0?o:le.indexOf(`concept`);let d=0;e.pinned&&(d|=1),e.tainted&&(d|=2),e.status===`stale`&&(d|=8),r-i>s&&(d|=4),m[t]=d;let f=e.supersededBy?c.get(e.supersededBy):void 0;if(f!==void 0&&f!==t){p[t]=f;let e=g.get(f);e?e.push(t):g.set(f,[t])}}),r.forEach((e,t)=>{let n=A(e.supersededAt,NaN)||A(e.validTo,NaN)||(e.status===`superseded`?p[t]>=0?u[p[t]]:a.end:NaN);Number.isFinite(n)&&(d[t]=Math.max(n,u[t]));let r=A(e.archivedAt,NaN)||(e.status===`archived`?a.end:NaN);Number.isFinite(r)&&(f[t]=Math.max(r,u[t]))});let{sectors:ee,sectorOf:te,theta:_,spaceArcs:v}=Ce(r,u,e.spaces),y=new Float32Array(i),ne=new Float32Array(i),b=new Float32Array(i),re=new Float32Array(i),C=new Float32Array(i),ie=new Float32Array(i),w=new Float32Array(i);r.forEach((e,t)=>{y[t]=de(a,l[t]),ne[t]=M(_[t],y[t]),b[t]=N(_[t],y[t]);let n=k(Number(e.importance)||0),r=k((Number(e.authority)||0)/100);C[t]=.16+.84*n**1.5,ie[t]=(.4+.22*r+.38*n)*(e.tainted?.6:1),re[t]=.016+.105*n**1.5+(e.pinned?.03:0),w[t]=ue(e.id)*S});let T=[];r.forEach((e,t)=>{Number.isFinite(d[t])&&T.push({at:d[t],from:t,to:p[t]})}),T.sort((e,t)=>e.at-t.at||e.from-t.from);let E=Math.max(1,t),ae=new Uint16Array(E),oe=new Uint16Array(E),se=e=>Math.min(E-1,Math.floor(k((e-a.start)/o)*E));for(let e=0;e<i;e+=1)u[e]<=a.end&&(ae[se(u[e])]+=1);for(let e of T)e.at<=a.end&&(oe[se(e.at)]+=1);let D=[...u],ce=[],O=[];for(let e=0;e<i;e+=1){let t=Math.min(d[e],f[e]);Number.isFinite(t)&&ce.push(t),Number.isFinite(f[e])&&O.push(f[e])}let fe=e.digests.map(e=>{let t=A(e.windowEnd,a.end),n=A(e.windowStart,t),r=v.find(t=>t.spaceId===e.spaceId),i=r?.start??-Math.PI,o=(r?.end??Math.PI)-i,s=o*(e.level===`month`?.16:e.level===`week`?.085:.045),c=i+ue(e.id)*Math.max(0,o-s);return{id:e.id,level:e.level,at:t,rho:de(a,(n+t)/2),start:c,end:c+s}}),j=me(a);return{facts:r,count:i,indexById:c,domain:a,unit:j,rings:ve(a,j,D),bornWindow:Math.max(o*.012,1),validAt:l,appearAt:u,replacedAt:d,archivedAt:f,theta:_,rho:y,x:ne,y:b,lift:re,size:C,brightness:ie,phase:w,typeIndex:h,sector:te,flags:m,successor:p,predecessors:g,replacements:T,sectors:ee,spaceArcs:v,digests:fe,histogram:ae,histogramReplacements:oe,truncated:!!e.truncated,sortedAppear:we(D),sortedEnded:we(ce),sortedArchived:we(O)}}function Ee(e,t,n){return n<e.appearAt[t]?0:n>=e.archivedAt[t]?3:n>=e.replacedAt[t]?2:1}function De(e,t,n,r=e.bornWindow){let i=Ee(e,t,n);return i===0?`hidden`:i===3?`archived`:i===2?`superseded`:n-e.appearAt[t]<r?`born`:`active`}function Oe(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<=t?n=i+1:r=i}return n}function ke(e,t){let n=Oe(e.sortedAppear,t),r=Oe(e.sortedEnded,t),i=Oe(e.sortedArchived,t);return{active:n-r,superseded:r-i,archived:i,known:n}}function Ae(e,t){let n=new Set([t]),r=[],i=[t];for(;i.length;)for(let t of e.predecessors.get(i.pop())||[])n.has(t)||(n.add(t),r.push(t),i.push(t));let a=[],o=e.successor[t];for(;o>=0&&!n.has(o);)n.add(o),a.push(o),o=e.successor[o];return[...r,t,...a].sort((t,n)=>e.appearAt[t]-e.appearAt[n]||t-n)}function je(e){return Math.min(E,Math.max(T,e))}function Me(e,t){return e<720&&t>=oe?ae:1}function Ne(e){let t=k((e-1)/.5);return t*t*(3-2*t)}function Pe(e,t){return Math.max(1,e/t)*se}function F(e,t){let n=k(e/Math.max(t,.001));return D+.6599999999999999*n*n*(3-2*n)}function Fe(e,t,n){return je(e*n/Math.max(1,t))}function Ie(e,t){return e.start+(e.end-e.start)*k(t/w)}function Le(e,t){let n=Math.max(1,e.end-e.start);return Math.round(k((t-e.start)/n)*w)}function Re(e,t=ce){let n=k(e/t);return n<.5?4*n*n*n:1-(-2*n+2)**3/2}var I=Math.PI*2,ze=144,L=72,Be=.2,R=96,z=620,B=55e5,Ve=[{inner:.965,alpha:.05},{inner:.9,alpha:.032},{inner:.78,alpha:.018}],V=.0012,He=.6,Ue={decision:[255,196,92],preference:[186,164,255],fact:[176,214,255],concept:[104,176,255],risk:[255,104,158],file:[92,226,176],task:[92,222,240]},H=[255,96,44],U=[96,118,164],We=[156,164,178],W=[236,208,164],Ge=[255,232,192],Ke=[255,176,104],qe=[255,236,204],G=[255,206,138],K=[255,222,180],Je=[176,202,255],q=([e,t,n],r=1)=>`rgba(${e}, ${t}, ${n}, ${r})`;function J(e,t,n){let r=Math.min(1,Math.max(0,(e-t)/(n-t)));return r*r*(3-2*r)}function Y(e,t){let n=document.createElement(`canvas`);return n.width=Math.max(1,Math.round(e)),n.height=Math.max(1,Math.round(t)),n}function Ye([e,t,n]){let r=Y(R,R),i=r.getContext(`2d`);if(!i)return r;let a=R/2,o=i.createRadialGradient(a,a,0,a,a,a),s=r=>[255+(e-255)*r,255+(t-255)*r,255+(n-255)*r],c=(e,t)=>{let[n,r,i]=s(e);return`rgba(${n|0}, ${r|0}, ${i|0}, ${t})`};return o.addColorStop(0,c(.12,1)),o.addColorStop(.08,c(.5,.96)),o.addColorStop(.16,c(1,.62)),o.addColorStop(.3,c(1,.22)),o.addColorStop(.56,c(1,.06)),o.addColorStop(1,c(1,0)),i.fillStyle=o,i.fillRect(0,0,R,R),r}function Xe([e,t,n]){let r=Y(R,R),i=r.getContext(`2d`);if(!i)return r;let a=R/2,o=i.createRadialGradient(a,a,0,a,a,a);return o.addColorStop(0,`rgba(${e}, ${t}, ${n}, 0.55)`),o.addColorStop(.35,`rgba(${e}, ${t}, ${n}, 0.16)`),o.addColorStop(.7,`rgba(${e}, ${t}, ${n}, 0.035)`),o.addColorStop(1,`rgba(${e}, ${t}, ${n}, 0)`),i.fillStyle=o,i.fillRect(0,0,R,R),r}var Ze=class{canvas;ctx;camera={yaw:0,tilt:.92,zoom:1,rim:0};quality;scene=null;width=1;height=1;dpr=1;maxDpr=2;insets={top:0,right:0,bottom:0,left:0};targetInsets={top:0,right:0,bottom:0,left:0};typeSprites;emberSprite;archiveSprite;untrustedSprite;pulseSprite;coreSprite;discSprite;pinnedHalo;background=null;bloomA=null;bloomB=null;ringPaths=[];grainPaths=[];frontierPath=new Float32Array(288);rimPath=new Float32Array(288);bandPaths=Ve.map(()=>new Float32Array(288));screenX=new Float32Array;screenY=new Float32Array;screenR=new Float32Array;liftNow=new Float32Array;worldX=new Float32Array;worldY=new Float32Array;morphX=null;morphY=null;morphStart=0;slowWindows=0;chainMask=new Uint8Array;ringLabels=[];sectorOrder=[];selected=-1;selectedSector=-1;hovered=-1;ringFormatter=()=>``;dust;rippleQueue=new Int32Array(48);lateQueue=new Int32Array(24);typeCss;ambientPulses=[];nextAmbientPulse=0;frameTimes=0;frameCount=0;px=0;py=0;ps=1;cx=0;cy=0;unit=1;cosYaw=1;sinYaw=0;cosTilt=1;sinTilt=0;constructor(e,{quality:t=3}={}){this.canvas=e;let n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`canvas 2d unavailable`);this.ctx=n,this.quality=t,this.typeSprites=le.map(e=>Ye(Ue[e])),this.typeCss=le.map(e=>q(Ue[e])),this.emberSprite=Ye(H),this.archiveSprite=Ye(U),this.untrustedSprite=Ye(We),this.pulseSprite=Ye(qe),this.coreSprite=Xe(G),this.discSprite=Xe([206,158,104]),this.pinnedHalo=Xe(Ge),this.dust=new Float32Array(1e3);let r=20261105,i=()=>(r=Math.imul(r,1664525)+1013904223>>>0,r/4294967296);for(let e=0;e<200;e+=1){let t=i()*I,n=.08+Math.sqrt(i())*1.42;this.dust[e*5]=Math.cos(t)*n,this.dust[e*5+1]=Math.sin(t)*n,this.dust[e*5+2]=(i()-.35)*.42,this.dust[e*5+3]=i()*I,this.dust[e*5+4]=.15+i()*.55}}setRingFormatter(e){this.ringFormatter=e,this.refreshLabels()}setScene(e,{animate:t=!1,now:n=0}={}){let r=this.scene,i=this.worldX,a=this.worldY;if(this.scene=e,this.ambientPulses=[],this.morphX=null,this.morphY=null,!e)return!1;let o=!1;if(t&&r&&r.count&&e.count){let t=Float32Array.from(e.x),s=Float32Array.from(e.y),c=0;e.facts.forEach((e,n)=>{let o=r.indexById.get(e.id);o!==void 0&&(t[n]=i[o],s[n]=a[o],c+=1)}),c>=Math.max(1,e.count*.3)&&(this.morphX=t,this.morphY=s,this.morphStart=n,o=!0)}return this.worldX=Float32Array.from(this.morphX??e.x),this.worldY=Float32Array.from(this.morphY??e.y),this.screenX=new Float32Array(e.count),this.screenY=new Float32Array(e.count),this.screenR=new Float32Array(e.count),this.liftNow=new Float32Array(e.count),this.chainMask=new Uint8Array(e.count),this.ringPaths=e.rings.map(e=>{let t=new Float32Array(288);return this.fillRingPath(t,e.rho),t}),this.fillRingPath(this.rimPath,1),this.grainPaths=this.buildGrain(),this.sectorOrder=e.sectors.map((e,t)=>({sector:e,index:t})).filter(({sector:e})=>e.kind===`topic`).sort((e,t)=>t.sector.count-e.sector.count).slice(0,10).map(e=>e.index),this.refreshLabels(),this.setSelection(this.selected<e.count?this.selected:-1),this.hovered=-1,o}buildGrain(){let e=[],t=7;for(let n=.07;n<1;n+=.0115){t=Math.imul(t,1664525)+1013904223>>>0;let r=((t>>>8)/16777216-.5)*.006,i=new Float32Array(144);for(let e=0;e<L;e+=1){let t=e/L*I;i[e*2]=M(t,n+r),i[e*2+1]=N(t,n+r)}e.push({rho:n+r,path:i})}return e}refreshLabels(){this.ringLabels=this.scene?this.scene.rings.map(e=>this.ringFormatter(e.at)):[]}setSelection(e){let{scene:t}=this;if(this.selected=e,this.chainMask.fill(0),this.selectedSector=-1,!t||e<0||e>=t.count){this.selected=-1;return}for(let n of Ae(t,e))this.chainMask[n]=1;this.selectedSector=t.sector[e]}setHover(e){this.hovered=e}resize(e,t,n){let r=Math.max(1,e),i=Math.max(1,t);(r!==this.width||i!==this.height||n!==this.maxDpr)&&(this.width=r,this.height=i,this.maxDpr=n,this.applyResolution())}setInsets(e,{animate:t=!1}={}){this.targetInsets=e,t||(this.insets=e)}get settling(){let{insets:e,targetInsets:t}=this;return e.top!==t.top||e.right!==t.right||e.bottom!==t.bottom||e.left!==t.left}stepInsets(){let e=(e,t)=>Math.abs(t-e)<.5?t:e+(t-e)*.14,{insets:t,targetInsets:n}=this;this.settling&&(this.insets={top:e(t.top,n.top),right:e(t.right,n.right),bottom:e(t.bottom,n.bottom),left:e(t.left,n.left)})}applyResolution(){let e=typeof devicePixelRatio==`number`?devicePixelRatio:1,t=this.quality===1?1:this.maxDpr,n=Math.sqrt(B/(this.width*this.height));this.dpr=Math.max(1,Math.min(e||1,t,n)),this.canvas.width=Math.max(1,Math.round(this.width*this.dpr)),this.canvas.height=Math.max(1,Math.round(this.height*this.dpr)),this.background=this.paintBackground(),this.bloomA=Y(this.canvas.width/4,this.canvas.height/4),this.bloomB=Y(this.canvas.width/10,this.canvas.height/10)}noteFrameInterval(e){if(this.frameTimes+=e,this.frameCount+=1,this.frameCount<45)return;let t=this.frameTimes/this.frameCount;this.frameTimes=0,this.frameCount=0,this.slowWindows=t>30?this.slowWindows+1:0,this.slowWindows>=2&&this.quality>1&&(this.slowWindows=0,--this.quality,this.applyResolution())}paintBackground(){let e=Y(Math.min(1024,this.width),Math.min(1024,this.height)),t=e.getContext(`2d`);if(!t)return e;let{width:n,height:r}=e;t.fillStyle=`#05060a`,t.fillRect(0,0,n,r);let i=this.layoutCenter(),a=t.createRadialGradient(i.x/this.width*n,i.y/this.height*r,0,i.x/this.width*n,i.y/this.height*r,Math.max(n,r)*.72);return a.addColorStop(0,`rgba(30, 27, 32, 0.8)`),a.addColorStop(.42,`rgba(10, 13, 22, 0.7)`),a.addColorStop(1,`rgba(3, 4, 8, 0)`),t.fillStyle=a,t.fillRect(0,0,n,r),e}layoutCenter(){let{top:e,bottom:t,left:n,right:r}=this.insets;return{x:n+(this.width-n-r)/2,y:e+(this.height-e-t)/2}}fillRingPath(e,t){for(let n=0;n<ze;n+=1){let r=n/ze*I;e[n*2]=M(r,t),e[n*2+1]=N(r,t)}}project(e,t,n){let r=e*this.cosYaw-t*this.sinYaw,i=e*this.sinYaw+t*this.cosYaw,a=1/(1-Be*(i*this.sinTilt+n*this.cosTilt));this.px=this.cx+this.unit*r*a,this.py=this.cy+this.unit*(i*this.cosTilt-n*this.sinTilt)*a,this.ps=a}traceRing(e){let{ctx:t}=this;for(let n=0;n<ze;n+=1)this.project(e[n*2],e[n*2+1],0),n===0?t.moveTo(this.px,this.py):t.lineTo(this.px,this.py);t.closePath()}applyCamera(e){let{camera:t}=this;this.stepInsets(),this.cosYaw=Math.cos(t.yaw),this.sinYaw=Math.sin(t.yaw),this.cosTilt=Math.cos(t.tilt),this.sinTilt=Math.sin(t.tilt);let{top:n,bottom:r,left:i,right:a}=this.insets,o=Math.max(40,this.width-i-a),s=Math.max(40,this.height-n-r),c=this.layoutCenter(),l=1+Be*this.sinTilt*.55,u=Math.min(o/(2.08*l),s/(2.08*Math.max(this.cosTilt,.34)*l+.14*this.sinTilt)),d=1+.72*(1-e)**2;this.unit=u*t.zoom*d,this.cx=c.x,this.cy=c.y+this.sinTilt*this.unit*.02;let f=J(e,.35,.75),p=t.rim*f;if(p>0){let t=this.unit*e*this.cosTilt/(1-Be*e*this.sinTilt),r=n+s*.94-t;this.cy+=(Math.min(this.cy,r)-this.cy)*p}}pick(e,t,n,r){let{scene:i}=this;if(!i)return-1;let a=-1,o=n*n;for(let n=0;n<i.count;n+=1){let s=this.screenX[n];if(Number.isNaN(s))continue;let c=s-e,l=this.screenY[n]-t,u=c*c+l*l;(r>=i.replacedAt[n]||r>=i.archivedAt[n])&&(u*=1.8),u<o&&(o=u,a=n)}return a}screenPosition(e){let t=this.screenX[e];return t===void 0||Number.isNaN(t)?null:{x:t,y:this.screenY[e]}}draw(e){let{ctx:t,scene:n,dpr:r}=this;t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,this.background?t.drawImage(this.background,0,0,this.width,this.height):(t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height));let i=n?de(n.domain,e.at):1;this.applyCamera(i),t.globalCompositeOperation=`lighter`,t.lineCap=`round`,t.lineJoin=`round`,this.drawDust(e),n&&(this.stepMorph(n,e),this.drawDiscBody(n,e,i),this.drawNewestBand(e,i),this.drawDigests(n,e,i),this.computePositions(n,e),this.drawThreads(n,e,i),this.drawStems(n,e,i),this.drawFacts(n,e,i),this.drawPulses(n,e),this.drawFrontier(e,i)),this.applyBloom(),t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,n&&this.drawLabels(n,e,i),e.fade<1&&(t.globalAlpha=1-e.fade,t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height),t.globalAlpha=1)}stepMorph(e,t){let{morphX:n,morphY:r}=this;if(!n||!r)return;let i=Math.min(1,Math.max(0,(t.wall-this.morphStart)/z)),a=i*i*(3-2*i);for(let t=0;t<e.count;t+=1)this.worldX[t]=n[t]+(e.x[t]-n[t])*a,this.worldY[t]=r[t]+(e.y[t]-r[t])*a;i>=1&&(this.morphX=null,this.morphY=null)}get morphing(){return this.morphX!==null}drawDust(e){let{ctx:t,dust:n}=this,r=this.quality===3?200:this.quality===2?110:40,i=e.ambient?e.wall*12e-6:0;for(let a=0;a<r;a+=1){let r=a*5,o=.55+a%7*.05,s=Math.cos(i*o),c=Math.sin(i*o),l=n[r]*s-n[r+1]*c,u=n[r]*c+n[r+1]*s;if(this.project(l,u,n[r+2]),this.px<-4||this.py<-4||this.px>this.width+4||this.py>this.height+4)continue;let d=e.ambient?.55+.45*Math.sin(e.wall*7e-4+n[r+3]):.7,f=(.7+n[r+4]*1.1)*this.ps;t.globalAlpha=n[r+4]*d*.5,t.fillStyle=q(a%3==0?Je:K),t.fillRect(this.px-f/2,this.py-f/2,f,f)}t.globalAlpha=1}drawDiscBody(e,t,n){let{ctx:r}=this,i=this.selected>=0?.55:1;this.project(M(0,0),N(0,0),0);let a=this.px,o=this.py,s=1-.72*J(n,.2,.7),c=this.unit*Math.max(n,.1)*1.32;if(r.globalAlpha=.5*s*i,r.drawImage(this.discSprite,this.cx-c,this.cy-c*this.cosTilt,c*2,c*2*this.cosTilt),n<.995&&(r.beginPath(),this.traceRing(this.rimPath),r.globalAlpha=.06,r.strokeStyle=q(W),r.lineWidth=.8,r.stroke()),this.quality>=2){let e=this.quality===3?1:2;r.strokeStyle=q(W),r.lineWidth=.5;let t=n*He;for(let a of[!1,!0]){r.globalAlpha=(a?.075:.03)*e*i,r.beginPath();for(let i=0;i<this.grainPaths.length;i+=e){let{rho:e,path:o}=this.grainPaths[i];if(e>n)break;if(e>=t===a){for(let e=0;e<L;e+=1)this.project(o[e*2],o[e*2+1],0),e===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py);r.closePath()}}r.stroke()}}let{rings:l}=e,u=-1;for(let e=0;e<l.length&&!(l[e].at>t.at);e+=1)u=e;r.fillStyle=q(W);for(let e=0;e<=u;e+=2){let t=l[e];r.beginPath(),this.traceRing(this.ringPaths[e]),e>0&&this.traceRing(this.ringPaths[e-1]),r.globalAlpha=(.012+.03*t.activity)*i*F(t.rho,n),r.fill(`evenodd`)}r.strokeStyle=q(W);for(let e=0;e<=u;e+=1){let t=l[e];r.beginPath(),this.traceRing(this.ringPaths[e]),r.globalAlpha=(.11+.17*t.activity+(t.major?.13:0))*i*F(t.rho,n),r.lineWidth=t.major?1:.65,r.stroke()}let d=this.knownCount(e,t.at),f=t.ambient?1+.08*Math.sin(t.wall*.0011):1,p=this.unit*(.17+.028*Math.log1p(d))*f;r.globalAlpha=.62*s*i,r.drawImage(this.coreSprite,a-p,o-p,p*2,p*2),r.globalAlpha=1}drawNewestBand(e,t){let{ctx:n}=this,r=(e.ambient?.82+.18*Math.sin(e.wall*V):.9)*(e.moving?1.2:1)*(this.selected>=0?.35:1),i=this.quality===1?1:Ve.length;n.fillStyle=q(W),this.fillRingPath(this.frontierPath,t);for(let e=0;e<i;e+=1){let{inner:i,alpha:a}=Ve[e],o=this.bandPaths[e];this.fillRingPath(o,t*i),n.beginPath(),this.traceRing(this.frontierPath),this.traceRing(o),n.globalAlpha=a*r,n.fill(`evenodd`)}n.globalAlpha=1}knownCount(e,t){let n=0,r=e.sortedAppear.length;for(;n<r;){let i=n+r>>1;e.sortedAppear[i]<=t?n=i+1:r=i}return n}drawDigests(e,t,n){let{ctx:r}=this;if(!e.digests.length)return;r.strokeStyle=q(Ge),r.lineWidth=1.25;let i=n*He;for(let n of[!1,!0]){r.globalAlpha=this.selected>=0?.1:n?.34:.14,r.beginPath();for(let a of e.digests){if(a.at>t.at||a.rho>=i!==n)continue;let e=Math.max(4,Math.ceil((a.end-a.start)/I*ze));for(let t=0;t<=e;t+=1){let n=a.start+(a.end-a.start)*t/e;this.project(M(n,a.rho),N(n,a.rho),0),t===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py)}}r.stroke()}r.globalAlpha=1}computePositions(e,t){let{at:n,effectWindow:r}=t,{appearAt:i,replacedAt:a,archivedAt:o,lift:s,count:c}=e,{worldX:l,worldY:u}=this;for(let e=0;e<c;e+=1){if(n<i[e]){this.screenX[e]=NaN;continue}let t=s[e],c=Math.min(a[e],o[e]);if(n>=c){let i=Math.min(1,(n-c)/(r*1.6)),a=i*i*(3-2*i);t=n>=o[e]?s[e]*(1-a)-.035*a:s[e]*(1-a)}this.liftNow[e]=t,this.project(l[e],u[e],t),this.screenX[e]=this.px,this.screenY[e]=this.py,this.screenR[e]=this.ps}}threadControl(e,t){let n=this.worldX[e],r=this.worldY[e],i=this.worldX[t],a=this.worldY[t],o=i-n,s=a-r,c=Math.sqrt(o*o+s*s);this.project((n+i)/2,(r+a)/2,(this.liftNow[e]+this.liftNow[t])/2+.018+c*.46)}drawThreads(e,t,n){let{ctx:r,selected:i,chainMask:a}=this,{at:o}=t;r.strokeStyle=q(Ke),r.lineWidth=.95;let s=n*He;for(let t of[!1,!0]){r.globalAlpha=i>=0?.06:t?.42:.16,r.beginPath();for(let n of e.replacements){if(n.at>o)break;n.to<0||o<e.appearAt[n.to]||i>=0&&a[n.from]&&a[n.to]||e.rho[n.to]>=s===t&&(this.threadControl(n.from,n.to),r.moveTo(this.screenX[n.from],this.screenY[n.from]),r.quadraticCurveTo(this.px,this.py,this.screenX[n.to],this.screenY[n.to]))}r.stroke()}if(i>=0){r.strokeStyle=q(Ge),r.lineWidth=1.5,r.globalAlpha=.8,r.beginPath();for(let t of e.replacements){if(t.at>o)break;t.to<0||o<e.appearAt[t.to]||!a[t.from]||!a[t.to]||(this.threadControl(t.from,t.to),r.moveTo(this.screenX[t.from],this.screenY[t.from]),r.quadraticCurveTo(this.px,this.py,this.screenX[t.to],this.screenY[t.to]))}r.stroke()}r.globalAlpha=1}drawStems(e,t,n){if(this.sinTilt<.2||this.quality<2||this.quality===2&&e.count>800)return;let{ctx:r,selected:i}=this,{at:a}=t,{appearAt:o,replacedAt:s,archivedAt:c,count:l}=e,{worldX:u,worldY:d}=this;r.strokeStyle=q(W),r.lineWidth=.6;let f=n*He;for(let t of[!1,!0]){r.globalAlpha=i>=0?.05:t?.3:.12,r.beginPath();for(let n=0;n<l;n+=1)a<o[n]||a>=s[n]||a>=c[n]||e.rho[n]>=f===t&&(this.project(u[n],d[n],0),r.moveTo(this.px,this.py),r.lineTo(this.screenX[n],this.screenY[n]));r.stroke()}if(this.quality===3&&l<=1500&&i<0){let t=Math.max(.2,this.cosTilt);for(let i=0;i<l;i+=1){if(a<o[i]||a>=s[i]||a>=c[i])continue;this.project(u[i],d[i],0);let l=12*(.5+e.size[i])*this.ps;r.globalAlpha=.2*F(e.rho[i],n),r.drawImage(this.typeSprites[e.typeIndex[i]],this.px-l/2,this.py-l*t/2,l,l*t)}}r.globalAlpha=1}drawFacts(e,t,n){let{ctx:r,selected:i,selectedSector:a,chainMask:o,hovered:s}=this,{at:c,effectWindow:l,wall:u,ambient:d}=t,{appearAt:f,replacedAt:p,archivedAt:m,size:h,brightness:g,phase:ee,typeIndex:te,flags:_,count:v}=e,y=Math.min(1.75,Math.max(.74,(420/Math.max(1,v))**.26)),ne=Math.min(1.35,Math.max(.7,this.unit/330))*y,b=this.quality===3?48:this.quality===2?24:8,re=v>2200||v>800&&this.quality<3?.34:this.quality===1&&v>300?.26:0,x=0,S=0;for(let y=0;y<v;y+=1){if(c<f[y])continue;let v=this.screenX[y],C=this.screenY[y],ie=this.screenR[y],w=1;i>=0&&(w=o[y]?1.3:e.sector[y]===a?.5:.11),y===s&&(w=Math.max(w,1.5)),w*=.62+.42*Math.min(1,Math.max(0,(ie-.84)/.3));let T=i>=0||y===s||_[y]&1?1:F(e.rho[y],n),E=(6+19*h[y])*ne*ie*(.72+.28*T),ae=Math.min(p[y],m[y]);if(c>=m[y]){let e=Math.min(1,(c-m[y])/(l*1.6)),t=E*(.62+.25*(1-e));r.globalAlpha=Math.min(1,(.2*T+.4*(1-e))*w),r.drawImage(this.archiveSprite,v-t/2,C-t/2,t,t);continue}if(c>=ae){let e=Math.min(1,(c-ae)/l),t=d?.82+.18*Math.sin(u*.0016+ee[y]):.9,n=E*(.86+.9*(1-e)*(1-e));if(e<1){r.globalAlpha=Math.min(1,(1-e)*g[y]*w);let t=this.spriteFor(y,te,_);r.drawImage(t,v-n/2,C-n/2,n,n)}r.globalAlpha=Math.min(1,(.62*T+.38*(1-e))*t*w),r.drawImage(this.emberSprite,v-n/2,C-n/2,n,n);continue}let oe=c-f[y],se=oe<l?(1-oe/l)*t.effectGain:0;if(h[y]<re&&se===0&&y!==s&&i<0){let e=1.7*ie;r.globalAlpha=Math.min(1,g[y]*w*T),r.fillStyle=this.typeCss[te[y]],r.fillRect(v-e/2,C-e/2,e,e);continue}let D=.08+.1*T,ce=d?1-D+D*Math.sin(u*.0013+ee[y]):.95,le=g[y]*ce*w*T;_[y]&8&&(le*=.72);let O=E*(1+2.4*se*se);r.globalAlpha=Math.min(1,le+se*.5);let ue=this.spriteFor(y,te,_);if(r.drawImage(ue,v-O/2,C-O/2,O,O),_[y]&1){let e=E*2.9;r.globalAlpha=Math.min(1,.5*w*ce),r.drawImage(this.pinnedHalo,v-e/2,C-e/2,e,e)}se>0&&(x<b&&(this.rippleQueue[x++]=y),_[y]&4&&S<this.lateQueue.length&&(this.lateQueue[S++]=y))}r.globalAlpha=1,this.drawRipples(e,t,x),this.drawLateBeams(e,t,S),this.drawSelectionMarks(e,t)}spriteFor(e,t,n){return n[e]&2?this.untrustedSprite:this.typeSprites[t[e]]}drawRipples(e,t,n){if(!n)return;let{ctx:r}=this;r.lineWidth=1;for(let i=0;i<n;i+=1){let n=this.rippleQueue[i],a=(t.at-e.appearAt[n])/t.effectWindow;if(a<0||a>=1)continue;this.project(this.worldX[n],this.worldY[n],0);let o=this.unit*(.006+.052*Math.sqrt(a))*this.ps;r.globalAlpha=(1-a)*(1-a)*.42*t.effectGain,r.strokeStyle=q(Ue[le[e.typeIndex[n]]]),r.beginPath(),r.ellipse(this.px,this.py,o,o*Math.max(.2,this.cosTilt),0,0,I),r.stroke()}r.globalAlpha=1}drawLateBeams(e,t,n){if(!n)return;let{ctx:r}=this,i=de(e.domain,t.at);r.strokeStyle=q(Ge),r.lineWidth=1.2;for(let a=0;a<n;a+=1){let n=this.lateQueue[a],o=(t.at-e.appearAt[n])/t.effectWindow;if(o<0||o>=1)continue;let s=e.theta[n];this.project(M(s,i),N(s,i),0),r.globalAlpha=(1-o)*.8*t.effectGain,r.beginPath(),r.moveTo(this.px,this.py),r.lineTo(this.screenX[n],this.screenY[n]),r.stroke()}r.globalAlpha=1}drawSelectionMarks(e,t){let{ctx:n,selected:r,hovered:i,chainMask:a}=this,o=(r,i,a)=>{r<0||r>=e.count||t.at<e.appearAt[r]||(n.globalAlpha=a,n.beginPath(),n.arc(this.screenX[r],this.screenY[r],i,0,I),n.stroke())};if(n.strokeStyle=q(Ge),n.lineWidth=1,r>=0)for(let t=0;t<e.count;t+=1)a[t]&&o(t,t===r?12:7,t===r?.95:.55);i>=0&&i!==r&&o(i,9,.7),n.globalAlpha=1}drawPulseAlong(e,t,n,r){let{ctx:i}=this;this.threadControl(e,t);let a=this.px,o=this.py,s=this.screenX[e],c=this.screenY[e],l=this.screenX[t],u=this.screenY[t],d=e=>{let t=1-e;this.px=t*t*s+2*t*e*a+e*e*l,this.py=t*t*c+2*t*e*o+e*e*u},f=Math.min(1,n*1.3),p=Math.max(0,f-.42),m=r*(n>.75?(1-n)/.25:1);i.strokeStyle=q(qe);for(let e=0;e<9;e+=1){let t=p+(f-p)*e/9,n=p+(f-p)*(e+1)/9;d(t);let r=this.px,a=this.py;d(n),i.globalAlpha=Math.min(1,((e+1)/9)**2*m),i.lineWidth=.7+1.5*((e+1)/9),i.beginPath(),i.moveTo(r,a),i.lineTo(this.px,this.py),i.stroke()}d(f);let h=20*Math.min(1.2,this.unit/300);i.globalAlpha=Math.min(1,m),i.drawImage(this.pulseSprite,this.px-h/2,this.py-h/2,h,h)}drawPulses(e,t){let{at:n,effectWindow:r,wall:i,ambient:a}=t,{replacements:o}=e;if(!o.length)return;let s=this.quality===3?36:this.quality===2?18:6,c=0,l=o.length;for(;c<l;){let e=c+l>>1;o[e].at<=n?c=e+1:l=e}let u=c,d=r*1.8,f=0;for(let r=u-1;r>=0&&f<s;--r){let i=o[r],a=(n-i.at)/d;if(a>=1)break;i.to<0||n<e.appearAt[i.to]||(t.effectGain>.02&&this.drawPulseAlong(i.from,i.to,a,t.effectGain),f+=1)}if(!a){this.ctx.globalAlpha=1;return}if(this.selected>=0){let e=0;for(let t of o){if(t.to<0||t.at>n||!this.chainMask[t.from]||!this.chainMask[t.to])continue;let r=((i*45e-5+e*.27)%1+1)%1;this.drawPulseAlong(t.from,t.to,r,.9),e+=1}}else if(u){if(i>=this.nextAmbientPulse&&this.ambientPulses.length<3){this.nextAmbientPulse=i+650+(Math.sin(i)+1)*500;let e=Math.floor(Math.abs(Math.sin(i*12.9898))*u)%u;this.ambientPulses.push({replacement:e,start:i})}for(let t=this.ambientPulses.length-1;t>=0;--t){let r=this.ambientPulses[t],a=(i-r.start)/1900,s=o[r.replacement];if(a>=1||!s||s.at>n){this.ambientPulses.splice(t,1);continue}s.to<0||n<e.appearAt[s.to]||this.drawPulseAlong(s.from,s.to,a,.55)}}this.ctx.globalAlpha=1}drawFrontier(e,t){let{ctx:n}=this,r=this.frontierPath;n.strokeStyle=q(Ge);let i=e.ambient?.78+.22*Math.sin(e.wall*V):.85,a=(e.moving?1.1:i)*(this.selected>=0?.5:1),o=this.quality===1?1:3;for(let e=0;e<o;e+=1)n.beginPath(),this.traceRing(r),e===o-1?(n.lineWidth=1.1,n.globalAlpha=.72*a):e===0?(n.lineWidth=9,n.globalAlpha=.035*a):(n.lineWidth=3.6,n.globalAlpha=.09*a),n.stroke();if(e.ambient&&this.quality>=2){let r=Math.min(46,this.unit*.11)*(e.moving?1.25:1);for(let i=0;i<3;i+=1){let o=e.wall*17e-5*(i===1?-1:1)+i*2.1;this.project(M(o,t),N(o,t),0),n.globalAlpha=(.32+.3*Math.max(0,Math.sin(e.wall*6e-4+i*2)))*a,n.drawImage(this.pulseSprite,this.px-r/2,this.py-r/2,r,r)}}n.globalAlpha=1}applyBloom(){let{ctx:e,canvas:t}=this;if(this.quality<2||!this.bloomA)return;let n=this.bloomA.getContext(`2d`);if(n){if(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(t,0,0,this.bloomA.width,this.bloomA.height),e.setTransform(1,0,0,1,0,0),e.imageSmoothingEnabled=!0,e.globalCompositeOperation=`lighter`,e.globalAlpha=.34,e.drawImage(this.bloomA,0,0,t.width,t.height),this.quality>=3&&this.bloomB){let n=this.bloomB.getContext(`2d`);n&&(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(this.bloomA,0,0,this.bloomB.width,this.bloomB.height),e.globalAlpha=.3,e.drawImage(this.bloomB,0,0,t.width,t.height))}e.globalAlpha=1}}drawLabels(e,t,n){let{ctx:r}=this;if(this.width<280||!e.count)return;r.textBaseline=`middle`,r.textAlign=`left`,r.font=`10.5px ui-sans-serif, system-ui, sans-serif`;let i=this.selected>=0?.45:1,a=Math.PI*.2-this.camera.yaw,o=1/0,s=1/0;for(let c=e.rings.length-1;c>=0;--c){let l=e.rings[c];if(l.at>t.at||!l.major||(this.project(M(a,l.rho),N(a,l.rho),0),Math.hypot(this.px-o,this.py-s)<34))continue;o=this.px,s=this.py,r.globalAlpha=.62*i*F(l.rho,n),r.fillStyle=q(W);let u=this.ringLabels[c]||``;r.fillText(u,Math.min(this.px+4,this.width-8-r.measureText(u).width),this.py)}let c=Math.min(1.09,n+.07),l=Math.min(1.14,n+.12);if(this.width>=560&&n>.32){r.textAlign=`center`;for(let t of this.sectorOrder){let i=e.sectors[t],a=(i.start+i.end)/2;if(e.spaceArcs.some(e=>e.name.includes(i.label)))continue;this.project(M(a,c),N(a,c),0);let o=(.14+.5*Math.min(1,Math.max(0,(this.ps-.86)/.24)))*Math.min(1,(n-.32)*4);this.selected>=0&&(o=t===this.selectedSector?.95:.1),r.globalAlpha=o,r.fillStyle=q(W),r.fillText(i.label.slice(0,18),this.px,this.py)}}if(e.spaceArcs.length){r.textAlign=`center`;for(let t of e.spaceArcs){let e=Math.max(6,Math.ceil((t.end-t.start)/I*ze));r.beginPath();for(let n=0;n<=e;n+=1){let i=t.start+(t.end-t.start)*n/e;this.project(M(i,l),N(i,l),0),n===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py)}r.strokeStyle=q(W),r.lineWidth=1,r.globalAlpha=.34*i,r.stroke();let n=(t.start+t.end)/2;this.project(M(n,l+.035),N(n,l+.035),0),r.globalAlpha=.72*i,r.fillStyle=q(Ge),r.fillText(t.name.slice(0,22),this.px,this.py)}}r.globalAlpha=1}};function Qe(e,t,n,r,i){let a=e.getContext(`2d`);if(!a)return;let o=Math.min((typeof devicePixelRatio==`number`?devicePixelRatio:1)||1,2),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o));(e.width!==s||e.height!==c)&&(e.width=s,e.height=c),a.setTransform(o,0,0,o,0,0),a.clearRect(0,0,r,i);let{histogram:l,histogramReplacements:u,domain:d}=t,f=l.length,p=Math.max(1,d.end-d.start),m=Math.min(1,Math.max(0,(n-d.start)/p))*r,h=1;for(let e=0;e<f;e+=1)h=Math.max(h,l[e]);let g=r/f,ee=i-5;for(let e=0;e<f;e+=1){let t=l[e],n=e*g,r=n+g/2<=m;if(t){let e=Math.max(1.5,Math.sqrt(t/h)*ee);a.fillStyle=r?q(W,.78):q(W,.2),a.fillRect(n+.5,i-e,Math.max(1,g-1),e)}if(u[e]){let t=Math.min(ee,3+u[e]*1.5);a.fillStyle=r?q(H,.95):q(H,.34),a.fillRect(n+g/2-.75,0,1.5,t)}}}var X=n(),$e=400,et=540,tt=880,nt=16,rt={colorScheme:`dark`,"--text":`rgba(246, 240, 228, 0.96)`,"--foreground":`rgba(246, 240, 228, 0.96)`,"--text-soft":`rgba(246, 240, 228, 0.86)`,"--text-secondary":`rgba(240, 232, 218, 0.74)`,"--text-muted":`rgba(232, 224, 208, 0.58)`,"--text-faint":`rgba(232, 224, 208, 0.38)`,"--surface-hover":`rgba(255, 244, 224, 0.1)`,"--surface-active":`rgba(255, 244, 224, 0.17)`,"--surface-muted":`rgba(255, 244, 224, 0.07)`,"--surface-subtle":`rgba(255, 244, 224, 0.1)`,"--stroke":`rgba(255, 244, 224, 0.13)`,"--stroke-soft":`rgba(255, 244, 224, 0.08)`,"--stroke-strong":`rgba(255, 244, 224, 0.22)`,"--solid":`rgba(255, 244, 224, 0.14)`,"--star":`rgba(255, 232, 192, 0.92)`,"--star-hover":`rgba(255, 240, 214, 1)`,"--key-bg":`rgba(255, 240, 214, 1)`,"--key-border":`rgba(255, 244, 224, 0.2)`,"--key-shadow":`0 0 14px rgba(255, 214, 150, 0.55)`,"--control-border":`rgba(255, 240, 214, 0.9)`,"--focus":`rgba(255, 222, 170, 1)`,"--focus-ring":`rgba(255, 222, 170, 0.32)`,"--danger":`rgba(255, 150, 130, 1)`,"--evo-panel":`rgba(13, 14, 19, 0.74)`,"--evo-line":`rgba(255, 244, 224, 0.13)`,"--evo-scrim":`rgba(5, 6, 10, 0.86)`,"--evo-scrim-clear":`rgba(5, 6, 10, 0)`,"--evo-base":`rgba(5, 6, 10, 1)`,"--evo-active":`rgba(255, 232, 192, 1)`},it=q(H),at=q(U),ot=24e3,st=[`0.5`,`1`,`2`],ct=-.38,lt=.94,ut=.68,dt=.24,ft=26e-6,pt=450,mt=2e4,ht=Math.PI*.62,gt=320,_t=30,vt=30,yt=7,bt=!1;function xt(e){let t=navigator.deviceMemory;return t!==void 0&&t<=2?1:e||t!==void 0&&t<=4?2:3}function St(e){let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)}var Ct=e=>e instanceof Error?e.message:String(e),wt=e=>e instanceof DOMException&&e.name===`AbortError`;function Tt({spaceId:e,refreshKey:t=0,selectedId:n=null,onSelect:i}){let{t:x,language:S}=r(),[C,ie]=(0,b.useState)(null),[w,T]=(0,b.useState)(!0),[E,ae]=(0,b.useState)(``),[oe,se]=(0,b.useState)(0),[D,ce]=(0,b.useState)(0),[O,ue]=(0,b.useState)(0),[k,A]=(0,b.useState)(!1),[de,fe]=(0,b.useState)(`1`),[j,pe]=(0,b.useState)(null),[M,N]=(0,b.useState)(null),[me,he]=(0,b.useState)(null),[ge,_e]=(0,b.useState)(0),[ve,ye]=(0,b.useState)(0),be=(0,b.useRef)(null),P=(0,b.useRef)(null),xe=(0,b.useRef)(null),Se=(0,b.useRef)(null),Ce=(0,b.useRef)(null),we=(0,b.useRef)(null),Ee=(0,b.useRef)(null),Oe=(0,b.useRef)(null),F=(0,b.useRef)(null),I=(0,b.useRef)(null),ze=(0,b.useRef)(-1),L=(0,b.useRef)(-1),Be=(0,b.useRef)(`1`),R=(0,b.useRef)(0),z=(0,b.useRef)(0),B=(0,b.useRef)(`idle`),Ve=(0,b.useRef)(0),V=(0,b.useRef)(1),He=(0,b.useRef)(0),H=(0,b.useRef)(!0),U=(0,b.useRef)(0),We=(0,b.useRef)(!1),W=(0,b.useRef)(0),Ge=(0,b.useRef)(0),Ke=(0,b.useRef)(0),qe=(0,b.useRef)(0),G=(0,b.useRef)(ct),K=(0,b.useRef)(lt),Je=(0,b.useRef)(!1),J=(0,b.useRef)(null),Y=(0,b.useRef)(1),Ye=(0,b.useRef)(1),Xe=(0,b.useRef)(!1),Tt=(0,b.useRef)(null),Et=(0,b.useRef)(null),Dt=(0,b.useRef)(()=>{}),Ot=(0,b.useRef)(null),kt=(0,b.useRef)(!1),{ref:At,playing:jt}=re(),Mt=(0,b.useCallback)(e=>{P.current=e,At(e)},[At]),Nt=(0,b.useCallback)((e=!1)=>{if(!I.current)return;let t=performance.now();!e&&t-Ke.current<33||(Ke.current=t,ce(R.current))},[]),Pt=(0,b.useCallback)(e=>{U.current=0;let t=F.current;if(!t)return;let n=I.current,r=kt.current,i=W.current?Math.min(64,e-W.current):16;W.current=e;let a=!1;if(n){let{start:e,end:o}=n.domain,s=Math.max(1,o-e);if(B.current===`opening`){Ve.current+=i;let n=Re(Ve.current);R.current=e+s*n,t.camera.tilt=dt+(K.current-dt)*St(n*1.15),t.camera.yaw=G.current-1.3*(1-n)**2,a=!0,Ve.current>=6e3&&(R.current=o,B.current=`idle`,A(!1),Nt(!0))}else B.current===`play`&&(R.current+=i*s*Number(Be.current)/ot,a=!0,R.current>=o&&(R.current=o,B.current=`idle`,A(!1),Nt(!0)));let c=z.current,l=R.current-c;B.current!==`idle`||Math.abs(l)<s*2e-4?z.current=R.current:z.current=c+l*(1-Math.exp(-i/85)),z.current!==c&&(a=!0);let u=Math.abs(z.current-c)/Math.max(1,i),d=Math.min(s*.08,Math.max(s*.002,u*520)),f=d>V.current?90:420;r?V.current=s*.002:(V.current+=(d-V.current)*(1-Math.exp(-i/f)),Math.abs(d-V.current)>s*2e-4&&(a=!0))}let o=!!(Ot.current?.moved||Tt.current);if(!r&&!o&&B.current!==`opening`&&L.current<0&&ze.current<0&&(G.current+=i*ft),J.current!==null&&!o){let e=Math.atan2(Math.sin(J.current-G.current),Math.cos(J.current-G.current));Math.abs(e)<.002||r?(G.current=J.current,J.current=null):(G.current+=e*(1-Math.exp(-i/240)),a=!0)}let s=ze.current>=0,c=s?Pe(Y.current,Ye.current):Y.current,l=s?0:Ne(Y.current);if((Math.abs(t.camera.zoom-c)>.001||Math.abs(t.camera.rim-l)>.001)&&!r){let e=1-Math.exp(-i/(Tt.current?50:240));t.camera.zoom+=(c-t.camera.zoom)*e,t.camera.rim+=(l-t.camera.rim)*e,a=!0}else t.camera.zoom=c,t.camera.rim=l;t.settling&&(a=!0),B.current!==`opening`&&(t.camera.yaw=G.current);let u=Math.min(1,(e-He.current)/pt);(a||o)&&(qe.current=e);let d=e-qe.current>mt?66:t.quality===3?32:48;(a||H.current||o||u<1||t.morphing||!r&&e-Ge.current>=d)&&(t.draw({at:z.current,wall:e,effectWindow:V.current,effectGain:n?Math.min(1,Math.max(0,(V.current/(Math.max(1,n.domain.end-n.domain.start)*.002)-1.05)/1.6)):0,ambient:!r,fade:r?1:u,moving:B.current!==`idle`||o}),Ge.current=e,H.current=!1),r||t.noteFrameInterval(i),a&&Nt(),We.current&&(!r||a||u<1||H.current||t.morphing)?U.current=requestAnimationFrame(Pt):a||Nt(!0)},[Nt]),Z=(0,b.useCallback)(()=>{H.current=!0,We.current&&!U.current&&(U.current=requestAnimationFrame(Pt))},[Pt]),Ft=(0,b.useCallback)(()=>{let e=P.current;e&&(Ye.current=Me(e.clientWidth,I.current?.count??0),!Xe.current&&(Y.current=Ye.current,e.setAttribute(`data-zoom`,Y.current.toFixed(2))))},[]),It=(0,b.useCallback)(e=>{let t=je(e);Xe.current=!0,Y.current=t,P.current?.setAttribute(`data-zoom`,t.toFixed(2)),Z()},[Z]),Lt=(0,b.useCallback)(()=>{let e=F.current;B.current===`opening`&&e&&(e.camera.tilt=K.current,e.camera.yaw=G.current),B.current!==`idle`&&(B.current=`idle`,A(!1))},[]),Rt=(0,b.useCallback)(e=>{let t=I.current;t&&(Lt(),R.current=Math.min(t.domain.end,Math.max(t.domain.start,e)),Nt(!0),Z())},[Nt,Lt,Z]),zt=(0,b.useCallback)(()=>{let e=I.current;if(!e||!e.count)return;if(B.current!==`idle`){Lt(),Nt(!0),Z();return}let{start:t,end:n}=e.domain;R.current>=n-(n-t)*.002&&(R.current=t,z.current=t),B.current=`play`,A(!0),Z()},[Nt,Lt,Z]);(0,b.useLayoutEffect)(()=>{let e=be.current;if(!e)return;let t=e.closest(`[data-feature-scroller]`);if(!t)return;let n=()=>{let n=t.clientWidth,r=Math.min(n-(n<=650?0:24)*2,1280),i=e.clientWidth;he(r>i?{width:r,offset:(i-r)/2}:{width:i,offset:0});let a=P.current;if(a){let e=a.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop,r=t.clientHeight-e-nt;_e(Math.round(Math.min(tt,Math.max(n<=650?et:$e,r))))}};n();let r=new ResizeObserver(n);return r.observe(t),r.observe(e),()=>r.disconnect()},[]),(0,b.useLayoutEffect)(()=>{let e=xe.current;if(!e)return;let t=matchMedia(`(pointer: coarse)`).matches;kt.current=_();let n;try{n=new Ze(e,{quality:xt(t)})}catch{return}n.camera.yaw=G.current,F.current=n;let r=(e=!1)=>{let r=P.current;if(!r)return;let i=r.clientWidth,a=r.clientHeight,o=i>=720,s=Se.current?.offsetHeight??0,c=we.current?.offsetHeight??0;r.style.setProperty(`--evo-controls`,`${c}px`),Je.current||(K.current=o?lt:ut,B.current!==`opening`&&(n.camera.tilt=K.current)),Ft(),n.resize(i,a,t?1.5:2);let l=o?0:Ce.current?.offsetHeight??0;n.setInsets({top:o?18:s+10,bottom:c+4+(l?l+4:0),left:o?28:6,right:o?28:6},{animate:e&&!kt.current}),H.current=!0,We.current&&(U.current&&cancelAnimationFrame(U.current),U.current=0,Pt(performance.now()))};r(),Dt.current=r;let i=new ResizeObserver(()=>r());return P.current&&i.observe(P.current),Se.current&&i.observe(Se.current),we.current&&i.observe(we.current),()=>{i.disconnect(),F.current=null}},[Ft,Pt]),(0,b.useEffect)(()=>(We.current=jt,jt&&(W.current=0,Z()),()=>{We.current=!1,U.current&&cancelAnimationFrame(U.current),U.current=0}),[jt,Z]),(0,b.useEffect)(()=>{let e=xe.current;if(!e)return;let t=e=>{!e.ctrlKey&&!e.metaKey||(e.preventDefault(),F.current&&It(Y.current*Math.exp(-e.deltaY*.0022)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[It]),(0,b.useEffect)(()=>{let e=xe.current;if(!e)return;let t=e=>{Tt.current=e.length>=2?{spread:Math.hypot(e[0].clientX-e[1].clientX,e[0].clientY-e[1].clientY),zoom:Y.current}:null},n=e=>{e.targetTouches.length<2||e.cancelable&&(e.preventDefault(),Ot.current=null,t(e.targetTouches),B.current===`opening`&&Lt(),Z())},r=e=>{let t=Tt.current;if(!t||e.targetTouches.length<2)return;e.cancelable&&e.preventDefault();let[n,r]=[e.targetTouches[0],e.targetTouches[1]];It(Fe(t.zoom,t.spread,Math.hypot(n.clientX-r.clientX,n.clientY-r.clientY)))},i=e=>{Tt.current&&t(e.targetTouches)},a=new AbortController,o={passive:!1,signal:a.signal};return e.addEventListener(`touchstart`,n,o),e.addEventListener(`touchmove`,r,o),e.addEventListener(`touchend`,i,{signal:a.signal}),e.addEventListener(`touchcancel`,i,{signal:a.signal}),()=>{a.abort(),Tt.current=null}},[It,Lt,Z]),(0,b.useEffect)(()=>{let t=new AbortController;return T(!0),ae(``),v(e,t.signal).then(e=>{t.signal.aborted||(ie(Te(e)),T(!1))}).catch(e=>{t.signal.aborted||wt(e)||(ae(Ct(e)),T(!1))}),()=>t.abort()},[e,t,oe]);let Bt=(0,b.useMemo)(()=>{let e=C?.unit===`day`||C?.unit===`week`?{month:`short`,day:`numeric`}:{year:`numeric`,month:`short`};return new Intl.DateTimeFormat(S,e)},[S,C?.unit]),Vt=(0,b.useMemo)(()=>new Intl.DateTimeFormat(S,{year:`numeric`,month:`long`,day:`numeric`}),[S]),Ht=(0,b.useMemo)(()=>new Intl.DateTimeFormat(S,{year:`numeric`,month:`2-digit`,day:`2-digit`}),[S]);(0,b.useEffect)(()=>{let e=F.current;e&&(e.setRingFormatter(e=>Bt.format(e)),H.current=!0)},[Bt]),(0,b.useEffect)(()=>{if(!C)return;let e=I.current,t=F.current,{start:n,end:r}=C.domain,i=r;if(e){let t=e.domain.end-e.domain.start;R.current>=e.domain.end-t*.002||(i=Math.min(r,Math.max(n,R.current))),B.current!==`idle`&&(B.current=`idle`,A(!1))}else!bt&&!kt.current&&C.count>0&&(bt=!0,B.current=`opening`,Ve.current=0,i=n,A(!0));I.current=C,R.current=i,z.current=i,V.current=(r-n)*.002;let a=performance.now();t?.setScene(C,{animate:!!e&&!kt.current,now:a})||(He.current=a),Ft(),!e&&t&&(t.camera.zoom=Y.current,t.camera.rim=Ne(Y.current)),ce(i),ue(i),pe(null),L.current=-1,Z()},[C,Ft,Z]);let Q=(0,b.useMemo)(()=>!C||!n?-1:C.indexById.get(n)??-1,[C,n]);(0,b.useEffect)(()=>{let e=F.current;ze.current=Q,e?.setSelection(Q);let t=I.current;t&&Q>=0?(J.current=ht-t.theta[Q],R.current<t.appearAt[Q]&&Rt(t.appearAt[Q])):J.current=null,Z()},[Rt,Q,Z]),(0,b.useEffect)(()=>{if(N(null),!n)return;let e=new AbortController;return y(n,e.signal).then(t=>{e.signal.aborted||N(t)}).catch(()=>{}),()=>e.abort()},[n,t]);let Ut=(0,b.useMemo)(()=>C&&Q>=0?Ae(C,Q):[],[C,Q]);(0,b.useLayoutEffect)(()=>{Dt.current(!0),Z()},[Ut,M,Z]),(0,b.useEffect)(()=>{if(!n)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role="dialog"], [data-slot="popover-content"]`)||i(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]),(0,b.useEffect)(()=>{if(k)return;let e=window.setTimeout(()=>ue(D),700);return()=>window.clearTimeout(e)},[D,k]),(0,b.useEffect)(()=>{let e=Oe.current;if(!e)return;let t=new ResizeObserver(()=>ye(e.clientWidth));return t.observe(e),ye(e.clientWidth),()=>t.disconnect()},[]),(0,b.useEffect)(()=>{let e=Ee.current;!e||!C||!ve||Qe(e,C,D,ve,vt)},[D,ve,C]);let Wt=(0,b.useMemo)(()=>C?ke(C,D):{active:0,superseded:0,archived:0,known:0},[D,C]),Gt=(0,b.useMemo)(()=>C?ke(C,O):Wt,[O,C,Wt]),$=!!C?.count,Kt=!C||D>=C.domain.end-(C.domain.end-C.domain.start)*.002,qt=C?Vt.format(D):``,Jt=x(`memory:memoryEvolution.stageLabel`,{date:C?Vt.format(O):``,active:Gt.active,superseded:Gt.superseded,archived:Gt.archived}),Yt=e=>x(e===`decision`?`memory:memoryEvolution.typeDecision`:e===`preference`?`memory:memoryEvolution.typePreference`:e===`fact`?`memory:memoryEvolution.typeFact`:e===`risk`?`memory:memoryEvolution.typeRisk`:e===`file`?`memory:memoryEvolution.typeFile`:e===`task`?`memory:memoryEvolution.typeTask`:`memory:memoryEvolution.typeConcept`),Xt=e=>x(e===`superseded`?`memory:memoryEvolution.superseded`:e===`archived`?`memory:memoryEvolution.archived`:e===`hidden`?`memory:memoryEvolution.notYet`:`memory:memoryEvolution.active`),Zt=e=>{let t=e.target,n=!!t.closest(`[data-slot="segmented-control"], [data-slot="popover-content"]`);if(e.key===` `){if(t.closest(`button, a, [role="radio"]`))return;e.preventDefault(),zt();return}let r=I.current;if(!r||!r.count||n)return;let i=(r.domain.end-r.domain.start)*(e.shiftKey?.05:.01),a=null;e.key===`ArrowLeft`?a=R.current-i:e.key===`ArrowRight`?a=R.current+i:e.key===`Home`?a=r.domain.start:e.key===`End`&&(a=r.domain.end),a!==null&&(e.preventDefault(),e.stopPropagation(),Rt(a))},Qt=e=>{e.button!==0||!e.isPrimary||(Ot.current={id:e.pointerId,x:e.clientX,y:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId))},$t=e=>{let t=F.current;if(!t)return;let n=Ot.current;if(n&&n.id===e.pointerId){let r=e.clientX-n.lastX,i=e.clientY-n.lastY;if(!n.moved&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<5)return;n.moved=!0,J.current=null,n.lastX=e.clientX,n.lastY=e.clientY,G.current+=r*.0062,e.pointerType===`mouse`&&(Je.current=!0,K.current=Math.min(1.16,Math.max(0,K.current-i*.0042)),t.camera.tilt=K.current),B.current===`opening`&&Lt(),L.current=-1,t.setHover(-1),pe(null),Z();return}if(e.pointerType!==`mouse`)return;let r=e.currentTarget.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=t.pick(i,a,15,z.current);o!==L.current&&(L.current=o,t.setHover(o),Z()),pe(o>=0?{index:o,x:i,y:a}:null)},en=e=>{let t=Ot.current;Ot.current=null;let n=F.current;if(!n||!I.current||!t||t.moved)return;if(e.pointerType!==`mouse`){let t=Et.current,n=t!==null&&e.timeStamp-t.at<gt&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<_t;if(Et.current=n?null:{at:e.timeStamp,x:e.clientX,y:e.clientY},n){nn();return}}let r=e.currentTarget.getBoundingClientRect(),a=n.pick(e.clientX-r.left,e.clientY-r.top,e.pointerType===`mouse`?16:28,z.current);i(a>=0?I.current.facts[a].id:null)},tn=()=>{L.current>=0&&(L.current=-1,F.current?.setHover(-1),Z()),pe(null)},nn=()=>{let e=F.current;e&&(It(Ye.current),Xe.current=!1,Je.current=!1,K.current=(P.current?.clientWidth??800)>=720?lt:ut,e.camera.tilt=K.current,Z())},rn=j&&C?C.facts[j.index]:null,an=(0,b.useMemo)(()=>{let e=new Map;M?.item&&e.set(M.item.id,M.item.content);for(let t of M?.history||[])e.set(t.id,t.content);return e},[M]),on=e=>(0,X.jsx)(p,{size:`sm`,className:e,"aria-label":x(`memory:memoryEvolution.speed`),value:de,onValueChange:e=>{Be.current=e,fe(e)},options:st.map(e=>({value:e,label:`${e}×`}))}),sn=me?.width??null,cn=(()=>{if(!j)return;let e=P.current?.clientWidth??800,t=P.current?.clientHeight??600;return{left:Math.min(e-272,j.x+16),...j.y>t-150?{bottom:t-j.y+16}:{top:j.y+16}}})();return(0,X.jsx)(`div`,{ref:be,className:`min-w-0`,children:(0,X.jsxs)(`div`,{ref:Mt,role:`group`,"aria-label":x(`memory:memoryEvolution.regionLabel`),"data-memory-evolution":!0,"data-at":C?new Date(D).toISOString():void 0,"data-active-count":Wt.active,"data-playing":k||void 0,onKeyDownCapture:Zt,style:{...rt,...sn?{width:sn,marginLeft:me?.offset??0}:{},...ge?{height:ge}:{}},className:`@container relative isolate h-[clamp(560px,calc(100dvh-196px),880px)] overflow-hidden rounded-xl bg-[var(--evo-base)] text-content select-none max-[650px]:h-[clamp(540px,calc(100dvh-132px),780px)] max-[650px]:rounded-none`,children:[(0,X.jsx)(`canvas`,{ref:xe,role:`img`,"aria-label":Jt,tabIndex:0,onPointerDown:Qt,onPointerMove:$t,onPointerUp:en,onPointerCancel:()=>{Ot.current=null},onPointerLeave:tn,onDoubleClick:nn,className:`absolute inset-0 size-full cursor-grab touch-pan-y outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset active:cursor-grabbing`}),(0,X.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,role:`status`,children:C&&!k?Jt:``}),(0,X.jsxs)(`div`,{ref:Se,className:`pointer-events-none absolute top-5 left-6 z-10 flex max-w-[min(70%,420px)] flex-col gap-1.5 @max-[719px]:top-3.5 @max-[719px]:right-4 @max-[719px]:left-4 @max-[719px]:max-w-none`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2.5`,children:[$&&(0,X.jsx)(`span`,{"data-memory-evolution-date":!0,className:`text-[30px] leading-9 font-light tracking-[-0.015em] text-content tabular-nums @max-[719px]:text-2xl @max-[719px]:leading-8`,children:qt}),$&&Kt&&(0,X.jsx)(`span`,{className:`text-xs text-[var(--evo-active)]`,children:x(`memory:memoryEvolution.now`)})]}),$&&(0,X.jsxs)(`dl`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-content-muted tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-[var(--evo-active)] shadow-[0_0_8px_var(--evo-active)]`}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.active`)}),(0,X.jsx)(`dd`,{"data-memory-evolution-active":!0,className:`font-medium text-content`,children:Wt.active})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:it,boxShadow:`0 0 8px ${it}`}}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.superseded`)}),(0,X.jsx)(`dd`,{className:`font-medium text-content`,children:Wt.superseded})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:at}}),(0,X.jsx)(`dt`,{children:x(`memory:memoryEvolution.archived`)}),(0,X.jsx)(`dd`,{className:`font-medium text-content`,children:Wt.archived})]})]}),C?.truncated&&(0,X.jsx)(`p`,{className:`m-0 text-xs text-content-faint`,children:x(`memory:memoryEvolution.truncated`,{count:C.count})}),E&&C&&(0,X.jsx)(`p`,{className:`m-0 text-xs text-danger`,children:E})]}),$&&Q<0&&(0,X.jsx)(`ul`,{"aria-label":x(`memory:memoryEvolution.legend`),className:`pointer-events-none absolute top-1/2 right-6 z-10 hidden -translate-y-[62%] list-none flex-col gap-1.5 p-0 text-[11px] text-content-muted @min-[880px]:flex`,children:le.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-end gap-2`,children:[Yt(e),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:q(Ue[e]),boxShadow:`0 0 7px ${q(Ue[e])}`}})]},e))}),$&&(0,X.jsx)(`div`,{className:`absolute top-3.5 right-4 z-10 @max-[719px]:top-2.5 @max-[719px]:right-2.5`,children:(0,X.jsxs)(d,{children:[(0,X.jsx)(l,{asChild:!0,children:(0,X.jsx)(g,{variant:`ghost`,size:`icon-sm`,"aria-label":x(`memory:memoryEvolution.howToRead`),title:x(`memory:memoryEvolution.howToRead`),children:(0,X.jsx)(a,{"aria-hidden":`true`})})}),(0,X.jsxs)(u,{align:`end`,className:`w-80 gap-2 text-xs`,children:[(0,X.jsx)(`p`,{className:`m-0 leading-relaxed`,children:x(`memory:memoryEvolution.howToReadBody`)}),(0,X.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-2 gap-x-3 gap-y-1 p-0`,children:le.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 text-content-secondary`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:q(Ue[e])}}),Yt(e)]},e))}),(0,X.jsx)(`p`,{className:`m-0 leading-relaxed text-content-muted`,children:x(`memory:memoryEvolution.gestures`)})]})]})}),rn&&j&&C&&j.index!==Q&&(0,X.jsxs)(`div`,{role:`tooltip`,"data-memory-evolution-tooltip":!0,style:cn,className:`pointer-events-none absolute z-20 flex w-max max-w-64 flex-col gap-0.5 rounded-md border border-[var(--evo-line)] bg-[var(--evo-panel)] px-2.5 py-1.5 text-xs backdrop-blur-md`,children:[(0,X.jsx)(`strong`,{className:`line-clamp-2 font-medium text-content`,children:rn.title}),(0,X.jsxs)(`span`,{className:`text-content-muted tabular-nums`,children:[Yt(rn.type),` · `,Ht.format(C.validAt[j.index]),` ·`,` `,Xt(De(C,j.index,D))]}),!!(C.flags[j.index]&4)&&(0,X.jsx)(`span`,{className:`text-content-muted tabular-nums`,children:x(`memory:memoryEvolution.learnedLate`,{date:Ht.format(C.appearAt[j.index])})})]}),C&&Q>=0&&(0,X.jsxs)(`section`,{ref:Ce,"data-memory-evolution-card":!0,"aria-label":C.facts[Q].title,className:`absolute top-14 right-4 z-20 flex max-h-[calc(100%-230px)] w-[320px] flex-col gap-2 overflow-y-auto rounded-lg border border-[var(--evo-line)] bg-[var(--evo-panel)] p-3 backdrop-blur-md @max-[719px]:top-auto @max-[719px]:right-2.5 @max-[719px]:bottom-[calc(var(--evo-controls,160px)+4px)] @max-[719px]:left-2.5 @max-[719px]:max-h-[32%] @max-[719px]:w-auto`,children:[(0,X.jsxs)(`header`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`m-0 min-w-0 text-[13px] leading-5 font-medium break-words text-content`,children:C.facts[Q].title}),(0,X.jsx)(g,{variant:`ghost`,size:`icon-sm`,className:`-mt-1 -mr-1 flex-none`,"aria-label":x(`memory:memoryEvolution.closeCard`),onClick:()=>i(null),children:(0,X.jsx)(c,{"aria-hidden":`true`})})]}),(0,X.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-2 text-[11px] text-content-muted`,children:[(0,X.jsx)(`span`,{children:Yt(C.facts[Q].type)}),!!(C.flags[Q]&1)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.pinned`)}),!!(C.flags[Q]&2)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.untrusted`)}),!!(C.flags[Q]&8)&&(0,X.jsx)(`span`,{children:x(`memory:memoryEvolution.stale`)})]}),(0,X.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:Ut.map(e=>{let t=C.facts[e],n=De(C,e,D),r=an.get(t.id);return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-current":e===Q||void 0,onClick:()=>{Rt(C.appearAt[e]),i(t.id)},className:m(`flex w-full min-w-0 flex-col gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none pointer-coarse:min-h-11`,e===Q&&`bg-surface-muted`),children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-content-muted tabular-nums`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full`,style:{backgroundColor:n===`superseded`?it:n===`archived`?at:q(Ue[t.type]??Ue.concept)}}),Ht.format(C.validAt[e]),` · `,Xt(n)]}),(0,X.jsx)(`span`,{className:`line-clamp-3 text-xs leading-[1.45] break-words text-content-soft`,children:r||t.title})]})},t.id)})})]}),C&&!$&&(0,X.jsx)(`div`,{className:`absolute inset-x-0 bottom-5 z-10 flex justify-center px-6`,children:(0,X.jsx)(te,{compact:!0,illustration:(0,X.jsx)(`span`,{}),title:x(`memory:memoryEvolution.emptyTitle`),description:x(`memory:memoryEvolution.emptyDescription`)})}),!C&&w&&(0,X.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center text-xs text-content-muted`,children:(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(h,{className:`size-4`}),x(`memory:memoryEvolution.loading`)]})}),!C&&!w&&E&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center`,children:(0,X.jsx)(ee,{kind:`error`,title:x(`memory:memoryEvolution.loadFailed`),description:E,action:(0,X.jsx)(g,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>se(e=>e+1),children:x(`memory:memoryEvolution.retry`)})})}),(0,X.jsx)(`div`,{ref:we,className:m(`absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-[var(--evo-scrim)] via-[var(--evo-scrim)] via-40% to-[var(--evo-scrim-clear)] px-5 pt-7 pb-3.5 @max-[719px]:px-3 @max-[719px]:pt-5 @max-[719px]:pb-3`,!$&&`invisible`),children:(0,X.jsxs)(`div`,{className:`flex items-end gap-3 @max-[719px]:flex-col @max-[719px]:items-stretch @max-[719px]:gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-none items-center gap-1 pb-1 @max-[719px]:order-2 @max-[719px]:justify-between @max-[719px]:pb-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(g,{variant:`ghost`,size:`icon`,"data-memory-evolution-play":!0,className:`max-[650px]:size-11`,"aria-label":x(k?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),title:x(k?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),disabled:!$,onClick:zt,children:k?(0,X.jsx)(o,{"aria-hidden":`true`}):(0,X.jsx)(s,{"aria-hidden":`true`})}),(0,X.jsxs)(g,{variant:`ghost`,size:`sm`,"data-memory-evolution-now":!0,className:`aria-disabled:opacity-50 max-[650px]:h-11`,"aria-disabled":!$||Kt&&!k,onClick:()=>{C&&!(Kt&&!k)&&Rt(C.domain.end)},children:[(0,X.jsx)(ne,{"aria-hidden":`true`}),x(`memory:memoryEvolution.backToNow`)]})]}),on(`hidden @max-[719px]:inline-flex`)]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 @max-[719px]:order-1`,children:[(0,X.jsx)(`div`,{ref:Oe,"aria-hidden":`true`,style:{marginLeft:yt,marginRight:yt,height:vt},children:(0,X.jsx)(`canvas`,{ref:Ee,className:`block size-full`})}),C&&(0,X.jsx)(f,{"aria-label":x(`memory:memoryEvolution.timelineLabel`),valueText:qt,min:0,max:1e3,step:1,value:[Le(C.domain,D)],disabled:!$,className:`h-5 pointer-coarse:h-11 max-[650px]:h-11`,onValueChange:([e])=>Rt(Ie(C.domain,e))}),C&&(0,X.jsxs)(`div`,{"aria-hidden":`true`,className:`flex justify-between px-[7px] text-[11px] text-content-faint tabular-nums`,children:[(0,X.jsx)(`span`,{children:Ht.format(C.domain.start)}),(0,X.jsx)(`span`,{children:Ht.format(C.domain.end)})]})]}),on(`mb-1 flex-none @max-[719px]:hidden`)]})})]})})}export{Tt as MemoryEvolution,Tt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryEvolution-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{t as r}from"./index-at6jiRd2.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{f as o}from"./routes-DIeaqWVc.js";import{t as s}from"./use-i18n-AM3jlRYR.js";import{t as c}from"./storage-DtvZ_lEu.js";import{i as l}from"./http-response-scdqC11Q.js";import"./http-CXQuFoDX.js";import{t as u}from"./createLucideIcon-Cd-3GVxJ.js";import{t as d}from"./archive-ojKJT7Fp.js";import{t as f}from"./book-open-BuHHD9os.js";import{t as p}from"./ellipsis-CfGKfbq6.js";import{t as m}from"./file-code-corner-BnE1ljT0.js";import{n as h,r as g,t as _}from"./undo-2-C-xQ0UVT.js";import{t as v}from"./pencil-U08v_vV9.js";import{t as y}from"./pin-off-BpRu_vrC.js";import{t as b}from"./pin-CU0FG0lI.js";import{t as x}from"./plus-fQbSqB1n.js";import{t as S}from"./refresh-cw-TbWxTY4K.js";import{t as C}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as w}from"./rotate-ccw-C0v8V77_.js";import{t as T}from"./sliders-horizontal-Dryf1XyC.js";import{t as E}from"./trash-2-CNrPOoPR.js";import{t as D}from"./triangle-alert-CE1q54ci.js";import{t as ee}from"./x-07u4-129.js";import{t as te}from"./more-pages-D_PnxLN0.js";import{c as ne,i as O,p as k,r as re,t as ie}from"./dropdown-menu-Ds0gD8S8.js";import{i as A,n as ae,r as oe,t as se}from"./tabs-DsgBuvJv.js";import{t as ce}from"./segmented-control-xkrEOP_d.js";import{t as j}from"./utils-C8uzG5AZ.js";import{n as M,t as N}from"./button-CCcCN8tE.js";import{s as le}from"./shortcuts-BsrTXPiU.js";import{a as P,i as F,l as ue,o as I,s as L,t as de}from"./dialog-BVAtioHy.js";import{t as R}from"./input-CPw-zkYh.js";import{t as fe}from"./textarea-DmATpOqT.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{a as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"./FeaturePage-C4fMefC-.js";import{n as V}from"./field-DoLEb0np.js";import{t as be}from"./AppSelect-DQYKUW5E.js";import{t as H}from"./badge-CWB3lj2H.js";import{i as U}from"./app-primitives-Drz_SjnR.js";import{a as xe,c as Se,f as W,g as G,h as Ce,i as we,l as K,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as je,u as Me}from"./memory-api-BZLLcIF1.js";var Ne=u(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Pe=u(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Fe=u(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Ie=u(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Le=u(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Re=u(`milestone`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M12 3v3`,key:`1n5kay`}],[`path`,{d:`M18.172 6a2 2 0 0 1 1.414.586l2.06 2.06a1.207 1.207 0 0 1 0 1.708l-2.06 2.06a2 2 0 0 1-1.414.586H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z`,key:`8gz4t4`}]]),ze=u(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),q=e(i(),1),Be={concept:g,file:m,risk:D,preference:T,decision:Re,fact:f,task:h};function Ve(e,t){return t(e===`file`?`memory:memoryPage.fileType`:e===`risk`?`memory:memoryPage.riskType`:e===`preference`?`memory:memoryPage.preferenceType`:e===`decision`?`memory:memoryPage.decisionType`:e===`fact`?`memory:memoryPage.factType`:e===`task`?`memory:memoryPage.taskType`:`memory:memoryPage.conceptType`)}function He(e,t){return t(e===`manual`?`memory:memoryPage.sourceManual`:e===`user_confirmed`?`memory:memoryPage.sourceUserRequest`:e===`agent`?`memory:memoryPage.sourceAgent`:e===`tool_verified`?`memory:memoryPage.sourceTool`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.sourceConversation`)}function Ue(e,t){return t(e===`assistant`?`memory:memoryPage.roleAssistant`:e===`tool`?`memory:memoryPage.roleTool`:e===`external`?`memory:memoryPage.roleExternal`:e===`manual`?`memory:memoryPage.roleManual`:`memory:memoryPage.roleUser`)}function We(e,t){return[e.pinned&&t(`memory:memoryPage.pinnedBadge`),e.status===`stale`&&t(`memory:memoryPage.staleBadge`),e.tainted&&t(`memory:memoryPage.taintedBadge`),e.status===`archived`&&t(`memory:memoryPage.archivedBadge`),e.status===`superseded`&&t(`memory:memoryPage.supersededBadge`)].filter(e=>!!e)}function J(e,t){return e?.kind===`global`?t(`memory:memoryPage.globalMemorySpace`):e?.name||``}function Y(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(n)}function Ge(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(n)}function Ke(e,t){let n={add:{icon:x,label:()=>t(`memory:memoryPage.eventAdd`)},supersede:{icon:ze,label:()=>t(`memory:memoryPage.eventSupersede`)},merge:{icon:Ie,label:()=>t(`memory:memoryPage.eventMerge`)},archive:{icon:d,label:()=>t(`memory:memoryPage.eventArchive`)},expire:{icon:Pe,label:()=>t(`memory:memoryPage.eventExpire`)},stale:{icon:D,label:()=>t(`memory:memoryPage.eventStale`)},confirm:{icon:Ne,label:()=>t(`memory:memoryPage.eventConfirm`)},restore:{icon:w,label:()=>t(`memory:memoryPage.eventRestore`)},edit:{icon:v,label:()=>t(`memory:memoryPage.eventEdit`)},pin:{icon:b,label:()=>t(`memory:memoryPage.eventPin`)},unpin:{icon:y,label:()=>t(`memory:memoryPage.eventUnpin`)},delete:{icon:E,label:()=>t(`memory:memoryPage.eventDelete`)},purge:{icon:Fe,label:()=>t(`memory:memoryPage.eventPurge`)},undo:{icon:_,label:()=>t(`memory:memoryPage.eventUndo`)},reinforce:{icon:S,label:()=>t(`memory:memoryPage.eventReinforce`)},migrate:{icon:C,label:()=>t(`memory:memoryPage.eventMigrate`)},consolidate:{icon:Ie,label:()=>t(`memory:memoryPage.eventConsolidate`)}}[e];return n?{icon:n.icon,label:n.label()}:{icon:C,label:t(`memory:memoryPage.eventGeneric`)}}function qe(e,t){return e===`user`||e===`manual`||e===`user_confirmed`?t(`memory:memoryPage.actorYou`):[`consolidator`,`reconcile`,`lifecycle`].includes(e)?t(`memory:memoryPage.actorConsolidator`):t(e===`conversation`?`memory:memoryPage.actorConversation`:e===`agent`||e===`tool_verified`?`memory:memoryPage.actorAgent`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.actorSystem`)}function Je(e,t){if(e===`same_identity`)return t(`memory:memoryPage.reasonSameIdentity`);if(e===`lower_authority_conflict`)return t(`memory:memoryPage.reasonLowerAuthority`);if(e===`expired`||e===`retention_expired`)return t(`memory:memoryPage.reasonExpired`);if(e===`unused`||e===`low_utility`)return t(`memory:memoryPage.reasonLowUtility`);if(e===`user_deleted`)return t(`memory:memoryPage.reasonUserDeleted`);if(e===`user_requested`)return t(`memory:memoryPage.reasonUserRequested`);let n=/^digests:(\d+) merged:(\d+)$/.exec(e);if(n){let e=Number(n[1]),r=Number(n[2]);return e&&r?t(`memory:memoryPage.reasonConsolidatedBoth`,{digests:e,merged:r}):r?t(`memory:memoryPage.reasonConsolidatedMerged`,{merged:r}):t(`memory:memoryPage.reasonConsolidatedDigests`,{digests:e})}let r=/^promoted (\d+) pending candidates$/.exec(e);return r?t(`memory:memoryPage.reasonPromoted`,{count:Number(r[1])}):e}var X=a(),Ye=50;function Xe({spaceId:e,refreshKey:t,onChanged:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(``),S=(0,q.useRef)(0),C=e===`all`?``:e,w=(0,q.useCallback)(async()=>{let e=++S.current;u(!0),y(``);try{let t=await Me({spaceId:C,limit:Ye});if(e!==S.current)return;o(t.events),m(t.events.length>=Ye),g(!1)}catch(t){if(e!==S.current)return;t instanceof l&&t.status===404?g(!0):y(t instanceof Error?t.message:String(t))}finally{e===S.current&&u(!1)}},[C]);(0,q.useEffect)(()=>(w(),()=>{S.current+=1}),[w,t]);let T=async()=>{let e=a.at(-1)?.at;if(!e||d)return;let t=S.current;f(!0);try{let n=await Me({spaceId:C,before:e,limit:Ye});if(t!==S.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.events.filter(e=>!t.has(e.id))]}),m(n.events.length>=Ye)}catch(e){t===S.current&&y(e instanceof Error?e.message:String(e))}finally{f(!1)}},E=async e=>{if(!b){x(e.id),y(``);try{await Ce(e.id),await n(r(`memory:memoryPage.eventUndone`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{x(``)}}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.activityUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):v&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.activityLoadFailed`),description:v,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void w(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[v&&(0,X.jsx)(ye,{className:`mt-0`,children:v}),(0,X.jsx)(he,{children:a.map(e=>{let{icon:t,label:n}=Ke(e.action,r),a=e.reason?Je(e.reason,r):``;return(0,X.jsx)(me,{"data-memory-event":e.action,icon:(0,X.jsx)(t,{}),name:n,description:[...new Set(e.titles||[])].join(`、`)||void 0,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(e.at,i),` · `,qe(e.actor,r),a?` · ${a}`:``]}),status:e.undoneAt?r(`memory:memoryPage.undone`):void 0,actions:e.undoable?(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,disabled:!!b,"aria-label":`${r(`memory:memoryPage.undo`)}: ${n}`,onClick:()=>void E(e),children:[(0,X.jsx)(_,{}),r(`memory:memoryPage.undo`)]}):void 0},e.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void T(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noActivity`)})}var Z=`flex min-h-[34px] min-w-0 items-center justify-between gap-4 border-t border-stroke-soft text-sm [&>dd]:min-w-0 [&>dd]:truncate [&>dd]:text-right [&>dd]:text-content [&>dt]:shrink-0 [&>dt]:text-content-muted`;function Ze({labels:e}){return(0,X.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:e.map(e=>(0,X.jsx)(H,{children:e},e))})}function Qe({id:e,fallback:t=null,spaces:n,refreshKey:r=0,withHeading:i=!1,onClose:a,onEdit:o,onChanged:c,onDeleted:l,requestConfirm:u}){let{t:d,language:f}=s(),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!0),[_,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[te,ne]=(0,q.useState)(0);(0,q.useEffect)(()=>{let t=new AbortController;return g(!0),x(``),K(e,t.signal).then(e=>{t.signal.aborted||(m(e),g(!1))}).catch(e=>{t.signal.aborted||(x(e instanceof Error?e.message:String(e)),g(!1))}),()=>t.abort()},[e,r,te]);let O=(0,q.useCallback)(async(e,t)=>{D(!0),C(``);try{await e(),await c(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}},[c]),k=p?.item?.id===e?p.item:t,re=p?.item?.id===e?p.history:[],ie=async()=>{if(k&&await u({title:d(`memory:memoryPage.deleteMemory`),message:d(`memory:memoryPage.deleteMemoryName`,{name:k.title}),confirmLabel:d(`memory:memoryPage.delete`)})){D(!0),C(``);try{await xe(k.id),await l(d(`memory:memoryPage.memoryDeleted`))}catch(e){C(e instanceof Error?e.message:String(e)),D(!1)}}};if(!k)return(0,X.jsx)(`div`,{className:`flex min-h-16 items-center gap-2 text-xs text-content-muted`,children:h?(0,X.jsx)(M,{className:`size-4`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{className:`my-0`,children:_||d(`memory:memoryPage.detailLoadFailed`)}),(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>ne(e=>e+1),children:d(`memory:memoryPage.retry`)})]})});let A=n.find(e=>e.id===k.spaceId),ae=k.status===`active`||k.status===`stale`||!k.status,oe=We(k,d);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,"aria-busy":h||T||void 0,children:[i&&(0,X.jsxs)(`header`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h3`,{className:`text-[15px] leading-6 font-medium break-words text-content`,children:k.title}),oe.length>0&&(0,X.jsx)(Ze,{labels:oe})]}),a&&(0,X.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`-mt-0.5 flex-none max-[650px]:size-11`,"aria-label":d(`memory:memoryPage.closeDetail`),onClick:a,children:(0,X.jsx)(ee,{})})]}),(0,X.jsx)(`p`,{className:`text-[13px] leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.content}),k.status===`stale`&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.staleHint`)}),k.tainted&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.taintedHint`)}),(0,X.jsxs)(`dl`,{className:`m-0`,children:[(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memoryType`)}),(0,X.jsx)(`dd`,{children:Ve(k.type,d)})]}),A&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memorySpace`)}),(0,X.jsx)(`dd`,{children:J(A,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.source`)}),(0,X.jsx)(`dd`,{children:He(k.sourceType,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validFrom`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.validFrom,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validTo`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.validTo?Y(k.validTo,f):d(`memory:memoryPage.stillValid`)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.created`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.createdAt,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.confirmCount`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.confirmCount??1})]}),k.expiresAt&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.expires`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.expiresAt,f)})]}),k.sourcePath&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.relatedFilePath`)}),(0,X.jsx)(`dd`,{className:`font-mono text-xs`,title:k.sourcePath,children:k.sourcePath})]}),k.archiveReason&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.archiveReason`)}),(0,X.jsx)(`dd`,{title:Je(k.archiveReason,d),children:Je(k.archiveReason,d)})]})]}),k.evidence&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.evidence`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted`,children:[d(`memory:memoryPage.evidenceFrom`),` · `,Ue(k.evidenceRole,d)]}),(0,X.jsx)(`blockquote`,{className:`m-0 border-l-2 border-stroke pl-2.5 text-xs leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.evidence})]}),re.length>1&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.versionHistory`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[d(`memory:memoryPage.versionHistory`),` · `,re.length]}),(0,X.jsx)(`ol`,{"data-memory-history":!0,className:`m-0 flex list-none flex-col p-0`,children:re.map(e=>{let t=e.status===`active`||e.status===`stale`;return(0,X.jsxs)(`li`,{"aria-current":e.id===k.id||void 0,className:j(`flex min-w-0 flex-col gap-0.5 border-t border-stroke-soft py-1.5 text-xs leading-normal`,!t&&`text-content-muted`),children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 tabular-nums`,children:[Ge(e.validFrom,f),t&&(0,X.jsx)(H,{children:d(`memory:memoryPage.currentVersion`)})]}),(0,X.jsx)(`span`,{className:`break-words whitespace-pre-wrap`,children:e.content})]},e.id)})})]}),S&&(0,X.jsx)(U,{className:`my-0`,children:S}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:T,onClick:()=>void ie(),children:[(0,X.jsx)(E,{}),d(`memory:memoryPage.delete`)]}),ae?(0,X.jsxs)(X.Fragment,{children:[k.status===`stale`&&(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`confirm`),d(`memory:memoryPage.confirmed`)),children:[(0,X.jsx)(Ne,{}),d(`memory:memoryPage.confirmStillValid`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,k.pinned?`unpin`:`pin`),k.pinned?d(`memory:memoryPage.unpinned`):d(`memory:memoryPage.pinned`)),children:[k.pinned?(0,X.jsx)(y,{}):(0,X.jsx)(b,{}),k.pinned?d(`memory:memoryPage.unpin`):d(`memory:memoryPage.pin`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>o(k),children:[(0,X.jsx)(v,{}),d(`memory:memoryPage.edit`)]})]}):(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`restore`),d(`memory:memoryPage.restored`)),children:[(0,X.jsx)(w,{}),d(`memory:memoryPage.restore`)]})]})]})}var $e=[`concept`,`file`,`risk`,`preference`,`decision`,`fact`,`task`],et=[.3,.5,.8,1];function tt(e){let t=e??.5;return et.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function nt(e){return e instanceof Error?e.message:String(e)}function rt({spaces:e,node:t,initialSpaceId:n,onClose:r,onSaved:i}){let{t:a}=s(),[o,c]=(0,q.useState)({spaceId:t?.spaceId||n||e[0]?.id||``,title:t?.title||``,content:t?.content||``,type:t?.type||`concept`,sourcePath:t?.sourcePath||``,importance:tt(t?.importance)}),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),p=a(t?`memory:memoryPage.editMemory`:`memory:memoryPage.addMemory`),m=async e=>{if(e.preventDefault(),!l){u(!0),f(``);try{t?await G(t.id,o):await ke(o),await i(a(t?`memory:memoryPage.memoryUpdated`:`memory:memoryPage.memoryCreated`))}catch(e){f(nt(e))}finally{u(!1)}}};return(0,X.jsx)(de,{open:!0,busy:l,onOpenChange:e=>!e&&r(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void m(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:p}),(0,X.jsx)(P,{children:a(`memory:memoryPage.memoryDialogHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryTitle`),(0,X.jsx)(R,{value:o.title,onChange:e=>c({...o,title:e.target.value}),placeholder:a(`memory:memoryPage.forExampleProjectUIConstraints`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryContent`),(0,X.jsx)(fe,{value:o.content,onChange:e=>c({...o,content:e.target.value}),placeholder:a(`memory:memoryPage.recordStandaloneReusableMemoryForFutureChats`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memorySpace`),(0,X.jsx)(be,{value:o.spaceId,onChange:e=>c({...o,spaceId:e.target.value}),children:e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:J(e,a)},e.id))})]}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-x-2.5 gap-y-3 sm:grid-cols-2`,children:[(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryType`),(0,X.jsx)(be,{value:o.type,onChange:e=>c({...o,type:e.target.value}),children:$e.map(e=>(0,X.jsx)(`option`,{value:e,children:Ve(e,a)},e))})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.importance`),(0,X.jsxs)(be,{value:o.importance,onChange:e=>c({...o,importance:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0.3`,children:a(`memory:memoryPage.normal`)}),(0,X.jsx)(`option`,{value:`0.5`,children:a(`memory:memoryPage.common`)}),(0,X.jsx)(`option`,{value:`0.8`,children:a(`memory:memoryPage.important`)}),(0,X.jsx)(`option`,{value:`1`,children:a(`memory:memoryPage.strict`)})]})]})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.relatedFilePath`),(0,X.jsx)(R,{value:o.sourcePath,onChange:e=>c({...o,sourcePath:e.target.value}),placeholder:a(`memory:memoryPage.optionalForExampleECodeProjectREADMEMd`)})]}),d&&(0,X.jsx)(U,{children:d}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:l,onClick:r,children:a(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:l||!o.spaceId||!o.title.trim()||!o.content.trim(),children:[l&&(0,X.jsx)(M,{className:`text-current`}),a(l?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}function it({space:e,onClose:t,onSaved:n}){let{t:r}=s(),[i,a]=(0,q.useState)(e?.name||``),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(``),d=r(e?`memory:memoryPage.renameMemorySpace`:`memory:memoryPage.newMemorySpace`),f=async t=>{if(t.preventDefault(),!o){c(!0),u(``);try{await n(e?await Te(e.id,i):await we(i),r(e?`memory:memoryPage.memorySpaceRenamed`:`memory:memoryPage.memorySpaceCreated`))}catch(e){u(nt(e))}finally{c(!1)}}};return(0,X.jsx)(de,{open:!0,busy:o,onOpenChange:e=>!e&&t(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void f(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:d}),(0,X.jsx)(P,{children:r(`memory:memoryPage.memorySpaceHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[r(`memory:memoryPage.memorySpaceName`),(0,X.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:r(`memory:memoryPage.forExampleProductDesignGuidelines`),autoFocus:!0})]}),l&&(0,X.jsx)(U,{children:l}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:o,onClick:t,children:r(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:o||!i.trim(),children:[o&&(0,X.jsx)(M,{className:`text-current`}),r(o?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}var at=30;function ot({digest:e}){let{t}=s(),r=n(),[i,a]=(0,q.useState)([]);return(0,q.useEffect)(()=>{let t=new AbortController;return K(e.id,t.signal).then(e=>a(e.children||[]),()=>a([])),()=>t.abort()},[e.id]),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`m-0 text-sm leading-relaxed break-words whitespace-pre-wrap`,children:e.text}),i.length>0&&(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`m-0 text-xs font-medium text-content-muted`,children:t(`memory:memoryPage.sessionFacts`)}),(0,X.jsx)(`ul`,{className:`m-0 mt-1 list-disc pl-4 text-sm leading-relaxed`,children:i.map(e=>(0,X.jsx)(`li`,{className:`break-words`,children:e.title},e.id))})]}),e.sessionAvailable&&(0,X.jsx)(`div`,{children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>r(o(e.sessionId)),children:t(`memory:memoryPage.openSession`)})})]})}function st({spaceId:e,spaces:t,refreshKey:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),x=(0,q.useRef)(0),S=e===`all`?``:e,C=(0,q.useCallback)(async()=>{let e=++x.current;u(!0),v(``);try{let t=await W({spaceId:S,limit:at});if(e!==x.current)return;o(t.sessions),m(t.sessions.length>=at),g(!1)}catch(t){if(e!==x.current)return;t instanceof l&&t.status===404?g(!0):v(t instanceof Error?t.message:String(t))}finally{e===x.current&&u(!1)}},[S]);(0,q.useEffect)(()=>(C(),()=>{x.current+=1}),[C,n]);let w=async()=>{let e=a.at(-1)?.windowEnd;if(!e||d)return;let t=x.current;f(!0);try{let n=await W({spaceId:S,before:e,limit:at});if(t!==x.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.sessions.filter(e=>!t.has(e.id))]}),m(n.sessions.length>=at)}catch(e){t===x.current&&v(e instanceof Error?e.message:String(e))}finally{f(!1)}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.sessionsUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):_&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.sessionsLoadFailed`),description:_,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void C(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[_&&(0,X.jsx)(ye,{className:`mt-0`,children:_}),(0,X.jsx)(he,{children:a.map(n=>{let a=n.sessionName||r(`memory:memoryPage.sessionUntitled`),o=t.find(e=>e.id===n.spaceId);return(0,X.jsx)(me,{"data-memory-session":n.sessionId,icon:(0,X.jsx)(Le,{}),name:a,description:y===n.id?void 0:n.text,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(n.windowEnd,i),e===`all`&&o?` · ${J(o,r)}`:``]}),expanded:y===n.id,onExpandedChange:e=>b(e?n.id:``),toggleLabel:a,detail:(0,X.jsx)(ot,{digest:n})},n.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void w(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noSessionDigests`)})}var ct=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate());function lt(e){let t=ct(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()-(t.getDay()+6)%7)}function ut(e,t,n=Date.now()){let r=new Date(n),i=ct(r).getTime(),a=i-864e5,o=lt(r).getTime(),s=new Map,c=(e,t)=>{let n=s.get(e.key);n?n.items.push(t):s.set(e.key,{...e,items:[t]})};for(let n of e){let e=Date.parse(t(n)||``);if(Number.isNaN(e))c({key:`unknown`,kind:`unknown`},n);else if(e>=i)c({key:`today`,kind:`today`},n);else if(e>=a)c({key:`yesterday`,kind:`yesterday`},n);else if(e>=o)c({key:`week`,kind:`week`},n);else{let t=new Date(e);c({key:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}`,kind:`month`,month:new Date(t.getFullYear(),t.getMonth(),1)},n)}}return[...s.values()]}var dt=(0,q.lazy)(()=>t(()=>import(`./MemoryEvolution-CVF6CYuV.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]))),Q=`all`;function ft(){try{let e=r.getItem(c.memoryView);return e===`timeline`||e===`sessions`||e===`activity`?e:`evolution`}catch{return`evolution`}}function pt(e){try{r.setItem(c.memoryView,e)}catch{}}function $(e){return e instanceof Error?e.message:String(e)}var mt={spaces:[],selectedSpaceId:``,nodes:[]};function ht({notify:e,onBack:t,requestConfirm:n}){let{t:r,language:i}=s(),a=le(`focusSearch`),[o,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(ft),[d,f]=(0,q.useState)(Q),[m,h]=(0,q.useState)(`current`),[g,_]=(0,q.useState)(mt),[v,y]=(0,q.useState)(!0),[b,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(``),[ee,j]=(0,q.useState)(``),[M,P]=(0,q.useState)(null),[F,ue]=(0,q.useState)(0),[I,L]=(0,q.useState)(null),[de,R]=(0,q.useState)(null),[fe,V]=(0,q.useState)(!1),H=(0,q.useRef)(0),U=(0,q.useCallback)(async()=>{let e=++H.current;y(!0),D(``);try{let t=await Se({spaceId:d,query:o,status:m});if(e!==H.current)return;_(t),T(!0),t.selectedSpaceId&&t.selectedSpaceId!==d&&f(t.selectedSpaceId)}catch(t){e===H.current&&D($(t))}finally{e===H.current&&y(!1)}},[o,d,m]);(0,q.useEffect)(()=>(U(),()=>{H.current+=1}),[U,F]);let xe=async()=>{let e=g.nodes.at(-1),t=e?.validFrom||e?.createdAt;if(!t||b)return;let n=H.current;C(!0);try{let e=await Se({spaceId:d,status:m,before:t});if(n!==H.current)return;_(t=>{let n=new Set(t.nodes.map(e=>e.id));return{...e,nodes:[...t.nodes,...e.nodes.filter(e=>!n.has(e.id))]}})}catch(e){n===H.current&&D($(e))}finally{C(!1)}},W=(0,q.useCallback)(()=>ue(e=>e+1),[]),G=(0,q.useCallback)(t=>{e(t),W()},[e,W]),Ce=(0,q.useCallback)(e=>{j(``),P(null),G(e)},[G]),we=(0,q.useMemo)(()=>[...g.spaces].sort((e,t)=>Number(t.kind===`global`)-Number(e.kind===`global`)),[g.spaces]),K=g.spaces.find(e=>e.id===d)||null,Te=!!o.trim(),Oe=(0,q.useMemo)(()=>ut(g.nodes,e=>e.validFrom||e.createdAt),[g.nodes]),ke=e=>{let t=e;u(t),pt(t)},Me=e=>{c(e),j(``),e.trim()&&l!==`timeline`&&u(`timeline`)},Ne=e=>{f(e),j(``),P(null)},Pe=async()=>{if(K&&await n({title:r(`memory:memoryPage.deleteMemorySpace`),message:r(`memory:memoryPage.deleteMemorySpaceNameAndAllMemoriesInIt`,{name:J(K,r)}),confirmLabel:r(`memory:memoryPage.delete`)}))try{await De(K.id),Ne(Q),G(r(`memory:memoryPage.memorySpaceDeleted`))}catch(e){D($(e))}},Fe=async()=>{try{let{markdown:t}=await Ae(d===Q?``:d),n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),i=document.createElement(`a`);i.href=n,i.download=`pisper-memory-${new Date().toISOString().slice(0,10)}.md`,i.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),e(r(`memory:memoryPage.exported`))}catch(e){D($(e))}},Ie=async()=>{if(!fe){V(!0),D(``);try{let e=await Ee();G(e.ran?r(`memory:memoryPage.consolidated`):r(`memory:memoryPage.nothingToConsolidate`))}catch(e){D($(e))}finally{V(!1)}}},Le=async()=>{if(await n({title:r(`memory:memoryPage.clearEpisodes`),message:r(`memory:memoryPage.clearEpisodesConfirm`),confirmLabel:r(`memory:memoryPage.clearEpisodesAction`)}))try{let{cleared:e}=await je(d===Q?``:d);G(r(`memory:memoryPage.episodesCleared`,{count:e}))}catch(e){D($(e))}},Re=!!K&&K?.kind!==`global`,ze=e=>(0,X.jsx)(Qe,{id:e.id,fallback:e,spaces:g.spaces,refreshKey:F,onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}),Ue=e=>{let t=Be[e.type]||Be.concept,n=We(e,r),a=g.spaces.find(t=>t.id===e.spaceId);return(0,X.jsx)(me,{"data-memory-node":e.id,icon:(0,X.jsx)(t,{}),name:e.title,nameMeta:Ve(e.type,r),description:ee===e.id?void 0:e.content,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Ge(e.validFrom||e.createdAt,i),d===Q&&a?` · ${J(a,r)}`:``,` · ${He(e.sourceType,r)}`]}),status:n.length?(0,X.jsx)(Ze,{labels:n}):void 0,expanded:ee===e.id,onExpandedChange:t=>j(t?e.id:``),toggleLabel:e.title,detail:ze(e)},e.id)},Y=e=>e.kind===`today`?r(`memory:memoryPage.groupToday`):e.kind===`yesterday`?r(`memory:memoryPage.groupYesterday`):e.kind===`week`?r(`memory:memoryPage.groupThisWeek`):e.kind===`unknown`||!e.month?r(`memory:memoryPage.groupUnknown`):new Intl.DateTimeFormat(i,{year:`numeric`,month:`long`}).format(e.month),Ke=r(Te?`memory:memoryPage.noMatchingMemories`:m===`archived`?`memory:memoryPage.noArchivedMemories`:m===`history`?`memory:memoryPage.noHistoryVersions`:`memory:memoryPage.noMemoriesInSpace`);return(0,X.jsx)(se,{asChild:!0,value:l,onValueChange:ke,className:`gap-0`,children:(0,X.jsxs)(_e,{title:r(`navigation:navigation.memory`),description:r(`memory:memoryPage.lede`),back:t&&{label:r(`navigation:sidebar.features`),ariaLabel:r(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,X.jsx)(ve,{search:(0,X.jsx)(pe,{id:te,value:o,onValueChange:Me,placeholder:r(`navigation:pageHeader.searchMemoriesOrFiles`),shortcut:a,clearLabel:r(`navigation:more.clearSearch`)}),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(N,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>L({spaceId:d===Q?`global`:d}),children:[(0,X.jsx)(x,{}),r(`memory:memoryPage.addMemory`)]}),(0,X.jsxs)(ie,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`icon-lg`,className:`max-[650px]:max-w-11`,disabled:!w,"aria-label":r(`memory:memoryPage.moreActions`),title:r(`memory:memoryPage.moreActions`),children:(0,X.jsx)(p,{})})}),(0,X.jsxs)(re,{align:`end`,children:[(0,X.jsx)(O,{onSelect:()=>R(`new`),children:r(`memory:memoryPage.newMemorySpace`)}),(0,X.jsx)(O,{disabled:!Re,onSelect:()=>K&&R(K),children:r(`memory:memoryPage.renameMemorySpace`)}),(0,X.jsx)(O,{variant:`destructive`,disabled:!Re,onSelect:()=>void Pe(),children:r(`memory:memoryPage.deleteMemorySpace`)}),(0,X.jsx)(ne,{}),(0,X.jsx)(O,{onSelect:()=>void Fe(),children:r(`memory:memoryPage.exportMarkdown`)}),(0,X.jsx)(O,{disabled:fe,onSelect:()=>void Ie(),children:r(`memory:memoryPage.consolidateNow`)}),(0,X.jsx)(O,{onSelect:()=>void Le(),children:r(`memory:memoryPage.clearEpisodes`)})]})]})]}),filters:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(oe,{"aria-label":r(`memory:memoryPage.viewsLabel`),children:[(0,X.jsx)(A,{value:`evolution`,children:r(`memory:memoryPage.evolutionView`)}),(0,X.jsx)(A,{value:`timeline`,children:r(`memory:memoryPage.timelineView`)}),(0,X.jsx)(A,{value:`sessions`,children:r(`memory:memoryPage.sessionsView`)}),(0,X.jsx)(A,{value:`activity`,children:r(`memory:memoryPage.activityView`)})]}),(0,X.jsxs)(be,{className:`w-[200px] max-w-full max-[650px]:w-full`,"aria-label":r(`memory:memoryPage.memorySpace`),value:d,disabled:!w,onChange:e=>Ne(e.target.value),children:[(0,X.jsx)(`option`,{value:Q,children:r(`memory:memoryPage.allSpaces`)}),we.map(e=>(0,X.jsx)(`option`,{value:e.id,children:`${J(e,r)} · ${e.nodeCount}`},e.id))]})]}),l===`timeline`&&w&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[Te?(0,X.jsxs)(`p`,{className:`m-0 text-[13px] font-medium text-content-muted tabular-nums`,children:[r(`memory:memoryPage.searchResults`),` · `,g.nodes.length]}):(0,X.jsx)(ce,{"aria-label":r(`memory:memoryPage.statusFilterLabel`),value:m,onValueChange:e=>{h(e),j(``)},options:[{value:`current`,label:r(`memory:memoryPage.statusCurrent`),count:g.counts?.current},{value:`archived`,label:r(`memory:memoryPage.statusArchived`),count:g.counts?.archived},{value:`history`,label:r(`memory:memoryPage.statusHistory`),count:g.counts?.history}]}),(0,X.jsx)(N,{variant:`ghost`,size:`icon-sm`,className:`text-content-muted max-[650px]:size-11`,loading:v,disabled:v,"aria-label":r(`memory:memoryPage.refresh`),title:r(`memory:memoryPage.refresh`),onClick:W,children:(0,X.jsx)(S,{})})]})]})}),children:[!w&&v?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):w?(0,X.jsxs)(X.Fragment,{children:[E&&(0,X.jsx)(ye,{children:E}),(0,X.jsxs)(`div`,{className:`mt-5 min-w-0`,"aria-busy":v,children:[(0,X.jsxs)(ae,{value:`evolution`,className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(q.Suspense,{fallback:(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}),children:(0,X.jsx)(dt,{spaceId:d,refreshKey:F,selectedId:M,onSelect:P})}),(0,X.jsx)(`div`,{role:`region`,"data-memory-detail":!0,"aria-label":r(`memory:memoryPage.selectedMemory`),className:`min-w-0 rounded-[var(--r-md)] border border-stroke px-4 py-3`,children:M?(0,X.jsx)(Qe,{id:M,spaces:g.spaces,refreshKey:F,withHeading:!0,onClose:()=>P(null),onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}):(0,X.jsx)(`p`,{className:`m-0 text-xs leading-normal text-content-muted`,children:r(`memory:memoryPage.selectAMemoryToViewDetails`)})})]}),(0,X.jsxs)(ae,{value:`timeline`,className:`min-w-0`,"data-memory-timeline":!0,children:[g.nodes.length?Te?(0,X.jsx)(he,{children:g.nodes.map(Ue)}):Oe.map(e=>(0,X.jsx)(ge,{"data-memory-group":e.key,className:`mt-5 first:mt-0`,title:Y(e),count:e.items.length,children:(0,X.jsx)(he,{children:e.items.map(Ue)})},e.key)):(0,X.jsx)(B,{compact:!0,title:Ke}),!Te&&g.hasMore&&(0,X.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:b,disabled:b,onClick:()=>void xe(),children:r(`memory:memoryPage.loadMore`)})})]}),(0,X.jsx)(ae,{value:`sessions`,className:`min-w-0`,children:(0,X.jsx)(st,{spaceId:d,spaces:g.spaces,refreshKey:F})}),(0,X.jsx)(ae,{value:`activity`,className:`min-w-0`,children:(0,X.jsx)(Xe,{spaceId:d,refreshKey:F,onChanged:G})})]})]}):(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.loadFailed`),description:E,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void U(),children:r(`common:pageTemplate.retry`)})}),I&&(0,X.jsx)(rt,{spaces:we,node:`id`in I?I:null,initialSpaceId:I.spaceId,onClose:()=>L(null),onSaved:e=>{L(null),G(e)}}),de&&(0,X.jsx)(it,{space:de===`new`?null:de,onClose:()=>R(null),onSaved:(e,t)=>{R(null),Ne(e.id),G(t)}})]})})}export{ht as MemoryPage};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryEvolution-DPD3_wye.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-D6tl7SDi.js","assets/i18n-Zs9wBTpa.js","assets/vendor-router-CSN_DGvx.js","assets/index-BpFQSLJJ.js","assets/index-BnQCk-QI.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/info-DATxy0fb.js","assets/pause-CYWpPg1R.js","assets/play-DNDjDNGn.js","assets/x-07u4-129.js","assets/popover-CXY-wqxd.js","assets/dist-41X0pdUs.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/dialog-C_ew2HiI.js","assets/dist-BHkR6BLP.js","assets/button-CCcCN8tE.js","assets/slider-De8rWVNs.js","assets/dist-DzGQ7sLi.js","assets/dist-BS3ekNDj.js","assets/segmented-control-xkrEOP_d.js","assets/dist-BaBySQmo.js","assets/PageState-Cz6vFMXv.js","assets/motion-DTR4ZVle.js","assets/memory-api-BdiBvhoi.js","assets/api-CHqbIMkc.js","assets/abort-signal-f4JsiYKX.js","assets/http-response-C_f1S2cS.js","assets/event-stream-CJDJ_f9g.js","assets/http-Clt0jbV2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{t as r}from"./index-BpFQSLJJ.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{f as o}from"./routes-DIeaqWVc.js";import{t as s}from"./use-i18n-D6tl7SDi.js";import{t as c}from"./storage-DtvZ_lEu.js";import{i as l}from"./http-response-C_f1S2cS.js";import"./http-Clt0jbV2.js";import{t as u}from"./createLucideIcon-Cd-3GVxJ.js";import{t as d}from"./archive-ojKJT7Fp.js";import{t as f}from"./book-open-BuHHD9os.js";import{t as p}from"./ellipsis-CfGKfbq6.js";import{t as m}from"./file-code-corner-BnE1ljT0.js";import{n as h,r as g,t as _}from"./undo-2-C-xQ0UVT.js";import{t as v}from"./pencil-U08v_vV9.js";import{t as y}from"./pin-off-BpRu_vrC.js";import{t as b}from"./pin-CU0FG0lI.js";import{t as x}from"./plus-fQbSqB1n.js";import{t as S}from"./refresh-cw-TbWxTY4K.js";import{t as C}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as w}from"./rotate-ccw-C0v8V77_.js";import{t as T}from"./sliders-horizontal-Dryf1XyC.js";import{t as E}from"./trash-2-CNrPOoPR.js";import{t as D}from"./triangle-alert-CE1q54ci.js";import{t as ee}from"./x-07u4-129.js";import{t as te}from"./more-pages-D_PnxLN0.js";import{c as ne,i as O,p as k,r as re,t as ie}from"./dropdown-menu-Ds0gD8S8.js";import{i as A,n as ae,r as oe,t as se}from"./tabs-DsgBuvJv.js";import{t as ce}from"./segmented-control-xkrEOP_d.js";import{t as j}from"./utils-C8uzG5AZ.js";import{n as M,t as N}from"./button-CCcCN8tE.js";import{s as le}from"./shortcuts-1-ySiY-G.js";import{a as P,i as F,l as ue,o as I,s as L,t as de}from"./dialog-C_ew2HiI.js";import{t as R}from"./input-CPw-zkYh.js";import{t as fe}from"./textarea-DmATpOqT.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{a as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"./FeaturePage-CoalHN81.js";import{n as V}from"./field-DoLEb0np.js";import{t as be}from"./AppSelect-DQYKUW5E.js";import{t as H}from"./badge-CWB3lj2H.js";import{i as U}from"./app-primitives-Drz_SjnR.js";import{a as xe,c as Se,f as W,g as G,h as Ce,i as we,l as K,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as je,u as Me}from"./memory-api-BdiBvhoi.js";var Ne=u(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Pe=u(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Fe=u(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Ie=u(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Le=u(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Re=u(`milestone`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M12 3v3`,key:`1n5kay`}],[`path`,{d:`M18.172 6a2 2 0 0 1 1.414.586l2.06 2.06a1.207 1.207 0 0 1 0 1.708l-2.06 2.06a2 2 0 0 1-1.414.586H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z`,key:`8gz4t4`}]]),ze=u(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),q=e(i(),1),Be={concept:g,file:m,risk:D,preference:T,decision:Re,fact:f,task:h};function Ve(e,t){return t(e===`file`?`memory:memoryPage.fileType`:e===`risk`?`memory:memoryPage.riskType`:e===`preference`?`memory:memoryPage.preferenceType`:e===`decision`?`memory:memoryPage.decisionType`:e===`fact`?`memory:memoryPage.factType`:e===`task`?`memory:memoryPage.taskType`:`memory:memoryPage.conceptType`)}function He(e,t){return t(e===`manual`?`memory:memoryPage.sourceManual`:e===`user_confirmed`?`memory:memoryPage.sourceUserRequest`:e===`agent`?`memory:memoryPage.sourceAgent`:e===`tool_verified`?`memory:memoryPage.sourceTool`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.sourceConversation`)}function Ue(e,t){return t(e===`assistant`?`memory:memoryPage.roleAssistant`:e===`tool`?`memory:memoryPage.roleTool`:e===`external`?`memory:memoryPage.roleExternal`:e===`manual`?`memory:memoryPage.roleManual`:`memory:memoryPage.roleUser`)}function We(e,t){return[e.pinned&&t(`memory:memoryPage.pinnedBadge`),e.status===`stale`&&t(`memory:memoryPage.staleBadge`),e.tainted&&t(`memory:memoryPage.taintedBadge`),e.status===`archived`&&t(`memory:memoryPage.archivedBadge`),e.status===`superseded`&&t(`memory:memoryPage.supersededBadge`)].filter(e=>!!e)}function J(e,t){return e?.kind===`global`?t(`memory:memoryPage.globalMemorySpace`):e?.name||``}function Y(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(n)}function Ge(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(n)}function Ke(e,t){let n={add:{icon:x,label:()=>t(`memory:memoryPage.eventAdd`)},supersede:{icon:ze,label:()=>t(`memory:memoryPage.eventSupersede`)},merge:{icon:Ie,label:()=>t(`memory:memoryPage.eventMerge`)},archive:{icon:d,label:()=>t(`memory:memoryPage.eventArchive`)},expire:{icon:Pe,label:()=>t(`memory:memoryPage.eventExpire`)},stale:{icon:D,label:()=>t(`memory:memoryPage.eventStale`)},confirm:{icon:Ne,label:()=>t(`memory:memoryPage.eventConfirm`)},restore:{icon:w,label:()=>t(`memory:memoryPage.eventRestore`)},edit:{icon:v,label:()=>t(`memory:memoryPage.eventEdit`)},pin:{icon:b,label:()=>t(`memory:memoryPage.eventPin`)},unpin:{icon:y,label:()=>t(`memory:memoryPage.eventUnpin`)},delete:{icon:E,label:()=>t(`memory:memoryPage.eventDelete`)},purge:{icon:Fe,label:()=>t(`memory:memoryPage.eventPurge`)},undo:{icon:_,label:()=>t(`memory:memoryPage.eventUndo`)},reinforce:{icon:S,label:()=>t(`memory:memoryPage.eventReinforce`)},migrate:{icon:C,label:()=>t(`memory:memoryPage.eventMigrate`)},consolidate:{icon:Ie,label:()=>t(`memory:memoryPage.eventConsolidate`)}}[e];return n?{icon:n.icon,label:n.label()}:{icon:C,label:t(`memory:memoryPage.eventGeneric`)}}function qe(e,t){return e===`user`||e===`manual`||e===`user_confirmed`?t(`memory:memoryPage.actorYou`):[`consolidator`,`reconcile`,`lifecycle`].includes(e)?t(`memory:memoryPage.actorConsolidator`):t(e===`conversation`?`memory:memoryPage.actorConversation`:e===`agent`||e===`tool_verified`?`memory:memoryPage.actorAgent`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.actorSystem`)}function Je(e,t){if(e===`same_identity`)return t(`memory:memoryPage.reasonSameIdentity`);if(e===`lower_authority_conflict`)return t(`memory:memoryPage.reasonLowerAuthority`);if(e===`expired`||e===`retention_expired`)return t(`memory:memoryPage.reasonExpired`);if(e===`unused`||e===`low_utility`)return t(`memory:memoryPage.reasonLowUtility`);if(e===`user_deleted`)return t(`memory:memoryPage.reasonUserDeleted`);if(e===`user_requested`)return t(`memory:memoryPage.reasonUserRequested`);let n=/^digests:(\d+) merged:(\d+)$/.exec(e);if(n){let e=Number(n[1]),r=Number(n[2]);return e&&r?t(`memory:memoryPage.reasonConsolidatedBoth`,{digests:e,merged:r}):r?t(`memory:memoryPage.reasonConsolidatedMerged`,{merged:r}):t(`memory:memoryPage.reasonConsolidatedDigests`,{digests:e})}let r=/^promoted (\d+) pending candidates$/.exec(e);return r?t(`memory:memoryPage.reasonPromoted`,{count:Number(r[1])}):e}var X=a(),Ye=50;function Xe({spaceId:e,refreshKey:t,onChanged:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(``),S=(0,q.useRef)(0),C=e===`all`?``:e,w=(0,q.useCallback)(async()=>{let e=++S.current;u(!0),y(``);try{let t=await Me({spaceId:C,limit:Ye});if(e!==S.current)return;o(t.events),m(t.events.length>=Ye),g(!1)}catch(t){if(e!==S.current)return;t instanceof l&&t.status===404?g(!0):y(t instanceof Error?t.message:String(t))}finally{e===S.current&&u(!1)}},[C]);(0,q.useEffect)(()=>(w(),()=>{S.current+=1}),[w,t]);let T=async()=>{let e=a.at(-1)?.at;if(!e||d)return;let t=S.current;f(!0);try{let n=await Me({spaceId:C,before:e,limit:Ye});if(t!==S.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.events.filter(e=>!t.has(e.id))]}),m(n.events.length>=Ye)}catch(e){t===S.current&&y(e instanceof Error?e.message:String(e))}finally{f(!1)}},E=async e=>{if(!b){x(e.id),y(``);try{await Ce(e.id),await n(r(`memory:memoryPage.eventUndone`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{x(``)}}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.activityUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):v&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.activityLoadFailed`),description:v,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void w(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[v&&(0,X.jsx)(ye,{className:`mt-0`,children:v}),(0,X.jsx)(he,{children:a.map(e=>{let{icon:t,label:n}=Ke(e.action,r),a=e.reason?Je(e.reason,r):``;return(0,X.jsx)(me,{"data-memory-event":e.action,icon:(0,X.jsx)(t,{}),name:n,description:[...new Set(e.titles||[])].join(`、`)||void 0,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(e.at,i),` · `,qe(e.actor,r),a?` · ${a}`:``]}),status:e.undoneAt?r(`memory:memoryPage.undone`):void 0,actions:e.undoable?(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,disabled:!!b,"aria-label":`${r(`memory:memoryPage.undo`)}: ${n}`,onClick:()=>void E(e),children:[(0,X.jsx)(_,{}),r(`memory:memoryPage.undo`)]}):void 0},e.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void T(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noActivity`)})}var Z=`flex min-h-[34px] min-w-0 items-center justify-between gap-4 border-t border-stroke-soft text-sm [&>dd]:min-w-0 [&>dd]:truncate [&>dd]:text-right [&>dd]:text-content [&>dt]:shrink-0 [&>dt]:text-content-muted`;function Ze({labels:e}){return(0,X.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:e.map(e=>(0,X.jsx)(H,{children:e},e))})}function Qe({id:e,fallback:t=null,spaces:n,refreshKey:r=0,withHeading:i=!1,onClose:a,onEdit:o,onChanged:c,onDeleted:l,requestConfirm:u}){let{t:d,language:f}=s(),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!0),[_,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[te,ne]=(0,q.useState)(0);(0,q.useEffect)(()=>{let t=new AbortController;return g(!0),x(``),K(e,t.signal).then(e=>{t.signal.aborted||(m(e),g(!1))}).catch(e=>{t.signal.aborted||(x(e instanceof Error?e.message:String(e)),g(!1))}),()=>t.abort()},[e,r,te]);let O=(0,q.useCallback)(async(e,t)=>{D(!0),C(``);try{await e(),await c(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}},[c]),k=p?.item?.id===e?p.item:t,re=p?.item?.id===e?p.history:[],ie=async()=>{if(k&&await u({title:d(`memory:memoryPage.deleteMemory`),message:d(`memory:memoryPage.deleteMemoryName`,{name:k.title}),confirmLabel:d(`memory:memoryPage.delete`)})){D(!0),C(``);try{await xe(k.id),await l(d(`memory:memoryPage.memoryDeleted`))}catch(e){C(e instanceof Error?e.message:String(e)),D(!1)}}};if(!k)return(0,X.jsx)(`div`,{className:`flex min-h-16 items-center gap-2 text-xs text-content-muted`,children:h?(0,X.jsx)(M,{className:`size-4`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{className:`my-0`,children:_||d(`memory:memoryPage.detailLoadFailed`)}),(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>ne(e=>e+1),children:d(`memory:memoryPage.retry`)})]})});let A=n.find(e=>e.id===k.spaceId),ae=k.status===`active`||k.status===`stale`||!k.status,oe=We(k,d);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,"aria-busy":h||T||void 0,children:[i&&(0,X.jsxs)(`header`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h3`,{className:`text-[15px] leading-6 font-medium break-words text-content`,children:k.title}),oe.length>0&&(0,X.jsx)(Ze,{labels:oe})]}),a&&(0,X.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`-mt-0.5 flex-none max-[650px]:size-11`,"aria-label":d(`memory:memoryPage.closeDetail`),onClick:a,children:(0,X.jsx)(ee,{})})]}),(0,X.jsx)(`p`,{className:`text-[13px] leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.content}),k.status===`stale`&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.staleHint`)}),k.tainted&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.taintedHint`)}),(0,X.jsxs)(`dl`,{className:`m-0`,children:[(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memoryType`)}),(0,X.jsx)(`dd`,{children:Ve(k.type,d)})]}),A&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memorySpace`)}),(0,X.jsx)(`dd`,{children:J(A,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.source`)}),(0,X.jsx)(`dd`,{children:He(k.sourceType,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validFrom`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.validFrom,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validTo`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.validTo?Y(k.validTo,f):d(`memory:memoryPage.stillValid`)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.created`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.createdAt,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.confirmCount`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.confirmCount??1})]}),k.expiresAt&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.expires`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.expiresAt,f)})]}),k.sourcePath&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.relatedFilePath`)}),(0,X.jsx)(`dd`,{className:`font-mono text-xs`,title:k.sourcePath,children:k.sourcePath})]}),k.archiveReason&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.archiveReason`)}),(0,X.jsx)(`dd`,{title:Je(k.archiveReason,d),children:Je(k.archiveReason,d)})]})]}),k.evidence&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.evidence`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted`,children:[d(`memory:memoryPage.evidenceFrom`),` · `,Ue(k.evidenceRole,d)]}),(0,X.jsx)(`blockquote`,{className:`m-0 border-l-2 border-stroke pl-2.5 text-xs leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.evidence})]}),re.length>1&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.versionHistory`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[d(`memory:memoryPage.versionHistory`),` · `,re.length]}),(0,X.jsx)(`ol`,{"data-memory-history":!0,className:`m-0 flex list-none flex-col p-0`,children:re.map(e=>{let t=e.status===`active`||e.status===`stale`;return(0,X.jsxs)(`li`,{"aria-current":e.id===k.id||void 0,className:j(`flex min-w-0 flex-col gap-0.5 border-t border-stroke-soft py-1.5 text-xs leading-normal`,!t&&`text-content-muted`),children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 tabular-nums`,children:[Ge(e.validFrom,f),t&&(0,X.jsx)(H,{children:d(`memory:memoryPage.currentVersion`)})]}),(0,X.jsx)(`span`,{className:`break-words whitespace-pre-wrap`,children:e.content})]},e.id)})})]}),S&&(0,X.jsx)(U,{className:`my-0`,children:S}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:T,onClick:()=>void ie(),children:[(0,X.jsx)(E,{}),d(`memory:memoryPage.delete`)]}),ae?(0,X.jsxs)(X.Fragment,{children:[k.status===`stale`&&(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`confirm`),d(`memory:memoryPage.confirmed`)),children:[(0,X.jsx)(Ne,{}),d(`memory:memoryPage.confirmStillValid`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,k.pinned?`unpin`:`pin`),k.pinned?d(`memory:memoryPage.unpinned`):d(`memory:memoryPage.pinned`)),children:[k.pinned?(0,X.jsx)(y,{}):(0,X.jsx)(b,{}),k.pinned?d(`memory:memoryPage.unpin`):d(`memory:memoryPage.pin`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>o(k),children:[(0,X.jsx)(v,{}),d(`memory:memoryPage.edit`)]})]}):(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`restore`),d(`memory:memoryPage.restored`)),children:[(0,X.jsx)(w,{}),d(`memory:memoryPage.restore`)]})]})]})}var $e=[`concept`,`file`,`risk`,`preference`,`decision`,`fact`,`task`],et=[.3,.5,.8,1];function tt(e){let t=e??.5;return et.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function nt(e){return e instanceof Error?e.message:String(e)}function rt({spaces:e,node:t,initialSpaceId:n,onClose:r,onSaved:i}){let{t:a}=s(),[o,c]=(0,q.useState)({spaceId:t?.spaceId||n||e[0]?.id||``,title:t?.title||``,content:t?.content||``,type:t?.type||`concept`,sourcePath:t?.sourcePath||``,importance:tt(t?.importance)}),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),p=a(t?`memory:memoryPage.editMemory`:`memory:memoryPage.addMemory`),m=async e=>{if(e.preventDefault(),!l){u(!0),f(``);try{t?await G(t.id,o):await ke(o),await i(a(t?`memory:memoryPage.memoryUpdated`:`memory:memoryPage.memoryCreated`))}catch(e){f(nt(e))}finally{u(!1)}}};return(0,X.jsx)(de,{open:!0,busy:l,onOpenChange:e=>!e&&r(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void m(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:p}),(0,X.jsx)(P,{children:a(`memory:memoryPage.memoryDialogHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryTitle`),(0,X.jsx)(R,{value:o.title,onChange:e=>c({...o,title:e.target.value}),placeholder:a(`memory:memoryPage.forExampleProjectUIConstraints`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryContent`),(0,X.jsx)(fe,{value:o.content,onChange:e=>c({...o,content:e.target.value}),placeholder:a(`memory:memoryPage.recordStandaloneReusableMemoryForFutureChats`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memorySpace`),(0,X.jsx)(be,{value:o.spaceId,onChange:e=>c({...o,spaceId:e.target.value}),children:e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:J(e,a)},e.id))})]}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-x-2.5 gap-y-3 sm:grid-cols-2`,children:[(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryType`),(0,X.jsx)(be,{value:o.type,onChange:e=>c({...o,type:e.target.value}),children:$e.map(e=>(0,X.jsx)(`option`,{value:e,children:Ve(e,a)},e))})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.importance`),(0,X.jsxs)(be,{value:o.importance,onChange:e=>c({...o,importance:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0.3`,children:a(`memory:memoryPage.normal`)}),(0,X.jsx)(`option`,{value:`0.5`,children:a(`memory:memoryPage.common`)}),(0,X.jsx)(`option`,{value:`0.8`,children:a(`memory:memoryPage.important`)}),(0,X.jsx)(`option`,{value:`1`,children:a(`memory:memoryPage.strict`)})]})]})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.relatedFilePath`),(0,X.jsx)(R,{value:o.sourcePath,onChange:e=>c({...o,sourcePath:e.target.value}),placeholder:a(`memory:memoryPage.optionalForExampleECodeProjectREADMEMd`)})]}),d&&(0,X.jsx)(U,{children:d}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:l,onClick:r,children:a(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:l||!o.spaceId||!o.title.trim()||!o.content.trim(),children:[l&&(0,X.jsx)(M,{className:`text-current`}),a(l?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}function it({space:e,onClose:t,onSaved:n}){let{t:r}=s(),[i,a]=(0,q.useState)(e?.name||``),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(``),d=r(e?`memory:memoryPage.renameMemorySpace`:`memory:memoryPage.newMemorySpace`),f=async t=>{if(t.preventDefault(),!o){c(!0),u(``);try{await n(e?await Te(e.id,i):await we(i),r(e?`memory:memoryPage.memorySpaceRenamed`:`memory:memoryPage.memorySpaceCreated`))}catch(e){u(nt(e))}finally{c(!1)}}};return(0,X.jsx)(de,{open:!0,busy:o,onOpenChange:e=>!e&&t(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void f(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:d}),(0,X.jsx)(P,{children:r(`memory:memoryPage.memorySpaceHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[r(`memory:memoryPage.memorySpaceName`),(0,X.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:r(`memory:memoryPage.forExampleProductDesignGuidelines`),autoFocus:!0})]}),l&&(0,X.jsx)(U,{children:l}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:o,onClick:t,children:r(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:o||!i.trim(),children:[o&&(0,X.jsx)(M,{className:`text-current`}),r(o?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}var at=30;function ot({digest:e}){let{t}=s(),r=n(),[i,a]=(0,q.useState)([]);return(0,q.useEffect)(()=>{let t=new AbortController;return K(e.id,t.signal).then(e=>a(e.children||[]),()=>a([])),()=>t.abort()},[e.id]),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`m-0 text-sm leading-relaxed break-words whitespace-pre-wrap`,children:e.text}),i.length>0&&(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`m-0 text-xs font-medium text-content-muted`,children:t(`memory:memoryPage.sessionFacts`)}),(0,X.jsx)(`ul`,{className:`m-0 mt-1 list-disc pl-4 text-sm leading-relaxed`,children:i.map(e=>(0,X.jsx)(`li`,{className:`break-words`,children:e.title},e.id))})]}),e.sessionAvailable&&(0,X.jsx)(`div`,{children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>r(o(e.sessionId)),children:t(`memory:memoryPage.openSession`)})})]})}function st({spaceId:e,spaces:t,refreshKey:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),x=(0,q.useRef)(0),S=e===`all`?``:e,C=(0,q.useCallback)(async()=>{let e=++x.current;u(!0),v(``);try{let t=await W({spaceId:S,limit:at});if(e!==x.current)return;o(t.sessions),m(t.sessions.length>=at),g(!1)}catch(t){if(e!==x.current)return;t instanceof l&&t.status===404?g(!0):v(t instanceof Error?t.message:String(t))}finally{e===x.current&&u(!1)}},[S]);(0,q.useEffect)(()=>(C(),()=>{x.current+=1}),[C,n]);let w=async()=>{let e=a.at(-1)?.windowEnd;if(!e||d)return;let t=x.current;f(!0);try{let n=await W({spaceId:S,before:e,limit:at});if(t!==x.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.sessions.filter(e=>!t.has(e.id))]}),m(n.sessions.length>=at)}catch(e){t===x.current&&v(e instanceof Error?e.message:String(e))}finally{f(!1)}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.sessionsUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):_&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.sessionsLoadFailed`),description:_,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void C(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[_&&(0,X.jsx)(ye,{className:`mt-0`,children:_}),(0,X.jsx)(he,{children:a.map(n=>{let a=n.sessionName||r(`memory:memoryPage.sessionUntitled`),o=t.find(e=>e.id===n.spaceId);return(0,X.jsx)(me,{"data-memory-session":n.sessionId,icon:(0,X.jsx)(Le,{}),name:a,description:y===n.id?void 0:n.text,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(n.windowEnd,i),e===`all`&&o?` · ${J(o,r)}`:``]}),expanded:y===n.id,onExpandedChange:e=>b(e?n.id:``),toggleLabel:a,detail:(0,X.jsx)(ot,{digest:n})},n.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void w(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noSessionDigests`)})}var ct=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate());function lt(e){let t=ct(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()-(t.getDay()+6)%7)}function ut(e,t,n=Date.now()){let r=new Date(n),i=ct(r).getTime(),a=i-864e5,o=lt(r).getTime(),s=new Map,c=(e,t)=>{let n=s.get(e.key);n?n.items.push(t):s.set(e.key,{...e,items:[t]})};for(let n of e){let e=Date.parse(t(n)||``);if(Number.isNaN(e))c({key:`unknown`,kind:`unknown`},n);else if(e>=i)c({key:`today`,kind:`today`},n);else if(e>=a)c({key:`yesterday`,kind:`yesterday`},n);else if(e>=o)c({key:`week`,kind:`week`},n);else{let t=new Date(e);c({key:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}`,kind:`month`,month:new Date(t.getFullYear(),t.getMonth(),1)},n)}}return[...s.values()]}var dt=(0,q.lazy)(()=>t(()=>import(`./MemoryEvolution-DPD3_wye.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]))),Q=`all`;function ft(){try{let e=r.getItem(c.memoryView);return e===`timeline`||e===`sessions`||e===`activity`?e:`evolution`}catch{return`evolution`}}function pt(e){try{r.setItem(c.memoryView,e)}catch{}}function $(e){return e instanceof Error?e.message:String(e)}var mt={spaces:[],selectedSpaceId:``,nodes:[]};function ht({notify:e,onBack:t,requestConfirm:n}){let{t:r,language:i}=s(),a=le(`focusSearch`),[o,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(ft),[d,f]=(0,q.useState)(Q),[m,h]=(0,q.useState)(`current`),[g,_]=(0,q.useState)(mt),[v,y]=(0,q.useState)(!0),[b,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(``),[ee,j]=(0,q.useState)(``),[M,P]=(0,q.useState)(null),[F,ue]=(0,q.useState)(0),[I,L]=(0,q.useState)(null),[de,R]=(0,q.useState)(null),[fe,V]=(0,q.useState)(!1),H=(0,q.useRef)(0),U=(0,q.useCallback)(async()=>{let e=++H.current;y(!0),D(``);try{let t=await Se({spaceId:d,query:o,status:m});if(e!==H.current)return;_(t),T(!0),t.selectedSpaceId&&t.selectedSpaceId!==d&&f(t.selectedSpaceId)}catch(t){e===H.current&&D($(t))}finally{e===H.current&&y(!1)}},[o,d,m]);(0,q.useEffect)(()=>(U(),()=>{H.current+=1}),[U,F]);let xe=async()=>{let e=g.nodes.at(-1),t=e?.validFrom||e?.createdAt;if(!t||b)return;let n=H.current;C(!0);try{let e=await Se({spaceId:d,status:m,before:t});if(n!==H.current)return;_(t=>{let n=new Set(t.nodes.map(e=>e.id));return{...e,nodes:[...t.nodes,...e.nodes.filter(e=>!n.has(e.id))]}})}catch(e){n===H.current&&D($(e))}finally{C(!1)}},W=(0,q.useCallback)(()=>ue(e=>e+1),[]),G=(0,q.useCallback)(t=>{e(t),W()},[e,W]),Ce=(0,q.useCallback)(e=>{j(``),P(null),G(e)},[G]),we=(0,q.useMemo)(()=>[...g.spaces].sort((e,t)=>Number(t.kind===`global`)-Number(e.kind===`global`)),[g.spaces]),K=g.spaces.find(e=>e.id===d)||null,Te=!!o.trim(),Oe=(0,q.useMemo)(()=>ut(g.nodes,e=>e.validFrom||e.createdAt),[g.nodes]),ke=e=>{let t=e;u(t),pt(t)},Me=e=>{c(e),j(``),e.trim()&&l!==`timeline`&&u(`timeline`)},Ne=e=>{f(e),j(``),P(null)},Pe=async()=>{if(K&&await n({title:r(`memory:memoryPage.deleteMemorySpace`),message:r(`memory:memoryPage.deleteMemorySpaceNameAndAllMemoriesInIt`,{name:J(K,r)}),confirmLabel:r(`memory:memoryPage.delete`)}))try{await De(K.id),Ne(Q),G(r(`memory:memoryPage.memorySpaceDeleted`))}catch(e){D($(e))}},Fe=async()=>{try{let{markdown:t}=await Ae(d===Q?``:d),n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),i=document.createElement(`a`);i.href=n,i.download=`pisper-memory-${new Date().toISOString().slice(0,10)}.md`,i.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),e(r(`memory:memoryPage.exported`))}catch(e){D($(e))}},Ie=async()=>{if(!fe){V(!0),D(``);try{let e=await Ee();G(e.ran?r(`memory:memoryPage.consolidated`):r(`memory:memoryPage.nothingToConsolidate`))}catch(e){D($(e))}finally{V(!1)}}},Le=async()=>{if(await n({title:r(`memory:memoryPage.clearEpisodes`),message:r(`memory:memoryPage.clearEpisodesConfirm`),confirmLabel:r(`memory:memoryPage.clearEpisodesAction`)}))try{let{cleared:e}=await je(d===Q?``:d);G(r(`memory:memoryPage.episodesCleared`,{count:e}))}catch(e){D($(e))}},Re=!!K&&K?.kind!==`global`,ze=e=>(0,X.jsx)(Qe,{id:e.id,fallback:e,spaces:g.spaces,refreshKey:F,onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}),Ue=e=>{let t=Be[e.type]||Be.concept,n=We(e,r),a=g.spaces.find(t=>t.id===e.spaceId);return(0,X.jsx)(me,{"data-memory-node":e.id,icon:(0,X.jsx)(t,{}),name:e.title,nameMeta:Ve(e.type,r),description:ee===e.id?void 0:e.content,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Ge(e.validFrom||e.createdAt,i),d===Q&&a?` · ${J(a,r)}`:``,` · ${He(e.sourceType,r)}`]}),status:n.length?(0,X.jsx)(Ze,{labels:n}):void 0,expanded:ee===e.id,onExpandedChange:t=>j(t?e.id:``),toggleLabel:e.title,detail:ze(e)},e.id)},Y=e=>e.kind===`today`?r(`memory:memoryPage.groupToday`):e.kind===`yesterday`?r(`memory:memoryPage.groupYesterday`):e.kind===`week`?r(`memory:memoryPage.groupThisWeek`):e.kind===`unknown`||!e.month?r(`memory:memoryPage.groupUnknown`):new Intl.DateTimeFormat(i,{year:`numeric`,month:`long`}).format(e.month),Ke=r(Te?`memory:memoryPage.noMatchingMemories`:m===`archived`?`memory:memoryPage.noArchivedMemories`:m===`history`?`memory:memoryPage.noHistoryVersions`:`memory:memoryPage.noMemoriesInSpace`);return(0,X.jsx)(se,{asChild:!0,value:l,onValueChange:ke,className:`gap-0`,children:(0,X.jsxs)(_e,{title:r(`navigation:navigation.memory`),description:r(`memory:memoryPage.lede`),back:t&&{label:r(`navigation:sidebar.features`),ariaLabel:r(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,X.jsx)(ve,{search:(0,X.jsx)(pe,{id:te,value:o,onValueChange:Me,placeholder:r(`navigation:pageHeader.searchMemoriesOrFiles`),shortcut:a,clearLabel:r(`navigation:more.clearSearch`)}),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(N,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>L({spaceId:d===Q?`global`:d}),children:[(0,X.jsx)(x,{}),r(`memory:memoryPage.addMemory`)]}),(0,X.jsxs)(ie,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`icon-lg`,className:`max-[650px]:max-w-11`,disabled:!w,"aria-label":r(`memory:memoryPage.moreActions`),title:r(`memory:memoryPage.moreActions`),children:(0,X.jsx)(p,{})})}),(0,X.jsxs)(re,{align:`end`,children:[(0,X.jsx)(O,{onSelect:()=>R(`new`),children:r(`memory:memoryPage.newMemorySpace`)}),(0,X.jsx)(O,{disabled:!Re,onSelect:()=>K&&R(K),children:r(`memory:memoryPage.renameMemorySpace`)}),(0,X.jsx)(O,{variant:`destructive`,disabled:!Re,onSelect:()=>void Pe(),children:r(`memory:memoryPage.deleteMemorySpace`)}),(0,X.jsx)(ne,{}),(0,X.jsx)(O,{onSelect:()=>void Fe(),children:r(`memory:memoryPage.exportMarkdown`)}),(0,X.jsx)(O,{disabled:fe,onSelect:()=>void Ie(),children:r(`memory:memoryPage.consolidateNow`)}),(0,X.jsx)(O,{onSelect:()=>void Le(),children:r(`memory:memoryPage.clearEpisodes`)})]})]})]}),filters:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(oe,{"aria-label":r(`memory:memoryPage.viewsLabel`),children:[(0,X.jsx)(A,{value:`evolution`,children:r(`memory:memoryPage.evolutionView`)}),(0,X.jsx)(A,{value:`timeline`,children:r(`memory:memoryPage.timelineView`)}),(0,X.jsx)(A,{value:`sessions`,children:r(`memory:memoryPage.sessionsView`)}),(0,X.jsx)(A,{value:`activity`,children:r(`memory:memoryPage.activityView`)})]}),(0,X.jsxs)(be,{className:`w-[200px] max-w-full max-[650px]:w-full`,"aria-label":r(`memory:memoryPage.memorySpace`),value:d,disabled:!w,onChange:e=>Ne(e.target.value),children:[(0,X.jsx)(`option`,{value:Q,children:r(`memory:memoryPage.allSpaces`)}),we.map(e=>(0,X.jsx)(`option`,{value:e.id,children:`${J(e,r)} · ${e.nodeCount}`},e.id))]})]}),l===`timeline`&&w&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[Te?(0,X.jsxs)(`p`,{className:`m-0 text-[13px] font-medium text-content-muted tabular-nums`,children:[r(`memory:memoryPage.searchResults`),` · `,g.nodes.length]}):(0,X.jsx)(ce,{"aria-label":r(`memory:memoryPage.statusFilterLabel`),value:m,onValueChange:e=>{h(e),j(``)},options:[{value:`current`,label:r(`memory:memoryPage.statusCurrent`),count:g.counts?.current},{value:`archived`,label:r(`memory:memoryPage.statusArchived`),count:g.counts?.archived},{value:`history`,label:r(`memory:memoryPage.statusHistory`),count:g.counts?.history}]}),(0,X.jsx)(N,{variant:`ghost`,size:`icon-sm`,className:`text-content-muted max-[650px]:size-11`,loading:v,disabled:v,"aria-label":r(`memory:memoryPage.refresh`),title:r(`memory:memoryPage.refresh`),onClick:W,children:(0,X.jsx)(S,{})})]})]})}),children:[!w&&v?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):w?(0,X.jsxs)(X.Fragment,{children:[E&&(0,X.jsx)(ye,{children:E}),(0,X.jsxs)(`div`,{className:`mt-5 min-w-0`,"aria-busy":v,children:[(0,X.jsxs)(ae,{value:`evolution`,className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(q.Suspense,{fallback:(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}),children:(0,X.jsx)(dt,{spaceId:d,refreshKey:F,selectedId:M,onSelect:P})}),(0,X.jsx)(`div`,{role:`region`,"data-memory-detail":!0,"aria-label":r(`memory:memoryPage.selectedMemory`),className:`min-w-0 rounded-[var(--r-md)] border border-stroke px-4 py-3`,children:M?(0,X.jsx)(Qe,{id:M,spaces:g.spaces,refreshKey:F,withHeading:!0,onClose:()=>P(null),onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}):(0,X.jsx)(`p`,{className:`m-0 text-xs leading-normal text-content-muted`,children:r(`memory:memoryPage.selectAMemoryToViewDetails`)})})]}),(0,X.jsxs)(ae,{value:`timeline`,className:`min-w-0`,"data-memory-timeline":!0,children:[g.nodes.length?Te?(0,X.jsx)(he,{children:g.nodes.map(Ue)}):Oe.map(e=>(0,X.jsx)(ge,{"data-memory-group":e.key,className:`mt-5 first:mt-0`,title:Y(e),count:e.items.length,children:(0,X.jsx)(he,{children:e.items.map(Ue)})},e.key)):(0,X.jsx)(B,{compact:!0,title:Ke}),!Te&&g.hasMore&&(0,X.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:b,disabled:b,onClick:()=>void xe(),children:r(`memory:memoryPage.loadMore`)})})]}),(0,X.jsx)(ae,{value:`sessions`,className:`min-w-0`,children:(0,X.jsx)(st,{spaceId:d,spaces:g.spaces,refreshKey:F})}),(0,X.jsx)(ae,{value:`activity`,className:`min-w-0`,children:(0,X.jsx)(Xe,{spaceId:d,refreshKey:F,onChanged:G})})]})]}):(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.loadFailed`),description:E,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void U(),children:r(`common:pageTemplate.retry`)})}),I&&(0,X.jsx)(rt,{spaces:we,node:`id`in I?I:null,initialSpaceId:I.spaceId,onClose:()=>L(null),onSaved:e=>{L(null),G(e)}}),de&&(0,X.jsx)(it,{space:de===`new`?null:de,onClose:()=>R(null),onSaved:(e,t)=>{R(null),Ne(e.id),G(t)}})]})})}export{ht as MemoryPage};
|