dsh-thoughtdag 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-app/assets/{canonical-4rZrwQLF.js → canonical-C3OufoVo.js} +2 -2
- package/dist-app/assets/{canvas-record-UgW4msHo.js → canvas-record-BlrHolpM.js} +1 -1
- package/dist-app/assets/{claude-code-session-r3i8eC0x.js → claude-code-session-D8efciRN.js} +1 -1
- package/dist-app/assets/{codex-session-C1oydShA.js → codex-session-BfatCn8z.js} +1 -1
- package/dist-app/assets/{dsh-session-DN19dxyt.js → dsh-session-DrCSvtGN.js} +1 -1
- package/dist-app/assets/{experiment-loop-B9S8G8tm.js → experiment-loop-XuEe5blq.js} +1 -1
- package/dist-app/assets/{http-bridge-P6t5GDSV.js → http-bridge-BFpCh3Q7.js} +1 -1
- package/dist-app/assets/{index-D0CNSZAd.js → index-AyluzteA.js} +1 -1
- package/dist-app/assets/{index-DOqNVCbY.js → index-BYreuYHM.js} +1 -1
- package/dist-app/assets/{index-4MlMfE8C.js → index-CFc2wOkT.js} +14 -14
- package/dist-app/assets/{index-CgnmeNGy.css → index-H1F6jL5D.css} +1 -1
- package/dist-app/assets/{index-CdxNcIpd.js → index-goc_KBNk.js} +3 -3
- package/dist-app/assets/{pi-session-BvpmiBJX.js → pi-session-geFUlvR4.js} +1 -1
- package/dist-app/assets/{sensitive-scan-BJN9JBOQ.js → sensitive-scan-CB-wz7Ro.js} +1 -1
- package/dist-app/assets/{session-handoff-BGisIC5k.js → session-handoff-DbK-2F0z.js} +2 -2
- package/dist-app/assets/{shared-Kh4K9LTp.js → shared-CeeIorPo.js} +1 -1
- package/dist-app/assets/{turndown-plugin-gfm.cjs-Ccez8Set.js → turndown-plugin-gfm.cjs-CWPGp6Gs.js} +1 -1
- package/dist-app/assets/{update-check-oK0-hbLG.js → update-check-D-Q8qeFG.js} +1 -1
- package/dist-app/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-D8efciRN.js","assets/shared-CeeIorPo.js","assets/codex-session-BfatCn8z.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function a(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();const $O="modulepreload",WO=function(e){return"/thoughtdag/"+e},T5={},ft=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),u=o?.nonce||o?.getAttribute("nonce");r=d(n.map(h=>{if(h=WO(h),h in T5)return;T5[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const x=document.createElement("link");if(x.rel=m?"stylesheet":$O,m||(x.as="script"),x.crossOrigin="",x.href=h,u&&x.setAttribute("nonce",u),document.head.appendChild(x),m)return new Promise((b,y)=>{x.addEventListener("load",b),x.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(o){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=o,window.dispatchEvent(u),!u.defaultPrevented)throw o}return r.then(o=>{for(const u of o||[])u.status==="rejected"&&s(u.reason);return t().catch(s)})};var Cue=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function O0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function _ue(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var V1={exports:{}},yd={};var N5;function VO(){if(N5)return yd;N5=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:o,ref:r!==void 0?r:null,props:s}}return yd.Fragment=t,yd.jsx=n,yd.jsxs=n,yd}var A5;function GO(){return A5||(A5=1,V1.exports=VO()),V1.exports}var l=GO(),G1={exports:{}},an={};var C5;function YO(){if(C5)return an;C5=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(G){return G===null||typeof G!="object"?null:(G=x&&G[x]||G["@@iterator"],typeof G=="function"?G:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,E={};function v(G,J,K){this.props=G,this.context=J,this.refs=E,this.updater=K||y}v.prototype.isReactComponent={},v.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},v.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function A(){}A.prototype=v.prototype;function T(G,J,K){this.props=G,this.context=J,this.refs=E,this.updater=K||y}var C=T.prototype=new A;C.constructor=T,w(C,v.prototype),C.isPureReactComponent=!0;var I=Array.isArray;function O(){}var _={H:null,A:null,T:null,S:null},S=Object.prototype.hasOwnProperty;function z(G,J,K){var ee=K.ref;return{$$typeof:e,type:G,key:J,ref:ee!==void 0?ee:null,props:K}}function V(G,J){return z(G.type,J,G.props)}function P(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function L(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(K){return J[K]})}var Y=/\/+/g;function q(G,J){return typeof G=="object"&&G!==null&&G.key!=null?L(""+G.key):J.toString(36)}function B(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(O,O):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function j(G,J,K,ee,ue){var pe=typeof G;(pe==="undefined"||pe==="boolean")&&(G=null);var be=!1;if(G===null)be=!0;else switch(pe){case"bigint":case"string":case"number":be=!0;break;case"object":switch(G.$$typeof){case e:case t:be=!0;break;case m:return be=G._init,j(be(G._payload),J,K,ee,ue)}}if(be)return ue=ue(G),be=ee===""?"."+q(G,0):ee,I(ue)?(K="",be!=null&&(K=be.replace(Y,"$&/")+"/"),j(ue,J,K,"",function(Ce){return Ce})):ue!=null&&(P(ue)&&(ue=V(ue,K+(ue.key==null||G&&G.key===ue.key?"":(""+ue.key).replace(Y,"$&/")+"/")+be)),J.push(ue)),1;be=0;var ae=ee===""?".":ee+":";if(I(G))for(var xe=0;xe<G.length;xe++)ee=G[xe],pe=ae+q(ee,xe),be+=j(ee,J,K,pe,ue);else if(xe=b(G),typeof xe=="function")for(G=xe.call(G),xe=0;!(ee=G.next()).done;)ee=ee.value,pe=ae+q(ee,xe++),be+=j(ee,J,K,pe,ue);else if(pe==="object"){if(typeof G.then=="function")return j(B(G),J,K,ee,ue);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return be}function $(G,J,K){if(G==null)return G;var ee=[],ue=0;return j(G,ee,"","",function(pe){return J.call(K,pe,ue++)}),ee}function X(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(K){(G._status===0||G._status===-1)&&(G._status=1,G._result=K)},function(K){(G._status===0||G._status===-1)&&(G._status=2,G._result=K)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._result.default;throw G._result}var Q=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var J=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(J))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},F={map:$,forEach:function(G,J,K){$(G,function(){J.apply(this,arguments)},K)},count:function(G){var J=0;return $(G,function(){J++}),J},toArray:function(G){return $(G,function(J){return J})||[]},only:function(G){if(!P(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return an.Activity=p,an.Children=F,an.Component=v,an.Fragment=n,an.Profiler=r,an.PureComponent=T,an.StrictMode=a,an.Suspense=d,an.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,an.__COMPILER_RUNTIME={__proto__:null,c:function(G){return _.H.useMemoCache(G)}},an.cache=function(G){return function(){return G.apply(null,arguments)}},an.cacheSignal=function(){return null},an.cloneElement=function(G,J,K){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var ee=w({},G.props),ue=G.key;if(J!=null)for(pe in J.key!==void 0&&(ue=""+J.key),J)!S.call(J,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&J.ref===void 0||(ee[pe]=J[pe]);var pe=arguments.length-2;if(pe===1)ee.children=K;else if(1<pe){for(var be=Array(pe),ae=0;ae<pe;ae++)be[ae]=arguments[ae+2];ee.children=be}return z(G.type,ue,ee)},an.createContext=function(G){return G={$$typeof:o,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:s,_context:G},G},an.createElement=function(G,J,K){var ee,ue={},pe=null;if(J!=null)for(ee in J.key!==void 0&&(pe=""+J.key),J)S.call(J,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(ue[ee]=J[ee]);var be=arguments.length-2;if(be===1)ue.children=K;else if(1<be){for(var ae=Array(be),xe=0;xe<be;xe++)ae[xe]=arguments[xe+2];ue.children=ae}if(G&&G.defaultProps)for(ee in be=G.defaultProps,be)ue[ee]===void 0&&(ue[ee]=be[ee]);return z(G,pe,ue)},an.createRef=function(){return{current:null}},an.forwardRef=function(G){return{$$typeof:u,render:G}},an.isValidElement=P,an.lazy=function(G){return{$$typeof:m,_payload:{_status:-1,_result:G},_init:X}},an.memo=function(G,J){return{$$typeof:h,type:G,compare:J===void 0?null:J}},an.startTransition=function(G){var J=_.T,K={};_.T=K;try{var ee=G(),ue=_.S;ue!==null&&ue(K,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(O,Q)}catch(pe){Q(pe)}finally{J!==null&&K.types!==null&&(J.types=K.types),_.T=J}},an.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},an.use=function(G){return _.H.use(G)},an.useActionState=function(G,J,K){return _.H.useActionState(G,J,K)},an.useCallback=function(G,J){return _.H.useCallback(G,J)},an.useContext=function(G){return _.H.useContext(G)},an.useDebugValue=function(){},an.useDeferredValue=function(G,J){return _.H.useDeferredValue(G,J)},an.useEffect=function(G,J){return _.H.useEffect(G,J)},an.useEffectEvent=function(G){return _.H.useEffectEvent(G)},an.useId=function(){return _.H.useId()},an.useImperativeHandle=function(G,J,K){return _.H.useImperativeHandle(G,J,K)},an.useInsertionEffect=function(G,J){return _.H.useInsertionEffect(G,J)},an.useLayoutEffect=function(G,J){return _.H.useLayoutEffect(G,J)},an.useMemo=function(G,J){return _.H.useMemo(G,J)},an.useOptimistic=function(G,J){return _.H.useOptimistic(G,J)},an.useReducer=function(G,J,K){return _.H.useReducer(G,J,K)},an.useRef=function(G){return _.H.useRef(G)},an.useState=function(G){return _.H.useState(G)},an.useSyncExternalStore=function(G,J,K){return _.H.useSyncExternalStore(G,J,K)},an.useTransition=function(){return _.H.useTransition()},an.version="19.2.4",an}var _5;function D0(){return _5||(_5=1,G1.exports=YO()),G1.exports}var D=D0();const jd=O0(D);var Y1={exports:{}},vd={},K1={exports:{}},X1={};var M5;function KO(){return M5||(M5=1,(function(e){function t(j,$){var X=j.length;j.push($);e:for(;0<X;){var Q=X-1>>>1,F=j[Q];if(0<r(F,$))j[Q]=$,j[X]=F,X=Q;else break e}}function n(j){return j.length===0?null:j[0]}function a(j){if(j.length===0)return null;var $=j[0],X=j.pop();if(X!==$){j[0]=X;e:for(var Q=0,F=j.length,G=F>>>1;Q<G;){var J=2*(Q+1)-1,K=j[J],ee=J+1,ue=j[ee];if(0>r(K,X))ee<F&&0>r(ue,K)?(j[Q]=ue,j[ee]=X,Q=ee):(j[Q]=K,j[J]=X,Q=J);else if(ee<F&&0>r(ue,X))j[Q]=ue,j[ee]=X,Q=ee;else break e}}return $}function r(j,$){var X=j.sortIndex-$.sortIndex;return X!==0?X:j.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,u=o.now();e.unstable_now=function(){return o.now()-u}}var d=[],h=[],m=1,p=null,x=3,b=!1,y=!1,w=!1,E=!1,v=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function C(j){for(var $=n(h);$!==null;){if($.callback===null)a(h);else if($.startTime<=j)a(h),$.sortIndex=$.expirationTime,t(d,$);else break;$=n(h)}}function I(j){if(w=!1,C(j),!y)if(n(d)!==null)y=!0,O||(O=!0,L());else{var $=n(h);$!==null&&B(I,$.startTime-j)}}var O=!1,_=-1,S=5,z=-1;function V(){return E?!0:!(e.unstable_now()-z<S)}function P(){if(E=!1,O){var j=e.unstable_now();z=j;var $=!0;try{e:{y=!1,w&&(w=!1,A(_),_=-1),b=!0;var X=x;try{t:{for(C(j),p=n(d);p!==null&&!(p.expirationTime>j&&V());){var Q=p.callback;if(typeof Q=="function"){p.callback=null,x=p.priorityLevel;var F=Q(p.expirationTime<=j);if(j=e.unstable_now(),typeof F=="function"){p.callback=F,C(j),$=!0;break t}p===n(d)&&a(d),C(j)}else a(d);p=n(d)}if(p!==null)$=!0;else{var G=n(h);G!==null&&B(I,G.startTime-j),$=!1}}break e}finally{p=null,x=X,b=!1}$=void 0}}finally{$?L():O=!1}}}var L;if(typeof T=="function")L=function(){T(P)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,q=Y.port2;Y.port1.onmessage=P,L=function(){q.postMessage(null)}}else L=function(){v(P,0)};function B(j,$){_=v(function(){j(e.unstable_now())},$)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):S=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(j){switch(x){case 1:case 2:case 3:var $=3;break;default:$=x}var X=x;x=$;try{return j()}finally{x=X}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(j,$){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var X=x;x=j;try{return $()}finally{x=X}},e.unstable_scheduleCallback=function(j,$,X){var Q=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Q+X:Q):X=Q,j){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=X+F,j={id:m++,callback:$,priorityLevel:j,startTime:X,expirationTime:F,sortIndex:-1},X>Q?(j.sortIndex=X,t(h,j),n(d)===null&&j===n(h)&&(w?(A(_),_=-1):w=!0,B(I,X-Q))):(j.sortIndex=F,t(d,j),y||b||(y=!0,O||(O=!0,L()))),j},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(j){var $=x;return function(){var X=x;x=$;try{return j.apply(this,arguments)}finally{x=X}}}})(X1)),X1}var I5;function XO(){return I5||(I5=1,K1.exports=KO()),K1.exports}var Q1={exports:{}},rr={};var O5;function QO(){if(O5)return rr;O5=1;var e=D0();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function s(d,h,m){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:p==null?null:""+p,children:d,containerInfo:h,implementation:m}}var o=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return rr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,rr.createPortal=function(d,h){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return s(d,h,null,m)},rr.flushSync=function(d){var h=o.T,m=a.p;try{if(o.T=null,a.p=2,d)return d()}finally{o.T=h,a.p=m,a.d.f()}},rr.preconnect=function(d,h){typeof d=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(d,h))},rr.prefetchDNS=function(d){typeof d=="string"&&a.d.D(d)},rr.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var m=h.as,p=u(m,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,b=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?a.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:p,integrity:x,fetchPriority:b}):m==="script"&&a.d.X(d,{crossOrigin:p,integrity:x,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},rr.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=u(h.as,h.crossOrigin);a.d.M(d,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(d)},rr.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,p=u(m,h.crossOrigin);a.d.L(d,m,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},rr.preloadModule=function(d,h){if(typeof d=="string")if(h){var m=u(h.as,h.crossOrigin);a.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(d)},rr.requestFormReset=function(d){a.d.r(d)},rr.unstable_batchedUpdates=function(d,h){return d(h)},rr.useFormState=function(d,h,m){return o.H.useFormState(d,h,m)},rr.useFormStatus=function(){return o.H.useHostTransitionStatus()},rr.version="19.2.4",rr}var D5;function WT(){if(D5)return Q1.exports;D5=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Q1.exports=QO(),Q1.exports}var R5;function ZO(){if(R5)return vd;R5=1;var e=XO(),t=D0(),n=WT();function a(i){var c="https://react.dev/errors/"+i;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+i+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function s(i){var c=i,f=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(f=c.return),i=c.return;while(i)}return c.tag===3?f:null}function o(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function u(i){if(i.tag===31){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function d(i){if(s(i)!==i)throw Error(a(188))}function h(i){var c=i.alternate;if(!c){if(c=s(i),c===null)throw Error(a(188));return c!==i?null:i}for(var f=i,g=c;;){var k=f.return;if(k===null)break;var N=k.alternate;if(N===null){if(g=k.return,g!==null){f=g;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===f)return d(k),i;if(N===g)return d(k),c;N=N.sibling}throw Error(a(188))}if(f.return!==g.return)f=k,g=N;else{for(var W=!1,te=k.child;te;){if(te===f){W=!0,f=k,g=N;break}if(te===g){W=!0,g=k,f=N;break}te=te.sibling}if(!W){for(te=N.child;te;){if(te===f){W=!0,f=N,g=k;break}if(te===g){W=!0,g=N,f=k;break}te=te.sibling}if(!W)throw Error(a(189))}}if(f.alternate!==g)throw Error(a(190))}if(f.tag!==3)throw Error(a(188));return f.stateNode.current===f?i:c}function m(i){var c=i.tag;if(c===5||c===26||c===27||c===6)return i;for(i=i.child;i!==null;){if(c=m(i),c!==null)return c;i=i.sibling}return null}var p=Object.assign,x=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),T=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function L(i){return i===null||typeof i!="object"?null:(i=P&&i[P]||i["@@iterator"],typeof i=="function"?i:null)}var Y=Symbol.for("react.client.reference");function q(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Y?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case w:return"Fragment";case v:return"Profiler";case E:return"StrictMode";case I:return"Suspense";case O:return"SuspenseList";case z:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case y:return"Portal";case T:return i.displayName||"Context";case A:return(i._context.displayName||"Context")+".Consumer";case C:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case _:return c=i.displayName||null,c!==null?c:q(i.type)||"Memo";case S:c=i._payload,i=i._init;try{return q(i(c))}catch{}}return null}var B=Array.isArray,j=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Q=[],F=-1;function G(i){return{current:i}}function J(i){0>F||(i.current=Q[F],Q[F]=null,F--)}function K(i,c){F++,Q[F]=i.current,i.current=c}var ee=G(null),ue=G(null),pe=G(null),be=G(null);function ae(i,c){switch(K(pe,c),K(ue,i),K(ee,null),c.nodeType){case 9:case 11:i=(i=c.documentElement)&&(i=i.namespaceURI)?Y3(i):0;break;default:if(i=c.tagName,c=c.namespaceURI)c=Y3(c),i=K3(c,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}J(ee),K(ee,i)}function xe(){J(ee),J(ue),J(pe)}function Ce(i){i.memoizedState!==null&&K(be,i);var c=ee.current,f=K3(c,i.type);c!==f&&(K(ue,i),K(ee,f))}function ze(i){ue.current===i&&(J(ee),J(ue)),be.current===i&&(J(be),pd._currentValue=X)}var Ie,Fe;function Ee(i){if(Ie===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);Ie=c&&c[1]||"",Fe=-1<f.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Ie+i+Fe}var Me=!1;function De(i,c){if(!i||Me)return"";Me=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(c){var Ke=function(){throw Error()};if(Object.defineProperty(Ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ke,[])}catch(qe){var He=qe}Reflect.construct(i,[],Ke)}else{try{Ke.call()}catch(qe){He=qe}i.call(Ke.prototype)}}else{try{throw Error()}catch(qe){He=qe}(Ke=i())&&typeof Ke.catch=="function"&&Ke.catch(function(){})}}catch(qe){if(qe&&He&&typeof qe.stack=="string")return[qe.stack,He.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var N=g.DetermineComponentFrameRoot(),W=N[0],te=N[1];if(W&&te){var ge=W.split(`
|
|
@@ -63,7 +63,7 @@ Economist: You analyze through incentives and trade-offs...`,"fanout.confirm":"F
|
|
|
63
63
|
`);m=w.pop()||"";for(const E of w){const v=E.trim();if(!v.startsWith("data: "))continue;const A=v.slice(6);if(A==="[DONE]")continue;let T;try{T=JSON.parse(A)}catch{continue}if(T.error){const _=typeof T.error=="string"?T.error:T.error.message;throw new Error(_||"Upstream stream error")}const C=T.choices?.[0];if(!C)continue;const I=C.delta;I?.content&&(p+=I.content,a(I.content));const O=I?.reasoning??I?.reasoning_content;O&&r(O);for(const _ of I?.annotations??[]){const S=_.url_citation;S?.url&&!s.has(S.url)&&s.set(S.url,{title:S.title||S.url,url:S.url,media:"Web"})}C.finish_reason&&(x=C.finish_reason)}}return{text:p,finishReason:x}}async function Hq(e,t,n,a,r,s,o,u){const d=u8(n,s),h=p2(e.baseURL)&&u!==!1,m=new Map;let p="",x="";const b=w=>{p+=w,a(w,p)},y=w=>{x+=w,o?.onReasoning?.(w,x)};try{let w=await fE(e,h?`${t}:online`:t,d,b,y,m,r);if(h&&p.length===0&&(w=await fE(e,t,d,b,y,m,r)),p.length===0)throw new Error(`Model produced no text (finish: ${w.finishReason}, model: ${t}${h?" via :online":""})`);return m.size>0&&o?.onSources?.([...m.values()]),p}catch(w){throw d8(w)}}async function Fq(e,t,n,a){try{const r=await fetch(`${e.baseURL.replace(/\/$/,"")}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json","X-Title":"ThoughtDAG"},body:JSON.stringify({model:t,messages:u8(n,a)})});if(!r.ok){const o=await r.json().catch(()=>null);throw new Error(o?.error?.message||`HTTP ${r.status}`)}return(await r.json()).choices?.[0]?.message?.content??""}catch(r){throw d8(r)}}const Uq=`${li}/api/claude`,h8=()=>{const e=rs();return e.length>0?e:void 0},qq=`${li}/api/stream`,$q=`${li}/api/pdf-extract`,Wq=`${li}/api/approvals`;async function Vq(e,t){const n=e.id,a=typeof t=="string"?{confirmed:t!=="rejected",...t==="allowed-session"?{scope:"session"}:{}}:t;if(e.channel?.runId&&window.desktopAgents)try{return await window.desktopAgents.answer(e.channel.runId,n,a)}catch{return!1}const r="confirmed"in a&&a.confirmed?"allowed-once":"rejected";try{return(await fetch(`${Wq}/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({outcome:r})})).ok}catch{return!1}}async function Gq(e){const t=await fetch($q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({base64:e})});if(!t.ok){const n=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw new Error(Fl(n,`HTTP ${t.status}`))}return t.json()}async function Yq(e){try{const t=await fetch(`${li}/api/fetch-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})});if(!t.ok){const n=await t.json().catch(()=>({error:t.status===404?"Proxy has no /api/fetch-url — restart it (npm run server)":`HTTP ${t.status}`}));throw new Error(Fl(n,`HTTP ${t.status}`))}return t.json()}catch(t){throw x2(t)}}function x2(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e instanceof Error?e.message:"Unknown error";return new Error(/fetch|network|Failed to fetch/i.test(t)?`${t} — is the proxy running? (npm run server)`:t)}async function f8(e,t){if(!t?.length)return t;const n=await dr(),a=e??n?.default??void 0,r=a?n?.models.find(s=>s.id===a):void 0;if(!(r&&r.vision===!1&&t.every(s=>s.hasCompanion)))return t}async function m8(e,t){if(!t?.length)return;const n=await dr(),a=e??n?.default??void 0,r=a?n?.models.find(s=>s.id===a):void 0;if(r&&r.vision===!1)throw new Error(Te("error.textOnlyModelImages"))}async function er(e,t,n,a){const r=n||oe.getState().selectedModel||void 0;t=await f8(r,t);const s=g2();if(s&&r)return await m8(r,t),Fq(s,r,e,t);try{const o=await fetch(Uq,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e,images:t?.length?t:void 0,model:n||oe.getState().selectedModel||void 0,...a?.fast?{fast:!0}:{},providers:h8()})});if(!o.ok){const d=await o.json().catch(()=>({error:"Unknown error"}));throw new Error(Fl(d,`HTTP ${o.status}`))}return(await o.json()).text}catch(o){throw x2(o)}}async function p8(e,t,n,a,r,s,o,u){const d=o||oe.getState().selectedModel||void 0;if(d&&ri(d)&&window.desktopAgents)return r?.onDispatch?.({messages:e,images:a??[],model:d,toolPrefs:s??{},lane:"proxy"}),PV(e,t,n,a,r,d,u?.cwd?{cwd:u.cwd,sessionPath:u.sessionPath,forkEntryId:u.forkEntryId,continue:u.continue}:void 0,u?.nodeId);a=await f8(d,a);let h=!1;const m={...r,onRerouted:(w,E)=>{h=!0,r?.onRerouted?.(w,E)}},p=async(w,E)=>{const v=g2();return v&&d?(await m8(d,w),r?.onDispatch?.({messages:e,images:w??[],model:d,toolPrefs:s??{},lane:"direct"}),Hq(v,d,e,E,n,w,m,s?.web)):(r?.onDispatch?.({messages:e,images:w??[],model:d??"",toolPrefs:s??{},lane:"proxy"}),y(w,E))},x=d?mq(d):void 0,b=!!d&&rs().some(w=>w.models.some(E=>E.id===d));if(a?.length&&d&&b&&x!==!1){const w=d.split("/").pop()??d,E=(A,T)=>{pq(d,A)&&($0(rs()).then(ql).catch(()=>{}),We("info",ve(Te(T),{m:w})))};let v=!1;try{const A=await p(a,(T,C)=>{v=!0,t(T,C)});return x===void 0&&!h&&A.trim()&&E(!0,"toast.visionLearnedTrue"),A}catch(A){if(A instanceof DOMException&&A.name==="AbortError"||v||h)throw A;if(x===!0){const C=A instanceof Error?A.message:String(A);throw new Error(`${C} ${Te("error.visionDeclaredHint")}`)}const T=await p(void 0,t);return T.trim()&&E(!1,"toast.visionLearnedFalse"),T}}return p(a,t);async function y(w,E){try{const v=await fetch(qq,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e,images:w?.length?w:void 0,webSearch:s?.web,scholarSearch:s?.scholar,mcpTools:s?.mcp,...oe.getState().searchEnginePref!=="server"?{searchEngine:oe.getState().searchEnginePref}:{},...oe.getState().anysearchKey?{anysearchKey:oe.getState().anysearchKey}:{},model:o||oe.getState().selectedModel||void 0,providers:h8(),...u?{harness:u}:{}}),signal:n});if(!v.ok){const _=await v.json().catch(()=>({error:"Unknown error"}));throw new Error(Fl(_,`HTTP ${v.status}`))}const A=v.body.getReader(),T=new TextDecoder;let C="",I="",O="";for(;;){const{done:_,value:S}=await A.read();if(_)break;C+=T.decode(S,{stream:!0});const z=C.split(`
|
|
64
64
|
`);C=z.pop()||"";for(const V of z){const P=V.trim();if(!P||!P.startsWith("data: "))continue;const L=P.slice(6);if(L!=="[DONE]")try{const Y=JSON.parse(L);if(Y.error)throw new Error(Fl(Y.error,"Upstream stream error"));Y.text&&(I+=Y.text,E(Y.text,I)),Y.reasoning&&(O+=Y.reasoning,m.onReasoning?.(Y.reasoning,O)),Y.tool?.query&&m.onToolCall?.(Y.tool.name,Y.tool.query),Y.gatewaySearch&&m.onGatewaySearch?.(),typeof Y.harnessSession=="string"&&m.onHarnessSession?.(Y.harnessSession,!!Y.continued),Y.harnessTurn?.session&&m.onHarnessTurn?.(Y.harnessTurn),Y.approval?.id&&m.onApproval?.(Y.approval),Y.approvalDecided?.id&&m.onApprovalDecided?.(Y.approvalDecided),Array.isArray(Y.sources)&&m.onSources?.(Y.sources),Y.rerouted?.to&&(We("info",ve(Te("toast.visionRerouted"),{from:Y.rerouted.from,to:Y.rerouted.to}),7e3),m.onRerouted?.(Y.rerouted.from,Y.rerouted.to)),Y.imageFallback?.model&&(We("info",ve(Te("toast.imagesAsText"),{model:Y.imageFallback.model}),9e3),m.onImageFallback?.(Y.imageFallback.model))}catch(Y){if(Y instanceof Error&&Y.message!==L)throw Y}}}return I}catch(v){throw x2(v)}}}const Gb="att-content:",g8=e=>`${Gb}${e}`,x8=e=>e.type==="application/pdf"&&!!e.content&&!e.contentInVault;async function b2(e){return x8(e)?(await Lr(g8(e.id),e.content),{...e,content:"",contentInVault:!0}):e}async function y2(e){return e.contentInVault?await Yo(g8(e.id))??"":e.content}async function v2(e){const t=[];for(const n of e){const a=n.data.attachments;if(!a?.some(s=>s.contentInVault)){t.push(n);continue}const r=[];for(const s of a){if(!s.contentInVault){r.push(s);continue}const o=await y2(s),u={...s,content:o};delete u.contentInVault,r.push(u)}t.push({...n,data:{...n.data,attachments:r}})}return t}async function vp(e){const t=[];for(const n of e){const a=n.data.attachments;if(!a?.some(x8)){t.push(n);continue}const r=[];for(const s of a)r.push(await b2(s));t.push({...n,data:{...n.data,attachments:r}})}return t}async function b8(e){const t=await s8();let n=0;for(const a of t)typeof a!="string"||!a.startsWith(Gb)||e.has(a.slice(Gb.length))||(await yu(a),n++);return n}const Kq=Object.freeze(Object.defineProperty({__proto__:null,gcVault:b8,inlineVaultedContent:v2,internAttachment:b2,internNodes:vp,loadAttachmentContent:y2},Symbol.toStringTag,{value:"Module"}));function Xq(e){return e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/[ \t]+/g," ").replace(/\s*\n\s*(\s*\n\s*)+/g,`
|
|
65
65
|
|
|
66
|
-
`).trim()}const Qq=/\.(md|txt|js|ts|tsx|jsx|py|json|csv|yaml|yml|toml|sh|bash|zsh|c|cpp|h|hpp|java|rs|go|rb|swift|kt|css|xml|sql|r|m|lua)$/i,Zq=/\.x?html?$/i,Jq=/\.(pptx?|key|odp|doc|rtf|odt|xlsx?|numbers|ods)$/i,b0="image/*,.pdf,.txt,.md,.js,.ts,.tsx,.jsx,.py,.json,.csv,.yaml,.yml,.toml,.sh,.c,.cpp,.h,.java,.rs,.go,.rb,.swift,.css,.html,.htm,.xml,.sql";function Kc(e){return`${e.name}|${e.size}|${e.content?.substring(0,100)}`}function e$(e){return new Promise(t=>{const n=Tn(),a=new Date().toISOString(),r=e.type.startsWith("image/"),s=e.type==="application/pdf"||e.name.endsWith(".pdf"),o=e.type==="text/html"||Zq.test(e.name),u=e.type.startsWith("text/")||Qq.test(e.name),d=e.name.toLowerCase().endsWith(".docx");if(r){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:e.type,size:e.size,addedAt:a,content:m,thumbnailUrl:h.result})},h.readAsDataURL(e)}else if(s){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:"application/pdf",size:e.size,addedAt:a,content:m})},h.readAsDataURL(e)}else d?e.arrayBuffer().then(async h=>{try{const p=await(await ft(()=>import("./index-
|
|
66
|
+
`).trim()}const Qq=/\.(md|txt|js|ts|tsx|jsx|py|json|csv|yaml|yml|toml|sh|bash|zsh|c|cpp|h|hpp|java|rs|go|rb|swift|kt|css|xml|sql|r|m|lua)$/i,Zq=/\.x?html?$/i,Jq=/\.(pptx?|key|odp|doc|rtf|odt|xlsx?|numbers|ods)$/i,b0="image/*,.pdf,.txt,.md,.js,.ts,.tsx,.jsx,.py,.json,.csv,.yaml,.yml,.toml,.sh,.c,.cpp,.h,.java,.rs,.go,.rb,.swift,.css,.html,.htm,.xml,.sql";function Kc(e){return`${e.name}|${e.size}|${e.content?.substring(0,100)}`}function e$(e){return new Promise(t=>{const n=Tn(),a=new Date().toISOString(),r=e.type.startsWith("image/"),s=e.type==="application/pdf"||e.name.endsWith(".pdf"),o=e.type==="text/html"||Zq.test(e.name),u=e.type.startsWith("text/")||Qq.test(e.name),d=e.name.toLowerCase().endsWith(".docx");if(r){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:e.type,size:e.size,addedAt:a,content:m,thumbnailUrl:h.result})},h.readAsDataURL(e)}else if(s){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:"application/pdf",size:e.size,addedAt:a,content:m})},h.readAsDataURL(e)}else d?e.arrayBuffer().then(async h=>{try{const p=await(await ft(()=>import("./index-BYreuYHM.js").then(x=>x.i),[])).extractRawText({arrayBuffer:h});t({id:n,name:e.name,type:"text/plain",size:e.size,addedAt:a,content:p.value.trim()})}catch{t(null)}}):o?e.text().then(h=>{t({id:n,name:e.name,type:"text/html",size:e.size,addedAt:a,content:h})}):u?e.text().then(h=>{t({id:n,name:e.name,type:e.type||"text/plain",size:e.size,addedAt:a,content:h})}):t(null)})}async function mE(e){const[t,n]=await Promise.all([ft(()=>import("./pdf-gh-BrLFn.js"),[]),ft(()=>import("./pdf.worker.min-C_APr3k7.js"),[])]);t.GlobalWorkerOptions.workerSrc=n.default;const a=Uint8Array.from(atob(e),r=>r.charCodeAt(0));return t.getDocument({data:a,verbosity:0}).promise}const t$=150;async function pE(e){const t=t$/72,n=[];for(let a=1;a<=e.numPages;a++){const r=document.createElement("canvas");try{const s=await e.getPage(a),o=s.getViewport({scale:t});r.width=Math.ceil(o.width),r.height=Math.ceil(o.height);const u=r.getContext("2d");if(!u)throw new Error("no 2d context");await s.render({canvasContext:u,viewport:o}).promise}catch{r.width=8,r.height=8}n.push(r.toDataURL("image/png").split(",")[1])}return n}async function W0(e,t){if(Jq.test(e.name)){We("info",`${e.name}: ${Te("content.officeExportHint")}`);return}const n=await e$(e);if(!n)return;if(n.type==="text/html"){t.add({...n,isExtracting:!0});try{const{extractHtmlMaterial:r}=await ft(async()=>{const{extractHtmlMaterial:o}=await Promise.resolve().then(()=>CM);return{extractHtmlMaterial:o}},void 0),s=await r(n.content);t.update(n.id,{extractedText:s.markdown,numPages:s.numPages,isExtracting:!1})}catch{t.update(n.id,{extractedText:Xq(n.content),isExtracting:!1})}return}if(n.type!=="application/pdf"){t.add(n);return}const a=await b2(n);t.add({...a,isExtracting:!0});try{const r=await Gq(n.content);if(!r.numPages&&!r.text?.trim())throw new Error("empty extraction result");const s=r.numPages||0;let o=r.images;if(!o?.length)try{const u=await mE(n.content);o=await pE(u),u.destroy()}catch{o=void 0}t.update(n.id,{extractedText:r.text,pageImages:o?.length?o:void 0,numPages:s,renderMode:s>Qk?"text-only":"full",isExtracting:!1})}catch{try{const r=await mE(n.content),s=[];for(let u=1;u<=r.numPages;u++)try{const h=await(await r.getPage(u)).getTextContent();s.push(h.items.map(m=>"str"in m?m.str:"").join(" "))}catch{s.push("")}let o;try{o=await pE(r)}catch{o=void 0}r.destroy(),t.update(n.id,{extractedText:s.join(`
|
|
67
67
|
|
|
68
68
|
`).trim(),pageImages:o?.length?o:void 0,numPages:r.numPages,renderMode:r.numPages>Qk?"text-only":"full",isExtracting:!1})}catch{t.update(n.id,{isExtracting:!1})}}}const Ed="[*_`~()#>\\[\\]|-]*",n$="\\s+(?:(?:\\d{1,3}[.)]|[-*+>|]|#{1,6}|[-:|]{3,})\\s+)*";function w2(e){const t=[...e.trim()];if(t.length===0)return null;const n=[];let a=!1;for(const r of t){if(/\s/.test(r)){a=!0;continue}const s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n.length===0?n.push(s):a?n.push(`${Ed}${n$}${Ed}${s}`):n.push(`${Ed}${s}`),a=!1}try{return new RegExp(Ed+n.join("")+Ed,"g")}catch{return null}}function a$(e,t){const n=w2(t);return n?n.test(e):!1}function im(e,t){const n=e??[],a=n.filter(r=>a$(t,r.text));return a.length===n.length?n:a}function gE(e){const t=e.data.question.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}…`:t}function y8(e){const t=e.data.highlightMode||"off",n=e.data.highlights||[];if(t==="filter"&&n.length>0)return n.map(a=>a.text).join(`
|
|
69
69
|
|
|
@@ -153,7 +153,7 @@ ${y??`*${ve(Te("reader.pageFail"),{n:p+1})}*`}`),n(p+1,d.length)}if(!a()){if(!m)
|
|
|
153
153
|
`)[0].slice(0,80)}catch{}return null}function bW(e){for(const t of e){if(t.type!=="user/message")continue;const n=t.data;if(!n||n.source?.kind&&n.source.kind!=="user")continue;const a=(n.content??[]).filter(r=>r.type==="text"&&r.text).map(r=>r.text).join(`
|
|
154
154
|
`).trim();if(a&&!a.startsWith("<"))return a.split(`
|
|
155
155
|
`)[0].slice(0,80)}return null}const q8="thoughtdag.atlas.disabledRoots",M2=()=>{try{return new Set(JSON.parse(localStorage.getItem(q8)??"[]"))}catch{return new Set}};function yW(e,t){const n=M2();t?n.add(e):n.delete(e),localStorage.setItem(q8,JSON.stringify([...n]))}const Rm=new Set;async function vW(){const e=window.desktopSessions;if(!e)return[];const t=M2(),n=(await e.roots().catch(()=>[])).filter(r=>r.exists&&!t.has(r.key)).map(r=>r.key),a=[];for(const r of n){const o=[...await e.list(r).catch(()=>[])].sort((d,h)=>h.mtime-d.mtime),u=12;for(let d=0;d<o.length;d+=u){const h=await Promise.all(o.slice(d,d+u).map(async m=>{const p=m.rel.endsWith(".zstd")?TE:xW,x=await e.head(r,m.rel,p).catch(()=>"");if(!x)return null;const b=NE(r,m.rel,x,m.mtime,m.size);if(b)return b;const y=await e.head(r,m.rel,TE).catch(()=>"");return y.length>x.length?NE(r,m.rel,y,m.mtime,m.size):null}));for(const m of h)m&&a.push(m)}}Rm.clear();for(const r of a)Rm.add(r.sessionId);return a.sort((r,s)=>s.mtime-r.mtime)}function wW(e){const t=new Map;for(const n of e){const a=n.cwd??"";let r=t.get(a);r||(r={cwd:n.cwd,name:n.cwd?n.cwd.split("/").filter(Boolean).pop()??n.cwd:"",cards:[]},t.set(a,r)),r.cards.push(n)}return[...t.values()].sort((n,a)=>!n.cwd!=!a.cwd?n.cwd?-1:1:a.cards[0].mtime-n.cards[0].mtime)}async function AE(e,t){let n="";for(;;){const a=await t();if(a===null)break;const r=(n+a).split(`
|
|
156
|
-
`);n=r.pop()??"";for(const s of r)e.feedLine(s)}return n&&e.feedLine(n),e.toSubagentSession()}async function Uc(e,t,n,a){if(!e?.adopt||!e.sessionId||!window.desktopSessions)return e;const r=[];try{const{shellSessionReader:s}=await ft(async()=>{const{shellSessionReader:o}=await import("./canonical-
|
|
156
|
+
`);n=r.pop()??"";for(const s of r)e.feedLine(s)}return n&&e.feedLine(n),e.toSubagentSession()}async function Uc(e,t,n,a){if(!e?.adopt||!e.sessionId||!window.desktopSessions)return e;const r=[];try{const{shellSessionReader:s}=await ft(async()=>{const{shellSessionReader:o}=await import("./canonical-C3OufoVo.js");return{shellSessionReader:o}},[]);if(e.source==="claude-code"){const o=`${n.replace(/\.jsonl$/,"")}/subagents/`,u=(await window.desktopSessions.list(t)).map(d=>d.rel).filter(d=>d.startsWith(o)&&d.endsWith(".jsonl"));if(u.length){const{ClaudeSessionCollector:d}=await ft(async()=>{const{ClaudeSessionCollector:h}=await import("./claude-code-session-D8efciRN.js");return{ClaudeSessionCollector:h}},__vite__mapDeps([0,1]));for(const h of u){const m=await AE(new d,s(t,h)).catch(()=>null);m&&r.push(m)}}}else if(e.source==="codex"&&a){const o=a.filter(u=>u.runner==="codex"&&u.subagent&&u.parentSessionId===e.sessionId);if(o.length){const{CodexSessionCollector:u}=await ft(async()=>{const{CodexSessionCollector:d}=await import("./codex-session-BfatCn8z.js");return{CodexSessionCollector:d}},__vite__mapDeps([2,1]));for(const d of o){const h=await AE(new u,s(d.rootKey,d.rel)).catch(()=>null);h&&r.push(h)}}}}catch{}return r.length&&e.adopt(r),e}function $8(e,t){return e.find(n=>(n.rel.split("/").pop()??n.rel).includes(t))}let CE=!1,Qb=null;function kW(){Qb?.()}let Zb=null;async function I2(e){return Zb?(await Zb(e),!0):!1}function EW(){const e=window.desktopSessions;if(!e||CE)return;CE=!0,e.watchStart();let t=!1,n=null;const a=async d=>{if(t){n=d;return}t=!0;try{window.dispatchEvent(new CustomEvent("td:sessions-changed"));const{useProjects:h,subscribedSessionIds:m}=await ft(async()=>{const{useProjects:_,subscribedSessionIds:S}=await Promise.resolve().then(()=>Sa);return{useProjects:_,subscribedSessionIds:S}},void 0),{activeId:p,projects:x}=h.getState(),b=x.find(_=>_.id===p),y=await e.head(d.rootKey,d.rel,262144).catch(()=>"");if(!y)return;const w=SE(y);if(!w)return;const E=!!b&&m(b).includes(w);let v=null;if(!E){if(x.some(V=>m(V).includes(w)))return;const{useStore:S}=await ft(async()=>{const{useStore:V}=await Promise.resolve().then(()=>vs);return{useStore:V}},void 0);if(!S.getState().nodes.some(V=>V.data.importSource?.sessionId===w)){const{parseAnchor:V}=await ft(async()=>{const{parseAnchor:L}=await import("./experiment-loop-XuEe5blq.js");return{parseAnchor:L}},[]),P=V(y);if(!P||!x.some(L=>L.id===P.project))return;if(v=P.project,v!==p){We("info",Te("atlas.mountPending"),9e3);return}}}const{streamRunnerConversation:A}=await ft(async()=>{const{streamRunnerConversation:_}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:_}},[]),{importOrAppendConversation:T,shellSessionReader:C}=await ft(async()=>{const{importOrAppendConversation:_,shellSessionReader:S}=await import("./canonical-C3OufoVo.js");return{importOrAppendConversation:_,shellSessionReader:S}},[]),I=await Uc(await A(C(d.rootKey,d.rel)).catch(()=>null),d.rootKey,d.rel),O=await T(I,{focusOnRefresh:!1});O?.kind==="appended"?We("success",ve(Te("atlas.liveAppended"),{n:O.turns}),8e3):O?.kind==="mounted"&&We("success",ve(Te(O.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:O.turns}),9e3)}finally{if(t=!1,n){const h=n;n=null,a(h)}}};e.onSessionsChanged(d=>{a(d)});const r=async d=>{if(!d)return;const{useStore:h}=await ft(async()=>{const{useStore:x}=await Promise.resolve().then(()=>vs);return{useStore:x}},void 0),{useUiStore:m}=await ft(async()=>{const{useUiStore:x}=await Promise.resolve().then(()=>uu);return{useUiStore:x}},void 0),p=h.getState().nodes.find(x=>x.data.importSource?.itemIds?.includes(d));p&&m.getState().setArrivalFocusNodeId(p.id)},s=async(d,h)=>{const{useProjects:m,switchProject:p}=await ft(async()=>{const{useProjects:w,switchProject:E}=await Promise.resolve().then(()=>Sa);return{useProjects:w,switchProject:E}},void 0),x=m.getState().projects,b=x.filter(w=>w.name===d),y=x.find(w=>w.id===d)??(b.length===1?b[0]:void 0);if(!y){We("error",Te("handoff.deeplinkMiss"));return}if(await p(y.id),h){const{useStore:w}=await ft(async()=>{const{useStore:v}=await Promise.resolve().then(()=>vs);return{useStore:v}},void 0),{useUiStore:E}=await ft(async()=>{const{useUiStore:v}=await Promise.resolve().then(()=>uu);return{useUiStore:v}},void 0);w.getState().nodes.some(v=>v.id===h)&&E.getState().setArrivalFocusNodeId(h)}},o=async d=>{let h="",m="";try{const A=new URL(d),T=A.searchParams.get("canvas");if(T){await s(T,A.searchParams.get("node")??"");return}h=A.searchParams.get("session")??"",m=A.searchParams.get("turn")??""}catch{return}if(!/^[A-Za-z0-9_-]{8,}$/.test(h))return;/^[A-Za-z0-9_-]*$/.test(m)||(m="");const p=await e.roots().catch(()=>[]);let x=null;for(const A of p){const T=await e.list(A.key).catch(()=>[]),C=$8(T,h);if(C){x={rootKey:A.key,rel:C.rel};break}}if(!x){const A=[];for(const T of p)for(const C of await e.list(T.key).catch(()=>[]))A.push({rootKey:T.key,rel:C.rel,mtime:C.mtime});A.sort((T,C)=>C.mtime-T.mtime);for(const T of A.slice(0,40)){const C=await e.head(T.rootKey,T.rel,262144).catch(()=>"");if(C&&SE(C)===h){x=T;break}}}if(!x){We("error",Te("handoff.deeplinkMiss"));return}const{streamRunnerConversation:b}=await ft(async()=>{const{streamRunnerConversation:A}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:A}},[]),{importOrAppendConversation:y,shellSessionReader:w}=await ft(async()=>{const{importOrAppendConversation:A,shellSessionReader:T}=await import("./canonical-C3OufoVo.js");return{importOrAppendConversation:A,shellSessionReader:T}},[]),E=await Uc(await b(w(x.rootKey,x.rel)).catch(()=>null),x.rootKey,x.rel),v=await y(E);v?v.kind==="appended"?We("success",ve(Te("atlas.liveAppended"),{n:v.turns}),8e3):v.kind==="mounted"?We("success",ve(Te(v.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:v.turns}),9e3):v.kind==="imported"&&We("success",ve(Te("toast.importedChats"),{n:1,m:v.nodeCount}),8e3):We("error",Te("handoff.notASession")),v&&m&&await r(m)};Zb=o,e.onDeepLink?.(d=>{o(d)}),(async()=>{const{bootProjects:d}=await ft(async()=>{const{bootProjects:m}=await Promise.resolve().then(()=>Sa);return{bootProjects:m}},void 0);await d();const h=await e.pendingDeepLink?.().catch(()=>null);h&&o(h)})();const u="thoughtdag.atlas.sweepmark";Qb=async()=>{const{bootProjects:d}=await ft(async()=>{const{bootProjects:y}=await Promise.resolve().then(()=>Sa);return{bootProjects:y}},void 0);await d();const h=await e.roots().catch(()=>[]),m=[];for(const y of h){const w=await e.list(y.key).catch(()=>[]);for(const E of w)m.push({rootKey:y.key,rel:E.rel,mtime:E.mtime,size:E.size})}let p={};try{p=JSON.parse(localStorage.getItem(u)??"{}")}catch{}const x=Object.keys(p).length===0;m.sort((y,w)=>w.mtime-y.mtime);const b=m.filter((y,w)=>{const E=`${y.mtime}|${y.size}`;return p[`${y.rootKey}|${y.rel}`]===E?!1:x?w<30:!0});for(const y of b)await a({rootKey:y.rootKey,rel:y.rel});for(const y of m)p[`${y.rootKey}|${y.rel}`]=`${y.mtime}|${y.size}`;localStorage.setItem(u,JSON.stringify(p))},Qb()}const W8=Object.freeze(Object.defineProperty({__proto__:null,openWhyLink:I2,pickSessionFile:$8,startLiveMirror:EW,sweepRecentSessions:kW},Symbol.toStringTag,{value:"Module"})),V8=(e,t)=>`td:card:${e}#${t}`,SW=420;let kx=0;const TW=4;async function G8(e,t){try{const n=await Yo(V8(e,t));return typeof n=="string"&&n?n:void 0}catch{return}}async function Y8(e,t,n){const a=(await dr())?.default??void 0,r=`Condense the past exchange below into a card of at most 60 words (or 120 Chinese characters), in the exchange's own language: what was asked, what was concluded or decided, the names, numbers and file names that matter. No preamble, no markdown. Output only the card.
|
|
157
157
|
|
|
158
158
|
${n.slice(0,6e3)}`,o=(await er([{role:"user",content:r}],void 0,a)).trim().replace(/^["“「]|["”」]$/g,"").slice(0,SW);if(!(o.length<20)){try{await Lr(V8(e,t),o)}catch{}return o}}function O2(e,t){const n=t.filter(a=>!a.card);n.length&&(async()=>{for(const a of n){for(;kx>=TW;)await new Promise(r=>setTimeout(r,200));kx++,Y8(a.session,a.turn,a.text).then(r=>{r&&se.setState(s=>({nodes:s.nodes.map(o=>o.id===e&&o.data.recallItems?.some(u=>u.id===a.id)?{...o,data:{...o.data,recallItems:o.data.recallItems.map(u=>u.id===a.id?{...u,card:r,cardTokens:Nn(r)}:u)}}:o)}))}).catch(()=>{}).finally(()=>{kx--})}})()}const v0=["what","decisions","now","open"],jm={what:"dossier.secWhat",decisions:"dossier.secDecisions",now:"dossier.secNow",open:"dossier.secOpen"},NW=100,AW=60,CW=6,_W=3200,MW=e=>e?e.slice(5,10).replace("-","-"):"",IW=(e,t)=>{const n=e.sources[t];return n?`${n.runner} ${MW(n.at)}`:""};function OW(e,t,n={}){const a=n.cap??_W,r=n.sources??!0,s=[`## ${ve(Te("dossier.title"),{name:t})}${e.updatedAt?` (${Te("dossier.updated")} ${e.updatedAt.slice(0,10)})`:""}`];for(const u of v0){const d=e.sections[u];if(d.length){s.push(`### ${Te(jm[u])}`);for(const h of d){const m=r?h.src.map(p=>IW(e,p)).filter(Boolean).slice(0,2):[];s.push(`- ${h.text}${m.length?` (${m.join("; ")})`:""}`)}}}const o=s.join(`
|
|
159
159
|
`);return o.length>a?o.slice(0,a).trimEnd()+`
|
|
@@ -229,7 +229,7 @@ takeaway: the conclusion, stated first and plainly, as one clause. Hard limit: 1
|
|
|
229
229
|
|
|
230
230
|
Both in the same language as the question. Never use dash characters (—, –, -) inside topic or takeaway; use commas or colons instead. Output only that one line.`}],void 0,p,{fast:!0}).then(x=>{const b=x.trim().split(`
|
|
231
231
|
`)[0].trim(),y=b.match(/^(INSIGHT|RULEOUT|DECISION|PIVOT|OPEN)\s*[||::]\s*([^||]+?)\s*[||]\s*(.+)$/is),w=y?null:b.match(/^(INSIGHT|RULEOUT|DECISION|PIVOT|OPEN)[::||]\s*(.+)$/is),E=(y?.[1]??w?.[1])?.toLowerCase()??"insight",v=y?y[2].trim():void 0,A=y?y[3].trim():w?w[2].trim():b;return d(A,v,E)});if(!s){o.then(m).catch(()=>{});return}Pm.add(e),o.then(async p=>{if(!p)return;const x=await x7(t,n,p,{context:s.context,thread:s.thread,parentAnswer:s.parentAnswer}).catch(()=>null);s.set(e,n,x),x?await d(fu(x,1),fu(x,0),x.move??"insight"):await m(p)}).catch(()=>{}).finally(()=>Pm.delete(e))}function bV(e,t,n){const{ordered:a}=Pr(e,t,n),r={ruleout:"RULEOUT",decision:"DECISION",pivot:"PIVOT",open:"OPEN"},s=a.filter(u=>u.id!==e).map(u=>{const d=Ko(u.data);if(!d)return null;const h=u.data.summaryTypes?.[u.data.responseIndex];return`- ${h&&r[h]?`${r[h]}: `:""}${d}`}).filter(u=>!!u).slice(-8),o=a.find(u=>u.data.isRoot&&u.id!==e);return o?.data.question&&s.unshift(`Opening question of the map: ${o.data.question.slice(0,200)}`),s}const Ds=new Map,Tx=new Map,E0=new Map;async function ji(e,t,n,a){if(Et)return;const{question:r,images:s,onSuccess:o,versionMode:u="replace"}=a;let{messages:d}=a;a.autoChain||E0.clear(),Ds.get(n)?.abort();const h=(Tx.get(n)??0)+1;Tx.set(n,h);const m=()=>Tx.get(n)===h,p=new AbortController;Ds.set(n,p),e(Y=>({nodes:Y.nodes.map(q=>q.id===n?{...q,data:{...q.data,generationFailed:void 0,reasoning:void 0,restreaming:q.data.response?!0:void 0}}:q)}));let x;const b=t().nodes.find(Y=>Y.id===n)?.data.model;let y=b;const w=await dr(),E=w?.default??null;if(b&&w&&w.models.length>0){const Y=C7(b,w.models);Y!==b&&(y=Y??void 0,We("info",ve(Te(Y?"node.pinnedModelRemapped":"node.pinnedModelUnavailable"),Y?{m:b,r:Y}:{m:b}),7e3))}let v,A=!1;const T=y??oe.getState().selectedModel??E??void 0,C=await A8(n,T),I=C?void 0:await N7(T,n);let O,_=null,S=null;const z=(Y,q=!1)=>{if(!m())return;const B=Nn(r+Y),j=v??T;t().logEvent("generate",n,{chars:Y.length,...j?{model:j}:{},...q?{failed:!0}:{}});const $=v8(n,t().nodes,t().edges),X=i$(w8(n,t().nodes,t().edges));e(Q=>({nodes:Q.nodes.map(F=>{if(F.id!==n)return F;const G=new Set([Te("node.failedPlaceholder"),Te("node.emptyResponse")]),J=u==="append"||q?F.data.responses.map((Ie,Fe)=>({r:Ie,q:F.data.questions?.[Fe],by:F.data.generatedBy?.[Fe],rs:F.data.reasonings?.[Fe],at:F.data.generatedAts?.[Fe],ed:F.data.editedAts?.[Fe],gw:F.data.gatewaySearches?.[Fe],ef:F.data.generatedEfforts?.[Fe]})).filter(({r:Ie})=>Ie&&!(q&&G.has(Ie))):[],K=new Date().toISOString(),ee=[...J.map(({r:Ie})=>Ie),Y],ue=[...J.map(({q:Ie})=>Ie??F.data.question),F.data.question],pe=[...J.map(({by:Ie})=>Ie),j],be=[...J.map(({gw:Ie})=>Ie),A||void 0],ae=[...J.map(({ef:Ie})=>Ie),ri(j)&&F.data.agentSession?.effort||void 0],xe=[...J.map(({rs:Ie})=>Ie),F.data.reasoning||void 0],Ce=[...J.map(({at:Ie})=>Ie),K],ze=[...J.map(({ed:Ie})=>Ie),void 0];return{...F,data:{...F.data,response:Y,responses:ee,questions:ue,generatedBy:pe,gatewaySearches:be,generatedEfforts:ae,reasonings:xe,generatedAts:Ce,editedAts:ze,reasoning:void 0,restreaming:void 0,pendingApprovals:void 0,agentTrace:void 0,responseIndex:ee.length-1,isLoading:!1,tokenCount:B,generationFailed:q||void 0,references:x,highlights:im(F.data.highlights,Y),lastContextHash:$,lastContextParts:X,lastGeneratedAt:K}}})}))},V=t().nodes.find(Y=>Y.id===n)?.data,P=!V?.stepKind&&!V?.digestOf?iW():null;if(P){let Y=d.length-1;for(let q=d.length-1;q>=0;q--)if(d[q].role==="assistant"){Y=q+1;break}d=[...d.slice(0,Y),P,...d.slice(Y)]}if(!V?.stepKind&&!V?.digestOf&&(V?.recall??oe.getState().recallEnabled)&&m()){let Y=V?.recallItems;if(!Y){const{useProjects:B}=await ft(async()=>{const{useProjects:X}=await Promise.resolve().then(()=>Sa);return{useProjects:X}},void 0),j=(X,Q)=>{m()&&e(F=>({nodes:F.nodes.map(G=>G.id===n?{...G,data:{...G.data,recallProgress:{done:X,total:Q}}}:G)}))},$=await d7(r,{excludeSession:B.getState().activeId,model:T,onProgress:j,reach:V?.recallReach,scale:V?.recallScale});if(Y=$.items,!m())return;e(X=>({nodes:X.nodes.map(Q=>Q.id===n?{...Q,data:{...Q.data,recallItems:$.items,recallMeta:$.meta,recallProgress:null}}:Q)})),O2(n,$.items)}const q=QW(Y);if(q){let B=d.length-1;for(let j=d.length-1;j>=0;j--)if(d[j].role==="assistant"){B=j+1;break}d=[...d.slice(0,B),q,...d.slice(B)]}}try{const Y=T,q=Y?n8(Y):void 0;if(q){const ee=Nn(d.map(ue=>ue.content).join(`
|
|
232
|
-
`));if(ee>=q)throw new Error(ve(Te("toast.contextOverWindow"),{est:ee.toLocaleString(),model:Y,limit:q.toLocaleString()}))}let B=null,j=null;const $=()=>{if(!B||!m()){B=null;return}const ee=B;B=null,e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n?{...pe,data:{...pe.data,...ee.response!==void 0?{response:ee.response,restreaming:void 0}:{},...ee.reasoning!==void 0?{reasoning:ee.reasoning}:{}}}:pe)}))},X=ee=>{B={...B??{},...ee},j==null&&($(),j=window.setTimeout(()=>{j=null,$()},100))},Q=()=>{j!=null&&(clearTimeout(j),j=null),$()},F=[...new Set((a.sources??[]).map(ee=>ee.nodeId).filter(ee=>!!ee))],G=async ee=>{const ue=await Promise.all(ee.images.map(async ae=>({type:ae.mimeType,sha:await _m(ae.data)}))),pe=await _m(E2({messages:ee.messages,images:ue,model:ee.model,tools:{web:!!ee.toolPrefs.web,scholar:!!ee.toolPrefs.scholar,mcp:!!ee.toolPrefs.mcp}})),be=F.slice(0,200);t().logEvent("commit",n,{kind:"request",sha:`sha256:${pe}`,n:ee.messages.length,images:ee.images.length,lane:ee.lane,...ee.model?{model:ee.model}:{},...be.length?{m:be.join(",")}:{},...F.length>be.length?{more:!0}:{}})};let J=!1;const K=await p8(d,(ee,ue)=>{if(X({response:ue}),C&&!J){J=!0;const pe=new Date().toISOString();e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&ae.data.agentTrace?.some(xe=>xe.status==="running")?{...ae,data:{...ae.data,agentTrace:ae.data.agentTrace.map(xe=>xe.status==="running"?{...xe,status:"ok",endedAt:pe}:xe)}}:ae)}))}},p.signal,s,{onDispatch:ee=>{G(ee).catch(()=>{})},onToolCall:(ee,ue)=>{if(!m())return;if(C){const be=new Date().toISOString();e(ae=>({nodes:ae.nodes.map(xe=>{if(xe.id!==n)return xe;const Ce=(xe.data.agentTrace??[]).map(ze=>ze.status==="running"?{...ze,status:"ok",endedAt:be}:ze);return Ce.push({id:`${be}-${Ce.length}`,name:ee,query:ue,status:"running",startedAt:be}),{...xe,data:{...xe.data,agentTrace:Ce}}})}));return}const pe=ee==="arxiv_search"?"📚":ee==="semantic_scholar"?"🎓":ee.startsWith("mcp:")?"🔧":"🔍";e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&!ae.data.response?{...ae,data:{...ae.data,response:`${pe} ${ue}…`}}:ae)}))},onGatewaySearch:()=>{m()&&(A=!0,e(ee=>({nodes:ee.nodes.map(ue=>ue.id===n&&!ue.data.response?{...ue,data:{...ue.data,response:`🌐 ${Te("node.gatewaySearching")}`}}:ue)})))},onSources:ee=>{x=ee},onHarnessSession:ee=>{O=ee},onAgentTool:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=[...be.data.agentTrace??[]];if(ee.phase==="start")ae.push({id:ee.id||`${ae.length}`,name:ee.name,query:ee.query,status:"running",startedAt:ue});else{const xe=ae.findIndex(Ce=>Ce.id===ee.id&&Ce.status==="running");xe>=0&&(ae[xe]={...ae[xe],status:ee.isError?"error":"ok",endedAt:ue})}return{...be,data:{...be.data,agentTrace:ae}}})}))},onAgentSession:ee=>{if(!m())return;const ue=!!I?.continue;e(pe=>({nodes:pe.nodes.map(be=>be.id===n?{...be,data:{...be.data,agentSession:{...be.data.agentSession,...ee,continued:ue}}}:be)})),ue&&ee.sessionId&&OV(ee.runtime,n,ee.sessionId,ee.cwd)},onAgentChanges:ee=>{m()&&e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n&&pe.data.agentSession?{...pe,data:{...pe.data,agentSession:{...pe.data.agentSession,changes:ee}}}:pe)}))},onHarnessTurn:ee=>{_=ee,C&&!S&&(S=M8(e,n,C,ee).catch(()=>!1))},onApproval:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=be.data.pendingApprovals??[];return ae.some(xe=>xe.id===ee.id)?be:{...be,data:{...be.data,pendingApprovals:[...ae,{...ee,askedAt:ue}]}}})})),We("info",Te("approval.toast"),8e3)},onApprovalDecided:({id:ee,outcome:ue,value:pe,auto:be,name:ae,query:xe,rule:Ce})=>{if(!m())return;const ze=new Date().toISOString();e(Ie=>({nodes:Ie.nodes.map(Fe=>{if(Fe.id!==n)return Fe;const Ee=Fe.data.pendingApprovals??[],Me=Ee.find(Ye=>Ye.id===ee),De=Ee.filter(Ye=>Ye.id!==ee),bt=De.length?De:void 0;if(!Me&&be)return{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{id:ee,kind:"confirm",toolName:Fe.data.agentSession?.runtime??"agent",callId:null,reason:null,name:ae??"",query:xe??"",arguments:null,askedAt:ze,decidedAt:ze,outcome:ue,auto:!0,...Ce?{rule:Ce}:{}}]}};if(!Me)return{...Fe,data:{...Fe.data,pendingApprovals:bt}};const mt={...Me};return delete mt.answered,{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{...mt,outcome:ue,decidedAt:ze,...pe?{value:pe}:{}}]}}})}))},onRerouted:(ee,ue)=>{v=ue},onImageFallback:ee=>{v=ee},onReasoning:(ee,ue)=>{X({reasoning:ue})}},(()=>{const ee=t().nodes.find(ue=>ue.id===n)?.data;return{web:ee?.webSearch??oe.getState().webSearchEnabled,scholar:ee?.scholarSearch??oe.getState().scholarSearchEnabled,mcp:oe.getState().mcpEnabled}})(),y,C??(I?{...I,nodeId:n}:void 0));if(Q(),!m())return;if(Ds.delete(n),!K.trim()){z(Te("node.emptyResponse"),!0);return}if(I){const ee=t().nodes.find(ue=>ue.id===n)?.data.agentSession;ee&&await zV(n,ee,r).catch(()=>!1)}if(z(K),C){const ee=S?await S:!1;await I8(e,t,n,{question:r,response:K},C,O,_,ee)}o?.(K),t().pushHistory(),xV(n,r,K,t().setSummary,bV(n,t().nodes,t().edges),{model:C||I?void 0:T,set:t().setLadder,...w7(n,t().nodes,t().edges)}),!V?.stepKind&&!V?.digestOf&&ft(async()=>{const{useProjects:ee}=await Promise.resolve().then(()=>Sa);return{useProjects:ee}},void 0).then(({useProjects:ee})=>{const{projects:ue,activeId:pe}=ee.getState(),be=ue.find(ae=>ae.id===pe);hW(r,K,be?{id:be.id,name:be.name}:void 0)}),yV(e,t,n),Ul(t,n)}catch(Y){if(!m())return;Ds.delete(n);const q=t().nodes.find(j=>j.id===n)?.data.response||"";if(Y instanceof DOMException&&Y.name==="AbortError")z(q||Te("node.stoppedPlaceholder"));else{const j=Y instanceof Error?Y.message:Te("toast.unknownError");/no model configured/i.test(j)?(We("info",Te("toast.noModelYet")),oe.getState().setApiKeyModalOpen(!0)):/429|too many requests|rate.?limit|quota/i.test(j)?We("info",Te("toast.rateLimited")):We("error",ve(Te("toast.generationFailed"),{message:j})),z(q||Te("node.failedPlaceholder"),!0)}t().pushHistory()}}function Ul(e,t){if(oe.getState().autoRefreshPaused)return;const{nodes:n,edges:a}=e(),r=new Map(n.map(o=>[o.id,o])),s=o=>{const u=r.get(o);return!u||u.data.isLoading?!1:u.data.stepKind==="human"||u.data.stepKind==="note"||u.data.stepKind==="link"?!!u.data.question.trim():u.data.stepKind==="file"?(u.data.attachments?.length??0)>0:!!u.data.response&&!u.data.generationFailed};for(const o of a){if(o.source!==t||o.data?.isCrossLink)continue;const u=r.get(o.target);!u||u.data.stepKind!=="prompt"||u.data.response||u.data.isLoading||u.data.generationFailed||!a.filter(h=>h.target===u.id&&!h.data?.isCrossLink).map(h=>h.source).every(s)||e().rerunNode(u.id,{auto:!0})}}function yV(e,t,n){if(oe.getState().autoRefreshPaused)return;const a=new Set([n]),r=[n];for(;r.length>0;){const d=r.shift();for(const h of t().edges)h.target===d&&!h.data?.isCrossLink&&!a.has(h.source)&&(a.add(h.source),r.push(h.source))}t().edges.some(d=>d.data?.followsTip&&d.source!==n&&a.has(d.source))&&e(d=>({edges:d.edges.map(h=>h.data?.followsTip&&h.source!==n&&a.has(h.source)?{...h,id:`watch-${n}-${h.target}`,source:n}:h)}));const{nodes:o,edges:u}=t();for(const d of o){if(!(d.data.autoRerun??d.data.evaluatorTrigger==="auto")||d.id===n||d.data.isLoading||Ds.has(d.id))continue;const m=E0.get(d.id)??0;if(m>=(d.data.autoRerunRounds??1))continue;const{ordered:p}=Pr(d.id,o,u);p.some(x=>x.id===n)&&(E0.set(d.id,m+1),t().rerunNode(d.id,{auto:!0}))}}const zE=e=>{for(const t of e){const n=Ds.get(t);n&&(n.abort(),Ds.delete(t))}},vV=(e,t)=>({nodes:[],edges:[],selectedNodeId:null,selectedNodeIds:[],setNodes:n=>e({nodes:n}),setEdges:n=>e({edges:n}),setSelectedNodeId:n=>e({selectedNodeId:n,selectedNodeIds:n?[n]:[]}),setSelectedNodeIds:n=>e({selectedNodeIds:n,selectedNodeId:n.length===1?n[0]:null}),deleteNode:n=>{if(Xr())return;t().logEvent("delete",n,{n:1}),t().pushHistory();const{edges:a}=t(),r=Vo(n,a),s=new Set([n,...r]);zE(s),e(o=>({nodes:o.nodes.filter(u=>!s.has(u.id)),edges:o.edges.filter(u=>!s.has(u.source)&&!s.has(u.target))})),t().pushHistory(),ft(()=>import("./canonical-4rZrwQLF.js"),[]).then(o=>o.unsubscribeOrphanedSessions())},deleteEdges:n=>{if(Xr())return;t().logEvent("disconnect",n[0],{n:n.length});const a=new Set(n);t().edges.some(r=>a.has(r.id))&&(t().pushHistory(),e(r=>({edges:r.edges.filter(s=>!a.has(s.id))})),t().pushHistory())},editResponse:(n,a)=>{if(Xr())return;t().logEvent("edit-response",n,{chars:a.length}),t().pushHistory();const r=Nn(t().nodes.find(s=>s.id===n)?.data.question+a||a);e(s=>({nodes:s.nodes.map(o=>o.id===n?{...o,data:{...o.data,response:a,responses:o.data.responses.map((u,d)=>d===o.data.responseIndex?a:u),summaries:o.data.summaries?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTypes:o.data.summaryTypes?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTopics:o.data.summaryTopics?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryLadders:o.data.summaryLadders?.map((u,d)=>d===o.data.responseIndex?void 0:u),editedAts:o.data.responses.map((u,d)=>d===o.data.responseIndex?new Date().toISOString():o.data.editedAts?.[d]),highlights:im(o.data.highlights,a),isEditingResponse:!1,tokenCount:r}}:o)})),t().pushHistory()},toggleCollapse:n=>{const a=t().nodes.find(h=>h.id===n);if(!a)return;const r=Pi(a),o=k2({...a,data:{...a.data,isCollapsed:!a.data.isCollapsed}})-r,u=Vo(n,t().edges),d=new Set(u);e(h=>({nodes:h.nodes.map(m=>m.id===n?{...m,data:{...m.data,isCollapsed:!m.data.isCollapsed}}:d.has(m.id)?{...m,position:{...m.position,y:m.position.y+o}}:m)}))},setEditing:(n,a)=>{a&&Xr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditing:a}}:s)}))},setEditingResponse:(n,a)=>{a&&Xr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditingResponse:a}}:s)}))},duplicateNode:n=>{const a=t().nodes.find(m=>m.id===n);if(!a)return;t().pushHistory();const r=Tn(),s={id:r,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{...a.data,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,highlights:a.data.highlights.map(m=>({...m,id:Tn()}))}},o=t().edges.find(m=>m.target===n),u=o?{...o,id:`edge-${o.source}-${r}`,target:r}:null,d=u?[...t().edges,u]:t().edges,h=xr([...t().nodes,s],d);e({nodes:h,edges:d,selectedNodeId:r}),t().pushHistory()},addCrossLink:(n,a)=>{const{edges:r,nodes:s}=t();if(r.some(x=>x.source===n&&x.target===a))return;const u=s.find(x=>x.id===n);if(u&&["note","file","link"].includes(u.data.stepKind??"")){t().pushHistory();const x={id:`edge-${n}-${a}`,source:n,sourceHandle:"continue",target:a,targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};e(y=>({edges:[...y.edges,x]})),t().logEvent("connect",x.id),t().setEdgeStructural(x.id,!0);const b=t().edges.find(y=>y.id===x.id);if(b&&!b.data?.isCrossLink){const w=br(n,t().nodes,t().edges).messages.reduce((E,v)=>E+Nn(v.content),0);We("success",ve(Te("edge.materialWiredFull"),{n:w.toLocaleString()}),8e3,{label:Te("edge.materialMakeQuote"),run:()=>t().setEdgeStructural(x.id,!1)})}return}t().pushHistory();const d=s.find(x=>x.id===n),h=s.find(x=>x.id===a),m=!!d&&!!h&&h.position.y>d.position.y+60&&Math.abs(h.position.x-d.position.x)<320,p={id:`crosslink-${n}-${a}`,source:n,sourceHandle:m?"continue":"branch",target:a,targetHandle:m?"top":"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};if(e(x=>({edges:[...x.edges,p]})),t().logEvent("connect",p.id),t().pushHistory(),d&&!["note","file","link"].includes(d.data.stepKind??"")){const{ordered:x}=Pr(n,s,r.filter(y=>!y.data?.isCrossLink)),b=x.filter(y=>y.id!==n&&!["note","file","link"].includes(y.data.stepKind??""));if(b.length>0){const y=Nn(y0({source:d,depth:"quote",chain:b})),E=br(n,s,r).messages.reduce((v,A)=>v+Nn(A.content),0)+Nn(d.data.question+d.data.response);We("info",ve(Te("edge.linkedQuote"),{n:y}),8e3,{label:ve(Te("edge.makeFull"),{m:E}),run:()=>t().setEdgeStructural(p.id,!0)})}}},staleIds:[],staleFps:{},staleVerdicts:{},setStaleVerdicts:n=>e(a=>({staleVerdicts:{...a.staleVerdicts,...n}})),recomputeStaleness:()=>{const{nodes:n,edges:a}=t(),r=[],s={};for(const d of n){if(!d.data.lastContextHash||!d.data.response||["note","file","link","frame"].includes(d.data.stepKind??""))continue;const h=v8(d.id,n,a);h!==d.data.lastContextHash&&(r.push(d.id),s[d.id]=h)}const o=t().staleFps,u=t().staleIds;u.length===r.length&&u.every((d,h)=>d===r[h]&&o[d]===s[d])||(e({staleIds:r,staleFps:s}),r.length&&ft(()=>Promise.resolve().then(()=>kV),void 0).then(d=>d.judgeStaleness()).catch(()=>{}))},setEdgeStructural:(n,a)=>{const{nodes:r,edges:s}=t(),o=s.find(u=>u.id===n);if(o){if(a){const u=s.filter(h=>!h.data?.isCrossLink),{ordered:d}=Pr(o.source,r,u);if(d.some(h=>h.id===o.target)){We("error",Te("edge.cycleBlocked"));return}}t().pushHistory(),t().logEvent(a?"connect":"disconnect",n,{convert:!0}),e(u=>({edges:u.edges.map(d=>{if(d.id!==n)return d;if(a){const h={...d.data??{}};return delete h.isCrossLink,delete h.contextDepth,delete h.isWatch,{...d,sourceHandle:"continue",targetHandle:"top",animated:!1,style:{stroke:it.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:h}}return{...d,animated:!0,style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{...d.data??{},isCrossLink:!0,contextDepth:void 0}}})})),e(u=>({nodes:xr(u.nodes,u.edges)})),t().pushHistory()}},setCrossLinkDepth:(n,a)=>{t().pushHistory(),e(r=>({edges:r.edges.map(s=>s.id!==n||!s.data?.isCrossLink?s:{...s,style:{...s.style,strokeDasharray:a==="full"?"12 3":"8 4",strokeWidth:a==="full"?3:2},data:{...s.data,contextDepth:a==="full"?"full":void 0}})})),t().pushHistory()},navigateVersion:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const{responses:o,responseIndex:u}=s.data;let d=a==="prev"?u-1:u+1;return d<0&&(d=o.length-1),d>=o.length&&(d=0),{...s,data:{...s.data,responseIndex:d,response:o[d],question:s.data.questions?.[d]??s.data.question,generationFailed:void 0,highlights:im(s.data.highlights,o[d])}}})}))},deleteVersion:(n,a)=>{t().pushHistory(),e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const o=s.data.responses.filter((d,h)=>h!==a);if(o.length===0)return s;const u=Math.min(s.data.responseIndex,o.length-1);return{...s,data:{...s.data,responses:o,responseIndex:u,response:o[u],questions:s.data.questions?.filter((d,h)=>h!==a),question:s.data.questions?.filter((d,h)=>h!==a)[u]??s.data.question,summaries:s.data.summaries?.filter((d,h)=>h!==a),generatedBy:s.data.generatedBy?.filter((d,h)=>h!==a),summaryTypes:s.data.summaryTypes?.filter((d,h)=>h!==a),reasonings:s.data.reasonings?.filter((d,h)=>h!==a),generatedAts:s.data.generatedAts?.filter((d,h)=>h!==a),editedAts:s.data.editedAts?.filter((d,h)=>h!==a),highlights:im(s.data.highlights,o[u])}}})})),t().pushHistory()},relayout:()=>{Xr()||(t().pushHistory(),e(n=>{const a=d$(n.nodes,n.edges);return{nodes:xr(n.nodes,a),edges:a}}),t().pushHistory())},setArchived:(n,a)=>{const r=new Set(n);t().pushHistory(),t().logEvent(a?"archive":"unarchive",n[0],{n:n.length}),e(s=>({nodes:s.nodes.map(o=>r.has(o.id)?{...o,data:{...o.data,archived:a||void 0,archivedAt:a?new Date().toISOString():void 0}}:o)})),t().pushHistory()},setNodeModel:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,model:a}}:s)}))},alignSelection:n=>{if(n.length<2)return;const a=new Set(n),{nodes:r,edges:s}=t(),o=new Map,u=s.filter(b=>!b.data?.isWatch),d=(b,y)=>{if(o.has(b))return o.get(b);if(y.has(b))return 0;y.add(b);const w=u.filter(v=>v.target===b&&a.has(v.source)),E=w.length===0?0:1+Math.max(...w.map(v=>d(v.source,y)));return o.set(b,E),E},h=n.map(b=>r.find(y=>y.id===b)).filter(b=>!!b).sort((b,y)=>d(b.id,new Set)-d(y.id,new Set)||b.position.y-y.position.y);t().pushHistory();const m=h[0].position;let p=m.y;const x=new Map;for(const b of h)x.set(b.id,{x:m.x,y:p}),p+=Pi(b)+40;e(b=>({nodes:b.nodes.map(y=>{const w=x.get(y.id);return w?{...y,position:w}:y})})),t().pushHistory()},batchDelete:n=>{if(Xr())return;t().logEvent("delete",n[0],{n:n.length}),t().pushHistory();const a=new Set(n);zE(a),e(r=>({nodes:r.nodes.filter(s=>!a.has(s.id)),edges:r.edges.filter(s=>!a.has(s.source)&&!a.has(s.target)),selectedNodeId:null,selectedNodeIds:[]})),t().pushHistory(),ft(()=>import("./canonical-4rZrwQLF.js"),[]).then(r=>r.unsubscribeOrphanedSessions())},duplicateSelection:n=>{const{nodes:a,edges:r}=t(),s=new Set(n),o=a.filter(_=>s.has(_.id));if(o.length===0)return;t().pushHistory();const u=_=>({x:_.position.x,y:_.position.y,w:_.measured?.width??_.width??520,h:_.measured?.height??_.height??Pi(_)}),d=o.map(u),h={x:Math.min(...d.map(_=>_.x)),y:Math.min(...d.map(_=>_.y)),right:Math.max(...d.map(_=>_.x+_.w)),bottom:Math.max(...d.map(_=>_.y+_.h))},m=80,p=h.right-h.x+m,x=h.bottom-h.y+m,b=[];for(let _=1;_<=6;_++)b.push({dx:_*p,dy:0},{dx:0,dy:_*x},{dx:_*p,dy:_*x});const y=a.filter(_=>_.data.stepKind!=="frame").map(u),w=(_,S)=>_.x<S.x+S.w&&_.x+_.w>S.x&&_.y<S.y+S.h&&_.y+_.h>S.y,E=b.find(_=>!d.some(S=>y.some(z=>w({...S,x:S.x+_.dx,y:S.y+_.dy},z))))??{dx:p,dy:x},v=new Map,A=new Map;for(const _ of o){v.set(_.id,Tn());for(const S of _.data.attachments??[])A.set(S.id,Tn())}const T=_=>(_??[]).map(S=>A.get(S)??S),C=o.map(_=>({..._,id:v.get(_.id),position:{x:_.position.x+E.dx,y:_.position.y+E.dy},selected:!0,data:{..._.data,attachments:(_.data.attachments??[]).map(S=>({...S,id:A.get(S.id)})),excludedAttachmentIds:T(_.data.excludedAttachmentIds),includedAttachmentIds:T(_.data.includedAttachmentIds),digestOf:_.data.digestOf?A.get(_.data.digestOf)??_.data.digestOf:void 0,highlights:(_.data.highlights??[]).map(S=>({...S,id:Tn()})),isEditing:!1,isEditingResponse:!1,isLoading:!1}})),I=r.filter(_=>s.has(_.source)&&s.has(_.target)).map(_=>({..._,id:`edge-${v.get(_.source)}-${v.get(_.target)}`,source:v.get(_.source),target:v.get(_.target),data:_.data?{..._.data}:_.data})),O=C.map(_=>_.id);e(_=>({nodes:[..._.nodes.map(S=>S.selected?{...S,selected:!1}:S),...C],edges:[..._.edges,...I],selectedNodeId:O.length===1?O[0]:null,selectedNodeIds:O})),t().pushHistory()}}),z2=(e,t)=>{const n=e.staleVerdicts[t];return!!n&&n.fp===e.staleFps[t]&&n.p<H$},Qr=e=>e.staleIds.filter(t=>!z2(e,t)),E7=(e,t)=>{const n=e.staleVerdicts[t];return n&&n.fp===e.staleFps[t]?n:void 0},wV=8;let Nx=!1;const Ax=new Set;async function S7(){if(Nx||!Rr())return;const e=se.getState(),t=e.staleIds.filter(a=>e.staleVerdicts[a]?.fp!==e.staleFps[a]&&!Ax.has(`${a}:${e.staleFps[a]}`));if(!t.length)return;Nx=!0;try{const{nodes:a,edges:r}=e,s=[];for(const o of t.slice(0,wV)){Ax.add(`${o}:${e.staleFps[o]}`);const u=a.find(p=>p.id===o),d=u?.data.lastContextParts;if(!u||!d)continue;const h=w8(o,a,r),m=[];for(const[p,x]of Object.entries(h)){const b=d[p];(!b||b.h!==x.h)&&m.push({node:p,before:b?.head??"",after:x.text})}for(const p of Object.keys(d))h[p]||m.push({node:p,before:d[p].head,after:""});m.length&&s.push({id:o,question:u.data.question,answer:u.data.response,changes:m})}if(s.length){const o=await F$(s),u={};for(const d of s)u[d.id]={fp:e.staleFps[d.id],p:o[d.id],changed:d.changes.map(h=>h.node)};se.getState().setStaleVerdicts(u)}}catch{}finally{Nx=!1}const n=se.getState();n.staleIds.some(a=>n.staleVerdicts[a]?.fp!==n.staleFps[a]&&!Ax.has(`${a}:${n.staleFps[a]}`))&&S7()}const kV=Object.freeze(Object.defineProperty({__proto__:null,currentStaleVerdict:E7,judgeStaleness:S7,shownStaleIds:Qr,staleHiddenByJudge:z2},Symbol.toStringTag,{value:"Module"})),EV=(e,t)=>({addQuestion:async(n,a={})=>{if(Xr())return;const{parentId:r,branchContext:s,branchYRatio:o,inheritRole:u,rolePrompt:d,initialAttachments:h,excludeAllInheritedAttachments:m,mentions:p}=a,x=Tn();t().logEvent("ask",x,{chars:n.length,...r?{}:{root:!0},...s?{branch:!0}:{}});const b=!r,y=r?t().nodes.find(Y=>Y.id===r)?.data.model:void 0,w={id:x,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:n,createdAt:new Date().toISOString(),askedAt:new Date().toISOString(),model:y,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!0,tokenCount:0,branchContext:s,highlights:[],highlightMode:"tag",attachments:h||[],excludedAttachmentIds:m&&r?t().getInheritedAttachments(r).map(({attachment:Y})=>Y.id).concat((t().nodes.find(Y=>Y.id===r)?.data.attachments||[]).map(Y=>Y.id)):[],includedAttachmentIds:[],roleMode:u===!1?"reset":"inherit",rolePrompt:d||void 0,isRoot:b,isBranch:!!s,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled,...Bd()}},E=!!s,v=r?{id:`edge-${r}-${x}`,source:r,target:x,sourceHandle:E?"branch":"continue",targetHandle:E?"left":"top",type:"smoothstep",...E?{style:{stroke:it.warm,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.warm,width:18,height:18},data:{isBranchFromSelection:!0,branchYRatio:o??.5}}:{style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}:null;let A=v?[...t().edges,v]:t().edges;const T=(p??[]).filter(Y=>Y!==x&&Y!==r&&t().nodes.some(q=>q.id===Y));if(T.length>0){const Y=A.filter($=>!$.data?.isCrossLink),q=r?new Set(Pr(r,t().nodes,Y).ordered.map($=>$.id)):new Set,B=new Set(A.filter($=>$.data?.isCrossLink&&$.target===x).map($=>$.source));let j=0;for(const $ of T)q.has($)||B.has($)||(A=[...A,{id:`crosslink-${$}-${x}`,source:$,target:x,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}}],j++);j>0&&We("info",ve(Te("mention.wired"),{n:j}),6e3)}const C=r?t().nodes.map(Y=>Y.id===r?{...Y,data:{...Y.data,isCollapsed:!0}}:Y):t().nodes,I=xr([...C,w],A);e({nodes:I,edges:A,selectedNodeId:x});const O=t().nodes.find(Y=>Y.id===x),_=r?br(r,t().nodes,t().edges,s,O?.data.excludedAttachmentIds,O?.data.includedAttachmentIds,Qr(t())):{messages:[],images:[],sources:[]},S=_.messages,z=_.images,V=r?t().nodes.find(Y=>Y.id===r):null;yE(S,bE(O?.data,V?.data,!!r));const P=O?.data.attachments||[];for(const Y of P)S.some(B=>B.content.includes(`[PDF: ${Y.name}]`)||B.content.includes(`[File: ${Y.name}]`))||(Y.type.startsWith("image/")?z.push({data:Y.content,mimeType:Y.type}):Y.type==="application/pdf"?Y.extractedText&&S.push({role:"user",content:`[PDF: ${Y.name}]
|
|
232
|
+
`));if(ee>=q)throw new Error(ve(Te("toast.contextOverWindow"),{est:ee.toLocaleString(),model:Y,limit:q.toLocaleString()}))}let B=null,j=null;const $=()=>{if(!B||!m()){B=null;return}const ee=B;B=null,e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n?{...pe,data:{...pe.data,...ee.response!==void 0?{response:ee.response,restreaming:void 0}:{},...ee.reasoning!==void 0?{reasoning:ee.reasoning}:{}}}:pe)}))},X=ee=>{B={...B??{},...ee},j==null&&($(),j=window.setTimeout(()=>{j=null,$()},100))},Q=()=>{j!=null&&(clearTimeout(j),j=null),$()},F=[...new Set((a.sources??[]).map(ee=>ee.nodeId).filter(ee=>!!ee))],G=async ee=>{const ue=await Promise.all(ee.images.map(async ae=>({type:ae.mimeType,sha:await _m(ae.data)}))),pe=await _m(E2({messages:ee.messages,images:ue,model:ee.model,tools:{web:!!ee.toolPrefs.web,scholar:!!ee.toolPrefs.scholar,mcp:!!ee.toolPrefs.mcp}})),be=F.slice(0,200);t().logEvent("commit",n,{kind:"request",sha:`sha256:${pe}`,n:ee.messages.length,images:ee.images.length,lane:ee.lane,...ee.model?{model:ee.model}:{},...be.length?{m:be.join(",")}:{},...F.length>be.length?{more:!0}:{}})};let J=!1;const K=await p8(d,(ee,ue)=>{if(X({response:ue}),C&&!J){J=!0;const pe=new Date().toISOString();e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&ae.data.agentTrace?.some(xe=>xe.status==="running")?{...ae,data:{...ae.data,agentTrace:ae.data.agentTrace.map(xe=>xe.status==="running"?{...xe,status:"ok",endedAt:pe}:xe)}}:ae)}))}},p.signal,s,{onDispatch:ee=>{G(ee).catch(()=>{})},onToolCall:(ee,ue)=>{if(!m())return;if(C){const be=new Date().toISOString();e(ae=>({nodes:ae.nodes.map(xe=>{if(xe.id!==n)return xe;const Ce=(xe.data.agentTrace??[]).map(ze=>ze.status==="running"?{...ze,status:"ok",endedAt:be}:ze);return Ce.push({id:`${be}-${Ce.length}`,name:ee,query:ue,status:"running",startedAt:be}),{...xe,data:{...xe.data,agentTrace:Ce}}})}));return}const pe=ee==="arxiv_search"?"📚":ee==="semantic_scholar"?"🎓":ee.startsWith("mcp:")?"🔧":"🔍";e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&!ae.data.response?{...ae,data:{...ae.data,response:`${pe} ${ue}…`}}:ae)}))},onGatewaySearch:()=>{m()&&(A=!0,e(ee=>({nodes:ee.nodes.map(ue=>ue.id===n&&!ue.data.response?{...ue,data:{...ue.data,response:`🌐 ${Te("node.gatewaySearching")}`}}:ue)})))},onSources:ee=>{x=ee},onHarnessSession:ee=>{O=ee},onAgentTool:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=[...be.data.agentTrace??[]];if(ee.phase==="start")ae.push({id:ee.id||`${ae.length}`,name:ee.name,query:ee.query,status:"running",startedAt:ue});else{const xe=ae.findIndex(Ce=>Ce.id===ee.id&&Ce.status==="running");xe>=0&&(ae[xe]={...ae[xe],status:ee.isError?"error":"ok",endedAt:ue})}return{...be,data:{...be.data,agentTrace:ae}}})}))},onAgentSession:ee=>{if(!m())return;const ue=!!I?.continue;e(pe=>({nodes:pe.nodes.map(be=>be.id===n?{...be,data:{...be.data,agentSession:{...be.data.agentSession,...ee,continued:ue}}}:be)})),ue&&ee.sessionId&&OV(ee.runtime,n,ee.sessionId,ee.cwd)},onAgentChanges:ee=>{m()&&e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n&&pe.data.agentSession?{...pe,data:{...pe.data,agentSession:{...pe.data.agentSession,changes:ee}}}:pe)}))},onHarnessTurn:ee=>{_=ee,C&&!S&&(S=M8(e,n,C,ee).catch(()=>!1))},onApproval:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=be.data.pendingApprovals??[];return ae.some(xe=>xe.id===ee.id)?be:{...be,data:{...be.data,pendingApprovals:[...ae,{...ee,askedAt:ue}]}}})})),We("info",Te("approval.toast"),8e3)},onApprovalDecided:({id:ee,outcome:ue,value:pe,auto:be,name:ae,query:xe,rule:Ce})=>{if(!m())return;const ze=new Date().toISOString();e(Ie=>({nodes:Ie.nodes.map(Fe=>{if(Fe.id!==n)return Fe;const Ee=Fe.data.pendingApprovals??[],Me=Ee.find(Ye=>Ye.id===ee),De=Ee.filter(Ye=>Ye.id!==ee),bt=De.length?De:void 0;if(!Me&&be)return{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{id:ee,kind:"confirm",toolName:Fe.data.agentSession?.runtime??"agent",callId:null,reason:null,name:ae??"",query:xe??"",arguments:null,askedAt:ze,decidedAt:ze,outcome:ue,auto:!0,...Ce?{rule:Ce}:{}}]}};if(!Me)return{...Fe,data:{...Fe.data,pendingApprovals:bt}};const mt={...Me};return delete mt.answered,{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{...mt,outcome:ue,decidedAt:ze,...pe?{value:pe}:{}}]}}})}))},onRerouted:(ee,ue)=>{v=ue},onImageFallback:ee=>{v=ee},onReasoning:(ee,ue)=>{X({reasoning:ue})}},(()=>{const ee=t().nodes.find(ue=>ue.id===n)?.data;return{web:ee?.webSearch??oe.getState().webSearchEnabled,scholar:ee?.scholarSearch??oe.getState().scholarSearchEnabled,mcp:oe.getState().mcpEnabled}})(),y,C??(I?{...I,nodeId:n}:void 0));if(Q(),!m())return;if(Ds.delete(n),!K.trim()){z(Te("node.emptyResponse"),!0);return}if(I){const ee=t().nodes.find(ue=>ue.id===n)?.data.agentSession;ee&&await zV(n,ee,r).catch(()=>!1)}if(z(K),C){const ee=S?await S:!1;await I8(e,t,n,{question:r,response:K},C,O,_,ee)}o?.(K),t().pushHistory(),xV(n,r,K,t().setSummary,bV(n,t().nodes,t().edges),{model:C||I?void 0:T,set:t().setLadder,...w7(n,t().nodes,t().edges)}),!V?.stepKind&&!V?.digestOf&&ft(async()=>{const{useProjects:ee}=await Promise.resolve().then(()=>Sa);return{useProjects:ee}},void 0).then(({useProjects:ee})=>{const{projects:ue,activeId:pe}=ee.getState(),be=ue.find(ae=>ae.id===pe);hW(r,K,be?{id:be.id,name:be.name}:void 0)}),yV(e,t,n),Ul(t,n)}catch(Y){if(!m())return;Ds.delete(n);const q=t().nodes.find(j=>j.id===n)?.data.response||"";if(Y instanceof DOMException&&Y.name==="AbortError")z(q||Te("node.stoppedPlaceholder"));else{const j=Y instanceof Error?Y.message:Te("toast.unknownError");/no model configured/i.test(j)?(We("info",Te("toast.noModelYet")),oe.getState().setApiKeyModalOpen(!0)):/429|too many requests|rate.?limit|quota/i.test(j)?We("info",Te("toast.rateLimited")):We("error",ve(Te("toast.generationFailed"),{message:j})),z(q||Te("node.failedPlaceholder"),!0)}t().pushHistory()}}function Ul(e,t){if(oe.getState().autoRefreshPaused)return;const{nodes:n,edges:a}=e(),r=new Map(n.map(o=>[o.id,o])),s=o=>{const u=r.get(o);return!u||u.data.isLoading?!1:u.data.stepKind==="human"||u.data.stepKind==="note"||u.data.stepKind==="link"?!!u.data.question.trim():u.data.stepKind==="file"?(u.data.attachments?.length??0)>0:!!u.data.response&&!u.data.generationFailed};for(const o of a){if(o.source!==t||o.data?.isCrossLink)continue;const u=r.get(o.target);!u||u.data.stepKind!=="prompt"||u.data.response||u.data.isLoading||u.data.generationFailed||!a.filter(h=>h.target===u.id&&!h.data?.isCrossLink).map(h=>h.source).every(s)||e().rerunNode(u.id,{auto:!0})}}function yV(e,t,n){if(oe.getState().autoRefreshPaused)return;const a=new Set([n]),r=[n];for(;r.length>0;){const d=r.shift();for(const h of t().edges)h.target===d&&!h.data?.isCrossLink&&!a.has(h.source)&&(a.add(h.source),r.push(h.source))}t().edges.some(d=>d.data?.followsTip&&d.source!==n&&a.has(d.source))&&e(d=>({edges:d.edges.map(h=>h.data?.followsTip&&h.source!==n&&a.has(h.source)?{...h,id:`watch-${n}-${h.target}`,source:n}:h)}));const{nodes:o,edges:u}=t();for(const d of o){if(!(d.data.autoRerun??d.data.evaluatorTrigger==="auto")||d.id===n||d.data.isLoading||Ds.has(d.id))continue;const m=E0.get(d.id)??0;if(m>=(d.data.autoRerunRounds??1))continue;const{ordered:p}=Pr(d.id,o,u);p.some(x=>x.id===n)&&(E0.set(d.id,m+1),t().rerunNode(d.id,{auto:!0}))}}const zE=e=>{for(const t of e){const n=Ds.get(t);n&&(n.abort(),Ds.delete(t))}},vV=(e,t)=>({nodes:[],edges:[],selectedNodeId:null,selectedNodeIds:[],setNodes:n=>e({nodes:n}),setEdges:n=>e({edges:n}),setSelectedNodeId:n=>e({selectedNodeId:n,selectedNodeIds:n?[n]:[]}),setSelectedNodeIds:n=>e({selectedNodeIds:n,selectedNodeId:n.length===1?n[0]:null}),deleteNode:n=>{if(Xr())return;t().logEvent("delete",n,{n:1}),t().pushHistory();const{edges:a}=t(),r=Vo(n,a),s=new Set([n,...r]);zE(s),e(o=>({nodes:o.nodes.filter(u=>!s.has(u.id)),edges:o.edges.filter(u=>!s.has(u.source)&&!s.has(u.target))})),t().pushHistory(),ft(()=>import("./canonical-C3OufoVo.js"),[]).then(o=>o.unsubscribeOrphanedSessions())},deleteEdges:n=>{if(Xr())return;t().logEvent("disconnect",n[0],{n:n.length});const a=new Set(n);t().edges.some(r=>a.has(r.id))&&(t().pushHistory(),e(r=>({edges:r.edges.filter(s=>!a.has(s.id))})),t().pushHistory())},editResponse:(n,a)=>{if(Xr())return;t().logEvent("edit-response",n,{chars:a.length}),t().pushHistory();const r=Nn(t().nodes.find(s=>s.id===n)?.data.question+a||a);e(s=>({nodes:s.nodes.map(o=>o.id===n?{...o,data:{...o.data,response:a,responses:o.data.responses.map((u,d)=>d===o.data.responseIndex?a:u),summaries:o.data.summaries?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTypes:o.data.summaryTypes?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTopics:o.data.summaryTopics?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryLadders:o.data.summaryLadders?.map((u,d)=>d===o.data.responseIndex?void 0:u),editedAts:o.data.responses.map((u,d)=>d===o.data.responseIndex?new Date().toISOString():o.data.editedAts?.[d]),highlights:im(o.data.highlights,a),isEditingResponse:!1,tokenCount:r}}:o)})),t().pushHistory()},toggleCollapse:n=>{const a=t().nodes.find(h=>h.id===n);if(!a)return;const r=Pi(a),o=k2({...a,data:{...a.data,isCollapsed:!a.data.isCollapsed}})-r,u=Vo(n,t().edges),d=new Set(u);e(h=>({nodes:h.nodes.map(m=>m.id===n?{...m,data:{...m.data,isCollapsed:!m.data.isCollapsed}}:d.has(m.id)?{...m,position:{...m.position,y:m.position.y+o}}:m)}))},setEditing:(n,a)=>{a&&Xr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditing:a}}:s)}))},setEditingResponse:(n,a)=>{a&&Xr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditingResponse:a}}:s)}))},duplicateNode:n=>{const a=t().nodes.find(m=>m.id===n);if(!a)return;t().pushHistory();const r=Tn(),s={id:r,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{...a.data,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,highlights:a.data.highlights.map(m=>({...m,id:Tn()}))}},o=t().edges.find(m=>m.target===n),u=o?{...o,id:`edge-${o.source}-${r}`,target:r}:null,d=u?[...t().edges,u]:t().edges,h=xr([...t().nodes,s],d);e({nodes:h,edges:d,selectedNodeId:r}),t().pushHistory()},addCrossLink:(n,a)=>{const{edges:r,nodes:s}=t();if(r.some(x=>x.source===n&&x.target===a))return;const u=s.find(x=>x.id===n);if(u&&["note","file","link"].includes(u.data.stepKind??"")){t().pushHistory();const x={id:`edge-${n}-${a}`,source:n,sourceHandle:"continue",target:a,targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};e(y=>({edges:[...y.edges,x]})),t().logEvent("connect",x.id),t().setEdgeStructural(x.id,!0);const b=t().edges.find(y=>y.id===x.id);if(b&&!b.data?.isCrossLink){const w=br(n,t().nodes,t().edges).messages.reduce((E,v)=>E+Nn(v.content),0);We("success",ve(Te("edge.materialWiredFull"),{n:w.toLocaleString()}),8e3,{label:Te("edge.materialMakeQuote"),run:()=>t().setEdgeStructural(x.id,!1)})}return}t().pushHistory();const d=s.find(x=>x.id===n),h=s.find(x=>x.id===a),m=!!d&&!!h&&h.position.y>d.position.y+60&&Math.abs(h.position.x-d.position.x)<320,p={id:`crosslink-${n}-${a}`,source:n,sourceHandle:m?"continue":"branch",target:a,targetHandle:m?"top":"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};if(e(x=>({edges:[...x.edges,p]})),t().logEvent("connect",p.id),t().pushHistory(),d&&!["note","file","link"].includes(d.data.stepKind??"")){const{ordered:x}=Pr(n,s,r.filter(y=>!y.data?.isCrossLink)),b=x.filter(y=>y.id!==n&&!["note","file","link"].includes(y.data.stepKind??""));if(b.length>0){const y=Nn(y0({source:d,depth:"quote",chain:b})),E=br(n,s,r).messages.reduce((v,A)=>v+Nn(A.content),0)+Nn(d.data.question+d.data.response);We("info",ve(Te("edge.linkedQuote"),{n:y}),8e3,{label:ve(Te("edge.makeFull"),{m:E}),run:()=>t().setEdgeStructural(p.id,!0)})}}},staleIds:[],staleFps:{},staleVerdicts:{},setStaleVerdicts:n=>e(a=>({staleVerdicts:{...a.staleVerdicts,...n}})),recomputeStaleness:()=>{const{nodes:n,edges:a}=t(),r=[],s={};for(const d of n){if(!d.data.lastContextHash||!d.data.response||["note","file","link","frame"].includes(d.data.stepKind??""))continue;const h=v8(d.id,n,a);h!==d.data.lastContextHash&&(r.push(d.id),s[d.id]=h)}const o=t().staleFps,u=t().staleIds;u.length===r.length&&u.every((d,h)=>d===r[h]&&o[d]===s[d])||(e({staleIds:r,staleFps:s}),r.length&&ft(()=>Promise.resolve().then(()=>kV),void 0).then(d=>d.judgeStaleness()).catch(()=>{}))},setEdgeStructural:(n,a)=>{const{nodes:r,edges:s}=t(),o=s.find(u=>u.id===n);if(o){if(a){const u=s.filter(h=>!h.data?.isCrossLink),{ordered:d}=Pr(o.source,r,u);if(d.some(h=>h.id===o.target)){We("error",Te("edge.cycleBlocked"));return}}t().pushHistory(),t().logEvent(a?"connect":"disconnect",n,{convert:!0}),e(u=>({edges:u.edges.map(d=>{if(d.id!==n)return d;if(a){const h={...d.data??{}};return delete h.isCrossLink,delete h.contextDepth,delete h.isWatch,{...d,sourceHandle:"continue",targetHandle:"top",animated:!1,style:{stroke:it.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:h}}return{...d,animated:!0,style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{...d.data??{},isCrossLink:!0,contextDepth:void 0}}})})),e(u=>({nodes:xr(u.nodes,u.edges)})),t().pushHistory()}},setCrossLinkDepth:(n,a)=>{t().pushHistory(),e(r=>({edges:r.edges.map(s=>s.id!==n||!s.data?.isCrossLink?s:{...s,style:{...s.style,strokeDasharray:a==="full"?"12 3":"8 4",strokeWidth:a==="full"?3:2},data:{...s.data,contextDepth:a==="full"?"full":void 0}})})),t().pushHistory()},navigateVersion:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const{responses:o,responseIndex:u}=s.data;let d=a==="prev"?u-1:u+1;return d<0&&(d=o.length-1),d>=o.length&&(d=0),{...s,data:{...s.data,responseIndex:d,response:o[d],question:s.data.questions?.[d]??s.data.question,generationFailed:void 0,highlights:im(s.data.highlights,o[d])}}})}))},deleteVersion:(n,a)=>{t().pushHistory(),e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const o=s.data.responses.filter((d,h)=>h!==a);if(o.length===0)return s;const u=Math.min(s.data.responseIndex,o.length-1);return{...s,data:{...s.data,responses:o,responseIndex:u,response:o[u],questions:s.data.questions?.filter((d,h)=>h!==a),question:s.data.questions?.filter((d,h)=>h!==a)[u]??s.data.question,summaries:s.data.summaries?.filter((d,h)=>h!==a),generatedBy:s.data.generatedBy?.filter((d,h)=>h!==a),summaryTypes:s.data.summaryTypes?.filter((d,h)=>h!==a),reasonings:s.data.reasonings?.filter((d,h)=>h!==a),generatedAts:s.data.generatedAts?.filter((d,h)=>h!==a),editedAts:s.data.editedAts?.filter((d,h)=>h!==a),highlights:im(s.data.highlights,o[u])}}})})),t().pushHistory()},relayout:()=>{Xr()||(t().pushHistory(),e(n=>{const a=d$(n.nodes,n.edges);return{nodes:xr(n.nodes,a),edges:a}}),t().pushHistory())},setArchived:(n,a)=>{const r=new Set(n);t().pushHistory(),t().logEvent(a?"archive":"unarchive",n[0],{n:n.length}),e(s=>({nodes:s.nodes.map(o=>r.has(o.id)?{...o,data:{...o.data,archived:a||void 0,archivedAt:a?new Date().toISOString():void 0}}:o)})),t().pushHistory()},setNodeModel:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,model:a}}:s)}))},alignSelection:n=>{if(n.length<2)return;const a=new Set(n),{nodes:r,edges:s}=t(),o=new Map,u=s.filter(b=>!b.data?.isWatch),d=(b,y)=>{if(o.has(b))return o.get(b);if(y.has(b))return 0;y.add(b);const w=u.filter(v=>v.target===b&&a.has(v.source)),E=w.length===0?0:1+Math.max(...w.map(v=>d(v.source,y)));return o.set(b,E),E},h=n.map(b=>r.find(y=>y.id===b)).filter(b=>!!b).sort((b,y)=>d(b.id,new Set)-d(y.id,new Set)||b.position.y-y.position.y);t().pushHistory();const m=h[0].position;let p=m.y;const x=new Map;for(const b of h)x.set(b.id,{x:m.x,y:p}),p+=Pi(b)+40;e(b=>({nodes:b.nodes.map(y=>{const w=x.get(y.id);return w?{...y,position:w}:y})})),t().pushHistory()},batchDelete:n=>{if(Xr())return;t().logEvent("delete",n[0],{n:n.length}),t().pushHistory();const a=new Set(n);zE(a),e(r=>({nodes:r.nodes.filter(s=>!a.has(s.id)),edges:r.edges.filter(s=>!a.has(s.source)&&!a.has(s.target)),selectedNodeId:null,selectedNodeIds:[]})),t().pushHistory(),ft(()=>import("./canonical-C3OufoVo.js"),[]).then(r=>r.unsubscribeOrphanedSessions())},duplicateSelection:n=>{const{nodes:a,edges:r}=t(),s=new Set(n),o=a.filter(_=>s.has(_.id));if(o.length===0)return;t().pushHistory();const u=_=>({x:_.position.x,y:_.position.y,w:_.measured?.width??_.width??520,h:_.measured?.height??_.height??Pi(_)}),d=o.map(u),h={x:Math.min(...d.map(_=>_.x)),y:Math.min(...d.map(_=>_.y)),right:Math.max(...d.map(_=>_.x+_.w)),bottom:Math.max(...d.map(_=>_.y+_.h))},m=80,p=h.right-h.x+m,x=h.bottom-h.y+m,b=[];for(let _=1;_<=6;_++)b.push({dx:_*p,dy:0},{dx:0,dy:_*x},{dx:_*p,dy:_*x});const y=a.filter(_=>_.data.stepKind!=="frame").map(u),w=(_,S)=>_.x<S.x+S.w&&_.x+_.w>S.x&&_.y<S.y+S.h&&_.y+_.h>S.y,E=b.find(_=>!d.some(S=>y.some(z=>w({...S,x:S.x+_.dx,y:S.y+_.dy},z))))??{dx:p,dy:x},v=new Map,A=new Map;for(const _ of o){v.set(_.id,Tn());for(const S of _.data.attachments??[])A.set(S.id,Tn())}const T=_=>(_??[]).map(S=>A.get(S)??S),C=o.map(_=>({..._,id:v.get(_.id),position:{x:_.position.x+E.dx,y:_.position.y+E.dy},selected:!0,data:{..._.data,attachments:(_.data.attachments??[]).map(S=>({...S,id:A.get(S.id)})),excludedAttachmentIds:T(_.data.excludedAttachmentIds),includedAttachmentIds:T(_.data.includedAttachmentIds),digestOf:_.data.digestOf?A.get(_.data.digestOf)??_.data.digestOf:void 0,highlights:(_.data.highlights??[]).map(S=>({...S,id:Tn()})),isEditing:!1,isEditingResponse:!1,isLoading:!1}})),I=r.filter(_=>s.has(_.source)&&s.has(_.target)).map(_=>({..._,id:`edge-${v.get(_.source)}-${v.get(_.target)}`,source:v.get(_.source),target:v.get(_.target),data:_.data?{..._.data}:_.data})),O=C.map(_=>_.id);e(_=>({nodes:[..._.nodes.map(S=>S.selected?{...S,selected:!1}:S),...C],edges:[..._.edges,...I],selectedNodeId:O.length===1?O[0]:null,selectedNodeIds:O})),t().pushHistory()}}),z2=(e,t)=>{const n=e.staleVerdicts[t];return!!n&&n.fp===e.staleFps[t]&&n.p<H$},Qr=e=>e.staleIds.filter(t=>!z2(e,t)),E7=(e,t)=>{const n=e.staleVerdicts[t];return n&&n.fp===e.staleFps[t]?n:void 0},wV=8;let Nx=!1;const Ax=new Set;async function S7(){if(Nx||!Rr())return;const e=se.getState(),t=e.staleIds.filter(a=>e.staleVerdicts[a]?.fp!==e.staleFps[a]&&!Ax.has(`${a}:${e.staleFps[a]}`));if(!t.length)return;Nx=!0;try{const{nodes:a,edges:r}=e,s=[];for(const o of t.slice(0,wV)){Ax.add(`${o}:${e.staleFps[o]}`);const u=a.find(p=>p.id===o),d=u?.data.lastContextParts;if(!u||!d)continue;const h=w8(o,a,r),m=[];for(const[p,x]of Object.entries(h)){const b=d[p];(!b||b.h!==x.h)&&m.push({node:p,before:b?.head??"",after:x.text})}for(const p of Object.keys(d))h[p]||m.push({node:p,before:d[p].head,after:""});m.length&&s.push({id:o,question:u.data.question,answer:u.data.response,changes:m})}if(s.length){const o=await F$(s),u={};for(const d of s)u[d.id]={fp:e.staleFps[d.id],p:o[d.id],changed:d.changes.map(h=>h.node)};se.getState().setStaleVerdicts(u)}}catch{}finally{Nx=!1}const n=se.getState();n.staleIds.some(a=>n.staleVerdicts[a]?.fp!==n.staleFps[a]&&!Ax.has(`${a}:${n.staleFps[a]}`))&&S7()}const kV=Object.freeze(Object.defineProperty({__proto__:null,currentStaleVerdict:E7,judgeStaleness:S7,shownStaleIds:Qr,staleHiddenByJudge:z2},Symbol.toStringTag,{value:"Module"})),EV=(e,t)=>({addQuestion:async(n,a={})=>{if(Xr())return;const{parentId:r,branchContext:s,branchYRatio:o,inheritRole:u,rolePrompt:d,initialAttachments:h,excludeAllInheritedAttachments:m,mentions:p}=a,x=Tn();t().logEvent("ask",x,{chars:n.length,...r?{}:{root:!0},...s?{branch:!0}:{}});const b=!r,y=r?t().nodes.find(Y=>Y.id===r)?.data.model:void 0,w={id:x,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:n,createdAt:new Date().toISOString(),askedAt:new Date().toISOString(),model:y,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!0,tokenCount:0,branchContext:s,highlights:[],highlightMode:"tag",attachments:h||[],excludedAttachmentIds:m&&r?t().getInheritedAttachments(r).map(({attachment:Y})=>Y.id).concat((t().nodes.find(Y=>Y.id===r)?.data.attachments||[]).map(Y=>Y.id)):[],includedAttachmentIds:[],roleMode:u===!1?"reset":"inherit",rolePrompt:d||void 0,isRoot:b,isBranch:!!s,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled,...Bd()}},E=!!s,v=r?{id:`edge-${r}-${x}`,source:r,target:x,sourceHandle:E?"branch":"continue",targetHandle:E?"left":"top",type:"smoothstep",...E?{style:{stroke:it.warm,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.warm,width:18,height:18},data:{isBranchFromSelection:!0,branchYRatio:o??.5}}:{style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}:null;let A=v?[...t().edges,v]:t().edges;const T=(p??[]).filter(Y=>Y!==x&&Y!==r&&t().nodes.some(q=>q.id===Y));if(T.length>0){const Y=A.filter($=>!$.data?.isCrossLink),q=r?new Set(Pr(r,t().nodes,Y).ordered.map($=>$.id)):new Set,B=new Set(A.filter($=>$.data?.isCrossLink&&$.target===x).map($=>$.source));let j=0;for(const $ of T)q.has($)||B.has($)||(A=[...A,{id:`crosslink-${$}-${x}`,source:$,target:x,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}}],j++);j>0&&We("info",ve(Te("mention.wired"),{n:j}),6e3)}const C=r?t().nodes.map(Y=>Y.id===r?{...Y,data:{...Y.data,isCollapsed:!0}}:Y):t().nodes,I=xr([...C,w],A);e({nodes:I,edges:A,selectedNodeId:x});const O=t().nodes.find(Y=>Y.id===x),_=r?br(r,t().nodes,t().edges,s,O?.data.excludedAttachmentIds,O?.data.includedAttachmentIds,Qr(t())):{messages:[],images:[],sources:[]},S=_.messages,z=_.images,V=r?t().nodes.find(Y=>Y.id===r):null;yE(S,bE(O?.data,V?.data,!!r));const P=O?.data.attachments||[];for(const Y of P)S.some(B=>B.content.includes(`[PDF: ${Y.name}]`)||B.content.includes(`[File: ${Y.name}]`))||(Y.type.startsWith("image/")?z.push({data:Y.content,mimeType:Y.type}):Y.type==="application/pdf"?Y.extractedText&&S.push({role:"user",content:`[PDF: ${Y.name}]
|
|
233
233
|
${Y.extractedText}`}):Y.type==="text/html"?Y.extractedText?.trim()&&S.push({role:"user",content:`[File: ${Y.name}]
|
|
234
234
|
${Y.extractedText}`}):Y.content&&S.push({role:"user",content:`[File: ${Y.name}]
|
|
235
235
|
${Y.content}`}));const L=S.find(Y=>Y.role==="system")?.content||void 0;S.push({role:"user",content:n}),e(Y=>({nodes:Y.nodes.map(q=>q.id===x?{...q,data:{...q.data,appliedRole:L}}:q)})),await ji(e,t,x,{question:n,messages:S,images:z,sources:_.sources})},fanOut:async(n,a,r,s={})=>{t().logEvent("fanout",n,{roles:r.length,chars:a.length});const o=t().nodes.find(T=>T.id===n);if(!o||r.length===0)return;const u=!!s.follow,d=u&&s.rounds&&s.rounds>1?Math.min(s.rounds,5):void 0;t().pushHistory();const h=[],m=[],p=[];r.forEach((T,C)=>{const I=Tn(),O=`${T.prompt}
|
|
@@ -287,7 +287,7 @@ ${u.content.trim()}`).join(`
|
|
|
287
287
|
|
|
288
288
|
---
|
|
289
289
|
|
|
290
|
-
${p}`:p,v=oe.getState().agentEffort||void 0,A=[...new Set(se.getState().nodes.flatMap(S=>(S.data.approvals??[]).filter(z=>z.outcome==="allowed-session"&&typeof z.rule=="string"&&z.rule.startsWith(h.runtime==="claude-code"?"claude:":h.runtime+":")).map(z=>z.rule)))];jV();let T="",C="",I="";const _=await new Promise(S=>{d.run({runtime:h.runtime,cwd:m,prompt:E,...o?.sessionPath?{sessionPath:o.sessionPath}:{},...o?.forkEntryId?{forkEntryId:o.forkEntryId}:{},images:(a??[]).map(z=>({type:"image",data:z.data,mimeType:z.mimeType})),model:{provider:h.provider,id:h.id},...v?{effort:v}:{},...A.length?{allowRules:A}:{}}).then(z=>{const V=()=>{d.abort(z)};n?.aborted&&V(),n?.addEventListener("abort",V,{once:!0}),om.set(z,P=>{switch(P.type){case"session":{const L=P.model?.resolved;L&&window.dispatchEvent(new CustomEvent("td:agent-model-resolved",{detail:{id:s,resolved:L}})),r?.onAgentSession?.({runtime:h.runtime,sessionId:P.sessionId??null,sessionFile:P.sessionFile??null,cwd:P.cwd??m,...typeof P.effort=="string"&&P.effort?{effort:P.effort}:{}});break}case"message_update":{const L=P.assistantMessageEvent;L?.type==="text_delta"&&L.delta?(T+=L.delta,t(L.delta,T)):L?.type==="thinking_delta"&&L.delta&&(C+=L.delta,r?.onReasoning?.(L.delta,C));break}case"tool_execution_start":{const L=String(P.toolName??"tool"),Y=LV(L,P.args);r?.onAgentTool?.({id:String(P.toolCallId??""),name:L,query:Y,phase:"start"});break}case"tool_execution_end":r?.onAgentTool?.({id:String(P.toolCallId??""),name:String(P.toolName??"tool"),query:"",phase:"end",isError:!!P.isError});break;case"extension_ui_cancelled":{const L=`dialog-${Date.now()}`,Y=String(P.title??P.method??"dialog");r?.onAgentTool?.({id:L,name:"dialog",query:Y,phase:"start"}),r?.onAgentTool?.({id:L,name:"dialog",query:"",phase:"end",isError:!0});break}case"question_answered":r?.onApprovalDecided?.({...P.auto?{auto:!0,name:String(P.title??""),query:String(P.message??""),rule:typeof P.rule=="string"?P.rule:null}:{},id:String(P.id),outcome:P.outcome??"cancelled",value:typeof P.value=="string"?P.value:null});break;case"question":r?.onApproval?.({id:String(P.id),kind:P.kind??"confirm",toolName:h.runtime,callId:null,reason:null,name:String(P.title??""),query:String(P.message??""),arguments:null,options:Array.isArray(P.options)?P.options:[],placeholder:typeof P.placeholder=="string"?P.placeholder:null,prefill:typeof P.prefill=="string"?P.prefill:null,channel:{runId:z},paths:Array.isArray(P.paths)?P.paths:[],suggest:typeof P.suggest=="string"?P.suggest:null,rule:typeof P.rule=="string"?P.rule:null});break;case"fs_changes":r?.onAgentChanges?.({changed:P.changed??[],added:P.added??[],removed:P.removed??[],truncated:!!P.truncated});break;case"run_end":I=typeof P.text=="string"&&P.text?P.text:T,om.delete(z),n?.removeEventListener("abort",V),S({how:String(P.how??"end")});break;case"run_error":om.delete(z),n?.removeEventListener("abort",V),S({how:"error",error:String(P.message??"agent run failed")});break}})}).catch(z=>S({how:"error",error:z instanceof Error?z.message:String(z)}))});if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(_.how==="error")throw new Error(_.error??"agent run failed");return I||T}async function zV(e,t,n){const a=o=>(console.warn("[agent] turn not adopted:",o,t.runtime,t.sessionFile),!1),r=window.desktopSessions;if(!r||!t.sessionFile)return a(r?"no session file":"no sessions bridge");const s=Ki[t.runtime].rootKey;try{const u=(await r.roots()).find(q=>q.key===s);if(!u)return a("no root "+s);const d=u.path.replace(/\/$/,"")+"/";if(!t.sessionFile.startsWith(d))return a("file outside root "+d);const h=t.sessionFile.slice(d.length),{anyRunnerSessionConversation:m}=await ft(async()=>{const{anyRunnerSessionConversation:q}=await import("./index-
|
|
290
|
+
${p}`:p,v=oe.getState().agentEffort||void 0,A=[...new Set(se.getState().nodes.flatMap(S=>(S.data.approvals??[]).filter(z=>z.outcome==="allowed-session"&&typeof z.rule=="string"&&z.rule.startsWith(h.runtime==="claude-code"?"claude:":h.runtime+":")).map(z=>z.rule)))];jV();let T="",C="",I="";const _=await new Promise(S=>{d.run({runtime:h.runtime,cwd:m,prompt:E,...o?.sessionPath?{sessionPath:o.sessionPath}:{},...o?.forkEntryId?{forkEntryId:o.forkEntryId}:{},images:(a??[]).map(z=>({type:"image",data:z.data,mimeType:z.mimeType})),model:{provider:h.provider,id:h.id},...v?{effort:v}:{},...A.length?{allowRules:A}:{}}).then(z=>{const V=()=>{d.abort(z)};n?.aborted&&V(),n?.addEventListener("abort",V,{once:!0}),om.set(z,P=>{switch(P.type){case"session":{const L=P.model?.resolved;L&&window.dispatchEvent(new CustomEvent("td:agent-model-resolved",{detail:{id:s,resolved:L}})),r?.onAgentSession?.({runtime:h.runtime,sessionId:P.sessionId??null,sessionFile:P.sessionFile??null,cwd:P.cwd??m,...typeof P.effort=="string"&&P.effort?{effort:P.effort}:{}});break}case"message_update":{const L=P.assistantMessageEvent;L?.type==="text_delta"&&L.delta?(T+=L.delta,t(L.delta,T)):L?.type==="thinking_delta"&&L.delta&&(C+=L.delta,r?.onReasoning?.(L.delta,C));break}case"tool_execution_start":{const L=String(P.toolName??"tool"),Y=LV(L,P.args);r?.onAgentTool?.({id:String(P.toolCallId??""),name:L,query:Y,phase:"start"});break}case"tool_execution_end":r?.onAgentTool?.({id:String(P.toolCallId??""),name:String(P.toolName??"tool"),query:"",phase:"end",isError:!!P.isError});break;case"extension_ui_cancelled":{const L=`dialog-${Date.now()}`,Y=String(P.title??P.method??"dialog");r?.onAgentTool?.({id:L,name:"dialog",query:Y,phase:"start"}),r?.onAgentTool?.({id:L,name:"dialog",query:"",phase:"end",isError:!0});break}case"question_answered":r?.onApprovalDecided?.({...P.auto?{auto:!0,name:String(P.title??""),query:String(P.message??""),rule:typeof P.rule=="string"?P.rule:null}:{},id:String(P.id),outcome:P.outcome??"cancelled",value:typeof P.value=="string"?P.value:null});break;case"question":r?.onApproval?.({id:String(P.id),kind:P.kind??"confirm",toolName:h.runtime,callId:null,reason:null,name:String(P.title??""),query:String(P.message??""),arguments:null,options:Array.isArray(P.options)?P.options:[],placeholder:typeof P.placeholder=="string"?P.placeholder:null,prefill:typeof P.prefill=="string"?P.prefill:null,channel:{runId:z},paths:Array.isArray(P.paths)?P.paths:[],suggest:typeof P.suggest=="string"?P.suggest:null,rule:typeof P.rule=="string"?P.rule:null});break;case"fs_changes":r?.onAgentChanges?.({changed:P.changed??[],added:P.added??[],removed:P.removed??[],truncated:!!P.truncated});break;case"run_end":I=typeof P.text=="string"&&P.text?P.text:T,om.delete(z),n?.removeEventListener("abort",V),S({how:String(P.how??"end")});break;case"run_error":om.delete(z),n?.removeEventListener("abort",V),S({how:"error",error:String(P.message??"agent run failed")});break}})}).catch(z=>S({how:"error",error:z instanceof Error?z.message:String(z)}))});if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(_.how==="error")throw new Error(_.error??"agent run failed");return I||T}async function zV(e,t,n){const a=o=>(console.warn("[agent] turn not adopted:",o,t.runtime,t.sessionFile),!1),r=window.desktopSessions;if(!r||!t.sessionFile)return a(r?"no session file":"no sessions bridge");const s=Ki[t.runtime].rootKey;try{const u=(await r.roots()).find(q=>q.key===s);if(!u)return a("no root "+s);const d=u.path.replace(/\/$/,"")+"/";if(!t.sessionFile.startsWith(d))return a("file outside root "+d);const h=t.sessionFile.slice(d.length),{anyRunnerSessionConversation:m}=await ft(async()=>{const{anyRunnerSessionConversation:q}=await import("./index-goc_KBNk.js");return{anyRunnerSessionConversation:q}},[]),{useStore:p}=await ft(async()=>{const{useStore:q}=await Promise.resolve().then(()=>vs);return{useStore:q}},void 0),{useProjects:x,registerLedgerEntry:b,updateSourceSession:y,subscribedSessionIds:w}=await ft(async()=>{const{useProjects:q,registerLedgerEntry:B,updateSourceSession:j,subscribedSessionIds:$}=await Promise.resolve().then(()=>Sa);return{useProjects:q,registerLedgerEntry:B,updateSourceSession:j,subscribedSessionIds:$}},void 0),E=await r.read(s,h);if(!E)return a("empty file");const v=await m(E);if(!v?.sessionId)return a("no conversation recognized");const T=v.build().nodes.filter(q=>q.data.importSource),C=n.trim();let I=-1;for(let q=T.length-1;q>=0;q--){const B=T[q].data.question.trim();if(B===C||B.endsWith(C)||C.endsWith(B)){I=q;break}}if(I<0&&(I=T.length-1),I<0)return a("no turn in file yet");const O=T[I],_=O.data.attachments??[],S=HV(t,_),z=S?[..._,S]:_;p.setState(q=>({nodes:q.nodes.map(B=>B.id===e?{...B,data:{...B.data,attachments:[...(B.data.attachments??[]).filter(j=>!j.op),...z],excludedAttachmentIds:[...new Set([...B.data.excludedAttachmentIds??[],...z.map(j=>j.id)])],importSource:O.data.importSource,source:O.data.source??{question:O.data.question,response:O.data.response},agentTrace:void 0}}:B)}));const{projects:V,activeId:P}=x.getState(),L=P?V.find(q=>q.id===P):void 0;if(!L)return!0;const Y={sessionId:v.sessionId,runner:t.runtime,importedCount:I+1,tailNodeId:e};if(w(L).includes(v.sessionId)){const{patchLedgerEntry:q}=await ft(async()=>{const{patchLedgerEntry:B}=await Promise.resolve().then(()=>Sa);return{patchLedgerEntry:B}},void 0);await q(P,v.sessionId,{importedCount:I+1,tailNodeId:e})}else L.sourceSession?await b(P,"chapter",Y):(await y(P,Y),x.getState().projects.find(q=>q.id===P)?.sourceSession||(x.setState(q=>({projects:q.projects.map(B=>B.id===P?{...B,sourceSession:Y}:B)})),await b(P,"chapter",Y).catch(()=>{}),x.setState(q=>({projects:q.projects.map(B=>B.id===P&&B.sourceSession?{...B,sourceSession:{...B.sourceSession,chapters:(B.sourceSession.chapters??[]).filter(j=>j.sessionId!==Y.sessionId)}}:B)}))));return!0}catch(o){return a("threw: "+(o instanceof Error?o.message:String(o)))}}async function BV(){try{const{useProjects:e}=await ft(async()=>{const{useProjects:r}=await Promise.resolve().then(()=>Sa);return{useProjects:r}},void 0),{projects:t,activeId:n}=e.getState(),a=t.find(r=>r.id===n)?.agentGuard;return{mode:a?.mode==="allow"?"allow":"ask",allow:a?.allow??[]}}catch{return{mode:"ask",allow:[]}}}async function H2(e){if(!window.desktopAgents)return;const t=e??(await B2())?.cwd;if(t)try{await window.desktopAgents.guardWrite(t,await BV())}catch{}}async function UE(e){const{useProjects:t,setProjectAgentGuard:n}=await ft(async()=>{const{useProjects:o,setProjectAgentGuard:u}=await Promise.resolve().then(()=>Sa);return{useProjects:o,setProjectAgentGuard:u}},void 0),{projects:a,activeId:r}=t.getState();if(!r)return;const s=a.find(o=>o.id===r)?.agentGuard;await n(r,{mode:e,allow:s?.allow??[]}),await H2()}async function A7(e,t=!1){const{useProjects:n,setProjectAgentGuard:a}=await ft(async()=>{const{useProjects:d,setProjectAgentGuard:h}=await Promise.resolve().then(()=>Sa);return{useProjects:d,setProjectAgentGuard:h}},void 0),{projects:r,activeId:s}=n.getState();if(!s)return;const o=r.find(d=>d.id===s)?.agentGuard,u=t?(o?.allow??[]).filter(d=>d!==e):[...new Set([...o?.allow??[],e])];await a(s,{mode:o?.mode??"ask",allow:u}),await H2()}function HV(e,t){const n=e.changes;if(!n)return null;const a=new Set;for(const d of t)for(const h of d.paths??[])a.add(h.startsWith("/")?h:`${e.cwd.replace(/\/$/,"")}/${h}`);const r=[...n.changed,...n.added].filter(d=>!a.has(d)),s=n.removed.filter(d=>!a.has(d));if(r.length===0&&s.length===0&&!n.truncated)return null;const o=d=>d.startsWith(e.cwd)?d.slice(e.cwd.length).replace(/^\//,""):d,u=[];return r.length&&u.push("Changed on disk during this turn (seen by the file system, not declared by a tool):",...r.map(d=>"- "+o(d))),s.length&&u.push("Removed:",...s.map(d=>"- "+o(d))),n.truncated&&u.push("(the directory was too large to scan completely)"),{id:`fs-${Date.now().toString(36)}`,name:"tool: fs-changes",type:"text/plain",size:0,content:u.join(`
|
|
291
291
|
`),op:"write",paths:[...r,...s]}}let Za=null,iy=null;const Yd=new Set;function dr(){return Za?Promise.resolve(Za):(iy??=(async()=>{const e=rs();let t=null;if(e.length>0)try{t=await $0(e)}catch{}return t||(t=await fetch(`${li}/api/models`).then(n=>n.json()).then(n=>({models:n.models??[],default:n.default??null,capabilities:n.capabilities})).catch(()=>null)),t?(Za=M7(t),Za):null})(),iy)}function qE(e){return(e.split("/").pop()??e).toLowerCase()}function C7(e,t){if(t.some(r=>r.id===e))return e;const n=qE(e),a=t.find(r=>qE(r.id)===n);return a?a.id:null}const F2="thoughtdag.agentModels",_7="thoughtdag.agentModelNames",Sp=()=>typeof window<"u"&&!!window.desktopAgents,pu=e=>e.provider===sr&&ri(e.id);function U2(){try{const e=JSON.parse(localStorage.getItem(_7)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function q2(e){const t=U2();return e.map(n=>{const a=n.provider===sr?t[n.id]:void 0;return!a||n.id.endsWith("/"+a)||n.name.includes(a)?n:{...n,name:`${n.name} · ${a}`}})}function S0(e,t,n){if(!e)return"";const a=T7(e);if(!a)return e.split("/").pop()??e;let r=[];try{r=JSON.parse(localStorage.getItem(F2)??"[]")}catch{r=[]}const o=r.find(h=>h&&h.id===e)?.name??`${Ki[a.runtime].label} · ${a.id}`,u=n?.compact?void 0:U2()[e],d=u&&!o.includes(u)?`${o} · ${u}`:o;return t?`${d} · ${t}`:d}function M7(e){if(!Sp())return e;let t=[];try{t=JSON.parse(localStorage.getItem(F2)??"[]")}catch{t=[]}const n=e.models.filter(a=>!pu(a));return{...e,models:[...n,...q2(t.filter(a=>a&&pu(a)))],agentsPending:!1}}let zm=!1,Td=null;async function $2(){if(!(!Sp()||!Za))return Td||(Td=(async()=>{const e=Za;ql({...e,agentsPending:!0});const t=await _V().catch(()=>({models:[],runtimes:{}})),n=t.models;try{localStorage.setItem(F2,JSON.stringify(n))}catch{}const a=(Za??e).models.filter(r=>!pu(r));ql({...Za??e,models:[...a,...q2(n)],agentsPending:!1,runtimes:t.runtimes})})().finally(()=>{Td=null}),Td)}function FV(){return zm=!0,dr().then(()=>$2())}function $E(){zm||!Sp()||(zm=!0,dr().then(()=>$2()))}function UV(e,t){if(!e||!t)return;const n=U2();if(n[e]===t)return;n[e]=t;try{localStorage.setItem(_7,JSON.stringify(n))}catch{}if(!Za)return;const a=Za.models.filter(s=>!pu(s)),r=Za.models.filter(pu).map(s=>({...s,name:s.name.split(" · ").slice(0,2).join(" · ")}));ql({...Za,models:[...a,...q2(r)]})}typeof window<"u"&&window.addEventListener("td:agent-model-resolved",e=>{const t=e.detail;t?.id&&t?.resolved&&UV(t.id,t.resolved)});function ql(e){Za=e,iy=Promise.resolve(e);for(const t of Yd)t(e);if(e.agentsPending===void 0&&Sp()&&!e.models.some(pu)){Za=M7(e);for(const t of Yd)t(Za);zm&&$2()}}function Yl(){const[e,t]=D.useState(Za);return D.useEffect(()=>{const n=a=>t(a);return Yd.add(n),Za||dr().then(a=>{Yd.has(n)&&a&&t(a)}),()=>{Yd.delete(n)}},[]),e}const qV=[[/^(Read|NotebookRead)$/i,"📖"],[/^(Edit|Write|MultiEdit|NotebookEdit)$/i,"✏️"],[/^(Bash|BashOutput|Shell)$/i,"⌨️"],[/^(Grep|Glob|LS|Search|WebSearch)$/i,"🔍"],[/^(WebFetch|Fetch)$/i,"🌐"],[/^(Task|Agent)$/i,"🤖"]],I7=/^tool: (\S+?)( \(truncated\))?$/;function $V(e){const t=new Map;for(const n of e.attachments??[]){const a=n.name.match(I7);if(!a)continue;const r=a[1],s=qV.find(([u])=>u.test(r))?.[1]??"🔧",o=t.get(r);o?o.count+=1:t.set(r,{glyph:s,name:r,count:1})}return[...t.values()]}function WV(e){let t=0;for(const s of e.attachments??[])I7.test(s.name)&&(t+=Nn(s.content));if(t===0)return null;const n=Nn(e.question),a=Nn(e.response),r=n+a+t;return{q:n,a,tool:t,total:r,toolShare:r>0?t/r:0}}function VV(e){const t=new Map;for(const n of e.attachments??[])if(!(!n.paths?.length||n.op!=="read"&&n.op!=="write"&&n.op!=="edit"))for(const a of n.paths){const r=t.get(a);r?r.op==="read"&&n.op!=="read"&&(r.op=n.op):t.set(a,{path:a,name:a.split("/").filter(Boolean).pop()??a,op:n.op})}return[...t.values()].sort((n,a)=>(n.op==="read"?1:0)-(a.op==="read"?1:0))}function GV(e,t=140){const n=e.replace(/```[\s\S]*?```/g,"").split(/\n\s*\n/).map(s=>s.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[#*`>|_~]/g,"").replace(/^\s*[-•\d.)]+\s*/gm,"").replace(/\s+/g," ").trim()).filter(s=>s.length>12&&!/[::]$/.test(s)&&!/^(sources?|references?|来源|参考)\b/i.test(s)),a=n.filter(s=>s.length>=30),r=a[a.length-1]??n[n.length-1]??e.replace(/[#*`>-]/g,"").replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t)}…`:r}function G0(){const e=D.useRef("work");return ln(t=>{const n=t.transform[2],a=e.current;return a==="work"?n<=.8&&(e.current=n<=.32?"glyph":"map"):a==="map"?n>=.9?e.current="work":n<=.32&&(e.current="glyph"):n>=.9?e.current="work":n>=.4&&(e.current="map"),e.current})}const WE={en:{name:"Rule-out / Rule-in",steps:[{id:"q",kind:"human",x:560,y:40,title:"Research question",instruction:"Type the question to differentiate: what phenomenon needs explaining?"},{id:"mechA",kind:"prompt",x:20,y:440,title:"Candidate: Mechanism A",instruction:`You advocate a low-level mechanistic account of the phenomenon. Be concrete and falsifiable.
|
|
292
292
|
From this lens, give the single best candidate explanation for the question above: name the mechanism, its testable predictions, and what evidence would rule it in or out.`},{id:"mechB",kind:"prompt",x:500,y:440,title:"Candidate: Mechanism B",instruction:`You advocate a higher-level / systems account. Name the mechanism and its boundary conditions.
|
|
293
293
|
From this lens, give the single best candidate explanation for the question above: name the mechanism, its testable predictions, and what evidence would rule it in or out.`},{id:"conf",kind:"prompt",x:980,y:440,title:"Candidate: Confound",instruction:`You argue the effect is an artifact or confound, not the phenomenon of interest.
|
|
@@ -298,13 +298,13 @@ For each candidate above, judge what evidence would rule it OUT and what would r
|
|
|
298
298
|
严格从这个视角,为上面的问题给出唯一最佳的候选解释:说清机制、可检验的预测,以及什么证据能确认或排除它。`},{id:"conf",kind:"prompt",x:980,y:440,title:"候选:混杂",instruction:`你主张这个效应是假象或混杂因素,而非目标现象。
|
|
299
299
|
严格从这个视角,为上面的问题给出唯一最佳的候选解释:说清疑似的混杂来源、可检验的预测,以及什么证据能确认或排除它。`},{id:"null",kind:"prompt",x:1460,y:440,title:"候选:零假设",instruction:`你主张这个效应可能不真实或被夸大,给出最强的收缩性论证。
|
|
300
300
|
严格从这个视角回答上面的问题:什么会让效应消失,以及什么证据能确认或排除这一解释。`},{id:"rev",kind:"prompt",x:560,y:920,title:"鉴别评审",instruction:`你是一位严谨的方法学家,正在对相互竞争的解释做鉴别诊断。
|
|
301
|
-
对上面每个候选,判断什么证据能将它排除(rule out)、什么能将它确认(rule in)。按可区分度排序:哪个检验最能把它们分开?`},{id:"syn",kind:"prompt",x:560,y:1360,title:"收敛",instruction:"综合上面的候选与区分性检验:先确认哪个解释、排除哪个,以及信息量最大的下一个实验是什么。"}],edges:[["q","mechA"],["q","mechB"],["q","conf"],["q","null"],["mechA","rev"],["mechB","rev"],["conf","rev"],["null","rev"],["rev","syn"]]}};function YV(e){const{name:t,steps:n,edges:a}=WE[e]??WE.en,r=n.map(o=>({id:`p-${o.id}`,type:"thought",position:{x:o.x,y:o.y},dragHandle:".drag-handle",data:{question:o.title,instruction:o.instruction,stepKind:o.kind,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:o.id==="q",isBranch:!1}})),s=a.map(([o,u])=>({id:`p-e-${o}-${u}`,source:`p-${o}`,target:`p-${u}`,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}));return{name:t,nodes:r,edges:s}}const oy="thoughtdag:projects",VE="thoughtdag",ws=e=>`thoughtdag:project:${e}`;async function Bm(e,t){const{projects:n,activeId:a}=sn.getState();if(t&&e===a){const r=n.filter(s=>s.id!==e&&!s.archived).sort((s,o)=>o.updatedAt-s.updatedAt);r.length>0?await Ui(r[0].id):await Tp("My Canvas")}sn.setState(r=>({projects:r.projects.map(s=>s.id===e?{...s,archived:t}:s)})),await zr()}async function KV(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e&&a.sourceSession?{...a,sourceSession:{...a.sourceSession,...t}}:a)})),await zr()}async function XV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e||!r.sourceSession)return r;const s=r.sourceSession;return s.sessionId===t?{...r,sourceSession:{...s,...n}}:{...r,sourceSession:{...s,chapters:s.chapters?.map(o=>o.sessionId===t?{...o,...n}:o),branches:s.branches?.map(o=>o.sessionId===t?{...o,...n}:o)}}})})),await zr()}async function QV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e)return r;const s=r.sourceSession??{sessionId:"",runner:"",importedCount:0,tailNodeId:""};return t==="chapter"?{...r,sourceSession:{...s,chapters:[...s.chapters??[],{sessionId:n.sessionId,runner:n.runner,importedCount:n.importedCount,tailNodeId:n.tailNodeId}]}}:{...r,sourceSession:{...s,branches:[...s.branches??[],{...n,anchorNodeId:n.anchorNodeId??""}]}}})})),await zr()}async function ZV(e,t){sn.setState(n=>({projects:n.projects.map(a=>{if(a.id!==e||!a.sourceSession)return a;const r=a.sourceSession,s=(r.chapters??[]).filter(d=>d.sessionId!==t),o=(r.branches??[]).filter(d=>d.sessionId!==t),u={...r,chapters:s.length?s:void 0,branches:o.length?o:void 0};return u.sessionId===t&&(u.sessionId="",u.runner="",u.importedCount=0,u.tailNodeId=""),!u.sessionId&&s.length===0&&o.length===0?{...a,sourceSession:void 0}:{...a,sourceSession:u}})})),await zr()}function ly(e){const t=e.sourceSession;return t?[t.sessionId,...(t.chapters??[]).map(n=>n.sessionId),...(t.branches??[]).map(n=>n.sessionId)].filter(Boolean):[]}async function O7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,instantiatedFrom:{name:t,at:new Date().toISOString()}}:a)})),await zr()}const sn=q0(()=>({projects:[],activeId:null,switching:!1}));async function zr(){const{projects:e,activeId:t}=sn.getState();await Lr(oy,{projects:e,activeId:t})}let GE=null;function D7(){return GE??=(async()=>{let e=await Yo(oy);if(!e||e.projects.length===0){const t=await Yo(VE),n=crypto.randomUUID(),a=Date.now();t&&await Lr(ws(n),t),e={projects:[{id:n,name:"My Canvas",createdAt:a,updatedAt:a}],activeId:n},await Lr(oy,e),t&&await yu(VE)}e.projects.some(t=>t.id===e.activeId)||(e.activeId=e.projects[0].id),sn.setState({projects:e.projects,activeId:e.activeId}),se.persist.setOptions({name:ws(e.activeId)}),await se.persist.rehydrate()})().catch(async e=>{console.error("[thoughtdag] project boot failed:",e),We("error",Te("toast.projectsLoadFailed")),se.persist.setOptions({name:ws("recovery")}),await se.persist.rehydrate()}),GE}let cy=!1;async function JV(){for(const t of Ds.values())t.abort();const e=Date.now()+1e3;for(;Ds.size>0&&Date.now()<e;)await new Promise(t=>setTimeout(t,30));await new Promise(t=>setTimeout(t,0))}const R7=[];async function Ui(e){for(const r of R7)await r().catch(()=>{});const{activeId:t,switching:n,projects:a}=sn.getState();if(!(n||e===t||!a.some(r=>r.id===e))){sn.setState({switching:!0});try{await JV(),await Iq(),sW(),cy=!0,se.persist.setOptions({name:ws(e)}),await se.persist.rehydrate(),se.setState({selectedNodeId:null,selectedNodeIds:[]}),sn.setState(r=>({activeId:e,projects:r.projects.map(s=>s.id===e&&s.archived?{...s,archived:!1}:s)})),await zr()}finally{cy=!1,sn.setState({switching:!1})}}}async function Tp(e="Untitled",t="chat"){const n=crypto.randomUUID(),a=Date.now();return sn.setState(r=>({projects:[...r.projects,{id:n,name:e,createdAt:a,updatedAt:a,kind:t}]})),await zr(),await Ui(n),n}async function W2(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentCwd:t}:a)})),await zr()}async function eG(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentGuard:t}:a)})),await zr()}async function j7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,name:t}:a)})),await zr()}async function L7(e){const{projects:t,activeId:n}=sn.getState();if(e===n){const a=t.filter(r=>r.id!==e);a.length>0?await Ui(a[0].id):await Tp("My Canvas")}await yu(ws(e)),sn.setState(a=>({projects:a.projects.filter(r=>r.id!==e)})),await zr(),ft(()=>import("./canvas-record-
|
|
301
|
+
对上面每个候选,判断什么证据能将它排除(rule out)、什么能将它确认(rule in)。按可区分度排序:哪个检验最能把它们分开?`},{id:"syn",kind:"prompt",x:560,y:1360,title:"收敛",instruction:"综合上面的候选与区分性检验:先确认哪个解释、排除哪个,以及信息量最大的下一个实验是什么。"}],edges:[["q","mechA"],["q","mechB"],["q","conf"],["q","null"],["mechA","rev"],["mechB","rev"],["conf","rev"],["null","rev"],["rev","syn"]]}};function YV(e){const{name:t,steps:n,edges:a}=WE[e]??WE.en,r=n.map(o=>({id:`p-${o.id}`,type:"thought",position:{x:o.x,y:o.y},dragHandle:".drag-handle",data:{question:o.title,instruction:o.instruction,stepKind:o.kind,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:o.id==="q",isBranch:!1}})),s=a.map(([o,u])=>({id:`p-e-${o}-${u}`,source:`p-${o}`,target:`p-${u}`,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}));return{name:t,nodes:r,edges:s}}const oy="thoughtdag:projects",VE="thoughtdag",ws=e=>`thoughtdag:project:${e}`;async function Bm(e,t){const{projects:n,activeId:a}=sn.getState();if(t&&e===a){const r=n.filter(s=>s.id!==e&&!s.archived).sort((s,o)=>o.updatedAt-s.updatedAt);r.length>0?await Ui(r[0].id):await Tp("My Canvas")}sn.setState(r=>({projects:r.projects.map(s=>s.id===e?{...s,archived:t}:s)})),await zr()}async function KV(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e&&a.sourceSession?{...a,sourceSession:{...a.sourceSession,...t}}:a)})),await zr()}async function XV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e||!r.sourceSession)return r;const s=r.sourceSession;return s.sessionId===t?{...r,sourceSession:{...s,...n}}:{...r,sourceSession:{...s,chapters:s.chapters?.map(o=>o.sessionId===t?{...o,...n}:o),branches:s.branches?.map(o=>o.sessionId===t?{...o,...n}:o)}}})})),await zr()}async function QV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e)return r;const s=r.sourceSession??{sessionId:"",runner:"",importedCount:0,tailNodeId:""};return t==="chapter"?{...r,sourceSession:{...s,chapters:[...s.chapters??[],{sessionId:n.sessionId,runner:n.runner,importedCount:n.importedCount,tailNodeId:n.tailNodeId}]}}:{...r,sourceSession:{...s,branches:[...s.branches??[],{...n,anchorNodeId:n.anchorNodeId??""}]}}})})),await zr()}async function ZV(e,t){sn.setState(n=>({projects:n.projects.map(a=>{if(a.id!==e||!a.sourceSession)return a;const r=a.sourceSession,s=(r.chapters??[]).filter(d=>d.sessionId!==t),o=(r.branches??[]).filter(d=>d.sessionId!==t),u={...r,chapters:s.length?s:void 0,branches:o.length?o:void 0};return u.sessionId===t&&(u.sessionId="",u.runner="",u.importedCount=0,u.tailNodeId=""),!u.sessionId&&s.length===0&&o.length===0?{...a,sourceSession:void 0}:{...a,sourceSession:u}})})),await zr()}function ly(e){const t=e.sourceSession;return t?[t.sessionId,...(t.chapters??[]).map(n=>n.sessionId),...(t.branches??[]).map(n=>n.sessionId)].filter(Boolean):[]}async function O7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,instantiatedFrom:{name:t,at:new Date().toISOString()}}:a)})),await zr()}const sn=q0(()=>({projects:[],activeId:null,switching:!1}));async function zr(){const{projects:e,activeId:t}=sn.getState();await Lr(oy,{projects:e,activeId:t})}let GE=null;function D7(){return GE??=(async()=>{let e=await Yo(oy);if(!e||e.projects.length===0){const t=await Yo(VE),n=crypto.randomUUID(),a=Date.now();t&&await Lr(ws(n),t),e={projects:[{id:n,name:"My Canvas",createdAt:a,updatedAt:a}],activeId:n},await Lr(oy,e),t&&await yu(VE)}e.projects.some(t=>t.id===e.activeId)||(e.activeId=e.projects[0].id),sn.setState({projects:e.projects,activeId:e.activeId}),se.persist.setOptions({name:ws(e.activeId)}),await se.persist.rehydrate()})().catch(async e=>{console.error("[thoughtdag] project boot failed:",e),We("error",Te("toast.projectsLoadFailed")),se.persist.setOptions({name:ws("recovery")}),await se.persist.rehydrate()}),GE}let cy=!1;async function JV(){for(const t of Ds.values())t.abort();const e=Date.now()+1e3;for(;Ds.size>0&&Date.now()<e;)await new Promise(t=>setTimeout(t,30));await new Promise(t=>setTimeout(t,0))}const R7=[];async function Ui(e){for(const r of R7)await r().catch(()=>{});const{activeId:t,switching:n,projects:a}=sn.getState();if(!(n||e===t||!a.some(r=>r.id===e))){sn.setState({switching:!0});try{await JV(),await Iq(),sW(),cy=!0,se.persist.setOptions({name:ws(e)}),await se.persist.rehydrate(),se.setState({selectedNodeId:null,selectedNodeIds:[]}),sn.setState(r=>({activeId:e,projects:r.projects.map(s=>s.id===e&&s.archived?{...s,archived:!1}:s)})),await zr()}finally{cy=!1,sn.setState({switching:!1})}}}async function Tp(e="Untitled",t="chat"){const n=crypto.randomUUID(),a=Date.now();return sn.setState(r=>({projects:[...r.projects,{id:n,name:e,createdAt:a,updatedAt:a,kind:t}]})),await zr(),await Ui(n),n}async function W2(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentCwd:t}:a)})),await zr()}async function eG(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentGuard:t}:a)})),await zr()}async function j7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,name:t}:a)})),await zr()}async function L7(e){const{projects:t,activeId:n}=sn.getState();if(e===n){const a=t.filter(r=>r.id!==e);a.length>0?await Ui(a[0].id):await Tp("My Canvas")}await yu(ws(e)),sn.setState(a=>({projects:a.projects.filter(r=>r.id!==e)})),await zr(),ft(()=>import("./canvas-record-BlrHolpM.js"),[]).then(a=>a.removeCanvasRecord(e)).catch(()=>{})}async function wu(e,t,n="chat",a){const r=Date.now();sn.setState(s=>({projects:[...s.projects,{id:e,name:t,createdAt:r,updatedAt:r,kind:n,...a}]})),await zr(),await Ui(e)}async function tG(e){const{name:t,nodes:n,edges:a}=YV(e),r=crypto.randomUUID();await Lr(ws(r),JSON.stringify({state:{nodes:n,edges:a},version:1})),await wu(r,t,"paradigm")}let Cx=null;se.subscribe((e,t)=>{cy||e.nodes===t.nodes&&e.edges===t.edges||(Cx&&clearTimeout(Cx),Cx=setTimeout(()=>{const{activeId:n}=sn.getState();if(!n)return;const a=[...new Set(se.getState().nodes.map(r=>r.data.importSource?.sessionId).filter(r=>!!r))];sn.setState(r=>({projects:r.projects.map(s=>s.id===n?{...s,updatedAt:Date.now(),provenanceSessions:a}:s)})),zr()},1e3))});const Sa=Object.freeze(Object.defineProperty({__proto__:null,adoptImportedProject:wu,beforeSwitchHooks:R7,bootProjects:D7,createBuiltinParadigm:tG,createProject:Tp,deleteProject:L7,markInstantiatedFrom:O7,patchLedgerEntry:XV,projectStorageKey:ws,registerLedgerEntry:QV,removeLedgerEntry:ZV,renameProject:j7,setProjectAgentCwd:W2,setProjectAgentGuard:eG,setProjectArchived:Bm,subscribedSessionIds:ly,switchProject:Ui,updateSourceSession:KV,useProjects:sn},Symbol.toStringTag,{value:"Module"}));function P7(e){if(Array.isArray(e)&&e.length>0){const n=e[0];if(n&&typeof n=="object"&&"mapping"in n)return"chatgpt";if(n&&typeof n=="object"&&"chat_messages"in n)return"claude"}const t=e;return t&&typeof t=="object"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)?"thoughtdag":"unknown"}function z7(e,t,n){return{id:Tn(),type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:e,response:t,responses:[t],responseIndex:0,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:Math.ceil((e+t).length/4),highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:n,isBranch:!1}}}function B7(e,t){return{id:`edge-${e}-${t}`,source:e,target:t,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}}function H7(e){const t=e.message?.content?.parts;return Array.isArray(t)?t.filter(n=>typeof n=="string").join(`
|
|
302
302
|
`).trim():""}function nG(e){const t=[],n=[],a=Object.values(e).filter(s=>!s.parent||!e[s.parent]),r=(s,o,u)=>{const d=e[s];if(!d)return;const h=d.message?.author?.role,m=H7(d);let p=o,x=u;if(h==="user"&&m)p=m;else if(h==="assistant"&&m){if(p!==null){const b=z7(p,m,u===null);t.push(b),u&&n.push(B7(u,b.id)),x=b.id,p=null}else if(x){const b=t.find(y=>y.id===x);b&&(b.data.response+=`
|
|
303
303
|
|
|
304
304
|
`+m,b.data.responses=[b.data.response])}}for(const b of d.children??[])r(b,p,x)};for(const s of a)r(s.id,null,null);return{nodes:xr(t,n),edges:n}}function F7(e){return typeof e.text=="string"&&e.text.trim()?e.text.trim():Array.isArray(e.content)?e.content.filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
305
305
|
`).trim():""}function aG(e){const t=[],n=[];let a=null,r=null;for(const s of e){const o=F7(s);if(o){if(s.sender==="human")a=o;else if(s.sender==="assistant"){if(a!==null){const u=z7(a,o,r===null);t.push(u),r&&n.push(B7(r,u.id)),r=u.id,a=null}else if(r){const u=t.find(d=>d.id===r);u&&(u.data.response+=`
|
|
306
306
|
|
|
307
|
-
`+o,u.data.responses=[u.data.response])}}}}return{nodes:xr(t,n),edges:n}}function rG(e){const t=P7(e),n=[];if(t==="chatgpt")for(const a of e){const r=a.mapping??{},s=Object.values(r).filter(o=>["user","assistant"].includes(o.message?.author?.role??"")&&H7(o)).length;s!==0&&n.push({title:a.title||"Untitled",messageCount:s,source:"chatgpt",build:()=>nG(r)})}else if(t==="claude")for(const a of e){const r=a.chat_messages??[],s=r.filter(o=>F7(o)).length;s!==0&&n.push({title:a.name||"Untitled",messageCount:s,source:"claude",build:()=>aG(r)})}return n}function sG(e){return e.some(t=>t.data.stepKind==="human"&&!t.data.question||t.data.stepKind==="prompt"&&(t.data.isLoading||!t.data.response&&!t.data.generationFailed))}function iG(e){const t=e;return!!t&&typeof t=="object"&&t.kind==="thoughtdag-paradigm"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}const oG=()=>({question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1});function lG(e,t){const n=new Map,a=e.map(u=>{const d=Tn();n.set(u.id,d);const h=u.data.stepKind??"prompt",m=(u.data.instruction?.trim()||u.data.question||"").trim(),p={...oG(),question:m,rolePrompt:u.data.rolePrompt||void 0,roleMode:u.data.rolePrompt?"reset":"inherit"};return h==="human"&&(p.stepKind="human",p.question="",p.instruction=u.data.instruction?.trim()||void 0,p.rolePrompt=void 0,p.roleMode="inherit"),h==="prompt"&&(p.stepKind="prompt",p.webSearch=u.data.webSearch,p.scholarSearch=u.data.scholarSearch,p.autoRerun=u.data.autoRerun,p.autoRerunRounds=u.data.autoRerunRounds),(h==="note"||h==="file"||h==="link"||h==="frame")&&(p.stepKind=h,p.question=u.data.question||"",p.attachments=u.data.attachments??[],p.tokenCount=u.data.tokenCount??0,p.linkUrl=u.data.linkUrl,p.linkTitle=u.data.linkTitle,p.linkFetchedAt=u.data.linkFetchedAt,p.frameColor=u.data.frameColor),h==="review"&&(p.isEvaluator=!0,p.autoRerun=!0,p.autoRerunRounds=u.data.autoRerunRounds,p.rolePrompt||(p.roleMode="inherit")),h==="fanout"&&(p.stepKind="fanout",p.fanoutRoles=u.data.fanoutRoles),{id:d,type:"thought",position:{...u.position},width:u.width,height:u.height,zIndex:u.zIndex,dragHandle:".drag-handle",data:p}}),r=new Set(e.filter(u=>(u.data.stepKind??"step")==="review").map(u=>n.get(u.id))),s=t.filter(u=>n.has(u.source)&&n.has(u.target)).map(u=>{const d=n.get(u.source),h=n.get(u.target);return r.has(h)?{id:`watch-${d}-${h}`,source:d,target:h,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.watch,strokeWidth:2,strokeDasharray:"4 4"},animated:!0,markerEnd:{type:"arrowclosed",color:it.watch,width:18,height:18},data:{isCrossLink:!0,isWatch:!0,followsTip:!0}}:{id:`edge-${d}-${h}`,source:d,target:h,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}),o=new Set(s.map(u=>u.target));for(const u of a)o.has(u.id)||(u.data.isRoot=!0);return{nodes:xr(a,s),edges:s}}const U7=1,V2=1;function Np(e){return e.replace(/[\\/:*?"<>|]/g,"_").trim()||"canvas"}function Y0(e,t,n){const a=URL.createObjectURL(new Blob([t],{type:n}));Object.assign(document.createElement("a"),{href:a,download:e}).click(),URL.revokeObjectURL(a)}async function G2(e){await navigator.clipboard.writeText(e),We("success",Te("toast.copied"))}function qi(){const{projects:e,activeId:t}=sn.getState();return e.find(n=>n.id===t)?.name??"canvas"}async function uy(e){const{nodes:t}=se.getState(),{confirmIfSensitive:n}=await ft(async()=>{const{confirmIfSensitive:p}=await import("./sensitive-scan-
|
|
307
|
+
`+o,u.data.responses=[u.data.response])}}}}return{nodes:xr(t,n),edges:n}}function rG(e){const t=P7(e),n=[];if(t==="chatgpt")for(const a of e){const r=a.mapping??{},s=Object.values(r).filter(o=>["user","assistant"].includes(o.message?.author?.role??"")&&H7(o)).length;s!==0&&n.push({title:a.title||"Untitled",messageCount:s,source:"chatgpt",build:()=>nG(r)})}else if(t==="claude")for(const a of e){const r=a.chat_messages??[],s=r.filter(o=>F7(o)).length;s!==0&&n.push({title:a.name||"Untitled",messageCount:s,source:"claude",build:()=>aG(r)})}return n}function sG(e){return e.some(t=>t.data.stepKind==="human"&&!t.data.question||t.data.stepKind==="prompt"&&(t.data.isLoading||!t.data.response&&!t.data.generationFailed))}function iG(e){const t=e;return!!t&&typeof t=="object"&&t.kind==="thoughtdag-paradigm"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}const oG=()=>({question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1});function lG(e,t){const n=new Map,a=e.map(u=>{const d=Tn();n.set(u.id,d);const h=u.data.stepKind??"prompt",m=(u.data.instruction?.trim()||u.data.question||"").trim(),p={...oG(),question:m,rolePrompt:u.data.rolePrompt||void 0,roleMode:u.data.rolePrompt?"reset":"inherit"};return h==="human"&&(p.stepKind="human",p.question="",p.instruction=u.data.instruction?.trim()||void 0,p.rolePrompt=void 0,p.roleMode="inherit"),h==="prompt"&&(p.stepKind="prompt",p.webSearch=u.data.webSearch,p.scholarSearch=u.data.scholarSearch,p.autoRerun=u.data.autoRerun,p.autoRerunRounds=u.data.autoRerunRounds),(h==="note"||h==="file"||h==="link"||h==="frame")&&(p.stepKind=h,p.question=u.data.question||"",p.attachments=u.data.attachments??[],p.tokenCount=u.data.tokenCount??0,p.linkUrl=u.data.linkUrl,p.linkTitle=u.data.linkTitle,p.linkFetchedAt=u.data.linkFetchedAt,p.frameColor=u.data.frameColor),h==="review"&&(p.isEvaluator=!0,p.autoRerun=!0,p.autoRerunRounds=u.data.autoRerunRounds,p.rolePrompt||(p.roleMode="inherit")),h==="fanout"&&(p.stepKind="fanout",p.fanoutRoles=u.data.fanoutRoles),{id:d,type:"thought",position:{...u.position},width:u.width,height:u.height,zIndex:u.zIndex,dragHandle:".drag-handle",data:p}}),r=new Set(e.filter(u=>(u.data.stepKind??"step")==="review").map(u=>n.get(u.id))),s=t.filter(u=>n.has(u.source)&&n.has(u.target)).map(u=>{const d=n.get(u.source),h=n.get(u.target);return r.has(h)?{id:`watch-${d}-${h}`,source:d,target:h,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.watch,strokeWidth:2,strokeDasharray:"4 4"},animated:!0,markerEnd:{type:"arrowclosed",color:it.watch,width:18,height:18},data:{isCrossLink:!0,isWatch:!0,followsTip:!0}}:{id:`edge-${d}-${h}`,source:d,target:h,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}),o=new Set(s.map(u=>u.target));for(const u of a)o.has(u.id)||(u.data.isRoot=!0);return{nodes:xr(a,s),edges:s}}const U7=1,V2=1;function Np(e){return e.replace(/[\\/:*?"<>|]/g,"_").trim()||"canvas"}function Y0(e,t,n){const a=URL.createObjectURL(new Blob([t],{type:n}));Object.assign(document.createElement("a"),{href:a,download:e}).click(),URL.revokeObjectURL(a)}async function G2(e){await navigator.clipboard.writeText(e),We("success",Te("toast.copied"))}function qi(){const{projects:e,activeId:t}=sn.getState();return e.find(n=>n.id===t)?.name??"canvas"}async function uy(e){const{nodes:t}=se.getState(),{confirmIfSensitive:n}=await ft(async()=>{const{confirmIfSensitive:p}=await import("./sensitive-scan-CB-wz7Ro.js");return{confirmIfSensitive:p}},[]);if(!await n(t))return;localStorage.setItem("thoughtdag.lastBackupAt",String(Date.now()));const{nodes:a,edges:r,events:s}=se.getState(),o=await v2(a),{projects:u,activeId:d}=sn.getState(),h=qi(),m=JSON.stringify({version:U7,name:h,projectId:d,exportedAt:new Date().toISOString(),instantiatedFrom:u.find(p=>p.id===d)?.instantiatedFrom,...e?.sharedReadonly?{sharedReadonly:!0}:{},nodes:Xo(o),edges:r,events:s});Y0(`${Np(h)}.thoughtdag.json`,m,"application/json"),We("success",ve(Te("toast.exported"),{name:h}))}function cG(){const{nodes:e,edges:t}=se.getState(),n=qi(),a=JSON.stringify({kind:"thoughtdag-paradigm",version:1,name:n,nodes:Xo(e),edges:t});Y0(`${Np(n)}.paradigm.json`,a,"application/json"),We("success",ve(Te("toast.exported"),{name:n}))}async function uG(e){const t=await e.text();let n;try{n=JSON.parse(t)}catch{const{anyRunnerSessionConversation:r}=await ft(async()=>{const{anyRunnerSessionConversation:o}=await import("./index-goc_KBNk.js");return{anyRunnerSessionConversation:o}},[]),s=await r(t);return s?{kind:"chat",conversations:[s]}:(We("error",Te("toast.importFailedJson")),{kind:"error"})}if(iG(n)){const r=crypto.randomUUID(),s=await vp(await q7(n.nodes));return await Lr(ws(r),JSON.stringify({state:{nodes:s,edges:n.edges},version:V2})),await wu(r,n.name||"Paradigm","paradigm"),We("success",ve(Te("toast.imported"),{name:n.name,n:n.nodes.length})),{kind:"own",ok:!0}}if(n?.format==="thoughtdag-manifest")return We("error",Te("toast.importManifest"),9e3),{kind:"error"};const a=P7(n);if(a==="chatgpt"||a==="claude"){const r=rG(n);return r.length===0?(We("error",Te("toast.importNoConversations")),{kind:"error"}):{kind:"chat",conversations:r}}return{kind:"own",ok:await fG(e,n)}}function dG(e){return e.every(t=>{const n=t;return!!n&&typeof n.id=="string"&&!!n.position&&typeof n.position.x=="number"&&typeof n.position.y=="number"&&!!n.data&&typeof n.data=="object"})}async function hG(e){let t=null,n=0;for(const a of e){const{nodes:r,edges:s}=a.build();if(r.length===0)continue;if(t===null){const{useUiStore:u}=await ft(async()=>{const{useUiStore:d}=await Promise.resolve().then(()=>uu);return{useUiStore:d}},void 0);u.getState().setArrivalFocusNodeId(r[r.length-1].id)}const o=crypto.randomUUID();await Lr(ws(o),JSON.stringify({state:{nodes:Xo(r),edges:s},version:V2})),await wu(o,a.title.slice(0,60)),t??=o,n+=r.length}t&&We("success",ve(Te("toast.importedChats"),{n:e.length,m:n}))}async function q7(e){const t=await dr();if(!t||t.models.length===0)return e;const n=new Set,a=new Set,r=e.map(s=>{const o=s.data?.model;if(!o)return s;const u=C7(o,t.models);return u===o?s:u?(n.add(`${o} → ${u}`),{...s,data:{...s.data,model:u}}):(a.add(o),s)});return n.size&&We("info",ve(Te("import.modelsRemapped"),{list:[...n].join(",")}),9e3),a.size&&We("info",ve(Te("import.modelsMissing"),{list:[...a].join(",")}),1e4),r}async function fG(e,t){let n;try{n=t??JSON.parse(await e.text())}catch{return We("error",Te("toast.importFailedJson")),!1}if(!Array.isArray(n.nodes)||!Array.isArray(n.edges))return We("error",Te("toast.importFailedMissing")),!1;if(n.nodes.length>0&&!dG(n.nodes))return We("error",Te("toast.importFailedShape"),9e3),!1;if(n.sharedReadonly&&!await ai({title:Te("import.readonlyTitle"),message:Te("import.readonlyConfirm"),confirmLabel:Te("common.confirm")}))return!1;if(n.sourceSession?.sessionId){const{useProjects:o,switchProject:u}=await ft(async()=>{const{useProjects:h,switchProject:m}=await Promise.resolve().then(()=>Sa);return{useProjects:h,switchProject:m}},void 0),d=o.getState().projects.find(h=>h.sourceSession?.sessionId===n.sourceSession.sessionId);if(d)return await u(d.id),We("info",ve(Te("toast.importAlreadySubscribed"),{name:d.name}),9e3),!0}const a=crypto.randomUUID(),r=await vp(await q7(n.nodes));await Lr(ws(a),JSON.stringify({state:{nodes:Xo(r),edges:n.edges,...Array.isArray(n.events)?{events:n.events}:{}},version:V2}));const s=n.name?.trim()||e.name.replace(/\.thoughtdag\.json$|\.json$/i,"")||"Imported canvas";return await wu(a,s,"chat",{instantiatedFrom:n.instantiatedFrom,sourceSession:n.sourceSession}),We("success",ve(Te("toast.imported"),{name:s,n:n.nodes.length})),!0}function mG(){const{events:e}=se.getState();if(e.length===0)return;const t=r=>`"${r.replace(/"/g,'""')}"`,a=["t,op,id,detail",...e.map(r=>[r.t,r.op,r.id??"",r.d?t(JSON.stringify(r.d)):""].join(","))].join(`
|
|
308
308
|
`);Y0(`${Np(qi())}.events.csv`,a,"text/csv"),We("success",ve(Te("toast.exported"),{name:qi()}))}function pG(e){const t=[`## Q: ${e.data.question}`,""],n=e.data.attachments||[];return n.length>0&&t.push(`> ${Te("export.attachmentsLabel")} ${n.map(a=>a.name).join(", ")}`,""),e.data.branchContext&&t.push(`> Exploring from: "${e.data.branchContext.slice(0,120)}"`,""),t.push(e.data.response||"_(no response)_",""),t.join(`
|
|
309
309
|
`)}function $7(e,t){const n=e.reduce((a,r)=>a+Nn(r.data.question+r.data.response),0);return[`# ${qi()}`,"",`> ${t} · exported ${new Date().toISOString().slice(0,10)} · ${e.length} nodes · ~${n} tok`,"",e.map(pG).join(`
|
|
310
310
|
---
|
|
@@ -613,7 +613,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Ne=st,we=H),ce===void
|
|
|
613
613
|
$$
|
|
614
614
|
${s.trim()}
|
|
615
615
|
$$
|
|
616
|
-
`).replace(/\\\((.+?)\\\)/g,(r,s)=>`$${s.trim()}$`)).join("")}const foe={...r0,clobberPrefix:"",tagNames:[...r0.tagNames??[],"mark"],attributes:{...r0.attributes,code:[["className",/^language-./,"math-inline","math-display"]]}},moe=[eoe,[uoe,foe],Oae,Xae];function poe(e){const t=D.useRef(null),[n,a]=D.useState(!1),r=St();return l.jsxs("div",{className:"relative group/pre",children:[l.jsx("pre",{...e,ref:t}),l.jsx("button",{onClick:s=>{s.stopPropagation(),navigator.clipboard.writeText(t.current?.innerText??""),a(!0),setTimeout(()=>a(!1),1600)},title:r("common.copyCode"),className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-md bg-card/90 border border-line text-ink-faint hover:text-accent flex items-center justify-center opacity-0 group-hover/pre:opacity-100 transition-opacity nodrag nopan",children:n?l.jsx(es,{size:12,strokeWidth:2,className:"text-green-600"}):l.jsx(to,{size:12,strokeWidth:1.75})})]})}function goe(e){return l.jsx("div",{className:"overflow-x-auto",children:l.jsx("table",{...e})})}const Hv=D.createContext(void 0);function xoe(e){const t=oM(e.href,D.useContext(Hv));return t?l.jsx("a",{...e,title:t,"data-local-path":t,onClick:n=>{n.preventDefault(),n.stopPropagation(),Ly(t)}}):l.jsx("a",{...e,target:"_blank",rel:"noreferrer noopener",onClick:n=>n.stopPropagation()})}function boe({path:e,alt:t}){const[n,a]=D.useState(null),[r,s]=D.useState(()=>!window.desktopLocal);return D.useEffect(()=>{const o=window.desktopLocal;if(!o)return;let u=!0;return o.image(e).then(d=>{u&&(d?a(d):s(!0))}).catch(()=>{u&&s(!0)}),()=>{u=!1}},[e]),n?l.jsx("img",{src:n,alt:t??sT(e),title:e,className:"cursor-zoom-in nopan",onClick:o=>{o.stopPropagation(),Ly(e)}}):l.jsxs("span",{className:`inline-flex items-center gap-1 text-xs border border-line rounded-md px-1.5 py-0.5 font-mono nopan cursor-pointer ${r?"text-ink-faint":"text-ink-muted"}`,title:e,"data-local-image":e,onClick:o=>{o.stopPropagation(),Ly(e)},children:["🖼 ",sT(e)]})}function yoe(e){const t=oM(e.src,D.useContext(Hv));return t?l.jsx(boe,{path:t,alt:e.alt}):l.jsx("img",{...e})}const voe={pre:poe,table:goe,a:xoe,img:yoe},Ji=D.memo(function({children:t,base:n}){return l.jsx(Hv.Provider,{value:n,children:l.jsx(EQ,{remarkPlugins:doe,rehypePlugins:moe,components:voe,children:hoe(t)})})}),woe='<mark class="
|
|
616
|
+
`).replace(/\\\((.+?)\\\)/g,(r,s)=>`$${s.trim()}$`)).join("")}const foe={...r0,clobberPrefix:"",tagNames:[...r0.tagNames??[],"mark"],attributes:{...r0.attributes,code:[["className",/^language-./,"math-inline","math-display"]],mark:[["className","highlight-mark","explore-mark"],"dataExploreTarget"]}},moe=[eoe,[uoe,foe],Oae,Xae];function poe(e){const t=D.useRef(null),[n,a]=D.useState(!1),r=St();return l.jsxs("div",{className:"relative group/pre",children:[l.jsx("pre",{...e,ref:t}),l.jsx("button",{onClick:s=>{s.stopPropagation(),navigator.clipboard.writeText(t.current?.innerText??""),a(!0),setTimeout(()=>a(!1),1600)},title:r("common.copyCode"),className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-md bg-card/90 border border-line text-ink-faint hover:text-accent flex items-center justify-center opacity-0 group-hover/pre:opacity-100 transition-opacity nodrag nopan",children:n?l.jsx(es,{size:12,strokeWidth:2,className:"text-green-600"}):l.jsx(to,{size:12,strokeWidth:1.75})})]})}function goe(e){return l.jsx("div",{className:"overflow-x-auto",children:l.jsx("table",{...e})})}const Hv=D.createContext(void 0);function xoe(e){const t=oM(e.href,D.useContext(Hv));return t?l.jsx("a",{...e,title:t,"data-local-path":t,onClick:n=>{n.preventDefault(),n.stopPropagation(),Ly(t)}}):l.jsx("a",{...e,target:"_blank",rel:"noreferrer noopener",onClick:n=>n.stopPropagation()})}function boe({path:e,alt:t}){const[n,a]=D.useState(null),[r,s]=D.useState(()=>!window.desktopLocal);return D.useEffect(()=>{const o=window.desktopLocal;if(!o)return;let u=!0;return o.image(e).then(d=>{u&&(d?a(d):s(!0))}).catch(()=>{u&&s(!0)}),()=>{u=!1}},[e]),n?l.jsx("img",{src:n,alt:t??sT(e),title:e,className:"cursor-zoom-in nopan",onClick:o=>{o.stopPropagation(),Ly(e)}}):l.jsxs("span",{className:`inline-flex items-center gap-1 text-xs border border-line rounded-md px-1.5 py-0.5 font-mono nopan cursor-pointer ${r?"text-ink-faint":"text-ink-muted"}`,title:e,"data-local-image":e,onClick:o=>{o.stopPropagation(),Ly(e)},children:["🖼 ",sT(e)]})}function yoe(e){const t=oM(e.src,D.useContext(Hv));return t?l.jsx(boe,{path:t,alt:e.alt}):l.jsx("img",{...e})}const voe={pre:poe,table:goe,a:xoe,img:yoe},Ji=D.memo(function({children:t,base:n}){return l.jsx(Hv.Provider,{value:n,children:l.jsx(EQ,{remarkPlugins:doe,rehypePlugins:moe,components:voe,children:hoe(t)})})}),woe='<mark class="highlight-mark">';function koe(e,t){const n=e.match(/^(\s*(?:(?:\d{1,3}[.)]|[-*+>]|#{1,6})\s+)*)(.*)$/),a=n?.[1]??"",r=n?.[2]??e;return r.trim()?r.includes("|")?/^[\s|:-]+$/.test(r)?e:a+r.split("|").map(s=>s.trim()?s.replace(/^(\s*)([\s\S]*?)(\s*)$/,(o,u,d,h)=>`${u}${t}${d}</mark>${h}`):s).join("|"):`${a}${t}${r}</mark>`:e}function Eoe(e,t){return!e.includes(`
|
|
617
617
|
`)&&!e.includes("|")?`${t}${e}</mark>`:e.split(`
|
|
618
618
|
`).map(n=>koe(n,t)).join(`
|
|
619
619
|
`)}const iT=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),I0=D.memo(function({content:t,highlights:n,exploreMarks:a}){const r=[],s=(d,h,m)=>{const p=w2(d);if(p)for(const x of t.matchAll(p))x[0]&&r.push({start:x.index,end:x.index+x[0].length,open:h,prio:m})};for(const d of n)s(d,woe,0);for(const d of a??[])s(d.text,`<mark class="explore-mark" data-explore-target="${iT(d.nodeId)}" title="${iT(d.title)}">`,1);r.sort((d,h)=>d.prio-h.prio||d.start-h.start);const o=[];for(const d of r)o.some(h=>d.start<h.end&&h.start<d.end)||o.push(d);o.sort((d,h)=>h.start-d.start);let u=t;for(const d of o)u=u.slice(0,d.start)+Eoe(u.slice(d.start,d.end),d.open)+u.slice(d.end);return l.jsx(Ji,{children:u})},Soe);function Soe(e,t){if(e.content!==t.content||e.highlights.size!==t.highlights.size)return!1;for(const r of e.highlights)if(!t.highlights.has(r))return!1;const n=e.exploreMarks??[],a=t.exploreMarks??[];return n.length!==a.length?!1:n.every((r,s)=>r.text===a[s].text&&r.nodeId===a[s].nodeId&&r.title===a[s].title)}function Toe(e,t){return t==="zh"?e.promptZh:e.prompt}const Noe=[{id:"reviewer",nameEn:"Paper Reviewer",nameZh:"论文审稿人",prompt:"You are a rigorous peer reviewer for a top-tier venue. Critique the reasoning presented: identify unsupported claims, methodological weaknesses, missing related work, and overstatements. Be specific and constructive; number your points.",promptZh:"你是一位顶级期刊/会议的严格审稿人。批评所呈现的推理:指出缺乏支撑的论断、方法学弱点、遗漏的相关工作和夸大之处。具体且有建设性;逐条编号。"},{id:"skeptic",nameEn:"Skeptic",nameZh:"质疑者",prompt:"You are a professional skeptic. Attack the strongest version of the argument presented: find counterexamples, hidden assumptions, and alternative explanations. Steelman first, then strike.",promptZh:"你是一位专业的质疑者。攻击论证的最强形式:寻找反例、隐藏假设和替代解释。先把对方论证补强到最好(steelman),再出手。"},{id:"statistician",nameEn:"Statistical Consultant",nameZh:"统计顾问",prompt:"You are a statistical consultant. Scrutinize any quantitative reasoning: sample sizes, confounds, multiple comparisons, effect sizes vs. significance, causal claims from correlational data. Flag what would not survive review.",promptZh:"你是一位统计顾问。审视所有定量推理:样本量、混杂因素、多重比较、效应量与显著性之分、从相关数据得出的因果论断。标出过不了评审的地方。"},{id:"code-reviewer",nameEn:"Code Reviewer",nameZh:"Code Reviewer",prompt:"You are a senior engineer reviewing code and technical designs. Look for correctness bugs, edge cases, unnecessary complexity, and maintainability issues. Suggest concrete improvements with short code sketches where useful.",promptZh:"你是一位评审代码与技术方案的资深工程师。寻找正确性缺陷、边界情况、不必要的复杂度和可维护性问题。给出具体改进建议,必要时附简短代码示意。"},{id:"literature",nameEn:"Literature Scout",nameZh:"文献侦察",prompt:"You are a literature scout. Ground the discussion in published work: use the scholarly search tools to find the most relevant papers, cite them as [n], summarize what each contributes, and point out where the current reasoning agrees with or contradicts the literature.",promptZh:"你是一位文献侦察员。把讨论锚定到已发表的研究:使用学术检索工具找到最相关的论文,以 [n] 引用,概述每篇的贡献,并指出当前推理与文献一致或冲突之处。"},{id:"tutor",nameEn:"Socratic Tutor",nameZh:"苏格拉底导师",prompt:"You are a Socratic tutor. Instead of giving answers, probe the reasoning with pointed questions that expose gaps in understanding, then offer one small hint.",promptZh:"你是一位苏格拉底式导师。不直接给答案,而是用尖锐的问题探查推理、暴露理解上的缺口,然后只给一个小提示。"}];function qp(e,t){const n=new Set(t?.hidden??[]);return[...Noe.filter(r=>!n.has(r.id)).map(r=>({id:r.id,name:e==="zh"?r.nameZh:r.nameEn,prompt:Toe(r,e),builtin:!0})),...(t?.custom??[]).map(r=>({...r,builtin:!1}))]}function lM({parentId:e,initialQuestion:t,initialRoles:n,onClose:a}){const r=se(S=>S.fanOut),s=St(),o=Da(S=>S.lang),[u,d]=D.useState("once"),[h,m]=D.useState(1),[p,x]=D.useState(t),[b,y]=D.useState(new Set),[w,E]=D.useState((n??[]).map(S=>`${S.name}: ${S.prompt}`).join(`
|
|
@@ -645,17 +645,17 @@ ${Te("continue.genOpen")}
|
|
|
645
645
|
${u.join(`
|
|
646
646
|
`)||"-"}`}]),h=c8(new Date().toISOString()).slice(0,10),m=wle(n.position);ps("note",m,{question:`**📌 ${h} · ${Te("continue.recapTag")}**
|
|
647
647
|
|
|
648
|
-
${d.trim()}`}),SM.current?.setCenter((n.position.x+m.x)/2+260,(n.position.y+m.y)/2+140,{zoom:.75,duration:600}),We("success",Te("continue.noteDropped"))}catch(a){We("error",a instanceof Error?a.message:String(a))}}}function kle({x:e,y:t,nodeId:n,onClose:a}){const r=St(),s=D.useRef(null),o=se(A=>A.nodes.find(T=>T.id===n));if(D.useEffect(()=>{const A=C=>{s.current?.contains(C.target)||a()},T=C=>{C.key==="Escape"&&a()};return window.addEventListener("mousedown",A),window.addEventListener("keydown",T),()=>{window.removeEventListener("mousedown",A),window.removeEventListener("keydown",T)}},[a]),!o)return null;const u=o.data.stepKind,d=!!u,h=!d&&!!o.data.response&&!o.data.isLoading,m=d?u==="note"||u==="link"?o.data.question:"":o.data.response,p="w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",x="text-ink-faint shrink-0",b=200,y=380,w=Math.min(e,window.innerWidth-b-8),E=Math.min(t,window.innerHeight-y-8),v=A=>()=>{a(),A()};return ur.createPortal(l.jsxs("div",{ref:s,className:"fixed z-[70] bg-card border border-line rounded-xl shadow-lg py-1 w-[200px] animate-fade-in",style:{left:w,top:E},children:[!d&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().setSelectedNodeId(n),oe.getState().setPanelOpen(!0)}),children:[l.jsx(Bl,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.openPanel")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>oe.getState().setResponseViewerNodeId(n)),children:[l.jsx(FA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.readingView")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().rerunNode(n)}),children:[l.jsx(or,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.rerun")]}),h&&l.jsxs("button",{className:p,title:Te("actions.regenBranchTitle"),onClick:v(()=>{se.getState().regenerate(n)}),children:[l.jsx(zA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.regenBranch")]}),h&&(o.data.response?.length??0)>=400&&l.jsxs("button",{className:p,onClick:v(()=>{EM([n])}),"data-reselect-ladder":!0,children:[l.jsx(u2,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.reselectLadder")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{TM(n)}),children:[l.jsx(ii,{size:14,strokeWidth:1.75,className:x})," ",r("continue.summarize")]}),m&&l.jsxs("button",{className:p,onClick:v(()=>{navigator.clipboard.writeText(m).then(()=>We("success",Te("ctx.copied")))}),children:[l.jsx(to,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.copyContent")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().duplicateNode(n)),children:[l.jsx(bF,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.duplicate")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().setArchived([n],!o.data.archived)),children:[o.data.archived?l.jsx(RA,{size:14,strokeWidth:1.75,className:x}):l.jsx(el,{size:14,strokeWidth:1.75,className:x}),o.data.archived?r("ctx.unarchive"):r("archive.label")]}),!d&&l.jsxs("button",{className:p,title:Te("exp.copyForCliTitle"),onClick:v(()=>{ft(()=>import("./experiment-loop-
|
|
648
|
+
${d.trim()}`}),SM.current?.setCenter((n.position.x+m.x)/2+260,(n.position.y+m.y)/2+140,{zoom:.75,duration:600}),We("success",Te("continue.noteDropped"))}catch(a){We("error",a instanceof Error?a.message:String(a))}}}function kle({x:e,y:t,nodeId:n,onClose:a}){const r=St(),s=D.useRef(null),o=se(A=>A.nodes.find(T=>T.id===n));if(D.useEffect(()=>{const A=C=>{s.current?.contains(C.target)||a()},T=C=>{C.key==="Escape"&&a()};return window.addEventListener("mousedown",A),window.addEventListener("keydown",T),()=>{window.removeEventListener("mousedown",A),window.removeEventListener("keydown",T)}},[a]),!o)return null;const u=o.data.stepKind,d=!!u,h=!d&&!!o.data.response&&!o.data.isLoading,m=d?u==="note"||u==="link"?o.data.question:"":o.data.response,p="w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",x="text-ink-faint shrink-0",b=200,y=380,w=Math.min(e,window.innerWidth-b-8),E=Math.min(t,window.innerHeight-y-8),v=A=>()=>{a(),A()};return ur.createPortal(l.jsxs("div",{ref:s,className:"fixed z-[70] bg-card border border-line rounded-xl shadow-lg py-1 w-[200px] animate-fade-in",style:{left:w,top:E},children:[!d&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().setSelectedNodeId(n),oe.getState().setPanelOpen(!0)}),children:[l.jsx(Bl,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.openPanel")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>oe.getState().setResponseViewerNodeId(n)),children:[l.jsx(FA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.readingView")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().rerunNode(n)}),children:[l.jsx(or,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.rerun")]}),h&&l.jsxs("button",{className:p,title:Te("actions.regenBranchTitle"),onClick:v(()=>{se.getState().regenerate(n)}),children:[l.jsx(zA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.regenBranch")]}),h&&(o.data.response?.length??0)>=400&&l.jsxs("button",{className:p,onClick:v(()=>{EM([n])}),"data-reselect-ladder":!0,children:[l.jsx(u2,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.reselectLadder")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{TM(n)}),children:[l.jsx(ii,{size:14,strokeWidth:1.75,className:x})," ",r("continue.summarize")]}),m&&l.jsxs("button",{className:p,onClick:v(()=>{navigator.clipboard.writeText(m).then(()=>We("success",Te("ctx.copied")))}),children:[l.jsx(to,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.copyContent")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().duplicateNode(n)),children:[l.jsx(bF,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.duplicate")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().setArchived([n],!o.data.archived)),children:[o.data.archived?l.jsx(RA,{size:14,strokeWidth:1.75,className:x}):l.jsx(el,{size:14,strokeWidth:1.75,className:x}),o.data.archived?r("ctx.unarchive"):r("archive.label")]}),!d&&l.jsxs("button",{className:p,title:Te("exp.copyForCliTitle"),onClick:v(()=>{ft(()=>import("./experiment-loop-XuEe5blq.js"),[]).then(A=>A.takeToExperiment(n,"branch"))}),"data-take-to-experiment":!0,children:[l.jsx(vF,{size:14,strokeWidth:1.75,className:x})," ",r("exp.copyForCli")]}),l.jsx("div",{className:"h-px bg-line my-1"}),l.jsxs("button",{className:"w-full text-left px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors flex items-center gap-2.5",onClick:v(()=>{ai({title:Te("confirm.deleteNodesTitle"),message:ve(Te("confirm.deleteNodes"),{n:1}),confirmLabel:Te("common.delete"),danger:!0}).then(A=>{A&&se.getState().deleteNode(n)})}),children:[l.jsx(Ja,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",r("common.delete")]})]}),document.body)}function Ele({onLocate:e}){const t=oe(C=>C.highlightsOverviewOpen),n=oe(C=>C.setHighlightsOverviewOpen),a=se(C=>C.nodes),r=se(C=>C.removeHighlight),s=se(C=>C.weaveHighlights),o=St(),[u,d]=D.useState("time"),[h,m]=D.useState(new Set),[p,x]=D.useState(""),b=D.useMemo(()=>{const C=[];for(const O of a){const _=O.data.question.replace(/\s+/g," ").trim().slice(0,60)||"—";for(const S of O.data.highlights||[])C.push({hlId:S.id,text:S.text,at:S.at,nodeId:O.id,nodeTitle:_})}const I=u==="time"?[...C].sort((O,_)=>(_.at??"").localeCompare(O.at??"")):C;return I.map((O,_)=>({...O,showGroup:u==="node"&&(_===0||I[_-1].nodeTitle!==O.nodeTitle)}))},[a,u]);if(!t)return null;const y=C=>{const I=new Set(h);I.has(C)?I.delete(C):I.add(C),m(I)},w=()=>{n(!1),m(new Set),x("")},E=()=>{const C=[...h].filter(O=>b.some(_=>_.hlId===O));if(C.length===0)return;const I=[...new Set(b.filter(O=>C.includes(O.hlId)).map(O=>O.nodeId))];w(),s(I,p.trim()||void 0,C)},v=()=>{const C=b.map(I=>`- ${I.text}
|
|
649
649
|
— ${I.nodeTitle}${I.at?` · ${I.at.slice(0,10)}`:""}`);Y2(`# ${o("hlov.title")}
|
|
650
650
|
|
|
651
651
|
${C.join(`
|
|
652
652
|
`)}
|
|
653
653
|
`)},A="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",T=(C,I)=>l.jsx("button",{onClick:()=>d(C),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${u===C?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:I});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:w,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:C=>C.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(m0,{size:15,strokeWidth:1.75,className:"text-amber-500"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:o("hlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ve(o("hlov.count"),{n:b.length})}),l.jsx("div",{className:"flex-1"}),T("time",o("hlov.byTime")),T("node",o("hlov.byNode")),l.jsx("button",{onClick:w,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[b.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:o("hlov.empty")}),b.map(C=>l.jsxs("div",{children:[C.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:C.nodeTitle}),l.jsxs("div",{className:"group flex items-start gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("input",{type:"checkbox",checked:h.has(C.hlId),onChange:()=>y(C.hlId),className:"mt-1 accent-amber-500 shrink-0"}),l.jsx("span",{className:"flex-1 text-sm text-ink leading-relaxed min-w-0",children:l.jsx("mark",{className:"bg-amber-100 text-amber-800 px-0.5 rounded",children:C.text})}),u==="time"&&l.jsxs("button",{className:A,onClick:()=>{w(),e(C.nodeId)},title:o("hlov.locateTitle"),children:[C.nodeTitle.slice(0,14),C.nodeTitle.length>14?"…":""]}),u==="node"&&l.jsx("button",{className:A,onClick:()=>{w(),e(C.nodeId)},title:o("hlov.locateTitle"),children:"↦"}),C.at&&l.jsx("span",{className:"shrink-0 text-2xs text-ink-faint font-mono mt-0.5",children:C.at.slice(5,10)}),l.jsx("button",{onClick:()=>r(C.nodeId,C.hlId),title:o("common.delete"),className:"text-ink-faint hover:text-red-500 w-5 h-5 rounded-full flex items-center justify-center transition-colors shrink-0 opacity-0 group-hover:opacity-100",children:l.jsx(Ja,{size:12,strokeWidth:1.75})})]})]},C.hlId))]}),l.jsxs("div",{className:"px-5 py-3 border-t border-line shrink-0 space-y-2",children:[h.size>0&&l.jsxs("div",{className:"flex gap-1.5",children:[l.jsx("input",{type:"text",value:p,onChange:C=>x(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!lr(C)&&E()},placeholder:o("toolbar.intentPlaceholder"),className:"flex-1 text-xs border border-amber-500/30 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-amber-500 bg-amber-500/5"}),l.jsx("button",{onClick:E,className:"text-xs bg-amber-500 hover:bg-amber-400 text-white px-3 py-2 rounded-lg transition-colors shrink-0",children:ve(o("hlov.weavePicked"),{n:h.size})})]}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:h.size>0?ve(o("hlov.picked"),{n:h.size}):o("hlov.pickHint")}),l.jsx("div",{className:"flex-1"}),b.length>0&&l.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 text-2xs text-ink-faint hover:text-ink-muted transition-colors",title:o("hlov.exportTitle"),children:[l.jsx(Ml,{size:12,strokeWidth:1.75})," ",o("hlov.export")]})]})]})]})}),document.body)}const Sle={pdf:js,img:PF,txt:js,note:ii,link:Gi};function Tle({onLocate:e}){const t=oe(x=>x.materialsOverviewOpen),n=oe(x=>x.setMaterialsOverviewOpen),a=se(x=>x.nodes),r=St(),[s,o]=D.useState("time"),u=D.useMemo(()=>{const x=[];for(const y of a){const w=y.data.stepKind;if(w==="note"||w==="link"){const v=w==="link"?y.data.linkTitle||y.data.linkUrl||"—":y.data.question.split(`
|
|
654
|
-
`)[0].replace(/^#+\s*/,"").slice(0,60)||"—";x.push({key:y.id,name:v,icon:w,at:y.data.createdAt,nodeId:y.id,nodeTitle:v,canOpen:!0});continue}const E=y.data.question.replace(/\s+/g," ").trim().slice(0,60)||(w==="file"?r("glyph.file"):"—");for(const v of y.data.attachments||[]){const A=v.type==="application/pdf"?"pdf":v.type.startsWith("image/")?"img":"txt";x.push({key:v.id,name:v.name,icon:A,sizeKB:v.size/1024,at:v.addedAt,nodeId:y.id,nodeTitle:E,canOpen:A==="pdf"})}}const b=s==="time"?[...x].sort((y,w)=>(w.at??"").localeCompare(y.at??"")):x;return b.map((y,w)=>({...y,showGroup:s==="node"&&(w===0||b[w-1].nodeTitle!==y.nodeTitle)}))},[a,s,r]);if(!t)return null;const d=()=>n(!1),h=x=>{d(),oe.getState().setReaderNodeId(x)},m="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",p=(x,b)=>l.jsx("button",{onClick:()=>o(x),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${s===x?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:b});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:d,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:x=>x.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(Ls,{size:15,strokeWidth:1.75,className:"text-warm"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("matov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ve(r("matov.count"),{n:u.length})}),l.jsx("div",{className:"flex-1"}),p("time",r("hlov.byTime")),p("node",r("hlov.byNode")),l.jsx("button",{onClick:d,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[u.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("matov.empty")}),u.map(x=>{const b=Sle[x.icon];return l.jsxs("div",{children:[x.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:x.nodeTitle}),l.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${x.icon==="note"?"bg-amber-100 text-amber-600":x.icon==="link"?"bg-cyan-100 text-cyan-700":"bg-wash text-ink-muted"}`,children:l.jsx(b,{size:14,strokeWidth:1.75})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-ink truncate",children:x.name}),l.jsxs("p",{className:"text-2xs text-ink-faint",children:[x.sizeKB!=null?`${x.sizeKB.toFixed(1)} KB`:r(`matov.kind.${x.icon}`),x.at?` · ${x.at.slice(0,10)}`:""]})]}),s==="time"&&l.jsxs("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:[x.nodeTitle.slice(0,14),x.nodeTitle.length>14?"…":""]}),s==="node"&&l.jsx("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:"↦"}),x.canOpen&&l.jsx("button",{onClick:()=>h(x.nodeId),title:r("attach.openReader"),className:"w-7 h-7 rounded-lg text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors shrink-0",children:l.jsx(Bl,{size:14,strokeWidth:1.75})})]})]},x.key)})]})]})}),document.body)}function Nle(e){const t=e.data.stepKind;return t==="note"||t==="file"||t==="link"||t==="frame"?t:e.data.condensedFrom?.length?"distill":"qa"}function Ale(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n+=1,a=e.indexOf(t,a+t.length);return n}function Cle(e,t,n){const r=Math.max(0,t-40),s=Math.min(e.length,t+n+60),o=r>0?"…":"",u=s<e.length?"…":"";return{snippet:o+e.slice(r,s)+u,matchStart:o.length+(t-r)}}function _le(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=[];for(const r of e){const s=r.data;if(s.stepKind==="fanout")continue;const o=[s.question??"",s.response??"",...(s.highlights??[]).map(p=>p.text),s.linkTitle??"",...(s.attachments??[]).map(p=>p.name),s.summaries?.[s.responseIndex]??s.summary??""];let u=0,d=null;for(const p of o){if(!p)continue;const x=p.toLowerCase(),b=x.indexOf(n);b!==-1&&(u+=Ale(x,n),d||(d={text:p,at:b}))}if(!d)continue;const{snippet:h,matchStart:m}=Cle(d.text,d.at,n.length);a.push({nodeId:r.id,kind:Nle(r),archived:!!s.archived,count:u,snippet:h,matchStart:m,matchLen:n.length})}return a.sort((r,s)=>Number(r.archived)-Number(s.archived)||s.count-r.count),a}const Mle={qa:UA,note:ii,file:js,link:Gi,frame:Fb,distill:xp},mb=50;function Ile({open:e,onClose:t,onLocate:n}){const a=St(),r=se(v=>v.nodes),s=oe(v=>v.setSearchHitIds),[o,u]=D.useState(""),[d,h]=D.useState(0),m=D.useRef(null),[p,x]=D.useState(e);p!==e&&(x(e),e&&(u(""),h(0))),D.useEffect(()=>{e&&setTimeout(()=>m.current?.focus(),50)},[e]);const[b,y]=D.useState("");D.useEffect(()=>{const v=setTimeout(()=>y(o),120);return()=>clearTimeout(v)},[o]);const w=D.useMemo(()=>e?_le(r,b):[],[e,r,b]);if(D.useEffect(()=>{if(!e||!b.trim()){s(null);return}s(new Set(w.map(v=>v.nodeId)))},[e,b,w,s]),D.useEffect(()=>()=>s(null),[s]),!e)return null;const E=v=>{n(v.nodeId);const A=b.trim().toLowerCase();setTimeout(()=>{const T=document.querySelector("[data-focus-panel]");if(!T||!A)return;const C=document.createTreeWalker(T,NodeFilter.SHOW_TEXT);let I;for(;I=C.nextNode();)if(I.textContent?.toLowerCase().includes(A)){const O=I.parentElement;O?.scrollIntoView({block:"center",behavior:"smooth"}),O?.animate([{backgroundColor:"rgba(107, 92, 231, 0.22)"},{backgroundColor:"transparent"}],{duration:1800,easing:"ease-out"});break}},500)};return l.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20 w-[460px]","data-canvas-search":!0,children:l.jsxs("div",{className:"bg-card border border-line rounded-xl shadow-xl overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 transition-shadow focus-within:ring-1 focus-within:ring-accent/40",children:[l.jsx(g0,{size:15,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{ref:m,type:"text",value:o,onChange:v=>{u(v.target.value),h(0)},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t()),v.key==="ArrowDown"&&(v.preventDefault(),h(A=>Math.min(A+1,w.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),h(A=>Math.max(A-1,0))),v.key==="Enter"&&!lr(v)&&w[d]&&(v.preventDefault(),E(w[d]))},placeholder:a("search.placeholder"),className:"flex-1 bg-transparent text-sm text-ink placeholder-ink-faint focus:outline-none","data-search-input":!0}),o&&l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ve(a("search.count"),{n:w.length})}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),w.length>0&&l.jsxs("ul",{className:"border-t border-line/60 max-h-72 overflow-y-auto py-1",children:[w.slice(0,mb).map((v,A)=>{const T=Mle[v.kind],I=r.find(O=>O.id===v.nodeId)?.data.question||"—";return l.jsx("li",{children:l.jsxs("button",{onClick:()=>E(v),onMouseEnter:()=>h(A),className:`w-full text-left px-4 py-2 transition-colors ${A===d?"bg-accent/8":""} ${v.archived?"opacity-55":""}`,"data-search-hit-row":!0,children:[l.jsxs("p",{className:`text-xs font-medium truncate flex items-center gap-1.5 ${A===d?"text-accent":"text-ink"}`,children:[l.jsx(T,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate flex-1 min-w-0",children:I}),v.archived&&l.jsx(el,{size:11,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),v.count>1&&l.jsxs("span",{className:"text-2xs text-ink-faint font-normal shrink-0",children:["×",v.count]})]}),l.jsxs("p",{className:"text-2xs text-ink-faint mt-0.5 break-all leading-relaxed",children:[v.snippet.slice(0,v.matchStart),l.jsx("mark",{className:"bg-accent/20 text-accent rounded-sm px-px",children:v.snippet.slice(v.matchStart,v.matchStart+v.matchLen)}),v.snippet.slice(v.matchStart+v.matchLen)]})]})},v.nodeId)}),w.length>mb&&l.jsx("li",{className:"px-4 py-2 text-2xs text-ink-faint",children:ve(a("search.more"),{n:w.length-mb})})]})]})})}const xT=new Set(["note","file","link"]),Ws=e=>{const t=(e?.data.question??"").replace(/\s+/g," ").trim();return t.length>24?`${t.slice(0,24)}…`:t||"(空)"};function pb(e,t,n){const a=new Set([e]),r=[e];for(;r.length;){const s=r.shift();for(const o of n.get(s)??[]){if(o===t)return!0;a.has(o)||(a.add(o),r.push(o))}}return!1}function gb(e){const t=new Map;for(const n of e)t.has(n.source)||t.set(n.source,[]),t.get(n.source).push(n.target);return t}function bT(e,t){const n=[],a=new Map(e.map(S=>[S.id,S])),r=t.filter(S=>!S.data?.isCrossLink),s=t.filter(S=>S.data?.isCrossLink),o=gb(r),u=gb(t);for(const S of r){const z=gb(r.filter(V=>V.id!==S.id));pb(S.source,S.target,z)&&n.push({tier:1,kind:"residual-edge",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]})}for(const S of s)pb(S.source,S.target,o)&&n.push({tier:1,kind:"shadow-reference",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]});const d=new Map;for(const S of r)d.has(S.source)||d.set(S.source,[]),d.get(S.source).push(S.target);const h=[];for(const S of d.values()){const z=S.filter(P=>a.get(P)?.data.stepKind==="prompt"),V=S.filter(P=>a.get(P)?.data.isBranch);z.length>=2&&h.push(z),V.length>=2&&h.push(V)}for(const S of h)for(const z of S)for(const V of S)if(z!==V&&pb(z,V,u)){const P=t.find(L=>L.source===z&&L.target===V);n.push({tier:1,kind:"blind-pool-breach",fixable:!!P,params:{a:Ws(a.get(V)),b:Ws(a.get(z))},nodeIds:[V,z],edgeIds:P?[P.id]:[]})}for(const S of h){const z=S.map(P=>new Set(t.filter(L=>L.target===P).map(L=>L.source))),V=new Set([...z[0]].filter(P=>z.every(L=>L.has(P))));S.forEach((P,L)=>{const Y=[...z[L]].filter(q=>!V.has(q)&&!S.includes(q));Y.length>0&&n.push({tier:1,kind:"pool-asymmetry",fixable:!1,params:{a:Ws(a.get(P)),n:Y.length},nodeIds:[P,...Y],edgeIds:[]})})}const m=e.filter(S=>!xT.has(S.data.stepKind??"")&&S.data.stepKind!=="frame"),p=new Map,x=new Map,b=S=>Nn(S.data.question+S.data.response),y=new Map;for(const S of m)y.set(S.id,0);for(const S of r)y.has(S.target)&&y.has(S.source)&&y.set(S.target,(y.get(S.target)??0)+1);const w=m.filter(S=>(y.get(S.id)??0)===0).map(S=>S.id),E=[],v=new Map(y);for(;w.length;){const S=w.shift();E.push(S);for(const z of o.get(S)??[])v.has(z)&&(v.set(z,v.get(z)-1),v.get(z)===0&&w.push(z))}for(const S of E){const z=a.get(S),V=r.filter(Y=>Y.target===S&&p.has(Y.source)),P=V.length?Math.max(...V.map(Y=>p.get(Y.source)))+1:1,L=V.length?Math.max(...V.map(Y=>x.get(Y.source)))+b(z):b(z);p.set(S,P),x.set(S,L)}const A=m.filter(S=>!(o.get(S.id)??[]).length&&!S.data.archived),T=A.filter(S=>(p.get(S.id)??0)>=8||(x.get(S.id)??0)>=15e3).sort((S,z)=>(p.get(z.id)??0)-(p.get(S.id)??0)).slice(0,3);for(const S of T)n.push({tier:2,kind:"long-chain",fixable:!1,params:{a:Ws(S),d:p.get(S.id)??0,tok:x.get(S.id)??0},nodeIds:[S.id],edgeIds:[]});const C=A.filter(S=>S.data.response);C.length>=4&&n.push({tier:2,kind:"open-branches",fixable:!1,params:{n:C.length},nodeIds:C.map(S=>S.id),edgeIds:[]});for(const S of m){const z=r.filter(P=>P.target===S.id).length,V=(o.get(S.id)??[]).length;z>=2&&V>=1&&n.push({tier:2,kind:"collider-continuation",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]})}const I=e.filter(S=>xT.has(S.data.stepKind??"")&&!t.some(z=>z.source===S.id));I.length>0&&n.push({tier:2,kind:"orphan-materials",fixable:!1,params:{n:I.length},nodeIds:I.map(S=>S.id),edgeIds:[]});const O=S=>{const z=new Set,V=[S];for(;V.length;)for(const P of o.get(V.shift())??[])z.has(P)||(z.add(P),V.push(P));return z.size},_=m.map(S=>({n:S,c:O(S.id)})).filter(({c:S})=>S>=5).sort((S,z)=>z.c-S.c).slice(0,3);for(const{n:S,c:z}of _)n.push({tier:2,kind:"load-bearing",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]});return n.sort((S,z)=>S.tier-z.tier)}const Ole={"residual-edge":"diag.residual","shadow-reference":"diag.shadow","blind-pool-breach":"diag.breach","pool-asymmetry":"diag.asym","long-chain":"diag.longChain","open-branches":"diag.openBranches","collider-continuation":"diag.collider","orphan-materials":"diag.orphans","load-bearing":"diag.loadBearing"};function Dle({onLocate:e,openPing:t=0,showTrigger:n=!0}){const a=se(v=>v.deleteEdges),r=St(),[s,o]=D.useState(!1),[u,d]=D.useState([]),h=D.useRef(null),[m,p]=D.useState(t);D.useEffect(()=>{if(!s)return;const v=A=>{h.current?.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[s]);const x=()=>{const{nodes:v,edges:A}=se.getState();d(bT(v,A)),o(!0)};t!==m&&(p(t),x());const b=v=>{a(v.edgeIds);const{nodes:A,edges:T}=se.getState();d(bT(A,T))},y=u.filter(v=>v.tier===1),w=u.filter(v=>v.tier===2),E=(v,A)=>l.jsxs("div",{className:"px-3 py-2 border-b border-line/50 last:border-0 flex items-start gap-2",children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${v.tier===1?"bg-red-400":"bg-amber-400"}`}),l.jsx("span",{className:"text-xs text-ink-muted leading-relaxed flex-1 min-w-0",children:ve(r(Ole[v.kind]),v.params)}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v.nodeIds.length>0&&l.jsx("button",{onClick:()=>e(v.nodeIds[0]),title:r("diag.locate"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(zd,{size:13,strokeWidth:1.75})}),v.fixable&&l.jsx("button",{onClick:()=>b(v),title:r("diag.fix"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-red-500 hover:bg-red-50 flex items-center justify-center transition-colors",children:l.jsx(Ja,{size:13,strokeWidth:1.75})})]})]},`${v.kind}-${A}`);return l.jsxs("div",{ref:h,className:"relative",children:[n&&l.jsx("button",{onClick:()=>s?o(!1):x(),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${s?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:r("toolbar.diagnose"),children:l.jsx(VA,{size:15,strokeWidth:1.75})}),s&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[340px] max-h-[420px] overflow-y-auto z-30 animate-fade-in",children:[l.jsxs("div",{className:"px-3 py-1.5 text-2xs font-semibold text-ink-muted border-b border-line",children:[r("diag.title"),l.jsx("span",{className:"text-ink-faint font-normal ml-2",children:u.length===0?"":ve(r("diag.summary"),{a:y.length,b:w.length})})]}),u.length===0&&l.jsx("p",{className:"px-3 py-3 text-xs text-ink-faint italic",children:r("diag.clean")}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-red-500",children:r("diag.tier1")}),y.map(E)]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-amber-600",children:r("diag.tier2")}),w.map(E)]})]})]})}async function NM(e,t){const{default:n}=await ft(async()=>{const{default:s}=await import("./purify.es-Cz4mVeUR.js");return{default:s}},[]),a=n.sanitize(e,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style"],FORBID_TAGS:["script","iframe","object","embed","form","base","meta",...t?.baseUrl?[]:["link"]]}),r=new DOMParser().parseFromString(a,"text/html");return t?.baseUrl&&Rle(r,t.baseUrl),r}function Rle(e,t){const n=a=>{try{const r=new URL(a,t);return/^https?:$/.test(r.protocol)?r.href:null}catch{return null}};e.querySelectorAll("link").forEach(a=>{const r=a.getAttribute("href"),s=r?n(r):null;(a.getAttribute("rel")??"").toLowerCase()!=="stylesheet"||!s?a.remove():a.setAttribute("href",s)});for(const[a,r]of[["img","src"],["source","src"],["video","poster"],["a","href"]])e.querySelectorAll(`${a}[${r}]`).forEach(s=>{const o=s.getAttribute(r),u=o?n(o):null;u?s.setAttribute(r,u):s.removeAttribute(r)});e.querySelectorAll("img[srcset], source[srcset]").forEach(a=>a.removeAttribute("srcset"))}async function jle(){const[{default:e},t]=await Promise.all([ft(()=>import("./turndown.browser.es-kLzRgxYD.js"),[]),ft(()=>import("./turndown-plugin-gfm.cjs-Ccez8Set.js").then(a=>a.t),[])]),n=new e({headingStyle:"atx",codeBlockStyle:"fenced",hr:"---"});return n.use(t.gfm),n.remove(["style","script","noscript","title"]),n}function yT(e){return(e.textContent??"").trim().length>0||!!e.querySelector("img,svg,canvas,video")}function qv(e){const t=Array.from(e.querySelectorAll(".reveal .slides > section"));if(t.length>=2){const s=[];for(const o of t){const u=Array.from(o.children).filter(d=>d.tagName==="SECTION");u.length>0?s.push(...u):s.push(o)}return s}const n=new Map;for(const s of Array.from(e.body?.querySelectorAll("[class]")??[])){const o=s.getAttribute("class")??"";if(!/(?:^|[\s_-])(?:slide|page)(?:[\s_-]|$)/i.test(o)||!yT(s))continue;const u=s.parentElement;if(!u)continue;const d=n.get(u)??[];d.push(s),n.set(u,d)}let a=null;for(const s of n.values())s.length>=2&&(!a||s.length>a.length)&&(a=s);if(a)return a;const r=Array.from(e.querySelectorAll("body > section")).filter(yT);return r.length>=3?r:null}async function Lle(e,t){const n=await NM(e,t),a=await jle(),r=qv(n);if(r)return{markdown:r.map((d,h)=>`<!-- tdag-page:${h+1} -->
|
|
654
|
+
`)[0].replace(/^#+\s*/,"").slice(0,60)||"—";x.push({key:y.id,name:v,icon:w,at:y.data.createdAt,nodeId:y.id,nodeTitle:v,canOpen:!0});continue}const E=y.data.question.replace(/\s+/g," ").trim().slice(0,60)||(w==="file"?r("glyph.file"):"—");for(const v of y.data.attachments||[]){const A=v.type==="application/pdf"?"pdf":v.type.startsWith("image/")?"img":"txt";x.push({key:v.id,name:v.name,icon:A,sizeKB:v.size/1024,at:v.addedAt,nodeId:y.id,nodeTitle:E,canOpen:A==="pdf"})}}const b=s==="time"?[...x].sort((y,w)=>(w.at??"").localeCompare(y.at??"")):x;return b.map((y,w)=>({...y,showGroup:s==="node"&&(w===0||b[w-1].nodeTitle!==y.nodeTitle)}))},[a,s,r]);if(!t)return null;const d=()=>n(!1),h=x=>{d(),oe.getState().setReaderNodeId(x)},m="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",p=(x,b)=>l.jsx("button",{onClick:()=>o(x),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${s===x?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:b});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:d,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:x=>x.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(Ls,{size:15,strokeWidth:1.75,className:"text-warm"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("matov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ve(r("matov.count"),{n:u.length})}),l.jsx("div",{className:"flex-1"}),p("time",r("hlov.byTime")),p("node",r("hlov.byNode")),l.jsx("button",{onClick:d,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[u.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("matov.empty")}),u.map(x=>{const b=Sle[x.icon];return l.jsxs("div",{children:[x.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:x.nodeTitle}),l.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${x.icon==="note"?"bg-amber-100 text-amber-600":x.icon==="link"?"bg-cyan-100 text-cyan-700":"bg-wash text-ink-muted"}`,children:l.jsx(b,{size:14,strokeWidth:1.75})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-ink truncate",children:x.name}),l.jsxs("p",{className:"text-2xs text-ink-faint",children:[x.sizeKB!=null?`${x.sizeKB.toFixed(1)} KB`:r(`matov.kind.${x.icon}`),x.at?` · ${x.at.slice(0,10)}`:""]})]}),s==="time"&&l.jsxs("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:[x.nodeTitle.slice(0,14),x.nodeTitle.length>14?"…":""]}),s==="node"&&l.jsx("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:"↦"}),x.canOpen&&l.jsx("button",{onClick:()=>h(x.nodeId),title:r("attach.openReader"),className:"w-7 h-7 rounded-lg text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors shrink-0",children:l.jsx(Bl,{size:14,strokeWidth:1.75})})]})]},x.key)})]})]})}),document.body)}function Nle(e){const t=e.data.stepKind;return t==="note"||t==="file"||t==="link"||t==="frame"?t:e.data.condensedFrom?.length?"distill":"qa"}function Ale(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n+=1,a=e.indexOf(t,a+t.length);return n}function Cle(e,t,n){const r=Math.max(0,t-40),s=Math.min(e.length,t+n+60),o=r>0?"…":"",u=s<e.length?"…":"";return{snippet:o+e.slice(r,s)+u,matchStart:o.length+(t-r)}}function _le(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=[];for(const r of e){const s=r.data;if(s.stepKind==="fanout")continue;const o=[s.question??"",s.response??"",...(s.highlights??[]).map(p=>p.text),s.linkTitle??"",...(s.attachments??[]).map(p=>p.name),s.summaries?.[s.responseIndex]??s.summary??""];let u=0,d=null;for(const p of o){if(!p)continue;const x=p.toLowerCase(),b=x.indexOf(n);b!==-1&&(u+=Ale(x,n),d||(d={text:p,at:b}))}if(!d)continue;const{snippet:h,matchStart:m}=Cle(d.text,d.at,n.length);a.push({nodeId:r.id,kind:Nle(r),archived:!!s.archived,count:u,snippet:h,matchStart:m,matchLen:n.length})}return a.sort((r,s)=>Number(r.archived)-Number(s.archived)||s.count-r.count),a}const Mle={qa:UA,note:ii,file:js,link:Gi,frame:Fb,distill:xp},mb=50;function Ile({open:e,onClose:t,onLocate:n}){const a=St(),r=se(v=>v.nodes),s=oe(v=>v.setSearchHitIds),[o,u]=D.useState(""),[d,h]=D.useState(0),m=D.useRef(null),[p,x]=D.useState(e);p!==e&&(x(e),e&&(u(""),h(0))),D.useEffect(()=>{e&&setTimeout(()=>m.current?.focus(),50)},[e]);const[b,y]=D.useState("");D.useEffect(()=>{const v=setTimeout(()=>y(o),120);return()=>clearTimeout(v)},[o]);const w=D.useMemo(()=>e?_le(r,b):[],[e,r,b]);if(D.useEffect(()=>{if(!e||!b.trim()){s(null);return}s(new Set(w.map(v=>v.nodeId)))},[e,b,w,s]),D.useEffect(()=>()=>s(null),[s]),!e)return null;const E=v=>{n(v.nodeId);const A=b.trim().toLowerCase();setTimeout(()=>{const T=document.querySelector("[data-focus-panel]");if(!T||!A)return;const C=document.createTreeWalker(T,NodeFilter.SHOW_TEXT);let I;for(;I=C.nextNode();)if(I.textContent?.toLowerCase().includes(A)){const O=I.parentElement;O?.scrollIntoView({block:"center",behavior:"smooth"}),O?.animate([{backgroundColor:"rgba(107, 92, 231, 0.22)"},{backgroundColor:"transparent"}],{duration:1800,easing:"ease-out"});break}},500)};return l.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20 w-[460px]","data-canvas-search":!0,children:l.jsxs("div",{className:"bg-card border border-line rounded-xl shadow-xl overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 transition-shadow focus-within:ring-1 focus-within:ring-accent/40",children:[l.jsx(g0,{size:15,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{ref:m,type:"text",value:o,onChange:v=>{u(v.target.value),h(0)},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t()),v.key==="ArrowDown"&&(v.preventDefault(),h(A=>Math.min(A+1,w.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),h(A=>Math.max(A-1,0))),v.key==="Enter"&&!lr(v)&&w[d]&&(v.preventDefault(),E(w[d]))},placeholder:a("search.placeholder"),className:"flex-1 bg-transparent text-sm text-ink placeholder-ink-faint focus:outline-none","data-search-input":!0}),o&&l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ve(a("search.count"),{n:w.length})}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),w.length>0&&l.jsxs("ul",{className:"border-t border-line/60 max-h-72 overflow-y-auto py-1",children:[w.slice(0,mb).map((v,A)=>{const T=Mle[v.kind],I=r.find(O=>O.id===v.nodeId)?.data.question||"—";return l.jsx("li",{children:l.jsxs("button",{onClick:()=>E(v),onMouseEnter:()=>h(A),className:`w-full text-left px-4 py-2 transition-colors ${A===d?"bg-accent/8":""} ${v.archived?"opacity-55":""}`,"data-search-hit-row":!0,children:[l.jsxs("p",{className:`text-xs font-medium truncate flex items-center gap-1.5 ${A===d?"text-accent":"text-ink"}`,children:[l.jsx(T,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate flex-1 min-w-0",children:I}),v.archived&&l.jsx(el,{size:11,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),v.count>1&&l.jsxs("span",{className:"text-2xs text-ink-faint font-normal shrink-0",children:["×",v.count]})]}),l.jsxs("p",{className:"text-2xs text-ink-faint mt-0.5 break-all leading-relaxed",children:[v.snippet.slice(0,v.matchStart),l.jsx("mark",{className:"bg-accent/20 text-accent rounded-sm px-px",children:v.snippet.slice(v.matchStart,v.matchStart+v.matchLen)}),v.snippet.slice(v.matchStart+v.matchLen)]})]})},v.nodeId)}),w.length>mb&&l.jsx("li",{className:"px-4 py-2 text-2xs text-ink-faint",children:ve(a("search.more"),{n:w.length-mb})})]})]})})}const xT=new Set(["note","file","link"]),Ws=e=>{const t=(e?.data.question??"").replace(/\s+/g," ").trim();return t.length>24?`${t.slice(0,24)}…`:t||"(空)"};function pb(e,t,n){const a=new Set([e]),r=[e];for(;r.length;){const s=r.shift();for(const o of n.get(s)??[]){if(o===t)return!0;a.has(o)||(a.add(o),r.push(o))}}return!1}function gb(e){const t=new Map;for(const n of e)t.has(n.source)||t.set(n.source,[]),t.get(n.source).push(n.target);return t}function bT(e,t){const n=[],a=new Map(e.map(S=>[S.id,S])),r=t.filter(S=>!S.data?.isCrossLink),s=t.filter(S=>S.data?.isCrossLink),o=gb(r),u=gb(t);for(const S of r){const z=gb(r.filter(V=>V.id!==S.id));pb(S.source,S.target,z)&&n.push({tier:1,kind:"residual-edge",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]})}for(const S of s)pb(S.source,S.target,o)&&n.push({tier:1,kind:"shadow-reference",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]});const d=new Map;for(const S of r)d.has(S.source)||d.set(S.source,[]),d.get(S.source).push(S.target);const h=[];for(const S of d.values()){const z=S.filter(P=>a.get(P)?.data.stepKind==="prompt"),V=S.filter(P=>a.get(P)?.data.isBranch);z.length>=2&&h.push(z),V.length>=2&&h.push(V)}for(const S of h)for(const z of S)for(const V of S)if(z!==V&&pb(z,V,u)){const P=t.find(L=>L.source===z&&L.target===V);n.push({tier:1,kind:"blind-pool-breach",fixable:!!P,params:{a:Ws(a.get(V)),b:Ws(a.get(z))},nodeIds:[V,z],edgeIds:P?[P.id]:[]})}for(const S of h){const z=S.map(P=>new Set(t.filter(L=>L.target===P).map(L=>L.source))),V=new Set([...z[0]].filter(P=>z.every(L=>L.has(P))));S.forEach((P,L)=>{const Y=[...z[L]].filter(q=>!V.has(q)&&!S.includes(q));Y.length>0&&n.push({tier:1,kind:"pool-asymmetry",fixable:!1,params:{a:Ws(a.get(P)),n:Y.length},nodeIds:[P,...Y],edgeIds:[]})})}const m=e.filter(S=>!xT.has(S.data.stepKind??"")&&S.data.stepKind!=="frame"),p=new Map,x=new Map,b=S=>Nn(S.data.question+S.data.response),y=new Map;for(const S of m)y.set(S.id,0);for(const S of r)y.has(S.target)&&y.has(S.source)&&y.set(S.target,(y.get(S.target)??0)+1);const w=m.filter(S=>(y.get(S.id)??0)===0).map(S=>S.id),E=[],v=new Map(y);for(;w.length;){const S=w.shift();E.push(S);for(const z of o.get(S)??[])v.has(z)&&(v.set(z,v.get(z)-1),v.get(z)===0&&w.push(z))}for(const S of E){const z=a.get(S),V=r.filter(Y=>Y.target===S&&p.has(Y.source)),P=V.length?Math.max(...V.map(Y=>p.get(Y.source)))+1:1,L=V.length?Math.max(...V.map(Y=>x.get(Y.source)))+b(z):b(z);p.set(S,P),x.set(S,L)}const A=m.filter(S=>!(o.get(S.id)??[]).length&&!S.data.archived),T=A.filter(S=>(p.get(S.id)??0)>=8||(x.get(S.id)??0)>=15e3).sort((S,z)=>(p.get(z.id)??0)-(p.get(S.id)??0)).slice(0,3);for(const S of T)n.push({tier:2,kind:"long-chain",fixable:!1,params:{a:Ws(S),d:p.get(S.id)??0,tok:x.get(S.id)??0},nodeIds:[S.id],edgeIds:[]});const C=A.filter(S=>S.data.response);C.length>=4&&n.push({tier:2,kind:"open-branches",fixable:!1,params:{n:C.length},nodeIds:C.map(S=>S.id),edgeIds:[]});for(const S of m){const z=r.filter(P=>P.target===S.id).length,V=(o.get(S.id)??[]).length;z>=2&&V>=1&&n.push({tier:2,kind:"collider-continuation",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]})}const I=e.filter(S=>xT.has(S.data.stepKind??"")&&!t.some(z=>z.source===S.id));I.length>0&&n.push({tier:2,kind:"orphan-materials",fixable:!1,params:{n:I.length},nodeIds:I.map(S=>S.id),edgeIds:[]});const O=S=>{const z=new Set,V=[S];for(;V.length;)for(const P of o.get(V.shift())??[])z.has(P)||(z.add(P),V.push(P));return z.size},_=m.map(S=>({n:S,c:O(S.id)})).filter(({c:S})=>S>=5).sort((S,z)=>z.c-S.c).slice(0,3);for(const{n:S,c:z}of _)n.push({tier:2,kind:"load-bearing",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]});return n.sort((S,z)=>S.tier-z.tier)}const Ole={"residual-edge":"diag.residual","shadow-reference":"diag.shadow","blind-pool-breach":"diag.breach","pool-asymmetry":"diag.asym","long-chain":"diag.longChain","open-branches":"diag.openBranches","collider-continuation":"diag.collider","orphan-materials":"diag.orphans","load-bearing":"diag.loadBearing"};function Dle({onLocate:e,openPing:t=0,showTrigger:n=!0}){const a=se(v=>v.deleteEdges),r=St(),[s,o]=D.useState(!1),[u,d]=D.useState([]),h=D.useRef(null),[m,p]=D.useState(t);D.useEffect(()=>{if(!s)return;const v=A=>{h.current?.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[s]);const x=()=>{const{nodes:v,edges:A}=se.getState();d(bT(v,A)),o(!0)};t!==m&&(p(t),x());const b=v=>{a(v.edgeIds);const{nodes:A,edges:T}=se.getState();d(bT(A,T))},y=u.filter(v=>v.tier===1),w=u.filter(v=>v.tier===2),E=(v,A)=>l.jsxs("div",{className:"px-3 py-2 border-b border-line/50 last:border-0 flex items-start gap-2",children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${v.tier===1?"bg-red-400":"bg-amber-400"}`}),l.jsx("span",{className:"text-xs text-ink-muted leading-relaxed flex-1 min-w-0",children:ve(r(Ole[v.kind]),v.params)}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v.nodeIds.length>0&&l.jsx("button",{onClick:()=>e(v.nodeIds[0]),title:r("diag.locate"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(zd,{size:13,strokeWidth:1.75})}),v.fixable&&l.jsx("button",{onClick:()=>b(v),title:r("diag.fix"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-red-500 hover:bg-red-50 flex items-center justify-center transition-colors",children:l.jsx(Ja,{size:13,strokeWidth:1.75})})]})]},`${v.kind}-${A}`);return l.jsxs("div",{ref:h,className:"relative",children:[n&&l.jsx("button",{onClick:()=>s?o(!1):x(),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${s?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:r("toolbar.diagnose"),children:l.jsx(VA,{size:15,strokeWidth:1.75})}),s&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[340px] max-h-[420px] overflow-y-auto z-30 animate-fade-in",children:[l.jsxs("div",{className:"px-3 py-1.5 text-2xs font-semibold text-ink-muted border-b border-line",children:[r("diag.title"),l.jsx("span",{className:"text-ink-faint font-normal ml-2",children:u.length===0?"":ve(r("diag.summary"),{a:y.length,b:w.length})})]}),u.length===0&&l.jsx("p",{className:"px-3 py-3 text-xs text-ink-faint italic",children:r("diag.clean")}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-red-500",children:r("diag.tier1")}),y.map(E)]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-amber-600",children:r("diag.tier2")}),w.map(E)]})]})]})}async function NM(e,t){const{default:n}=await ft(async()=>{const{default:s}=await import("./purify.es-Cz4mVeUR.js");return{default:s}},[]),a=n.sanitize(e,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style"],FORBID_TAGS:["script","iframe","object","embed","form","base","meta",...t?.baseUrl?[]:["link"]]}),r=new DOMParser().parseFromString(a,"text/html");return t?.baseUrl&&Rle(r,t.baseUrl),r}function Rle(e,t){const n=a=>{try{const r=new URL(a,t);return/^https?:$/.test(r.protocol)?r.href:null}catch{return null}};e.querySelectorAll("link").forEach(a=>{const r=a.getAttribute("href"),s=r?n(r):null;(a.getAttribute("rel")??"").toLowerCase()!=="stylesheet"||!s?a.remove():a.setAttribute("href",s)});for(const[a,r]of[["img","src"],["source","src"],["video","poster"],["a","href"]])e.querySelectorAll(`${a}[${r}]`).forEach(s=>{const o=s.getAttribute(r),u=o?n(o):null;u?s.setAttribute(r,u):s.removeAttribute(r)});e.querySelectorAll("img[srcset], source[srcset]").forEach(a=>a.removeAttribute("srcset"))}async function jle(){const[{default:e},t]=await Promise.all([ft(()=>import("./turndown.browser.es-kLzRgxYD.js"),[]),ft(()=>import("./turndown-plugin-gfm.cjs-CWPGp6Gs.js").then(a=>a.t),[])]),n=new e({headingStyle:"atx",codeBlockStyle:"fenced",hr:"---"});return n.use(t.gfm),n.remove(["style","script","noscript","title"]),n}function yT(e){return(e.textContent??"").trim().length>0||!!e.querySelector("img,svg,canvas,video")}function qv(e){const t=Array.from(e.querySelectorAll(".reveal .slides > section"));if(t.length>=2){const s=[];for(const o of t){const u=Array.from(o.children).filter(d=>d.tagName==="SECTION");u.length>0?s.push(...u):s.push(o)}return s}const n=new Map;for(const s of Array.from(e.body?.querySelectorAll("[class]")??[])){const o=s.getAttribute("class")??"";if(!/(?:^|[\s_-])(?:slide|page)(?:[\s_-]|$)/i.test(o)||!yT(s))continue;const u=s.parentElement;if(!u)continue;const d=n.get(u)??[];d.push(s),n.set(u,d)}let a=null;for(const s of n.values())s.length>=2&&(!a||s.length>a.length)&&(a=s);if(a)return a;const r=Array.from(e.querySelectorAll("body > section")).filter(yT);return r.length>=3?r:null}async function Lle(e,t){const n=await NM(e,t),a=await jle(),r=qv(n);if(r)return{markdown:r.map((d,h)=>`<!-- tdag-page:${h+1} -->
|
|
655
655
|
|
|
656
656
|
${a.turndown(d.cloneNode(!0).outerHTML).trim()}`).join(`
|
|
657
657
|
|
|
658
|
-
`).trim(),numPages:r.length,title:n.title||void 0};let s=n.title||void 0,o=null;try{const{default:u}=await ft(async()=>{const{default:h}=await import("./index-
|
|
658
|
+
`).trim(),numPages:r.length,title:n.title||void 0};let s=n.title||void 0,o=null;try{const{default:u}=await ft(async()=>{const{default:h}=await import("./index-AyluzteA.js").then(m=>m.i);return{default:h}},[]),d=new u(n.cloneNode(!0)).parse();d?.content&&d.content.replace(/<[^>]+>/g," ").trim().length>40&&(o=d.content,d.title&&(s=d.title))}catch{}if(o==null&&n.body){const u=n.body.cloneNode(!0);u.querySelectorAll("script,style,noscript,nav,header,footer,aside").forEach(d=>d.remove()),o=u.innerHTML}return{markdown:o?a.turndown(o).trim():"",title:s}}const Ple=[":root{color-scheme:light}","html,body{margin:0;padding:0;overflow-x:hidden}","[data-tdag-shell]{position:static !important;transform:none !important;width:auto !important;height:auto !important;min-height:0 !important;max-height:none !important;overflow:visible !important;display:block !important;margin:0 !important;padding:0 !important}","[data-tdag-slide]{display:block !important;visibility:visible !important;opacity:1 !important;position:relative !important;inset:auto !important;transform:none !important;margin:0 auto !important}"].join(`
|
|
659
659
|
`);function zy(e){return e.replace(/&/g,"&").replace(/"/g,""")}function zle(e,t){const n=e.tagName.toLowerCase(),a=["class","id","style"].map(r=>{const s=e.getAttribute(r);return s?` ${r}="${zy(s)}"`:""}).join("");return`<${n}${a} data-tdag-shell>${t}</${n}>`}function vT(e,t,n,a){const r=n?` class="${zy(n)}"`:"",s=a?` style="${zy(a)}"`:"";return`<!doctype html><html><head><meta charset="utf-8">${e}<style>${Ple}</style></head><body${r}${s}>${t}</body></html>`}async function AM(e,t){const n=await NM(e,t),a=Array.from(n.querySelectorAll('style, link[rel="stylesheet" i]')).map(u=>u.outerHTML).join(`
|
|
660
660
|
`),r=n.body?.getAttribute("class"),s=n.body?.getAttribute("style"),o=qv(n);return o?o.map((u,d)=>{const h=u.cloneNode(!0);h.setAttribute("data-tdag-slide","");let m=h.outerHTML;for(let p=u.parentElement;p&&p!==n.body&&p.tagName!=="HTML";p=p.parentElement)m=zle(p,m);return{page:d+1,srcdoc:vT(a,m,r,s)}}):[{page:null,srcdoc:vT(a,n.body?.innerHTML??"",r,s)}]}const CM=Object.freeze(Object.defineProperty({__proto__:null,buildReaderPages:AM,detectSlides:qv,extractHtmlMaterial:Lle},Symbol.toStringTag,{value:"Module"}));function wT({att:e,onSelect:t,clipMode:n,onClipped:a,baseUrl:r}){const s=St(),[o,u]=D.useState(null),[d,h]=D.useState(!1);return D.useEffect(()=>{let m=!1;return AM(e.content,r?{baseUrl:r}:void 0).then(p=>{m||u(p)}).catch(()=>{m||h(!0)}),()=>{m=!0}},[]),d?l.jsx("p",{className:"text-sm text-ink-faint italic py-10 text-center",children:s("reader.htmlNoText")}):o?l.jsx("div",{className:"flex flex-col items-center py-6 px-4",children:o.map(m=>l.jsxs("div",{"data-page":m.page??void 0,className:"w-full max-w-[860px]",children:[m.page!=null&&l.jsxs("div",{className:"text-2xs text-ink-faint font-mono text-center select-none pt-4 pb-2",children:["— p.",m.page," —"]}),l.jsx(Ble,{srcdoc:m.srcdoc,page:m.page,onSelect:t,clipMode:n,onClipped:a,clipFailedText:s("reader.clipFailed")})]},m.page??0))}):l.jsxs("div",{className:"flex items-center justify-center gap-2 h-full min-h-[200px] text-sm text-ink-muted",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",s("reader.loading")]})}function Ble({srcdoc:e,page:t,onSelect:n,clipMode:a,onClipped:r,clipFailedText:s}){const o=D.useRef(null),u=D.useRef(null),[d,h]=D.useState(120),[m,p]=D.useState(null),[x,b]=D.useState(!1),y=()=>{const v=u.current,A=v?.contentDocument;if(!v||!A?.body)return;const T=A.body.scrollWidth||A.documentElement.scrollWidth,C=v.clientWidth;T>C+2&&(A.body.style.zoom=String(C/T)),h(Math.max(40,A.documentElement.scrollHeight+2)),A.addEventListener("mouseup",()=>{const I=v.contentWindow?.getSelection();if(!I||I.isCollapsed){n(null);return}const O=I.toString().replace(/\s+/g," ").trim();if(O.length<2)return;const _=I.getRangeAt(0).getBoundingClientRect(),S=v.getBoundingClientRect();n({text:O,page:t,x:S.left+_.left+_.width/2,y:S.top+_.bottom})})},w=v=>{const A=o.current.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(v.clientX-A.left)/A.width)),y:Math.min(1,Math.max(0,(v.clientY-A.top)/A.height))}},E=()=>{if(!m||x){p(null);return}const v=Math.min(m.x0,m.x1),A=Math.min(m.y0,m.y1),T=Math.abs(m.x1-m.x0),C=Math.abs(m.y1-m.y0);if(p(null),T<.02||C<.01)return;const I=u.current?.contentDocument;!I?.documentElement||!r||(b(!0),(async()=>{const{toCanvas:O}=await ft(async()=>{const{toCanvas:B}=await import("./index-BeoRn2gJ.js");return{toCanvas:B}},[]),_=await O(I.documentElement,{pixelRatio:2}),S=Math.floor(v*_.width),z=Math.floor(A*_.height),V=Math.max(1,Math.floor(T*_.width)),P=Math.max(1,Math.floor(C*_.height)),L=document.createElement("canvas");L.width=V,L.height=P,L.getContext("2d").drawImage(_,S,z,V,P,0,0,V,P);const Y=o.current.getBoundingClientRect(),q={left:Y.left+v*Y.width,top:Y.top+A*Y.height,width:T*Y.width,height:C*Y.height};r(t??1,[v,A,T,C],L.toDataURL("image/png"),q)})().catch(()=>We("error",s)).finally(()=>b(!1)))};return l.jsxs("div",{ref:o,className:"relative",children:[l.jsx("iframe",{ref:u,sandbox:"allow-same-origin",srcDoc:e,onLoad:y,style:{height:d},className:"w-full border-0 bg-white shadow-md rounded-sm","aria-label":t!=null?`p.${t}`:"document"}),a&&l.jsxs("div",{className:"absolute inset-0 cursor-crosshair",style:{zIndex:6},"data-clip-overlay":t??1,onMouseDown:v=>{v.preventDefault();const A=w(v);p({x0:A.x,y0:A.y,x1:A.x,y1:A.y})},onMouseMove:v=>{if(m){const A=w(v);p({...m,x1:A.x,y1:A.y})}},onMouseUp:E,onMouseLeave:()=>{m&&E()},children:[x&&l.jsx("div",{className:"absolute top-2 right-2 flex items-center gap-1.5 text-2xs text-warm bg-card/95 border border-line rounded-lg px-2 py-1 shadow-sm",children:l.jsx(nn,{size:11,strokeWidth:1.75,className:"animate-spin"})}),m&&l.jsx("div",{className:"absolute border-2 border-warm bg-warm/10 rounded-sm pointer-events-none",style:{left:`${Math.min(m.x0,m.x1)*100}%`,top:`${Math.min(m.y0,m.y1)*100}%`,width:`${Math.abs(m.x1-m.x0)*100}%`,height:`${Math.abs(m.y1-m.y0)*100}%`}})]})]})}let xb=null;function Hle(){return xb||(xb=Promise.all([ft(()=>import("./pdf-gh-BrLFn.js"),[]),ft(()=>import("./pdf.worker.min-C_APr3k7.js"),[])]).then(([e,t])=>(e.GlobalWorkerOptions.workerSrc=t.default,e))),xb}function Fle(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}const Ule=/<!--\s*tdag-page:(\d+)\s*-->/;function qle(e){const t=e.split(Ule),n=[];t[0].trim()&&n.push({page:null,md:t[0]});for(let a=1;a<t.length;a+=2)n.push({page:Number(t[a]),md:t[a+1]??""});return n.length>0?n:[{page:null,md:e}]}const bb=60,kT=new Map;function $le({onLocate:e}){const t=oe(a=>a.readerNodeId),n=se(a=>t?a.nodes.find(r=>r.id===t):void 0);return D.useEffect(()=>{t&&!n&&oe.getState().setReaderNodeId(null)},[t,n]),n?l.jsx(Wle,{node:n,onLocate:e},n.id):null}function Wle({node:e,onLocate:t}){const n=St(),a=e.data,r=a.stepKind==="file"||!a.stepKind&&(a.attachments??[]).some(ye=>ye.type==="application/pdf")?"file":a.stepKind==="link"?"link":"note",s=D.useMemo(()=>a.attachments??[],[a.attachments]),o=s.find(ye=>ye.type==="application/pdf"),u=s.find(ye=>ye.type==="text/html"),d=r==="link"?a.linkSnapshotHtml:void 0,h=D.useMemo(()=>d?{id:`link-snapshot-${e.id}`,name:a.linkTitle||a.linkUrl||"snapshot",type:"text/html",size:d.length,content:d}:null,[d,e.id,a.linkTitle,a.linkUrl]),m=D.useMemo(()=>s.filter(ye=>ye.type.startsWith("image/")),[s]),p=()=>oe.getState().setReaderNodeId(null),x=D.useMemo(()=>{if(o)return o.extractedText??"";if(r==="file"){const ye=s.filter(kt=>!kt.type.startsWith("image/")&&kt.type!=="application/pdf"),tt=ye.map(kt=>{const jt=kt.type==="text/html"?kt.extractedText??"":kt.content;return ye.length>1?`### ${kt.name}
|
|
661
661
|
|
|
@@ -671,7 +671,7 @@ ${_}`:O.question.trim();a([...n,{id:Tn(),text:S,at:new Date().toISOString(),from
|
|
|
671
671
|
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-3 text-sm text-ink resize-y focus:outline-none","data-mp-profile-text":!0}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1",children:n("mp.docHint")}),l.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[l.jsx("button",{onClick:()=>u(!1),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:n("common.cancel")}),l.jsx("button",{onClick:()=>{eW(e,r,n("mp.editedNote")),u(!1)},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white","data-mp-profile-save":!0,children:n("mp.save")})]})]}):d.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic",children:n("mp.docEmpty")}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed list-disc pl-5 max-w-[68ch]","data-mp-profile-lines":!0,children:d.map((h,m)=>l.jsx("li",{children:h},m))}),a.changelog.length>0&&l.jsxs("div",{className:"mt-3 pt-2 border-t border-dashed border-line-strong text-2xs text-ink-muted space-y-0.5",children:[l.jsx("div",{className:"text-ink-faint",children:n("mp.changelog")}),a.changelog.slice(-6).reverse().map((h,m)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:Fi(h.at)}),h.note]},m))]})]})}function AT({topicId:e,name:t,onClose:n,onChanged:a,onOpened:r}){const s=St(),[o,u]=D.useState(void 0),[d,h]=D.useState(null),[m,p]=D.useState(null),[x,b]=D.useState(null),[y,w]=D.useState(""),[E,v]=D.useState(null),A=D.useCallback(async()=>{const _=In();if(_)try{const[S,z]=await Promise.all([_.dossier(e),_.dossiers()]);u(S),v(z.find(V=>V.topicId===e)??null)}catch(S){p(fm(S))}},[e]);D.useEffect(()=>{A()},[A]);const T=async _=>{h(_),p(null);try{const S=_==="build"?await R2(e):_==="update"?await J8(e):await DW(e);u(S),await A(),a()}catch(S){p(fm(S))}finally{h(null)}},C=async()=>{if(x)try{const _=await RW(e,x,y.split(`
|
|
672
672
|
`));u(_),b(null),a()}catch(_){p(fm(_))}},I=async _=>{const S=o?.sources[_];!S||S.kind!=="turn"||await I2(S.open)&&r?.()},O=!!o?.builtAt&&!D2(o);return l.jsxs("div",{className:"border border-line rounded-xl bg-surface px-4 py-3 mt-3","data-mp-dossier":e,children:[l.jsxs("div",{className:"flex items-baseline gap-3 flex-wrap mb-2",children:[l.jsx("span",{className:"text-sm font-semibold text-ink",children:t}),l.jsx("span",{className:"text-2xs text-ink-faint",children:O?`${ve(s("mp.fromTurns"),{n:o.covered.length})} · ${ve(s("mp.updatedAt"),{d:Fi(o.updatedAt)})}`:s("mp.notBuilt")}),l.jsx("span",{className:"flex-1"}),d?l.jsxs("span",{className:"text-xs text-accent flex items-center gap-1",children:[l.jsx(nn,{size:12,className:"animate-spin"})," ",s("mp.building")]}):l.jsxs(l.Fragment,{children:[O?l.jsxs("button",{onClick:()=>{T("update")},disabled:!E||E.newTurns===0&&E.pending===0,className:"text-xs px-2.5 py-1 rounded-lg bg-accent text-white disabled:opacity-40 flex items-center gap-1","data-mp-dossier-update":!0,children:[l.jsx(or,{size:12,strokeWidth:1.75})," ",E?.newTurns?ve(s("mp.updateN"),{n:E.newTurns}):s("mp.update")]}):l.jsxs("button",{onClick:()=>{T("build")},className:"text-xs px-2.5 py-1 rounded-lg bg-accent text-white flex items-center gap-1","data-mp-dossier-build":!0,children:[l.jsx(Hl,{size:12,strokeWidth:1.75})," ",s("mp.build")]}),O&&l.jsx("button",{onClick:()=>{T("rebuild")},className:"text-xs px-2.5 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("mp.rebuild")})]}),l.jsx("button",{onClick:n,className:"text-xs px-2 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.close")})]}),m&&l.jsx("p",{className:"text-2xs text-red-500 mb-2","data-mp-dossier-error":!0,children:m}),o===void 0?l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"}):l.jsxs("div",{className:"grid gap-3 max-w-[72ch]",children:[v0.map(_=>{const S=o?.sections[_]??[];return!S.length&&O&&x!==_?l.jsxs("div",{className:"group",children:[l.jsxs("div",{className:"text-2xs font-semibold text-ink-faint tracking-wide flex items-center gap-2",children:[s(jm[_]),l.jsx("button",{onClick:()=>{b(_),w("")},className:"opacity-0 group-hover:opacity-100 text-accent font-normal",children:s("mp.edit")})]}),l.jsx("p",{className:"text-xs text-ink-faint italic",children:"—"})]},_):!S.length&&!O?null:l.jsxs("div",{className:"group","data-mp-dossier-section":_,children:[l.jsxs("div",{className:"text-2xs font-semibold text-ink-faint tracking-wide flex items-center gap-2",children:[s(jm[_]),x!==_&&l.jsx("button",{onClick:()=>{b(_),w(S.map(z=>z.text).join(`
|
|
673
673
|
`))},className:"opacity-0 group-hover:opacity-100 text-accent font-normal",children:s("mp.edit")})]}),x===_?l.jsxs("div",{children:[l.jsx("textarea",{value:y,onChange:z=>w(z.target.value),rows:Math.max(3,y.split(`
|
|
674
|
-
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-2 text-sm text-ink resize-y focus:outline-none"}),l.jsxs("div",{className:"flex justify-end gap-2 mt-1",children:[l.jsx("button",{onClick:()=>b(null),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.cancel")}),l.jsx("button",{onClick:()=>{C()},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white",children:s("mp.save")})]})]}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed space-y-0.5",children:S.map((z,V)=>l.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-1.5",children:[l.jsx("span",{children:z.text}),z.src.map(P=>{const L=o.sources[P];return L?l.jsxs("button",{onClick:()=>{I(P)},title:`${L.title} · ${s("mp.sourceOpen")}`,className:"inline-flex items-center gap-0.5 font-mono text-2xs text-ink-faint border border-line rounded px-1 hover:text-accent hover:border-accent/40","data-mp-source":!0,children:[L.runner," · ",Fi(L.at),L.kind==="turn"&&l.jsx(pp,{size:9})]},P):P.startsWith("filed:")?l.jsx("span",{className:"font-mono text-2xs text-ink-faint border border-line rounded px-1",children:s("mp.filedTag")},P):null})]},V))})]},_)}),!O&&!d&&l.jsx("p",{className:"text-xs text-ink-faint italic",children:E?.labeled?ve(s("mp.buildHint"),{n:E.labeled}):s("dossier.nothingToRead")}),!!o?.pending.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2","data-mp-dossier-pending":!0,children:[l.jsxs("div",{className:"text-ink-faint mb-0.5",children:[s("mp.pendingList")," · ",o.pending.length]}),o.pending.map(_=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:Fi(_.at)}),_.text]},_.id))]}),!!o?.changelog.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2",children:[l.jsx("div",{className:"text-ink-faint mb-0.5",children:s("mp.changelog")}),o.changelog.slice(-6).reverse().map((_,S)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:Fi(_.at)}),_.note]},S))]})]})]})}function Zle({query:e,onOpened:t}){const n=St(),a=oe(j=>j.recallEnabled),r=oe(j=>j.setRecallEnabled),s=oe(j=>j.memoryEnabled),o=oe(j=>j.setMemoryEnabled),u=oe(j=>j.profile),d=oe(j=>j.memoryInbox),[h,m]=D.useState(null),[p,x]=D.useState(null),[b,y]=D.useState(null),[w,E]=D.useState(null),[v,A]=D.useState(!1),[T,C]=D.useState(!1),[I,O]=D.useState(!1),[_,S]=D.useState(null),z=wp();D.useEffect(()=>{C2()},[]);const[V,P]=D.useState(0),L=D.useCallback(()=>P(j=>j+1),[]);D.useEffect(()=>{const j=In();if(!j)return;let $=!0;return(async()=>{try{const[X,Q]=await Promise.all([j.dossiers(),j.topics()]);if(!$)return;x(X),y(Q);for(const F of X)F.built&&F.pending>=CW&&!ST.has(F.topicId)&&(ST.add(F.topicId),J8(F.topicId).then(()=>P(G=>G+1)).catch(()=>{}))}catch{$&&x([])}})(),()=>{$=!1}},[V]),D.useEffect(()=>{!I||_!==null||In()?.memories().then(j=>S(j.length)).catch(()=>S(0))},[I,_]);const Y=D.useMemo(()=>({preferences:vr(u.preferences),identity:vr(u.identity)}),[u]),q=async(j,$)=>{const X=In(),Q=d.find(F=>F.id===j);if(!(!X||!Q))try{await X.dossierPending($,{text:Q.text,...Q.from?{from:Q.from}:{}}),kE(j),We("success",ve(n("mp.filed"),{name:b?.topics.find(F=>F.id===$)?.name??""})),L()}catch(F){We("error",fm(F))}},B=e.trim().length>=2;return l.jsxs("div",{"data-memory-page":!0,children:[B&&l.jsx(yM,{phrase:e,onOpened:t,dossiers:p??[],onOpenDossier:j=>E(j)}),B&&w&&l.jsx(AT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t}),!B&&l.jsxs("div",{className:"max-w-[860px]",children:[l.jsxs("section",{className:"mb-6","data-mp-section":"settings",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.settings")}),l.jsxs("div",{className:"border-t border-line",children:[l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.recallOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.recallOnHint")})]}),l.jsx(TT,{on:a,onChange:r,testId:"recall"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.memoryOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.memoryOnHint")})]}),l.jsx(TT,{on:s,onChange:o,testId:"memory"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.judgeRow")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.judgeRowHint")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0,"judge"),className:"text-xs text-accent hover:underline","data-judge-configure":!0,children:n("mp.open")})]})]})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"you",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.you")}),l.jsx("div",{className:"border-t border-line",children:["preferences","identity"].map(j=>l.jsxs("button",{onClick:()=>m(h===j?null:j),className:`w-full grid grid-cols-[110px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${h===j?"bg-wash":""}`,"data-mp-doc":j,children:[l.jsx("span",{className:"text-sm text-ink font-medium",children:n(j==="preferences"?"mp.preferences":"mp.identity")}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:Y[j].length?Y[j].join(" · "):n("mp.docEmpty")}),l.jsx("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:u[j].updatedAt?ve(n("mp.updatedAt"),{d:Fi(u[j].updatedAt)}):""})]},j))}),h&&l.jsx(Qle,{kind:h,onClose:()=>m(null)})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"projects",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint",children:n("mp.projects")}),l.jsx("span",{className:"flex-1"}),z&&b&&b.topics.length>0&&l.jsxs("span",{className:"text-2xs text-ink-faint","data-mp-label-state":!0,children:[ve(n("mp.labelState"),{n:b.labeled,m:b.turns}),b.status.running?` · ${ve(n("topics.running"),{a:b.status.done,b:b.status.total})}`:""]}),z&&l.jsxs("button",{onClick:()=>A(j=>!j),className:"text-xs text-ink-muted hover:text-ink flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-wash","data-mp-edit-topics":!0,children:[l.jsx(GA,{size:12,strokeWidth:1.75})," ",n("mp.editTopics")]})]}),z?l.jsxs(l.Fragment,{children:[v&&l.jsx("div",{className:"border border-line rounded-xl px-4 pb-3 mb-3 bg-surface",children:l.jsx(Xle,{onOpened:t,onChanged:L})}),l.jsx("div",{className:"border-t border-line",children:p===null?l.jsx("div",{className:"py-3",children:l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"})}):p.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic py-2","data-mp-no-topics":!0,children:n("mp.noTopics")}):p.map(j=>l.jsxs("button",{onClick:()=>E(w===j.topicId?null:j.topicId),className:`w-full grid grid-cols-[150px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${w===j.topicId?"bg-wash":""}`,"data-mp-project":j.topicId,children:[l.jsx("span",{className:"text-sm text-ink font-medium truncate",children:j.name}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:j.built?j.lead:l.jsxs("span",{className:"text-ink-faint italic",children:[n("mp.notBuilt"),j.labeled?` · ${ve(n("mp.labeledTurns"),{n:j.labeled})}`:""]})}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap flex items-center gap-1.5",children:[j.built&&j.newTurns>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-warm/60 text-warm bg-warm/10",children:ve(n("mp.newTurns"),{n:j.newTurns})}),j.pending>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-accent/40 text-accent bg-accent/10",children:ve(n("mp.pending"),{n:j.pending})}),j.built&&ve(n("mp.updatedAt"),{d:Fi(j.updatedAt)})]})]},j.topicId))}),w&&!B&&l.jsx(AT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t})]}):l.jsx("p",{className:"text-xs text-ink-faint italic border-t border-line pt-2",children:n("mp.needIndex")}),d.length>0&&l.jsx(NT,{label:ve(n("mp.inbox"),{n:d.length}),open:T,onToggle:()=>C(j=>!j),testId:"inbox",children:l.jsx("div",{className:"space-y-1.5",children:d.map(j=>l.jsxs("div",{className:"flex items-center gap-2 text-xs","data-mp-inbox-item":!0,children:[l.jsx("span",{className:"flex-1 min-w-0 text-ink truncate",children:j.text}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:[j.from?`${j.from} · `:"",Fi(j.at)]}),z&&!!b?.topics.length&&l.jsxs("select",{defaultValue:"",onChange:$=>{$.target.value&&q(j.id,$.target.value)},className:"text-2xs bg-wash border border-line rounded-md px-1.5 py-0.5","data-mp-inbox-file":!0,children:[l.jsx("option",{value:"",children:n("mp.fileTo")}),b.topics.map($=>l.jsx("option",{value:$.id,children:$.name},$.id))]}),l.jsx("button",{onClick:()=>kE(j.id),className:"text-2xs text-ink-faint hover:text-red-500 px-1.5 py-0.5 rounded",children:n("mp.discard")})]},j.id))})})]}),z&&l.jsxs("section",{className:"mb-4","data-mp-section":"sources",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.sources")}),l.jsxs(NT,{label:ve(n("mp.sourcesN"),{n:1+(_??0)}),open:I,onToggle:()=>O(j=>!j),testId:"sources",children:[l.jsxs("div",{className:"text-xs text-ink-muted mb-3 flex items-center gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:n("mp.index")}),l.jsx("span",{children:b?ve(n("mp.indexLine"),{n:b.turns}):"…"})]}),l.jsx(Kle,{})]})]})]})]})}const _M="thoughtdag.atlas.watermark",Uo=e=>`${e.rootKey}:${e.rel}`;function $v(){try{return JSON.parse(localStorage.getItem(_M)??"{}")}catch{return{}}}function tp(e){localStorage.setItem(_M,JSON.stringify(e))}function Jle(e){const t=$v(),n=new Map;if(Object.keys(t).length===0)return tp(Object.fromEntries(e.map(s=>[Uo(s),{mtime:s.mtime,size:s.size}]))),n;const a=new Set(e.map(Uo));let r=!1;for(const s of Object.keys(t))a.has(s)||(delete t[s],r=!0);for(const s of e){const o=t[Uo(s)];o?(s.size>o.size||s.mtime>o.mtime+1e3)&&n.set(Uo(s),{kind:"updated",deltaSize:Math.max(0,s.size-o.size)}):n.set(Uo(s),{kind:"new",deltaSize:s.size})}return r&&tp(t),n}function ece(e){const t=$v();t[Uo(e)]={mtime:e.mtime,size:e.size},tp(t)}function tce(e){const t=$v();for(const n of e)t[Uo(n)]={mtime:n.mtime,size:n.size};tp(t)}const jc=Uo,yb=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),CT=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`,nce={time:(e,t)=>t.mtime-e.mtime,name:(e,t)=>e.title.localeCompare(t.title),size:(e,t)=>t.size-e.size,runner:(e,t)=>e.runner.localeCompare(t.runner)||t.mtime-e.mtime};function ace({roots:e,counts:t,onChanged:n,onClose:a}){const r=St(),s=M2(),o={"claude-projects":"Claude Code","codex-sessions":"Codex","dsh-sessions":"DeepSeek Harness","pi-sessions":"Pi"},[u,d]=D.useState(null),h=()=>{window.desktopSessions?.commandsStatus?.().then(d).catch(()=>{})};D.useEffect(h,[]);const m={"claude-code":"Claude Code",codex:"Codex",dsh:"DeepSeek Harness",pi:"Pi"},p=x=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line last:border-b-0","data-atlas-source":x.key,children:[l.jsx("input",{type:"checkbox",checked:!s.has(x.key),disabled:!x.exists,onChange:b=>{yW(x.key,!b.target.checked),n()},className:"shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink",children:o[x.key]??x.path.split("/").filter(Boolean).pop()}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:x.path})]}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:x.exists?t.get(x.key)??0:r("atlas.rootMissing")}),!x.builtin&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",onClick:()=>{window.desktopSessions.removeRoot(x.key).then(n)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x.key);return l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:a,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[440px] max-h-[80%] overflow-y-auto",onClick:x=>x.stopPropagation(),"data-atlas-sources-dialog":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r("atlas.sourcesTitle")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r("atlas.sourcesHint")})]}),e.filter(x=>x.builtin).map(p),u&&Object.values(u).some(x=>x.state!=="unavailable")&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-4 pt-3 pb-1.5 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.handoffTitle")}),Object.entries(u).filter(([,x])=>x.state!=="unavailable").map(([x,b])=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line","data-atlas-handoff":x,"data-handoff-state":b.state,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink flex items-center gap-2",children:[m[x]??x,l.jsx("code",{className:"text-2xs bg-wash border border-line rounded px-1.5 py-px font-mono",children:b.invoke})]}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:r(b.state==="installed"?"atlas.handoffOn":b.state==="outdated"?"atlas.handoffOutdated":"atlas.handoffOff")})]}),b.state!=="installed"&&l.jsx("button",{className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-2.5 py-1 rounded-lg transition-colors shrink-0","data-handoff-install":!0,onClick:()=>{(async()=>{const{confirmDialog:y}=await ft(async()=>{const{confirmDialog:v}=await Promise.resolve().then(()=>uu);return{confirmDialog:v}},void 0);if(!await y({title:Te("atlas.handoffEnableTitle"),message:ve(Te("confirm.installCommand"),{path:b.dest}),confirmLabel:Te(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}))return;const E=await window.desktopSessions.commandsInstall(x);E.ok?We("success",ve(Te("atlas.handoffInstalled"),{cmd:b.invoke}),8e3):We("error",E.error??"install failed"),h()})()},children:r(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}),(b.state==="installed"||b.state==="outdated")&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",title:r("atlas.handoffRemove"),"data-handoff-remove":!0,onClick:()=>{window.desktopSessions.commandsRemove(x).then(h)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x))]}),e.filter(x=>!x.builtin).map(p),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[l.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors",children:[l.jsx(or,{size:13,strokeWidth:1.75})," ",r("atlas.autoDetect")]}),l.jsxs("button",{onClick:()=>{window.desktopSessions.addRoot().then(x=>{x&&n()})},className:"flex items-center gap-1.5 text-sm text-accent border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-add-dir":!0,children:[l.jsx(qA,{size:13,strokeWidth:1.75})," ",r("atlas.addDir")]})]})]})})}function Wv({onClose:e,onSwitched:t,focusSessionId:n,initialTab:a}){const r=St(),[s,o]=D.useState(a??"sessions"),u=!!In(),d=sn(ie=>ie.projects),h=sn(ie=>ie.projects.find(Be=>Be.id===ie.activeId)?.sourceSession?.sessionId),m=!!window.desktopSessions,[p,x]=D.useState(null),[b,y]=D.useState([]),[w,E]=D.useState(!1),[v,A]=D.useState(window.desktopSessions?null:"canvases"),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(null),[z,V]=D.useState(new Map),[P,L]=D.useState(new Map),[Y,q]=D.useState(new Map),[B,j]=D.useState(!1),$=ie=>`${ie.rootKey}|${ie.rel}`,X=ie=>q(Be=>{const Je=new Map(Be),Ht=$(ie);return Je.has(Ht)?Je.delete(Ht):Je.set(Ht,ie),Je}),Q=ie=>d.find(Be=>ly(Be).includes(ie)),[F,G]=D.useState(""),[J,K]=D.useState(new Set),[ee,ue]=D.useState("time"),[pe,be]=D.useState(!1),[ae,xe]=D.useState(!1),[Ce,ze]=D.useState(new Map),[Ie,Fe]=D.useState(null);D.useEffect(()=>{window.desktopSessions?.openTargets().then(Fe).catch(()=>{})},[]);const Ee=D.useMemo(()=>new Map((Ie?.apps??[]).map(ie=>[ie.runner,ie.name])),[Ie]),Me=async()=>{E(!0);try{y(await window.desktopSessions?.roots().catch(()=>[])??[]);const ie=await vW();if(x(ie),ze(Jle(ie)),window.desktopSessions?.codexThreads?.().then(Be=>{Be&&(V(new Map(Be.filter(Je=>Je.name&&Je.sessionId).map(Je=>[Je.sessionId,Je.name]))),L(new Map(Be.filter(Je=>Je.forkedFromId&&Je.sessionId).map(Je=>[Je.sessionId,Je.forkedFromId]))))}).catch(()=>{}),n){const Be=ie.find(Je=>Je.sessionId===n);Be&&A(Be.cwd??"")}}finally{E(!1)}};D.useEffect(()=>{Me()},[]),D.useEffect(()=>{let ie=!1;const Be=()=>{ie||w||(ie=!0,setTimeout(()=>{ie=!1,Me()},2e3))};return window.addEventListener("td:sessions-changed",Be),()=>window.removeEventListener("td:sessions-changed",Be)},[w]);const De=D.useCallback(ie=>z.get(ie.sessionId)??ie.title,[z]),bt=D.useMemo(()=>(p??[]).filter(ie=>!J.has(ie.runner)&&(ae||!ie.subagent)&&(!pe||Ce.has(jc(ie)))&&(!F.trim()||De(ie).toLowerCase().includes(F.trim().toLowerCase()))),[p,J,F,pe,Ce,ae,De]),mt=D.useMemo(()=>wW(bt),[bt]),Ye=D.useMemo(()=>[...new Set((p??[]).map(ie=>ie.runner))].sort(),[p]),at=D.useMemo(()=>{const ie=new Map;for(const Be of p??[])ie.set(Be.rootKey,(ie.get(Be.rootKey)??0)+1);return ie},[p]),rt=v==="canvases"?null:mt.find(ie=>(ie.cwd??"")===(v??mt[0]?.cwd??""))??mt[0]??null,Ue=D.useMemo(()=>{if(!rt)return[];const ie=ee==="name"?(Be,Je)=>De(Be).localeCompare(De(Je)):nce[ee];return[...rt.cards].sort(ie)},[rt,ee,De]),Ct=ie=>{ece(ie),ze(Be=>{const Je=new Map(Be);return Je.delete(jc(ie)),Je})},ot=async ie=>{if(!T){C(ie.rel),Ct(ie);try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-CdxNcIpd.js");return{streamRunnerConversation:Rt}},[]),{importOrAppendConversation:Je,shellSessionReader:Ht}=await ft(async()=>{const{importOrAppendConversation:Rt,shellSessionReader:en}=await import("./canonical-4rZrwQLF.js");return{importOrAppendConversation:Rt,shellSessionReader:en}},[]),Kt=await Uc(await Be(Ht(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p),qt=await Je(Kt);if(!qt)throw new Error(Te("handoff.notASession"));qt.kind==="appended"?We("success",ve(Te("atlas.appended"),{n:qt.turns}),9e3):qt.kind==="mounted"?We("success",ve(Te(qt.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:qt.turns}),9e3):qt.kind==="opened"?We("info",Te("atlas.upToDate"),6e3):We("success",ve(Te("toast.importedChats"),{n:1,m:qt.nodeCount}),9e3),e(),t()}catch(Be){We("error",ve(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},It=async ie=>{if(!(T||Y.size<2)){C("__merge__");try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-CdxNcIpd.js");return{streamRunnerConversation:Rt}},[]),{mergeSessionsIntoProject:Je,shellSessionReader:Ht}=await ft(async()=>{const{mergeSessionsIntoProject:Rt,shellSessionReader:en}=await import("./canonical-4rZrwQLF.js");return{mergeSessionsIntoProject:Rt,shellSessionReader:en}},[]),Kt=[];for(const Rt of Y.values())Kt.push(await Uc(await Be(Ht(Rt.rootKey,Rt.rel)),Rt.rootKey,Rt.rel,p)),Ct(Rt);const qt=await Je(Kt,ie);if(!qt)throw new Error(Te("handoff.notASession"));We("success",ve(Te("atlas.merged"),{n:qt.mounted}),1e4),qt.skipped>0&&We("info",ve(Te("atlas.mergeSkippedInfo"),{n:qt.skipped}),8e3),q(new Map),e(),t()}catch(Be){We("error",ve(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},_e=async ie=>{const Be=sn.getState().projects.find(Kt=>Kt.sourceSession?.sessionId===ie.sessionId);if(!Be||T)return;const{confirmDialog:Je}=await ft(async()=>{const{confirmDialog:Kt}=await Promise.resolve().then(()=>uu);return{confirmDialog:Kt}},void 0);if(await Je({title:Te("confirm.recastTitle"),message:ve(Te("confirm.recast"),{name:Be.name}),confirmLabel:Te("confirm.recastTitle"),danger:!0})){C(ie.rel);try{const{streamRunnerConversation:Kt}=await ft(async()=>{const{streamRunnerConversation:zn}=await import("./index-CdxNcIpd.js");return{streamRunnerConversation:zn}},[]),{importOrAppendConversation:qt,shellSessionReader:Rt}=await ft(async()=>{const{importOrAppendConversation:zn,shellSessionReader:tr}=await import("./canonical-4rZrwQLF.js");return{importOrAppendConversation:zn,shellSessionReader:tr}},[]),en=await Uc(await Kt(Rt(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p);if(!en)throw new Error(Te("handoff.notASession"));const{deleteProject:Gt}=await ft(async()=>{const{deleteProject:zn}=await Promise.resolve().then(()=>Sa);return{deleteProject:zn}},void 0);if(await Gt(Be.id),!await qt(en))throw new Error(Te("handoff.notASession"));We("success",Te("atlas.recastDone"),8e3),e(),t()}catch(Kt){We("error",ve(Te("atlas.parseFailed"),{msg:Kt instanceof Error?Kt.message:String(Kt)}))}finally{C(null)}}},Ze=async(ie,Be)=>{const Je=await window.desktopSessions.openInCli(ie.runner,ie.cwd,ie.sessionId,Be).catch(()=>({opened:!1,via:"",command:""}));Je.opened&&Je.via==="app"?(await navigator.clipboard.writeText(ie.sessionId).catch(()=>{}),We("success",Te("atlas.appOpened"),9e3)):Je.opened?We("success",Te("atlas.opened")):Je.command&&(await navigator.clipboard.writeText(Je.command).catch(()=>{}),We("info",Te("atlas.cmdCopied"),9e3))};return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6","data-session-atlas":!0,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-2xl w-full max-w-[980px] h-[min(680px,90vh)] flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-base font-semibold text-ink",children:r(s==="memory"?"memory.managerTitle":"atlas.title")}),l.jsx("div",{className:"text-xs text-ink-muted mt-0.5",children:r(s==="memory"?"mp.subtitle":"atlas.subtitle")}),Ce.size>0&&l.jsxs("div",{className:"text-xs mt-1 flex items-center gap-2","data-atlas-changes":!0,children:[l.jsx("span",{className:"text-accent",children:ve(r("atlas.changesSummary"),{n:[...Ce.values()].filter(ie=>ie.kind==="new").length,m:[...Ce.values()].filter(ie=>ie.kind==="updated").length})}),l.jsx("button",{className:"text-ink-faint hover:text-ink underline decoration-dotted transition-colors",onClick:()=>{tce(p??[]),ze(new Map)},"data-atlas-mark-all":!0,children:r("atlas.markAllSeen")})]})]}),m&&Ie&&Ie.terminals.length>0&&l.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-ink-muted border border-line rounded-lg px-2.5 py-1.5 cursor-pointer",title:r("atlas.terminalChoice"),children:[l.jsx(Go,{size:14,strokeWidth:1.75}),l.jsxs("select",{value:Ie.prefs.terminal,onChange:ie=>{const Be=ie.target.value;if(Be==="__add__"){window.desktopSessions?.addTerminal().then(()=>window.desktopSessions?.openTargets().then(Fe));return}window.desktopSessions?.setOpenPrefs({terminal:Be}).then(Je=>Fe(Ht=>Ht&&{...Ht,prefs:Je}))},className:"bg-transparent focus:outline-none text-sm text-ink cursor-pointer","data-atlas-terminal-select":!0,children:[Ie.terminals.map(ie=>l.jsx("option",{value:ie.id,children:ie.name},ie.id)),Ie.canAddCustom&&l.jsx("option",{value:"__add__",children:r("atlas.otherTerminal")})]})]}),m&&l.jsxs("button",{onClick:()=>O(!0),hidden:s==="memory",className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-sources":!0,children:[l.jsx(qA,{size:14,strokeWidth:1.75})," ",r("atlas.sources")]}),m&&s!=="memory"&&l.jsxs("button",{onClick:()=>{Me()},disabled:w,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors disabled:opacity-60","data-atlas-refresh":!0,children:[w?l.jsx(nn,{size:14,className:"animate-spin"}):l.jsx(or,{size:14,strokeWidth:1.75}),r(w?"atlas.scanning":"atlas.refresh")]}),l.jsx("button",{onClick:e,className:"text-ink-faint hover:text-ink p-1.5 rounded-lg hover:bg-wash transition-colors","data-atlas-close":!0,children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 border-b border-line shrink-0","data-atlas-tabs":!0,children:[l.jsx("div",{className:"flex items-center bg-wash rounded-lg p-0.5 shrink-0",children:["sessions","memory"].map(ie=>l.jsx("button",{onClick:()=>o(ie),className:`text-xs px-3 py-1 rounded-md transition-colors ${s===ie?"bg-card text-ink shadow-sm font-medium":"text-ink-muted hover:text-ink"}`,"data-atlas-tab":ie,"aria-pressed":s===ie,children:r(ie==="sessions"?"atlas.tabSessions":"atlas.tabMemory")},ie))}),u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2.5 py-1 bg-card flex-1 max-w-[520px]",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.searchPlaceholder"),className:"text-sm bg-transparent focus:outline-none w-full text-ink placeholder:text-ink-faint","data-atlas-search":!0})]})]}),s==="memory"?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4","data-atlas-memory":!0,children:l.jsx(Zle,{query:u?F:"",onOpened:()=>{e(),t()}})}):l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"w-[260px] border-r border-line overflow-y-auto py-2 shrink-0",children:[l.jsx("div",{className:"px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.recent")}),d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).slice(0,6).map(ie=>l.jsxs("button",{onClick:()=>{e(),Ui(ie.id).then(t)},className:"w-full text-left px-4 py-1.5 flex items-center gap-2 text-ink hover:bg-wash transition-colors","data-atlas-recent":ie.id,children:[ie.sourceSession?.sessionId?l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner}):l.jsx(Yk,{size:13,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name})]},ie.id)),l.jsx("div",{className:"border-t border-line mt-2 pt-2 px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.folders")}),!m&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.webNoScan")}),m&&p===null&&l.jsxs("div",{className:"px-4 py-2 text-sm text-ink-faint flex items-center gap-2",children:[l.jsx(nn,{size:14,className:"animate-spin"})," ",r("atlas.scanning")]}),m&&p!==null&&mt.length===0&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.empty")}),mt.map(ie=>{const Be=ie.cwd??"",Je=v!=="canvases"&&rt===ie;return l.jsxs("button",{onClick:()=>A(Be),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${Je?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-folder":ie.name||"unfiled",children:[Je?l.jsx(cu,{size:15,strokeWidth:1.75,className:"shrink-0"}):l.jsx(SF,{size:15,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name||r("atlas.unfiled")}),(()=>{const Ht=ie.cards.filter(Kt=>Ce.has(jc(Kt))).length;return Ht>0?l.jsxs("span",{className:"text-2xs text-accent shrink-0","data-atlas-folder-changes":!0,children:["+",Ht]}):null})(),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ie.cards.length})]},Be)}),l.jsx("div",{className:"border-t border-line mt-2 pt-2",children:l.jsxs("button",{onClick:()=>A("canvases"),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${v==="canvases"?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-canvases":!0,children:[l.jsx(Yk,{size:15,strokeWidth:1.75,className:"shrink-0"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:r("atlas.myCanvases")}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:d.length})]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&F.trim().length>=2&&l.jsx(yM,{phrase:F,onOpened:()=>{e(),t()}}),v==="canvases"?l.jsxs("div",{className:"space-y-1.5",children:[d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("div",{className:"group flex items-center flex-wrap gap-2 border border-line rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer",onClick:()=>{e(),Ui(ie.id).then(t)},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium truncate",children:ie.name}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-1.5",children:[l.jsx("span",{children:yb(ie.updatedAt)}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px",children:ie.sourceSession.runner})]})]}),l.jsx("button",{title:r("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1.5 rounded transition-all shrink-0",onClick:Be=>{Be.stopPropagation(),Bm(ie.id,!0)},"data-atlas-archive":!0,children:l.jsx(el,{size:15,strokeWidth:1.75})}),!!ie.sourceSession&&ly(ie).length>0&&l.jsxs("div",{className:"w-full basis-full text-2xs text-ink-faint font-mono flex flex-wrap gap-x-3 gap-y-0.5 pt-1","data-atlas-cluster":!0,children:[ie.sourceSession.sessionId&&l.jsxs("span",{children:["◉ ",ie.sourceSession.runner," ",ie.sourceSession.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:ie.sourceSession.importedCount})]}),(ie.sourceSession.chapters??[]).map(Be=>l.jsxs("span",{children:["↳ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId)),(ie.sourceSession.branches??[]).map(Be=>l.jsxs("span",{children:["⑂ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId))]})]},ie.id)),d.some(ie=>ie.archived)&&l.jsxs("details",{className:"pt-2","data-atlas-archived-group":!0,children:[l.jsx("summary",{className:"text-2xs uppercase tracking-wide text-ink-faint cursor-pointer px-1 py-1",children:ve(r("atlas.archivedGroup"),{n:d.filter(ie=>ie.archived).length})}),l.jsx("div",{className:"space-y-1.5 mt-1.5",children:d.filter(ie=>ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("button",{title:r("atlas.restoreOpen"),onClick:()=>{Bm(ie.id,!1).then(()=>{e(),Ui(ie.id).then(t)})},className:"w-full text-left border border-dashed border-line rounded-xl px-4 py-2.5 hover:bg-wash transition-colors opacity-70 hover:opacity-100","data-atlas-archived-item":!0,children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:ie.name}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner})]}),l.jsx("div",{className:"text-2xs text-ink-faint mt-0.5",children:yb(ie.updatedAt)})]},ie.id))})]})]}):l.jsxs(l.Fragment,{children:[(p?.length??0)>0&&l.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[!u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2 py-1 bg-card",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.filterTitle"),className:"text-sm bg-transparent focus:outline-none w-[150px] text-ink placeholder:text-ink-faint","data-atlas-filter":!0})]}),Ye.map(ie=>l.jsx("button",{onClick:()=>K(Be=>{const Je=new Set(Be);return Je.has(ie)?Je.delete(ie):Je.add(ie),Je}),className:`text-2xs font-mono border rounded-lg px-2 py-1 transition-colors ${J.has(ie)?"border-line text-ink-faint line-through":"border-accent/40 text-accent bg-accent/5"}`,"data-atlas-runner-toggle":ie,children:ie},ie)),Ce.size>0&&l.jsx("button",{onClick:()=>be(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${pe?"border-accent text-white bg-accent":"border-line text-ink-muted hover:text-ink"}`,"data-atlas-only-changed":!0,children:r("atlas.onlyChanged")}),(p??[]).some(ie=>ie.subagent)&&l.jsx("button",{onClick:()=>xe(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${ae?"border-accent text-accent bg-accent/5":"border-line text-ink-faint hover:text-ink"}`,"data-atlas-show-sub":!0,children:r("atlas.showSub")}),l.jsxs("button",{onClick:()=>ue(ie=>({time:"name",name:"size",size:"runner",runner:"time"})[ie]),className:"ml-auto flex items-center gap-1.5 text-2xs text-ink-muted hover:text-ink border border-line rounded-lg px-2 py-1 hover:bg-wash transition-colors","data-atlas-sort":!0,children:[l.jsx(kH,{size:12,strokeWidth:1.75}),r(`atlas.sort${ee[0].toUpperCase()}${ee.slice(1)}`)]})]}),rt?l.jsxs(l.Fragment,{children:[rt.cwd&&l.jsxs("div",{className:"text-2xs text-ink-faint mb-3 truncate",children:[rt.cwd," · ",ve(r("atlas.sessions"),{n:rt.cards.length})]}),l.jsx("div",{className:"space-y-1.5",children:Ue.map(ie=>l.jsxs("div",{className:`group border rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer flex items-center gap-3 ${Y.has($(ie))?"border-accent/60 bg-accent/5":"border-line"}`,onClick:()=>{ot(ie)},"data-atlas-session":ie.sessionId,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:De(ie)}),P.has(ie.sessionId)&&l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0 font-mono",title:`⑂ ${P.get(ie.sessionId)}`,"data-atlas-fork":!0,children:"⑂"}),Ce.get(jc(ie))?.kind==="new"&&l.jsx("span",{className:"text-2xs text-white bg-accent rounded px-1 py-px shrink-0","data-atlas-badge":"new",children:r("atlas.badgeNew")}),Ce.get(jc(ie))?.kind==="updated"&&l.jsxs("span",{className:"text-2xs text-accent border border-accent/40 rounded px-1 py-px shrink-0","data-atlas-badge":"updated",children:["+",CT(Ce.get(jc(ie)).deltaSize)]}),ie.sessionId===h?l.jsx("span",{className:"text-2xs text-white bg-ink rounded px-1 py-px shrink-0","data-atlas-badge":"current",children:r("atlas.currentOpen")}):(()=>{const Be=Q(ie.sessionId);return Be?l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0",title:Be.name,"data-atlas-badge":"canvas",children:r("atlas.onCanvas")}):null})()]}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-2",children:[l.jsx("span",{className:"border border-line rounded px-1 py-px font-mono",children:ie.runner}),l.jsx("span",{children:yb(ie.mtime)}),l.jsx("span",{children:CT(ie.size)})]})]}),T===ie.rel?l.jsx(nn,{size:16,className:"animate-spin text-accent shrink-0"}):l.jsxs("div",{className:`${Y.has($(ie))?"":"opacity-0 group-hover:opacity-100"} transition-opacity flex items-center gap-1 shrink-0`,children:[!Q(ie.sessionId)&&!!ie.sessionId&&l.jsx("button",{title:r("atlas.pickForMerge"),className:`p-1.5 rounded transition-colors ${Y.has($(ie))?"text-accent":"text-ink-faint hover:text-accent"}`,onClick:Be=>{Be.stopPropagation(),X(ie)},"data-atlas-pick":Y.has($(ie))?"on":"off",children:Y.has($(ie))?l.jsx(LU,{size:16,strokeWidth:1.75}):l.jsx(U0,{size:16,strokeWidth:1.75})}),l.jsx("span",{title:r("atlas.import"),className:"text-ink-faint hover:text-accent p-1.5",children:l.jsx(BF,{size:16,strokeWidth:1.75})}),d.some(Be=>Be.sourceSession?.sessionId===ie.sessionId)&&l.jsx("button",{title:r("atlas.recast"),className:"text-ink-faint hover:text-red-500 p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),_e(ie)},"data-atlas-recast":!0,children:l.jsx($A,{size:16,strokeWidth:1.75})}),!Q(ie.sessionId)&&l.jsx("button",{title:r("atlas.mountTo"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),S(ie)},"data-atlas-mount":!0,children:l.jsx(Gi,{size:16,strokeWidth:1.75})}),Ee.has(ie.runner)&&l.jsx("button",{title:ve(r("atlas.openApp"),{name:Ee.get(ie.runner)}),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"app")},"data-atlas-open-app":!0,children:l.jsx(bH,{size:16,strokeWidth:1.75})}),l.jsx("button",{title:r("atlas.openTerminal"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"terminal")},"data-atlas-open-cli":!0,children:l.jsx(Go,{size:16,strokeWidth:1.75})})]})]},ie.rel))})]}):l.jsx("div",{className:"py-16 text-center text-sm text-ink-faint",children:p===null?r("atlas.scanning"):p.length>0?r("atlas.filteredOut"):r("atlas.empty")})]})]})]}),Y.size>=2&&!B&&l.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-10 bg-surface border border-line rounded-xl shadow-lg px-4 py-2.5 flex items-center gap-3","data-atlas-merge-bar":!0,children:[l.jsx("span",{className:"text-xs text-ink-muted whitespace-nowrap",children:ve(r("atlas.mergeSelected"),{n:Y.size})}),T==="__merge__"?l.jsx(nn,{size:15,className:"animate-spin text-accent"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"text-xs bg-accent hover:bg-accent-strong text-white font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>{It()},"data-atlas-merge-new":!0,children:r("atlas.mergeNew")}),l.jsx("button",{className:"text-xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>j(!0),"data-atlas-merge-into":!0,children:r("atlas.mergeInto")})]}),l.jsx("button",{className:"text-ink-faint hover:text-ink p-1",onClick:()=>q(new Map),title:r("common.cancel"),children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),(_||B)&&l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:()=>{S(null),j(!1)},children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[400px] max-h-[70%] overflow-y-auto",onClick:ie=>ie.stopPropagation(),"data-atlas-mount-picker":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r(B?"atlas.mergeInto":"atlas.mountTo")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r(B?"atlas.mergeSelected":"atlas.mountHint").replace("{n}",String(Y.size))})]}),d.filter(ie=>!ie.archived&&ie.kind!=="paradigm").sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsx("button",{className:"w-full text-left px-4 py-2.5 text-sm text-ink hover:bg-wash transition-colors border-b border-line last:border-b-0",onClick:()=>{if(B){j(!1),It(ie.id);return}const Be=_;S(null),(async()=>{C(Be.rel);try{const{streamRunnerConversation:Je}=await ft(async()=>{const{streamRunnerConversation:en}=await import("./index-CdxNcIpd.js");return{streamRunnerConversation:en}},[]),{mountConversationToProject:Ht,shellSessionReader:Kt}=await ft(async()=>{const{mountConversationToProject:en,shellSessionReader:Gt}=await import("./canonical-4rZrwQLF.js");return{mountConversationToProject:en,shellSessionReader:Gt}},[]),qt=await Uc(await Je(Kt(Be.rootKey,Be.rel)),Be.rootKey,Be.rel,p),Rt=await Ht(qt,ie.id);if(!Rt)throw new Error(Te("handoff.notASession"));We("success",ve(Te("atlas.mountedChapter"),{n:Rt.kind==="mounted"||Rt.kind==="appended"?Rt.turns:0}),9e3),e(),t()}catch(Je){We("error",ve(Te("atlas.parseFailed"),{msg:Je instanceof Error?Je.message:String(Je)}))}finally{C(null)}})()},children:ie.name},ie.id))]})}),I&&l.jsx(ace,{roots:b,counts:at,onChanged:()=>{Me()},onClose:()=>O(!1)})]})}),document.body)}function rce(){const e=St(),t=oe(a=>!!a.harnessHost?.bar);if(!I$||t)return null;const n=()=>window.parent.postMessage({source:"dsh-thoughtdag",type:"td:close"},window.location.origin);return l.jsxs("div",{className:"bg-card/90 backdrop-blur border border-line rounded-xl p-0.5 shadow-sm flex items-center",role:"group","aria-label":"view switch","data-harness-view-switch":!0,children:[l.jsx("button",{type:"button",onClick:n,className:"h-8 px-3 rounded-[10px] text-xs font-semibold text-ink-muted hover:bg-wash hover:text-ink transition-colors whitespace-nowrap","data-view":"dialog","aria-pressed":!1,children:e("harness.viewChat")}),l.jsx("button",{type:"button",className:"h-8 px-3 rounded-[10px] text-xs font-semibold bg-ink text-card whitespace-nowrap cursor-default","data-view":"map","aria-pressed":!0,children:e("harness.viewMap")})]})}function sce({conversations:e,onClose:t,onDone:n}){const a=St(),[r,s]=D.useState(new Set),[o,u]=D.useState(!1),d=p=>{s(x=>{const b=new Set(x);return b.has(p)?b.delete(p):b.add(p),b})},h=r.size===e.length,m=async()=>{r.size===0||o||(u(!0),await hG([...r].sort((p,x)=>p-x).map(p=>e[p])),u(!1),n())};return l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:t,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-full max-w-lg max-h-[80vh] flex flex-col",onClick:p=>p.stopPropagation(),children:[l.jsxs("div",{className:"px-6 py-4 border-b border-line flex items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-base font-semibold text-ink",children:a("import.title")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1 leading-relaxed",children:a("import.subtitle")})]}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0 mt-0.5",children:l.jsx(cn,{size:16,strokeWidth:1.75})})]}),l.jsx("div",{className:"px-6 py-2 border-b border-line/60",children:l.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-muted cursor-pointer select-none py-1",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:()=>s(h?new Set:new Set(e.map((p,x)=>x))),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5"}),a("import.selectAll"),l.jsx("span",{className:"ml-auto text-2xs text-ink-faint uppercase tracking-wider",children:e[0]?.source})]})}),l.jsx("ul",{className:"flex-1 overflow-y-auto py-1",children:e.map((p,x)=>l.jsx("li",{children:l.jsxs("label",{className:"flex items-center gap-3 px-6 py-2 hover:bg-wash transition-colors cursor-pointer select-none",children:[l.jsx("input",{type:"checkbox",checked:r.has(x),onChange:()=>d(x),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5 shrink-0"}),l.jsx(UA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"text-sm text-ink truncate flex-1",children:p.title}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ve(a("import.messages"),{n:p.messageCount})})]})},x))}),l.jsxs("div",{className:"px-6 py-4 border-t border-line flex justify-end gap-2",children:[l.jsx("button",{onClick:t,className:"text-xs text-ink-muted hover:text-ink px-4 py-2 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")}),l.jsx("button",{onClick:()=>{m()},disabled:r.size===0||o,className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors disabled:opacity-30",children:o?"…":ve(a("import.confirm"),{n:r.size})})]})]})})}function ice(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return Te("switcher.justNow");if(n<60)return ve(Te("switcher.minAgo"),{n});const a=Math.floor(n/60);if(a<24)return ve(Te("switcher.hourAgo"),{n:a});const r=Math.floor(a/24);return r<30?ve(Te("switcher.dayAgo"),{n:r}):new Date(e).toLocaleDateString(Da.getState().lang==="zh"?"zh-CN":"en-US")}function oce({onSwitched:e}){const t=St(),n=sn(S=>S.projects),a=sn(S=>S.activeId),r=sn(S=>S.switching),s=n.find(S=>S.id===a)?.kind==="paradigm",[o,u]=D.useState(!1),[d,h]=D.useState(null),[m,p]=D.useState(!1),[x,b]=D.useState(void 0),[y,w]=D.useState(null),[E,v]=D.useState(""),A=D.useRef(null),T=D.useRef(null),C=n.find(S=>S.id===a),I=n.filter(S=>!S.archived).sort((S,z)=>z.updatedAt-S.updatedAt).slice(0,7),O=async S=>{const{canvasUniqueness:z}=await ft(async()=>{const{canvasUniqueness:Y}=await import("./canonical-4rZrwQLF.js");return{canvasUniqueness:Y}},[]),V=await z(S.id),P=V==="native"?"confirm.deleteNative":V==="diverged-mirror"?"confirm.deleteDiverged":"confirm.deletePristine";await ai({title:Te("confirm.deleteCanvasTitle"),message:ve(Te(P),{name:S.name}),confirmLabel:Te("common.delete"),danger:V!=="pristine-mirror"})&&L7(S.id).then(e)};D.useEffect(()=>{if(!o)return;const S=z=>{T.current?.contains(z.target)||u(!1)};return window.addEventListener("mousedown",S),()=>window.removeEventListener("mousedown",S)},[o]);const _=async S=>{u(!1),await Ui(S),e(),ft(()=>import("./canonical-4rZrwQLF.js"),[]).then(z=>z.unsubscribeOrphanedSessions()),ft(()=>Promise.resolve().then(()=>W8),void 0).then(z=>z.sweepRecentSessions())};return l.jsxs("div",{ref:T,className:"absolute top-4 left-4 z-20",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{onClick:()=>u(!o),disabled:r,className:"bg-card/90 backdrop-blur border border-line rounded-xl px-3.5 py-2 shadow-sm hover:bg-wash transition-colors flex items-center gap-2 text-sm text-ink max-w-[240px] disabled:opacity-60",children:[r?l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin shrink-0 text-accent"}):s?l.jsx(iF,{size:16,strokeWidth:1.75,className:"shrink-0 text-accent"}):l.jsx(cu,{size:16,strokeWidth:1.75,className:"shrink-0 text-ink-muted"}),l.jsx("span",{className:"truncate font-medium",children:C?.name??"…"}),l.jsx(cr,{size:14,strokeWidth:1.75,className:"shrink-0 text-ink-faint"})]}),l.jsx(rce,{}),!!C?.sourceSession?.sessionId&&(()=>{const S=Rm.size>0&&!Rm.has(C.sourceSession.sessionId);return l.jsxs("button",{title:S?Te("switcher.mirrorBadgeGone"):ve(Te("switcher.mirrorBadge"),{runner:C.sourceSession.runner}),onClick:()=>{b(C.sourceSession.sessionId),p(!0)},className:`bg-card/90 backdrop-blur border border-line rounded-xl px-2 py-2 shadow-sm hover:bg-wash transition-colors text-2xs font-mono flex items-center gap-1 ${S?"text-ink-faint/50 line-through decoration-1":"text-ink-faint hover:text-accent"}`,"data-twin-badge":S?"unreachable":"live",children:["⇄ ",C.sourceSession.runner]})})()]}),o&&l.jsxs("div",{className:"mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1.5 w-[320px] animate-fade-in",children:[l.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:I.map(S=>l.jsx("div",{className:`group flex items-center gap-1 px-3 py-2 hover:bg-wash cursor-pointer transition-colors ${S.id===a?"bg-accent/5":""}`,onClick:()=>{y!==S.id&&S.id!==a&&_(S.id)},children:y===S.id?l.jsx("input",{autoFocus:!0,value:E,onChange:z=>v(z.target.value),onClick:z=>z.stopPropagation(),onKeyDown:z=>{z.key==="Enter"&&!lr(z)&&E.trim()&&(j7(S.id,E.trim()),w(null)),z.key==="Escape"&&w(null)},onBlur:()=>w(null),className:"flex-1 text-sm text-ink border border-accent/40 rounded-lg px-2 py-1 bg-surface focus:outline-none"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:`text-sm truncate ${S.id===a?"text-accent font-medium":"text-ink"}`,children:S.name}),l.jsxs("div",{className:"text-2xs text-ink-faint flex items-center gap-1.5",children:[l.jsx("span",{children:ice(S.updatedAt)}),!!S.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px","data-mirror-mark":!0,children:S.sourceSession.runner})]})]}),l.jsx("button",{title:t("switcher.rename"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-ink p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),w(S.id),v(S.name)},children:l.jsx(Gl,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("common.delete"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-red-500 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),O(S)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),Bm(S.id,!0).then(e)},"data-archive-canvas":!0,children:l.jsx(el,{size:14,strokeWidth:1.75})})]})},S.id))}),l.jsxs("div",{className:"border-t border-line mt-1 pt-1",children:[l.jsxs("button",{onClick:()=>{u(!1),Tp().then(e)},className:"w-full text-left px-3 py-2 text-sm text-accent hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(F0,{size:15,strokeWidth:1.75})," ",t("switcher.newCanvas")]}),l.jsxs("button",{onClick:()=>A.current?.click(),className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(KU,{size:15,strokeWidth:1.75})," ",t("switcher.importBackup")]}),l.jsxs("button",{onClick:()=>{u(!1),p(!0)},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-open-atlas":!0,children:[l.jsx(ZF,{size:15,strokeWidth:1.75})," ",t("switcher.allCanvases")]}),window.desktop&&l.jsxs("button",{onClick:()=>{u(!1),window.desktop.checkForUpdates()},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-check-updates":!0,children:[l.jsx(or,{size:15,strokeWidth:1.75})," ",t("update.checkMenu"),l.jsxs("span",{className:"ml-auto text-2xs text-ink-faint",children:["v",new URLSearchParams(window.location.search).get("dv")]})]}),l.jsx("input",{ref:A,type:"file",accept:".json,.jsonl,application/json",className:"hidden",onChange:S=>{const z=S.target.files?.[0];z&&uG(z).then(V=>{V.kind==="own"&&V.ok?(u(!1),e()):V.kind==="chat"&&(u(!1),h(V.conversations))}).catch(V=>{We("error",ve(Te("toast.importFailedGeneric"),{msg:V instanceof Error?V.message:String(V)}))}),S.target.value=""}})]})]}),d&&l.jsx(sce,{conversations:d,onClose:()=>h(null),onDone:()=>{h(null),e()}}),m&&l.jsx(Wv,{onClose:()=>{p(!1),b(void 0)},onSwitched:e,focusSessionId:x})]})}const lce="JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUiA0IDAgUl0gL0NvdW50IDIgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvQ29udGVudHMgNSAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNyAwIFIgL0YyIDggMCBSID4+ID4+ID4+CmVuZG9iago0IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTk1IDg0Ml0gL0NvbnRlbnRzIDYgMCBSIC9SZXNvdXJjZXMgPDwgL0ZvbnQgPDwgL0YxIDcgMCBSIC9GMiA4IDAgUiA+PiA+PiA+PgplbmRvYmoKNSAwIG9iago8PCAvTGVuZ3RoIDExMTIgPj4Kc3RyZWFtCkJUCi9GMiAxOSBUZiAxIDAgMCAxIDY0IDcyNS4wIFRtIChXaHkgU2F2ZWQgQXJ0aWNsZXMgU3RheSBVbnJlYWQpIFRqCi9GMSAxMSBUZiAxIDAgMCAxIDY0IDcwOC4wIFRtIChBIHNob3J0IGJyaWVmIG9uIGRpZ2l0YWwgaG9hcmRpbmcgYW5kIHRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjIgMTMgVGYgMSAwIDAgMSA2NCA2NjkuMCBUbSAoMS4gVGhlIHBoZW5vbWVub24pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjUxLjUgVG0gKFJlYWQtaXQtbGF0ZXIgc2VydmljZXMgcmVwb3J0IHRoYXQgbW9zdCBzYXZlZCBpdGVtcyBhcmUgbmV2ZXIpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjM0LjAgVG0gKHJlb3BlbmVkLiBBY3Jvc3MgcHVibGlzaGVkIHVzYWdlIHN0dWRpZXMsIHRoZSBzaGFyZSBvZiBzYXZlZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA2MTYuNSBUbSAoYXJ0aWNsZXMgdGhhdCBnZXQgYSBzZWNvbmQgdmlzaXQgaXMgc21hbGwsIGFuZCBjb21wbGV0aW9uIHJhdGVzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU5OS4wIFRtIChhcmUgc21hbGxlciBzdGlsbC4gVGhlIGFyY2hpdmUgZ3Jvd3M7IHRoZSByZWFkaW5nIGRvZXMgbm90LikgVGoKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNTYwLjAgVG0gKDIuIFRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU0Mi41IFRtIChDb2xsZWN0aW5nIHByb2R1Y2VzIGFuIGltbWVkaWF0ZSBzZW5zZSBvZiBwcm9ncmVzcyB3aGlsZSB0aGUpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTI1LjAgVG0gKHVuZGVyc3RhbmRpbmcgaXQgcHJvbWlzZXMgaXMgZGVmZXJyZWQuIFNhdmluZyBhIHRleHQgZmVlbHMgbGlrZSkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1MDcuNSBUbSAoYSBmaXJzdCBzdGVwIG9mIHJlYWRpbmcgaXQsIGJ1dCBubyBwYXJ0IG9mIHRoZSByZWFkaW5nIGhhcykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA0OTAuMCBUbSAoaGFwcGVuZWQuKSBUagovRjIgMTEuNSBUZiAxIDAgMCAxIDY0IDQ3Mi41IFRtIChUaGUgYWN0IG9mIHNhdmluZyBpcyBtaXN0YWtlbiBmb3IgdGhlIGFjdCBvZiBsZWFybmluZy4pIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNiAwIG9iago8PCAvTGVuZ3RoIDkwOCA+PgpzdHJlYW0KQlQKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNzI1LjAgVG0gKDMuIFdoeSBpdCBwZXJzaXN0cykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA3MDcuNSBUbSAoVGhlIGNvc3RzIGFyZSBhc3ltbWV0cmljOiBzYXZpbmcgdGFrZXMgb25lIHNlY29uZCBhbmQgcGF5cyBvdXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjkwLjAgVG0gKGEgc21hbGwgcmV3YXJkIG5vdzsgcmVhZGluZyB0YWtlcyBhbiBob3VyIGFuZCBwYXlzIG91dCBsYXRlci4pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjcyLjUgVG0gKEhhYml0cyBmb2xsb3cgdGhlIGNoZWFwZXIgbG9vcCwgc28gbGlicmFyaWVzIGluZmxhdGUgYnkgZGVmYXVsdC4pIFRqCi9GMiAxMyBUZiAxIDAgMCAxIDY0IDYzMy41IFRtICg0LiBXaGF0IGhlbHBzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDYxNi4wIFRtIChJbnRlcnZlbnRpb25zIHRoYXQgd29yayBtb3ZlIHByb2Nlc3NpbmcgdG8gdGhlIG1vbWVudCBvZiBjYXB0dXJlOikgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1OTguNSBUbSAod3JpdGUgb25lIGxpbmUgaW4geW91ciBvd24gd29yZHMgYWJvdXQgd2h5IHRoZSBpdGVtIG1hdHRlcnMsIGFuZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1ODEuMCBUbSAoc2NoZWR1bGUgYSByZXZpZXcgcGFzcyBpbnN0ZWFkIG9mIHRydXN0aW5nIHRoZSBhcmNoaXZlIHRvKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU2My41IFRtIChyZXN1cmZhY2UgaXQuKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDUzMi4wIFRtIChBIHNtYWxsZXIgbGlicmFyeSB0aGF0IGdldHMgcHJvY2Vzc2VkIGJlYXRzIGEgY29tcGxldGUgb25lIHRoYXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTE0LjUgVG0gKGRvZXMgbm90LikgVGoKRVQKZW5kc3RyZWFtCmVuZG9iago3IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKOCAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EtQm9sZCA+PgplbmRvYmoKeHJlZgowIDkKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDEyMSAwMDAwMCBuIAowMDAwMDAwMjU3IDAwMDAwIG4gCjAwMDAwMDAzOTMgMDAwMDAgbiAKMDAwMDAwMTU1NyAwMDAwMCBuIAowMDAwMDAyNTE2IDAwMDAwIG4gCjAwMDAwMDI1ODYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA5IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoyNjYxCiUlRU9G",cce=`<!-- tdag-page:1 -->
|
|
674
|
+
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-2 text-sm text-ink resize-y focus:outline-none"}),l.jsxs("div",{className:"flex justify-end gap-2 mt-1",children:[l.jsx("button",{onClick:()=>b(null),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.cancel")}),l.jsx("button",{onClick:()=>{C()},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white",children:s("mp.save")})]})]}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed space-y-0.5",children:S.map((z,V)=>l.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-1.5",children:[l.jsx("span",{children:z.text}),z.src.map(P=>{const L=o.sources[P];return L?l.jsxs("button",{onClick:()=>{I(P)},title:`${L.title} · ${s("mp.sourceOpen")}`,className:"inline-flex items-center gap-0.5 font-mono text-2xs text-ink-faint border border-line rounded px-1 hover:text-accent hover:border-accent/40","data-mp-source":!0,children:[L.runner," · ",Fi(L.at),L.kind==="turn"&&l.jsx(pp,{size:9})]},P):P.startsWith("filed:")?l.jsx("span",{className:"font-mono text-2xs text-ink-faint border border-line rounded px-1",children:s("mp.filedTag")},P):null})]},V))})]},_)}),!O&&!d&&l.jsx("p",{className:"text-xs text-ink-faint italic",children:E?.labeled?ve(s("mp.buildHint"),{n:E.labeled}):s("dossier.nothingToRead")}),!!o?.pending.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2","data-mp-dossier-pending":!0,children:[l.jsxs("div",{className:"text-ink-faint mb-0.5",children:[s("mp.pendingList")," · ",o.pending.length]}),o.pending.map(_=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:Fi(_.at)}),_.text]},_.id))]}),!!o?.changelog.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2",children:[l.jsx("div",{className:"text-ink-faint mb-0.5",children:s("mp.changelog")}),o.changelog.slice(-6).reverse().map((_,S)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:Fi(_.at)}),_.note]},S))]})]})]})}function Zle({query:e,onOpened:t}){const n=St(),a=oe(j=>j.recallEnabled),r=oe(j=>j.setRecallEnabled),s=oe(j=>j.memoryEnabled),o=oe(j=>j.setMemoryEnabled),u=oe(j=>j.profile),d=oe(j=>j.memoryInbox),[h,m]=D.useState(null),[p,x]=D.useState(null),[b,y]=D.useState(null),[w,E]=D.useState(null),[v,A]=D.useState(!1),[T,C]=D.useState(!1),[I,O]=D.useState(!1),[_,S]=D.useState(null),z=wp();D.useEffect(()=>{C2()},[]);const[V,P]=D.useState(0),L=D.useCallback(()=>P(j=>j+1),[]);D.useEffect(()=>{const j=In();if(!j)return;let $=!0;return(async()=>{try{const[X,Q]=await Promise.all([j.dossiers(),j.topics()]);if(!$)return;x(X),y(Q);for(const F of X)F.built&&F.pending>=CW&&!ST.has(F.topicId)&&(ST.add(F.topicId),J8(F.topicId).then(()=>P(G=>G+1)).catch(()=>{}))}catch{$&&x([])}})(),()=>{$=!1}},[V]),D.useEffect(()=>{!I||_!==null||In()?.memories().then(j=>S(j.length)).catch(()=>S(0))},[I,_]);const Y=D.useMemo(()=>({preferences:vr(u.preferences),identity:vr(u.identity)}),[u]),q=async(j,$)=>{const X=In(),Q=d.find(F=>F.id===j);if(!(!X||!Q))try{await X.dossierPending($,{text:Q.text,...Q.from?{from:Q.from}:{}}),kE(j),We("success",ve(n("mp.filed"),{name:b?.topics.find(F=>F.id===$)?.name??""})),L()}catch(F){We("error",fm(F))}},B=e.trim().length>=2;return l.jsxs("div",{"data-memory-page":!0,children:[B&&l.jsx(yM,{phrase:e,onOpened:t,dossiers:p??[],onOpenDossier:j=>E(j)}),B&&w&&l.jsx(AT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t}),!B&&l.jsxs("div",{className:"max-w-[860px]",children:[l.jsxs("section",{className:"mb-6","data-mp-section":"settings",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.settings")}),l.jsxs("div",{className:"border-t border-line",children:[l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.recallOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.recallOnHint")})]}),l.jsx(TT,{on:a,onChange:r,testId:"recall"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.memoryOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.memoryOnHint")})]}),l.jsx(TT,{on:s,onChange:o,testId:"memory"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.judgeRow")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.judgeRowHint")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0,"judge"),className:"text-xs text-accent hover:underline","data-judge-configure":!0,children:n("mp.open")})]})]})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"you",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.you")}),l.jsx("div",{className:"border-t border-line",children:["preferences","identity"].map(j=>l.jsxs("button",{onClick:()=>m(h===j?null:j),className:`w-full grid grid-cols-[110px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${h===j?"bg-wash":""}`,"data-mp-doc":j,children:[l.jsx("span",{className:"text-sm text-ink font-medium",children:n(j==="preferences"?"mp.preferences":"mp.identity")}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:Y[j].length?Y[j].join(" · "):n("mp.docEmpty")}),l.jsx("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:u[j].updatedAt?ve(n("mp.updatedAt"),{d:Fi(u[j].updatedAt)}):""})]},j))}),h&&l.jsx(Qle,{kind:h,onClose:()=>m(null)})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"projects",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint",children:n("mp.projects")}),l.jsx("span",{className:"flex-1"}),z&&b&&b.topics.length>0&&l.jsxs("span",{className:"text-2xs text-ink-faint","data-mp-label-state":!0,children:[ve(n("mp.labelState"),{n:b.labeled,m:b.turns}),b.status.running?` · ${ve(n("topics.running"),{a:b.status.done,b:b.status.total})}`:""]}),z&&l.jsxs("button",{onClick:()=>A(j=>!j),className:"text-xs text-ink-muted hover:text-ink flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-wash","data-mp-edit-topics":!0,children:[l.jsx(GA,{size:12,strokeWidth:1.75})," ",n("mp.editTopics")]})]}),z?l.jsxs(l.Fragment,{children:[v&&l.jsx("div",{className:"border border-line rounded-xl px-4 pb-3 mb-3 bg-surface",children:l.jsx(Xle,{onOpened:t,onChanged:L})}),l.jsx("div",{className:"border-t border-line",children:p===null?l.jsx("div",{className:"py-3",children:l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"})}):p.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic py-2","data-mp-no-topics":!0,children:n("mp.noTopics")}):p.map(j=>l.jsxs("button",{onClick:()=>E(w===j.topicId?null:j.topicId),className:`w-full grid grid-cols-[150px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${w===j.topicId?"bg-wash":""}`,"data-mp-project":j.topicId,children:[l.jsx("span",{className:"text-sm text-ink font-medium truncate",children:j.name}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:j.built?j.lead:l.jsxs("span",{className:"text-ink-faint italic",children:[n("mp.notBuilt"),j.labeled?` · ${ve(n("mp.labeledTurns"),{n:j.labeled})}`:""]})}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap flex items-center gap-1.5",children:[j.built&&j.newTurns>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-warm/60 text-warm bg-warm/10",children:ve(n("mp.newTurns"),{n:j.newTurns})}),j.pending>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-accent/40 text-accent bg-accent/10",children:ve(n("mp.pending"),{n:j.pending})}),j.built&&ve(n("mp.updatedAt"),{d:Fi(j.updatedAt)})]})]},j.topicId))}),w&&!B&&l.jsx(AT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t})]}):l.jsx("p",{className:"text-xs text-ink-faint italic border-t border-line pt-2",children:n("mp.needIndex")}),d.length>0&&l.jsx(NT,{label:ve(n("mp.inbox"),{n:d.length}),open:T,onToggle:()=>C(j=>!j),testId:"inbox",children:l.jsx("div",{className:"space-y-1.5",children:d.map(j=>l.jsxs("div",{className:"flex items-center gap-2 text-xs","data-mp-inbox-item":!0,children:[l.jsx("span",{className:"flex-1 min-w-0 text-ink truncate",children:j.text}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:[j.from?`${j.from} · `:"",Fi(j.at)]}),z&&!!b?.topics.length&&l.jsxs("select",{defaultValue:"",onChange:$=>{$.target.value&&q(j.id,$.target.value)},className:"text-2xs bg-wash border border-line rounded-md px-1.5 py-0.5","data-mp-inbox-file":!0,children:[l.jsx("option",{value:"",children:n("mp.fileTo")}),b.topics.map($=>l.jsx("option",{value:$.id,children:$.name},$.id))]}),l.jsx("button",{onClick:()=>kE(j.id),className:"text-2xs text-ink-faint hover:text-red-500 px-1.5 py-0.5 rounded",children:n("mp.discard")})]},j.id))})})]}),z&&l.jsxs("section",{className:"mb-4","data-mp-section":"sources",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.sources")}),l.jsxs(NT,{label:ve(n("mp.sourcesN"),{n:1+(_??0)}),open:I,onToggle:()=>O(j=>!j),testId:"sources",children:[l.jsxs("div",{className:"text-xs text-ink-muted mb-3 flex items-center gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:n("mp.index")}),l.jsx("span",{children:b?ve(n("mp.indexLine"),{n:b.turns}):"…"})]}),l.jsx(Kle,{})]})]})]})]})}const _M="thoughtdag.atlas.watermark",Uo=e=>`${e.rootKey}:${e.rel}`;function $v(){try{return JSON.parse(localStorage.getItem(_M)??"{}")}catch{return{}}}function tp(e){localStorage.setItem(_M,JSON.stringify(e))}function Jle(e){const t=$v(),n=new Map;if(Object.keys(t).length===0)return tp(Object.fromEntries(e.map(s=>[Uo(s),{mtime:s.mtime,size:s.size}]))),n;const a=new Set(e.map(Uo));let r=!1;for(const s of Object.keys(t))a.has(s)||(delete t[s],r=!0);for(const s of e){const o=t[Uo(s)];o?(s.size>o.size||s.mtime>o.mtime+1e3)&&n.set(Uo(s),{kind:"updated",deltaSize:Math.max(0,s.size-o.size)}):n.set(Uo(s),{kind:"new",deltaSize:s.size})}return r&&tp(t),n}function ece(e){const t=$v();t[Uo(e)]={mtime:e.mtime,size:e.size},tp(t)}function tce(e){const t=$v();for(const n of e)t[Uo(n)]={mtime:n.mtime,size:n.size};tp(t)}const jc=Uo,yb=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),CT=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`,nce={time:(e,t)=>t.mtime-e.mtime,name:(e,t)=>e.title.localeCompare(t.title),size:(e,t)=>t.size-e.size,runner:(e,t)=>e.runner.localeCompare(t.runner)||t.mtime-e.mtime};function ace({roots:e,counts:t,onChanged:n,onClose:a}){const r=St(),s=M2(),o={"claude-projects":"Claude Code","codex-sessions":"Codex","dsh-sessions":"DeepSeek Harness","pi-sessions":"Pi"},[u,d]=D.useState(null),h=()=>{window.desktopSessions?.commandsStatus?.().then(d).catch(()=>{})};D.useEffect(h,[]);const m={"claude-code":"Claude Code",codex:"Codex",dsh:"DeepSeek Harness",pi:"Pi"},p=x=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line last:border-b-0","data-atlas-source":x.key,children:[l.jsx("input",{type:"checkbox",checked:!s.has(x.key),disabled:!x.exists,onChange:b=>{yW(x.key,!b.target.checked),n()},className:"shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink",children:o[x.key]??x.path.split("/").filter(Boolean).pop()}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:x.path})]}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:x.exists?t.get(x.key)??0:r("atlas.rootMissing")}),!x.builtin&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",onClick:()=>{window.desktopSessions.removeRoot(x.key).then(n)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x.key);return l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:a,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[440px] max-h-[80%] overflow-y-auto",onClick:x=>x.stopPropagation(),"data-atlas-sources-dialog":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r("atlas.sourcesTitle")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r("atlas.sourcesHint")})]}),e.filter(x=>x.builtin).map(p),u&&Object.values(u).some(x=>x.state!=="unavailable")&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-4 pt-3 pb-1.5 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.handoffTitle")}),Object.entries(u).filter(([,x])=>x.state!=="unavailable").map(([x,b])=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line","data-atlas-handoff":x,"data-handoff-state":b.state,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink flex items-center gap-2",children:[m[x]??x,l.jsx("code",{className:"text-2xs bg-wash border border-line rounded px-1.5 py-px font-mono",children:b.invoke})]}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:r(b.state==="installed"?"atlas.handoffOn":b.state==="outdated"?"atlas.handoffOutdated":"atlas.handoffOff")})]}),b.state!=="installed"&&l.jsx("button",{className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-2.5 py-1 rounded-lg transition-colors shrink-0","data-handoff-install":!0,onClick:()=>{(async()=>{const{confirmDialog:y}=await ft(async()=>{const{confirmDialog:v}=await Promise.resolve().then(()=>uu);return{confirmDialog:v}},void 0);if(!await y({title:Te("atlas.handoffEnableTitle"),message:ve(Te("confirm.installCommand"),{path:b.dest}),confirmLabel:Te(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}))return;const E=await window.desktopSessions.commandsInstall(x);E.ok?We("success",ve(Te("atlas.handoffInstalled"),{cmd:b.invoke}),8e3):We("error",E.error??"install failed"),h()})()},children:r(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}),(b.state==="installed"||b.state==="outdated")&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",title:r("atlas.handoffRemove"),"data-handoff-remove":!0,onClick:()=>{window.desktopSessions.commandsRemove(x).then(h)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x))]}),e.filter(x=>!x.builtin).map(p),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[l.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors",children:[l.jsx(or,{size:13,strokeWidth:1.75})," ",r("atlas.autoDetect")]}),l.jsxs("button",{onClick:()=>{window.desktopSessions.addRoot().then(x=>{x&&n()})},className:"flex items-center gap-1.5 text-sm text-accent border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-add-dir":!0,children:[l.jsx(qA,{size:13,strokeWidth:1.75})," ",r("atlas.addDir")]})]})]})})}function Wv({onClose:e,onSwitched:t,focusSessionId:n,initialTab:a}){const r=St(),[s,o]=D.useState(a??"sessions"),u=!!In(),d=sn(ie=>ie.projects),h=sn(ie=>ie.projects.find(Be=>Be.id===ie.activeId)?.sourceSession?.sessionId),m=!!window.desktopSessions,[p,x]=D.useState(null),[b,y]=D.useState([]),[w,E]=D.useState(!1),[v,A]=D.useState(window.desktopSessions?null:"canvases"),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(null),[z,V]=D.useState(new Map),[P,L]=D.useState(new Map),[Y,q]=D.useState(new Map),[B,j]=D.useState(!1),$=ie=>`${ie.rootKey}|${ie.rel}`,X=ie=>q(Be=>{const Je=new Map(Be),Ht=$(ie);return Je.has(Ht)?Je.delete(Ht):Je.set(Ht,ie),Je}),Q=ie=>d.find(Be=>ly(Be).includes(ie)),[F,G]=D.useState(""),[J,K]=D.useState(new Set),[ee,ue]=D.useState("time"),[pe,be]=D.useState(!1),[ae,xe]=D.useState(!1),[Ce,ze]=D.useState(new Map),[Ie,Fe]=D.useState(null);D.useEffect(()=>{window.desktopSessions?.openTargets().then(Fe).catch(()=>{})},[]);const Ee=D.useMemo(()=>new Map((Ie?.apps??[]).map(ie=>[ie.runner,ie.name])),[Ie]),Me=async()=>{E(!0);try{y(await window.desktopSessions?.roots().catch(()=>[])??[]);const ie=await vW();if(x(ie),ze(Jle(ie)),window.desktopSessions?.codexThreads?.().then(Be=>{Be&&(V(new Map(Be.filter(Je=>Je.name&&Je.sessionId).map(Je=>[Je.sessionId,Je.name]))),L(new Map(Be.filter(Je=>Je.forkedFromId&&Je.sessionId).map(Je=>[Je.sessionId,Je.forkedFromId]))))}).catch(()=>{}),n){const Be=ie.find(Je=>Je.sessionId===n);Be&&A(Be.cwd??"")}}finally{E(!1)}};D.useEffect(()=>{Me()},[]),D.useEffect(()=>{let ie=!1;const Be=()=>{ie||w||(ie=!0,setTimeout(()=>{ie=!1,Me()},2e3))};return window.addEventListener("td:sessions-changed",Be),()=>window.removeEventListener("td:sessions-changed",Be)},[w]);const De=D.useCallback(ie=>z.get(ie.sessionId)??ie.title,[z]),bt=D.useMemo(()=>(p??[]).filter(ie=>!J.has(ie.runner)&&(ae||!ie.subagent)&&(!pe||Ce.has(jc(ie)))&&(!F.trim()||De(ie).toLowerCase().includes(F.trim().toLowerCase()))),[p,J,F,pe,Ce,ae,De]),mt=D.useMemo(()=>wW(bt),[bt]),Ye=D.useMemo(()=>[...new Set((p??[]).map(ie=>ie.runner))].sort(),[p]),at=D.useMemo(()=>{const ie=new Map;for(const Be of p??[])ie.set(Be.rootKey,(ie.get(Be.rootKey)??0)+1);return ie},[p]),rt=v==="canvases"?null:mt.find(ie=>(ie.cwd??"")===(v??mt[0]?.cwd??""))??mt[0]??null,Ue=D.useMemo(()=>{if(!rt)return[];const ie=ee==="name"?(Be,Je)=>De(Be).localeCompare(De(Je)):nce[ee];return[...rt.cards].sort(ie)},[rt,ee,De]),Ct=ie=>{ece(ie),ze(Be=>{const Je=new Map(Be);return Je.delete(jc(ie)),Je})},ot=async ie=>{if(!T){C(ie.rel),Ct(ie);try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:Rt}},[]),{importOrAppendConversation:Je,shellSessionReader:Ht}=await ft(async()=>{const{importOrAppendConversation:Rt,shellSessionReader:en}=await import("./canonical-C3OufoVo.js");return{importOrAppendConversation:Rt,shellSessionReader:en}},[]),Kt=await Uc(await Be(Ht(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p),qt=await Je(Kt);if(!qt)throw new Error(Te("handoff.notASession"));qt.kind==="appended"?We("success",ve(Te("atlas.appended"),{n:qt.turns}),9e3):qt.kind==="mounted"?We("success",ve(Te(qt.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:qt.turns}),9e3):qt.kind==="opened"?We("info",Te("atlas.upToDate"),6e3):We("success",ve(Te("toast.importedChats"),{n:1,m:qt.nodeCount}),9e3),e(),t()}catch(Be){We("error",ve(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},It=async ie=>{if(!(T||Y.size<2)){C("__merge__");try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:Rt}},[]),{mergeSessionsIntoProject:Je,shellSessionReader:Ht}=await ft(async()=>{const{mergeSessionsIntoProject:Rt,shellSessionReader:en}=await import("./canonical-C3OufoVo.js");return{mergeSessionsIntoProject:Rt,shellSessionReader:en}},[]),Kt=[];for(const Rt of Y.values())Kt.push(await Uc(await Be(Ht(Rt.rootKey,Rt.rel)),Rt.rootKey,Rt.rel,p)),Ct(Rt);const qt=await Je(Kt,ie);if(!qt)throw new Error(Te("handoff.notASession"));We("success",ve(Te("atlas.merged"),{n:qt.mounted}),1e4),qt.skipped>0&&We("info",ve(Te("atlas.mergeSkippedInfo"),{n:qt.skipped}),8e3),q(new Map),e(),t()}catch(Be){We("error",ve(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},_e=async ie=>{const Be=sn.getState().projects.find(Kt=>Kt.sourceSession?.sessionId===ie.sessionId);if(!Be||T)return;const{confirmDialog:Je}=await ft(async()=>{const{confirmDialog:Kt}=await Promise.resolve().then(()=>uu);return{confirmDialog:Kt}},void 0);if(await Je({title:Te("confirm.recastTitle"),message:ve(Te("confirm.recast"),{name:Be.name}),confirmLabel:Te("confirm.recastTitle"),danger:!0})){C(ie.rel);try{const{streamRunnerConversation:Kt}=await ft(async()=>{const{streamRunnerConversation:zn}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:zn}},[]),{importOrAppendConversation:qt,shellSessionReader:Rt}=await ft(async()=>{const{importOrAppendConversation:zn,shellSessionReader:tr}=await import("./canonical-C3OufoVo.js");return{importOrAppendConversation:zn,shellSessionReader:tr}},[]),en=await Uc(await Kt(Rt(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p);if(!en)throw new Error(Te("handoff.notASession"));const{deleteProject:Gt}=await ft(async()=>{const{deleteProject:zn}=await Promise.resolve().then(()=>Sa);return{deleteProject:zn}},void 0);if(await Gt(Be.id),!await qt(en))throw new Error(Te("handoff.notASession"));We("success",Te("atlas.recastDone"),8e3),e(),t()}catch(Kt){We("error",ve(Te("atlas.parseFailed"),{msg:Kt instanceof Error?Kt.message:String(Kt)}))}finally{C(null)}}},Ze=async(ie,Be)=>{const Je=await window.desktopSessions.openInCli(ie.runner,ie.cwd,ie.sessionId,Be).catch(()=>({opened:!1,via:"",command:""}));Je.opened&&Je.via==="app"?(await navigator.clipboard.writeText(ie.sessionId).catch(()=>{}),We("success",Te("atlas.appOpened"),9e3)):Je.opened?We("success",Te("atlas.opened")):Je.command&&(await navigator.clipboard.writeText(Je.command).catch(()=>{}),We("info",Te("atlas.cmdCopied"),9e3))};return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6","data-session-atlas":!0,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-2xl w-full max-w-[980px] h-[min(680px,90vh)] flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-base font-semibold text-ink",children:r(s==="memory"?"memory.managerTitle":"atlas.title")}),l.jsx("div",{className:"text-xs text-ink-muted mt-0.5",children:r(s==="memory"?"mp.subtitle":"atlas.subtitle")}),Ce.size>0&&l.jsxs("div",{className:"text-xs mt-1 flex items-center gap-2","data-atlas-changes":!0,children:[l.jsx("span",{className:"text-accent",children:ve(r("atlas.changesSummary"),{n:[...Ce.values()].filter(ie=>ie.kind==="new").length,m:[...Ce.values()].filter(ie=>ie.kind==="updated").length})}),l.jsx("button",{className:"text-ink-faint hover:text-ink underline decoration-dotted transition-colors",onClick:()=>{tce(p??[]),ze(new Map)},"data-atlas-mark-all":!0,children:r("atlas.markAllSeen")})]})]}),m&&Ie&&Ie.terminals.length>0&&l.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-ink-muted border border-line rounded-lg px-2.5 py-1.5 cursor-pointer",title:r("atlas.terminalChoice"),children:[l.jsx(Go,{size:14,strokeWidth:1.75}),l.jsxs("select",{value:Ie.prefs.terminal,onChange:ie=>{const Be=ie.target.value;if(Be==="__add__"){window.desktopSessions?.addTerminal().then(()=>window.desktopSessions?.openTargets().then(Fe));return}window.desktopSessions?.setOpenPrefs({terminal:Be}).then(Je=>Fe(Ht=>Ht&&{...Ht,prefs:Je}))},className:"bg-transparent focus:outline-none text-sm text-ink cursor-pointer","data-atlas-terminal-select":!0,children:[Ie.terminals.map(ie=>l.jsx("option",{value:ie.id,children:ie.name},ie.id)),Ie.canAddCustom&&l.jsx("option",{value:"__add__",children:r("atlas.otherTerminal")})]})]}),m&&l.jsxs("button",{onClick:()=>O(!0),hidden:s==="memory",className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-sources":!0,children:[l.jsx(qA,{size:14,strokeWidth:1.75})," ",r("atlas.sources")]}),m&&s!=="memory"&&l.jsxs("button",{onClick:()=>{Me()},disabled:w,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors disabled:opacity-60","data-atlas-refresh":!0,children:[w?l.jsx(nn,{size:14,className:"animate-spin"}):l.jsx(or,{size:14,strokeWidth:1.75}),r(w?"atlas.scanning":"atlas.refresh")]}),l.jsx("button",{onClick:e,className:"text-ink-faint hover:text-ink p-1.5 rounded-lg hover:bg-wash transition-colors","data-atlas-close":!0,children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 border-b border-line shrink-0","data-atlas-tabs":!0,children:[l.jsx("div",{className:"flex items-center bg-wash rounded-lg p-0.5 shrink-0",children:["sessions","memory"].map(ie=>l.jsx("button",{onClick:()=>o(ie),className:`text-xs px-3 py-1 rounded-md transition-colors ${s===ie?"bg-card text-ink shadow-sm font-medium":"text-ink-muted hover:text-ink"}`,"data-atlas-tab":ie,"aria-pressed":s===ie,children:r(ie==="sessions"?"atlas.tabSessions":"atlas.tabMemory")},ie))}),u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2.5 py-1 bg-card flex-1 max-w-[520px]",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.searchPlaceholder"),className:"text-sm bg-transparent focus:outline-none w-full text-ink placeholder:text-ink-faint","data-atlas-search":!0})]})]}),s==="memory"?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4","data-atlas-memory":!0,children:l.jsx(Zle,{query:u?F:"",onOpened:()=>{e(),t()}})}):l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"w-[260px] border-r border-line overflow-y-auto py-2 shrink-0",children:[l.jsx("div",{className:"px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.recent")}),d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).slice(0,6).map(ie=>l.jsxs("button",{onClick:()=>{e(),Ui(ie.id).then(t)},className:"w-full text-left px-4 py-1.5 flex items-center gap-2 text-ink hover:bg-wash transition-colors","data-atlas-recent":ie.id,children:[ie.sourceSession?.sessionId?l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner}):l.jsx(Yk,{size:13,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name})]},ie.id)),l.jsx("div",{className:"border-t border-line mt-2 pt-2 px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.folders")}),!m&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.webNoScan")}),m&&p===null&&l.jsxs("div",{className:"px-4 py-2 text-sm text-ink-faint flex items-center gap-2",children:[l.jsx(nn,{size:14,className:"animate-spin"})," ",r("atlas.scanning")]}),m&&p!==null&&mt.length===0&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.empty")}),mt.map(ie=>{const Be=ie.cwd??"",Je=v!=="canvases"&&rt===ie;return l.jsxs("button",{onClick:()=>A(Be),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${Je?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-folder":ie.name||"unfiled",children:[Je?l.jsx(cu,{size:15,strokeWidth:1.75,className:"shrink-0"}):l.jsx(SF,{size:15,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name||r("atlas.unfiled")}),(()=>{const Ht=ie.cards.filter(Kt=>Ce.has(jc(Kt))).length;return Ht>0?l.jsxs("span",{className:"text-2xs text-accent shrink-0","data-atlas-folder-changes":!0,children:["+",Ht]}):null})(),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ie.cards.length})]},Be)}),l.jsx("div",{className:"border-t border-line mt-2 pt-2",children:l.jsxs("button",{onClick:()=>A("canvases"),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${v==="canvases"?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-canvases":!0,children:[l.jsx(Yk,{size:15,strokeWidth:1.75,className:"shrink-0"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:r("atlas.myCanvases")}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:d.length})]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&F.trim().length>=2&&l.jsx(yM,{phrase:F,onOpened:()=>{e(),t()}}),v==="canvases"?l.jsxs("div",{className:"space-y-1.5",children:[d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("div",{className:"group flex items-center flex-wrap gap-2 border border-line rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer",onClick:()=>{e(),Ui(ie.id).then(t)},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium truncate",children:ie.name}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-1.5",children:[l.jsx("span",{children:yb(ie.updatedAt)}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px",children:ie.sourceSession.runner})]})]}),l.jsx("button",{title:r("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1.5 rounded transition-all shrink-0",onClick:Be=>{Be.stopPropagation(),Bm(ie.id,!0)},"data-atlas-archive":!0,children:l.jsx(el,{size:15,strokeWidth:1.75})}),!!ie.sourceSession&&ly(ie).length>0&&l.jsxs("div",{className:"w-full basis-full text-2xs text-ink-faint font-mono flex flex-wrap gap-x-3 gap-y-0.5 pt-1","data-atlas-cluster":!0,children:[ie.sourceSession.sessionId&&l.jsxs("span",{children:["◉ ",ie.sourceSession.runner," ",ie.sourceSession.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:ie.sourceSession.importedCount})]}),(ie.sourceSession.chapters??[]).map(Be=>l.jsxs("span",{children:["↳ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId)),(ie.sourceSession.branches??[]).map(Be=>l.jsxs("span",{children:["⑂ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ve(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId))]})]},ie.id)),d.some(ie=>ie.archived)&&l.jsxs("details",{className:"pt-2","data-atlas-archived-group":!0,children:[l.jsx("summary",{className:"text-2xs uppercase tracking-wide text-ink-faint cursor-pointer px-1 py-1",children:ve(r("atlas.archivedGroup"),{n:d.filter(ie=>ie.archived).length})}),l.jsx("div",{className:"space-y-1.5 mt-1.5",children:d.filter(ie=>ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("button",{title:r("atlas.restoreOpen"),onClick:()=>{Bm(ie.id,!1).then(()=>{e(),Ui(ie.id).then(t)})},className:"w-full text-left border border-dashed border-line rounded-xl px-4 py-2.5 hover:bg-wash transition-colors opacity-70 hover:opacity-100","data-atlas-archived-item":!0,children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:ie.name}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner})]}),l.jsx("div",{className:"text-2xs text-ink-faint mt-0.5",children:yb(ie.updatedAt)})]},ie.id))})]})]}):l.jsxs(l.Fragment,{children:[(p?.length??0)>0&&l.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[!u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2 py-1 bg-card",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.filterTitle"),className:"text-sm bg-transparent focus:outline-none w-[150px] text-ink placeholder:text-ink-faint","data-atlas-filter":!0})]}),Ye.map(ie=>l.jsx("button",{onClick:()=>K(Be=>{const Je=new Set(Be);return Je.has(ie)?Je.delete(ie):Je.add(ie),Je}),className:`text-2xs font-mono border rounded-lg px-2 py-1 transition-colors ${J.has(ie)?"border-line text-ink-faint line-through":"border-accent/40 text-accent bg-accent/5"}`,"data-atlas-runner-toggle":ie,children:ie},ie)),Ce.size>0&&l.jsx("button",{onClick:()=>be(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${pe?"border-accent text-white bg-accent":"border-line text-ink-muted hover:text-ink"}`,"data-atlas-only-changed":!0,children:r("atlas.onlyChanged")}),(p??[]).some(ie=>ie.subagent)&&l.jsx("button",{onClick:()=>xe(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${ae?"border-accent text-accent bg-accent/5":"border-line text-ink-faint hover:text-ink"}`,"data-atlas-show-sub":!0,children:r("atlas.showSub")}),l.jsxs("button",{onClick:()=>ue(ie=>({time:"name",name:"size",size:"runner",runner:"time"})[ie]),className:"ml-auto flex items-center gap-1.5 text-2xs text-ink-muted hover:text-ink border border-line rounded-lg px-2 py-1 hover:bg-wash transition-colors","data-atlas-sort":!0,children:[l.jsx(kH,{size:12,strokeWidth:1.75}),r(`atlas.sort${ee[0].toUpperCase()}${ee.slice(1)}`)]})]}),rt?l.jsxs(l.Fragment,{children:[rt.cwd&&l.jsxs("div",{className:"text-2xs text-ink-faint mb-3 truncate",children:[rt.cwd," · ",ve(r("atlas.sessions"),{n:rt.cards.length})]}),l.jsx("div",{className:"space-y-1.5",children:Ue.map(ie=>l.jsxs("div",{className:`group border rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer flex items-center gap-3 ${Y.has($(ie))?"border-accent/60 bg-accent/5":"border-line"}`,onClick:()=>{ot(ie)},"data-atlas-session":ie.sessionId,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:De(ie)}),P.has(ie.sessionId)&&l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0 font-mono",title:`⑂ ${P.get(ie.sessionId)}`,"data-atlas-fork":!0,children:"⑂"}),Ce.get(jc(ie))?.kind==="new"&&l.jsx("span",{className:"text-2xs text-white bg-accent rounded px-1 py-px shrink-0","data-atlas-badge":"new",children:r("atlas.badgeNew")}),Ce.get(jc(ie))?.kind==="updated"&&l.jsxs("span",{className:"text-2xs text-accent border border-accent/40 rounded px-1 py-px shrink-0","data-atlas-badge":"updated",children:["+",CT(Ce.get(jc(ie)).deltaSize)]}),ie.sessionId===h?l.jsx("span",{className:"text-2xs text-white bg-ink rounded px-1 py-px shrink-0","data-atlas-badge":"current",children:r("atlas.currentOpen")}):(()=>{const Be=Q(ie.sessionId);return Be?l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0",title:Be.name,"data-atlas-badge":"canvas",children:r("atlas.onCanvas")}):null})()]}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-2",children:[l.jsx("span",{className:"border border-line rounded px-1 py-px font-mono",children:ie.runner}),l.jsx("span",{children:yb(ie.mtime)}),l.jsx("span",{children:CT(ie.size)})]})]}),T===ie.rel?l.jsx(nn,{size:16,className:"animate-spin text-accent shrink-0"}):l.jsxs("div",{className:`${Y.has($(ie))?"":"opacity-0 group-hover:opacity-100"} transition-opacity flex items-center gap-1 shrink-0`,children:[!Q(ie.sessionId)&&!!ie.sessionId&&l.jsx("button",{title:r("atlas.pickForMerge"),className:`p-1.5 rounded transition-colors ${Y.has($(ie))?"text-accent":"text-ink-faint hover:text-accent"}`,onClick:Be=>{Be.stopPropagation(),X(ie)},"data-atlas-pick":Y.has($(ie))?"on":"off",children:Y.has($(ie))?l.jsx(LU,{size:16,strokeWidth:1.75}):l.jsx(U0,{size:16,strokeWidth:1.75})}),l.jsx("span",{title:r("atlas.import"),className:"text-ink-faint hover:text-accent p-1.5",children:l.jsx(BF,{size:16,strokeWidth:1.75})}),d.some(Be=>Be.sourceSession?.sessionId===ie.sessionId)&&l.jsx("button",{title:r("atlas.recast"),className:"text-ink-faint hover:text-red-500 p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),_e(ie)},"data-atlas-recast":!0,children:l.jsx($A,{size:16,strokeWidth:1.75})}),!Q(ie.sessionId)&&l.jsx("button",{title:r("atlas.mountTo"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),S(ie)},"data-atlas-mount":!0,children:l.jsx(Gi,{size:16,strokeWidth:1.75})}),Ee.has(ie.runner)&&l.jsx("button",{title:ve(r("atlas.openApp"),{name:Ee.get(ie.runner)}),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"app")},"data-atlas-open-app":!0,children:l.jsx(bH,{size:16,strokeWidth:1.75})}),l.jsx("button",{title:r("atlas.openTerminal"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"terminal")},"data-atlas-open-cli":!0,children:l.jsx(Go,{size:16,strokeWidth:1.75})})]})]},ie.rel))})]}):l.jsx("div",{className:"py-16 text-center text-sm text-ink-faint",children:p===null?r("atlas.scanning"):p.length>0?r("atlas.filteredOut"):r("atlas.empty")})]})]})]}),Y.size>=2&&!B&&l.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-10 bg-surface border border-line rounded-xl shadow-lg px-4 py-2.5 flex items-center gap-3","data-atlas-merge-bar":!0,children:[l.jsx("span",{className:"text-xs text-ink-muted whitespace-nowrap",children:ve(r("atlas.mergeSelected"),{n:Y.size})}),T==="__merge__"?l.jsx(nn,{size:15,className:"animate-spin text-accent"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"text-xs bg-accent hover:bg-accent-strong text-white font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>{It()},"data-atlas-merge-new":!0,children:r("atlas.mergeNew")}),l.jsx("button",{className:"text-xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>j(!0),"data-atlas-merge-into":!0,children:r("atlas.mergeInto")})]}),l.jsx("button",{className:"text-ink-faint hover:text-ink p-1",onClick:()=>q(new Map),title:r("common.cancel"),children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),(_||B)&&l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:()=>{S(null),j(!1)},children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[400px] max-h-[70%] overflow-y-auto",onClick:ie=>ie.stopPropagation(),"data-atlas-mount-picker":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r(B?"atlas.mergeInto":"atlas.mountTo")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r(B?"atlas.mergeSelected":"atlas.mountHint").replace("{n}",String(Y.size))})]}),d.filter(ie=>!ie.archived&&ie.kind!=="paradigm").sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsx("button",{className:"w-full text-left px-4 py-2.5 text-sm text-ink hover:bg-wash transition-colors border-b border-line last:border-b-0",onClick:()=>{if(B){j(!1),It(ie.id);return}const Be=_;S(null),(async()=>{C(Be.rel);try{const{streamRunnerConversation:Je}=await ft(async()=>{const{streamRunnerConversation:en}=await import("./index-goc_KBNk.js");return{streamRunnerConversation:en}},[]),{mountConversationToProject:Ht,shellSessionReader:Kt}=await ft(async()=>{const{mountConversationToProject:en,shellSessionReader:Gt}=await import("./canonical-C3OufoVo.js");return{mountConversationToProject:en,shellSessionReader:Gt}},[]),qt=await Uc(await Je(Kt(Be.rootKey,Be.rel)),Be.rootKey,Be.rel,p),Rt=await Ht(qt,ie.id);if(!Rt)throw new Error(Te("handoff.notASession"));We("success",ve(Te("atlas.mountedChapter"),{n:Rt.kind==="mounted"||Rt.kind==="appended"?Rt.turns:0}),9e3),e(),t()}catch(Je){We("error",ve(Te("atlas.parseFailed"),{msg:Je instanceof Error?Je.message:String(Je)}))}finally{C(null)}})()},children:ie.name},ie.id))]})}),I&&l.jsx(ace,{roots:b,counts:at,onChanged:()=>{Me()},onClose:()=>O(!1)})]})}),document.body)}function rce(){const e=St(),t=oe(a=>!!a.harnessHost?.bar);if(!I$||t)return null;const n=()=>window.parent.postMessage({source:"dsh-thoughtdag",type:"td:close"},window.location.origin);return l.jsxs("div",{className:"bg-card/90 backdrop-blur border border-line rounded-xl p-0.5 shadow-sm flex items-center",role:"group","aria-label":"view switch","data-harness-view-switch":!0,children:[l.jsx("button",{type:"button",onClick:n,className:"h-8 px-3 rounded-[10px] text-xs font-semibold text-ink-muted hover:bg-wash hover:text-ink transition-colors whitespace-nowrap","data-view":"dialog","aria-pressed":!1,children:e("harness.viewChat")}),l.jsx("button",{type:"button",className:"h-8 px-3 rounded-[10px] text-xs font-semibold bg-ink text-card whitespace-nowrap cursor-default","data-view":"map","aria-pressed":!0,children:e("harness.viewMap")})]})}function sce({conversations:e,onClose:t,onDone:n}){const a=St(),[r,s]=D.useState(new Set),[o,u]=D.useState(!1),d=p=>{s(x=>{const b=new Set(x);return b.has(p)?b.delete(p):b.add(p),b})},h=r.size===e.length,m=async()=>{r.size===0||o||(u(!0),await hG([...r].sort((p,x)=>p-x).map(p=>e[p])),u(!1),n())};return l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:t,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-full max-w-lg max-h-[80vh] flex flex-col",onClick:p=>p.stopPropagation(),children:[l.jsxs("div",{className:"px-6 py-4 border-b border-line flex items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-base font-semibold text-ink",children:a("import.title")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1 leading-relaxed",children:a("import.subtitle")})]}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0 mt-0.5",children:l.jsx(cn,{size:16,strokeWidth:1.75})})]}),l.jsx("div",{className:"px-6 py-2 border-b border-line/60",children:l.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-muted cursor-pointer select-none py-1",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:()=>s(h?new Set:new Set(e.map((p,x)=>x))),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5"}),a("import.selectAll"),l.jsx("span",{className:"ml-auto text-2xs text-ink-faint uppercase tracking-wider",children:e[0]?.source})]})}),l.jsx("ul",{className:"flex-1 overflow-y-auto py-1",children:e.map((p,x)=>l.jsx("li",{children:l.jsxs("label",{className:"flex items-center gap-3 px-6 py-2 hover:bg-wash transition-colors cursor-pointer select-none",children:[l.jsx("input",{type:"checkbox",checked:r.has(x),onChange:()=>d(x),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5 shrink-0"}),l.jsx(UA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"text-sm text-ink truncate flex-1",children:p.title}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ve(a("import.messages"),{n:p.messageCount})})]})},x))}),l.jsxs("div",{className:"px-6 py-4 border-t border-line flex justify-end gap-2",children:[l.jsx("button",{onClick:t,className:"text-xs text-ink-muted hover:text-ink px-4 py-2 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")}),l.jsx("button",{onClick:()=>{m()},disabled:r.size===0||o,className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors disabled:opacity-30",children:o?"…":ve(a("import.confirm"),{n:r.size})})]})]})})}function ice(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return Te("switcher.justNow");if(n<60)return ve(Te("switcher.minAgo"),{n});const a=Math.floor(n/60);if(a<24)return ve(Te("switcher.hourAgo"),{n:a});const r=Math.floor(a/24);return r<30?ve(Te("switcher.dayAgo"),{n:r}):new Date(e).toLocaleDateString(Da.getState().lang==="zh"?"zh-CN":"en-US")}function oce({onSwitched:e}){const t=St(),n=sn(S=>S.projects),a=sn(S=>S.activeId),r=sn(S=>S.switching),s=n.find(S=>S.id===a)?.kind==="paradigm",[o,u]=D.useState(!1),[d,h]=D.useState(null),[m,p]=D.useState(!1),[x,b]=D.useState(void 0),[y,w]=D.useState(null),[E,v]=D.useState(""),A=D.useRef(null),T=D.useRef(null),C=n.find(S=>S.id===a),I=n.filter(S=>!S.archived).sort((S,z)=>z.updatedAt-S.updatedAt).slice(0,7),O=async S=>{const{canvasUniqueness:z}=await ft(async()=>{const{canvasUniqueness:Y}=await import("./canonical-C3OufoVo.js");return{canvasUniqueness:Y}},[]),V=await z(S.id),P=V==="native"?"confirm.deleteNative":V==="diverged-mirror"?"confirm.deleteDiverged":"confirm.deletePristine";await ai({title:Te("confirm.deleteCanvasTitle"),message:ve(Te(P),{name:S.name}),confirmLabel:Te("common.delete"),danger:V!=="pristine-mirror"})&&L7(S.id).then(e)};D.useEffect(()=>{if(!o)return;const S=z=>{T.current?.contains(z.target)||u(!1)};return window.addEventListener("mousedown",S),()=>window.removeEventListener("mousedown",S)},[o]);const _=async S=>{u(!1),await Ui(S),e(),ft(()=>import("./canonical-C3OufoVo.js"),[]).then(z=>z.unsubscribeOrphanedSessions()),ft(()=>Promise.resolve().then(()=>W8),void 0).then(z=>z.sweepRecentSessions())};return l.jsxs("div",{ref:T,className:"absolute top-4 left-4 z-20",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{onClick:()=>u(!o),disabled:r,className:"bg-card/90 backdrop-blur border border-line rounded-xl px-3.5 py-2 shadow-sm hover:bg-wash transition-colors flex items-center gap-2 text-sm text-ink max-w-[240px] disabled:opacity-60",children:[r?l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin shrink-0 text-accent"}):s?l.jsx(iF,{size:16,strokeWidth:1.75,className:"shrink-0 text-accent"}):l.jsx(cu,{size:16,strokeWidth:1.75,className:"shrink-0 text-ink-muted"}),l.jsx("span",{className:"truncate font-medium",children:C?.name??"…"}),l.jsx(cr,{size:14,strokeWidth:1.75,className:"shrink-0 text-ink-faint"})]}),l.jsx(rce,{}),!!C?.sourceSession?.sessionId&&(()=>{const S=Rm.size>0&&!Rm.has(C.sourceSession.sessionId);return l.jsxs("button",{title:S?Te("switcher.mirrorBadgeGone"):ve(Te("switcher.mirrorBadge"),{runner:C.sourceSession.runner}),onClick:()=>{b(C.sourceSession.sessionId),p(!0)},className:`bg-card/90 backdrop-blur border border-line rounded-xl px-2 py-2 shadow-sm hover:bg-wash transition-colors text-2xs font-mono flex items-center gap-1 ${S?"text-ink-faint/50 line-through decoration-1":"text-ink-faint hover:text-accent"}`,"data-twin-badge":S?"unreachable":"live",children:["⇄ ",C.sourceSession.runner]})})()]}),o&&l.jsxs("div",{className:"mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1.5 w-[320px] animate-fade-in",children:[l.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:I.map(S=>l.jsx("div",{className:`group flex items-center gap-1 px-3 py-2 hover:bg-wash cursor-pointer transition-colors ${S.id===a?"bg-accent/5":""}`,onClick:()=>{y!==S.id&&S.id!==a&&_(S.id)},children:y===S.id?l.jsx("input",{autoFocus:!0,value:E,onChange:z=>v(z.target.value),onClick:z=>z.stopPropagation(),onKeyDown:z=>{z.key==="Enter"&&!lr(z)&&E.trim()&&(j7(S.id,E.trim()),w(null)),z.key==="Escape"&&w(null)},onBlur:()=>w(null),className:"flex-1 text-sm text-ink border border-accent/40 rounded-lg px-2 py-1 bg-surface focus:outline-none"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:`text-sm truncate ${S.id===a?"text-accent font-medium":"text-ink"}`,children:S.name}),l.jsxs("div",{className:"text-2xs text-ink-faint flex items-center gap-1.5",children:[l.jsx("span",{children:ice(S.updatedAt)}),!!S.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px","data-mirror-mark":!0,children:S.sourceSession.runner})]})]}),l.jsx("button",{title:t("switcher.rename"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-ink p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),w(S.id),v(S.name)},children:l.jsx(Gl,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("common.delete"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-red-500 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),O(S)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),Bm(S.id,!0).then(e)},"data-archive-canvas":!0,children:l.jsx(el,{size:14,strokeWidth:1.75})})]})},S.id))}),l.jsxs("div",{className:"border-t border-line mt-1 pt-1",children:[l.jsxs("button",{onClick:()=>{u(!1),Tp().then(e)},className:"w-full text-left px-3 py-2 text-sm text-accent hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(F0,{size:15,strokeWidth:1.75})," ",t("switcher.newCanvas")]}),l.jsxs("button",{onClick:()=>A.current?.click(),className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(KU,{size:15,strokeWidth:1.75})," ",t("switcher.importBackup")]}),l.jsxs("button",{onClick:()=>{u(!1),p(!0)},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-open-atlas":!0,children:[l.jsx(ZF,{size:15,strokeWidth:1.75})," ",t("switcher.allCanvases")]}),window.desktop&&l.jsxs("button",{onClick:()=>{u(!1),window.desktop.checkForUpdates()},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-check-updates":!0,children:[l.jsx(or,{size:15,strokeWidth:1.75})," ",t("update.checkMenu"),l.jsxs("span",{className:"ml-auto text-2xs text-ink-faint",children:["v",new URLSearchParams(window.location.search).get("dv")]})]}),l.jsx("input",{ref:A,type:"file",accept:".json,.jsonl,application/json",className:"hidden",onChange:S=>{const z=S.target.files?.[0];z&&uG(z).then(V=>{V.kind==="own"&&V.ok?(u(!1),e()):V.kind==="chat"&&(u(!1),h(V.conversations))}).catch(V=>{We("error",ve(Te("toast.importFailedGeneric"),{msg:V instanceof Error?V.message:String(V)}))}),S.target.value=""}})]})]}),d&&l.jsx(sce,{conversations:d,onClose:()=>h(null),onDone:()=>{h(null),e()}}),m&&l.jsx(Wv,{onClose:()=>{p(!1),b(void 0)},onSwitched:e,focusSessionId:x})]})}const lce="JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUiA0IDAgUl0gL0NvdW50IDIgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvQ29udGVudHMgNSAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNyAwIFIgL0YyIDggMCBSID4+ID4+ID4+CmVuZG9iago0IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTk1IDg0Ml0gL0NvbnRlbnRzIDYgMCBSIC9SZXNvdXJjZXMgPDwgL0ZvbnQgPDwgL0YxIDcgMCBSIC9GMiA4IDAgUiA+PiA+PiA+PgplbmRvYmoKNSAwIG9iago8PCAvTGVuZ3RoIDExMTIgPj4Kc3RyZWFtCkJUCi9GMiAxOSBUZiAxIDAgMCAxIDY0IDcyNS4wIFRtIChXaHkgU2F2ZWQgQXJ0aWNsZXMgU3RheSBVbnJlYWQpIFRqCi9GMSAxMSBUZiAxIDAgMCAxIDY0IDcwOC4wIFRtIChBIHNob3J0IGJyaWVmIG9uIGRpZ2l0YWwgaG9hcmRpbmcgYW5kIHRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjIgMTMgVGYgMSAwIDAgMSA2NCA2NjkuMCBUbSAoMS4gVGhlIHBoZW5vbWVub24pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjUxLjUgVG0gKFJlYWQtaXQtbGF0ZXIgc2VydmljZXMgcmVwb3J0IHRoYXQgbW9zdCBzYXZlZCBpdGVtcyBhcmUgbmV2ZXIpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjM0LjAgVG0gKHJlb3BlbmVkLiBBY3Jvc3MgcHVibGlzaGVkIHVzYWdlIHN0dWRpZXMsIHRoZSBzaGFyZSBvZiBzYXZlZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA2MTYuNSBUbSAoYXJ0aWNsZXMgdGhhdCBnZXQgYSBzZWNvbmQgdmlzaXQgaXMgc21hbGwsIGFuZCBjb21wbGV0aW9uIHJhdGVzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU5OS4wIFRtIChhcmUgc21hbGxlciBzdGlsbC4gVGhlIGFyY2hpdmUgZ3Jvd3M7IHRoZSByZWFkaW5nIGRvZXMgbm90LikgVGoKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNTYwLjAgVG0gKDIuIFRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU0Mi41IFRtIChDb2xsZWN0aW5nIHByb2R1Y2VzIGFuIGltbWVkaWF0ZSBzZW5zZSBvZiBwcm9ncmVzcyB3aGlsZSB0aGUpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTI1LjAgVG0gKHVuZGVyc3RhbmRpbmcgaXQgcHJvbWlzZXMgaXMgZGVmZXJyZWQuIFNhdmluZyBhIHRleHQgZmVlbHMgbGlrZSkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1MDcuNSBUbSAoYSBmaXJzdCBzdGVwIG9mIHJlYWRpbmcgaXQsIGJ1dCBubyBwYXJ0IG9mIHRoZSByZWFkaW5nIGhhcykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA0OTAuMCBUbSAoaGFwcGVuZWQuKSBUagovRjIgMTEuNSBUZiAxIDAgMCAxIDY0IDQ3Mi41IFRtIChUaGUgYWN0IG9mIHNhdmluZyBpcyBtaXN0YWtlbiBmb3IgdGhlIGFjdCBvZiBsZWFybmluZy4pIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNiAwIG9iago8PCAvTGVuZ3RoIDkwOCA+PgpzdHJlYW0KQlQKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNzI1LjAgVG0gKDMuIFdoeSBpdCBwZXJzaXN0cykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA3MDcuNSBUbSAoVGhlIGNvc3RzIGFyZSBhc3ltbWV0cmljOiBzYXZpbmcgdGFrZXMgb25lIHNlY29uZCBhbmQgcGF5cyBvdXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjkwLjAgVG0gKGEgc21hbGwgcmV3YXJkIG5vdzsgcmVhZGluZyB0YWtlcyBhbiBob3VyIGFuZCBwYXlzIG91dCBsYXRlci4pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjcyLjUgVG0gKEhhYml0cyBmb2xsb3cgdGhlIGNoZWFwZXIgbG9vcCwgc28gbGlicmFyaWVzIGluZmxhdGUgYnkgZGVmYXVsdC4pIFRqCi9GMiAxMyBUZiAxIDAgMCAxIDY0IDYzMy41IFRtICg0LiBXaGF0IGhlbHBzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDYxNi4wIFRtIChJbnRlcnZlbnRpb25zIHRoYXQgd29yayBtb3ZlIHByb2Nlc3NpbmcgdG8gdGhlIG1vbWVudCBvZiBjYXB0dXJlOikgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1OTguNSBUbSAod3JpdGUgb25lIGxpbmUgaW4geW91ciBvd24gd29yZHMgYWJvdXQgd2h5IHRoZSBpdGVtIG1hdHRlcnMsIGFuZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1ODEuMCBUbSAoc2NoZWR1bGUgYSByZXZpZXcgcGFzcyBpbnN0ZWFkIG9mIHRydXN0aW5nIHRoZSBhcmNoaXZlIHRvKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU2My41IFRtIChyZXN1cmZhY2UgaXQuKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDUzMi4wIFRtIChBIHNtYWxsZXIgbGlicmFyeSB0aGF0IGdldHMgcHJvY2Vzc2VkIGJlYXRzIGEgY29tcGxldGUgb25lIHRoYXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTE0LjUgVG0gKGRvZXMgbm90LikgVGoKRVQKZW5kc3RyZWFtCmVuZG9iago3IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKOCAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EtQm9sZCA+PgplbmRvYmoKeHJlZgowIDkKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDEyMSAwMDAwMCBuIAowMDAwMDAwMjU3IDAwMDAwIG4gCjAwMDAwMDAzOTMgMDAwMDAgbiAKMDAwMDAwMTU1NyAwMDAwMCBuIAowMDAwMDAyNTE2IDAwMDAwIG4gCjAwMDAwMDI1ODYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA5IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoyNjYxCiUlRU9G",cce=`<!-- tdag-page:1 -->
|
|
675
675
|
|
|
676
676
|
# Why Saved Articles Stay Unread
|
|
677
677
|
|
|
@@ -904,11 +904,11 @@ ${n==="zh"?"**高光(原文保真)**":"**Highlights (verbatim)**"}
|
|
|
904
904
|
${T.map(S=>`> ${S.text}`).join(`
|
|
905
905
|
`)}`:"",I=Tn();x.push(I);const O=`${n==="zh"?"凝练":"Condensed"}: ${v.data.question.replace(/\s+/g," ").slice(0,60)} → ${A.data.question.replace(/\s+/g," ").slice(0,60)}`,_=`${t[E]||""}${C}`;p.push({id:I,type:"thought",position:{x:v.position.x+h,y:v.position.y},dragHandle:".drag-handle",data:{question:O,response:_,responses:[_],responseIndex:0,condensedFrom:w.nodeIds,createdAt:new Date().toISOString(),isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:Nn(`${O}
|
|
906
906
|
${_}`),highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}),w.nodeIds.forEach(S=>m.set(S,I))});for(const w of r){if(u.has(w.id))continue;const E=Tn();m.set(w.id,E);const v=w.data;p.push({...w,id:E,position:{x:w.position.x+h,y:w.position.y},selected:!1,data:{...v,isEditing:!1,isEditingResponse:!1,isLoading:!1}})}const b=[],y=new Set;for(const w of s){const E=m.get(w.source),v=m.get(w.target);if(!E||!v||E===v)continue;const A=`${E}→${v}`;y.has(A)||(y.add(A),b.push({...w,id:`e-${Tn()}`,source:E,target:v,selected:!1}))}return a.pushHistory(),se.setState(w=>{const E=[...w.nodes,...p],v=[...w.edges,...b];return{nodes:xr(E,v),edges:v}}),{copiedNodes:p.length,collapsedRuns:e.length,distillIds:x}}let Tl=0;function Jce(){Tl++,oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})}async function eue(e,t,n){if(e.length===0)return;const a=++Tl,r=oe.getState(),s=se.getState().nodes.map(o=>o.id);r.setCondenseRun({status:"building",current:0,total:e.length,streaming:"",error:void 0,originalIds:s,distillIds:[]});try{const o=[];let u="";for(let h=0;h<e.length;h++){if(Tl!==a)return;oe.getState().setCondenseRun({current:h+1,streaming:""});const m=await Xce(e[h],t,n,p=>{Tl===a&&oe.getState().setCondenseRun({streaming:p})},u||void 0);if(Tl!==a)return;o.push(m),u=`${u}
|
|
907
|
-
${m}`.slice(-1500)}const d=Zce(e,o,t);if(Tl!==a)return;oe.getState().setCondenseRun({status:"done",streaming:"",distillIds:d.distillIds}),We("success",Te("condense.copyReady"),8e3,{label:Te("tmap.export"),run:()=>oe.getState().setThoughtMapOpen(!0)})}catch(o){if(Tl!==a)return;oe.getState().setCondenseRun({status:"error",error:o instanceof Error?o.message:String(o)})}}function tue({onFocusSegment:e}){const t=oe(P=>P.condenseDialogOpen),n=oe(P=>P.condenseRun),a=St(),r=Da(P=>P.lang),s=se(P=>P.nodes),o=se(P=>P.edges),[u,d]=D.useState(0),h=D.useMemo(()=>t&&n.status==="idle"?Yce(s,o):[],[t,n.status,s,o,u]),m=oe(P=>P.selectedModel),p=Yl()?.models??[],[x,b]=D.useState(""),[y,w]=D.useState(new Set),[E,v]=D.useState(null),A=D.useRef(null),T=P=>{const L=A.current?.getBoundingClientRect();if(!L)return;const Y=P.clientX-L.left,q=P.clientY-L.top,B=$=>v({x:Math.min(window.innerWidth-120,Math.max(0,$.clientX-Y)),y:Math.min(window.innerHeight-80,Math.max(0,$.clientY-q))}),j=()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",j)},C=P=>P.nodeIds.join(","),I=h.filter(P=>!y.has(C(P))),O=I.reduce((P,L)=>P+L.saving,0),_=()=>{oe.getState().setCondenseDialogOpen(!1),oe.getState().setCondenseHighlightIds([])};if(D.useEffect(()=>{if(!t)return;const P=L=>{L.key==="Escape"&&_()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),!t)return null;const S=()=>{I.length!==0&&eue(I,r,x||m||void 0)},z=()=>{se.getState().setArchived(n.originalIds,!0),We("success",a("condense.originalArchived")),oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:"",originalIds:[],distillIds:[]}),_()},V=()=>{const L=se.getState().nodes.filter(Y=>n.distillIds.includes(Y.id));L.length&&e?.(L.map(Y=>Y.id))};return ur.createPortal(l.jsxs("div",{ref:A,className:"fixed z-[70] bg-surface border border-line rounded-2xl shadow-2xl w-[400px] max-h-[72vh] flex flex-col p-4 animate-fade-in",style:E?{left:E.x,top:E.y}:{left:80,bottom:16},"data-condense-dialog":!0,onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between mb-1 cursor-grab active:cursor-grabbing select-none",onMouseDown:T,children:[l.jsxs("div",{className:"text-sm font-semibold text-ink flex items-center gap-2",children:[l.jsx(xp,{size:15,strokeWidth:1.75,className:"text-accent"})," ",a("condense.title")]}),l.jsx("button",{onClick:_,title:n.status==="building"?a("condense.runningBg"):void 0,className:"text-ink-faint hover:text-ink rounded-lg w-7 h-7 flex items-center justify-center hover:bg-wash transition-colors",children:l.jsx(cn,{size:15})})]}),n.status==="idle"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsx("p",{className:"text-2xs text-ink-faint leading-snug",title:a("condense.copyIntroFull"),children:a("condense.copyIntroShort")}),l.jsxs("button",{onClick:()=>d(P=>P+1),title:a("condense.rescanTitle"),"data-condense-rescan":!0,className:"text-2xs text-ink-muted hover:text-accent px-2 py-1 rounded-lg hover:bg-wash transition-colors shrink-0",children:["⟳ ",a("condense.rescan")]})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2","data-condense-scanline":!0,children:ve(a("condense.scanLine"),{turns:String(s.filter(P=>P.data.response&&!P.data.stepKind).length),n:String(h.length)})}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("label",{className:"text-2xs text-ink-muted shrink-0",children:a("condense.modelLabel")}),l.jsxs("select",{value:x,onChange:P=>b(P.target.value),"data-condense-model":!0,className:"text-xs bg-wash text-ink rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/40 max-w-[220px] truncate",children:[l.jsx("option",{value:"",children:ve(a("condense.modelGlobal"),{model:m||"auto"})}),p.map(P=>l.jsx("option",{value:P.id,children:P.id},P.id))]})]}),h.length===0?l.jsx("p",{className:"text-xs text-ink-muted py-4",children:a("condense.segNothing")}):l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:h.map(P=>{const L=C(P),Y=!y.has(L);return l.jsxs("div",{"data-condense-item":!0,className:`border rounded-xl p-3 transition-colors cursor-pointer ${Y?"border-accent/60 bg-accent/5":"border-line opacity-60"}`,onClick:()=>{oe.getState().setCondenseHighlightIds(P.nodeIds),e?.(P.nodeIds)},children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("input",{type:"checkbox",checked:Y,onClick:q=>q.stopPropagation(),onChange:()=>w(q=>{const B=new Set(q);return B.has(L)?B.delete(L):B.add(L),B}),className:"accent-[var(--color-accent)]","data-condense-check":!0}),l.jsx("span",{className:"text-2xs text-ink-faint font-mono",children:ve(a("condense.segMeta"),{n:String(P.nodeIds.length),tok:String(P.saving)})})]}),l.jsx("p",{className:"text-xs text-ink mt-1 leading-snug line-clamp-2",children:P.headQuestion})]},L)})}),h.length>0&&l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-3 mt-2 border-t border-line",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:a("condense.copyFootnote")}),l.jsxs("button",{onClick:S,disabled:I.length===0,"data-condense-build":!0,className:"text-xs bg-accent text-white px-3.5 py-2 rounded-lg disabled:opacity-40 transition-colors flex items-center gap-1.5 shrink-0",children:[l.jsx(to,{size:13,strokeWidth:1.75}),ve(a("condense.buildCopy"),{n:String(I.length),tok:String(O)})]})]})]}),n.status==="building"&&l.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted mb-1.5",children:[l.jsx(nn,{size:15,className:"animate-spin text-accent"}),ve(a("condense.buildingRun"),{i:String(n.current),n:String(n.total)})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2",children:a("condense.runningBg")}),n.streaming&&l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto text-2xs text-ink-muted bg-wash rounded-lg p-2.5 whitespace-pre-wrap leading-relaxed","data-condense-streaming":!0,children:n.streaming}),l.jsx("button",{onClick:()=>Jce(),"data-condense-cancel":!0,className:"self-start mt-3 text-xs text-ink-muted hover:text-red-600 px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="error"&&l.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[l.jsx("p",{className:"text-2xs text-red-600",children:n.error}),l.jsx("button",{onClick:()=>oe.getState().setCondenseRun({status:"idle",error:void 0}),className:"self-start text-xs text-ink-muted hover:text-ink px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="done"&&l.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-700",children:[l.jsx(es,{size:16})," ",a("condense.copyReady")]}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:a("condense.copyCompareHint")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:V,className:"text-xs bg-accent/10 text-accent hover:bg-accent/20 px-3 py-2 rounded-lg transition-colors",children:a("condense.viewCopy")}),l.jsxs("button",{onClick:z,"data-condense-archive-original":!0,className:"text-xs border border-line text-ink-muted hover:text-ink hover:bg-wash px-3 py-2 rounded-lg transition-colors flex items-center gap-1.5",children:[l.jsx(el,{size:13,strokeWidth:1.75})," ",a("condense.archiveOriginal")]})]}),l.jsx("button",{onClick:()=>{oe.getState().setCondenseRun({status:"idle"}),_()},className:"self-start text-xs text-ink-faint hover:text-ink transition-colors",children:a("common.close")})]})]}),document.body)}function HT(){const e=Da(n=>n.lang),t=Da(n=>n.setLang);return l.jsx("div",{className:"flex items-center bg-card/90 backdrop-blur border border-line rounded-lg shadow-sm overflow-hidden",children:["en","zh"].map(n=>l.jsx("button",{onClick:()=>t(n),className:`px-2 h-8 text-2xs font-medium transition-colors ${e===n?"bg-accent text-white":"text-ink-muted hover:bg-wash"}`,children:n==="en"?"EN":"中"},n))})}function ma({x:e,y:t,w:n=34,h:a=20,tone:r="plain"}){return l.jsxs("g",{children:[l.jsx("rect",{x:e,y:t,width:n,height:a,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),r!=="plain"&&l.jsx("rect",{x:e,y:t,width:2.5,height:a,rx:1.25,fill:r==="accent"?it.accent:it.warm})]})}const nue={1:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:32,tone:"accent"}),l.jsx("circle",{cx:60,cy:28,r:2.5,fill:it.accent})]}),2:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:12,tone:"accent"}),l.jsx("line",{x1:60,y1:32,x2:60,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 47 L 60 52 L 63 47 Z",fill:it.accent}),l.jsx(ma,{x:43,y:52})]}),3:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:20,y:12,tone:"accent"}),l.jsx("line",{x1:37,y1:32,x2:37,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 34 47 L 37 52 L 40 47 Z",fill:it.accent}),l.jsx(ma,{x:20,y:52}),l.jsx("rect",{x:26,y:58,width:14,height:3,rx:1.5,fill:it.trace,opacity:.6}),l.jsx("path",{d:"M 54 62 C 64 62, 62 40, 72 38",stroke:it.warm,strokeWidth:1.75,fill:"none",strokeDasharray:"4 3"}),l.jsx("path",{d:"M 69 35.5 L 74 38 L 70 41 Z",fill:it.warm}),l.jsx(ma,{x:74,y:28,tone:"warm"})]}),4:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:52,stroke:it.line,strokeWidth:1.75,strokeDasharray:"3 3"}),l.jsx("circle",{cx:60,cy:41,r:7,fill:"white",stroke:"#FCA5A5",strokeWidth:1}),l.jsx("line",{x1:57,y1:38,x2:63,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx("line",{x1:63,y1:38,x2:57,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx(ma,{x:43,y:54})]}),5:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:12,y:14,w:40,h:15}),l.jsx("circle",{cx:14,cy:16,r:4.5,fill:"#D64533"}),l.jsx("text",{x:14,y:18.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"✕"}),l.jsx(ma,{x:12,y:35,w:40,h:15}),l.jsx("circle",{cx:14,cy:37,r:4.5,fill:it.accent}),l.jsx("text",{x:14,y:39.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"⚖"}),l.jsx(ma,{x:12,y:56,w:40,h:15}),l.jsx("circle",{cx:14,cy:58,r:4.5,fill:"#C9A227"}),l.jsx("text",{x:14,y:60.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"?"}),l.jsx("path",{d:"M 62 42 L 74 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 71.5 39.5 L 76 42 L 71.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:86,y:14,width:13,height:13,rx:4.5,fill:"#D64533"}),l.jsx("line",{x1:92.5,y1:27,x2:92.5,y2:35,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:35,width:13,height:13,rx:4.5,fill:it.accent}),l.jsx("line",{x1:92.5,y1:48,x2:92.5,y2:56,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:56,width:13,height:13,rx:4.5,fill:"#C9A227"})]}),7:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:14,y:12,width:30,height:22,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("line",{x1:29,y1:34,x2:29,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 26 47 L 29 52 L 32 47 Z",fill:it.accent}),l.jsx(ma,{x:12,y:52,tone:"accent"}),l.jsx("path",{d:"M 100 22 C 80 22, 70 55, 50 60",stroke:it.accent,strokeWidth:1.75,fill:"none",strokeDasharray:"5 3"}),l.jsx("path",{d:"M 52 57 L 47 61 L 52 64 Z",fill:it.accent}),l.jsx(ma,{x:82,y:12})]}),9:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:48,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 45 L 60 50 L 63 45 Z",fill:it.accent}),l.jsx(ma,{x:43,y:50}),l.jsx("circle",{cx:75,cy:53,r:4,fill:"#F59E0B"}),l.jsx("path",{d:"M 73.5 53 a 1.5 1.5 0 1 1 3 0",stroke:"white",strokeWidth:.9,fill:"none"}),l.jsx("text",{x:60,y:80,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"v2/2 · replay"})]}),6:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:18,width:14,height:48,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:15,cy:27,r:3,fill:it.accent,opacity:.7}),l.jsx("rect",{x:12,y:37,width:6,height:6,rx:1,fill:"#F59E0B",opacity:.8}),l.jsx("rect",{x:12,y:49,width:6,height:6,rx:1,fill:it.inkMuted,opacity:.5}),l.jsx("rect",{x:38,y:14,width:32,height:24,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("rect",{x:80,y:14,width:32,height:24,rx:3,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:88,cy:22,r:3,fill:it.line}),l.jsx("path",{d:"M 82 34 L 92 26 L 100 32 L 108 24",stroke:it.inkMuted,strokeWidth:1.2,fill:"none"}),l.jsx("text",{x:72,y:62,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"⌘V paste anything"})]}),8:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:8,width:70,height:52,rx:3,fill:it.accent,opacity:.06,stroke:it.accent,strokeWidth:.8,strokeDasharray:"3 2"}),l.jsx(ma,{x:14,y:14,w:26,h:16}),l.jsx(ma,{x:46,y:14,w:26,h:16}),l.jsx(ma,{x:30,y:38,w:26,h:16}),l.jsx("path",{d:"M 40 46 C 60 50, 70 50, 84 48",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 59 30 C 70 36, 76 42, 84 46",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 43 22 C 66 24, 76 38, 84 44",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx(ma,{x:84,y:40,w:28,h:18,tone:"accent"})]}),10:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:10,y:18,w:30,h:17,tone:"accent"}),l.jsx("line",{x1:25,y1:35,x2:25,y2:48,stroke:it.accent,strokeWidth:1.5}),l.jsx("path",{d:"M 22.5 45.5 L 25 50 L 27.5 45.5 Z",fill:it.accent}),l.jsx(ma,{x:10,y:50,w:30,h:17}),l.jsx("path",{d:"M 46 42 L 60 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 57.5 39.5 L 62 42 L 57.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:68,y:20,width:44,height:44,rx:5,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx(ma,{x:74,y:30,w:20,h:11,tone:"accent"}),l.jsx(ma,{x:88,y:46,w:20,h:11}),l.jsx("rect",{x:76,y:14,width:28,height:11,rx:5.5,fill:"#2B2A28"}),l.jsx("circle",{cx:84,cy:19.5,r:2.6,fill:"none",stroke:"white",strokeWidth:1}),l.jsx("circle",{cx:84,cy:19.5,r:.9,fill:"white"}),l.jsx("text",{x:90,y:22,fontSize:6,fill:"white",fontFamily:"JetBrains Mono Variable, monospace",children:"view"}),l.jsx("text",{x:60,y:78,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"#view= · read-only"})]})},FT={4:"prune",5:"map",6:"reading",7:"ref"};function aue(){const e=oe(h=>h.tutorialOpen),t=oe(h=>h.setTutorialOpen);D.useEffect(()=>{if(!e)return;const h=m=>{m.key==="Escape"&&t(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t]);const n=St(),a=Da(h=>h.lang),[r,s]=D.useState(0),o=[{label:n("tutorial.pg1"),steps:[1,2,3]},{label:n("tutorial.pg2"),steps:[4,5]},{label:n("tutorial.pg3"),steps:[6,7]},{label:n("tutorial.pg4"),steps:[8,9,10]}],u=r===o.length-1;if(D.useEffect(()=>{if(!e)return;s(0);const h=m=>{m.key==="ArrowRight"&&s(p=>Math.min(p+1,o.length-1)),m.key==="ArrowLeft"&&s(p=>Math.max(p-1,0))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e]),!e)return null;const d=o[r];return l.jsx("div",{className:"fixed inset-0 z-[95] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-[min(980px,94vw)] flex flex-col",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between px-7 pt-5 pb-1 shrink-0",children:[l.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[l.jsx("h2",{className:"text-lg font-semibold text-ink tracking-tight shrink-0",children:n("tutorial.title")}),l.jsx("p",{className:"text-xs text-ink-faint truncate",children:n("tutorial.subtitle")})]}),l.jsx("button",{onClick:()=>t(!1),className:"text-ink-faint hover:text-ink transition-colors mt-1",children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 pt-3 pb-1 min-h-[380px]",children:[l.jsx("p",{className:"text-2xs font-semibold text-accent mb-3 uppercase tracking-wider",children:d.label}),l.jsx("div",{className:`grid gap-4 ${d.steps.length===3?"grid-cols-1 sm:grid-cols-3":"grid-cols-1 sm:grid-cols-2"}`,children:d.steps.map(h=>l.jsxs("div",{className:"bg-surface border border-line/70 rounded-xl p-4 flex flex-col animate-fade-in",children:[l.jsx("div",{className:"w-full aspect-[120/72] bg-card rounded-lg border border-line/60 mb-3 overflow-hidden",children:FT[h]?l.jsx("img",{src:`/thoughtdag/tutorial/${FT[h]}-${a}.gif`,loading:"lazy",alt:"",className:"w-full h-full object-cover"}):nue[h]}),l.jsx("h3",{className:"text-[13px] font-semibold text-ink leading-snug",children:n(`tutorial.step${h}.title`)}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed mt-1.5",children:n(`tutorial.step${h}.desc`)})]},h))})]}),l.jsxs("div",{className:"px-7 py-4 shrink-0 flex items-center justify-between",children:[l.jsx("button",{onClick:()=>s(h=>Math.max(h-1,0)),disabled:r===0,className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center disabled:opacity-25 disabled:cursor-not-allowed",children:l.jsx(Tm,{size:16,strokeWidth:1.75})}),l.jsx("div",{className:"flex items-center gap-2",children:o.map((h,m)=>l.jsx("button",{onClick:()=>s(m),className:`h-2 rounded-full transition-all ${m===r?"w-6 bg-accent":"w-2 bg-line hover:bg-line-strong"}`,"aria-label":`${m+1}/${o.length}`},m))}),u?l.jsx("button",{onClick:()=>t(!1),className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors",children:n("tutorial.close")}):l.jsx("button",{onClick:()=>s(h=>h+1),className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center",children:l.jsx(Ba,{size:16,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 py-2.5 border-t border-line/60 shrink-0 flex flex-wrap gap-x-4 gap-y-1 text-2xs text-ink-faint font-mono",children:[l.jsxs("span",{children:[n("shortcut.panKeys")," ",n("shortcut.pan")]}),l.jsxs("span",{children:[n("shortcut.marqueeKeys")," ",n("shortcut.marquee")]}),l.jsxs("span",{children:["⌘","F ",n("shortcut.search")]}),l.jsxs("span",{children:["Space ",n("shortcut.collapse")]}),l.jsxs("span",{children:["R ",n("shortcut.regenerate")]}),l.jsxs("span",{children:["↑↓←→"," ",n("shortcut.navigate")]}),l.jsxs("span",{children:["⌘","Z/","⇧","⌘","Z ",n("shortcut.undo")]}),l.jsxs("span",{children:["Del ",n("shortcut.delete")]}),l.jsxs("span",{children:["Esc ",n("shortcut.escape")]})]})]})})}const rue=new URLSearchParams(window.location.search),_s=rue.get("dv"),Lc="https://chenxiachan.github.io/thoughtdag/docs",zM=[{version:"0.5.7",date:"2026-09-30",announce:!1,lead:{zh:"安全修补:回答里的原始 HTML 先经过消毒再渲染,折叠块、上下标、键帽、高亮、表格、换行照旧,能执行脚本或嵌入外部页面的标签(iframe、object、script、style、form 等)被去掉;此前分享链接、导入的画布或模型引用的网页都能借 srcdoc 的 iframe 在本页面的源里执行代码。托管代理的模型探测只接受公网 https 地址,两处网页快照抓取共用一套地址检查并逐跳核对重定向。另外两处小修:「重跑上游已变」只跑确认框里数到的那些,牌子摘要不再参考已归档的步骤。",en:"Security: raw HTML in an answer is sanitized before rendering; folds, sub/sup, kbd, highlights, tables and line breaks stay, while tags that run scripts or embed pages (iframe, object, script, style, form and the like) are stripped. Until now a shared link, an imported canvas or a page the model quoted could run code in this origin through a srcdoc iframe. The hosted proxy's model probe takes public https endpoints only, and both page-snapshot fetchers share one address guard and check every redirect hop. Two small fixes: replay reruns exactly the stale nodes the dialog counts, and plaque summaries no longer read archived steps."},items:[]},{version:"0.5.6",date:"2026-09-30",announce:!1,lead:{zh:"回忆改成安静的小标签,默认关:输入框旁一个「回忆」,点开是开关、搜索范围(轻量 40 条 / 深挖 2,000 条 / 全量)和带入上下文,改的只对这一次提问生效,「设为默认」写回全局;深挖和全量由判断模型分批看候选,全量先告诉你条数、秒数和费用。判断模型页的开关并进供应商下拉(最后一项「关闭,按规则」);联网和学术搜索也默认关。每个节点都有可缩放的摘要:一句话的回答、笔记、文件都上梯子。双击卡片上的问题,侧栏编辑框带着原文打开。Harness 插件:思维图顶上是自己的标题带(不再压住红绿灯);自己的模型接口回来了,添加、拉模型列表、调用都走插件;不再提示桌面版新版本,插件更新提示直接说在插件页重新添加哪个包;桌面版 0.2 写的 v4 会话文件进得了对话地图。",en:`Recall is a quiet chip, off by default: a "Recall" beside the composer opens the switch, the search reach (light 40 / deep 2,000 / full) and the context brought in; a change there holds for the next ask only, "set as default" writes it back. Deep and full have the decision model read candidates in batches; full first says how many turns, seconds and dollars. The decision model page folds its switch into the provider dropdown (last entry: off, rules decide); web and scholar search start off too. Every node zooms: one-line answers, notes and files get a ladder. Double-clicking a card's question opens the side panel editor with the text in place. Harness plugin: the map wears its own title band (clear of the traffic lights); its own model interfaces are back, added, listed and called through the plugin; no more desktop-app update nudge, and the plugin's own notice names the package to re-add on the Plugins page; the 0.2 desktop's v4 session files reach the atlas.`},items:[]},{version:"0.5.5",date:"2026-09-29",announce:!1,lead:{zh:"换档不再互相盖住:缩小到地图层时,节点的牌子不会超出布局留给它的位置,写不下的摘要在底部渐隐,再放大一档就能看全;折叠卡显示和牌子同一段摘要,放大缩小之间只是字号在变。节点间距略微拉开,已有画布的位置不动,按「一键排版」才换成新间距。另外:从 Finder 启动时也能找到本机的 Pi、Codex、Claude Code 命令行,找不到会说明查过哪些地方,可重新检测;子 Agent 的运行展开在父画布上,作为那一轮旁边的分支;模型接口分成「慢思考 · 回答模型」和「快思考 · 判断模型」两页,只用 Agent 的人也能单独接判断模型;新装机没有模型时会先问一次本机的 Agent。",en:"Zoom tiers no longer cover each other: at map zoom a node's plaque stays inside the room the layout keeps for it, an abstract that runs past it fades out at the bottom and shows in full one step in; the folded card carries the same abstract as the plaque, so zooming only changes the type size. Node gaps open slightly; existing canvases keep their positions until you choose Tidy layout. Also: the Pi, Codex and Claude Code CLIs are found under a Finder launch, and a missing one says where it looked, with a recheck; a subagent's run unfolds on the parent canvas as a branch beside its turn; the model dialog has two pages, slow thinking for answering models and fast thinking for the decision model, which agent-only users can connect on its own; a fresh install with no model asks the local agents first."},items:[]},{version:"0.5.4",date:"2026-09-29",announce:!1,lead:{zh:"鼠标滚轮恢复缩放画布,和 0.5.2 一样。0.5.3 起滚轮改成了平移,这对触控板顺手,却让鼠标用户没法用滚轮缩放。触控板用户可以在画布 ⋯ 菜单打开「滚轮平移画布」:双指滑动即平移,捏合或按住 ⌘/Ctrl 滚动来缩放。",en:"The mouse wheel zooms the canvas again, as in 0.5.2. Since 0.5.3 it panned, which suits a trackpad but left mouse users without wheel zoom. On a trackpad, turn on ⋯ → Wheel pans the canvas: a two-finger scroll pans, pinch or hold ⌘/Ctrl while scrolling to zoom."},items:[]},{version:"0.5.3",date:"2026-09-27",announce:!1,lead:{zh:"圈选多个节点后,工具栏多了「更新节点摘要」:用当前选中的模型为它们一次更新四层摘要,文件、便签和短回答自动跳过。进度在右下角,随时可停。旧画布想整体升级到新摘要,圈一下就行。右键单个节点也是同一个入口。",en:'With several nodes selected, the toolbar gains "Update node summaries": the picked model updates their four summary levels in one go, files, notes and short answers skipped. Progress shows bottom right and can be stopped any time. An older canvas upgrades to the new summaries with one lasso; the right-click item on a single node is the same door.'},items:[{title:{zh:"🧭 摘要写的是这一步新增了什么",en:"🧭 Summaries say what the step adds"},body:{zh:"结论与短述改为由模型撰写。写之前它先读这条思路里前面各步的牌匾,只写本步新增的结论、决定或转向,不重复前面已经说过的;概要仍是原答里的原文摘句,作为证据。旧节点用「更新节点摘要」换新即可。",en:'The takeaway and brief are now written by the model. It first reads the plaques of the earlier steps in the thread, then writes only what this step adds, a conclusion, a decision or a turn, without repeating what came before; the abstract stays verbatim sentences of the answer, as evidence. Older nodes switch over with "Update node summaries".'}},{title:{zh:"🖐️ 触控板双指滑动即平移",en:"🖐️ Two-finger scroll pans"},body:{zh:"在触控板上双指滑动就能移动画布,不用再按住按键拖。捏合缩放不变。鼠标滚轮现在同样是平移,缩放请按住 ⌘(Windows 上是 Ctrl)再滚。感谢 @Pireirik 的贡献。",en:"On a trackpad, a two-finger scroll moves the canvas; no button to hold. Pinch still zooms. A mouse wheel now pans too; hold ⌘ (Ctrl on Windows) to zoom with it. Contributed by @Pireirik."}}]},{version:"0.5.2",date:"2026-09-27",announce:!0,lead:{zh:"🔍 上下文管理重大更新!现在,无论画布缩放至何种比例,节点内容始终保持极佳的阅读体验。",en:"🔍 A major update to context management! Whatever the zoom, every node on the canvas now stays a pleasure to read."},media:{src:{zh:"whats-new/zoom-ladder-zh.mp4",en:"whats-new/zoom-ladder-en.mp4"},alt:{zh:"缩小画布时,牌匾上的结论逐词长成短述再长成摘要",en:"Zooming out, a plaque's takeaway grows word by word into a brief, then an abstract"},width:960,height:600},items:[{title:{zh:"🪜 智能四层摘要",en:"🪜 Four smart summary levels"},body:{zh:"每个回答自动构建「主题、结论、短述、完整概要」四个递进层级,随缩放比例自动无缝切换。",en:"Every answer builds four progressive levels, topic, takeaway, brief and full abstract, and switches between them seamlessly as you zoom."}},{title:{zh:"✨ 丝滑的视觉过渡",en:"✨ Silky visual transitions"},body:{zh:"缩放时,文字会逐词自然展开或收起。保留的关键词会平滑移动,新文本自然淡入,核心重点始终高亮加深。视线聚焦零中断,数十个节点的全局脉络一眼即达。",en:"As you zoom, text unfolds or folds word by word. The words that stay glide into place, new text fades in, and the key points stay highlighted in full ink. Your focus is never broken, and the shape of dozens of nodes reads at a glance."}},{title:{zh:"🔁 新旧节点全面兼容",en:"🔁 New and old nodes alike"},body:{zh:"新回答自动生效该特性;旧节点会在浏览时实时生成摘要层级,若需更精准的 AI 总结,只需右键一键生成。",en:"New answers get it automatically; older nodes build their levels live as you browse, and for a sharper AI-selected summary, one right-click does it."}},{title:{zh:"🎚️ 时间线详略随手调",en:"🎚️ Timeline detail at your fingertips"},body:{zh:"时间线弹窗新增详略滑块,从主题一路拉到完整概要,字号与行距随手指流动,每一步文字完整呈现,告别省略号。",en:"The timeline overview gains a detail slider: glide from topic to full abstract, type and spacing flowing with your drag, every step shown whole, no ellipsis anywhere."},media:{src:{zh:"whats-new/timeline-detail-zh.mp4",en:"whats-new/timeline-detail-en.mp4"},alt:{zh:"拖动时间线弹窗的详略滑块,每一步的文字逐词展开",en:"Dragging the timeline overview's detail slider, each step's text unfolds word by word"},width:720,height:760}},{title:{zh:"🛡️ 所见即所发",en:"🛡️ What you see is what is sent"},body:{zh:"判断模型认定上游改动与答案无关时,「上游已变」标记现在同时从预览和请求中退场,两者始终一致。感谢 Agent Memory Atlas 的审阅指出这一点。",en:'When the decision model rules an upstream change irrelevant, the "upstream changed" mark now leaves the preview and the request together, always in step. Thanks to the Agent Memory Atlas review for catching it.'}},{title:{zh:"🧹 右键菜单焕新",en:"🧹 A refreshed right-click menu"},body:{zh:"「重新生成」更简洁,CLI 相关操作合并为一项,新增「用模型重选摘要」。手动修改过的回答会自动重做摘要。",en:'"Regenerate" is simpler, the CLI actions merge into one, and "Update node summary" joins the menu. Hand-edited answers get their summaries redone automatically.'}}]},{version:"0.5.1",date:"2026-09-26",announce:!1,lead:{zh:"0.5 之后的一批修正。删除正在生成的节点时,那一轮生成随之中止,不再在后台跑完。记忆的自动写入上限按画布分开计,切换画布后重新计;之前是全局三条写满就静默。档案更新只带走模型读过的那几条待归档事实,更新期间新归档的保留下来;档案文件的写入排队进行,不再互相覆盖。why 层不再把执行失败的文件操作算作改动足迹,更新后索引会重建一次。判断模型直接沿用模型接入里保存的 OpenRouter key,不再显示为空、测试不可点。",en:"A round of fixes after 0.5. Deleting a node that is still generating stops that generation instead of letting it run on in the background. The memory judge's automatic-write cap counts per canvas and starts over on a canvas switch; it used to be one global count of three, after which memory went quiet. A dossier update takes only the filed facts the model read and keeps anything filed while it was writing; dossier writes queue instead of overwriting one another. The why layer no longer counts a file operation the harness answered with an error as a change, and the index rebuilds once. The decision model uses the OpenRouter key saved with your model providers, instead of showing an empty field with a disabled test."},items:[]},{version:"0.5.0",date:"2026-09-26",announce:!0,lead:{zh:"🎉 ThoughtDAG 0.5:记忆上线。你在 Pi、Codex、Claude Code、DeepSeek Harness 里聊过的一切,现在接成一个可以回忆的整体。散在几百个会话里的碎片,按主题整理成档案;提问时相关的档案和对话自动带进上下文,跨 Agent、跨时间。背后是快思考与慢思考的分工:慢思考模型回答,快思考模型判断。所有信息都在你自己的机器上。",en:"🎉 ThoughtDAG 0.5: memory. Everything you discussed in Pi, Codex, Claude Code and DeepSeek Harness now forms one whole you can recall. Fragments scattered across hundreds of sessions are organised into dossiers by topic; when you ask, the relevant dossiers and conversations ride into the context, across agents and across time. Behind it, a division of labour: a slow-thinking model answers, a fast-thinking model decides. Everything stays on your machine."},items:[{title:{zh:"碎片串成一条线",en:"Fragments become a thread"},body:{zh:"昨天在 Codex 里定的阈值,上周在 Claude Code 里排除的方案,今天在画布上问起时都在。每个主题一份档案:是什么、定过什么、到哪一步、还没解决什么,每句都能点回原来的那轮对话。「你」是两份文档:偏好与身份,记到新东西时改写而不是堆砌。原来的记忆条目已并入。",en:"The threshold you settled in Codex yesterday and the approach you ruled out in Claude Code last week are there when you ask on the canvas today. Every topic keeps a dossier: what it is, what was decided, where it stands, what is still open, each line pointing back to its turn. Your profile is two documents, preferences and identity, rewritten rather than piled up. Earlier memory entries were folded in."},link:{label:{zh:"记忆指南",en:"The memory guide"},href:`${Lc}/zh/guides/memory`}},{title:{zh:"提问时自动回忆",en:"Recall as you ask"},media:{src:{zh:"whats-new/jev-recall.mp4",en:"whats-new/jev-recall.mp4"},alt:{zh:"回忆流程里,判断模型半秒内从候选片段中选出相关的几条",en:"In the recall flow the decision model picks the relevant excerpts from the candidates in under a second"},width:1200,height:720},body:{zh:"开着「回忆」提问,先判断问题涉及哪些主题,把档案整份带进去;问的是细节时再补几条原话。带了什么、花了多少,面板上一条一条看得见,不想要的划掉就不带。带入量三档:省、标准、多带。",en:"With recall on, a question is first matched to its topics and their dossiers ride in whole; a question about a detail brings a few verbatim excerpts too. What came in and what it cost is listed item by item; strike one and it stays out. Three amounts: lean, standard, generous."}},{title:{zh:"快思考,慢思考",en:"Fast thinking, slow thinking"},body:{zh:"回答你的是慢思考模型。判断「这条相关吗」「这句是决定吗」「这处改动影响吗」的是快思考模型:半秒一次,返回校准过的概率,让回忆、地图徽章和「上游已变」都有依据。模型选择器里一行开关,默认开;关掉全部退回规则,功能不变。",en:"The slow-thinking model answers you. The fast-thinking model decides — is this relevant, is this line a decision, does this change matter — in half a second, with calibrated probabilities, so recall, map badges and “upstream changed” rest on evidence. One switch in the model picker, on by default; off, every decision falls back to a rule and nothing stops working."}},{title:{zh:"接入一个快思考模型",en:"Connect a fast-thinking model"},body:{zh:"Jev 类判断模型可以经你已保存的聚合商接入直接使用,也支持官方接口和自建服务;没有接入时会提示,一切照常。",en:"A Jev-class decision model runs through the aggregator access you already saved, through the official endpoint, or from a self-hosted server; without one you are told, and everything still works."},link:{label:{zh:"怎么接入",en:"How to connect one"},href:`${Lc}/zh/setup#decision-model`}},{title:{zh:"一切都在本地",en:"All of it stays local"},body:{zh:"索引、主题标签、档案存在本机 .thoughtdag 目录,画像文档存在应用本地。判断时发出去的只有问题和候选片段,发给你自己选的接入。",en:"The index, topic labels and dossiers live in your machine's .thoughtdag folder; your profile lives in the app's own storage. A decision sends only the question and the candidate excerpts, to the access you chose."}}]},{version:"0.4.20",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件一轮实测后的整理。「对话 | 思维图」开关:对话页顶部仍是浮动的,切到思维图后它移到画布顶栏「画布名」右侧,不再压住画布工具栏。工作目录改用 Harness 自己的目录选择器:本机运行时弹的就是系统的文件夹对话框,远程访问时回落为输入路径;0.4.19 里自带的目录浏览器撤掉。Harness Agent 也能选工作目录,新会话按所选目录运行。插件里去掉配置模型 API 的入口。实时镜像刷新会话时不再把镜头拉回节点。节点记录的是发起请求时的模型,执行中切换选择器不再改写徽章。Harness 执行中的每个工具调用都列为一条步骤,思考尾巴显示在下方。备份提醒去掉。",en:"DeepSeek Harness plugin, after a round of hands-on testing. The 对话 | 思维图 switch still floats over the chat; on the canvas it sits in the canvas's own top bar next to the canvas chip, so it never covers the toolbar. The working directory is chosen in the harness's own picker: the system folder dialog when the harness runs on this machine, a typed path when reached remotely; the folder browser 0.4.19 carried is withdrawn. The Harness Agent gets the folder chip too, and a fresh session runs where it says. The API-key door is gone inside the plugin. The live mirror no longer drags the camera back to a node while its session refreshes. A node records the model it was asked with; switching the picker mid-run no longer relabels it. Every tool call of a harness run is listed as a step, the thinking beneath. The backup reminder is removed."},items:[]},{version:"0.4.19",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:Harness Agent 节点的回答不再「闪一下就没了」。新版 Harness(0.1.5-rc.3)不再把逐字流写进会话日志,一步只落一条 assistant/message;画布续读实时日志时按会话列表报的序号少读了一条,恰好是带答案的那条,节点随后被镜像成空回答。现在按实际持有的最后一条事件续读,且镜像永不把已有回答改写为空。思考过程重新同步显示:宿主订阅 Harness 新的流事件(agent/assistant-stream),正文和思考逐字到达节点,没有流的运行时从每步的 reasoning 块补发。「对话 | 思维图」开关回到浮动位置,空态也能切换(0.4.18 的标题栏开关撤回)。Agent 的工作目录改为浏览宿主机的文件夹来选,也仍可直接输入路径。",en:"DeepSeek Harness plugin: a Harness Agent node no longer shows its answer for a moment and then loses it. Newer Harness builds (0.1.5-rc.3) stop writing the token stream into the session log; a step lands as one assistant/message. When the canvas read the live log incrementally it asked from the seq the session list reported and skipped exactly one event, the one carrying the answer, and the node was then mirrored as an empty reply. It now continues from the last event it actually holds, and a mirror never rewrites an existing answer to nothing. Reasoning shows live again: the host subscribes to the Harness's new stream event (agent/assistant-stream), so text and reasoning reach the node as they are produced; a runtime without that stream gets each step's reasoning block instead. The 对话 | 思维图 switch floats again and works on the empty page (the 0.4.18 header switch is withdrawn). An agent's working directory is chosen by browsing the host's folders, with a path field still there for typing."},items:[]},{version:"0.4.18",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:历史会话列表在新版 Harness 上不再为空。dsh 从 0.1.5-rc.2 起把会话格式版本写进日志文件名(session.v3.jsonl.zstd),插件现在按已知文件名探测,新旧两种都认(#44,感谢 @LHN-xiao-hai-tun)。模型选择器加宽,条目悬停显示完整名称,Agent 执行组的长名字改为换行而不是截断,flash 与 flash-vision 一眼可辨(#43)。",en:"DeepSeek Harness plugin: the list of past sessions is no longer empty on newer Harness builds. From 0.1.5-rc.2 dsh writes the session format version into the log file name (session.v3.jsonl.zstd); the plugin now probes the known names and reads both (#44, thanks @LHN-xiao-hai-tun). The model picker is wider, every entry shows its full name on hover, and long names in the agent group wrap instead of being cut, so flash and flash-vision tell apart at a glance (#43)."},items:[]},{version:"0.4.17",date:"2026-09-21",announce:!1,lead:{zh:"DeepSeek Harness 插件:从画布向 Harness 提问时,节点只接自己那一轮。此前如果你同时在聊天框里发消息,画布节点会拿到你那轮的回答、在你那轮结束时提前收尾,并把镜像标记挂到错误的轮次上,产生重复节点;工具审批也可能被画布抢走。现在 Host 用 dsh 记在消息上的请求 id 精确认出自己的那一轮,文本、工具调用、审批、结束全部按这一轮过滤(#42,感谢 @nanami-0713)。桌面版本次只同步版本号。",en:"DeepSeek Harness plugin: a question asked from the canvas now receives only its own turn. Before, if you were also typing in the chat, the canvas node could receive your turn's answer, finish early when your turn ended, and stamp its mirror mark on the wrong turn, leaving duplicate nodes; tool approvals could be captured by the canvas as well. The host now recognises its own turn by the request id dsh records on the message, and filters text, tool calls, approvals and the end of turn to that turn alone (#42, thanks @nanami-0713). The desktop app only moves its version number."},items:[]},{version:"0.4.16",date:"2026-09-17",announce:!1,lead:{zh:"分区框:两个只是部分重叠的框不再互相收编。拖动大框时,重叠的小框和它自己的节点留在原地;拖动和一键排版现在用同一条成员规则,普通节点按中心点归属,框只有完整落在另一个框里才算它的成员(#40,感谢 @nanami-0713)。DeepSeek Harness 插件:「插件有新版本」提示复制的命令带上具体版本号,发版当天也能立刻装到新版。",en:"Frames: two frames that merely overlap no longer own each other. Dragging the larger one leaves the overlapping smaller frame and its own nodes in place; dragging and auto layout now share one membership rule, nodes by centre and a frame only when it lies fully inside another (#40, thanks @nanami-0713). DeepSeek Harness plugin: the update hint now copies a command naming the exact version, so a release installs on its first day too."},items:[]},{version:"0.4.15",date:"2026-09-15",announce:!1,lead:{zh:"分区框三件事:一键排版后,框跟着框内的节点重新包好(#32);拖动外框会带动嵌套在里面的框;重叠时小框叠在大框上面,标题栏不再被盖住。三项均来自 @hexu321。DeepSeek Harness 插件:「对话 | 思维图」切换器移进会话标题栏,不再遮挡标题;返回按钮居中,画布右上的工具栏保持可见;从画布切回会话的跳转修好了(#30,来自 @nanami-0713)。插件重新在 npm 上发布,安装命令恢复为包名。",en:"Frames, three fixes: after auto layout a frame re-wraps the nodes it held (#32); dragging an outer frame carries the frames nested inside it; where frames overlap, the smaller one stacks on top so its title bar stays reachable. All three by @hexu321. DeepSeek Harness plugin: the 对话 | 思维图 switch moves into the session header and no longer covers the title; the back button sits top centre, clear of the canvas toolbar; jumping from the canvas back to a session works again (#30, by @nanami-0713). The plugin is back on npm and the install command is the package name again."},items:[]},{version:"0.4.14",date:"2026-09-11",announce:!1,lead:{zh:"插件的「有新版本」提示现在复制 dsh plugin --profile web add dsh-thoughtdag@latest,这条命令对从 npm 装和从 Release 文件装的用户都有效(update 对文件安装无效)。其余同 0.4.13。",en:"The plugin's update hint now copies dsh plugin --profile web add dsh-thoughtdag@latest, which works for installs from npm and from a release file alike (update does nothing for a file install). Otherwise the same as 0.4.13."},items:[]},{version:"0.4.13",date:"2026-09-11",announce:!1,lead:{zh:"修复:DeepSeek Harness 插件里,模型选择器丢失了「Harness · 模型」这一组 Agent 条目(0.4.11 起,机器上没装 Pi、Codex 等命令行时整组消失)。原因是思维图把 Harness 给的条目当成本机命令行的探测结果替换掉了,现在只替换命令行报来的那几种。插件里「如何使用」的教程动图也能显示了(#35,感谢 @Moya-Doc)。",en:`Fix: inside the DeepSeek Harness plugin, the model picker lost the "Harness · model" agent entries (since 0.4.11; with no Pi or Codex CLI on the machine the whole group vanished). The canvas had been replacing the harness's entries with the local CLI probe; now only the entries the CLIs report get replaced. The tutorial gifs inside the plugin load again (#35, thanks @Moya-Doc).`},items:[]},{version:"0.4.12",date:"2026-09-10",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 子节点现在续接父节点的会话;同一父节点下的第二个分支从父节点那一轮分叉出自己的会话,preset 的会话状态不再在每个子节点重头开始(#28、#29)。插件的构建脚本在 Windows 上也能跑了(#24、#26)。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an agent child node now continues its parent's session, and a second branch off the same parent forks its own session at that parent's turn, so a preset's session state no longer restarts at every child (#28, #29). The plugin's build script runs on Windows too (#24, #26). The desktop app only moves its version number."},items:[]},{version:"0.4.11",date:"2026-09-08",announce:!1,lead:{zh:"性能优化:启动更快,后台更省,多个工具调用并行时更稳;300 节点以上的画布实测流畅。ThoughtDAG 现在可以用 Claude Code、Codex、Pi 作为节点的 Agent 运行时,处于测试阶段。",en:"Performance: faster launch, lighter in the background, steadier when several tool calls run in parallel; canvases past 300 nodes measured smooth. ThoughtDAG can now run a node through Claude Code, Codex or Pi as its agent runtime, in testing."},items:[]},{version:"0.4.10",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览继续:Codex 加入,和 Pi 一样在画布里带工具作答;这条通道现在在桌面版、本地网页版和 DeepSeek Harness 插件里都可用;插件里的 Harness Agent 按模型平铺;插件有新版本时画布会提示。",en:"Agent runs, preview continued: Codex joins Pi, answering with tools right from the canvas; the lane now works in the desktop app, the local web app and the DeepSeek Harness plugin alike; inside the plugin the Harness agent lists one entry per model; the canvas tells you when a newer plugin is out."},items:[]},{version:"0.4.9",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览:桌面版的模型选择器多了「Agent 执行」组,装了 Pi 的话可以直接在画布里让它带工具作答,轨迹、足迹、审批和提问都落在节点上,工作目录在顶栏可见可改。正式版会连同 Claude Code 与 Codex 一起发布。DeepSeek Harness 插件里的审批卡片同步更新。",en:'Agent runs, preview: the desktop picker gains an "Agent runs" group; with Pi installed, a question runs through it with tools right from the canvas, and the trace, footprints, approvals and questions land on the node, with the working directory visible on the toolbar. The full release will arrive together with Claude Code and Codex. The approval card inside the DeepSeek Harness plugin is updated alike.'},items:[]},{version:"0.4.8",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件在 Windows 上能打开了:静态资源和会话目录的路径守卫此前只认正斜杠,Windows 用户看到的是一片 403。感谢 GitHub 上的报告(#23)。桌面版本次只同步版本号。",en:"The DeepSeek Harness plugin now opens on Windows: the path guards for static assets and session directories only accepted forward slashes, so Windows users saw nothing but 403s. Thanks to the report on GitHub (#23). The desktop app only moves its version number this time."},items:[]},{version:"0.4.7",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 需要你批准的操作现在直接出现在节点上:工具、命令、理由,允许一次或拒绝,决定留在节点记录里。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an action the agent needs approved now appears on the node itself: tool, command, reason, allow once or reject, and the decision stays in the node's record. The desktop app only moves its version number this time."},items:[]},{version:"0.4.6",date:"2026-09-06",announce:!0,lead:{zh:"🎉 Pi 的会话进了对话地图,「⋯」菜单里多了更新历史,随时能回看每一版改了什么。",en:"🎉 Pi sessions join the Session Atlas, and the ⋯ menu gains a release history, so what every version changed is one click away."},items:[{title:{zh:"Pi 的会话也在地图上了",en:"Pi sessions are on the map"},body:{zh:"本地 Pi 会话按项目聚在一起,打开就是一张图。Pi 里的每次分叉在图上就是一条支线,不再压成一条直线。命令行 why 和 MCP 也同步认识 Pi 留下的文件足迹。",en:"Local Pi sessions group by project and open as a graph. Every fork you made in Pi shows up as a branch instead of being flattened into one line. The why command and MCP index Pi's file footprints too."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"更新历史,随时补看",en:"Release history, whenever you like"},body:{zh:"右上「⋯」菜单,「如何使用」下面。每个版本改了什么都在这里,从新到旧,当前版本有标记。",en:"In the ⋯ menu, under How it works: what each release changed, newest first, with the version you are running marked."}}]},{version:"0.4.5",date:"2026-09-06",announce:!0,lead:{zh:"🎉 这是 ThoughtDAG 到目前为止最大的一次升级:散在各个 Agent 里的对话接成了一张地图,能从画布里查,还能直接在 DeepSeek Harness 里用。四件新东西,都值得试一试。",en:"🎉 The biggest ThoughtDAG release so far: the conversations scattered across your agents become one map, you can query them, and it all runs inside DeepSeek Harness. Four new things, each worth a try."},items:[{title:{zh:"跨 Agent 的对话地图,终于连成一张",en:"Session Atlas: all your agents, one map"},body:{zh:"Claude Code、Codex 和 DeepSeek Harness 的本地会话按项目文件夹聚在一起,点开就是一张图,随对话实时生长。",en:"Local Claude Code, Codex and DeepSeek Harness sessions, grouped by project; open one as a graph and it follows the conversation live."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"命令行 why:一条命令找回塑造文件的那些对话",en:"thoughtdag why: one command finds the conversations that shaped a file"},body:{zh:"npx thoughtdag why <文件> 列出哪些轮次读过、改过它,当时问了什么、改了什么;find 按原话搜,MCP 让 Agent 自己来查。",en:"npx thoughtdag why <file> lists the turns that read or changed it, what was asked and what changed; find searches verbatim; MCP lets your agent ask."},link:{label:{zh:"命令与 MCP",en:"CLI and MCP"},href:`${Lc}/zh/guides/why-layer`}},{title:{zh:"DeepSeek Harness 插件上线",en:"DeepSeek Harness plugin is live"},body:{zh:'dsh plugin --profile web add dsh-thoughtdag,Harness 的网页里多一个"思维图"视图:在画布上提问、让 Harness 的 Agent 带工具作答,why 也成了它的原生工具。',en:"dsh plugin --profile web add dsh-thoughtdag adds a canvas view to the Harness web UI: ask from the canvas, let its agent answer with tools, and why becomes a native tool there."},link:{label:{zh:"插件说明",en:"Plugin README"},href:"https://github.com/chenxiachan/thoughtdag/tree/main/dsh#readme"}},{title:{zh:"文档站上线",en:"The docs site is live"},body:{zh:"概念、任务指南、命令字典和隐私说明各有一页,中英文对照。感谢一路同行,欢迎来 Discussions 说说你怎么用它。",en:"Concepts, task guides, the command dictionary and the privacy notes, each on its own page, in both languages. Thank you for coming this far with us; tell us how you use it in Discussions."},link:{label:{zh:"打开文档",en:"Open the docs"},href:`${Lc}/zh/`}}]},{version:"0.4.4",date:"2026-09-04",announce:!1,lead:{zh:"DeepSeek Harness 成为对话地图的内置来源:它的 zstd 日志由桌面壳逐帧解码,每条消息一个节点,工具调用与结果配对成附件。",en:"DeepSeek Harness becomes a built-in Atlas source: the shell decodes its zstd logs frame by frame, one node per message, tool calls paired with their results as attachments."},items:[]},{version:"0.4.3",date:"2026-09-03",announce:!1,lead:{zh:"深链接可以直达某一轮,画布可以按稳定 id 打开;子 Agent 的会话文件不再打扰实时监听。",en:"A deep link can land on a turn and a canvas opens by its stable id; subagent session files no longer disturb the live watcher."},items:[]},{version:"0.4.2",date:"2026-09-02",announce:!1,lead:{zh:"镜像节点列出那一轮碰过的文件(✏️ 改过、📖 读过),预览用结论而不是开头;子 Agent 的会话作为子线程识别,报告折回发起它的那一轮。",en:"A mirrored node lists the files its turn touched (✏️ edited, 📖 read) and previews the conclusion rather than the opening line; subagent files are recognized as sub-threads and their reports fold into the launching turn."},items:[]},{version:"0.4.1",date:"2026-09-01",announce:!1,lead:{zh:"Agent 对话地图首发:本地 Claude Code 与 Codex 的会话按项目文件夹聚成一张图,一键接入,随对话实时生长。",en:"Session Atlas debuts: local Claude Code and Codex sessions group by project folder into one map, connect in one click, and grow with the conversation."},items:[]}];function Uy(e,t){const n=e.split(".").map(r=>parseInt(r,10)||0),a=t.split(".").map(r=>parseInt(r,10)||0);for(let r=0;r<Math.max(n.length,a.length);r++){const s=(n[r]??0)-(a[r]??0);if(s!==0)return s}return 0}function em(e,t){return zM.filter(n=>n.announce&&Uy(n.version,t)<=0&&(e===null||Uy(n.version,e)>0))}const qy="thoughtdag.whatsNewSeen",sue=new URLSearchParams(window.location.search);function iue(){if(!_s)return[];const e=sue.get("wn");if(e==="1")return em(null,_s);if(e)return em(e,_s);let t=null;try{t=localStorage.getItem(qy)}catch{}if(t===null){let n=!1;try{n=!!(localStorage.getItem("thoughtdag.tutorialDone")||localStorage.getItem("thoughtdag.lastBackupAt"))}catch{}if(!n){try{localStorage.setItem(qy,_s)}catch{}return[]}return em(null,_s)}return t===_s?[]:em(t,_s)}function BM({media:e,lang:t}){const n=e.src[t],a=/\.(mp4|webm)$/i.test(n);return l.jsx("div",{className:"mt-3 rounded-xl border border-line overflow-hidden bg-wash",style:{aspectRatio:`${e.width} / ${e.height}`},"data-whats-new-media":!0,children:a?l.jsx("video",{src:`/thoughtdag/${n}`,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-full object-cover","aria-label":e.alt[t]}):l.jsx("img",{src:`/thoughtdag/${n}`,alt:e.alt[t],className:"w-full h-full object-cover"})})}function HM({items:e,lang:t}){return e.length===0?null:l.jsx("ol",{className:"divide-y divide-line",children:e.map((n,a)=>l.jsxs("li",{className:"py-3 flex gap-3.5",children:[l.jsx("span",{className:"shrink-0 w-6 h-6 rounded-full bg-accent/10 text-accent text-xs font-semibold flex items-center justify-center mt-0.5",children:a+1}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-ink",children:n.title[t]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1 [overflow-wrap:anywhere]",children:n.body[t]}),n.media&&l.jsx(BM,{media:n.media,lang:t}),n.link&&l.jsxs("a",{href:n.link.href,target:"_blank",rel:"noreferrer",className:"inline-block mt-1.5 text-xs font-medium text-accent hover:underline",children:[n.link.label[t]," →"]})]})]},a))})}function oue(){const[e,t]=D.useState(()=>iue()),n=e.length>0,a=Da(u=>u.lang),r=St(),s=D.useRef(null),o=()=>{if(_s)try{localStorage.setItem(qy,_s)}catch{}t([])};return D.useEffect(()=>{if(!n)return;s.current?.focus({preventScroll:!0});const u=d=>{d.stopPropagation(),(d.key==="Escape"||d.key==="Enter")&&o()};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[n]),n?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:o,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:u=>u.stopPropagation(),role:"dialog","aria-labelledby":"whats-new-title","data-whats-new":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"whats-new-title",className:"text-base font-semibold text-ink mt-0.5",children:ve(r("whatsNew.title"),{v:_s??""})}),e.length>1&&l.jsx("p",{className:"text-xs text-ink-faint mt-1",children:r("whatsNew.multi")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:e.map(u=>l.jsxs("li",{className:"py-4","data-release":u.version,children:[e.length>1&&l.jsxs("div",{className:"flex items-baseline gap-2.5 mb-1.5",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",u.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:u.date})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed [overflow-wrap:anywhere]",children:u.lead[a]}),u.media&&l.jsx(BM,{media:u.media,lang:a}),l.jsx(HM,{items:u.items,lang:a})]},u.version))}),l.jsxs("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex items-center justify-between gap-4",children:[l.jsx("button",{onClick:()=>{o(),oe.getState().setReleaseNotesOpen(!0)},className:"text-xs text-ink-muted hover:text-ink hover:underline transition-colors","data-whats-new-all":!0,children:r("whatsNew.seeAll")}),l.jsx("button",{ref:s,onClick:o,className:"text-xs text-white px-4 py-2 rounded-lg bg-accent hover:bg-accent-strong transition-colors",children:r("whatsNew.ok")})]})]})}):null}function lue(){const e=St(),t=oe(a=>a.ladderJob);if(D.useEffect(()=>{if(!t||t.running)return;const a=setTimeout(gT,8e3);return()=>clearTimeout(a)},[t]),!t)return null;const n=t.total?Math.min(1,(t.done+t.failed)/t.total):1;return l.jsxs("div",{className:"fixed bottom-4 right-4 z-[85] w-[300px] bg-card border border-line rounded-xl shadow-lg px-4 py-3 animate-fade-in","data-ladder-job":!0,"data-ladder-job-running":t.running?"yes":"no",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(u2,{size:14,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-ink flex-1",children:e("ladder.jobTitle")}),t.running?l.jsxs("button",{onClick:yle,disabled:t.cancelled,className:"flex items-center gap-1 text-2xs text-ink-muted hover:text-red-600 disabled:opacity-50","data-ladder-job-stop":!0,children:[l.jsx(U0,{size:10,strokeWidth:1.75,fill:"currentColor"})," ",t.cancelled?e("ladder.jobStopping"):e("ladder.jobStop")]}):l.jsx("button",{onClick:gT,className:"text-ink-faint hover:text-ink",title:e("ladder.jobClose"),"data-ladder-job-close":!0,children:l.jsx(cn,{size:13,strokeWidth:1.75})})]}),l.jsx("div",{className:"mt-2 h-1 rounded-full bg-wash overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent transition-[width] duration-300",style:{width:`${Math.round(n*100)}%`}})}),l.jsx("p",{className:"mt-1.5 text-2xs text-ink-muted tabular-nums","data-ladder-job-line":!0,children:t.running?ve(e("ladder.jobProgress"),{n:t.done+t.failed,m:t.total,model:t.model}):(t.cancelled?ve(e("ladder.jobStopped"),{n:t.done}):ve(e("ladder.jobDone"),{n:t.done,k:t.skipped}))+(t.failed?ve(e("ladder.jobFailed"),{f:t.failed}):"")}),!t.running&&t.failed>0&&t.lastError&&l.jsx("p",{className:"mt-1 text-2xs text-red-500 break-words","data-ladder-job-error":!0,children:t.lastError})]})}function cue(){const e=oe(r=>r.releaseNotesOpen),t=oe(r=>r.setReleaseNotesOpen),n=Da(r=>r.lang),a=St();return D.useEffect(()=>{if(!e)return;const r=s=>{s.key==="Escape"&&(s.stopPropagation(),t(!1))};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t]),e?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:r=>r.stopPropagation(),role:"dialog","aria-labelledby":"release-notes-title","data-release-notes":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"release-notes-title",className:"text-base font-semibold text-ink mt-0.5",children:a("releaseNotes.title")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:zM.map(r=>{const s=_s===r.version;return l.jsxs("li",{className:"py-4","data-release":r.version,children:[l.jsxs("div",{className:"flex items-baseline gap-2.5 flex-wrap",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",r.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:r.date}),s&&l.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-accent bg-accent/10 rounded-full px-2 py-0.5",children:a("releaseNotes.current")})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1.5 [overflow-wrap:anywhere]",children:r.lead[n]}),l.jsx(HM,{items:r.items,lang:n})]},r.version)})}),l.jsx("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex justify-end",children:l.jsx("button",{onClick:()=>t(!1),className:"text-xs text-ink px-4 py-2 rounded-lg border border-line hover:bg-wash transition-colors",children:a("common.close")})})]})}):null}const Tb=e=>e.split("/").filter(Boolean).slice(-1)[0]??e;function uue(){const e=St(),t=oe(_=>_.selectedModel),n=sn(_=>_.activeId),a=sn(_=>_.projects),r=se(_=>_.nodes.length),[s,o]=D.useState(null),[u,d]=D.useState(null),[h,m]=D.useState(!1),[p,x]=D.useState(""),[,b]=D.useState(0),y=D.useRef(null),w=!!window.desktopSessions&&S2(t),E=!!window.desktopAgents&&(ri(t)||w);if(D.useEffect(()=>{if(!E)return;let _=!0;return B2(w).then(S=>{_&&o(S)}),MV().then(S=>{_&&d(S)}),()=>{_=!1}},[E,w,n,a,r]),D.useEffect(()=>{if(!h)return;const _=z=>{y.current&&!y.current.contains(z.target)&&m(!1)},S=z=>{z.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",S)}},[h]),!E||!s)return null;const v=a.find(_=>_.id===n),A=[...new Set(a.map(_=>_.agentCwd).filter(_=>!!_))].filter(_=>_!==v?.agentCwd).slice(0,5),T=async _=>{n&&(await W2(n,_),m(!1))},C=window.desktopAgents?.capabilities?.nativePicker!==!1,I=async()=>{const _=await window.desktopAgents.pickCwd();_?await T(_):window.desktopAgents?.capabilities?.nativePicker===!1&&b(S=>S+1)},O=async()=>{const _=p.trim();_.startsWith("/")&&await T(_)};return l.jsxs("div",{ref:y,className:"relative",children:[l.jsxs("button",{onClick:_=>{_.stopPropagation(),m(S=>!S)},className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-2.5 flex items-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-xs text-ink max-w-[220px]",title:`${e("agent.cwd")} · ${s.cwd}`,"data-agent-cwd":s.kind,children:[l.jsx(cu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate",children:s.kind==="workspace"?e("agent.cwdWorkspace"):Tb(s.cwd)}),l.jsx(cr,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"})]}),h&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 w-[320px] bg-card border border-line rounded-xl shadow-lg py-1.5 z-50 animate-fade-in",onClick:_=>_.stopPropagation(),children:[l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.cwd")}),l.jsxs("button",{onClick:()=>{T(void 0)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:u?e("agent.cwdMirrored"):s.kind==="session"?e("agent.cwdSession"):e("agent.cwdWorkspace")}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:u??(s.kind==="session"?s.cwd:e("agent.cwdWorkspaceHint"))})]}),!v?.agentCwd&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),v?.agentCwd&&l.jsxs("button",{onClick:()=>{T(v.agentCwd)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Tb(v.agentCwd)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:v.agentCwd})]}),l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),A.length>0&&l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-2 pb-1",children:e("agent.cwdRecent")}),A.map(_=>l.jsx("button",{onClick:()=>{T(_)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2",children:l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Tb(_)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:_})]})},_)),l.jsx("div",{className:"border-t border-line/60 my-1"}),C?l.jsxs("button",{onClick:()=>{I()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash flex items-center gap-2","data-agent-cwd-pick":!0,children:[l.jsx(cu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",e("agent.cwdPick")]}):l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("input",{value:p,onChange:_=>x(_.target.value),onKeyDown:_=>{_.stopPropagation(),_.key==="Enter"&&O()},placeholder:e("agent.cwdType"),className:"flex-1 min-w-0 text-xs font-mono bg-wash border border-line rounded-md px-2 py-1 focus:outline-none focus:border-accent/60","data-agent-cwd-input":!0}),l.jsx("button",{onClick:()=>{O()},className:"text-xs text-accent hover:underline shrink-0",children:e("agent.cwdUse")})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.guard")}),l.jsxs("button",{onClick:()=>{UE("ask"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"ask",children:[l.jsx(CU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAsk")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAskHint")})]}),(v?.agentGuard?.mode??"ask")==="ask"&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),l.jsxs("button",{onClick:()=>{UE("allow"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"allow",children:[l.jsx(MU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAllow")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAllowHint")})]}),v?.agentGuard?.mode==="allow"&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),(v?.agentGuard?.allow?.length??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-2xs text-ink-faint px-3 pt-2 pb-1",children:e("agent.guardAllowed")}),v.agentGuard.allow.map(_=>l.jsxs("div",{className:"px-3 py-1 text-xs flex items-center gap-2 min-w-0","data-agent-guard-allowed":_,children:[l.jsx("span",{className:"flex-1 min-w-0 truncate text-ink-muted font-mono",title:_,children:_}),l.jsx("button",{onClick:()=>{A7(_,!0)},className:"text-ink-faint hover:text-red-500 shrink-0",title:e("agent.guardRemove"),children:l.jsx(cn,{size:12,strokeWidth:2})})]},_))]})]})]})}const UT="thoughtdag.pluginUpdateNotified";function $y(e){return`dsh plugin --profile web add dsh-thoughtdag@${e||"latest"}`}async function due(e){try{const t=await fetch(e.replace(/\/+$/,"")+"/version",{credentials:"same-origin"});if(!t.ok)return;const n=await t.json();if(!n.version||!n.latest||Uy(n.latest,n.version)<=0)return;oe.getState().setPluginUpdate({current:n.version,latest:n.latest});let a=null;try{a=localStorage.getItem(UT)}catch{}if(a!==n.latest){try{localStorage.setItem(UT,n.latest)}catch{}const r=oe.getState().harnessHost?.desktop??(()=>{try{const s=window.parent?.document?.documentElement;return!!s&&(s.dataset.platform!==void 0||s.hasAttribute("data-windows-titlebar"))}catch{return!1}})();We("info",ve(Te("plugin.updateAvailable"),{v:n.latest})+(r?" "+ve(Te("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${n.latest}`}):""),12e3)}}catch{}}const hue=Object.freeze(Object.defineProperty({__proto__:null,bootPluginUpdateCheck:due,pluginUpdateCommand:$y},Symbol.toStringTag,{value:"Module"})),fue={ruleout:"#ef4444",decision:"#6B5CE7",pivot:"#e8890c",open:"#d97706",insight:"#0284c7"},qT=e=>{if(e){for(let t=e.length-1;t>=0;t--)if(e[t])return e[t]}};function mue(e){if(e.stepKind==="file")return e.attachments?.[0]?.name;if(e.stepKind==="link")return e.linkTitle||e.linkUrl;if(e.stepKind==="note")return e.question?.split(`
|
|
907
|
+
${m}`.slice(-1500)}const d=Zce(e,o,t);if(Tl!==a)return;oe.getState().setCondenseRun({status:"done",streaming:"",distillIds:d.distillIds}),We("success",Te("condense.copyReady"),8e3,{label:Te("tmap.export"),run:()=>oe.getState().setThoughtMapOpen(!0)})}catch(o){if(Tl!==a)return;oe.getState().setCondenseRun({status:"error",error:o instanceof Error?o.message:String(o)})}}function tue({onFocusSegment:e}){const t=oe(P=>P.condenseDialogOpen),n=oe(P=>P.condenseRun),a=St(),r=Da(P=>P.lang),s=se(P=>P.nodes),o=se(P=>P.edges),[u,d]=D.useState(0),h=D.useMemo(()=>t&&n.status==="idle"?Yce(s,o):[],[t,n.status,s,o,u]),m=oe(P=>P.selectedModel),p=Yl()?.models??[],[x,b]=D.useState(""),[y,w]=D.useState(new Set),[E,v]=D.useState(null),A=D.useRef(null),T=P=>{const L=A.current?.getBoundingClientRect();if(!L)return;const Y=P.clientX-L.left,q=P.clientY-L.top,B=$=>v({x:Math.min(window.innerWidth-120,Math.max(0,$.clientX-Y)),y:Math.min(window.innerHeight-80,Math.max(0,$.clientY-q))}),j=()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",j)},C=P=>P.nodeIds.join(","),I=h.filter(P=>!y.has(C(P))),O=I.reduce((P,L)=>P+L.saving,0),_=()=>{oe.getState().setCondenseDialogOpen(!1),oe.getState().setCondenseHighlightIds([])};if(D.useEffect(()=>{if(!t)return;const P=L=>{L.key==="Escape"&&_()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),!t)return null;const S=()=>{I.length!==0&&eue(I,r,x||m||void 0)},z=()=>{se.getState().setArchived(n.originalIds,!0),We("success",a("condense.originalArchived")),oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:"",originalIds:[],distillIds:[]}),_()},V=()=>{const L=se.getState().nodes.filter(Y=>n.distillIds.includes(Y.id));L.length&&e?.(L.map(Y=>Y.id))};return ur.createPortal(l.jsxs("div",{ref:A,className:"fixed z-[70] bg-surface border border-line rounded-2xl shadow-2xl w-[400px] max-h-[72vh] flex flex-col p-4 animate-fade-in",style:E?{left:E.x,top:E.y}:{left:80,bottom:16},"data-condense-dialog":!0,onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between mb-1 cursor-grab active:cursor-grabbing select-none",onMouseDown:T,children:[l.jsxs("div",{className:"text-sm font-semibold text-ink flex items-center gap-2",children:[l.jsx(xp,{size:15,strokeWidth:1.75,className:"text-accent"})," ",a("condense.title")]}),l.jsx("button",{onClick:_,title:n.status==="building"?a("condense.runningBg"):void 0,className:"text-ink-faint hover:text-ink rounded-lg w-7 h-7 flex items-center justify-center hover:bg-wash transition-colors",children:l.jsx(cn,{size:15})})]}),n.status==="idle"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsx("p",{className:"text-2xs text-ink-faint leading-snug",title:a("condense.copyIntroFull"),children:a("condense.copyIntroShort")}),l.jsxs("button",{onClick:()=>d(P=>P+1),title:a("condense.rescanTitle"),"data-condense-rescan":!0,className:"text-2xs text-ink-muted hover:text-accent px-2 py-1 rounded-lg hover:bg-wash transition-colors shrink-0",children:["⟳ ",a("condense.rescan")]})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2","data-condense-scanline":!0,children:ve(a("condense.scanLine"),{turns:String(s.filter(P=>P.data.response&&!P.data.stepKind).length),n:String(h.length)})}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("label",{className:"text-2xs text-ink-muted shrink-0",children:a("condense.modelLabel")}),l.jsxs("select",{value:x,onChange:P=>b(P.target.value),"data-condense-model":!0,className:"text-xs bg-wash text-ink rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/40 max-w-[220px] truncate",children:[l.jsx("option",{value:"",children:ve(a("condense.modelGlobal"),{model:m||"auto"})}),p.map(P=>l.jsx("option",{value:P.id,children:P.id},P.id))]})]}),h.length===0?l.jsx("p",{className:"text-xs text-ink-muted py-4",children:a("condense.segNothing")}):l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:h.map(P=>{const L=C(P),Y=!y.has(L);return l.jsxs("div",{"data-condense-item":!0,className:`border rounded-xl p-3 transition-colors cursor-pointer ${Y?"border-accent/60 bg-accent/5":"border-line opacity-60"}`,onClick:()=>{oe.getState().setCondenseHighlightIds(P.nodeIds),e?.(P.nodeIds)},children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("input",{type:"checkbox",checked:Y,onClick:q=>q.stopPropagation(),onChange:()=>w(q=>{const B=new Set(q);return B.has(L)?B.delete(L):B.add(L),B}),className:"accent-[var(--color-accent)]","data-condense-check":!0}),l.jsx("span",{className:"text-2xs text-ink-faint font-mono",children:ve(a("condense.segMeta"),{n:String(P.nodeIds.length),tok:String(P.saving)})})]}),l.jsx("p",{className:"text-xs text-ink mt-1 leading-snug line-clamp-2",children:P.headQuestion})]},L)})}),h.length>0&&l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-3 mt-2 border-t border-line",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:a("condense.copyFootnote")}),l.jsxs("button",{onClick:S,disabled:I.length===0,"data-condense-build":!0,className:"text-xs bg-accent text-white px-3.5 py-2 rounded-lg disabled:opacity-40 transition-colors flex items-center gap-1.5 shrink-0",children:[l.jsx(to,{size:13,strokeWidth:1.75}),ve(a("condense.buildCopy"),{n:String(I.length),tok:String(O)})]})]})]}),n.status==="building"&&l.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted mb-1.5",children:[l.jsx(nn,{size:15,className:"animate-spin text-accent"}),ve(a("condense.buildingRun"),{i:String(n.current),n:String(n.total)})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2",children:a("condense.runningBg")}),n.streaming&&l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto text-2xs text-ink-muted bg-wash rounded-lg p-2.5 whitespace-pre-wrap leading-relaxed","data-condense-streaming":!0,children:n.streaming}),l.jsx("button",{onClick:()=>Jce(),"data-condense-cancel":!0,className:"self-start mt-3 text-xs text-ink-muted hover:text-red-600 px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="error"&&l.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[l.jsx("p",{className:"text-2xs text-red-600",children:n.error}),l.jsx("button",{onClick:()=>oe.getState().setCondenseRun({status:"idle",error:void 0}),className:"self-start text-xs text-ink-muted hover:text-ink px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="done"&&l.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-700",children:[l.jsx(es,{size:16})," ",a("condense.copyReady")]}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:a("condense.copyCompareHint")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:V,className:"text-xs bg-accent/10 text-accent hover:bg-accent/20 px-3 py-2 rounded-lg transition-colors",children:a("condense.viewCopy")}),l.jsxs("button",{onClick:z,"data-condense-archive-original":!0,className:"text-xs border border-line text-ink-muted hover:text-ink hover:bg-wash px-3 py-2 rounded-lg transition-colors flex items-center gap-1.5",children:[l.jsx(el,{size:13,strokeWidth:1.75})," ",a("condense.archiveOriginal")]})]}),l.jsx("button",{onClick:()=>{oe.getState().setCondenseRun({status:"idle"}),_()},className:"self-start text-xs text-ink-faint hover:text-ink transition-colors",children:a("common.close")})]})]}),document.body)}function HT(){const e=Da(n=>n.lang),t=Da(n=>n.setLang);return l.jsx("div",{className:"flex items-center bg-card/90 backdrop-blur border border-line rounded-lg shadow-sm overflow-hidden",children:["en","zh"].map(n=>l.jsx("button",{onClick:()=>t(n),className:`px-2 h-8 text-2xs font-medium transition-colors ${e===n?"bg-accent text-white":"text-ink-muted hover:bg-wash"}`,children:n==="en"?"EN":"中"},n))})}function ma({x:e,y:t,w:n=34,h:a=20,tone:r="plain"}){return l.jsxs("g",{children:[l.jsx("rect",{x:e,y:t,width:n,height:a,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),r!=="plain"&&l.jsx("rect",{x:e,y:t,width:2.5,height:a,rx:1.25,fill:r==="accent"?it.accent:it.warm})]})}const nue={1:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:32,tone:"accent"}),l.jsx("circle",{cx:60,cy:28,r:2.5,fill:it.accent})]}),2:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:12,tone:"accent"}),l.jsx("line",{x1:60,y1:32,x2:60,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 47 L 60 52 L 63 47 Z",fill:it.accent}),l.jsx(ma,{x:43,y:52})]}),3:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:20,y:12,tone:"accent"}),l.jsx("line",{x1:37,y1:32,x2:37,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 34 47 L 37 52 L 40 47 Z",fill:it.accent}),l.jsx(ma,{x:20,y:52}),l.jsx("rect",{x:26,y:58,width:14,height:3,rx:1.5,fill:it.trace,opacity:.6}),l.jsx("path",{d:"M 54 62 C 64 62, 62 40, 72 38",stroke:it.warm,strokeWidth:1.75,fill:"none",strokeDasharray:"4 3"}),l.jsx("path",{d:"M 69 35.5 L 74 38 L 70 41 Z",fill:it.warm}),l.jsx(ma,{x:74,y:28,tone:"warm"})]}),4:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:52,stroke:it.line,strokeWidth:1.75,strokeDasharray:"3 3"}),l.jsx("circle",{cx:60,cy:41,r:7,fill:"white",stroke:"#FCA5A5",strokeWidth:1}),l.jsx("line",{x1:57,y1:38,x2:63,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx("line",{x1:63,y1:38,x2:57,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx(ma,{x:43,y:54})]}),5:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:12,y:14,w:40,h:15}),l.jsx("circle",{cx:14,cy:16,r:4.5,fill:"#D64533"}),l.jsx("text",{x:14,y:18.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"✕"}),l.jsx(ma,{x:12,y:35,w:40,h:15}),l.jsx("circle",{cx:14,cy:37,r:4.5,fill:it.accent}),l.jsx("text",{x:14,y:39.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"⚖"}),l.jsx(ma,{x:12,y:56,w:40,h:15}),l.jsx("circle",{cx:14,cy:58,r:4.5,fill:"#C9A227"}),l.jsx("text",{x:14,y:60.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"?"}),l.jsx("path",{d:"M 62 42 L 74 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 71.5 39.5 L 76 42 L 71.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:86,y:14,width:13,height:13,rx:4.5,fill:"#D64533"}),l.jsx("line",{x1:92.5,y1:27,x2:92.5,y2:35,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:35,width:13,height:13,rx:4.5,fill:it.accent}),l.jsx("line",{x1:92.5,y1:48,x2:92.5,y2:56,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:56,width:13,height:13,rx:4.5,fill:"#C9A227"})]}),7:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:14,y:12,width:30,height:22,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("line",{x1:29,y1:34,x2:29,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 26 47 L 29 52 L 32 47 Z",fill:it.accent}),l.jsx(ma,{x:12,y:52,tone:"accent"}),l.jsx("path",{d:"M 100 22 C 80 22, 70 55, 50 60",stroke:it.accent,strokeWidth:1.75,fill:"none",strokeDasharray:"5 3"}),l.jsx("path",{d:"M 52 57 L 47 61 L 52 64 Z",fill:it.accent}),l.jsx(ma,{x:82,y:12})]}),9:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:48,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 45 L 60 50 L 63 45 Z",fill:it.accent}),l.jsx(ma,{x:43,y:50}),l.jsx("circle",{cx:75,cy:53,r:4,fill:"#F59E0B"}),l.jsx("path",{d:"M 73.5 53 a 1.5 1.5 0 1 1 3 0",stroke:"white",strokeWidth:.9,fill:"none"}),l.jsx("text",{x:60,y:80,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"v2/2 · replay"})]}),6:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:18,width:14,height:48,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:15,cy:27,r:3,fill:it.accent,opacity:.7}),l.jsx("rect",{x:12,y:37,width:6,height:6,rx:1,fill:"#F59E0B",opacity:.8}),l.jsx("rect",{x:12,y:49,width:6,height:6,rx:1,fill:it.inkMuted,opacity:.5}),l.jsx("rect",{x:38,y:14,width:32,height:24,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("rect",{x:80,y:14,width:32,height:24,rx:3,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:88,cy:22,r:3,fill:it.line}),l.jsx("path",{d:"M 82 34 L 92 26 L 100 32 L 108 24",stroke:it.inkMuted,strokeWidth:1.2,fill:"none"}),l.jsx("text",{x:72,y:62,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"⌘V paste anything"})]}),8:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:8,width:70,height:52,rx:3,fill:it.accent,opacity:.06,stroke:it.accent,strokeWidth:.8,strokeDasharray:"3 2"}),l.jsx(ma,{x:14,y:14,w:26,h:16}),l.jsx(ma,{x:46,y:14,w:26,h:16}),l.jsx(ma,{x:30,y:38,w:26,h:16}),l.jsx("path",{d:"M 40 46 C 60 50, 70 50, 84 48",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 59 30 C 70 36, 76 42, 84 46",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 43 22 C 66 24, 76 38, 84 44",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx(ma,{x:84,y:40,w:28,h:18,tone:"accent"})]}),10:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:10,y:18,w:30,h:17,tone:"accent"}),l.jsx("line",{x1:25,y1:35,x2:25,y2:48,stroke:it.accent,strokeWidth:1.5}),l.jsx("path",{d:"M 22.5 45.5 L 25 50 L 27.5 45.5 Z",fill:it.accent}),l.jsx(ma,{x:10,y:50,w:30,h:17}),l.jsx("path",{d:"M 46 42 L 60 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 57.5 39.5 L 62 42 L 57.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:68,y:20,width:44,height:44,rx:5,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx(ma,{x:74,y:30,w:20,h:11,tone:"accent"}),l.jsx(ma,{x:88,y:46,w:20,h:11}),l.jsx("rect",{x:76,y:14,width:28,height:11,rx:5.5,fill:"#2B2A28"}),l.jsx("circle",{cx:84,cy:19.5,r:2.6,fill:"none",stroke:"white",strokeWidth:1}),l.jsx("circle",{cx:84,cy:19.5,r:.9,fill:"white"}),l.jsx("text",{x:90,y:22,fontSize:6,fill:"white",fontFamily:"JetBrains Mono Variable, monospace",children:"view"}),l.jsx("text",{x:60,y:78,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"#view= · read-only"})]})},FT={4:"prune",5:"map",6:"reading",7:"ref"};function aue(){const e=oe(h=>h.tutorialOpen),t=oe(h=>h.setTutorialOpen);D.useEffect(()=>{if(!e)return;const h=m=>{m.key==="Escape"&&t(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t]);const n=St(),a=Da(h=>h.lang),[r,s]=D.useState(0),o=[{label:n("tutorial.pg1"),steps:[1,2,3]},{label:n("tutorial.pg2"),steps:[4,5]},{label:n("tutorial.pg3"),steps:[6,7]},{label:n("tutorial.pg4"),steps:[8,9,10]}],u=r===o.length-1;if(D.useEffect(()=>{if(!e)return;s(0);const h=m=>{m.key==="ArrowRight"&&s(p=>Math.min(p+1,o.length-1)),m.key==="ArrowLeft"&&s(p=>Math.max(p-1,0))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e]),!e)return null;const d=o[r];return l.jsx("div",{className:"fixed inset-0 z-[95] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-[min(980px,94vw)] flex flex-col",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between px-7 pt-5 pb-1 shrink-0",children:[l.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[l.jsx("h2",{className:"text-lg font-semibold text-ink tracking-tight shrink-0",children:n("tutorial.title")}),l.jsx("p",{className:"text-xs text-ink-faint truncate",children:n("tutorial.subtitle")})]}),l.jsx("button",{onClick:()=>t(!1),className:"text-ink-faint hover:text-ink transition-colors mt-1",children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 pt-3 pb-1 min-h-[380px]",children:[l.jsx("p",{className:"text-2xs font-semibold text-accent mb-3 uppercase tracking-wider",children:d.label}),l.jsx("div",{className:`grid gap-4 ${d.steps.length===3?"grid-cols-1 sm:grid-cols-3":"grid-cols-1 sm:grid-cols-2"}`,children:d.steps.map(h=>l.jsxs("div",{className:"bg-surface border border-line/70 rounded-xl p-4 flex flex-col animate-fade-in",children:[l.jsx("div",{className:"w-full aspect-[120/72] bg-card rounded-lg border border-line/60 mb-3 overflow-hidden",children:FT[h]?l.jsx("img",{src:`/thoughtdag/tutorial/${FT[h]}-${a}.gif`,loading:"lazy",alt:"",className:"w-full h-full object-cover"}):nue[h]}),l.jsx("h3",{className:"text-[13px] font-semibold text-ink leading-snug",children:n(`tutorial.step${h}.title`)}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed mt-1.5",children:n(`tutorial.step${h}.desc`)})]},h))})]}),l.jsxs("div",{className:"px-7 py-4 shrink-0 flex items-center justify-between",children:[l.jsx("button",{onClick:()=>s(h=>Math.max(h-1,0)),disabled:r===0,className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center disabled:opacity-25 disabled:cursor-not-allowed",children:l.jsx(Tm,{size:16,strokeWidth:1.75})}),l.jsx("div",{className:"flex items-center gap-2",children:o.map((h,m)=>l.jsx("button",{onClick:()=>s(m),className:`h-2 rounded-full transition-all ${m===r?"w-6 bg-accent":"w-2 bg-line hover:bg-line-strong"}`,"aria-label":`${m+1}/${o.length}`},m))}),u?l.jsx("button",{onClick:()=>t(!1),className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors",children:n("tutorial.close")}):l.jsx("button",{onClick:()=>s(h=>h+1),className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center",children:l.jsx(Ba,{size:16,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 py-2.5 border-t border-line/60 shrink-0 flex flex-wrap gap-x-4 gap-y-1 text-2xs text-ink-faint font-mono",children:[l.jsxs("span",{children:[n("shortcut.panKeys")," ",n("shortcut.pan")]}),l.jsxs("span",{children:[n("shortcut.marqueeKeys")," ",n("shortcut.marquee")]}),l.jsxs("span",{children:["⌘","F ",n("shortcut.search")]}),l.jsxs("span",{children:["Space ",n("shortcut.collapse")]}),l.jsxs("span",{children:["R ",n("shortcut.regenerate")]}),l.jsxs("span",{children:["↑↓←→"," ",n("shortcut.navigate")]}),l.jsxs("span",{children:["⌘","Z/","⇧","⌘","Z ",n("shortcut.undo")]}),l.jsxs("span",{children:["Del ",n("shortcut.delete")]}),l.jsxs("span",{children:["Esc ",n("shortcut.escape")]})]})]})})}const rue=new URLSearchParams(window.location.search),_s=rue.get("dv"),Lc="https://chenxiachan.github.io/thoughtdag/docs",zM=[{version:"0.5.8",date:"2026-09-30",announce:!1,lead:{zh:"修复 0.5.7 的一处遗漏:回答里的消毒把画布自己加的标记也剥掉了,从回答文字跳到分支的入口失效,用户高亮和探索标记都退化成默认黄底。现在两种标记保留各自的类和目标,跳转、点状下划线、高亮填色都回来了。",en:"Fixes an oversight in 0.5.7: the answer sanitizer also stripped the marks the canvas adds itself, so the jump from an answer to the branch it bore stopped working and highlights and explore marks fell back to the browser's plain yellow. Both marks keep their class and target again; the jump, the dotted underline and the highlight fill are back."},items:[]},{version:"0.5.7",date:"2026-09-30",announce:!1,lead:{zh:"安全修补:回答里的原始 HTML 先经过消毒再渲染,折叠块、上下标、键帽、高亮、表格、换行照旧,能执行脚本或嵌入外部页面的标签(iframe、object、script、style、form 等)被去掉;此前分享链接、导入的画布或模型引用的网页都能借 srcdoc 的 iframe 在本页面的源里执行代码。托管代理的模型探测只接受公网 https 地址,两处网页快照抓取共用一套地址检查并逐跳核对重定向。另外两处小修:「重跑上游已变」只跑确认框里数到的那些,牌子摘要不再参考已归档的步骤。",en:"Security: raw HTML in an answer is sanitized before rendering; folds, sub/sup, kbd, highlights, tables and line breaks stay, while tags that run scripts or embed pages (iframe, object, script, style, form and the like) are stripped. Until now a shared link, an imported canvas or a page the model quoted could run code in this origin through a srcdoc iframe. The hosted proxy's model probe takes public https endpoints only, and both page-snapshot fetchers share one address guard and check every redirect hop. Two small fixes: replay reruns exactly the stale nodes the dialog counts, and plaque summaries no longer read archived steps."},items:[]},{version:"0.5.6",date:"2026-09-30",announce:!1,lead:{zh:"回忆改成安静的小标签,默认关:输入框旁一个「回忆」,点开是开关、搜索范围(轻量 40 条 / 深挖 2,000 条 / 全量)和带入上下文,改的只对这一次提问生效,「设为默认」写回全局;深挖和全量由判断模型分批看候选,全量先告诉你条数、秒数和费用。判断模型页的开关并进供应商下拉(最后一项「关闭,按规则」);联网和学术搜索也默认关。每个节点都有可缩放的摘要:一句话的回答、笔记、文件都上梯子。双击卡片上的问题,侧栏编辑框带着原文打开。Harness 插件:思维图顶上是自己的标题带(不再压住红绿灯);自己的模型接口回来了,添加、拉模型列表、调用都走插件;不再提示桌面版新版本,插件更新提示直接说在插件页重新添加哪个包;桌面版 0.2 写的 v4 会话文件进得了对话地图。",en:`Recall is a quiet chip, off by default: a "Recall" beside the composer opens the switch, the search reach (light 40 / deep 2,000 / full) and the context brought in; a change there holds for the next ask only, "set as default" writes it back. Deep and full have the decision model read candidates in batches; full first says how many turns, seconds and dollars. The decision model page folds its switch into the provider dropdown (last entry: off, rules decide); web and scholar search start off too. Every node zooms: one-line answers, notes and files get a ladder. Double-clicking a card's question opens the side panel editor with the text in place. Harness plugin: the map wears its own title band (clear of the traffic lights); its own model interfaces are back, added, listed and called through the plugin; no more desktop-app update nudge, and the plugin's own notice names the package to re-add on the Plugins page; the 0.2 desktop's v4 session files reach the atlas.`},items:[]},{version:"0.5.5",date:"2026-09-29",announce:!1,lead:{zh:"换档不再互相盖住:缩小到地图层时,节点的牌子不会超出布局留给它的位置,写不下的摘要在底部渐隐,再放大一档就能看全;折叠卡显示和牌子同一段摘要,放大缩小之间只是字号在变。节点间距略微拉开,已有画布的位置不动,按「一键排版」才换成新间距。另外:从 Finder 启动时也能找到本机的 Pi、Codex、Claude Code 命令行,找不到会说明查过哪些地方,可重新检测;子 Agent 的运行展开在父画布上,作为那一轮旁边的分支;模型接口分成「慢思考 · 回答模型」和「快思考 · 判断模型」两页,只用 Agent 的人也能单独接判断模型;新装机没有模型时会先问一次本机的 Agent。",en:"Zoom tiers no longer cover each other: at map zoom a node's plaque stays inside the room the layout keeps for it, an abstract that runs past it fades out at the bottom and shows in full one step in; the folded card carries the same abstract as the plaque, so zooming only changes the type size. Node gaps open slightly; existing canvases keep their positions until you choose Tidy layout. Also: the Pi, Codex and Claude Code CLIs are found under a Finder launch, and a missing one says where it looked, with a recheck; a subagent's run unfolds on the parent canvas as a branch beside its turn; the model dialog has two pages, slow thinking for answering models and fast thinking for the decision model, which agent-only users can connect on its own; a fresh install with no model asks the local agents first."},items:[]},{version:"0.5.4",date:"2026-09-29",announce:!1,lead:{zh:"鼠标滚轮恢复缩放画布,和 0.5.2 一样。0.5.3 起滚轮改成了平移,这对触控板顺手,却让鼠标用户没法用滚轮缩放。触控板用户可以在画布 ⋯ 菜单打开「滚轮平移画布」:双指滑动即平移,捏合或按住 ⌘/Ctrl 滚动来缩放。",en:"The mouse wheel zooms the canvas again, as in 0.5.2. Since 0.5.3 it panned, which suits a trackpad but left mouse users without wheel zoom. On a trackpad, turn on ⋯ → Wheel pans the canvas: a two-finger scroll pans, pinch or hold ⌘/Ctrl while scrolling to zoom."},items:[]},{version:"0.5.3",date:"2026-09-27",announce:!1,lead:{zh:"圈选多个节点后,工具栏多了「更新节点摘要」:用当前选中的模型为它们一次更新四层摘要,文件、便签和短回答自动跳过。进度在右下角,随时可停。旧画布想整体升级到新摘要,圈一下就行。右键单个节点也是同一个入口。",en:'With several nodes selected, the toolbar gains "Update node summaries": the picked model updates their four summary levels in one go, files, notes and short answers skipped. Progress shows bottom right and can be stopped any time. An older canvas upgrades to the new summaries with one lasso; the right-click item on a single node is the same door.'},items:[{title:{zh:"🧭 摘要写的是这一步新增了什么",en:"🧭 Summaries say what the step adds"},body:{zh:"结论与短述改为由模型撰写。写之前它先读这条思路里前面各步的牌匾,只写本步新增的结论、决定或转向,不重复前面已经说过的;概要仍是原答里的原文摘句,作为证据。旧节点用「更新节点摘要」换新即可。",en:'The takeaway and brief are now written by the model. It first reads the plaques of the earlier steps in the thread, then writes only what this step adds, a conclusion, a decision or a turn, without repeating what came before; the abstract stays verbatim sentences of the answer, as evidence. Older nodes switch over with "Update node summaries".'}},{title:{zh:"🖐️ 触控板双指滑动即平移",en:"🖐️ Two-finger scroll pans"},body:{zh:"在触控板上双指滑动就能移动画布,不用再按住按键拖。捏合缩放不变。鼠标滚轮现在同样是平移,缩放请按住 ⌘(Windows 上是 Ctrl)再滚。感谢 @Pireirik 的贡献。",en:"On a trackpad, a two-finger scroll moves the canvas; no button to hold. Pinch still zooms. A mouse wheel now pans too; hold ⌘ (Ctrl on Windows) to zoom with it. Contributed by @Pireirik."}}]},{version:"0.5.2",date:"2026-09-27",announce:!0,lead:{zh:"🔍 上下文管理重大更新!现在,无论画布缩放至何种比例,节点内容始终保持极佳的阅读体验。",en:"🔍 A major update to context management! Whatever the zoom, every node on the canvas now stays a pleasure to read."},media:{src:{zh:"whats-new/zoom-ladder-zh.mp4",en:"whats-new/zoom-ladder-en.mp4"},alt:{zh:"缩小画布时,牌匾上的结论逐词长成短述再长成摘要",en:"Zooming out, a plaque's takeaway grows word by word into a brief, then an abstract"},width:960,height:600},items:[{title:{zh:"🪜 智能四层摘要",en:"🪜 Four smart summary levels"},body:{zh:"每个回答自动构建「主题、结论、短述、完整概要」四个递进层级,随缩放比例自动无缝切换。",en:"Every answer builds four progressive levels, topic, takeaway, brief and full abstract, and switches between them seamlessly as you zoom."}},{title:{zh:"✨ 丝滑的视觉过渡",en:"✨ Silky visual transitions"},body:{zh:"缩放时,文字会逐词自然展开或收起。保留的关键词会平滑移动,新文本自然淡入,核心重点始终高亮加深。视线聚焦零中断,数十个节点的全局脉络一眼即达。",en:"As you zoom, text unfolds or folds word by word. The words that stay glide into place, new text fades in, and the key points stay highlighted in full ink. Your focus is never broken, and the shape of dozens of nodes reads at a glance."}},{title:{zh:"🔁 新旧节点全面兼容",en:"🔁 New and old nodes alike"},body:{zh:"新回答自动生效该特性;旧节点会在浏览时实时生成摘要层级,若需更精准的 AI 总结,只需右键一键生成。",en:"New answers get it automatically; older nodes build their levels live as you browse, and for a sharper AI-selected summary, one right-click does it."}},{title:{zh:"🎚️ 时间线详略随手调",en:"🎚️ Timeline detail at your fingertips"},body:{zh:"时间线弹窗新增详略滑块,从主题一路拉到完整概要,字号与行距随手指流动,每一步文字完整呈现,告别省略号。",en:"The timeline overview gains a detail slider: glide from topic to full abstract, type and spacing flowing with your drag, every step shown whole, no ellipsis anywhere."},media:{src:{zh:"whats-new/timeline-detail-zh.mp4",en:"whats-new/timeline-detail-en.mp4"},alt:{zh:"拖动时间线弹窗的详略滑块,每一步的文字逐词展开",en:"Dragging the timeline overview's detail slider, each step's text unfolds word by word"},width:720,height:760}},{title:{zh:"🛡️ 所见即所发",en:"🛡️ What you see is what is sent"},body:{zh:"判断模型认定上游改动与答案无关时,「上游已变」标记现在同时从预览和请求中退场,两者始终一致。感谢 Agent Memory Atlas 的审阅指出这一点。",en:'When the decision model rules an upstream change irrelevant, the "upstream changed" mark now leaves the preview and the request together, always in step. Thanks to the Agent Memory Atlas review for catching it.'}},{title:{zh:"🧹 右键菜单焕新",en:"🧹 A refreshed right-click menu"},body:{zh:"「重新生成」更简洁,CLI 相关操作合并为一项,新增「用模型重选摘要」。手动修改过的回答会自动重做摘要。",en:'"Regenerate" is simpler, the CLI actions merge into one, and "Update node summary" joins the menu. Hand-edited answers get their summaries redone automatically.'}}]},{version:"0.5.1",date:"2026-09-26",announce:!1,lead:{zh:"0.5 之后的一批修正。删除正在生成的节点时,那一轮生成随之中止,不再在后台跑完。记忆的自动写入上限按画布分开计,切换画布后重新计;之前是全局三条写满就静默。档案更新只带走模型读过的那几条待归档事实,更新期间新归档的保留下来;档案文件的写入排队进行,不再互相覆盖。why 层不再把执行失败的文件操作算作改动足迹,更新后索引会重建一次。判断模型直接沿用模型接入里保存的 OpenRouter key,不再显示为空、测试不可点。",en:"A round of fixes after 0.5. Deleting a node that is still generating stops that generation instead of letting it run on in the background. The memory judge's automatic-write cap counts per canvas and starts over on a canvas switch; it used to be one global count of three, after which memory went quiet. A dossier update takes only the filed facts the model read and keeps anything filed while it was writing; dossier writes queue instead of overwriting one another. The why layer no longer counts a file operation the harness answered with an error as a change, and the index rebuilds once. The decision model uses the OpenRouter key saved with your model providers, instead of showing an empty field with a disabled test."},items:[]},{version:"0.5.0",date:"2026-09-26",announce:!0,lead:{zh:"🎉 ThoughtDAG 0.5:记忆上线。你在 Pi、Codex、Claude Code、DeepSeek Harness 里聊过的一切,现在接成一个可以回忆的整体。散在几百个会话里的碎片,按主题整理成档案;提问时相关的档案和对话自动带进上下文,跨 Agent、跨时间。背后是快思考与慢思考的分工:慢思考模型回答,快思考模型判断。所有信息都在你自己的机器上。",en:"🎉 ThoughtDAG 0.5: memory. Everything you discussed in Pi, Codex, Claude Code and DeepSeek Harness now forms one whole you can recall. Fragments scattered across hundreds of sessions are organised into dossiers by topic; when you ask, the relevant dossiers and conversations ride into the context, across agents and across time. Behind it, a division of labour: a slow-thinking model answers, a fast-thinking model decides. Everything stays on your machine."},items:[{title:{zh:"碎片串成一条线",en:"Fragments become a thread"},body:{zh:"昨天在 Codex 里定的阈值,上周在 Claude Code 里排除的方案,今天在画布上问起时都在。每个主题一份档案:是什么、定过什么、到哪一步、还没解决什么,每句都能点回原来的那轮对话。「你」是两份文档:偏好与身份,记到新东西时改写而不是堆砌。原来的记忆条目已并入。",en:"The threshold you settled in Codex yesterday and the approach you ruled out in Claude Code last week are there when you ask on the canvas today. Every topic keeps a dossier: what it is, what was decided, where it stands, what is still open, each line pointing back to its turn. Your profile is two documents, preferences and identity, rewritten rather than piled up. Earlier memory entries were folded in."},link:{label:{zh:"记忆指南",en:"The memory guide"},href:`${Lc}/zh/guides/memory`}},{title:{zh:"提问时自动回忆",en:"Recall as you ask"},media:{src:{zh:"whats-new/jev-recall.mp4",en:"whats-new/jev-recall.mp4"},alt:{zh:"回忆流程里,判断模型半秒内从候选片段中选出相关的几条",en:"In the recall flow the decision model picks the relevant excerpts from the candidates in under a second"},width:1200,height:720},body:{zh:"开着「回忆」提问,先判断问题涉及哪些主题,把档案整份带进去;问的是细节时再补几条原话。带了什么、花了多少,面板上一条一条看得见,不想要的划掉就不带。带入量三档:省、标准、多带。",en:"With recall on, a question is first matched to its topics and their dossiers ride in whole; a question about a detail brings a few verbatim excerpts too. What came in and what it cost is listed item by item; strike one and it stays out. Three amounts: lean, standard, generous."}},{title:{zh:"快思考,慢思考",en:"Fast thinking, slow thinking"},body:{zh:"回答你的是慢思考模型。判断「这条相关吗」「这句是决定吗」「这处改动影响吗」的是快思考模型:半秒一次,返回校准过的概率,让回忆、地图徽章和「上游已变」都有依据。模型选择器里一行开关,默认开;关掉全部退回规则,功能不变。",en:"The slow-thinking model answers you. The fast-thinking model decides — is this relevant, is this line a decision, does this change matter — in half a second, with calibrated probabilities, so recall, map badges and “upstream changed” rest on evidence. One switch in the model picker, on by default; off, every decision falls back to a rule and nothing stops working."}},{title:{zh:"接入一个快思考模型",en:"Connect a fast-thinking model"},body:{zh:"Jev 类判断模型可以经你已保存的聚合商接入直接使用,也支持官方接口和自建服务;没有接入时会提示,一切照常。",en:"A Jev-class decision model runs through the aggregator access you already saved, through the official endpoint, or from a self-hosted server; without one you are told, and everything still works."},link:{label:{zh:"怎么接入",en:"How to connect one"},href:`${Lc}/zh/setup#decision-model`}},{title:{zh:"一切都在本地",en:"All of it stays local"},body:{zh:"索引、主题标签、档案存在本机 .thoughtdag 目录,画像文档存在应用本地。判断时发出去的只有问题和候选片段,发给你自己选的接入。",en:"The index, topic labels and dossiers live in your machine's .thoughtdag folder; your profile lives in the app's own storage. A decision sends only the question and the candidate excerpts, to the access you chose."}}]},{version:"0.4.20",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件一轮实测后的整理。「对话 | 思维图」开关:对话页顶部仍是浮动的,切到思维图后它移到画布顶栏「画布名」右侧,不再压住画布工具栏。工作目录改用 Harness 自己的目录选择器:本机运行时弹的就是系统的文件夹对话框,远程访问时回落为输入路径;0.4.19 里自带的目录浏览器撤掉。Harness Agent 也能选工作目录,新会话按所选目录运行。插件里去掉配置模型 API 的入口。实时镜像刷新会话时不再把镜头拉回节点。节点记录的是发起请求时的模型,执行中切换选择器不再改写徽章。Harness 执行中的每个工具调用都列为一条步骤,思考尾巴显示在下方。备份提醒去掉。",en:"DeepSeek Harness plugin, after a round of hands-on testing. The 对话 | 思维图 switch still floats over the chat; on the canvas it sits in the canvas's own top bar next to the canvas chip, so it never covers the toolbar. The working directory is chosen in the harness's own picker: the system folder dialog when the harness runs on this machine, a typed path when reached remotely; the folder browser 0.4.19 carried is withdrawn. The Harness Agent gets the folder chip too, and a fresh session runs where it says. The API-key door is gone inside the plugin. The live mirror no longer drags the camera back to a node while its session refreshes. A node records the model it was asked with; switching the picker mid-run no longer relabels it. Every tool call of a harness run is listed as a step, the thinking beneath. The backup reminder is removed."},items:[]},{version:"0.4.19",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:Harness Agent 节点的回答不再「闪一下就没了」。新版 Harness(0.1.5-rc.3)不再把逐字流写进会话日志,一步只落一条 assistant/message;画布续读实时日志时按会话列表报的序号少读了一条,恰好是带答案的那条,节点随后被镜像成空回答。现在按实际持有的最后一条事件续读,且镜像永不把已有回答改写为空。思考过程重新同步显示:宿主订阅 Harness 新的流事件(agent/assistant-stream),正文和思考逐字到达节点,没有流的运行时从每步的 reasoning 块补发。「对话 | 思维图」开关回到浮动位置,空态也能切换(0.4.18 的标题栏开关撤回)。Agent 的工作目录改为浏览宿主机的文件夹来选,也仍可直接输入路径。",en:"DeepSeek Harness plugin: a Harness Agent node no longer shows its answer for a moment and then loses it. Newer Harness builds (0.1.5-rc.3) stop writing the token stream into the session log; a step lands as one assistant/message. When the canvas read the live log incrementally it asked from the seq the session list reported and skipped exactly one event, the one carrying the answer, and the node was then mirrored as an empty reply. It now continues from the last event it actually holds, and a mirror never rewrites an existing answer to nothing. Reasoning shows live again: the host subscribes to the Harness's new stream event (agent/assistant-stream), so text and reasoning reach the node as they are produced; a runtime without that stream gets each step's reasoning block instead. The 对话 | 思维图 switch floats again and works on the empty page (the 0.4.18 header switch is withdrawn). An agent's working directory is chosen by browsing the host's folders, with a path field still there for typing."},items:[]},{version:"0.4.18",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:历史会话列表在新版 Harness 上不再为空。dsh 从 0.1.5-rc.2 起把会话格式版本写进日志文件名(session.v3.jsonl.zstd),插件现在按已知文件名探测,新旧两种都认(#44,感谢 @LHN-xiao-hai-tun)。模型选择器加宽,条目悬停显示完整名称,Agent 执行组的长名字改为换行而不是截断,flash 与 flash-vision 一眼可辨(#43)。",en:"DeepSeek Harness plugin: the list of past sessions is no longer empty on newer Harness builds. From 0.1.5-rc.2 dsh writes the session format version into the log file name (session.v3.jsonl.zstd); the plugin now probes the known names and reads both (#44, thanks @LHN-xiao-hai-tun). The model picker is wider, every entry shows its full name on hover, and long names in the agent group wrap instead of being cut, so flash and flash-vision tell apart at a glance (#43)."},items:[]},{version:"0.4.17",date:"2026-09-21",announce:!1,lead:{zh:"DeepSeek Harness 插件:从画布向 Harness 提问时,节点只接自己那一轮。此前如果你同时在聊天框里发消息,画布节点会拿到你那轮的回答、在你那轮结束时提前收尾,并把镜像标记挂到错误的轮次上,产生重复节点;工具审批也可能被画布抢走。现在 Host 用 dsh 记在消息上的请求 id 精确认出自己的那一轮,文本、工具调用、审批、结束全部按这一轮过滤(#42,感谢 @nanami-0713)。桌面版本次只同步版本号。",en:"DeepSeek Harness plugin: a question asked from the canvas now receives only its own turn. Before, if you were also typing in the chat, the canvas node could receive your turn's answer, finish early when your turn ended, and stamp its mirror mark on the wrong turn, leaving duplicate nodes; tool approvals could be captured by the canvas as well. The host now recognises its own turn by the request id dsh records on the message, and filters text, tool calls, approvals and the end of turn to that turn alone (#42, thanks @nanami-0713). The desktop app only moves its version number."},items:[]},{version:"0.4.16",date:"2026-09-17",announce:!1,lead:{zh:"分区框:两个只是部分重叠的框不再互相收编。拖动大框时,重叠的小框和它自己的节点留在原地;拖动和一键排版现在用同一条成员规则,普通节点按中心点归属,框只有完整落在另一个框里才算它的成员(#40,感谢 @nanami-0713)。DeepSeek Harness 插件:「插件有新版本」提示复制的命令带上具体版本号,发版当天也能立刻装到新版。",en:"Frames: two frames that merely overlap no longer own each other. Dragging the larger one leaves the overlapping smaller frame and its own nodes in place; dragging and auto layout now share one membership rule, nodes by centre and a frame only when it lies fully inside another (#40, thanks @nanami-0713). DeepSeek Harness plugin: the update hint now copies a command naming the exact version, so a release installs on its first day too."},items:[]},{version:"0.4.15",date:"2026-09-15",announce:!1,lead:{zh:"分区框三件事:一键排版后,框跟着框内的节点重新包好(#32);拖动外框会带动嵌套在里面的框;重叠时小框叠在大框上面,标题栏不再被盖住。三项均来自 @hexu321。DeepSeek Harness 插件:「对话 | 思维图」切换器移进会话标题栏,不再遮挡标题;返回按钮居中,画布右上的工具栏保持可见;从画布切回会话的跳转修好了(#30,来自 @nanami-0713)。插件重新在 npm 上发布,安装命令恢复为包名。",en:"Frames, three fixes: after auto layout a frame re-wraps the nodes it held (#32); dragging an outer frame carries the frames nested inside it; where frames overlap, the smaller one stacks on top so its title bar stays reachable. All three by @hexu321. DeepSeek Harness plugin: the 对话 | 思维图 switch moves into the session header and no longer covers the title; the back button sits top centre, clear of the canvas toolbar; jumping from the canvas back to a session works again (#30, by @nanami-0713). The plugin is back on npm and the install command is the package name again."},items:[]},{version:"0.4.14",date:"2026-09-11",announce:!1,lead:{zh:"插件的「有新版本」提示现在复制 dsh plugin --profile web add dsh-thoughtdag@latest,这条命令对从 npm 装和从 Release 文件装的用户都有效(update 对文件安装无效)。其余同 0.4.13。",en:"The plugin's update hint now copies dsh plugin --profile web add dsh-thoughtdag@latest, which works for installs from npm and from a release file alike (update does nothing for a file install). Otherwise the same as 0.4.13."},items:[]},{version:"0.4.13",date:"2026-09-11",announce:!1,lead:{zh:"修复:DeepSeek Harness 插件里,模型选择器丢失了「Harness · 模型」这一组 Agent 条目(0.4.11 起,机器上没装 Pi、Codex 等命令行时整组消失)。原因是思维图把 Harness 给的条目当成本机命令行的探测结果替换掉了,现在只替换命令行报来的那几种。插件里「如何使用」的教程动图也能显示了(#35,感谢 @Moya-Doc)。",en:`Fix: inside the DeepSeek Harness plugin, the model picker lost the "Harness · model" agent entries (since 0.4.11; with no Pi or Codex CLI on the machine the whole group vanished). The canvas had been replacing the harness's entries with the local CLI probe; now only the entries the CLIs report get replaced. The tutorial gifs inside the plugin load again (#35, thanks @Moya-Doc).`},items:[]},{version:"0.4.12",date:"2026-09-10",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 子节点现在续接父节点的会话;同一父节点下的第二个分支从父节点那一轮分叉出自己的会话,preset 的会话状态不再在每个子节点重头开始(#28、#29)。插件的构建脚本在 Windows 上也能跑了(#24、#26)。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an agent child node now continues its parent's session, and a second branch off the same parent forks its own session at that parent's turn, so a preset's session state no longer restarts at every child (#28, #29). The plugin's build script runs on Windows too (#24, #26). The desktop app only moves its version number."},items:[]},{version:"0.4.11",date:"2026-09-08",announce:!1,lead:{zh:"性能优化:启动更快,后台更省,多个工具调用并行时更稳;300 节点以上的画布实测流畅。ThoughtDAG 现在可以用 Claude Code、Codex、Pi 作为节点的 Agent 运行时,处于测试阶段。",en:"Performance: faster launch, lighter in the background, steadier when several tool calls run in parallel; canvases past 300 nodes measured smooth. ThoughtDAG can now run a node through Claude Code, Codex or Pi as its agent runtime, in testing."},items:[]},{version:"0.4.10",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览继续:Codex 加入,和 Pi 一样在画布里带工具作答;这条通道现在在桌面版、本地网页版和 DeepSeek Harness 插件里都可用;插件里的 Harness Agent 按模型平铺;插件有新版本时画布会提示。",en:"Agent runs, preview continued: Codex joins Pi, answering with tools right from the canvas; the lane now works in the desktop app, the local web app and the DeepSeek Harness plugin alike; inside the plugin the Harness agent lists one entry per model; the canvas tells you when a newer plugin is out."},items:[]},{version:"0.4.9",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览:桌面版的模型选择器多了「Agent 执行」组,装了 Pi 的话可以直接在画布里让它带工具作答,轨迹、足迹、审批和提问都落在节点上,工作目录在顶栏可见可改。正式版会连同 Claude Code 与 Codex 一起发布。DeepSeek Harness 插件里的审批卡片同步更新。",en:'Agent runs, preview: the desktop picker gains an "Agent runs" group; with Pi installed, a question runs through it with tools right from the canvas, and the trace, footprints, approvals and questions land on the node, with the working directory visible on the toolbar. The full release will arrive together with Claude Code and Codex. The approval card inside the DeepSeek Harness plugin is updated alike.'},items:[]},{version:"0.4.8",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件在 Windows 上能打开了:静态资源和会话目录的路径守卫此前只认正斜杠,Windows 用户看到的是一片 403。感谢 GitHub 上的报告(#23)。桌面版本次只同步版本号。",en:"The DeepSeek Harness plugin now opens on Windows: the path guards for static assets and session directories only accepted forward slashes, so Windows users saw nothing but 403s. Thanks to the report on GitHub (#23). The desktop app only moves its version number this time."},items:[]},{version:"0.4.7",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 需要你批准的操作现在直接出现在节点上:工具、命令、理由,允许一次或拒绝,决定留在节点记录里。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an action the agent needs approved now appears on the node itself: tool, command, reason, allow once or reject, and the decision stays in the node's record. The desktop app only moves its version number this time."},items:[]},{version:"0.4.6",date:"2026-09-06",announce:!0,lead:{zh:"🎉 Pi 的会话进了对话地图,「⋯」菜单里多了更新历史,随时能回看每一版改了什么。",en:"🎉 Pi sessions join the Session Atlas, and the ⋯ menu gains a release history, so what every version changed is one click away."},items:[{title:{zh:"Pi 的会话也在地图上了",en:"Pi sessions are on the map"},body:{zh:"本地 Pi 会话按项目聚在一起,打开就是一张图。Pi 里的每次分叉在图上就是一条支线,不再压成一条直线。命令行 why 和 MCP 也同步认识 Pi 留下的文件足迹。",en:"Local Pi sessions group by project and open as a graph. Every fork you made in Pi shows up as a branch instead of being flattened into one line. The why command and MCP index Pi's file footprints too."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"更新历史,随时补看",en:"Release history, whenever you like"},body:{zh:"右上「⋯」菜单,「如何使用」下面。每个版本改了什么都在这里,从新到旧,当前版本有标记。",en:"In the ⋯ menu, under How it works: what each release changed, newest first, with the version you are running marked."}}]},{version:"0.4.5",date:"2026-09-06",announce:!0,lead:{zh:"🎉 这是 ThoughtDAG 到目前为止最大的一次升级:散在各个 Agent 里的对话接成了一张地图,能从画布里查,还能直接在 DeepSeek Harness 里用。四件新东西,都值得试一试。",en:"🎉 The biggest ThoughtDAG release so far: the conversations scattered across your agents become one map, you can query them, and it all runs inside DeepSeek Harness. Four new things, each worth a try."},items:[{title:{zh:"跨 Agent 的对话地图,终于连成一张",en:"Session Atlas: all your agents, one map"},body:{zh:"Claude Code、Codex 和 DeepSeek Harness 的本地会话按项目文件夹聚在一起,点开就是一张图,随对话实时生长。",en:"Local Claude Code, Codex and DeepSeek Harness sessions, grouped by project; open one as a graph and it follows the conversation live."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"命令行 why:一条命令找回塑造文件的那些对话",en:"thoughtdag why: one command finds the conversations that shaped a file"},body:{zh:"npx thoughtdag why <文件> 列出哪些轮次读过、改过它,当时问了什么、改了什么;find 按原话搜,MCP 让 Agent 自己来查。",en:"npx thoughtdag why <file> lists the turns that read or changed it, what was asked and what changed; find searches verbatim; MCP lets your agent ask."},link:{label:{zh:"命令与 MCP",en:"CLI and MCP"},href:`${Lc}/zh/guides/why-layer`}},{title:{zh:"DeepSeek Harness 插件上线",en:"DeepSeek Harness plugin is live"},body:{zh:'dsh plugin --profile web add dsh-thoughtdag,Harness 的网页里多一个"思维图"视图:在画布上提问、让 Harness 的 Agent 带工具作答,why 也成了它的原生工具。',en:"dsh plugin --profile web add dsh-thoughtdag adds a canvas view to the Harness web UI: ask from the canvas, let its agent answer with tools, and why becomes a native tool there."},link:{label:{zh:"插件说明",en:"Plugin README"},href:"https://github.com/chenxiachan/thoughtdag/tree/main/dsh#readme"}},{title:{zh:"文档站上线",en:"The docs site is live"},body:{zh:"概念、任务指南、命令字典和隐私说明各有一页,中英文对照。感谢一路同行,欢迎来 Discussions 说说你怎么用它。",en:"Concepts, task guides, the command dictionary and the privacy notes, each on its own page, in both languages. Thank you for coming this far with us; tell us how you use it in Discussions."},link:{label:{zh:"打开文档",en:"Open the docs"},href:`${Lc}/zh/`}}]},{version:"0.4.4",date:"2026-09-04",announce:!1,lead:{zh:"DeepSeek Harness 成为对话地图的内置来源:它的 zstd 日志由桌面壳逐帧解码,每条消息一个节点,工具调用与结果配对成附件。",en:"DeepSeek Harness becomes a built-in Atlas source: the shell decodes its zstd logs frame by frame, one node per message, tool calls paired with their results as attachments."},items:[]},{version:"0.4.3",date:"2026-09-03",announce:!1,lead:{zh:"深链接可以直达某一轮,画布可以按稳定 id 打开;子 Agent 的会话文件不再打扰实时监听。",en:"A deep link can land on a turn and a canvas opens by its stable id; subagent session files no longer disturb the live watcher."},items:[]},{version:"0.4.2",date:"2026-09-02",announce:!1,lead:{zh:"镜像节点列出那一轮碰过的文件(✏️ 改过、📖 读过),预览用结论而不是开头;子 Agent 的会话作为子线程识别,报告折回发起它的那一轮。",en:"A mirrored node lists the files its turn touched (✏️ edited, 📖 read) and previews the conclusion rather than the opening line; subagent files are recognized as sub-threads and their reports fold into the launching turn."},items:[]},{version:"0.4.1",date:"2026-09-01",announce:!1,lead:{zh:"Agent 对话地图首发:本地 Claude Code 与 Codex 的会话按项目文件夹聚成一张图,一键接入,随对话实时生长。",en:"Session Atlas debuts: local Claude Code and Codex sessions group by project folder into one map, connect in one click, and grow with the conversation."},items:[]}];function Uy(e,t){const n=e.split(".").map(r=>parseInt(r,10)||0),a=t.split(".").map(r=>parseInt(r,10)||0);for(let r=0;r<Math.max(n.length,a.length);r++){const s=(n[r]??0)-(a[r]??0);if(s!==0)return s}return 0}function em(e,t){return zM.filter(n=>n.announce&&Uy(n.version,t)<=0&&(e===null||Uy(n.version,e)>0))}const qy="thoughtdag.whatsNewSeen",sue=new URLSearchParams(window.location.search);function iue(){if(!_s)return[];const e=sue.get("wn");if(e==="1")return em(null,_s);if(e)return em(e,_s);let t=null;try{t=localStorage.getItem(qy)}catch{}if(t===null){let n=!1;try{n=!!(localStorage.getItem("thoughtdag.tutorialDone")||localStorage.getItem("thoughtdag.lastBackupAt"))}catch{}if(!n){try{localStorage.setItem(qy,_s)}catch{}return[]}return em(null,_s)}return t===_s?[]:em(t,_s)}function BM({media:e,lang:t}){const n=e.src[t],a=/\.(mp4|webm)$/i.test(n);return l.jsx("div",{className:"mt-3 rounded-xl border border-line overflow-hidden bg-wash",style:{aspectRatio:`${e.width} / ${e.height}`},"data-whats-new-media":!0,children:a?l.jsx("video",{src:`/thoughtdag/${n}`,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-full object-cover","aria-label":e.alt[t]}):l.jsx("img",{src:`/thoughtdag/${n}`,alt:e.alt[t],className:"w-full h-full object-cover"})})}function HM({items:e,lang:t}){return e.length===0?null:l.jsx("ol",{className:"divide-y divide-line",children:e.map((n,a)=>l.jsxs("li",{className:"py-3 flex gap-3.5",children:[l.jsx("span",{className:"shrink-0 w-6 h-6 rounded-full bg-accent/10 text-accent text-xs font-semibold flex items-center justify-center mt-0.5",children:a+1}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-ink",children:n.title[t]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1 [overflow-wrap:anywhere]",children:n.body[t]}),n.media&&l.jsx(BM,{media:n.media,lang:t}),n.link&&l.jsxs("a",{href:n.link.href,target:"_blank",rel:"noreferrer",className:"inline-block mt-1.5 text-xs font-medium text-accent hover:underline",children:[n.link.label[t]," →"]})]})]},a))})}function oue(){const[e,t]=D.useState(()=>iue()),n=e.length>0,a=Da(u=>u.lang),r=St(),s=D.useRef(null),o=()=>{if(_s)try{localStorage.setItem(qy,_s)}catch{}t([])};return D.useEffect(()=>{if(!n)return;s.current?.focus({preventScroll:!0});const u=d=>{d.stopPropagation(),(d.key==="Escape"||d.key==="Enter")&&o()};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[n]),n?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:o,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:u=>u.stopPropagation(),role:"dialog","aria-labelledby":"whats-new-title","data-whats-new":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"whats-new-title",className:"text-base font-semibold text-ink mt-0.5",children:ve(r("whatsNew.title"),{v:_s??""})}),e.length>1&&l.jsx("p",{className:"text-xs text-ink-faint mt-1",children:r("whatsNew.multi")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:e.map(u=>l.jsxs("li",{className:"py-4","data-release":u.version,children:[e.length>1&&l.jsxs("div",{className:"flex items-baseline gap-2.5 mb-1.5",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",u.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:u.date})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed [overflow-wrap:anywhere]",children:u.lead[a]}),u.media&&l.jsx(BM,{media:u.media,lang:a}),l.jsx(HM,{items:u.items,lang:a})]},u.version))}),l.jsxs("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex items-center justify-between gap-4",children:[l.jsx("button",{onClick:()=>{o(),oe.getState().setReleaseNotesOpen(!0)},className:"text-xs text-ink-muted hover:text-ink hover:underline transition-colors","data-whats-new-all":!0,children:r("whatsNew.seeAll")}),l.jsx("button",{ref:s,onClick:o,className:"text-xs text-white px-4 py-2 rounded-lg bg-accent hover:bg-accent-strong transition-colors",children:r("whatsNew.ok")})]})]})}):null}function lue(){const e=St(),t=oe(a=>a.ladderJob);if(D.useEffect(()=>{if(!t||t.running)return;const a=setTimeout(gT,8e3);return()=>clearTimeout(a)},[t]),!t)return null;const n=t.total?Math.min(1,(t.done+t.failed)/t.total):1;return l.jsxs("div",{className:"fixed bottom-4 right-4 z-[85] w-[300px] bg-card border border-line rounded-xl shadow-lg px-4 py-3 animate-fade-in","data-ladder-job":!0,"data-ladder-job-running":t.running?"yes":"no",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(u2,{size:14,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-ink flex-1",children:e("ladder.jobTitle")}),t.running?l.jsxs("button",{onClick:yle,disabled:t.cancelled,className:"flex items-center gap-1 text-2xs text-ink-muted hover:text-red-600 disabled:opacity-50","data-ladder-job-stop":!0,children:[l.jsx(U0,{size:10,strokeWidth:1.75,fill:"currentColor"})," ",t.cancelled?e("ladder.jobStopping"):e("ladder.jobStop")]}):l.jsx("button",{onClick:gT,className:"text-ink-faint hover:text-ink",title:e("ladder.jobClose"),"data-ladder-job-close":!0,children:l.jsx(cn,{size:13,strokeWidth:1.75})})]}),l.jsx("div",{className:"mt-2 h-1 rounded-full bg-wash overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent transition-[width] duration-300",style:{width:`${Math.round(n*100)}%`}})}),l.jsx("p",{className:"mt-1.5 text-2xs text-ink-muted tabular-nums","data-ladder-job-line":!0,children:t.running?ve(e("ladder.jobProgress"),{n:t.done+t.failed,m:t.total,model:t.model}):(t.cancelled?ve(e("ladder.jobStopped"),{n:t.done}):ve(e("ladder.jobDone"),{n:t.done,k:t.skipped}))+(t.failed?ve(e("ladder.jobFailed"),{f:t.failed}):"")}),!t.running&&t.failed>0&&t.lastError&&l.jsx("p",{className:"mt-1 text-2xs text-red-500 break-words","data-ladder-job-error":!0,children:t.lastError})]})}function cue(){const e=oe(r=>r.releaseNotesOpen),t=oe(r=>r.setReleaseNotesOpen),n=Da(r=>r.lang),a=St();return D.useEffect(()=>{if(!e)return;const r=s=>{s.key==="Escape"&&(s.stopPropagation(),t(!1))};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t]),e?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:r=>r.stopPropagation(),role:"dialog","aria-labelledby":"release-notes-title","data-release-notes":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"release-notes-title",className:"text-base font-semibold text-ink mt-0.5",children:a("releaseNotes.title")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:zM.map(r=>{const s=_s===r.version;return l.jsxs("li",{className:"py-4","data-release":r.version,children:[l.jsxs("div",{className:"flex items-baseline gap-2.5 flex-wrap",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",r.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:r.date}),s&&l.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-accent bg-accent/10 rounded-full px-2 py-0.5",children:a("releaseNotes.current")})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1.5 [overflow-wrap:anywhere]",children:r.lead[n]}),l.jsx(HM,{items:r.items,lang:n})]},r.version)})}),l.jsx("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex justify-end",children:l.jsx("button",{onClick:()=>t(!1),className:"text-xs text-ink px-4 py-2 rounded-lg border border-line hover:bg-wash transition-colors",children:a("common.close")})})]})}):null}const Tb=e=>e.split("/").filter(Boolean).slice(-1)[0]??e;function uue(){const e=St(),t=oe(_=>_.selectedModel),n=sn(_=>_.activeId),a=sn(_=>_.projects),r=se(_=>_.nodes.length),[s,o]=D.useState(null),[u,d]=D.useState(null),[h,m]=D.useState(!1),[p,x]=D.useState(""),[,b]=D.useState(0),y=D.useRef(null),w=!!window.desktopSessions&&S2(t),E=!!window.desktopAgents&&(ri(t)||w);if(D.useEffect(()=>{if(!E)return;let _=!0;return B2(w).then(S=>{_&&o(S)}),MV().then(S=>{_&&d(S)}),()=>{_=!1}},[E,w,n,a,r]),D.useEffect(()=>{if(!h)return;const _=z=>{y.current&&!y.current.contains(z.target)&&m(!1)},S=z=>{z.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",S)}},[h]),!E||!s)return null;const v=a.find(_=>_.id===n),A=[...new Set(a.map(_=>_.agentCwd).filter(_=>!!_))].filter(_=>_!==v?.agentCwd).slice(0,5),T=async _=>{n&&(await W2(n,_),m(!1))},C=window.desktopAgents?.capabilities?.nativePicker!==!1,I=async()=>{const _=await window.desktopAgents.pickCwd();_?await T(_):window.desktopAgents?.capabilities?.nativePicker===!1&&b(S=>S+1)},O=async()=>{const _=p.trim();_.startsWith("/")&&await T(_)};return l.jsxs("div",{ref:y,className:"relative",children:[l.jsxs("button",{onClick:_=>{_.stopPropagation(),m(S=>!S)},className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-2.5 flex items-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-xs text-ink max-w-[220px]",title:`${e("agent.cwd")} · ${s.cwd}`,"data-agent-cwd":s.kind,children:[l.jsx(cu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate",children:s.kind==="workspace"?e("agent.cwdWorkspace"):Tb(s.cwd)}),l.jsx(cr,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"})]}),h&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 w-[320px] bg-card border border-line rounded-xl shadow-lg py-1.5 z-50 animate-fade-in",onClick:_=>_.stopPropagation(),children:[l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.cwd")}),l.jsxs("button",{onClick:()=>{T(void 0)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:u?e("agent.cwdMirrored"):s.kind==="session"?e("agent.cwdSession"):e("agent.cwdWorkspace")}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:u??(s.kind==="session"?s.cwd:e("agent.cwdWorkspaceHint"))})]}),!v?.agentCwd&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),v?.agentCwd&&l.jsxs("button",{onClick:()=>{T(v.agentCwd)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Tb(v.agentCwd)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:v.agentCwd})]}),l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),A.length>0&&l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-2 pb-1",children:e("agent.cwdRecent")}),A.map(_=>l.jsx("button",{onClick:()=>{T(_)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2",children:l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Tb(_)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:_})]})},_)),l.jsx("div",{className:"border-t border-line/60 my-1"}),C?l.jsxs("button",{onClick:()=>{I()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash flex items-center gap-2","data-agent-cwd-pick":!0,children:[l.jsx(cu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",e("agent.cwdPick")]}):l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("input",{value:p,onChange:_=>x(_.target.value),onKeyDown:_=>{_.stopPropagation(),_.key==="Enter"&&O()},placeholder:e("agent.cwdType"),className:"flex-1 min-w-0 text-xs font-mono bg-wash border border-line rounded-md px-2 py-1 focus:outline-none focus:border-accent/60","data-agent-cwd-input":!0}),l.jsx("button",{onClick:()=>{O()},className:"text-xs text-accent hover:underline shrink-0",children:e("agent.cwdUse")})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.guard")}),l.jsxs("button",{onClick:()=>{UE("ask"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"ask",children:[l.jsx(CU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAsk")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAskHint")})]}),(v?.agentGuard?.mode??"ask")==="ask"&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),l.jsxs("button",{onClick:()=>{UE("allow"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"allow",children:[l.jsx(MU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAllow")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAllowHint")})]}),v?.agentGuard?.mode==="allow"&&l.jsx(es,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),(v?.agentGuard?.allow?.length??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-2xs text-ink-faint px-3 pt-2 pb-1",children:e("agent.guardAllowed")}),v.agentGuard.allow.map(_=>l.jsxs("div",{className:"px-3 py-1 text-xs flex items-center gap-2 min-w-0","data-agent-guard-allowed":_,children:[l.jsx("span",{className:"flex-1 min-w-0 truncate text-ink-muted font-mono",title:_,children:_}),l.jsx("button",{onClick:()=>{A7(_,!0)},className:"text-ink-faint hover:text-red-500 shrink-0",title:e("agent.guardRemove"),children:l.jsx(cn,{size:12,strokeWidth:2})})]},_))]})]})]})}const UT="thoughtdag.pluginUpdateNotified";function $y(e){return`dsh plugin --profile web add dsh-thoughtdag@${e||"latest"}`}async function due(e){try{const t=await fetch(e.replace(/\/+$/,"")+"/version",{credentials:"same-origin"});if(!t.ok)return;const n=await t.json();if(!n.version||!n.latest||Uy(n.latest,n.version)<=0)return;oe.getState().setPluginUpdate({current:n.version,latest:n.latest});let a=null;try{a=localStorage.getItem(UT)}catch{}if(a!==n.latest){try{localStorage.setItem(UT,n.latest)}catch{}const r=oe.getState().harnessHost?.desktop??(()=>{try{const s=window.parent?.document?.documentElement;return!!s&&(s.dataset.platform!==void 0||s.hasAttribute("data-windows-titlebar"))}catch{return!1}})();We("info",ve(Te("plugin.updateAvailable"),{v:n.latest})+(r?" "+ve(Te("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${n.latest}`}):""),12e3)}}catch{}}const hue=Object.freeze(Object.defineProperty({__proto__:null,bootPluginUpdateCheck:due,pluginUpdateCommand:$y},Symbol.toStringTag,{value:"Module"})),fue={ruleout:"#ef4444",decision:"#6B5CE7",pivot:"#e8890c",open:"#d97706",insight:"#0284c7"},qT=e=>{if(e){for(let t=e.length-1;t>=0;t--)if(e[t])return e[t]}};function mue(e){if(e.stepKind==="file")return e.attachments?.[0]?.name;if(e.stepKind==="link")return e.linkTitle||e.linkUrl;if(e.stepKind==="note")return e.question?.split(`
|
|
908
908
|
`)[0].replace(/^#+\s*/,"")||void 0}function Gv(e,t,n={}){return e.filter(a=>a.data.stepKind!=="frame").map((a,r)=>{const s=a.data,o=s.createdAt??s.askedAt??s.generatedAts?.[0]??s.lastGeneratedAt,u=[s.askedAt,qT(s.generatedAts),qT(s.editedAts)].filter(Boolean).sort().pop(),d=s.summaryTypes?.[s.responseIndex??0]??void 0,h=s.summaries?.[s.responseIndex??0],m=s.summaryTopics?.[s.responseIndex??0]??void 0,p=n.ladders?s.summaryLadders?.[s.responseIndex??0]??P2(a.id,s.question,s.response,h,m):null,x=o?Date.parse(o):NaN,b=u?Date.parse(u):NaN;return{entry:{id:a.id,label:(h||mue(s)||s.question||"").slice(0,120),topic:m,...p?{ladder:p}:{},badged:!!d&&d!=="insight",type:d??void 0,createdAt:o,modifiedAt:u,color:d&&fue[d]||"#b8b3c7",archived:!!s.archived,recentlyEdited:!isNaN(x)&&!isNaN(b)&&b-x>6e4&&t-b<30*6e4,x:a.position.x,y:a.position.y},i:r}}).sort((a,r)=>{const s=a.entry.createdAt??"",o=r.entry.createdAt??"";return s<o?-1:s>o?1:a.i-r.i}).map(({entry:a})=>a)}const pue=e=>e?24:16,gue=(e,t,n)=>{const a=pue(n);if(t==null)return a;const r=Math.abs(e-t);return r===0?a+14:r===1?a+7:r===2?a+3:a};function xue(){const e=G0(),t=se(C=>C.nodes),n=se(C=>C.setSelectedNodeId),a=oe(C=>C.setTimelineOverviewOpen),r=Vl(),s=St(),o=ZA(),[u,d]=D.useState(null),[h,m]=D.useState(()=>Date.now());D.useEffect(()=>{const C=setInterval(()=>m(Date.now()),6e4);return()=>clearInterval(C)},[]);const p=ln(C=>C.transform),x=ln(C=>C.width),b=ln(C=>C.height),y=D.useMemo(()=>Gv(t,h),[t,h]),w=D.useMemo(()=>{const[C,I,O]=p,_=-C/O,S=-I/O,z=(x-C)/O,V=(b-I)/O,P=new Set;for(const L of y)L.x+520>_&&L.x<z&&L.y+220>S&&L.y<V&&P.add(L.id);return P},[y,p,x,b]);if(e==="work"||y.length<2)return null;const E=C=>C?C.slice(0,10):"",v=C=>C.slice(5).replace("-","/"),A=C=>C?new Date(C).toLocaleString(o):"",T=u?y.find(C=>C.id===u.id):null;return l.jsxs("div",{className:"absolute left-[2px] top-[calc(38%+116px)] w-[100px] z-10 tdag-timeline pointer-events-none flex flex-col items-stretch","data-timeline-bar":!0,role:"navigation","aria-label":s("timeline.label"),children:[T&&u&&l.jsxs("div",{className:"fixed left-[108px] max-w-[320px] bg-card border border-line rounded-lg shadow-md px-3 py-2 text-xs pointer-events-none z-20",style:{top:u.y-14},children:[l.jsxs("div",{className:"font-medium text-ink truncate",children:[T.topic&&l.jsxs("span",{className:"text-accent",children:[T.topic," · "]}),T.label||"…"]}),T.createdAt&&l.jsxs("div",{className:"text-ink-faint mt-0.5",children:[s("timeline.created")," ",A(T.createdAt)]}),T.modifiedAt&&T.modifiedAt!==T.createdAt&&l.jsxs("div",{className:"text-ink-faint",children:[s("timeline.modified")," ",A(T.modifiedAt)]}),l.jsx("div",{className:"text-[10px] text-ink-faint/80 mt-1",children:s("timeline.clickHint")})]}),l.jsx("button",{onClick:()=>a(!0),title:s("timeline.openOverview"),"data-timeline-overview-btn":!0,className:"pointer-events-auto self-start ml-[25px] w-7 h-7 rounded-lg flex items-center justify-center text-ink-faint/70 hover:text-accent hover:bg-accent/10 transition-colors",children:l.jsx(gp,{size:14,strokeWidth:1.75})}),l.jsx("div",{className:"pointer-events-auto overflow-y-auto tdag-noscrollbar max-h-[170px] mt-0.5",children:l.jsx("div",{className:"flex flex-col py-1",children:y.map((C,I)=>{const O=I>0?E(y[I-1].createdAt):"",_=E(C.createdAt),S=_!==""&&_!==O;return l.jsxs("button",{"data-timeline-dot":C.id,onMouseEnter:z=>d({id:C.id,idx:I,y:z.currentTarget.getBoundingClientRect().top}),onMouseLeave:()=>d(z=>z?.id===C.id?null:z),onClick:()=>{n(C.id);const z=r.getViewport().zoom;r.setCenter(C.x+260+np(C.id)/(2*z),C.y+110,{zoom:z,duration:300})},onDoubleClick:()=>{n(C.id),r.setCenter(C.x+260+np(C.id)/2,C.y+110,{zoom:1,duration:350})},className:"relative flex items-center w-full h-[14px] shrink-0 pl-[29px] cursor-pointer","aria-label":C.label,children:[l.jsx("span",{className:`rounded-full ${C.recentlyEdited?"tdag-timeline-pulse":""}`,style:{width:gue(I,u?.idx??null,C.badged),height:4,background:C.color,opacity:C.archived?.3:w.has(C.id)?1:.45,transition:"width .18s ease, opacity .3s ease"}}),S&&l.jsx("span",{className:"absolute left-[67px] top-1/2 -translate-y-1/2 text-[10px] leading-none text-ink-faint select-none whitespace-nowrap",children:v(_)})]},C.id)})})})]})}function FM(e){const t=e.filter(a=>!a.data.archived).map(a=>`${a.id}:${Ko(a.data)??""}:${a.data.summaryTypes?.[a.data.responseIndex]??""}`).sort();let n=5381;for(const a of t)for(let r=0;r<a.length;r++)n=(n<<5)+n+a.charCodeAt(r)|0;return String(n>>>0)}const Wy=new Map,bue=(e,t)=>Wy.get(`${t}:${e}`),$T={ruleout:"RULEOUT",decision:"DECISION",pivot:"PIVOT",open:"OPEN",insight:"INSIGHT"};async function yue(e,t,n){const a=FM(e),r=Wy.get(`${n}:${a}`);if(r)return r;const s=e.find(b=>b.data.isRoot),o=Gv(e.filter(b=>!b.data.archived),0),d=o.length>60?o.filter((b,y)=>b.badged||y<10||y>=o.length-10):o,h=o.length-d.length,m=d.map(b=>{const y=e.find(A=>A.id===b.id);if(!y)return null;const w=y.data,E=Ko(w);if(!E)return null;const v=w.summaryTypes?.[w.responseIndex]??void 0;return`- ${v&&$T[v]?`${$T[v]}: `:""}${b.topic?`[${b.topic}] `:""}${E}`}).filter(b=>!!b);h>0&&m.push(`(${h} plain steps omitted from this list)`);const x={text:(await er([{role:"user",content:`Opening question of a thinking map: ${s?.data.question?.slice(0,300)??"(untitled)"}
|
|
909
909
|
|
|
910
910
|
The takeaway of every step, in the order they were thought (tags: RULEOUT = killed an option, DECISION = chose, PIVOT = reframed, OPEN = still unresolved):
|
|
911
911
|
${m.join(`
|
|
912
912
|
`)}
|
|
913
913
|
|
|
914
|
-
Write the JOURNEY of this thinking as one flowing paragraph a reader absorbs in twenty seconds: where it started, what got ruled out, where it turned, where it landed, what remains open. Only the turns that mattered — do not enumerate every step. Hard limit: 250 characters for CJK languages, 500 characters otherwise. Write in ${n==="zh"?"Chinese":"English"} (the reader's interface language), even if the takeaway lines mix languages. Never use dash characters (—, –, -); use commas, colons or full stops. Output only the paragraph.`}])).trim(),fp:a,at:new Date().toISOString(),lang:n};return Wy.set(`${n}:${a}`,x),x}function vue({onLocate:e}){const t=oe(B=>B.timelineOverviewOpen),n=oe(B=>B.setTimelineOverviewOpen),a=se(B=>B.nodes),r=St(),s=ZA(),o=Da(B=>B.lang),u=pV(),d=D.useMemo(()=>Gv(a,0,{ladders:!0}),[a,u]),[h,m]=D.useState(1),p=Math.round(h),x={paddingTop:4+h*5,paddingBottom:4+h*5},b=D.useRef(null),y=D.useRef(null),w=D.useRef(null),E=B=>{const j=b.current;if(j){const $=j.getBoundingClientRect().top,X=[...j.querySelectorAll("[data-entry]")];let Q=y.current?X.find(F=>F.dataset.entry===y.current)??null:null;if(!Q){const F=$+j.clientHeight/2;Q=X.reduce((G,J)=>{const K=J.getBoundingClientRect(),ee=Math.abs((K.top+K.bottom)/2-F);return!G||ee<Math.abs((G.getBoundingClientRect().top+G.getBoundingClientRect().bottom)/2-F)?J:G},null)}w.current=Q?{id:Q.dataset.entry,y:Q.getBoundingClientRect().top-$}:null}m(B)};D.useLayoutEffect(()=>{const B=b.current,j=w.current;if(!B||!j)return;const $=B.querySelector(`[data-entry="${j.id}"]`);if(!$)return;const X=$.getBoundingClientRect().top-B.getBoundingClientRect().top;B.scrollTop+=X-j.y},[h]);const v=13+h*.9,A=D.useMemo(()=>FM(a),[a]),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(!1),z=bue(A,o)??T,V=!!z&&(z.fp!==A||z.lang!==o),P=()=>{O(!0),S(!1);const{nodes:B,edges:j}=se.getState();yue(B,j,o).then(C).catch(()=>S(!0)).finally(()=>O(!1))};if(!t)return null;const L=()=>n(!1),Y=B=>B?B.slice(0,10):"",q=B=>B?new Date(B).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit"}):"—";return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:L,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(gp,{size:15,strokeWidth:1.75,className:"text-accent"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("tlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ve(r("tlov.count"),{n:d.length})}),l.jsxs("label",{className:"flex items-center gap-2 ml-3 text-2xs text-ink-faint",title:r("tlov.detailTitle"),children:[l.jsx("span",{children:r("tlov.detail")}),l.jsx("input",{type:"range",min:0,max:3,step:.01,value:h,onChange:B=>E(Number(B.target.value)),className:"w-28 accent-accent","data-tlov-detail":!0}),l.jsx("span",{className:"text-ink-muted w-8",children:r(`ladder.level${p}`)})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{L(),oe.getState().setThoughtMapOpen(!0)},disabled:d.length===0,"data-tmap-from-timeline":!0,className:"flex items-center gap-1.5 text-2xs text-ink-muted hover:text-accent hover:bg-accent/10 rounded-full px-2.5 py-1 transition-colors disabled:opacity-50",children:[l.jsx(c2,{size:13,strokeWidth:1.75}),r("tmap.export")]}),l.jsx("button",{onClick:L,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-5 pt-3 shrink-0","data-gedankengang":!0,children:[!z&&!I&&l.jsxs("button",{onClick:P,className:"flex items-center gap-1.5 text-2xs text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-3 py-1.5 transition-colors",children:[l.jsx(Hl,{size:12,strokeWidth:1.75}),r("tlov.gedankenGenerate")]}),I&&l.jsx("p",{className:"text-2xs text-ink-faint italic py-1.5",children:r("tlov.gedankenLoading")}),_&&!I&&l.jsx("p",{className:"text-2xs text-red-500 py-1",children:r("tlov.gedankenFailed")}),z&&!I&&l.jsxs("div",{className:`rounded-xl bg-wash px-4 py-3 ${V?"opacity-60":""}`,children:[l.jsx("p",{className:"text-sm text-ink leading-relaxed",children:z.text}),l.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:V?r("tlov.gedankenStale"):new Date(z.at).toLocaleString(s)}),V&&l.jsx("button",{onClick:P,className:"text-2xs text-accent hover:underline",children:r("tlov.gedankenRedo")})]})]})]}),l.jsxs("div",{ref:b,className:"flex-1 min-h-0 overflow-y-auto px-5 py-3","data-timeline-overview":!0,children:[d.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("tlov.empty")}),d.map((B,j)=>{const $=j>0?Y(d[j-1].createdAt):void 0,X=Y(B.createdAt),Q=j===0||X!==$;return l.jsxs("div",{children:[Q&&l.jsx("div",{className:"sticky top-0 bg-card text-2xs text-ink-faint font-medium pt-3 pb-1 first:pt-0",children:X||r("tlov.undated")}),l.jsxs("div",{className:"group flex items-start gap-2.5 border-b border-line/50 last:border-0",style:x,"data-entry":B.id,onMouseEnter:()=>{y.current=B.id},onMouseLeave:()=>{y.current===B.id&&(y.current=null)},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:B.color,opacity:B.archived?.35:1}}),l.jsx("span",{className:"text-2xs font-mono text-ink-faint shrink-0 w-11",children:q(B.createdAt)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[B.ladder?l.jsx("div",{className:B.archived?"opacity-50 line-through":"",children:l.jsx(cM,{ladder:B.ladder,level:p,fontSize:v,weight:B.badged?"font-semibold":"font-medium",className:"whitespace-pre-wrap break-words"})}):l.jsx("p",{className:`leading-snug whitespace-pre-wrap break-words ${B.archived?"text-ink-faint line-through":B.badged?"text-ink":"text-ink-muted"}`,style:{fontSize:v,transition:"font-size 160ms ease-out"},children:p===0?B.topic||B.label||"…":l.jsxs(l.Fragment,{children:[B.topic&&l.jsxs("span",{className:"font-medium text-accent",children:[B.topic," · "]}),B.label||"…"]})}),B.modifiedAt&&B.modifiedAt!==B.createdAt&&l.jsxs("p",{className:"text-2xs text-ink-faint",children:[r("timeline.modified")," ",new Date(B.modifiedAt).toLocaleString(s)]})]}),l.jsx("button",{className:"shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors opacity-0 group-hover:opacity-100",onClick:()=>{L(),e(B.id)},title:r("hlov.locateTitle"),children:r("tlov.locate")})]})]},B.id)})]})]})}),document.body)}const wue=D.memo(function(t){const n=sn(a=>a.projects.find(r=>r.id===a.activeId)?.kind==="paradigm");return t.data?.stepKind==="frame"?l.jsx(Hoe,{...t}):Dm(t.data?.stepKind)?l.jsx(Boe,{...t}):n?l.jsx(joe,{...t}):l.jsx(Ooe,{...t})}),kue={thought:wue},Eue={smoothstep:D.memo(qoe)};function Sue(){const[e,t]=D.useState(Et||se.persist.hasHydrated());return D.useEffect(()=>se.persist.onFinishHydration(()=>t(!0)),[]),D.useEffect(()=>{if(!e||Et)return;let n;const a=()=>{clearTimeout(n),n=setTimeout(()=>{hce()},800)},r=se.subscribe((s,o)=>{s.nodes!==o.nodes&&a()});return a(),()=>{r(),clearTimeout(n)}},[e]),D.useEffect(()=>{oe.getState().condenseRun.status==="building"&&oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})},[]),D.useEffect(()=>{if(Et)return;const n=setTimeout(()=>{fce()},6e3);return()=>clearTimeout(n)},[]),D.useEffect(()=>{if(!e||Et||localStorage.getItem("thoughtdag.tutorialDone")||se.getState().nodes.length>0)return;const n=setTimeout(()=>oe.getState().setTutorialOpen(!0),900);return()=>clearTimeout(n)},[e]),D.useEffect(()=>{bce()},[]),D.useEffect(()=>{Et||(ft(()=>import("./session-handoff-BGisIC5k.js"),[]).then(n=>n.consumeSessionHandoff()),ft(()=>Promise.resolve().then(()=>W8),void 0).then(n=>n.startLiveMirror()),ft(()=>import("./canvas-record-UgW4msHo.js"),[]).then(n=>n.startCanvasRecord()),ft(()=>import("./canonical-4rZrwQLF.js"),[]).then(n=>n.unsubscribeOrphanedSessions()))},[]),D.useEffect(()=>{Et||xce().then(n=>{n&&(n.status==="minted"?(We("success",Te("provider.oauthMinted")),OM(n.key)):We("error",ve(Te("provider.oauthFailed"),{error:n.error})))})},[]),l.jsxs(l.Fragment,{children:[e&&l.jsx(Tue,{}),l.jsx(kce,{}),l.jsx(lue,{}),l.jsx(Sce,{}),l.jsx(Ace,{}),l.jsx(Cce,{}),l.jsx(Ice,{}),l.jsx(Oce,{}),l.jsx(Dce,{}),l.jsx(Bce,{}),l.jsx(Wce,{}),l.jsx(yce,{}),l.jsx(aue,{}),l.jsx(oue,{}),l.jsx(cue,{})]})}function Tue(){const{nodes:e,edges:t,setNodes:n,setEdges:a,addQuestion:r,undo:s,redo:o,addCrossLink:u,setSelectedNodeId:d,setSelectedNodeIds:h,history:m,historyIndex:p,relayout:x}=se(),b=St(),y=oe(H=>H.setTutorialOpen),w=oe(H=>H.annotationsHidden),E=oe(H=>H.setAnnotationsHidden),v=oe(H=>H.wheelPans),A=oe(H=>H.setWheelPans),[T,C]=D.useState(""),[I,O]=D.useState(!1),[_,S]=D.useState(""),[z,V]=D.useState(!1),[P,L]=D.useState(!1),[Y,q]=D.useState([]),[B,j]=D.useState(!1),$=D.useRef(null),X=D.useRef(null),Q=e.length>0,F=se(H=>H.events.length>0),G=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.highlights?.length??0),0)),J=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.attachments?.length??0)+(["note","link"].includes(we.data.stepKind??"")?1:0),0)),K=D.useRef(null),ee=oe(H=>H.arrivalFocusNodeId);D.useEffect(()=>{if(!ee)return;const H=se.getState().nodes.find(ce=>ce.id===ee);H&&(oe.getState().setArrivalFocusNodeId(null),window.setTimeout(()=>{K.current?.setCenter(H.position.x+260,H.position.y+140,{zoom:.9,duration:400})},150))},[ee]);const ue=Bi(H=>H.paper),pe=Bi(H=>H.lighting),be=Bi(H=>H.resolved),ae=D.useMemo(()=>zoe(),[be]),xe=D.useMemo(()=>{const H=getComputedStyle(document.documentElement),ce=(H.getPropertyValue("--color-surface").trim()||"#FAF9F7").replace("#",""),[we,Ne,Xe]=[0,2,4].map(vt=>parseInt(ce.slice(vt,vt+2),16));return{mask:`rgba(${we},${Ne},${Xe},0.7)`,archived:H.getPropertyValue("--color-wash").trim()||"#EFEDE9",ordinary:be==="dark"?"#6E6759":"#B9B3AB"}},[be]),Ce=D.useRef(e.length),ze=D.useCallback((H,ce={})=>{const we=K.current;if(!we)return;const Ne=ce.zoom??we.getZoom();we.setCenter(H.position.x+(ce.offX??260)+np(H.id)/(2*Ne),H.position.y+110,{zoom:Ne,duration:ce.duration??350})},[]),Ie=Da(H=>H.lang),Fe=oe(H=>H.condenseRun),Ee=Fe.status==="building",Me=sn(H=>H.projects.find(ce=>ce.id===H.activeId)?.kind==="paradigm"),De=Yl(),bt=D.useCallback(()=>{const{nodes:H,edges:ce}=dce(Ie),we=se.getState();we.setNodes([...we.nodes,...H.filter(Ne=>!we.nodes.some(Xe=>Xe.id===Ne.id))]),we.setEdges([...we.edges,...ce.filter(Ne=>!we.edges.some(Xe=>Xe.id===Ne.id))]),we.pushHistory(),setTimeout(()=>{const Ne=K.current;Ne&&(Ne.fitView({duration:500,padding:.1}),setTimeout(()=>{if(Ne.getViewport().zoom<.34){const Xe=[...se.getState().nodes].sort((vt,wt)=>(vt.data.createdAt??"").localeCompare(wt.data.createdAt??""))[0];Xe&&Ne.setCenter(Xe.position.x+300,Xe.position.y+240,{zoom:.6,duration:550})}},680))},100),localStorage.getItem("thoughtdag.tutorialDone")||y(!0)},[Ie,y]),mt=D.useCallback(H=>{const ce=se.getState(),we=ce.nodes[ce.nodes.length-1],Ne=we?{x:we.position.x,y:we.position.y+340}:{x:120,y:80},Xe=Tn();ce.setNodes([...ce.nodes,{id:Xe,type:"thought",position:Ne,dragHandle:".drag-handle",data:{question:"",instruction:"",stepKind:H,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:ce.nodes.length===0,isBranch:!1}}]),ce.pushHistory()},[]),Ye=D.useCallback(()=>{Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:300,padding:.2}),50)},[]);D.useEffect(()=>{const H=()=>Ye();return window.addEventListener("td:project-switched",H),()=>window.removeEventListener("td:project-switched",H)},[Ye]);const at=D.useRef(null),rt=D.useCallback(H=>{const ce=se.getState(),we=Tn();ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,width:640,height:420,zIndex:-1,dragHandle:".drag-handle",data:{question:"",stepKind:"frame",frameCarry:!1,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}]),ce.pushHistory()},[]),Ue=D.useCallback(H=>{const ce=[];for(const we of Array.from(H)){const Ne=we.name.split(".").pop()?.toLowerCase()??"";we.type.startsWith("image/")||we.type==="application/pdf"||we.type.startsWith("text/")||["pdf","docx","txt","md","csv","json","yaml","yml","toml","js","ts","tsx","jsx","py","sh","c","cpp","h","java","rs","go","rb","swift","css","html","xml","sql","tex","bib"].includes(Ne)?ce.push(we):We("info",ve(Te("toast.unsupportedFile"),{name:we.name}))}return ce},[]),Ct=D.useCallback(H=>{const ce=se.getState(),we=Tn();return ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,dragHandle:".drag-handle",data:{question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled}}]),ce.pushHistory(),we},[]),ot=D.useCallback(H=>{const ce=Ue(H);if(ce.length===0)return;let we=null;ce.forEach((Ne,Xe)=>{const vt=ps("file",{x:120+Xe%3*480,y:120+Math.floor(Xe/3)*620});Gd(vt,[Ne]),!we&&!Ne.type.startsWith("image/")&&(we=vt)}),we&&oe.getState().setReaderNodeId(we),setTimeout(()=>K.current?.fitView({duration:400,padding:.2}),120)},[Ue]),It=D.useCallback((H,ce)=>{const we=H.clientX,Ne=H.clientY,Xe=H.currentTarget;let vt=null;const wt=$t=>{!vt&&Math.hypot($t.clientX-we,$t.clientY-Ne)>6&&(vt=document.createElement("div"),vt.innerHTML=Xe.innerHTML,vt.style.cssText="position:fixed;z-index:300;pointer-events:none;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--color-card);border:1px solid var(--color-accent);border-radius:10px;box-shadow:0 4px 14px rgba(0,0,0,.18);opacity:.92;",document.body.appendChild(vt)),vt&&(vt.style.left=`${$t.clientX-18}px`,vt.style.top=`${$t.clientY-18}px`)},Ot=$t=>{window.removeEventListener("pointermove",wt),window.removeEventListener("pointerup",Ot);const fn=!!vt;vt?.remove(),ce(fn?{x:$t.clientX,y:$t.clientY}:null)};window.addEventListener("pointermove",wt),window.addEventListener("pointerup",Ot)},[]),_e=D.useCallback(H=>{const ce=K.current?.screenToFlowPosition(H??{x:window.innerWidth/2,y:window.innerHeight/2})??{x:140,y:140};return{x:ce.x-200,y:ce.y-60}},[]);D.useEffect(()=>{const H=we=>{at.current={x:we.clientX,y:we.clientY}},ce=we=>{if(Et)return;const Ne=we.target;if(Ne&&(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.isContentEditable))return;const Xe=sn.getState(),vt=Xe.projects.find(Kn=>Kn.id===Xe.activeId)?.kind==="paradigm";if(se.getState().nodes.length===0&&!vt)return;const wt=we.clipboardData;if(!wt)return;const Ot=_e(at.current),$t=wt.getData("text/plain").trim(),fn=Array.from(wt.files),Ga=fn.some(Kn=>!Kn.type.startsWith("image/"));if(fn.length>0&&(Ga||!$t)){we.preventDefault();const Kn=ps("file",Ot);Gd(Kn,fn);return}if($t)if(we.preventDefault(),/^https?:\/\/\S+$/.test($t)){const Kn=ps("link",Ot,{linkUrl:$t});U8(Kn,$t)}else ps("note",Ot,{question:fW($t)})};return window.addEventListener("mousemove",H),window.addEventListener("paste",ce),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("paste",ce)}},[_e]);const Ze=D.useCallback(async()=>{const H=se.getState();if(H.nodes.length===0)return;const{nodes:ce,edges:we}=lG(H.nodes,H.edges),Ne=sn.getState(),Xe=Ne.projects.find(wt=>wt.id===Ne.activeId)?.name??"Paradigm",vt=crypto.randomUUID();await Lr(ws(vt),JSON.stringify({state:{nodes:ce,edges:we},version:1})),await wu(vt,`▶ ${Xe}`,"chat"),await O7(vt,Xe),Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),150)},[]);D.useEffect(()=>{e.length===0&&!Me&&!localStorage.getItem("thoughtdag.seeded")&&localStorage.setItem("thoughtdag.seeded","yes")},[]),D.useEffect(()=>{if(e.length>Ce.current&&K.current){const H=e[e.length-1];H&&setTimeout(()=>ze(H,{zoom:1,duration:400,offX:220}),100)}Ce.current=e.length},[e,ze]);const ie=D.useCallback(H=>{const ce=se.getState().nodes;n(aA(H,ce))},[n]),Be=D.useCallback(H=>a(rA(H,se.getState().edges)),[a]),Je=D.useRef(null),Ht=D.useCallback((H,ce)=>{if(ce.data.stepKind!=="frame"||ce.data.frameCarry===!1)return;const we=se.getState(),Ne=we.nodes.find(vt=>vt.id===ce.id);if(!Ne)return;const Xe=T8(Ne,we.nodes).filter(vt=>!vt.selected).map(vt=>({id:vt.id,start:vt.position}));Xe.length!==0&&(Je.current={frameId:Ne.id,start:Ne.position,members:Xe})},[]),Kt=D.useCallback((H,ce)=>{const we=Je.current;if(!we||ce.id!==we.frameId)return;const Ne=ce.position.x-we.start.x,Xe=ce.position.y-we.start.y,vt=new Map(we.members.map(wt=>[wt.id,{x:wt.start.x+Ne,y:wt.start.y+Xe}]));se.setState(wt=>({nodes:wt.nodes.map(Ot=>{const $t=vt.get(Ot.id);return $t?{...Ot,position:$t}:Ot})}))},[]),qt=D.useCallback(()=>{Je.current=null},[]),[Rt,en]=D.useState(null),[Gt,ha]=D.useState(null),zn=D.useCallback((H,ce)=>{Et||window.getSelection()?.toString()||(H.preventDefault(),ha({x:H.clientX,y:H.clientY,nodeId:ce.id}))},[]),tr=D.useCallback((H,ce)=>{H.preventDefault(),en({x:H.clientX,y:H.clientY,edgeId:ce.id})},[]);D.useEffect(()=>{if(!Rt)return;const H=()=>en(null);return window.addEventListener("click",H),()=>window.removeEventListener("click",H)},[Rt]);const La=se(H=>H.deleteEdges),na=D.useCallback(H=>{La([H]),en(null)},[La]),Wa=D.useCallback(H=>{H.source&&H.target&&u(H.source,H.target)},[u]),ia=D.useCallback(()=>{window.getSelection()?.removeAllRanges(),document.body.classList.add("tdag-connecting")},[]),me=D.useCallback((H,ce)=>{if(document.body.classList.remove("tdag-connecting"),Me||ce.isValid||ce.fromHandle?.type!=="source"||!ce.fromNode)return;const we=ce.fromNode.id,Ne=H.target?.closest?.(".react-flow__node");if(Ne){const fn=Ne.getAttribute("data-id");if(fn&&fn!==we){const Ga=se.getState().nodes.find(Fr=>Fr.id===fn),Kn=Ga?.data.stepKind??"";Ga&&!["note","file","link","frame"].includes(Kn)&&se.getState().addCrossLink(we,fn)}return}const{clientX:Xe,clientY:vt}="changedTouches"in H?H.changedTouches[0]:H,wt=_e({x:Xe,y:vt}),Ot=se.getState();if(Ot.nodes.find(fn=>fn.id===we)?.data.stepKind==="frame")return;const $t=Ct(wt);Ot.setEdges([...se.getState().edges,{id:`edge-${we}-${$t}`,source:we,target:$t,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}]),se.getState().pushHistory()},[Me,_e,Ct]),Pe=se(H=>H.selectedNodeId),lt=se(H=>H.selectedNodeIds),zt=oe(H=>H.panelOpen),_n=oe(H=>H.viewerLoadError),mn=se(H=>Qr(H).length),Nt=oe(H=>H.panelWidth),pt=e.find(H=>H.id===Pe),Mt=pt?.data.stepKind,Mn=Dm(Mt)||Mt==="frame",pn=zt&&!!pt&&!Me&&!Mn;D.useEffect(()=>{Pe&&!pt&&se.getState().setSelectedNodeId(null)},[Pe,pt]);const ye=lt.length>1,tt=se(H=>H.batchDelete);D.useEffect(()=>{const H=ce=>{if(!oe.getState().confirmRequest&&!(Et&&!((ce.metaKey||ce.ctrlKey)&&ce.key==="f"))){if((ce.metaKey||ce.ctrlKey)&&ce.key==="z"&&(ce.shiftKey?(ce.preventDefault(),o()):(ce.preventDefault(),s())),(ce.metaKey||ce.ctrlKey)&&ce.key==="f"){ce.preventDefault(),O(!0);return}{const we=ce.target;if(!(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)&&Pe&&!Me&&!ce.metaKey&&!ce.ctrlKey&&!ce.altKey){const{nodes:Xe,edges:vt}=se.getState();if(ce.key===" "){ce.preventDefault(),se.getState().toggleCollapse(Pe);return}if(ce.key==="r"||ce.key==="R"){ce.preventDefault(),se.getState().rerunNode(Pe,{});return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(ce.key)){const wt=vt.filter($t=>!$t.data?.isCrossLink);let Ot;if(ce.key==="ArrowUp")Ot=wt.find($t=>$t.target===Pe)?.source;else if(ce.key==="ArrowDown")Ot=wt.find($t=>$t.source===Pe)?.target;else{const $t=wt.find(Kn=>Kn.target===Pe),fn=$t?wt.filter(Kn=>Kn.source===$t.source).map(Kn=>Kn.target):Xe.filter(Kn=>!wt.some(Fr=>Fr.target===Kn.id)).map(Kn=>Kn.id),Ga=fn.indexOf(Pe);Ga!==-1&&fn.length>1&&(Ot=fn[(Ga+(ce.key==="ArrowRight"?1:fn.length-1))%fn.length])}if(Ot){ce.preventDefault(),d(Ot);const $t=Xe.find(fn=>fn.id===Ot);$t&&ze($t,{zoom:1,duration:300})}return}}}if(ce.key==="Escape"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;lt.length>1?h([]):Pe&&d(null);return}if(ce.key==="Delete"||ce.key==="Backspace"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;if(lt.length>1)ce.preventDefault(),ai({title:Te("confirm.deleteNodesTitle"),message:ve(Te("confirm.deleteNodes"),{n:lt.length}),confirmLabel:Te("common.delete"),danger:!0}).then(Ne=>{Ne&&tt(lt)});else{const Ne=t.filter(Xe=>Xe.selected).map(Xe=>Xe.id);Ne.length>0&&(ce.preventDefault(),La(Ne))}}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[s,o,Pe,lt,d,h,tt,t,La,Me,ze]);const kt=()=>{T.trim()&&(r(T.trim(),{rolePrompt:_.trim()||void 0,initialAttachments:Y.length>0?Y:void 0}),C(""),S(""),V(!1),q([]))},jt=async H=>{for(const ce of Array.from(H))await W0(ce,{add:we=>q(Ne=>[...Ne,we]),update:(we,Ne)=>q(Xe=>Xe.map(vt=>vt.id===we?{...vt,...Ne}:vt))})},yt=H=>{H.key==="Enter"&&!H.shiftKey&&!lr(H)&&(H.preventDefault(),kt())},Ut=D.useCallback(({nodes:H})=>{const ce=H.map(we=>we.id);ce.length>1?h(ce):ce.length===1&&d(ce[0])},[d,h]),Qt=D.useMemo(()=>e.filter(H=>H.data.stepKind==="frame"),[e]),[Zt,Yn]=D.useState(!1),tn=D.useRef(null);D.useEffect(()=>{if(!Zt)return;const H=ce=>{tn.current?.contains(ce.target)||Yn(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[Zt]);const[wn,An]=D.useState(!1),xa=oe(H=>H.pluginUpdate),Ln=oe(H=>!!H.harnessHost?.desktop),[Jn,Pa]=D.useState(0),Bn=oe(H=>H.searchHitIds!==null),Hn=D.useRef(null);D.useEffect(()=>{if(!wn)return;const H=ce=>{Hn.current?.contains(ce.target)||An(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[wn]);const Va=oe(H=>H.searchHitIds),oa=D.useMemo(()=>{if(!Pe||lt.length>1||!e.some(wt=>wt.id===Pe))return null;const H=yp(Pe,e,t),ce=new Set;for(const wt of H.mainline)wt.id!==Pe&&ce.add(wt.id);for(const wt of H.materials)ce.add(wt.id);for(const wt of H.references)ce.add(wt.source.id);const we=t.filter(wt=>!wt.data?.isCrossLink),Ne=Pr(Pe,e,we).visitedEdgeIds,Xe=new Set(H.references.map(wt=>wt.edge.id)),vt=we.filter(wt=>wt.source===Pe);return{ctx:ce,down:new Set(vt.map(wt=>wt.target)),pathEdgeIds:Ne,refEdgeIds:Xe,downEdgeIds:new Set(vt.map(wt=>wt.id))}},[Pe,lt,e,t]),nr=D.useMemo(()=>{const H=e.filter(Ne=>Ne.data.stepKind==="frame").map((Ne,Xe)=>({id:Ne.id,order:Xe,area:(Ne.measured?.width??Ne.width??640)*(Ne.measured?.height??Ne.height??420)})).sort((Ne,Xe)=>Xe.area-Ne.area||Ne.order-Xe.order),ce=new Map(H.map((Ne,Xe)=>[Ne.id,Xe-H.length]));let we=e.map(Ne=>Ne.data.stepKind==="frame"?{...Ne,zIndex:ce.get(Ne.id)??-1}:Ne);return w&&(we=we.map(Ne=>{const Xe=Ne.data.stepKind,vt=Dm(Xe)&&!t.some(wt=>wt.source===Ne.id||wt.target===Ne.id);return Xe==="frame"||vt?{...Ne,hidden:!0}:Ne})),Va!==null&&(we=we.map(Ne=>Va.has(Ne.id)||Ne.data.stepKind==="frame"?{...Ne,className:"search-hit"}:Ne.className==="search-hit"?{...Ne,className:void 0}:Ne)),oa&&(we=we.map(Ne=>{const Xe=Ne.id===Pe?"target":oa.ctx.has(Ne.id)?"ctx":oa.down.has(Ne.id)?"down":Ne.data.stepKind==="frame"?void 0:"dim";return Xe?{...Ne,className:[Ne.className,`focus-${Xe}`].filter(Boolean).join(" "),...Xe!=="dim"?{data:{...Ne.data,focusRole:Xe}}:{}}:Ne})),we},[e,t,w,Va,oa,Pe]),st=D.useMemo(()=>{const H=t.map(Ne=>{const Xe=Ne.data?.isBranchFromSelection?{...Ne,animated:!1,style:{...Ne.style,strokeDasharray:void 0}}:Ne,vt=typeof Xe.style?.stroke=="string"?cT[Xe.style.stroke.toUpperCase()]:void 0,wt=Xe.markerEnd&&typeof Xe.markerEnd=="object"?Xe.markerEnd:void 0,Ot=typeof wt?.color=="string"?cT[wt.color.toUpperCase()]:void 0;return!vt&&!Ot?Xe:{...Xe,...vt?{style:{...Xe.style,stroke:ae[vt]}}:{},...Ot&&wt?{markerEnd:{...wt,color:ae[Ot]}}:{}}});if(oa)return H.map(Ne=>oa.pathEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-path",style:{...Ne.style,stroke:ae.accent,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.accent},zIndex:10,data:{...Ne.data,focusRole:"path"}}:oa.refEdgeIds.has(Ne.id)?{...Ne,style:{...Ne.style,opacity:.9},zIndex:5,data:{...Ne.data,focusRole:"ref"}}:oa.downEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-down",style:{...Ne.style,strokeWidth:2.5,opacity:.85},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{}},zIndex:5,data:{...Ne.data,focusRole:"down"}}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0});const ce=lt.length>1?lt:[];if(ce.length===0)return H;const{visitedEdgeIds:we}=Pr(ce,e,t);return H.map(Ne=>we.has(Ne.id)?{...Ne,style:{...Ne.style,stroke:ae.trace,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.trace},zIndex:10}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0})},[e,t,lt,ae,oa]);return D.useEffect(()=>{if(!pn||!Pe)return;const H=setTimeout(()=>{const ce=K.current;if(!ce)return;const we=se.getState().nodes.find(Ot=>Ot.id===Pe);if(!we)return;const Ne=ce.getViewport(),Xe=we.measured?.width??we.width??480,vt=(we.position.x+Xe)*Ne.zoom+Ne.x,wt=window.innerWidth-oe.getState().panelWidth-Vd-24;if(vt>wt){const Ot=(we.position.x+Xe/2)*Ne.zoom+Ne.x;ce.setViewport({...Ne,x:Ne.x-(Ot-wt/2)},{duration:300})}},60);return()=>clearTimeout(H)},[pn,Pe]),l.jsxs("div",{className:"relative w-full h-full","data-searching":Bn||void 0,children:[l.jsxs("div",{className:"relative h-full w-full",onDoubleClick:H=>{H.target.classList.contains("react-flow__pane")&&!Me&&Ct(_e({x:H.clientX,y:H.clientY}))},onDragOver:H=>{(H.dataTransfer.types.includes("application/thoughtdag-content")||H.dataTransfer.types.includes("Files"))&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",!Q&&!Me&&j(!0))},onDrop:H=>{if(Et)return;const ce=H.target;if(!Q&&!Me&&H.dataTransfer.files.length>0){H.preventDefault(),j(!1),ot(H.dataTransfer.files);return}const we=ce.closest?.(".react-flow__node"),Ne=we&&se.getState().nodes.find(wt=>wt.id===we.getAttribute("data-id"))?.data.stepKind==="frame";if(!ce.classList?.contains("react-flow__pane")&&!Ne)return;const Xe=_e({x:H.clientX,y:H.clientY}),vt=H.dataTransfer.getData("application/thoughtdag-content");if(vt==="ask"){H.preventDefault(),Ct(Xe);return}if(vt==="frame"){H.preventDefault(),rt(Xe);return}if(vt==="note"||vt==="file"){H.preventDefault(),ps(vt,Xe);return}if(H.dataTransfer.files.length>0){H.preventDefault();const wt=Ue(H.dataTransfer.files);if(wt.length===0)return;const Ot=ps("file",Xe);Gd(Ot,wt)}},children:[l.jsxs(DB,{onInit:H=>{K.current=H,SM.current=H;const ce=oe.getState().arrivalFocusNodeId;if(ce){oe.getState().setArrivalFocusNodeId(null);const we=se.getState().nodes.find(Ne=>Ne.id===ce);we&&window.setTimeout(()=>{H.setCenter(we.position.x+260,we.position.y+140,{zoom:.9,duration:400})},150)}},nodes:nr,edges:st,onNodesChange:ie,onEdgesChange:Be,onNodeDragStart:Ht,onNodeDrag:Kt,onNodeDragStop:qt,onConnect:Wa,onConnectStart:ia,onConnectEnd:me,onEdgeContextMenu:tr,onNodeContextMenu:zn,nodeTypes:kue,edgeTypes:Eue,deleteKeyCode:null,fitView:!0,onlyRenderVisibleElements:!0,minZoom:.04,maxZoom:2,defaultEdgeOptions:{type:"smoothstep",animated:!1,style:{stroke:ae.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:ae.accent,width:18,height:18}},snapToGrid:ue==="grid",snapGrid:[22,22],proOptions:{hideAttribution:!0},nodeDragThreshold:5,connectionRadius:40,selectionMode:su.Partial,selectionOnDrag:!Et,nodesDraggable:!Et,nodesConnectable:!Et,panOnDrag:Et?!0:[1,2],panOnScroll:v,zoomOnScroll:!v,zoomOnPinch:!0,zoomOnDoubleClick:!1,connectionLineStyle:{stroke:ae.accent,strokeDasharray:"8 4",strokeWidth:2},onSelectionChange:Ut,onPaneClick:()=>{d(null),h([]),ha(null)},children:[ue==="grid"?l.jsxs(l.Fragment,{children:[l.jsx(ux,{id:"grid-fine",variant:Rs.Lines,gap:22,color:"var(--canvas-grid-fine)"}),l.jsx(ux,{id:"grid-major",variant:Rs.Lines,gap:110,color:"var(--canvas-grid-major)"})]}):l.jsx(ux,{variant:Rs.Dots,gap:24,size:1,color:"var(--canvas-dot)"}),l.jsx(Aue,{}),l.jsx(Nue,{panelShiftWidth:pn?Nt:0}),l.jsx(xue,{}),l.jsx(WB,{position:"bottom-left"}),e.length>0&&l.jsx(rH,{nodeColor:H=>{const ce=H.data;if(ce.archived)return xe.archived;const we=ce.stepKind;return we==="note"?"#D97706":we==="file"||we==="link"?"#64748B":Array.isArray(ce.condensedFrom)&&ce.condensedFrom.length?"#8B7CF0":ce.isRoot?ae.accent:ce.isBranch?ae.warm:xe.ordinary},maskColor:xe.mask,style:{width:200,height:140},pannable:!0,zoomable:!0,position:"bottom-right"})]}),!Q&&Me&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"text-center pointer-events-auto",children:[l.jsx("p",{className:"text-sm text-ink-muted mb-1 font-medium",children:b("paradigm.emptyTitle")}),l.jsx("p",{className:"text-xs text-ink-faint mb-4 max-w-sm leading-relaxed",children:b("paradigm.emptyHint")}),l.jsxs("div",{className:"flex items-center justify-center gap-2",children:[l.jsxs("button",{onClick:()=>mt("human"),className:"text-sm border-2 border-dashed border-warm/60 text-warm hover:bg-warm/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx($d,{size:15,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"text-sm border-2 border-dashed border-accent/50 text-accent hover:bg-accent/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(Go,{size:15,strokeWidth:1.75})," ",b("paradigm.addPrompt")]})]})]})}),Et&&!Q&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("div",{className:"text-center max-w-[420px] px-6",children:_n?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-3xl mb-3",children:"🔗"}),l.jsx("div",{className:"text-sm font-semibold text-ink mb-1.5",children:b("viewer.loadError")}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:b("viewer.loadErrorHint")})]}):l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted justify-center",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",b("viewer.loading")]})})}),!Q&&!Me&&!Et&&l.jsxs("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none overflow-hidden",children:[l.jsxs("svg",{className:"absolute -left-10 top-[8%] w-[360px] h-[300px] opacity-[0.35] pointer-events-none",viewBox:"0 0 360 300","aria-hidden":!0,children:[l.jsx("path",{d:"M80 40 C80 90 80 90 80 130 M80 170 C80 210 80 210 80 250",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M95 150 C150 150 150 90 205 88",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"80",cy:"30",r:"7",fill:it.line}),l.jsx("circle",{cx:"80",cy:"150",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"80",cy:"262",r:"7",fill:it.line}),l.jsx("circle",{cx:"218",cy:"88",r:"7",fill:it.line})]}),l.jsxs("svg",{className:"absolute right-[-30px] bottom-[10%] w-[320px] h-[280px] opacity-[0.35] pointer-events-none",viewBox:"0 0 320 280","aria-hidden":!0,children:[l.jsx("path",{d:"M240 30 C240 80 240 80 240 120 M240 160 C240 200 240 200 240 240",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M225 140 C170 140 170 210 115 212",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"240",cy:"20",r:"7",fill:it.line}),l.jsx("circle",{cx:"240",cy:"140",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"240",cy:"252",r:"7",fill:it.line}),l.jsx("circle",{cx:"102",cy:"212",r:"7",fill:it.line})]}),l.jsxs("div",{className:"pointer-events-auto w-[560px] animate-fade-in relative",children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsxs("svg",{width:"52",height:"52",viewBox:"0 0 44 44",className:"mx-auto mb-4","aria-hidden":!0,children:[l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.05s"},cx:"22",cy:"7",r:"3.5",fill:it.accent}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.2s"},x1:"22",y1:"11",x2:"22",y2:"19",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.35s"},cx:"22",cy:"22",r:"3.5",fill:"none",stroke:it.accent,strokeWidth:"2.5"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.5s"},x1:"22",y1:"25",x2:"22",y2:"33",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.65s"},cx:"22",cy:"37",r:"3.5",fill:it.accent,opacity:"0.35"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.8s"},x1:"25.5",y1:"23.5",x2:"33",y2:"28.5",stroke:it.warm,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"3 3"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.95s"},cx:"36",cy:"30",r:"3.5",fill:it.warm})]}),l.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-ink mb-2.5",children:"ThoughtDAG"}),l.jsx("p",{className:"text-sm text-ink-muted",children:b("landing.tagline")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1.5 font-medium",children:b("landing.mechanism")})]}),l.jsxs("div",{className:"bg-card border border-line rounded-xl px-5 py-4 shadow-lg transition-all focus-within:border-accent/50 focus-within:shadow-xl",children:[l.jsx("textarea",{value:T,onChange:H=>C(H.target.value),onKeyDown:yt,onPaste:H=>{if(H.clipboardData.getData("text/plain").trim())return;const ce=Array.from(H.clipboardData.items).filter(we=>we.kind==="file").map(we=>we.getAsFile()).filter(Boolean);ce.length&&jt(ce)},placeholder:b("landing.placeholder"),className:"w-full bg-transparent text-ink text-sm leading-relaxed resize-none focus:outline-none placeholder-ink-faint",rows:3,autoFocus:!0}),Y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mt-2 pb-1",children:Y.map(H=>l.jsxs("div",{className:"flex items-center gap-1.5 bg-wash rounded-lg px-2.5 py-1.5 group",children:[H.thumbnailUrl?l.jsx("img",{src:H.thumbnailUrl,className:"w-6 h-6 rounded object-cover",alt:H.name}):l.jsx("span",{className:"text-xs",children:l.jsx(js,{size:16,strokeWidth:1.75})}),l.jsx("span",{className:"text-xs text-ink-muted max-w-[100px] truncate",children:H.name}),H.isExtracting&&l.jsx("span",{className:"text-2xs text-accent",children:l.jsx(nn,{className:"animate-spin",size:12,strokeWidth:1.75})}),H.numPages!=null&&l.jsxs("span",{className:"text-2xs text-ink-faint",children:[H.numPages,"p"]}),l.jsx("button",{onClick:()=>q(ce=>ce.filter(we=>we.id!==H.id)),className:"text-ink-faint hover:text-red-500 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]},H.id))}),z&&l.jsxs("div",{className:"space-y-1 mt-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-xs text-ink-muted font-medium",children:b("landing.roleLabel")}),l.jsx("button",{onClick:()=>{V(!1),S("")},className:"text-xs text-ink-faint hover:text-ink-muted",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),l.jsx("textarea",{value:_,onChange:H=>S(H.target.value),placeholder:b("landing.rolePlaceholder"),className:"w-full text-xs border border-line rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-accent bg-surface resize-none leading-relaxed",rows:2,autoFocus:!0}),l.jsx(xM,{onPick:S})]}),l.jsxs("div",{className:"flex items-center justify-end mt-2 gap-2",children:[l.jsx(K2,{}),l.jsx("button",{onClick:()=>V(!z),title:b("landing.roleTrayTitle"),className:`rounded-full w-8 h-8 flex items-center justify-center transition-colors shrink-0 ${z||_?"text-accent bg-accent/10 hover:bg-accent/20":"text-ink-faint hover:text-ink-muted hover:bg-line"}`,children:l.jsx(cF,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:()=>$.current?.click(),className:"text-ink-faint hover:text-accent hover:bg-wash rounded-xl px-3 py-2 transition-colors text-sm",title:b("landing.attach"),children:l.jsx(Ls,{size:16,strokeWidth:1.75})}),l.jsx("input",{ref:$,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{jt(H.target.files||[]),H.target.value=""}}),l.jsx("button",{onClick:kt,disabled:!T.trim()||Y.some(H=>H.isExtracting),className:"bg-accent hover:bg-accent-strong disabled:opacity-30 disabled:cursor-not-allowed text-white text-sm px-5 py-2 rounded-xl transition-all",children:Y.some(H=>H.isExtracting)?b("landing.extracting"):b("landing.send")})]})]}),l.jsxs("div",{onClick:()=>X.current?.click(),className:`mt-3 border-2 border-dashed rounded-xl px-5 py-3.5 cursor-pointer transition-all text-center bg-card/60 backdrop-blur ${B?"border-accent bg-accent/5 ring-2 ring-accent/20":"border-line hover:border-accent/40 hover:bg-accent/5"}`,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(Bl,{size:15,strokeWidth:1.75,className:"text-accent"})," ",b("landing.docStart")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.docFormats")}),l.jsx("p",{className:"text-2xs text-ink-faint mt-0.5",children:b("landing.docPrivacy")})]}),!!window.desktopSessions&&l.jsxs("button",{onClick:()=>L(!0),className:"w-full mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 hover:border-accent/40 hover:bg-accent/5 transition-all text-center","data-landing-atlas":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(RH,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{children:b("landing.atlasStart")}),l.jsx(CH,{size:13,strokeWidth:1.75,className:"text-accent shrink-0"})]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.atlasDesc")})]}),l.jsx("input",{ref:X,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{ot(H.target.files||[]),H.target.value=""}}),P&&l.jsx(Wv,{onClose:()=>L(!1),onSwitched:()=>{L(!1),Ye()}}),(!De||(De.models?.length??0)===0)&&l.jsxs("div",{className:"mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 text-center","data-quick-connect":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(p0,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"})," ",b("landing.quickTitle")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.quickDesc")}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-center flex-wrap gap-2",children:[Ie==="zh"&&l.jsx("button",{onClick:()=>{oe.getState().setApiKeyPresetHint("zhipu"),oe.getState().setApiKeyModalOpen(!0)},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-zhipu":!0,children:b("landing.quickZhipu")}),l.jsx("button",{onClick:()=>{IM()},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-primary":!0,children:b("landing.quickOpenRouter")}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"text-2xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0",children:b("landing.quickOther")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"mt-2 mx-auto text-2xs text-ink-faint hover:text-accent transition-colors block","data-quick-subs":!0,children:b("landing.quickSubs")})]}),l.jsx("div",{className:"grid grid-cols-3 gap-3 mt-6",children:[{icon:ni,title:"landing.feature1.title",desc:"landing.feature1.desc"},{icon:Xk,title:"landing.feature2.title",desc:"landing.feature2.desc"},{icon:WA,title:"landing.feature3.title",desc:"landing.feature3.desc"}].map(({icon:H,title:ce,desc:we})=>l.jsxs("div",{className:"bg-card/60 backdrop-blur border border-line rounded-xl px-4 py-3.5",children:[l.jsx(H,{size:16,strokeWidth:1.75,className:"text-accent mb-2"}),l.jsx("h3",{className:"text-xs font-semibold text-ink mb-1",children:b(ce)}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:b(we)})]},ce))}),l.jsxs("div",{className:"text-center mt-6 flex items-center justify-center gap-5",children:[l.jsxs("button",{onClick:bt,className:"text-xs text-accent hover:text-accent-strong font-medium transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Xk,{size:14,strokeWidth:1.75})," ",b("landing.loadExample")]}),l.jsxs("button",{onClick:()=>y(!0),className:"text-xs text-ink-muted hover:text-accent transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Wk,{size:14,strokeWidth:1.75})," ",b("landing.howItWorks")]})]})]})]}),!Et&&l.jsx(oce,{onSwitched:Ye}),(Q||Me)&&!Et&&l.jsxs("div",{className:"absolute top-[38%] -translate-y-1/2 left-4 z-10 flex flex-col gap-1.5 bg-card/90 backdrop-blur border border-line rounded-xl p-1.5 shadow-sm",children:[!Me&&l.jsx("button",{onClick:()=>Ct(_e(null)),draggable:!0,onDragStart:H=>{H.dataTransfer.setData("application/thoughtdag-content","ask"),H.dataTransfer.effectAllowed="copy"},title:b("palette.askTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-accent hover:bg-accent/10 transition-colors cursor-grab",children:l.jsx($d,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("note",_e(ce))),title:b("palette.noteTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-amber-600 hover:bg-amber-500/10 transition-colors",children:l.jsx(ii,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("file",_e(ce))),title:b("palette.fileTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ls,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>rt(_e(ce))),title:b("palette.frameTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Fb,{size:17,strokeWidth:1.75})})]}),Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Vd+12:16},"data-top-toolbar":!0,children:[l.jsxs("span",{className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm text-ink-muted text-xs font-medium","data-viewer-badge":!0,children:[l.jsx(f0,{size:14,strokeWidth:1.75})," ",b("viewer.badge")]}),l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(HT,{}),l.jsx("button",{onClick:()=>uy(),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("viewer.downloadJson"),children:l.jsx(Ml,{size:15,strokeWidth:1.75})}),l.jsx("a",{href:"https://github.com/chenxiachan/thoughtdag",target:"_blank",rel:"noreferrer",className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:b("viewer.openApp")})]}),!Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Vd+12:16},"data-top-toolbar":!0,children:[Me&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>mt("human"),className:"bg-card/90 backdrop-blur border border-warm/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-warm/10 transition-colors text-warm text-xs font-medium",children:[l.jsx($d,{size:14,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"bg-card/90 backdrop-blur border border-accent/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-accent/10 transition-colors text-accent text-xs font-medium",children:[l.jsx(Go,{size:14,strokeWidth:1.75})," ",b("paradigm.addPrompt")]}),l.jsxs("button",{onClick:()=>{Ze()},title:b("paradigm.instantiateTitle"),className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:["▶ ",b("paradigm.instantiate")]})]}),!Me&&l.jsx(uue,{}),!Me&&l.jsx(wM,{}),!Q&&l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("apikey.entryTitle"),"data-apikey-entry":!0,children:l.jsx(p0,{size:15,strokeWidth:1.75})}),mn>0&&!Me&&l.jsxs("button",{onClick:()=>{const{nodes:H,edges:ce}=se.getState(),Ne=Qr(se.getState()).reduce((Xe,vt)=>{const wt=H.map(fn=>fn.id===vt?{...fn,data:{...fn.data,question:"",response:""}}:fn),{layerTokens:Ot}=br(vt,wt,ce),$t=H.find(fn=>fn.id===vt)?.data.question??"";return Xe+Ot.material+Ot.reference+Ot.chain+Nn($t)},0);ai({title:b("replay.confirmTitle"),message:ve(b("replay.confirmMsg"),{n:mn,tok:Ne.toLocaleString()}),confirmLabel:b("replay.confirmBtn")}).then(Xe=>{Xe&&se.getState().replayStale()})},className:"bg-amber-500/10 backdrop-blur border border-amber-500/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-amber-500/20 transition-colors text-amber-600 text-xs font-medium",title:b("replay.chipTitle"),children:[l.jsx(KF,{size:14,strokeWidth:1.75})," ",mn]}),Q&&Qt.length>0&&l.jsxs("div",{ref:tn,className:"relative",children:[l.jsx("button",{onClick:()=>Yn(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${Zt?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.frames"),children:l.jsx(Fb,{size:15,strokeWidth:1.75})}),Zt&&l.jsx("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[230px] max-h-[320px] overflow-y-auto z-30 animate-fade-in",children:Qt.map(H=>l.jsxs("button",{onClick:()=>{Yn(!1),K.current?.fitBounds({x:H.position.x,y:H.position.y,width:H.width??640,height:H.height??420},{duration:400,padding:.15})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx("span",{className:`w-2.5 h-2.5 rounded-sm shrink-0 ${(Wd[H.data.frameColor??"gray"]??Wd.gray).dot}`}),l.jsx("span",{className:"truncate",children:H.data.question||b("frame.untitled")})]},H.id))})]}),Q&&l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(HT,{}),Q&&!Me&&l.jsx(Dle,{showTrigger:!1,openPing:Jn,onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Ee&&!Et&&l.jsxs("button",{onClick:()=>oe.getState().setCondenseDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-accent/50 rounded-lg h-8 px-2 flex items-center justify-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-accent",title:ve(b("condense.entryBuilding"),{i:String(Fe.current),n:String(Fe.total)}),"data-condense-entry":!0,children:[l.jsx(nn,{size:14,strokeWidth:1.75,className:"animate-spin"}),l.jsxs("span",{className:"text-2xs font-mono",children:[Fe.current,"/",Fe.total]})]}),$p&&l.jsx("button",{onClick:()=>oe.getState().setBackupDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("backup.dialogTitle"),"data-backup-entry":!0,children:l.jsx(PA,{size:15,strokeWidth:1.75})}),l.jsxs("div",{ref:Hn,className:"relative",children:[l.jsx("button",{onClick:()=>An(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${wn?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.more"),"data-toolbar-more":!0,children:l.jsx(jA,{size:15,strokeWidth:1.75})}),wn&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[220px] z-30 animate-fade-in",children:[Q&&l.jsxs("button",{onClick:()=>{An(!1),E(!w)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b(w?"toolbar.showAnnotations":"toolbar.hideAnnotations"),children:[l.jsx(ii,{size:14,strokeWidth:1.75,className:`shrink-0 ${w?"text-accent":"text-ink-faint"}`})," ",b(w?"toolbar.menuAnnotationsShow":"toolbar.menuAnnotationsHide")]}),l.jsxs("button",{onClick:()=>{An(!1),A(!v)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.wheelPansTitle"),"aria-pressed":v,"data-wheel-pans":!0,children:[l.jsx(IF,{size:14,strokeWidth:1.75,className:`shrink-0 ${v?"text-accent":"text-ink-faint"}`})," ",l.jsx("span",{className:"flex-1",children:b("toolbar.menuWheelPans")}),v&&l.jsx("span",{className:"text-accent",children:"✓"})]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),ai({title:b("confirm.relayoutTitle"),message:b("confirm.relayoutMsg"),confirmLabel:b("toolbar.relayout")}).then(H=>{H&&(x(),setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),50))})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(WF,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.relayout")]}),G>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setHighlightsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("hlov.entryTitle"),"data-hlov-entry":!0,children:[l.jsx(m0,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ve(b("hlov.entry"),{n:G})]}),J>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMaterialsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("matov.entryTitle"),"data-matov-entry":!0,children:[l.jsx(Ls,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ve(b("matov.entry"),{n:J})]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),Q&&!Me&&!Et&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setCondenseDialogOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("condense.entryTitle"),children:[l.jsx(xp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("condense.title"),"…"]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),Pa(H=>H+1)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.diagnose"),"data-menu-diagnose":!0,children:[l.jsx(VA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuDiagnose")]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),(async()=>{const{nodes:H,edges:ce}=se.getState(),{confirmIfSensitive:we}=await ft(async()=>{const{confirmIfSensitive:Xe}=await import("./sensitive-scan-BJN9JBOQ.js");return{confirmIfSensitive:Xe}},[]);if(!await we(H))return;const Ne=await Dq(H,ce);await navigator.clipboard.writeText(Ne).catch(()=>{}),oe.getState().setShareDialogUrl(Ne)})()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-share-link":!0,title:b("viewer.shareTitle"),children:[l.jsx(SU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuShare")]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),Me?cG():uy()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-menu-export":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b(Me?"paradigm.exportParadigm":"switcher.exportBackup")]}),F&&l.jsxs("button",{onClick:()=>{An(!1),mG()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.exportEventsTitle"),children:[l.jsx(js,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.exportEvents")]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("div",{className:"px-3 pt-2 pb-1","data-appearance-lighting":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.lighting")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["light",b("appearance.light")],["dark",b("appearance.dark")],["system",b("appearance.system")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Bi.getState().setLighting(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${pe===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsxs("div",{className:"px-3 pt-1 pb-2","data-appearance-paper":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.paper")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["plain",b("appearance.plain")],["grid",b("appearance.grid")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Bi.getState().setPaper(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${ue===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMemoryManagerOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("memory.entryTitle"),children:[l.jsx(LH,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("memory.managerTitle")]}),l.jsxs("button",{onClick:()=>{An(!1),y(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(Wk,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("landing.howItWorks")]}),xa&&l.jsxs("button",{onClick:()=>{An(!1);const H=Ln?`dsh-thoughtdag@${xa.latest}`:$y(xa.latest);navigator.clipboard.writeText(H).then(()=>We("success",b(Ln?"plugin.updateCopiedDesktop":"plugin.updateCopied")))},className:"w-full text-left px-3 py-2 text-xs text-accent hover:bg-wash transition-colors flex items-center gap-2.5",title:Ln?ve(b("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${xa.latest}`}):ve(b("plugin.updateHint"),{cmd:$y(xa.latest)}),"data-plugin-update":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",ve(b("plugin.updateAvailable"),{v:xa.latest})]}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setReleaseNotesOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-open-release-notes":!0,children:[l.jsx(gp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("releaseNotes.entry")]})]})]}),l.jsx("button",{onClick:s,disabled:p<=0,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.undo"),children:l.jsx(KA,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:o,disabled:p>=m.length-1,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.redo"),children:l.jsx(fU,{size:16,strokeWidth:1.75})})]}),ye&&!Et&&l.jsx(vle,{}),l.jsx(Ile,{open:I,onClose:()=>O(!1),onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Gt&&l.jsx(kle,{x:Gt.x,y:Gt.y,nodeId:Gt.nodeId,onClose:()=>ha(null)}),l.jsx(Tle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(vue,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Ele,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Rt&&l.jsx("div",{className:"fixed z-50 bg-card border border-line rounded-xl shadow-lg py-1 min-w-[120px]",style:{left:Rt.x,top:Rt.y},children:l.jsxs("button",{onClick:()=>na(Rt.edgeId),className:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors flex items-center gap-1.5",children:[l.jsx(Ja,{size:14,strokeWidth:1.75}),b("canvas.deleteEdge")]})})]}),l.jsx(tue,{onFocusSegment:H=>{const ce=K.current,we=se.getState().nodes.filter(fn=>H.includes(fn.id));if(!ce||we.length===0)return;const Ne=we.map(fn=>fn.position.x),Xe=we.map(fn=>fn.position.y),vt=Math.min(...Ne),wt=Math.min(...Xe),Ot=Math.max(...Ne)+520-vt,$t=Math.max(...Xe)+240-wt;ce.fitBounds({x:vt,y:wt,width:Ot+700,height:$t},{duration:350,padding:.15})}}),pn&&l.jsx(gle,{onFocusNode:H=>{const ce=e.find(we=>we.id===H);ce&&ze(ce,{duration:300})}}),l.jsx($le,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}})]})}function Nue({panelShiftWidth:e}){const t=G0(),n=St(),a=Vl(),r=se(d=>d.nodes.length),s=se(d=>d.nodes),o=D.useMemo(()=>{let d=null,h="";for(const m of s){if(m.data.stepKind&&m.data.stepKind!=="human"&&m.data.stepKind!=="prompt")continue;const p=[m.data.lastGeneratedAt,m.data.askedAt,m.data.createdAt,...m.data.editedAts??[]].filter(Boolean).sort().pop();p&&p>h&&(h=p,d=m)}return d?{node:d,at:h}:null},[s]);if(Et||t==="work"||r<2)return null;const u=()=>{if(!o)return;oe.getState().setBeaconNodeId(null);const{node:d}=o;a.setCenter(d.position.x+260,d.position.y+110,{zoom:1,duration:1100}),window.setTimeout(()=>{se.getState().setSelectedNodeId(d.id),oe.getState().setPanelOpen(!0),window.setTimeout(()=>{a.setCenter(d.position.x+260+np(d.id)/2,d.position.y+110,{zoom:1,duration:300})},60)},1150),window.setTimeout(()=>{We("success",n("continue.arrived"),12e3,{label:n("continue.summarize"),run:()=>{TM(d.id)}})},1550)};return l.jsxs("div",{className:"absolute bottom-6 z-10 flex items-center gap-2 -translate-x-1/2 transition-[left] duration-300",style:{left:`calc((100% - ${e}px) / 2)`},"data-map-dock":!0,children:[l.jsxs("button",{onClick:()=>oe.getState().setThoughtMapOpen(!0),"data-tmap-pill":!0,className:"flex items-center gap-2 bg-card/95 backdrop-blur border border-line-strong rounded-full px-5 py-2.5 text-sm text-ink shadow-lg hover:border-accent/40 hover:text-accent transition-colors",children:[l.jsx(c2,{size:16,strokeWidth:1.75})," ",n("tmap.export")]}),o&&l.jsxs("button",{onClick:u,onMouseEnter:()=>oe.getState().setBeaconNodeId(o.node.id),onMouseLeave:()=>oe.getState().setBeaconNodeId(null),title:n("continue.buttonTitle"),"data-continue-pill":!0,className:"flex items-center gap-2 bg-accent text-white rounded-full px-5 py-2.5 text-sm shadow-lg hover:bg-accent-strong transition-colors",children:[l.jsx(gU,{size:16,strokeWidth:1.75})," ",n("continue.button")]})]})}function Aue(){const e=G0(),t=ln(n=>n.transform[2]);return D.useEffect(()=>{document.querySelector(".react-flow")?.setAttribute("data-zoom-tier",e)},[e]),D.useEffect(()=>{document.querySelector(".react-flow")?.style.setProperty("--tdag-zoom",String(t))},[t]),null}Poe();const Yv="/thoughtdag/api";window.desktopSessions||N8(Yv);ft(()=>Promise.resolve().then(()=>hue),void 0).then(e=>e.bootPluginUpdateCheck(Yv));if(!window.desktopAgents){const e=Yv;ft(()=>import("./http-bridge-P6t5GDSV.js"),[]).then(async t=>{await t.installAgentsHttpBridge(e)&&window.dispatchEvent(new CustomEvent("td:agents-ready"))})}Et?jq():(D7(),navigator.storage?.persist&&navigator.storage.persist(),ft(()=>Promise.resolve().then(()=>$ce),void 0).then(e=>e.bootAutoBackup()));ft(()=>import("./update-check-oK0-hbLG.js"),[]).then(e=>e.bootUpdateCheck());window.addEventListener("hashchange",()=>{window.location.hash.startsWith("#view=")!==Et&&window.location.reload()});eD.createRoot(document.getElementById("root")).render(l.jsx(D.StrictMode,{children:l.jsx(Sue,{})}));export{O0 as A,xr as B,GV as C,Mue as D,U7 as E,Sa as F,I$ as I,ft as _,Te as a,se as b,sn as c,qi as d,R7 as e,ve as f,Ui as g,Lr as h,Et as i,wu as j,Tp as k,ly as l,ZV as m,Tn as n,XV as o,ws as p,z7 as q,QV as r,Xo as s,We as t,oe as u,ai as v,Iue as w,Qr as x,_ue as y,Cue as z};
|
|
914
|
+
Write the JOURNEY of this thinking as one flowing paragraph a reader absorbs in twenty seconds: where it started, what got ruled out, where it turned, where it landed, what remains open. Only the turns that mattered — do not enumerate every step. Hard limit: 250 characters for CJK languages, 500 characters otherwise. Write in ${n==="zh"?"Chinese":"English"} (the reader's interface language), even if the takeaway lines mix languages. Never use dash characters (—, –, -); use commas, colons or full stops. Output only the paragraph.`}])).trim(),fp:a,at:new Date().toISOString(),lang:n};return Wy.set(`${n}:${a}`,x),x}function vue({onLocate:e}){const t=oe(B=>B.timelineOverviewOpen),n=oe(B=>B.setTimelineOverviewOpen),a=se(B=>B.nodes),r=St(),s=ZA(),o=Da(B=>B.lang),u=pV(),d=D.useMemo(()=>Gv(a,0,{ladders:!0}),[a,u]),[h,m]=D.useState(1),p=Math.round(h),x={paddingTop:4+h*5,paddingBottom:4+h*5},b=D.useRef(null),y=D.useRef(null),w=D.useRef(null),E=B=>{const j=b.current;if(j){const $=j.getBoundingClientRect().top,X=[...j.querySelectorAll("[data-entry]")];let Q=y.current?X.find(F=>F.dataset.entry===y.current)??null:null;if(!Q){const F=$+j.clientHeight/2;Q=X.reduce((G,J)=>{const K=J.getBoundingClientRect(),ee=Math.abs((K.top+K.bottom)/2-F);return!G||ee<Math.abs((G.getBoundingClientRect().top+G.getBoundingClientRect().bottom)/2-F)?J:G},null)}w.current=Q?{id:Q.dataset.entry,y:Q.getBoundingClientRect().top-$}:null}m(B)};D.useLayoutEffect(()=>{const B=b.current,j=w.current;if(!B||!j)return;const $=B.querySelector(`[data-entry="${j.id}"]`);if(!$)return;const X=$.getBoundingClientRect().top-B.getBoundingClientRect().top;B.scrollTop+=X-j.y},[h]);const v=13+h*.9,A=D.useMemo(()=>FM(a),[a]),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(!1),z=bue(A,o)??T,V=!!z&&(z.fp!==A||z.lang!==o),P=()=>{O(!0),S(!1);const{nodes:B,edges:j}=se.getState();yue(B,j,o).then(C).catch(()=>S(!0)).finally(()=>O(!1))};if(!t)return null;const L=()=>n(!1),Y=B=>B?B.slice(0,10):"",q=B=>B?new Date(B).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit"}):"—";return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:L,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(gp,{size:15,strokeWidth:1.75,className:"text-accent"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("tlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ve(r("tlov.count"),{n:d.length})}),l.jsxs("label",{className:"flex items-center gap-2 ml-3 text-2xs text-ink-faint",title:r("tlov.detailTitle"),children:[l.jsx("span",{children:r("tlov.detail")}),l.jsx("input",{type:"range",min:0,max:3,step:.01,value:h,onChange:B=>E(Number(B.target.value)),className:"w-28 accent-accent","data-tlov-detail":!0}),l.jsx("span",{className:"text-ink-muted w-8",children:r(`ladder.level${p}`)})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{L(),oe.getState().setThoughtMapOpen(!0)},disabled:d.length===0,"data-tmap-from-timeline":!0,className:"flex items-center gap-1.5 text-2xs text-ink-muted hover:text-accent hover:bg-accent/10 rounded-full px-2.5 py-1 transition-colors disabled:opacity-50",children:[l.jsx(c2,{size:13,strokeWidth:1.75}),r("tmap.export")]}),l.jsx("button",{onClick:L,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-5 pt-3 shrink-0","data-gedankengang":!0,children:[!z&&!I&&l.jsxs("button",{onClick:P,className:"flex items-center gap-1.5 text-2xs text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-3 py-1.5 transition-colors",children:[l.jsx(Hl,{size:12,strokeWidth:1.75}),r("tlov.gedankenGenerate")]}),I&&l.jsx("p",{className:"text-2xs text-ink-faint italic py-1.5",children:r("tlov.gedankenLoading")}),_&&!I&&l.jsx("p",{className:"text-2xs text-red-500 py-1",children:r("tlov.gedankenFailed")}),z&&!I&&l.jsxs("div",{className:`rounded-xl bg-wash px-4 py-3 ${V?"opacity-60":""}`,children:[l.jsx("p",{className:"text-sm text-ink leading-relaxed",children:z.text}),l.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:V?r("tlov.gedankenStale"):new Date(z.at).toLocaleString(s)}),V&&l.jsx("button",{onClick:P,className:"text-2xs text-accent hover:underline",children:r("tlov.gedankenRedo")})]})]})]}),l.jsxs("div",{ref:b,className:"flex-1 min-h-0 overflow-y-auto px-5 py-3","data-timeline-overview":!0,children:[d.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("tlov.empty")}),d.map((B,j)=>{const $=j>0?Y(d[j-1].createdAt):void 0,X=Y(B.createdAt),Q=j===0||X!==$;return l.jsxs("div",{children:[Q&&l.jsx("div",{className:"sticky top-0 bg-card text-2xs text-ink-faint font-medium pt-3 pb-1 first:pt-0",children:X||r("tlov.undated")}),l.jsxs("div",{className:"group flex items-start gap-2.5 border-b border-line/50 last:border-0",style:x,"data-entry":B.id,onMouseEnter:()=>{y.current=B.id},onMouseLeave:()=>{y.current===B.id&&(y.current=null)},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:B.color,opacity:B.archived?.35:1}}),l.jsx("span",{className:"text-2xs font-mono text-ink-faint shrink-0 w-11",children:q(B.createdAt)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[B.ladder?l.jsx("div",{className:B.archived?"opacity-50 line-through":"",children:l.jsx(cM,{ladder:B.ladder,level:p,fontSize:v,weight:B.badged?"font-semibold":"font-medium",className:"whitespace-pre-wrap break-words"})}):l.jsx("p",{className:`leading-snug whitespace-pre-wrap break-words ${B.archived?"text-ink-faint line-through":B.badged?"text-ink":"text-ink-muted"}`,style:{fontSize:v,transition:"font-size 160ms ease-out"},children:p===0?B.topic||B.label||"…":l.jsxs(l.Fragment,{children:[B.topic&&l.jsxs("span",{className:"font-medium text-accent",children:[B.topic," · "]}),B.label||"…"]})}),B.modifiedAt&&B.modifiedAt!==B.createdAt&&l.jsxs("p",{className:"text-2xs text-ink-faint",children:[r("timeline.modified")," ",new Date(B.modifiedAt).toLocaleString(s)]})]}),l.jsx("button",{className:"shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors opacity-0 group-hover:opacity-100",onClick:()=>{L(),e(B.id)},title:r("hlov.locateTitle"),children:r("tlov.locate")})]})]},B.id)})]})]})}),document.body)}const wue=D.memo(function(t){const n=sn(a=>a.projects.find(r=>r.id===a.activeId)?.kind==="paradigm");return t.data?.stepKind==="frame"?l.jsx(Hoe,{...t}):Dm(t.data?.stepKind)?l.jsx(Boe,{...t}):n?l.jsx(joe,{...t}):l.jsx(Ooe,{...t})}),kue={thought:wue},Eue={smoothstep:D.memo(qoe)};function Sue(){const[e,t]=D.useState(Et||se.persist.hasHydrated());return D.useEffect(()=>se.persist.onFinishHydration(()=>t(!0)),[]),D.useEffect(()=>{if(!e||Et)return;let n;const a=()=>{clearTimeout(n),n=setTimeout(()=>{hce()},800)},r=se.subscribe((s,o)=>{s.nodes!==o.nodes&&a()});return a(),()=>{r(),clearTimeout(n)}},[e]),D.useEffect(()=>{oe.getState().condenseRun.status==="building"&&oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})},[]),D.useEffect(()=>{if(Et)return;const n=setTimeout(()=>{fce()},6e3);return()=>clearTimeout(n)},[]),D.useEffect(()=>{if(!e||Et||localStorage.getItem("thoughtdag.tutorialDone")||se.getState().nodes.length>0)return;const n=setTimeout(()=>oe.getState().setTutorialOpen(!0),900);return()=>clearTimeout(n)},[e]),D.useEffect(()=>{bce()},[]),D.useEffect(()=>{Et||(ft(()=>import("./session-handoff-DbK-2F0z.js"),[]).then(n=>n.consumeSessionHandoff()),ft(()=>Promise.resolve().then(()=>W8),void 0).then(n=>n.startLiveMirror()),ft(()=>import("./canvas-record-BlrHolpM.js"),[]).then(n=>n.startCanvasRecord()),ft(()=>import("./canonical-C3OufoVo.js"),[]).then(n=>n.unsubscribeOrphanedSessions()))},[]),D.useEffect(()=>{Et||xce().then(n=>{n&&(n.status==="minted"?(We("success",Te("provider.oauthMinted")),OM(n.key)):We("error",ve(Te("provider.oauthFailed"),{error:n.error})))})},[]),l.jsxs(l.Fragment,{children:[e&&l.jsx(Tue,{}),l.jsx(kce,{}),l.jsx(lue,{}),l.jsx(Sce,{}),l.jsx(Ace,{}),l.jsx(Cce,{}),l.jsx(Ice,{}),l.jsx(Oce,{}),l.jsx(Dce,{}),l.jsx(Bce,{}),l.jsx(Wce,{}),l.jsx(yce,{}),l.jsx(aue,{}),l.jsx(oue,{}),l.jsx(cue,{})]})}function Tue(){const{nodes:e,edges:t,setNodes:n,setEdges:a,addQuestion:r,undo:s,redo:o,addCrossLink:u,setSelectedNodeId:d,setSelectedNodeIds:h,history:m,historyIndex:p,relayout:x}=se(),b=St(),y=oe(H=>H.setTutorialOpen),w=oe(H=>H.annotationsHidden),E=oe(H=>H.setAnnotationsHidden),v=oe(H=>H.wheelPans),A=oe(H=>H.setWheelPans),[T,C]=D.useState(""),[I,O]=D.useState(!1),[_,S]=D.useState(""),[z,V]=D.useState(!1),[P,L]=D.useState(!1),[Y,q]=D.useState([]),[B,j]=D.useState(!1),$=D.useRef(null),X=D.useRef(null),Q=e.length>0,F=se(H=>H.events.length>0),G=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.highlights?.length??0),0)),J=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.attachments?.length??0)+(["note","link"].includes(we.data.stepKind??"")?1:0),0)),K=D.useRef(null),ee=oe(H=>H.arrivalFocusNodeId);D.useEffect(()=>{if(!ee)return;const H=se.getState().nodes.find(ce=>ce.id===ee);H&&(oe.getState().setArrivalFocusNodeId(null),window.setTimeout(()=>{K.current?.setCenter(H.position.x+260,H.position.y+140,{zoom:.9,duration:400})},150))},[ee]);const ue=Bi(H=>H.paper),pe=Bi(H=>H.lighting),be=Bi(H=>H.resolved),ae=D.useMemo(()=>zoe(),[be]),xe=D.useMemo(()=>{const H=getComputedStyle(document.documentElement),ce=(H.getPropertyValue("--color-surface").trim()||"#FAF9F7").replace("#",""),[we,Ne,Xe]=[0,2,4].map(vt=>parseInt(ce.slice(vt,vt+2),16));return{mask:`rgba(${we},${Ne},${Xe},0.7)`,archived:H.getPropertyValue("--color-wash").trim()||"#EFEDE9",ordinary:be==="dark"?"#6E6759":"#B9B3AB"}},[be]),Ce=D.useRef(e.length),ze=D.useCallback((H,ce={})=>{const we=K.current;if(!we)return;const Ne=ce.zoom??we.getZoom();we.setCenter(H.position.x+(ce.offX??260)+np(H.id)/(2*Ne),H.position.y+110,{zoom:Ne,duration:ce.duration??350})},[]),Ie=Da(H=>H.lang),Fe=oe(H=>H.condenseRun),Ee=Fe.status==="building",Me=sn(H=>H.projects.find(ce=>ce.id===H.activeId)?.kind==="paradigm"),De=Yl(),bt=D.useCallback(()=>{const{nodes:H,edges:ce}=dce(Ie),we=se.getState();we.setNodes([...we.nodes,...H.filter(Ne=>!we.nodes.some(Xe=>Xe.id===Ne.id))]),we.setEdges([...we.edges,...ce.filter(Ne=>!we.edges.some(Xe=>Xe.id===Ne.id))]),we.pushHistory(),setTimeout(()=>{const Ne=K.current;Ne&&(Ne.fitView({duration:500,padding:.1}),setTimeout(()=>{if(Ne.getViewport().zoom<.34){const Xe=[...se.getState().nodes].sort((vt,wt)=>(vt.data.createdAt??"").localeCompare(wt.data.createdAt??""))[0];Xe&&Ne.setCenter(Xe.position.x+300,Xe.position.y+240,{zoom:.6,duration:550})}},680))},100),localStorage.getItem("thoughtdag.tutorialDone")||y(!0)},[Ie,y]),mt=D.useCallback(H=>{const ce=se.getState(),we=ce.nodes[ce.nodes.length-1],Ne=we?{x:we.position.x,y:we.position.y+340}:{x:120,y:80},Xe=Tn();ce.setNodes([...ce.nodes,{id:Xe,type:"thought",position:Ne,dragHandle:".drag-handle",data:{question:"",instruction:"",stepKind:H,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:ce.nodes.length===0,isBranch:!1}}]),ce.pushHistory()},[]),Ye=D.useCallback(()=>{Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:300,padding:.2}),50)},[]);D.useEffect(()=>{const H=()=>Ye();return window.addEventListener("td:project-switched",H),()=>window.removeEventListener("td:project-switched",H)},[Ye]);const at=D.useRef(null),rt=D.useCallback(H=>{const ce=se.getState(),we=Tn();ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,width:640,height:420,zIndex:-1,dragHandle:".drag-handle",data:{question:"",stepKind:"frame",frameCarry:!1,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}]),ce.pushHistory()},[]),Ue=D.useCallback(H=>{const ce=[];for(const we of Array.from(H)){const Ne=we.name.split(".").pop()?.toLowerCase()??"";we.type.startsWith("image/")||we.type==="application/pdf"||we.type.startsWith("text/")||["pdf","docx","txt","md","csv","json","yaml","yml","toml","js","ts","tsx","jsx","py","sh","c","cpp","h","java","rs","go","rb","swift","css","html","xml","sql","tex","bib"].includes(Ne)?ce.push(we):We("info",ve(Te("toast.unsupportedFile"),{name:we.name}))}return ce},[]),Ct=D.useCallback(H=>{const ce=se.getState(),we=Tn();return ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,dragHandle:".drag-handle",data:{question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled}}]),ce.pushHistory(),we},[]),ot=D.useCallback(H=>{const ce=Ue(H);if(ce.length===0)return;let we=null;ce.forEach((Ne,Xe)=>{const vt=ps("file",{x:120+Xe%3*480,y:120+Math.floor(Xe/3)*620});Gd(vt,[Ne]),!we&&!Ne.type.startsWith("image/")&&(we=vt)}),we&&oe.getState().setReaderNodeId(we),setTimeout(()=>K.current?.fitView({duration:400,padding:.2}),120)},[Ue]),It=D.useCallback((H,ce)=>{const we=H.clientX,Ne=H.clientY,Xe=H.currentTarget;let vt=null;const wt=$t=>{!vt&&Math.hypot($t.clientX-we,$t.clientY-Ne)>6&&(vt=document.createElement("div"),vt.innerHTML=Xe.innerHTML,vt.style.cssText="position:fixed;z-index:300;pointer-events:none;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--color-card);border:1px solid var(--color-accent);border-radius:10px;box-shadow:0 4px 14px rgba(0,0,0,.18);opacity:.92;",document.body.appendChild(vt)),vt&&(vt.style.left=`${$t.clientX-18}px`,vt.style.top=`${$t.clientY-18}px`)},Ot=$t=>{window.removeEventListener("pointermove",wt),window.removeEventListener("pointerup",Ot);const fn=!!vt;vt?.remove(),ce(fn?{x:$t.clientX,y:$t.clientY}:null)};window.addEventListener("pointermove",wt),window.addEventListener("pointerup",Ot)},[]),_e=D.useCallback(H=>{const ce=K.current?.screenToFlowPosition(H??{x:window.innerWidth/2,y:window.innerHeight/2})??{x:140,y:140};return{x:ce.x-200,y:ce.y-60}},[]);D.useEffect(()=>{const H=we=>{at.current={x:we.clientX,y:we.clientY}},ce=we=>{if(Et)return;const Ne=we.target;if(Ne&&(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.isContentEditable))return;const Xe=sn.getState(),vt=Xe.projects.find(Kn=>Kn.id===Xe.activeId)?.kind==="paradigm";if(se.getState().nodes.length===0&&!vt)return;const wt=we.clipboardData;if(!wt)return;const Ot=_e(at.current),$t=wt.getData("text/plain").trim(),fn=Array.from(wt.files),Ga=fn.some(Kn=>!Kn.type.startsWith("image/"));if(fn.length>0&&(Ga||!$t)){we.preventDefault();const Kn=ps("file",Ot);Gd(Kn,fn);return}if($t)if(we.preventDefault(),/^https?:\/\/\S+$/.test($t)){const Kn=ps("link",Ot,{linkUrl:$t});U8(Kn,$t)}else ps("note",Ot,{question:fW($t)})};return window.addEventListener("mousemove",H),window.addEventListener("paste",ce),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("paste",ce)}},[_e]);const Ze=D.useCallback(async()=>{const H=se.getState();if(H.nodes.length===0)return;const{nodes:ce,edges:we}=lG(H.nodes,H.edges),Ne=sn.getState(),Xe=Ne.projects.find(wt=>wt.id===Ne.activeId)?.name??"Paradigm",vt=crypto.randomUUID();await Lr(ws(vt),JSON.stringify({state:{nodes:ce,edges:we},version:1})),await wu(vt,`▶ ${Xe}`,"chat"),await O7(vt,Xe),Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),150)},[]);D.useEffect(()=>{e.length===0&&!Me&&!localStorage.getItem("thoughtdag.seeded")&&localStorage.setItem("thoughtdag.seeded","yes")},[]),D.useEffect(()=>{if(e.length>Ce.current&&K.current){const H=e[e.length-1];H&&setTimeout(()=>ze(H,{zoom:1,duration:400,offX:220}),100)}Ce.current=e.length},[e,ze]);const ie=D.useCallback(H=>{const ce=se.getState().nodes;n(aA(H,ce))},[n]),Be=D.useCallback(H=>a(rA(H,se.getState().edges)),[a]),Je=D.useRef(null),Ht=D.useCallback((H,ce)=>{if(ce.data.stepKind!=="frame"||ce.data.frameCarry===!1)return;const we=se.getState(),Ne=we.nodes.find(vt=>vt.id===ce.id);if(!Ne)return;const Xe=T8(Ne,we.nodes).filter(vt=>!vt.selected).map(vt=>({id:vt.id,start:vt.position}));Xe.length!==0&&(Je.current={frameId:Ne.id,start:Ne.position,members:Xe})},[]),Kt=D.useCallback((H,ce)=>{const we=Je.current;if(!we||ce.id!==we.frameId)return;const Ne=ce.position.x-we.start.x,Xe=ce.position.y-we.start.y,vt=new Map(we.members.map(wt=>[wt.id,{x:wt.start.x+Ne,y:wt.start.y+Xe}]));se.setState(wt=>({nodes:wt.nodes.map(Ot=>{const $t=vt.get(Ot.id);return $t?{...Ot,position:$t}:Ot})}))},[]),qt=D.useCallback(()=>{Je.current=null},[]),[Rt,en]=D.useState(null),[Gt,ha]=D.useState(null),zn=D.useCallback((H,ce)=>{Et||window.getSelection()?.toString()||(H.preventDefault(),ha({x:H.clientX,y:H.clientY,nodeId:ce.id}))},[]),tr=D.useCallback((H,ce)=>{H.preventDefault(),en({x:H.clientX,y:H.clientY,edgeId:ce.id})},[]);D.useEffect(()=>{if(!Rt)return;const H=()=>en(null);return window.addEventListener("click",H),()=>window.removeEventListener("click",H)},[Rt]);const La=se(H=>H.deleteEdges),na=D.useCallback(H=>{La([H]),en(null)},[La]),Wa=D.useCallback(H=>{H.source&&H.target&&u(H.source,H.target)},[u]),ia=D.useCallback(()=>{window.getSelection()?.removeAllRanges(),document.body.classList.add("tdag-connecting")},[]),me=D.useCallback((H,ce)=>{if(document.body.classList.remove("tdag-connecting"),Me||ce.isValid||ce.fromHandle?.type!=="source"||!ce.fromNode)return;const we=ce.fromNode.id,Ne=H.target?.closest?.(".react-flow__node");if(Ne){const fn=Ne.getAttribute("data-id");if(fn&&fn!==we){const Ga=se.getState().nodes.find(Fr=>Fr.id===fn),Kn=Ga?.data.stepKind??"";Ga&&!["note","file","link","frame"].includes(Kn)&&se.getState().addCrossLink(we,fn)}return}const{clientX:Xe,clientY:vt}="changedTouches"in H?H.changedTouches[0]:H,wt=_e({x:Xe,y:vt}),Ot=se.getState();if(Ot.nodes.find(fn=>fn.id===we)?.data.stepKind==="frame")return;const $t=Ct(wt);Ot.setEdges([...se.getState().edges,{id:`edge-${we}-${$t}`,source:we,target:$t,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}]),se.getState().pushHistory()},[Me,_e,Ct]),Pe=se(H=>H.selectedNodeId),lt=se(H=>H.selectedNodeIds),zt=oe(H=>H.panelOpen),_n=oe(H=>H.viewerLoadError),mn=se(H=>Qr(H).length),Nt=oe(H=>H.panelWidth),pt=e.find(H=>H.id===Pe),Mt=pt?.data.stepKind,Mn=Dm(Mt)||Mt==="frame",pn=zt&&!!pt&&!Me&&!Mn;D.useEffect(()=>{Pe&&!pt&&se.getState().setSelectedNodeId(null)},[Pe,pt]);const ye=lt.length>1,tt=se(H=>H.batchDelete);D.useEffect(()=>{const H=ce=>{if(!oe.getState().confirmRequest&&!(Et&&!((ce.metaKey||ce.ctrlKey)&&ce.key==="f"))){if((ce.metaKey||ce.ctrlKey)&&ce.key==="z"&&(ce.shiftKey?(ce.preventDefault(),o()):(ce.preventDefault(),s())),(ce.metaKey||ce.ctrlKey)&&ce.key==="f"){ce.preventDefault(),O(!0);return}{const we=ce.target;if(!(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)&&Pe&&!Me&&!ce.metaKey&&!ce.ctrlKey&&!ce.altKey){const{nodes:Xe,edges:vt}=se.getState();if(ce.key===" "){ce.preventDefault(),se.getState().toggleCollapse(Pe);return}if(ce.key==="r"||ce.key==="R"){ce.preventDefault(),se.getState().rerunNode(Pe,{});return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(ce.key)){const wt=vt.filter($t=>!$t.data?.isCrossLink);let Ot;if(ce.key==="ArrowUp")Ot=wt.find($t=>$t.target===Pe)?.source;else if(ce.key==="ArrowDown")Ot=wt.find($t=>$t.source===Pe)?.target;else{const $t=wt.find(Kn=>Kn.target===Pe),fn=$t?wt.filter(Kn=>Kn.source===$t.source).map(Kn=>Kn.target):Xe.filter(Kn=>!wt.some(Fr=>Fr.target===Kn.id)).map(Kn=>Kn.id),Ga=fn.indexOf(Pe);Ga!==-1&&fn.length>1&&(Ot=fn[(Ga+(ce.key==="ArrowRight"?1:fn.length-1))%fn.length])}if(Ot){ce.preventDefault(),d(Ot);const $t=Xe.find(fn=>fn.id===Ot);$t&&ze($t,{zoom:1,duration:300})}return}}}if(ce.key==="Escape"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;lt.length>1?h([]):Pe&&d(null);return}if(ce.key==="Delete"||ce.key==="Backspace"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;if(lt.length>1)ce.preventDefault(),ai({title:Te("confirm.deleteNodesTitle"),message:ve(Te("confirm.deleteNodes"),{n:lt.length}),confirmLabel:Te("common.delete"),danger:!0}).then(Ne=>{Ne&&tt(lt)});else{const Ne=t.filter(Xe=>Xe.selected).map(Xe=>Xe.id);Ne.length>0&&(ce.preventDefault(),La(Ne))}}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[s,o,Pe,lt,d,h,tt,t,La,Me,ze]);const kt=()=>{T.trim()&&(r(T.trim(),{rolePrompt:_.trim()||void 0,initialAttachments:Y.length>0?Y:void 0}),C(""),S(""),V(!1),q([]))},jt=async H=>{for(const ce of Array.from(H))await W0(ce,{add:we=>q(Ne=>[...Ne,we]),update:(we,Ne)=>q(Xe=>Xe.map(vt=>vt.id===we?{...vt,...Ne}:vt))})},yt=H=>{H.key==="Enter"&&!H.shiftKey&&!lr(H)&&(H.preventDefault(),kt())},Ut=D.useCallback(({nodes:H})=>{const ce=H.map(we=>we.id);ce.length>1?h(ce):ce.length===1&&d(ce[0])},[d,h]),Qt=D.useMemo(()=>e.filter(H=>H.data.stepKind==="frame"),[e]),[Zt,Yn]=D.useState(!1),tn=D.useRef(null);D.useEffect(()=>{if(!Zt)return;const H=ce=>{tn.current?.contains(ce.target)||Yn(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[Zt]);const[wn,An]=D.useState(!1),xa=oe(H=>H.pluginUpdate),Ln=oe(H=>!!H.harnessHost?.desktop),[Jn,Pa]=D.useState(0),Bn=oe(H=>H.searchHitIds!==null),Hn=D.useRef(null);D.useEffect(()=>{if(!wn)return;const H=ce=>{Hn.current?.contains(ce.target)||An(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[wn]);const Va=oe(H=>H.searchHitIds),oa=D.useMemo(()=>{if(!Pe||lt.length>1||!e.some(wt=>wt.id===Pe))return null;const H=yp(Pe,e,t),ce=new Set;for(const wt of H.mainline)wt.id!==Pe&&ce.add(wt.id);for(const wt of H.materials)ce.add(wt.id);for(const wt of H.references)ce.add(wt.source.id);const we=t.filter(wt=>!wt.data?.isCrossLink),Ne=Pr(Pe,e,we).visitedEdgeIds,Xe=new Set(H.references.map(wt=>wt.edge.id)),vt=we.filter(wt=>wt.source===Pe);return{ctx:ce,down:new Set(vt.map(wt=>wt.target)),pathEdgeIds:Ne,refEdgeIds:Xe,downEdgeIds:new Set(vt.map(wt=>wt.id))}},[Pe,lt,e,t]),nr=D.useMemo(()=>{const H=e.filter(Ne=>Ne.data.stepKind==="frame").map((Ne,Xe)=>({id:Ne.id,order:Xe,area:(Ne.measured?.width??Ne.width??640)*(Ne.measured?.height??Ne.height??420)})).sort((Ne,Xe)=>Xe.area-Ne.area||Ne.order-Xe.order),ce=new Map(H.map((Ne,Xe)=>[Ne.id,Xe-H.length]));let we=e.map(Ne=>Ne.data.stepKind==="frame"?{...Ne,zIndex:ce.get(Ne.id)??-1}:Ne);return w&&(we=we.map(Ne=>{const Xe=Ne.data.stepKind,vt=Dm(Xe)&&!t.some(wt=>wt.source===Ne.id||wt.target===Ne.id);return Xe==="frame"||vt?{...Ne,hidden:!0}:Ne})),Va!==null&&(we=we.map(Ne=>Va.has(Ne.id)||Ne.data.stepKind==="frame"?{...Ne,className:"search-hit"}:Ne.className==="search-hit"?{...Ne,className:void 0}:Ne)),oa&&(we=we.map(Ne=>{const Xe=Ne.id===Pe?"target":oa.ctx.has(Ne.id)?"ctx":oa.down.has(Ne.id)?"down":Ne.data.stepKind==="frame"?void 0:"dim";return Xe?{...Ne,className:[Ne.className,`focus-${Xe}`].filter(Boolean).join(" "),...Xe!=="dim"?{data:{...Ne.data,focusRole:Xe}}:{}}:Ne})),we},[e,t,w,Va,oa,Pe]),st=D.useMemo(()=>{const H=t.map(Ne=>{const Xe=Ne.data?.isBranchFromSelection?{...Ne,animated:!1,style:{...Ne.style,strokeDasharray:void 0}}:Ne,vt=typeof Xe.style?.stroke=="string"?cT[Xe.style.stroke.toUpperCase()]:void 0,wt=Xe.markerEnd&&typeof Xe.markerEnd=="object"?Xe.markerEnd:void 0,Ot=typeof wt?.color=="string"?cT[wt.color.toUpperCase()]:void 0;return!vt&&!Ot?Xe:{...Xe,...vt?{style:{...Xe.style,stroke:ae[vt]}}:{},...Ot&&wt?{markerEnd:{...wt,color:ae[Ot]}}:{}}});if(oa)return H.map(Ne=>oa.pathEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-path",style:{...Ne.style,stroke:ae.accent,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.accent},zIndex:10,data:{...Ne.data,focusRole:"path"}}:oa.refEdgeIds.has(Ne.id)?{...Ne,style:{...Ne.style,opacity:.9},zIndex:5,data:{...Ne.data,focusRole:"ref"}}:oa.downEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-down",style:{...Ne.style,strokeWidth:2.5,opacity:.85},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{}},zIndex:5,data:{...Ne.data,focusRole:"down"}}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0});const ce=lt.length>1?lt:[];if(ce.length===0)return H;const{visitedEdgeIds:we}=Pr(ce,e,t);return H.map(Ne=>we.has(Ne.id)?{...Ne,style:{...Ne.style,stroke:ae.trace,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.trace},zIndex:10}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0})},[e,t,lt,ae,oa]);return D.useEffect(()=>{if(!pn||!Pe)return;const H=setTimeout(()=>{const ce=K.current;if(!ce)return;const we=se.getState().nodes.find(Ot=>Ot.id===Pe);if(!we)return;const Ne=ce.getViewport(),Xe=we.measured?.width??we.width??480,vt=(we.position.x+Xe)*Ne.zoom+Ne.x,wt=window.innerWidth-oe.getState().panelWidth-Vd-24;if(vt>wt){const Ot=(we.position.x+Xe/2)*Ne.zoom+Ne.x;ce.setViewport({...Ne,x:Ne.x-(Ot-wt/2)},{duration:300})}},60);return()=>clearTimeout(H)},[pn,Pe]),l.jsxs("div",{className:"relative w-full h-full","data-searching":Bn||void 0,children:[l.jsxs("div",{className:"relative h-full w-full",onDoubleClick:H=>{H.target.classList.contains("react-flow__pane")&&!Me&&Ct(_e({x:H.clientX,y:H.clientY}))},onDragOver:H=>{(H.dataTransfer.types.includes("application/thoughtdag-content")||H.dataTransfer.types.includes("Files"))&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",!Q&&!Me&&j(!0))},onDrop:H=>{if(Et)return;const ce=H.target;if(!Q&&!Me&&H.dataTransfer.files.length>0){H.preventDefault(),j(!1),ot(H.dataTransfer.files);return}const we=ce.closest?.(".react-flow__node"),Ne=we&&se.getState().nodes.find(wt=>wt.id===we.getAttribute("data-id"))?.data.stepKind==="frame";if(!ce.classList?.contains("react-flow__pane")&&!Ne)return;const Xe=_e({x:H.clientX,y:H.clientY}),vt=H.dataTransfer.getData("application/thoughtdag-content");if(vt==="ask"){H.preventDefault(),Ct(Xe);return}if(vt==="frame"){H.preventDefault(),rt(Xe);return}if(vt==="note"||vt==="file"){H.preventDefault(),ps(vt,Xe);return}if(H.dataTransfer.files.length>0){H.preventDefault();const wt=Ue(H.dataTransfer.files);if(wt.length===0)return;const Ot=ps("file",Xe);Gd(Ot,wt)}},children:[l.jsxs(DB,{onInit:H=>{K.current=H,SM.current=H;const ce=oe.getState().arrivalFocusNodeId;if(ce){oe.getState().setArrivalFocusNodeId(null);const we=se.getState().nodes.find(Ne=>Ne.id===ce);we&&window.setTimeout(()=>{H.setCenter(we.position.x+260,we.position.y+140,{zoom:.9,duration:400})},150)}},nodes:nr,edges:st,onNodesChange:ie,onEdgesChange:Be,onNodeDragStart:Ht,onNodeDrag:Kt,onNodeDragStop:qt,onConnect:Wa,onConnectStart:ia,onConnectEnd:me,onEdgeContextMenu:tr,onNodeContextMenu:zn,nodeTypes:kue,edgeTypes:Eue,deleteKeyCode:null,fitView:!0,onlyRenderVisibleElements:!0,minZoom:.04,maxZoom:2,defaultEdgeOptions:{type:"smoothstep",animated:!1,style:{stroke:ae.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:ae.accent,width:18,height:18}},snapToGrid:ue==="grid",snapGrid:[22,22],proOptions:{hideAttribution:!0},nodeDragThreshold:5,connectionRadius:40,selectionMode:su.Partial,selectionOnDrag:!Et,nodesDraggable:!Et,nodesConnectable:!Et,panOnDrag:Et?!0:[1,2],panOnScroll:v,zoomOnScroll:!v,zoomOnPinch:!0,zoomOnDoubleClick:!1,connectionLineStyle:{stroke:ae.accent,strokeDasharray:"8 4",strokeWidth:2},onSelectionChange:Ut,onPaneClick:()=>{d(null),h([]),ha(null)},children:[ue==="grid"?l.jsxs(l.Fragment,{children:[l.jsx(ux,{id:"grid-fine",variant:Rs.Lines,gap:22,color:"var(--canvas-grid-fine)"}),l.jsx(ux,{id:"grid-major",variant:Rs.Lines,gap:110,color:"var(--canvas-grid-major)"})]}):l.jsx(ux,{variant:Rs.Dots,gap:24,size:1,color:"var(--canvas-dot)"}),l.jsx(Aue,{}),l.jsx(Nue,{panelShiftWidth:pn?Nt:0}),l.jsx(xue,{}),l.jsx(WB,{position:"bottom-left"}),e.length>0&&l.jsx(rH,{nodeColor:H=>{const ce=H.data;if(ce.archived)return xe.archived;const we=ce.stepKind;return we==="note"?"#D97706":we==="file"||we==="link"?"#64748B":Array.isArray(ce.condensedFrom)&&ce.condensedFrom.length?"#8B7CF0":ce.isRoot?ae.accent:ce.isBranch?ae.warm:xe.ordinary},maskColor:xe.mask,style:{width:200,height:140},pannable:!0,zoomable:!0,position:"bottom-right"})]}),!Q&&Me&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"text-center pointer-events-auto",children:[l.jsx("p",{className:"text-sm text-ink-muted mb-1 font-medium",children:b("paradigm.emptyTitle")}),l.jsx("p",{className:"text-xs text-ink-faint mb-4 max-w-sm leading-relaxed",children:b("paradigm.emptyHint")}),l.jsxs("div",{className:"flex items-center justify-center gap-2",children:[l.jsxs("button",{onClick:()=>mt("human"),className:"text-sm border-2 border-dashed border-warm/60 text-warm hover:bg-warm/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx($d,{size:15,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"text-sm border-2 border-dashed border-accent/50 text-accent hover:bg-accent/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(Go,{size:15,strokeWidth:1.75})," ",b("paradigm.addPrompt")]})]})]})}),Et&&!Q&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("div",{className:"text-center max-w-[420px] px-6",children:_n?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-3xl mb-3",children:"🔗"}),l.jsx("div",{className:"text-sm font-semibold text-ink mb-1.5",children:b("viewer.loadError")}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:b("viewer.loadErrorHint")})]}):l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted justify-center",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",b("viewer.loading")]})})}),!Q&&!Me&&!Et&&l.jsxs("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none overflow-hidden",children:[l.jsxs("svg",{className:"absolute -left-10 top-[8%] w-[360px] h-[300px] opacity-[0.35] pointer-events-none",viewBox:"0 0 360 300","aria-hidden":!0,children:[l.jsx("path",{d:"M80 40 C80 90 80 90 80 130 M80 170 C80 210 80 210 80 250",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M95 150 C150 150 150 90 205 88",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"80",cy:"30",r:"7",fill:it.line}),l.jsx("circle",{cx:"80",cy:"150",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"80",cy:"262",r:"7",fill:it.line}),l.jsx("circle",{cx:"218",cy:"88",r:"7",fill:it.line})]}),l.jsxs("svg",{className:"absolute right-[-30px] bottom-[10%] w-[320px] h-[280px] opacity-[0.35] pointer-events-none",viewBox:"0 0 320 280","aria-hidden":!0,children:[l.jsx("path",{d:"M240 30 C240 80 240 80 240 120 M240 160 C240 200 240 200 240 240",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M225 140 C170 140 170 210 115 212",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"240",cy:"20",r:"7",fill:it.line}),l.jsx("circle",{cx:"240",cy:"140",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"240",cy:"252",r:"7",fill:it.line}),l.jsx("circle",{cx:"102",cy:"212",r:"7",fill:it.line})]}),l.jsxs("div",{className:"pointer-events-auto w-[560px] animate-fade-in relative",children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsxs("svg",{width:"52",height:"52",viewBox:"0 0 44 44",className:"mx-auto mb-4","aria-hidden":!0,children:[l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.05s"},cx:"22",cy:"7",r:"3.5",fill:it.accent}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.2s"},x1:"22",y1:"11",x2:"22",y2:"19",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.35s"},cx:"22",cy:"22",r:"3.5",fill:"none",stroke:it.accent,strokeWidth:"2.5"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.5s"},x1:"22",y1:"25",x2:"22",y2:"33",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.65s"},cx:"22",cy:"37",r:"3.5",fill:it.accent,opacity:"0.35"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.8s"},x1:"25.5",y1:"23.5",x2:"33",y2:"28.5",stroke:it.warm,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"3 3"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.95s"},cx:"36",cy:"30",r:"3.5",fill:it.warm})]}),l.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-ink mb-2.5",children:"ThoughtDAG"}),l.jsx("p",{className:"text-sm text-ink-muted",children:b("landing.tagline")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1.5 font-medium",children:b("landing.mechanism")})]}),l.jsxs("div",{className:"bg-card border border-line rounded-xl px-5 py-4 shadow-lg transition-all focus-within:border-accent/50 focus-within:shadow-xl",children:[l.jsx("textarea",{value:T,onChange:H=>C(H.target.value),onKeyDown:yt,onPaste:H=>{if(H.clipboardData.getData("text/plain").trim())return;const ce=Array.from(H.clipboardData.items).filter(we=>we.kind==="file").map(we=>we.getAsFile()).filter(Boolean);ce.length&&jt(ce)},placeholder:b("landing.placeholder"),className:"w-full bg-transparent text-ink text-sm leading-relaxed resize-none focus:outline-none placeholder-ink-faint",rows:3,autoFocus:!0}),Y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mt-2 pb-1",children:Y.map(H=>l.jsxs("div",{className:"flex items-center gap-1.5 bg-wash rounded-lg px-2.5 py-1.5 group",children:[H.thumbnailUrl?l.jsx("img",{src:H.thumbnailUrl,className:"w-6 h-6 rounded object-cover",alt:H.name}):l.jsx("span",{className:"text-xs",children:l.jsx(js,{size:16,strokeWidth:1.75})}),l.jsx("span",{className:"text-xs text-ink-muted max-w-[100px] truncate",children:H.name}),H.isExtracting&&l.jsx("span",{className:"text-2xs text-accent",children:l.jsx(nn,{className:"animate-spin",size:12,strokeWidth:1.75})}),H.numPages!=null&&l.jsxs("span",{className:"text-2xs text-ink-faint",children:[H.numPages,"p"]}),l.jsx("button",{onClick:()=>q(ce=>ce.filter(we=>we.id!==H.id)),className:"text-ink-faint hover:text-red-500 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]},H.id))}),z&&l.jsxs("div",{className:"space-y-1 mt-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-xs text-ink-muted font-medium",children:b("landing.roleLabel")}),l.jsx("button",{onClick:()=>{V(!1),S("")},className:"text-xs text-ink-faint hover:text-ink-muted",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),l.jsx("textarea",{value:_,onChange:H=>S(H.target.value),placeholder:b("landing.rolePlaceholder"),className:"w-full text-xs border border-line rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-accent bg-surface resize-none leading-relaxed",rows:2,autoFocus:!0}),l.jsx(xM,{onPick:S})]}),l.jsxs("div",{className:"flex items-center justify-end mt-2 gap-2",children:[l.jsx(K2,{}),l.jsx("button",{onClick:()=>V(!z),title:b("landing.roleTrayTitle"),className:`rounded-full w-8 h-8 flex items-center justify-center transition-colors shrink-0 ${z||_?"text-accent bg-accent/10 hover:bg-accent/20":"text-ink-faint hover:text-ink-muted hover:bg-line"}`,children:l.jsx(cF,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:()=>$.current?.click(),className:"text-ink-faint hover:text-accent hover:bg-wash rounded-xl px-3 py-2 transition-colors text-sm",title:b("landing.attach"),children:l.jsx(Ls,{size:16,strokeWidth:1.75})}),l.jsx("input",{ref:$,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{jt(H.target.files||[]),H.target.value=""}}),l.jsx("button",{onClick:kt,disabled:!T.trim()||Y.some(H=>H.isExtracting),className:"bg-accent hover:bg-accent-strong disabled:opacity-30 disabled:cursor-not-allowed text-white text-sm px-5 py-2 rounded-xl transition-all",children:Y.some(H=>H.isExtracting)?b("landing.extracting"):b("landing.send")})]})]}),l.jsxs("div",{onClick:()=>X.current?.click(),className:`mt-3 border-2 border-dashed rounded-xl px-5 py-3.5 cursor-pointer transition-all text-center bg-card/60 backdrop-blur ${B?"border-accent bg-accent/5 ring-2 ring-accent/20":"border-line hover:border-accent/40 hover:bg-accent/5"}`,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(Bl,{size:15,strokeWidth:1.75,className:"text-accent"})," ",b("landing.docStart")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.docFormats")}),l.jsx("p",{className:"text-2xs text-ink-faint mt-0.5",children:b("landing.docPrivacy")})]}),!!window.desktopSessions&&l.jsxs("button",{onClick:()=>L(!0),className:"w-full mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 hover:border-accent/40 hover:bg-accent/5 transition-all text-center","data-landing-atlas":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(RH,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{children:b("landing.atlasStart")}),l.jsx(CH,{size:13,strokeWidth:1.75,className:"text-accent shrink-0"})]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.atlasDesc")})]}),l.jsx("input",{ref:X,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{ot(H.target.files||[]),H.target.value=""}}),P&&l.jsx(Wv,{onClose:()=>L(!1),onSwitched:()=>{L(!1),Ye()}}),(!De||(De.models?.length??0)===0)&&l.jsxs("div",{className:"mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 text-center","data-quick-connect":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(p0,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"})," ",b("landing.quickTitle")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.quickDesc")}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-center flex-wrap gap-2",children:[Ie==="zh"&&l.jsx("button",{onClick:()=>{oe.getState().setApiKeyPresetHint("zhipu"),oe.getState().setApiKeyModalOpen(!0)},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-zhipu":!0,children:b("landing.quickZhipu")}),l.jsx("button",{onClick:()=>{IM()},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-primary":!0,children:b("landing.quickOpenRouter")}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"text-2xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0",children:b("landing.quickOther")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"mt-2 mx-auto text-2xs text-ink-faint hover:text-accent transition-colors block","data-quick-subs":!0,children:b("landing.quickSubs")})]}),l.jsx("div",{className:"grid grid-cols-3 gap-3 mt-6",children:[{icon:ni,title:"landing.feature1.title",desc:"landing.feature1.desc"},{icon:Xk,title:"landing.feature2.title",desc:"landing.feature2.desc"},{icon:WA,title:"landing.feature3.title",desc:"landing.feature3.desc"}].map(({icon:H,title:ce,desc:we})=>l.jsxs("div",{className:"bg-card/60 backdrop-blur border border-line rounded-xl px-4 py-3.5",children:[l.jsx(H,{size:16,strokeWidth:1.75,className:"text-accent mb-2"}),l.jsx("h3",{className:"text-xs font-semibold text-ink mb-1",children:b(ce)}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:b(we)})]},ce))}),l.jsxs("div",{className:"text-center mt-6 flex items-center justify-center gap-5",children:[l.jsxs("button",{onClick:bt,className:"text-xs text-accent hover:text-accent-strong font-medium transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Xk,{size:14,strokeWidth:1.75})," ",b("landing.loadExample")]}),l.jsxs("button",{onClick:()=>y(!0),className:"text-xs text-ink-muted hover:text-accent transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Wk,{size:14,strokeWidth:1.75})," ",b("landing.howItWorks")]})]})]})]}),!Et&&l.jsx(oce,{onSwitched:Ye}),(Q||Me)&&!Et&&l.jsxs("div",{className:"absolute top-[38%] -translate-y-1/2 left-4 z-10 flex flex-col gap-1.5 bg-card/90 backdrop-blur border border-line rounded-xl p-1.5 shadow-sm",children:[!Me&&l.jsx("button",{onClick:()=>Ct(_e(null)),draggable:!0,onDragStart:H=>{H.dataTransfer.setData("application/thoughtdag-content","ask"),H.dataTransfer.effectAllowed="copy"},title:b("palette.askTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-accent hover:bg-accent/10 transition-colors cursor-grab",children:l.jsx($d,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("note",_e(ce))),title:b("palette.noteTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-amber-600 hover:bg-amber-500/10 transition-colors",children:l.jsx(ii,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("file",_e(ce))),title:b("palette.fileTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ls,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>rt(_e(ce))),title:b("palette.frameTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Fb,{size:17,strokeWidth:1.75})})]}),Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Vd+12:16},"data-top-toolbar":!0,children:[l.jsxs("span",{className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm text-ink-muted text-xs font-medium","data-viewer-badge":!0,children:[l.jsx(f0,{size:14,strokeWidth:1.75})," ",b("viewer.badge")]}),l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(HT,{}),l.jsx("button",{onClick:()=>uy(),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("viewer.downloadJson"),children:l.jsx(Ml,{size:15,strokeWidth:1.75})}),l.jsx("a",{href:"https://github.com/chenxiachan/thoughtdag",target:"_blank",rel:"noreferrer",className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:b("viewer.openApp")})]}),!Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Vd+12:16},"data-top-toolbar":!0,children:[Me&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>mt("human"),className:"bg-card/90 backdrop-blur border border-warm/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-warm/10 transition-colors text-warm text-xs font-medium",children:[l.jsx($d,{size:14,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"bg-card/90 backdrop-blur border border-accent/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-accent/10 transition-colors text-accent text-xs font-medium",children:[l.jsx(Go,{size:14,strokeWidth:1.75})," ",b("paradigm.addPrompt")]}),l.jsxs("button",{onClick:()=>{Ze()},title:b("paradigm.instantiateTitle"),className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:["▶ ",b("paradigm.instantiate")]})]}),!Me&&l.jsx(uue,{}),!Me&&l.jsx(wM,{}),!Q&&l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("apikey.entryTitle"),"data-apikey-entry":!0,children:l.jsx(p0,{size:15,strokeWidth:1.75})}),mn>0&&!Me&&l.jsxs("button",{onClick:()=>{const{nodes:H,edges:ce}=se.getState(),Ne=Qr(se.getState()).reduce((Xe,vt)=>{const wt=H.map(fn=>fn.id===vt?{...fn,data:{...fn.data,question:"",response:""}}:fn),{layerTokens:Ot}=br(vt,wt,ce),$t=H.find(fn=>fn.id===vt)?.data.question??"";return Xe+Ot.material+Ot.reference+Ot.chain+Nn($t)},0);ai({title:b("replay.confirmTitle"),message:ve(b("replay.confirmMsg"),{n:mn,tok:Ne.toLocaleString()}),confirmLabel:b("replay.confirmBtn")}).then(Xe=>{Xe&&se.getState().replayStale()})},className:"bg-amber-500/10 backdrop-blur border border-amber-500/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-amber-500/20 transition-colors text-amber-600 text-xs font-medium",title:b("replay.chipTitle"),children:[l.jsx(KF,{size:14,strokeWidth:1.75})," ",mn]}),Q&&Qt.length>0&&l.jsxs("div",{ref:tn,className:"relative",children:[l.jsx("button",{onClick:()=>Yn(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${Zt?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.frames"),children:l.jsx(Fb,{size:15,strokeWidth:1.75})}),Zt&&l.jsx("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[230px] max-h-[320px] overflow-y-auto z-30 animate-fade-in",children:Qt.map(H=>l.jsxs("button",{onClick:()=>{Yn(!1),K.current?.fitBounds({x:H.position.x,y:H.position.y,width:H.width??640,height:H.height??420},{duration:400,padding:.15})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx("span",{className:`w-2.5 h-2.5 rounded-sm shrink-0 ${(Wd[H.data.frameColor??"gray"]??Wd.gray).dot}`}),l.jsx("span",{className:"truncate",children:H.data.question||b("frame.untitled")})]},H.id))})]}),Q&&l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(HT,{}),Q&&!Me&&l.jsx(Dle,{showTrigger:!1,openPing:Jn,onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Ee&&!Et&&l.jsxs("button",{onClick:()=>oe.getState().setCondenseDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-accent/50 rounded-lg h-8 px-2 flex items-center justify-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-accent",title:ve(b("condense.entryBuilding"),{i:String(Fe.current),n:String(Fe.total)}),"data-condense-entry":!0,children:[l.jsx(nn,{size:14,strokeWidth:1.75,className:"animate-spin"}),l.jsxs("span",{className:"text-2xs font-mono",children:[Fe.current,"/",Fe.total]})]}),$p&&l.jsx("button",{onClick:()=>oe.getState().setBackupDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("backup.dialogTitle"),"data-backup-entry":!0,children:l.jsx(PA,{size:15,strokeWidth:1.75})}),l.jsxs("div",{ref:Hn,className:"relative",children:[l.jsx("button",{onClick:()=>An(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${wn?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.more"),"data-toolbar-more":!0,children:l.jsx(jA,{size:15,strokeWidth:1.75})}),wn&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[220px] z-30 animate-fade-in",children:[Q&&l.jsxs("button",{onClick:()=>{An(!1),E(!w)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b(w?"toolbar.showAnnotations":"toolbar.hideAnnotations"),children:[l.jsx(ii,{size:14,strokeWidth:1.75,className:`shrink-0 ${w?"text-accent":"text-ink-faint"}`})," ",b(w?"toolbar.menuAnnotationsShow":"toolbar.menuAnnotationsHide")]}),l.jsxs("button",{onClick:()=>{An(!1),A(!v)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.wheelPansTitle"),"aria-pressed":v,"data-wheel-pans":!0,children:[l.jsx(IF,{size:14,strokeWidth:1.75,className:`shrink-0 ${v?"text-accent":"text-ink-faint"}`})," ",l.jsx("span",{className:"flex-1",children:b("toolbar.menuWheelPans")}),v&&l.jsx("span",{className:"text-accent",children:"✓"})]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),ai({title:b("confirm.relayoutTitle"),message:b("confirm.relayoutMsg"),confirmLabel:b("toolbar.relayout")}).then(H=>{H&&(x(),setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),50))})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(WF,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.relayout")]}),G>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setHighlightsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("hlov.entryTitle"),"data-hlov-entry":!0,children:[l.jsx(m0,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ve(b("hlov.entry"),{n:G})]}),J>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMaterialsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("matov.entryTitle"),"data-matov-entry":!0,children:[l.jsx(Ls,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ve(b("matov.entry"),{n:J})]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),Q&&!Me&&!Et&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setCondenseDialogOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("condense.entryTitle"),children:[l.jsx(xp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("condense.title"),"…"]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),Pa(H=>H+1)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.diagnose"),"data-menu-diagnose":!0,children:[l.jsx(VA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuDiagnose")]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),(async()=>{const{nodes:H,edges:ce}=se.getState(),{confirmIfSensitive:we}=await ft(async()=>{const{confirmIfSensitive:Xe}=await import("./sensitive-scan-CB-wz7Ro.js");return{confirmIfSensitive:Xe}},[]);if(!await we(H))return;const Ne=await Dq(H,ce);await navigator.clipboard.writeText(Ne).catch(()=>{}),oe.getState().setShareDialogUrl(Ne)})()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-share-link":!0,title:b("viewer.shareTitle"),children:[l.jsx(SU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuShare")]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),Me?cG():uy()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-menu-export":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b(Me?"paradigm.exportParadigm":"switcher.exportBackup")]}),F&&l.jsxs("button",{onClick:()=>{An(!1),mG()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.exportEventsTitle"),children:[l.jsx(js,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.exportEvents")]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("div",{className:"px-3 pt-2 pb-1","data-appearance-lighting":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.lighting")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["light",b("appearance.light")],["dark",b("appearance.dark")],["system",b("appearance.system")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Bi.getState().setLighting(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${pe===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsxs("div",{className:"px-3 pt-1 pb-2","data-appearance-paper":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.paper")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["plain",b("appearance.plain")],["grid",b("appearance.grid")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Bi.getState().setPaper(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${ue===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMemoryManagerOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("memory.entryTitle"),children:[l.jsx(LH,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("memory.managerTitle")]}),l.jsxs("button",{onClick:()=>{An(!1),y(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(Wk,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("landing.howItWorks")]}),xa&&l.jsxs("button",{onClick:()=>{An(!1);const H=Ln?`dsh-thoughtdag@${xa.latest}`:$y(xa.latest);navigator.clipboard.writeText(H).then(()=>We("success",b(Ln?"plugin.updateCopiedDesktop":"plugin.updateCopied")))},className:"w-full text-left px-3 py-2 text-xs text-accent hover:bg-wash transition-colors flex items-center gap-2.5",title:Ln?ve(b("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${xa.latest}`}):ve(b("plugin.updateHint"),{cmd:$y(xa.latest)}),"data-plugin-update":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",ve(b("plugin.updateAvailable"),{v:xa.latest})]}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setReleaseNotesOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-open-release-notes":!0,children:[l.jsx(gp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("releaseNotes.entry")]})]})]}),l.jsx("button",{onClick:s,disabled:p<=0,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.undo"),children:l.jsx(KA,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:o,disabled:p>=m.length-1,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.redo"),children:l.jsx(fU,{size:16,strokeWidth:1.75})})]}),ye&&!Et&&l.jsx(vle,{}),l.jsx(Ile,{open:I,onClose:()=>O(!1),onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Gt&&l.jsx(kle,{x:Gt.x,y:Gt.y,nodeId:Gt.nodeId,onClose:()=>ha(null)}),l.jsx(Tle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(vue,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Ele,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Rt&&l.jsx("div",{className:"fixed z-50 bg-card border border-line rounded-xl shadow-lg py-1 min-w-[120px]",style:{left:Rt.x,top:Rt.y},children:l.jsxs("button",{onClick:()=>na(Rt.edgeId),className:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors flex items-center gap-1.5",children:[l.jsx(Ja,{size:14,strokeWidth:1.75}),b("canvas.deleteEdge")]})})]}),l.jsx(tue,{onFocusSegment:H=>{const ce=K.current,we=se.getState().nodes.filter(fn=>H.includes(fn.id));if(!ce||we.length===0)return;const Ne=we.map(fn=>fn.position.x),Xe=we.map(fn=>fn.position.y),vt=Math.min(...Ne),wt=Math.min(...Xe),Ot=Math.max(...Ne)+520-vt,$t=Math.max(...Xe)+240-wt;ce.fitBounds({x:vt,y:wt,width:Ot+700,height:$t},{duration:350,padding:.15})}}),pn&&l.jsx(gle,{onFocusNode:H=>{const ce=e.find(we=>we.id===H);ce&&ze(ce,{duration:300})}}),l.jsx($le,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}})]})}function Nue({panelShiftWidth:e}){const t=G0(),n=St(),a=Vl(),r=se(d=>d.nodes.length),s=se(d=>d.nodes),o=D.useMemo(()=>{let d=null,h="";for(const m of s){if(m.data.stepKind&&m.data.stepKind!=="human"&&m.data.stepKind!=="prompt")continue;const p=[m.data.lastGeneratedAt,m.data.askedAt,m.data.createdAt,...m.data.editedAts??[]].filter(Boolean).sort().pop();p&&p>h&&(h=p,d=m)}return d?{node:d,at:h}:null},[s]);if(Et||t==="work"||r<2)return null;const u=()=>{if(!o)return;oe.getState().setBeaconNodeId(null);const{node:d}=o;a.setCenter(d.position.x+260,d.position.y+110,{zoom:1,duration:1100}),window.setTimeout(()=>{se.getState().setSelectedNodeId(d.id),oe.getState().setPanelOpen(!0),window.setTimeout(()=>{a.setCenter(d.position.x+260+np(d.id)/2,d.position.y+110,{zoom:1,duration:300})},60)},1150),window.setTimeout(()=>{We("success",n("continue.arrived"),12e3,{label:n("continue.summarize"),run:()=>{TM(d.id)}})},1550)};return l.jsxs("div",{className:"absolute bottom-6 z-10 flex items-center gap-2 -translate-x-1/2 transition-[left] duration-300",style:{left:`calc((100% - ${e}px) / 2)`},"data-map-dock":!0,children:[l.jsxs("button",{onClick:()=>oe.getState().setThoughtMapOpen(!0),"data-tmap-pill":!0,className:"flex items-center gap-2 bg-card/95 backdrop-blur border border-line-strong rounded-full px-5 py-2.5 text-sm text-ink shadow-lg hover:border-accent/40 hover:text-accent transition-colors",children:[l.jsx(c2,{size:16,strokeWidth:1.75})," ",n("tmap.export")]}),o&&l.jsxs("button",{onClick:u,onMouseEnter:()=>oe.getState().setBeaconNodeId(o.node.id),onMouseLeave:()=>oe.getState().setBeaconNodeId(null),title:n("continue.buttonTitle"),"data-continue-pill":!0,className:"flex items-center gap-2 bg-accent text-white rounded-full px-5 py-2.5 text-sm shadow-lg hover:bg-accent-strong transition-colors",children:[l.jsx(gU,{size:16,strokeWidth:1.75})," ",n("continue.button")]})]})}function Aue(){const e=G0(),t=ln(n=>n.transform[2]);return D.useEffect(()=>{document.querySelector(".react-flow")?.setAttribute("data-zoom-tier",e)},[e]),D.useEffect(()=>{document.querySelector(".react-flow")?.style.setProperty("--tdag-zoom",String(t))},[t]),null}Poe();const Yv="/thoughtdag/api";window.desktopSessions||N8(Yv);ft(()=>Promise.resolve().then(()=>hue),void 0).then(e=>e.bootPluginUpdateCheck(Yv));if(!window.desktopAgents){const e=Yv;ft(()=>import("./http-bridge-BFpCh3Q7.js"),[]).then(async t=>{await t.installAgentsHttpBridge(e)&&window.dispatchEvent(new CustomEvent("td:agents-ready"))})}Et?jq():(D7(),navigator.storage?.persist&&navigator.storage.persist(),ft(()=>Promise.resolve().then(()=>$ce),void 0).then(e=>e.bootAutoBackup()));ft(()=>import("./update-check-D-Q8qeFG.js"),[]).then(e=>e.bootUpdateCheck());window.addEventListener("hashchange",()=>{window.location.hash.startsWith("#view=")!==Et&&window.location.reload()});eD.createRoot(document.getElementById("root")).render(l.jsx(D.StrictMode,{children:l.jsx(Sue,{})}));export{O0 as A,xr as B,GV as C,Mue as D,U7 as E,Sa as F,I$ as I,ft as _,Te as a,se as b,sn as c,qi as d,R7 as e,ve as f,Ui as g,Lr as h,Et as i,wu as j,Tp as k,ly as l,ZV as m,Tn as n,XV as o,ws as p,z7 as q,QV as r,Xo as s,We as t,oe as u,ai as v,Iue as w,Qr as x,_ue as y,Cue as z};
|