@clauderecallhq/cli 0.94.0 → 0.95.5
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/README.md +6 -6
- package/dist/cli.js +260 -260
- package/dist/daemon/entrypoint.js +278 -278
- package/dist/daemon/query-worker.js +758 -0
- package/dist/mcp-server.js +82 -82
- package/dist/web/assets/{dist-Zvhj1IwK.js → dist-C3F6ixrp.js} +3 -3
- package/dist/web/assets/index-Uw_Mu1-d.css +1 -0
- package/dist/web/assets/{index-Cc61yjtR.js → index-emVWWys3.js} +14 -14
- package/dist/web/index.html +2 -2
- package/package.json +4 -3
- package/scripts/postinstall.mjs +1 -1
- package/dist/web/assets/index-Bk28z8Va.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./stats-Db9NRYik.js","./_brand-C2V3ysl0.js","./thread-4KmPh02n.js","./patterns-Dsv_eCME.js","./card-a-minimal-Beg8-vFs.js","./card-b-terminal-BxIeub6M.js","./card-c-gradient-Dp20rmwu.js","./card-d-dashboard-Dix1TgTv.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=ee(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},F={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.6`})),p=s(((e,t)=>{t.exports=f()})),m=s((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),h=s(((e,t)=>{t.exports=m()})),g=s((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.6`})),_=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=s((e=>{var t=h(),n=p(),r=_();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,m=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var ee=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var te=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var ne=z(null),H=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(H,e),V(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(ne),V(ne,e)}function oe(){B(ne),B(H),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=ne.current,n=Hd(t,e.type);t!==n&&(V(H,e),V(ne,n))}function ce(e){H.current===e&&(B(ne),B(H)),ie.current===e&&(B(ie),Qf._currentValue=I)}var U,le;function ue(e){if(U===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);U=t&&t[1]||``,le=-1<e.stack.indexOf(`
|
|
2
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=ee(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},F={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),p=s(((e,t)=>{t.exports=f()})),m=s((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),h=s(((e,t)=>{t.exports=m()})),g=s((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),_=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=s((e=>{var t=h(),n=p(),r=_();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,m=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var ee=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var te=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var ne=z(null),H=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(H,e),V(ne,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(ne),V(ne,e)}function oe(){B(ne),B(H),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=ne.current,n=Hd(t,e.type);t!==n&&(V(H,e),V(ne,n))}function ce(e){H.current===e&&(B(ne),B(H)),ie.current===e&&(B(ie),Qf._currentValue=I)}var U,le;function ue(e){if(U===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);U=t&&t[1]||``,le=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+U+e+le}var de=!1;function fe(e,t){if(!e||de)return``;de=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -7,9 +7,9 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
7
7
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{de=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ue(n):``}function pe(e,t){switch(e.tag){case 26:case 27:case 5:return ue(e.type);case 16:return ue(`Lazy`);case 13:return e.child!==t&&t!==null?ue(`Suspense Fallback`):ue(`Suspense`);case 19:return ue(`SuspenseList`);case 0:case 15:return fe(e.type,!1);case 11:return fe(e.type.render,!1);case 1:return fe(e.type,!0);case 31:return ue(`Activity`);default:return``}}function me(e){try{var t=``,n=null;do t+=pe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
8
|
Error generating stack: `+e.message+`
|
|
9
9
|
`+e.stack}}var he=Object.prototype.hasOwnProperty,ge=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,ve=t.unstable_shouldYield,ye=t.unstable_requestPaint,be=t.unstable_now,xe=t.unstable_getCurrentPriorityLevel,Se=t.unstable_ImmediatePriority,Ce=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,Te=t.unstable_LowPriority,Ee=t.unstable_IdlePriority,De=t.log,Oe=t.unstable_setDisableYieldValue,ke=null,Ae=null;function je(e){if(typeof De==`function`&&Oe(e),Ae&&typeof Ae.setStrictMode==`function`)try{Ae.setStrictMode(ke,e)}catch{}}var Me=Math.clz32?Math.clz32:Fe,Ne=Math.log,Pe=Math.LN2;function Fe(e){return e>>>=0,e===0?32:31-(Ne(e)/Pe|0)|0}var Ie=256,Le=262144,Re=4194304;function ze(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Be(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ze(n))):i=ze(o):i=ze(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ze(n))):i=ze(o)):i=ze(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ve(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function He(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ue(){var e=Re;return Re<<=1,!(Re&62914560)&&(Re=4194304),e}function We(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ge(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ke(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Me(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&W(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function W(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Me(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function G(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Me(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function qe(e,t){var n=t&-t;return n=n&42?1:K(n),(n&(e.suspendedLanes|t))===0?n:0}function K(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=F.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Xe(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,rt=`__reactHandles$`+Ze,it=`__reactResources$`+Ze,at=`__reactMarker$`+Ze;function ot(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[rt]}function st(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Qe])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function ct(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function q(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function J(e){var t=e[it];return t||=e[it]={hoistableStyles:new Map,hoistableScripts:new Map},t}function lt(e){e[at]=!0}var ut=new Set,dt={};function ft(e,t){pt(e,t),pt(e+`Capture`,t)}function pt(e,t){for(dt[e]=t,e=0;e<t.length;e++)ut.add(t[e])}var mt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Y={},X={};function Z(e){return he.call(X,e)?!0:he.call(Y,e)?!1:mt.test(e)?X[e]=!0:(Y[e]=!0,!1)}function ht(e,t,n){if(Z(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function gt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function _t(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function vt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function yt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function bt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function xt(e){if(!e._valueTracker){var t=yt(e)?`checked`:`value`;e._valueTracker=bt(e,t,``+e[t])}}function St(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=yt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Ct(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var wt=/[\n"\\]/g;function Tt(e){return e.replace(wt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Et(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+vt(t)):e.value!==``+vt(t)&&(e.value=``+vt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ot(e,o,vt(n)):Ot(e,o,vt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+vt(s):e.removeAttribute(`name`)}function Dt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){xt(e);return}n=n==null?``:``+vt(n),t=t==null?n:``+vt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),xt(e)}function Ot(e,t,n){t===`number`&&Ct(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function kt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+vt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function At(e,t,n){if(t!=null&&(t=``+vt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+vt(n)}function jt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(te(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=vt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),xt(e)}function Mt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Nt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Pt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Nt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ft(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Pt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Pt(e,o,t[o])}function It(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Lt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Q=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Rt(e){return Q.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function zt(){}var Bt=null;function Vt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ht=null,Ut=null;function Wt(e){var t=ct(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Et(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Tt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));Et(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&St(r)}break a;case`textarea`:At(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&kt(e,!!n.multiple,t,!1)}}}var Gt=!1;function Kt(e,t,n){if(Gt)return e(t,n);Gt=!0;try{return e(t)}finally{if(Gt=!1,(Ht!==null||Ut!==null)&&(_u(),Ht&&(t=Ht,e=Ut,Ut=Ht=null,Wt(t),e)))for(t=0;t<e.length;t++)Wt(e[t])}}function qt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Jt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Yt=!1;if(Jt)try{var Xt={};Object.defineProperty(Xt,"passive",{get:function(){Yt=!0}}),window.addEventListener(`test`,Xt,Xt),window.removeEventListener(`test`,Xt,Xt)}catch{Yt=!1}var Zt=null,Qt=null,$t=null;function en(){if($t)return $t;var e,t=Qt,n=t.length,r,i=`value`in Zt?Zt.value:Zt.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return $t=i.slice(e,1<r?1-r:void 0)}function tn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function nn(){return!0}function rn(){return!1}function an(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?nn:rn,this.isPropagationStopped=rn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=nn)},persist:function(){},isPersistent:nn}),t}var on={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sn=an(on),cn=f({},on,{view:0,detail:0}),ln=an(cn),un,dn,fn,pn=f({},cn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==fn&&(fn&&e.type===`mousemove`?(un=e.screenX-fn.screenX,dn=e.screenY-fn.screenY):dn=un=0,fn=e),un)},movementY:function(e){return`movementY`in e?e.movementY:dn}}),mn=an(pn),hn=an(f({},pn,{dataTransfer:0})),gn=an(f({},cn,{relatedTarget:0})),_n=an(f({},on,{animationName:0,elapsedTime:0,pseudoElement:0})),vn=an(f({},on,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),yn=an(f({},on,{data:0})),bn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},xn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Sn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Cn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Sn[e])?!!t[e]:!1}function wn(){return Cn}var $=an(f({},cn,{key:function(e){if(e.key){var t=bn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=tn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?xn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return e.type===`keypress`?tn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?tn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Tn=an(f({},pn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),En=an(f({},cn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),Dn=an(f({},on,{propertyName:0,elapsedTime:0,pseudoElement:0})),On=an(f({},pn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),kn=an(f({},on,{newState:0,oldState:0})),An=[9,13,27,32],jn=Jt&&`CompositionEvent`in window,Mn=null;Jt&&`documentMode`in document&&(Mn=document.documentMode);var Nn=Jt&&`TextEvent`in window&&!Mn,Pn=Jt&&(!jn||Mn&&8<Mn&&11>=Mn),Fn=` `,In=!1;function Ln(e,t){switch(e){case`keyup`:return An.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Rn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var zn=!1;function Bn(e,t){switch(e){case`compositionend`:return Rn(t);case`keypress`:return t.which===32?(In=!0,Fn):null;case`textInput`:return e=t.data,e===Fn&&In?null:e;default:return null}}function Vn(e,t){if(zn)return e===`compositionend`||!jn&&Ln(e,t)?(e=en(),$t=Qt=Zt=null,zn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Pn&&t.locale!==`ko`?null:t.data;default:return null}}var Hn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Un(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Hn[e.type]:t===`textarea`}function Wn(e,t,n,r){Ht?Ut?Ut.push(r):Ut=[r]:Ht=r,t=Td(t,`onChange`),0<t.length&&(n=new sn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Gn=null,Kn=null;function qn(e){_d(e,0)}function Jn(e){if(St(q(e)))return e}function Yn(e,t){if(e===`change`)return t}var Xn=!1;if(Jt){var Zn;if(Jt){var Qn=`oninput`in document;if(!Qn){var $n=document.createElement(`div`);$n.setAttribute(`oninput`,`return;`),Qn=typeof $n.oninput==`function`}Zn=Qn}else Zn=!1;Xn=Zn&&(!document.documentMode||9<document.documentMode)}function er(){Gn&&(Gn.detachEvent(`onpropertychange`,tr),Kn=Gn=null)}function tr(e){if(e.propertyName===`value`&&Jn(Kn)){var t=[];Wn(t,Kn,e,Vt(e)),Kt(qn,t)}}function nr(e,t,n){e===`focusin`?(er(),Gn=t,Kn=n,Gn.attachEvent(`onpropertychange`,tr)):e===`focusout`&&er()}function rr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Jn(Kn)}function ir(e,t){if(e===`click`)return Jn(t)}function ar(e,t){if(e===`input`||e===`change`)return Jn(t)}function or(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var sr=typeof Object.is==`function`?Object.is:or;function cr(e,t){if(sr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!he.call(t,i)||!sr(e[i],t[i]))return!1}return!0}function lr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ur(e,t){var n=lr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=lr(n)}}function dr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?dr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function fr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ct(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ct(e.document)}return t}function pr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var mr=Jt&&`documentMode`in document&&11>=document.documentMode,hr=null,gr=null,_r=null,vr=!1;function yr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;vr||hr==null||hr!==Ct(r)||(r=hr,`selectionStart`in r&&pr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_r&&cr(_r,r)||(_r=r,r=Td(gr,`onSelect`),0<r.length&&(t=new sn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=hr)))}function br(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var xr={animationend:br(`Animation`,`AnimationEnd`),animationiteration:br(`Animation`,`AnimationIteration`),animationstart:br(`Animation`,`AnimationStart`),transitionrun:br(`Transition`,`TransitionRun`),transitionstart:br(`Transition`,`TransitionStart`),transitioncancel:br(`Transition`,`TransitionCancel`),transitionend:br(`Transition`,`TransitionEnd`)},Sr={},Cr={};Jt&&(Cr=document.createElement(`div`).style,`AnimationEvent`in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),`TransitionEvent`in window||delete xr.transitionend.transition);function wr(e){if(Sr[e])return Sr[e];if(!xr[e])return e;var t=xr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Cr)return Sr[e]=t[n];return e}var Tr=wr(`animationend`),Er=wr(`animationiteration`),Dr=wr(`animationstart`),Or=wr(`transitionrun`),kr=wr(`transitionstart`),Ar=wr(`transitioncancel`),jr=wr(`transitionend`),Mr=new Map,Nr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Nr.push(`scrollEnd`);function Pr(e,t){Mr.set(e,t),ft(t,[e])}var Fr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ir=[],Lr=0,Rr=0;function zr(){for(var e=Lr,t=Rr=Lr=0;t<e;){var n=Ir[t];Ir[t++]=null;var r=Ir[t];Ir[t++]=null;var i=Ir[t];Ir[t++]=null;var a=Ir[t];if(Ir[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Ur(n,i,a)}}function Br(e,t,n,r){Ir[Lr++]=e,Ir[Lr++]=t,Ir[Lr++]=n,Ir[Lr++]=r,Rr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Vr(e,t,n,r){return Br(e,t,n,r),Wr(e)}function Hr(e,t){return Br(e,null,null,t),Wr(e)}function Ur(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Me(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Wr(e){if(50<cu)throw cu=0,lu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Gr={};function Kr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qr(e,t,n,r){return new Kr(e,t,n,r)}function Jr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yr(e,t){var n=e.alternate;return n===null?(n=qr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Xr(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Zr(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Jr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,ne.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=qr(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return Qr(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=qr(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=qr(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=qr(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=qr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Qr(e,t,n,r){return e=qr(7,e,r,t),e.lanes=n,e}function $r(e,t,n){return e=qr(6,e,null,t),e.lanes=n,e}function ei(e){var t=qr(18,null,null,0);return t.stateNode=e,t}function ti(e,t,n){return t=qr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ni=new WeakMap;function ri(e,t){if(typeof e==`object`&&e){var n=ni.get(e);return n===void 0?(t={value:e,source:t,stack:me(t)},ni.set(e,t),t):n}return{value:e,source:t,stack:me(t)}}var ii=[],ai=0,oi=null,si=0,ci=[],li=0,ui=null,di=1,fi=``;function pi(e,t){ii[ai++]=si,ii[ai++]=oi,oi=e,si=t}function mi(e,t,n){ci[li++]=di,ci[li++]=fi,ci[li++]=ui,ui=e;var r=di;e=fi;var i=32-Me(r)-1;r&=~(1<<i),n+=1;var a=32-Me(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,di=1<<32-Me(t)+i|n<<i|r,fi=a+e}else di=1<<a|n<<i|r,fi=e}function hi(e){e.return!==null&&(pi(e,1),mi(e,1,0))}function gi(e){for(;e===oi;)oi=ii[--ai],ii[ai]=null,si=ii[--ai],ii[ai]=null;for(;e===ui;)ui=ci[--li],ci[li]=null,fi=ci[--li],ci[li]=null,di=ci[--li],ci[li]=null}function _i(e,t){ci[li++]=di,ci[li++]=fi,ci[li++]=ui,di=t.id,fi=t.overflow,ui=e}var vi=null,yi=null,bi=!1,xi=null,Si=!1,Ci=Error(i(519));function wi(e){throw Ai(ri(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ci}function Ti(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),Dt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),jt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=zt),t=!0):t=!1,t||wi(e,!0)}function Ei(e){for(vi=e.return;vi;)switch(vi.tag){case 5:case 31:case 13:Si=!1;return;case 27:case 3:Si=!0;return;default:vi=vi.return}}function Di(e){if(e!==vi)return!1;if(!bi)return Ei(e),bi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Ud(e.type,e.memoizedProps)),n=!n),n&&yi&&wi(e),Ei(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));yi=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));yi=uf(e)}else t===27?(t=yi,Zd(e.type)?(e=lf,lf=null,yi=e):yi=t):yi=vi?cf(e.stateNode.nextSibling):null;return!0}function Oi(){yi=vi=null,bi=!1}function ki(){var e=xi;return e!==null&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),xi=null),e}function Ai(e){xi===null?xi=[e]:xi.push(e)}var ji=z(null),Mi=null,Ni=null;function Pi(e,t,n){V(ji,t._currentValue),t._currentValue=n}function Fi(e){e._currentValue=ji.current,B(ji)}function Ii(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Li(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Ii(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Ii(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Ri(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;sr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ie.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Li(t,e,n,r),t.flags|=262144}function zi(e){for(e=e.firstContext;e!==null;){if(!sr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Bi(e){Mi=e,Ni=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Vi(e){return Ui(Mi,e)}function Hi(e,t){return Mi===null&&Bi(e),Ui(e,t)}function Ui(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ni===null){if(e===null)throw Error(i(308));Ni=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ni=Ni.next=t;return n}var Wi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Gi=t.unstable_scheduleCallback,Ki=t.unstable_NormalPriority,qi={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ji(){return{controller:new Wi,data:new Map,refCount:0}}function Yi(e){e.refCount--,e.refCount===0&&Gi(Ki,function(){e.controller.abort()})}var Xi=null,Zi=0,Qi=0,$i=null;function ea(e,t){if(Xi===null){var n=Xi=[];Zi=0,Qi=ld(),$i={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Zi++,t.then(ta,ta),t}function ta(){if(--Zi===0&&Xi!==null){$i!==null&&($i.status=`fulfilled`);var e=Xi;Xi=null,Qi=0,$i=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function na(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ra=P.S;P.S=function(e,t){Zl=be(),typeof t==`object`&&t&&typeof t.then==`function`&&ea(e,t),ra!==null&&ra(e,t)};var ia=z(null);function aa(){var e=ia.current;return e===null?Ml.pooledCache:e}function oa(e,t){t===null?V(ia,ia.current):V(ia,t.pool)}function sa(){var e=aa();return e===null?null:{parent:qi._currentValue,pool:e}}var ca=Error(i(460)),la=Error(i(474)),ua=Error(i(542)),da={then:function(){}};function fa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function pa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(zt,zt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,_a(e),e;default:if(typeof t.status==`string`)t.then(zt,zt);else{if(e=Ml,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,_a(e),e}throw ha=t,ca}}function ma(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ha=e,ca):e}}var ha=null;function ga(){if(ha===null)throw Error(i(459));var e=ha;return ha=null,e}function _a(e){if(e===ca||e===ua)throw Error(i(483))}var va=null,ya=0;function ba(e){var t=ya;return ya+=1,va===null&&(va=[]),pa(va,e,t)}function xa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Sa(e,t){throw t.$$typeof===m?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ca(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Yr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=$r(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&ma(i)===t.type)?(t=a(t,n.props),xa(t,n),t.return=e,t):(t=Zr(n.type,n.key,n.props,null,e.mode,r),xa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ti(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Qr(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=$r(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=Zr(t.type,t.key,t.props,null,e.mode,n),xa(n,t),n.return=e,n;case v:return t=ti(t,e.mode,n),t.return=e,t;case O:return t=ma(t),f(e,t,n)}if(te(t)||M(t))return t=Qr(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ba(t),n);if(t.$$typeof===C)return f(e,Hi(e,t),n);Sa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=ma(n),p(e,t,n,r)}if(te(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ba(n),r);if(n.$$typeof===C)return p(e,t,Hi(e,n),r);Sa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=ma(r),m(e,t,n,r,i)}if(te(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,ba(r),i);if(r.$$typeof===C)return m(e,t,n,Hi(t,r),i);Sa(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),bi&&pi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return bi&&pi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),bi&&pi(i,h),l}function _(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),bi&&pi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return bi&&pi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),bi&&pi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case g:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&ma(l)===r.type){n(e,r.sibling),c=a(r,o.props),xa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=Qr(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=Zr(o.type,o.key,o.props,null,e.mode,c),xa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ti(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=ma(o),b(e,r,o,c)}if(te(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),_(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,ba(o),c);if(o.$$typeof===C)return b(e,r,Hi(e,o),c);Sa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=$r(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ya=0;var i=b(e,t,n,r);return va=null,i}catch(t){if(t===ca||t===ua)throw t;var a=qr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var wa=Ca(!0),Ta=Ca(!1),Ea=!1;function Da(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Oa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Aa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,jl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Wr(e),Ur(e,null,n),t}return Br(e,r,t,n),Wr(e)}function ja(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,G(e,n)}}function Ma(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Pa(){if(Na){var e=$i;if(e!==null)throw e}}function Fa(e,t,n,r){Na=!1;var i=e.updateQueue;Ea=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Pl&p)===p:(r&p)===p){p!==0&&p===Qi&&(Na=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Ea=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Hl|=o,e.lanes=o,e.memoizedState=d}}function Ia(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function La(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ia(n[e],t)}var Ra=z(null),za=z(0);function Ba(e,t){e=Bl,V(za,e),V(Ra,t),Bl=e|t.baseLanes}function Va(){V(za,Bl),V(Ra,Ra.current)}function Ha(){Bl=za.current,B(Ra),B(za)}var Ua=z(null),Wa=null;function Ga(e){var t=e.alternate;V(Xa,Xa.current&1),V(Ua,e),Wa===null&&(t===null||Ra.current!==null||t.memoizedState!==null)&&(Wa=e)}function Ka(e){V(Xa,Xa.current),V(Ua,e),Wa===null&&(Wa=e)}function qa(e){e.tag===22?(V(Xa,Xa.current),V(Ua,e),Wa===null&&(Wa=e)):Ja(e)}function Ja(){V(Xa,Xa.current),V(Ua,Ua.current)}function Ya(e){B(Ua),Wa===e&&(Wa=null),B(Xa)}var Xa=z(0);function Za(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Qa=0,$a=null,eo=null,to=null,no=!1,ro=!1,io=!1,ao=0,oo=0,so=null,co=0;function lo(){throw Error(i(321))}function uo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!sr(e[n],t[n]))return!1;return!0}function fo(e,t,n,r,i,a){return Qa=a,$a=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?ks:As,io=!1,a=n(r,i),io=!1,ro&&(a=mo(t,n,r,i)),po(e),a}function po(e){P.H=Os;var t=eo!==null&&eo.next!==null;if(Qa=0,to=eo=$a=null,no=!1,oo=0,so=null,t)throw Error(i(300));e===null||qs||(e=e.dependencies,e!==null&&zi(e)&&(qs=!0))}function mo(e,t,n,r){$a=e;var a=0;do{if(ro&&(so=null),oo=0,ro=!1,25<=a)throw Error(i(301));if(a+=1,to=eo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=js,o=t(n,r)}while(ro);return o}function ho(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?So(t):t,e=e.useState()[0],(eo===null?null:eo.memoizedState)!==e&&($a.flags|=1024),t}function go(){var e=ao!==0;return ao=0,e}function _o(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function vo(e){if(no){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}no=!1}Qa=0,to=eo=$a=null,ro=!1,oo=ao=0,so=null}function yo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return to===null?$a.memoizedState=to=e:to=to.next=e,to}function bo(){if(eo===null){var e=$a.alternate;e=e===null?null:e.memoizedState}else e=eo.next;var t=to===null?$a.memoizedState:to.next;if(t!==null)to=t,eo=e;else{if(e===null)throw $a.alternate===null?Error(i(467)):Error(i(310));eo=e,e={memoizedState:eo.memoizedState,baseState:eo.baseState,baseQueue:eo.baseQueue,queue:eo.queue,next:null},to===null?$a.memoizedState=to=e:to=to.next=e}return to}function xo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function So(e){var t=oo;return oo+=1,so===null&&(so=[]),e=pa(so,e,t),t=$a,(to===null?t.memoizedState:to.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?ks:As),e}function Co(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return So(e);if(e.$$typeof===C)return Vi(e)}throw Error(i(438,String(e)))}function wo(e){var t=null,n=$a.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=$a.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=xo(),$a.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function To(e,t){return typeof t==`function`?t(e):t}function Eo(e){return Do(bo(),eo,e)}function Do(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Qa&f)===f:(Pl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Qi&&(d=!0);else if((Qa&p)===p){u=u.next,p===Qi&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,$a.lanes|=p,Hl|=p;f=u.action,io&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,$a.lanes|=f,Hl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!sr(o,e.memoizedState)&&(qs=!0,d&&(n=$i,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Oo(e){var t=bo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);sr(o,t.memoizedState)||(qs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function ko(e,t,n){var r=$a,a=bo(),o=bi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!sr((eo||a).memoizedState,n);if(s&&(a.memoizedState=n,qs=!0),a=a.queue,es(Mo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||to!==null&&to.memoizedState.tag&1){if(r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,a,n,t),null),Ml===null)throw Error(i(349));o||Qa&127||Ao(r,t,n)}return n}function Ao(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$a.updateQueue,t===null?(t=xo(),$a.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function jo(e,t,n,r){t.value=n,t.getSnapshot=r,No(t)&&Po(e)}function Mo(e,t,n){return n(function(){No(t)&&Po(e)})}function No(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!sr(e,n)}catch{return!0}}function Po(e){var t=Hr(e,2);t!==null&&fu(t,e,2)}function Fo(e){var t=yo();if(typeof e==`function`){var n=e;if(e=n(),io){je(!0);try{n()}finally{je(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:e},t}function Io(e,t,n,r){return e.baseState=n,Do(e,eo,typeof r==`function`?r:To)}function Lo(e,t,n,r,a){if(Ts(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ro(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ro(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),zo(e,t,s)}catch(n){Vo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),zo(e,t,a)}catch(n){Vo(e,t,n)}}function zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Bo(e,t,n)},function(n){return Vo(e,t,n)}):Bo(e,t,n)}function Bo(e,t,n){t.status=`fulfilled`,t.value=n,Ho(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ro(e,n)))}function Vo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Ho(t),t=t.next;while(t!==r)}e.action=null}function Ho(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Uo(e,t){return t}function Wo(e,t){if(bi){var n=Ml.formState;if(n!==null){a:{var r=$a;if(bi){if(yi){b:{for(var i=yi,a=Si;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){yi=cf(i.nextSibling),r=i.data===`F!`;break a}}wi(r)}r=!1}r&&(t=n[0])}}return n=yo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:t},n.queue=r,n=Ss.bind(null,$a,r),r.dispatch=n,r=Fo(!1),a=ws.bind(null,$a,!1,r.queue),r=yo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Lo.bind(null,$a,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Go(e){return Ko(bo(),eo,e)}function Ko(e,t,n){if(t=Do(e,t,Uo)[0],e=Eo(To)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=So(t)}catch(e){throw e===ca?ua:e}else r=t;t=bo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&($a.flags|=2048,Yo(9,{destroy:void 0},qo.bind(null,i,n),null)),[r,a,e]}function qo(e,t){e.action=t}function Jo(e){var t=bo(),n=eo;if(n!==null)return Ko(t,n,e);bo(),t=t.memoizedState,n=bo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=$a.updateQueue,t===null&&(t=xo(),$a.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Xo(){return bo().memoizedState}function Zo(e,t,n,r){var i=yo();$a.flags|=e,i.memoizedState=Yo(1|t,{destroy:void 0},n,r===void 0?null:r)}function Qo(e,t,n,r){var i=bo();r=r===void 0?null:r;var a=i.memoizedState.inst;eo!==null&&r!==null&&uo(r,eo.memoizedState.deps)?i.memoizedState=Yo(t,a,n,r):($a.flags|=e,i.memoizedState=Yo(1|t,a,n,r))}function $o(e,t){Zo(8390656,8,e,t)}function es(e,t){Qo(2048,8,e,t)}function ts(e){$a.flags|=4;var t=$a.updateQueue;if(t===null)t=xo(),$a.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ns(e){var t=bo().memoizedState;return ts({ref:t,nextImpl:e}),function(){if(jl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function rs(e,t){return Qo(4,2,e,t)}function is(e,t){return Qo(4,4,e,t)}function as(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function os(e,t,n){n=n==null?null:n.concat([e]),Qo(4,4,as.bind(null,t,e),n)}function ss(){}function cs(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&uo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ls(e,t){var n=bo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&uo(t,r[1]))return r[0];if(r=e(),io){je(!0);try{e()}finally{je(!1)}}return n.memoizedState=[r,t],r}function us(e,t,n){return n===void 0||Qa&1073741824&&!(Pl&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),$a.lanes|=e,Hl|=e,n)}function ds(e,t,n,r){return sr(n,t)?n:Ra.current===null?!(Qa&42)||Qa&1073741824&&!(Pl&261930)?(qs=!0,e.memoizedState=n):(e=du(),$a.lanes|=e,Hl|=e,t):(e=us(e,n,r),sr(e,t)||(qs=!0),e)}function fs(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,ws(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Cs(e,t,na(c,r),uu(e)):Cs(e,t,r,uu(e))}catch(n){Cs(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function ps(){}function ms(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=hs(e).queue;fs(e,a,t,I,n===null?ps:function(){return gs(e),n(r)})}function hs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:I},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function gs(e){var t=hs(e);t.next===null&&(t=e.alternate.memoizedState),Cs(e,t.next.queue,{},uu())}function _s(){return Vi(Qf)}function vs(){return bo().memoizedState}function ys(){return bo().memoizedState}function bs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=ka(n);var r=Aa(t,e,n);r!==null&&(fu(r,t,n),ja(r,t,n)),t={cache:Ji()},e.payload=t;return}t=t.return}}function xs(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Es(t,n):(n=Vr(e,t,n,r),n!==null&&(fu(n,e,r),Ds(n,t,r)))}function Ss(e,t,n){Cs(e,t,n,uu())}function Cs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Es(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,sr(s,o))return Br(e,t,i,0),Ml===null&&zr(),!1}catch{}if(n=Vr(e,t,i,r),n!==null)return fu(n,e,r),Ds(n,t,r),!0}return!1}function ws(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(t)throw Error(i(479))}else t=Vr(e,n,r,2),t!==null&&fu(t,e,2)}function Ts(e){var t=e.alternate;return e===$a||t!==null&&t===$a}function Es(e,t){ro=no=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ds(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,G(e,n)}}var Os={readContext:Vi,use:Co,useCallback:lo,useContext:lo,useEffect:lo,useImperativeHandle:lo,useLayoutEffect:lo,useInsertionEffect:lo,useMemo:lo,useReducer:lo,useRef:lo,useState:lo,useDebugValue:lo,useDeferredValue:lo,useTransition:lo,useSyncExternalStore:lo,useId:lo,useHostTransitionStatus:lo,useFormState:lo,useActionState:lo,useOptimistic:lo,useMemoCache:lo,useCacheRefresh:lo};Os.useEffectEvent=lo;var ks={readContext:Vi,use:Co,useCallback:function(e,t){return yo().memoizedState=[e,t===void 0?null:t],e},useContext:Vi,useEffect:$o,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Zo(4194308,4,as.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){Zo(4,2,e,t)},useMemo:function(e,t){var n=yo();t=t===void 0?null:t;var r=e();if(io){je(!0);try{e()}finally{je(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=yo();if(n!==void 0){var i=n(t);if(io){je(!0);try{n(t)}finally{je(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=xs.bind(null,$a,e),[r.memoizedState,e]},useRef:function(e){var t=yo();return e={current:e},t.memoizedState=e},useState:function(e){e=Fo(e);var t=e.queue,n=Ss.bind(null,$a,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ss,useDeferredValue:function(e,t){return us(yo(),e,t)},useTransition:function(){var e=Fo(!1);return e=fs.bind(null,$a,e.queue,!0,!1),yo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=$a,a=yo();if(bi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ml===null)throw Error(i(349));Pl&127||Ao(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,$o(Mo.bind(null,r,o,e),[e]),r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,o,n,t),null),n},useId:function(){var e=yo(),t=Ml.identifierPrefix;if(bi){var n=fi,r=di;n=(r&~(1<<32-Me(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ao++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=co++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:_s,useFormState:Wo,useActionState:Wo,useOptimistic:function(e){var t=yo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ws.bind(null,$a,!0,n),n.dispatch=t,[e,t]},useMemoCache:wo,useCacheRefresh:function(){return yo().memoizedState=bs.bind(null,$a)},useEffectEvent:function(e){var t=yo(),n={impl:e};return t.memoizedState=n,function(){if(jl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},As={readContext:Vi,use:Co,useCallback:cs,useContext:Vi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Eo,useRef:Xo,useState:function(){return Eo(To)},useDebugValue:ss,useDeferredValue:function(e,t){return ds(bo(),eo.memoizedState,e,t)},useTransition:function(){var e=Eo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Go,useActionState:Go,useOptimistic:function(e,t){return Io(bo(),eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};As.useEffectEvent=ns;var js={readContext:Vi,use:Co,useCallback:cs,useContext:Vi,useEffect:es,useImperativeHandle:os,useInsertionEffect:rs,useLayoutEffect:is,useMemo:ls,useReducer:Oo,useRef:Xo,useState:function(){return Oo(To)},useDebugValue:ss,useDeferredValue:function(e,t){var n=bo();return eo===null?us(n,e,t):ds(n,eo.memoizedState,e,t)},useTransition:function(){var e=Oo(To)[0],t=bo().memoizedState;return[typeof e==`boolean`?e:So(e),t]},useSyncExternalStore:ko,useId:vs,useHostTransitionStatus:_s,useFormState:Jo,useActionState:Jo,useOptimistic:function(e,t){var n=bo();return eo===null?(n.baseState=e,[e,n.queue.dispatch]):Io(n,eo,e,t)},useMemoCache:wo,useCacheRefresh:ys};js.useEffectEvent=ns;function Ms(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ns={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ka(r);i.payload=t,n!=null&&(i.callback=n),t=Aa(e,i,r),t!==null&&(fu(t,e,r),ja(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=ka(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Aa(e,i,r),t!==null&&(fu(t,e,r),ja(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=ka(n);r.tag=2,t!=null&&(r.callback=t),t=Aa(e,r,n),t!==null&&(fu(t,e,n),ja(t,e,n))}};function Ps(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!cr(n,r)||!cr(i,a):!0}function Fs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ns.enqueueReplaceState(t,t.state,null)}function Is(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ls(e){Fr(e)}function Rs(e){console.error(e)}function zs(e){Fr(e)}function Bs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Vs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Hs(e,t,n){return n=ka(n),n.tag=3,n.payload={element:null},n.callback=function(){Bs(e,t)},n}function Us(e){return e=ka(e),e.tag=3,e}function Ws(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Vs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Vs(t,n,r),typeof i!=`function`&&(eu===null?eu=new Set([this]):eu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Gs(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ri(t,n,a,!0),n=Ua.current,n!==null){switch(n.tag){case 31:case 13:return Wa===null?wu():n.alternate===null&&Vl===0&&(Vl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===da?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Uu(e,r,a)),!1;case 22:return n.flags|=65536,r===da?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Uu(e,r,a)),!1}throw Error(i(435,n.tag))}return Uu(e,r,a),wu(),!1}if(bi)return t=Ua.current,t===null?(r!==Ci&&(t=Error(i(423),{cause:r}),Ai(ri(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ri(r,n),a=Hs(e.stateNode,r,a),Ma(e,a),Vl!==4&&(Vl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ci&&(e=Error(i(422),{cause:r}),Ai(ri(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ri(o,n),ql===null?ql=[o]:ql.push(o),Vl!==4&&(Vl=2),t===null)return!0;r=ri(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Hs(n.stateNode,r,e),Ma(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(eu===null||!eu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Us(a),Ws(a,e,n,r),Ma(n,a),!1}n=n.return}while(n!==null);return!1}var Ks=Error(i(461)),qs=!1;function Js(e,t,n,r){t.child=e===null?Ta(t,null,n,r):wa(t,e.child,n,r)}function Ys(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Bi(t),r=fo(e,t,n,o,a,i),s=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(bi&&s&&hi(t),t.flags|=1,Js(e,t,r,i),t.child)}function Xs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Jr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Zs(e,t,a,r,i)):(e=Zr(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!bc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?cr:n,n(o,r)&&e.ref===t.ref)return yc(e,t,i)}return t.flags|=1,e=Yr(a,r),e.ref=t.ref,e.return=t,t.child=e}function Zs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(cr(a,r)&&e.ref===t.ref)if(qs=!1,t.pendingProps=r=a,bc(e,i))e.flags&131072&&(qs=!0);else return t.lanes=e.lanes,yc(e,t,i)}return ac(e,t,n,r,i)}function Qs(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return ec(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&oa(t,a===null?null:a.cachePool),a===null?Va():Ba(t,a),qa(t);else return r=t.lanes=536870912,ec(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&oa(t,null),Va(),Ja(t)):(oa(t,a.cachePool),Ba(t,a),Ja(t),t.memoizedState=null);return Js(e,t,i,n),t.child}function $s(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function ec(e,t,n,r,i){var a=aa();return a=a===null?null:{parent:qi._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&oa(t,null),Va(),qa(t),e!==null&&Ri(e,t,r,!0),t.childLanes=i,null}function tc(e,t){return t=mc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function nc(e,t,n){return wa(t,e.child,null,n),e=tc(t,t.pendingProps),e.flags|=2,Ya(t),t.memoizedState=null,e}function rc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(bi){if(r.mode===`hidden`)return e=tc(t,r),t.lanes=536870912,$s(null,e);if(Ka(t),(e=yi)?(e=rf(e,Si),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ui===null?null:{id:di,overflow:fi},retryLane:536870912,hydrationErrors:null},n=ei(e),n.return=t,t.child=n,vi=t,yi=null)):e=null,e===null)throw wi(t);return t.lanes=536870912,null}return tc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Ka(t),a)if(t.flags&256)t.flags&=-257,t=nc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(qs||Ri(e,t,n,!1),a=(n&e.childLanes)!==0,qs||a){if(r=Ml,r!==null&&(s=qe(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Hr(e,s),fu(r,e,s),Ks;wu(),t=nc(e,t,n)}else e=o.treeContext,yi=cf(s.nextSibling),vi=t,bi=!0,xi=null,Si=!1,e!==null&&_i(t,e),t=tc(t,r),t.flags|=4096;return t}return e=Yr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ic(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function ac(e,t,n,r,i){return Bi(t),n=fo(e,t,n,r,void 0,i),r=go(),e!==null&&!qs?(_o(e,t,i),yc(e,t,i)):(bi&&r&&hi(t),t.flags|=1,Js(e,t,n,i),t.child)}function oc(e,t,n,r,i,a){return Bi(t),t.updateQueue=null,n=mo(t,r,n,i),po(e),r=go(),e!==null&&!qs?(_o(e,t,a),yc(e,t,a)):(bi&&r&&hi(t),t.flags|=1,Js(e,t,n,a),t.child)}function sc(e,t,n,r,i){if(Bi(t),t.stateNode===null){var a=Gr,o=n.contextType;typeof o==`object`&&o&&(a=Vi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ns,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Da(t),o=n.contextType,a.context=typeof o==`object`&&o?Vi(o):Gr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ms(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ns.enqueueReplaceState(a,a.state,null),Fa(t,r,a,i),Pa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Is(n,s);a.props=c;var l=a.context,u=n.contextType;o=Gr,typeof u==`object`&&u&&(o=Vi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Fs(t,a,r,o),Ea=!1;var f=t.memoizedState;a.state=f,Fa(t,r,a,i),Pa(),l=t.memoizedState,s||f!==l||Ea?(typeof d==`function`&&(Ms(t,n,d,r),l=t.memoizedState),(c=Ea||Ps(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Oa(e,t),o=t.memoizedProps,u=Is(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Gr,typeof l==`object`&&l&&(c=Vi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Fs(t,a,r,c),Ea=!1,f=t.memoizedState,a.state=f,Fa(t,r,a,i),Pa();var p=t.memoizedState;o!==d||f!==p||Ea||e!==null&&e.dependencies!==null&&zi(e.dependencies)?(typeof s==`function`&&(Ms(t,n,s,r),p=t.memoizedState),(u=Ea||Ps(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&zi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,ic(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=wa(t,e.child,null,i),t.child=wa(t,null,n,i)):Js(e,t,n,i),t.memoizedState=a.state,e=t.child):e=yc(e,t,i),e}function cc(e,t,n,r){return Oi(),t.flags|=256,Js(e,t,n,r),t.child}var lc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function uc(e){return{baseLanes:e,cachePool:sa()}}function dc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Gl),e}function fc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Xa.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(bi){if(a?Ga(t):Ja(t),(e=yi)?(e=rf(e,Si),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ui===null?null:{id:di,overflow:fi},retryLane:536870912,hydrationErrors:null},n=ei(e),n.return=t,t.child=n,vi=t,yi=null)):e=null,e===null)throw wi(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Ja(t),a=t.mode,c=mc({mode:`hidden`,children:c},a),r=Qr(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(null,r)):(Ga(t),pc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ga(t),t.flags&=-257,t=hc(e,t,n)):t.memoizedState===null?(Ja(t),c=r.fallback,a=t.mode,r=mc({mode:`visible`,children:r.children},a),c=Qr(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,wa(t,e.child,null,n),r=t.child,r.memoizedState=uc(n),r.childLanes=dc(e,s,n),t.memoizedState=lc,t=$s(null,r)):(Ja(t),t.child=e.child,t.flags|=128,t=null);else if(Ga(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ai({value:r,source:null,stack:null}),t=hc(e,t,n)}else if(qs||Ri(e,t,n,!1),s=(n&e.childLanes)!==0,qs||s){if(s=Ml,s!==null&&(r=qe(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Hr(e,r),fu(s,e,r),Ks;af(c)||wu(),t=hc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,yi=cf(c.nextSibling),vi=t,bi=!0,xi=null,Si=!1,e!==null&&_i(t,e),t=pc(t,r.children),t.flags|=4096);return t}return a?(Ja(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Yr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=Qr(c,a,n,null),c.flags|=2):c=Yr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,$s(null,r),r=t.child,c=e.child.memoizedState,c===null?c=uc(n):(a=c.cachePool,a===null?a=sa():(l=qi._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=dc(e,s,n),t.memoizedState=lc,$s(e.child,r)):(Ga(t),n=e.child,e=n.sibling,n=Yr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function pc(e,t){return t=mc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function mc(e,t){return e=qr(22,e,null,t),e.lanes=0,e}function hc(e,t,n){return wa(t,e.child,null,n),e=pc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function gc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ii(e.return,t,n)}function _c(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function vc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Xa.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(Xa,o),Js(e,t,r,n),r=bi?si:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&gc(e,n,t);else if(e.tag===19)gc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Za(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),_c(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Za(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}_c(t,!0,n,null,a,r);break;case`together`:_c(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function yc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Hl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Ri(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Yr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&zi(e))):!0}function xc(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Pi(t,qi,e.memoizedState.cache),Oi();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Pi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ka(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ga(t),e=yc(e,t,n),e===null?null:e.sibling):fc(e,t,n):(Ga(t),t.flags|=128,null);Ga(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Ri(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return vc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(Xa,Xa.current),r)break;return null;case 22:return t.lanes=0,Qs(e,t,n,t.pendingProps);case 24:Pi(t,qi,e.memoizedState.cache)}return yc(e,t,n)}function Sc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)qs=!0;else{if(!bc(e,n)&&!(t.flags&128))return qs=!1,xc(e,t,n);qs=!!(e.flags&131072)}else qs=!1,bi&&t.flags&1048576&&mi(t,si,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ma(t.elementType),t.type=e,typeof e==`function`)Jr(e)?(r=Is(e,r),t.tag=1,t=sc(null,t,e,r,n)):(t.tag=0,t=ac(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=Ys(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=Xs(null,t,e,r,n);break a}}throw t=N(e)||e,Error(i(306,t,``))}}return t;case 0:return ac(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Is(r,t.pendingProps),sc(e,t,r,a,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Oa(e,t),Fa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Pi(t,qi,r),r!==o.cache&&Li(t,[qi],n,!0),Pa(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=cc(e,t,r,n);break a}else if(r!==a){a=ri(Error(i(424)),t),Ai(a),t=cc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(yi=cf(e.firstChild),vi=t,bi=!0,xi=null,Si=!0,n=Ta(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Oi(),r===a){t=yc(e,t,n);break a}Js(e,t,r,n)}t=t.child}return t;case 26:return ic(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:bi||(n=t.type,e=t.pendingProps,r=Bd(re.current).createElement(n),r[Qe]=t,r[$e]=e,Pd(r,n,e),lt(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&bi&&(r=t.stateNode=ff(t.type,t.pendingProps,re.current),vi=t,Si=!0,a=yi,Zd(t.type)?(lf=a,yi=cf(r.firstChild)):yi=a),Js(e,t,t.pendingProps.children,n),ic(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&bi&&((a=r=yi)&&(r=tf(r,t.type,t.pendingProps,Si),r===null?a=!1:(t.stateNode=r,vi=t,yi=cf(r.firstChild),Si=!1,a=!0)),a||wi(t)),se(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=fo(e,t,ho,null,null,n),Qf._currentValue=a),ic(e,t),Js(e,t,r,n),t.child;case 6:return e===null&&bi&&((e=n=yi)&&(n=nf(n,t.pendingProps,Si),n===null?e=!1:(t.stateNode=n,vi=t,yi=null,e=!0)),e||wi(t)),null;case 13:return fc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wa(t,null,r,n):Js(e,t,r,n),t.child;case 11:return Ys(e,t,t.type,t.pendingProps,n);case 7:return Js(e,t,t.pendingProps,n),t.child;case 8:return Js(e,t,t.pendingProps.children,n),t.child;case 12:return Js(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Pi(t,t.type,r.value),Js(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Bi(t),a=Vi(a),r=r(a),t.flags|=1,Js(e,t,r,n),t.child;case 14:return Xs(e,t,t.type,t.pendingProps,n);case 15:return Zs(e,t,t.type,t.pendingProps,n);case 19:return vc(e,t,n);case 31:return rc(e,t,n);case 22:return Qs(e,t,n,t.pendingProps);case 24:return Bi(t),r=Vi(qi),e===null?(a=aa(),a===null&&(a=Ml,o=Ji(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Da(t),Pi(t,qi,a)):((e.lanes&n)!==0&&(Oa(e,t),Fa(t,null,null,n),Pa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Pi(t,qi,r),r!==a.cache&&Li(t,[qi],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Pi(t,qi,r))),Js(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Cc(e){e.flags|=4}function wc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(xu())e.flags|=8192;else throw ha=da,la}else e.flags&=-16777217}function Tc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t))if(xu())e.flags|=8192;else throw ha=da,la}function Ec(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ue(),e.lanes|=t,Kl|=t)}function Dc(e,t){if(!bi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Oc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function kc(e,t,n){var r=t.pendingProps;switch(gi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Oc(t),null;case 1:return Oc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Fi(qi),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Di(t)?Cc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ki())),Oc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Cc(t),o===null?(Oc(t),wc(t,a,null,r,n)):(Oc(t),Tc(t,o))):o?o===e.memoizedState?(Oc(t),t.flags&=-16777217):(Cc(t),Oc(t),Tc(t,o)):(e=e.memoizedProps,e!==r&&Cc(t),Oc(t),wc(t,a,e,r,n)),null;case 27:if(ce(t),n=re.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Oc(t),null}e=ne.current,Di(t)?Ti(t,e):(e=ff(a,r,n),t.stateNode=e,Cc(t))}return Oc(t),null;case 5:if(ce(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Oc(t),null}if(o=ne.current,Di(t))Ti(t,o);else{var s=Bd(re.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Cc(t)}}return Oc(t),wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=re.current,Di(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=vi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||wi(t,!0)}else e=Bd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return Oc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Di(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else Oi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),e=!1}else n=ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ya(t),t):(Ya(t),null);if(t.flags&128)throw Error(i(558))}return Oc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Di(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else Oi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),a=!1}else a=ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Ya(t),t):(Ya(t),null)}return Ya(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ec(t,t.updateQueue),Oc(t),null);case 4:return oe(),e===null&&xd(t.stateNode.containerInfo),Oc(t),null;case 10:return Fi(t.type),Oc(t),null;case 19:if(B(Xa),r=t.memoizedState,r===null)return Oc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Dc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Za(e),o!==null){for(t.flags|=128,Dc(r,!1),e=o.updateQueue,t.updateQueue=e,Ec(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Xr(n,e),n=n.sibling;return V(Xa,Xa.current&1|2),bi&&pi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&be()>Ql&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304)}else{if(!a)if(e=Za(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ec(t,e),Dc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!bi)return Oc(t),null}else 2*be()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Oc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=be(),e.sibling=null,n=Xa.current,V(Xa,a?n&1|2:n&1),bi&&pi(t,r.treeForkCount),e);case 22:case 23:return Ya(t),Ha(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Oc(t),t.subtreeFlags&6&&(t.flags|=8192)):Oc(t),n=t.updateQueue,n!==null&&Ec(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(ia),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Fi(qi),Oc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Ac(e,t){switch(gi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fi(qi),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(Ya(t),t.alternate===null)throw Error(i(340));Oi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ya(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Oi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(Xa),null;case 4:return oe(),null;case 10:return Fi(t.type),null;case 22:case 23:return Ya(t),Ha(),e!==null&&B(ia),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fi(qi),null;case 25:return null;default:return null}}function jc(e,t){switch(gi(t),t.tag){case 3:Fi(qi),oe();break;case 26:case 27:case 5:ce(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&Ya(t);break;case 13:Ya(t);break;case 19:B(Xa);break;case 10:Fi(t.type);break;case 22:case 23:Ya(t),Ha(),e!==null&&B(ia);break;case 24:Fi(qi)}}function Mc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Nc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Pc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{La(t,n)}catch(t){Hu(e,e.return,t)}}}function Fc(e,t,n){n.props=Is(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Ic(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Lc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}function Rc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function zc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[$e]=t}catch(t){Hu(e,e.return,t)}}function Bc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Vc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Bc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=zt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Hc(e,t,n),e=e.sibling;e!==null;)Hc(e,t,n),e=e.sibling}function Uc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Hu(e,e.return,t)}}var Gc=!1,Kc=!1,qc=!1,Jc=typeof WeakSet==`function`?WeakSet:Set,Yc=null;function Xc(e,t){if(e=e.containerInfo,Rd=sp,e=fr(e),pr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Yc=t;Yc!==null;)if(t=Yc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Yc=e;else for(;Yc!==null;){switch(t=Yc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Is(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Hu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Yc=e;break}Yc=t.return}}function Zc(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:fl(e,n),r&4&&Mc(5,n);break;case 1:if(fl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Hu(n,n.return,e)}else{var i=Is(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(n,n.return,e)}}r&64&&Pc(n),r&512&&Ic(n,n.return);break;case 3:if(fl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{La(e,t)}catch(e){Hu(n,n.return,e)}}break;case 27:t===null&&r&4&&Wc(n);case 26:case 5:fl(e,n),t===null&&r&4&&Rc(n),r&512&&Ic(n,n.return);break;case 12:fl(e,n);break;case 31:fl(e,n),r&4&&rl(e,n);break;case 13:fl(e,n),r&4&&il(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ku.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||Gc,!r){t=t!==null&&t.memoizedState!==null||Kc,i=Gc;var a=Kc;Gc=r,(Kc=t)&&!a?ml(e,n,(n.subtreeFlags&8772)!=0):fl(e,n),Gc=i,Kc=a}break;case 30:break;default:fl(e,n)}}function Qc(e){var t=e.alternate;t!==null&&(e.alternate=null,Qc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ot(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var $c=null,el=!1;function tl(e,t,n){for(n=n.child;n!==null;)nl(e,t,n),n=n.sibling}function nl(e,t,n){if(Ae&&typeof Ae.onCommitFiberUnmount==`function`)try{Ae.onCommitFiberUnmount(ke,n)}catch{}switch(n.tag){case 26:Kc||Lc(n,t),tl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Kc||Lc(n,t);var r=$c,i=el;Zd(n.type)&&($c=n.stateNode,el=!1),tl(e,t,n),pf(n.stateNode),$c=r,el=i;break;case 5:Kc||Lc(n,t);case 6:if(r=$c,i=el,$c=null,tl(e,t,n),$c=r,el=i,$c!==null)if(el)try{($c.nodeType===9?$c.body:$c.nodeName===`HTML`?$c.ownerDocument.body:$c).removeChild(n.stateNode)}catch(e){Hu(n,t,e)}else try{$c.removeChild(n.stateNode)}catch(e){Hu(n,t,e)}break;case 18:$c!==null&&(el?(e=$c,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd($c,n.stateNode));break;case 4:r=$c,i=el,$c=n.stateNode.containerInfo,el=!0,tl(e,t,n),$c=r,el=i;break;case 0:case 11:case 14:case 15:Nc(2,n,t),Kc||Nc(4,n,t),tl(e,t,n);break;case 1:Kc||(Lc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Fc(n,t,r)),tl(e,t,n);break;case 21:tl(e,t,n);break;case 22:Kc=(r=Kc)||n.memoizedState!==null,tl(e,t,n),Kc=r;break;default:tl(e,t,n)}}function rl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Hu(t,t.return,e)}}}function il(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Hu(t,t.return,e)}}function al(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Jc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Jc),t;default:throw Error(i(435,e.tag))}}function ol(e,t){var n=al(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=qu.bind(null,e,t);t.then(r,r)}})}function sl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){$c=c.stateNode,el=!1;break a}break;case 5:$c=c.stateNode,el=!1;break a;case 3:case 4:$c=c.stateNode.containerInfo,el=!0;break a}c=c.return}if($c===null)throw Error(i(160));nl(o,s,a),$c=null,el=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ll(t,e),t=t.sibling}var cl=null;function ll(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:sl(t,e),ul(e),r&4&&(Nc(3,e,e.return),Mc(3,e),Nc(5,e,e.return));break;case 1:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&64&&Gc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=cl;if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[at]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[Qe]=e,lt(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,lt(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode);else e.stateNode=If(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&zc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),n!==null&&r&4&&zc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(sl(t,e),ul(e),r&512&&(Kc||n===null||Lc(n,n.return)),e.flags&32){a=e.stateNode;try{Mt(a,``)}catch(t){Hu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,zc(e,a,n===null?a:n.memoizedProps)),r&1024&&(qc=!0);break;case 6:if(sl(t,e),ul(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Hu(e,e.return,t)}}break;case 3:if(Bf=null,a=cl,cl=gf(t.containerInfo),sl(t,e),cl=a,ul(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Hu(e,e.return,t)}qc&&(qc=!1,dl(e));break;case 4:r=cl,cl=gf(e.stateNode.containerInfo),sl(t,e),ul(e),cl=r;break;case 12:sl(t,e),ul(e);break;case 31:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 13:sl(t,e),ul(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Xl=be()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Gc,d=Kc;if(Gc=u||a,Kc=d||l,sl(t,e),Kc=d,Gc=u,ul(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Gc||Kc||pl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Hu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Hu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ol(e,n))));break;case 19:sl(t,e),ul(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ol(e,r)));break;case 30:break;case 21:break;default:sl(t,e),ul(e)}}function ul(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Bc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Uc(e,Vc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Mt(o,``),n.flags&=-33),Uc(e,Vc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Hc(e,Vc(e),s);break;default:throw Error(i(161))}}catch(t){Hu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;dl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function fl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Zc(e,t.alternate,t),t=t.sibling}function pl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Nc(4,t,t.return),pl(t);break;case 1:Lc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Fc(t,t.return,n),pl(t);break;case 27:pf(t.stateNode);case 26:case 5:Lc(t,t.return),pl(t);break;case 22:t.memoizedState===null&&pl(t);break;case 30:pl(t);break;default:pl(t)}e=e.sibling}}function ml(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:ml(i,a,n),Mc(4,a);break;case 1:if(ml(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Hu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ia(c[i],s)}catch(e){Hu(r,r.return,e)}}n&&o&64&&Pc(a),Ic(a,a.return);break;case 27:Wc(a);case 26:case 5:ml(i,a,n),n&&r===null&&o&4&&Rc(a),Ic(a,a.return);break;case 12:ml(i,a,n);break;case 31:ml(i,a,n),n&&o&4&&rl(i,a);break;case 13:ml(i,a,n),n&&o&4&&il(i,a);break;case 22:a.memoizedState===null&&ml(i,a,n),Ic(a,a.return);break;case 30:break;default:ml(i,a,n)}t=t.sibling}}function hl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Yi(n))}function gl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yi(e))}function _l(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)vl(e,t,n,r),t=t.sibling}function vl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:_l(e,t,n,r),i&2048&&Mc(9,t);break;case 1:_l(e,t,n,r);break;case 3:_l(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Yi(e)));break;case 12:if(i&2048){_l(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Hu(t,t.return,e)}}else _l(e,t,n,r);break;case 31:_l(e,t,n,r);break;case 13:_l(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?_l(e,t,n,r):(a._visibility|=2,yl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?_l(e,t,n,r):bl(e,t),i&2048&&hl(o,t);break;case 24:_l(e,t,n,r),i&2048&&gl(t.alternate,t);break;default:_l(e,t,n,r)}}function yl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:yl(a,o,s,c,i),Mc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,yl(a,o,s,c,i)):u._visibility&2?yl(a,o,s,c,i):bl(a,o),i&&l&2048&&hl(o.alternate,o);break;case 24:yl(a,o,s,c,i),i&&l&2048&&gl(o.alternate,o);break;default:yl(a,o,s,c,i)}t=t.sibling}}function bl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:bl(n,r),i&2048&&hl(r.alternate,r);break;case 24:bl(n,r),i&2048&&gl(r.alternate,r);break;default:bl(n,r)}t=t.sibling}}var xl=8192;function Sl(e,t,n){if(e.subtreeFlags&xl)for(e=e.child;e!==null;)Cl(e,t,n),e=e.sibling}function Cl(e,t,n){switch(e.tag){case 26:Sl(e,t,n),e.flags&xl&&e.memoizedState!==null&&Gf(n,cl,e.memoizedState,e.memoizedProps);break;case 5:Sl(e,t,n);break;case 3:case 4:var r=cl;cl=gf(e.stateNode.containerInfo),Sl(e,t,n),cl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=xl,xl=16777216,Sl(e,t,n),xl=r):Sl(e,t,n));break;default:Sl(e,t,n)}}function wl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Tl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)El(e),e=e.sibling}function El(e){switch(e.tag){case 0:case 11:case 15:Tl(e),e.flags&2048&&Nc(9,e,e.return);break;case 3:Tl(e);break;case 12:Tl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Dl(e)):Tl(e);break;default:Tl(e)}}function Dl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Yc=r,Ol(r,e)}wl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Nc(8,t,t.return),Dl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Dl(t));break;default:Dl(t)}e=e.sibling}}function Ol(e,t){for(;Yc!==null;){var n=Yc;switch(n.tag){case 0:case 11:case 15:Nc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Yi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Yc=r;else a:for(n=e;Yc!==null;){r=Yc;var i=r.sibling,a=r.return;if(Qc(r),r===n){Yc=null;break a}if(i!==null){i.return=a,Yc=i;break a}Yc=a}}}var kl={getCacheForType:function(e){var t=Vi(qi),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Vi(qi).controller.signal}},Al=typeof WeakMap==`function`?WeakMap:Map,jl=0,Ml=null,Nl=null,Pl=0,Fl=0,Il=null,Ll=!1,Rl=!1,zl=!1,Bl=0,Vl=0,Hl=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return jl&2&&Pl!==0?Pl&-Pl:P.T===null?Ye():ld()}function du(){if(Gl===0)if(!(Pl&536870912)||bi){var e=Le;Le<<=1,!(Le&3932160)&&(Le=262144),Gl=e}else Gl=536870912;return e=Ua.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Ml&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,Pl,Gl,!1)),Ge(e,n),(!(jl&2)||e!==Ml)&&(e===Ml&&(!(jl&2)&&(Ul|=n),Vl===4&&gu(e,Pl,Gl,!1)),td(e))}function pu(e,t,n){if(jl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Ve(e,t),a=r?Du(e,t):Tu(e,t,!0),o=r;do{if(a===0){Rl&&!r&&gu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!hu(n)){a=Tu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(zl&&!l){c.errorRecoveryDisabledLanes|=o,Ul|=o,a=4;break a}o=Jl,Jl=a,o!==null&&(Jl===null?Jl=o:Jl.push.apply(Jl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){yu(e,0),gu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:gu(r,t,Gl,!Ll);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Xl+300-be(),10<a)){if(gu(r,t,Gl,!Ll),Be(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,`Throttled`,-0,0),a);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Ll,o,null,-0,0)}}break}while(1);td(e)}function mu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zt},Cl(t,a,d);var m=(a&62914560)===a?Xl-be():(a&4194048)===a?Zl-be():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!sr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Me(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&W(e,n,t)}function _u(){return jl&6?!0:(nd(0,!1),!1)}function vu(){if(Nl!==null){if(Fl===0)var e=Nl.return;else e=Nl,Ni=Mi=null,vo(e),va=null,ya=0,e=Nl;for(;e!==null;)jc(e.alternate,e),e=e.return;Nl=null}}function yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Ml=e,Nl=n=Yr(e.current,null),Pl=t,Fl=0,Il=null,Ll=!1,Rl=Ve(e,t),zl=!1,Kl=Gl=Wl=Ul=Hl=Vl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Me(r),a=1<<i;t|=e[i],r&=~a}return Bl=t,zr(),n}function bu(e,t){$a=null,P.H=Os,t===ca||t===ua?(t=ga(),Fl=3):t===la?(t=ga(),Fl=4):Fl=t===Ks?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Il=t,Nl===null&&(Vl=1,Bs(e,ri(t,e.current)))}function xu(){var e=Ua.current;return e===null?!0:(Pl&4194048)===Pl?Wa===null:(Pl&62914560)===Pl||Pl&536870912?e===Wa:!1}function Su(){var e=P.H;return P.H=Os,e===null?Os:e}function Cu(){var e=P.A;return P.A=kl,e}function wu(){Vl=4,Ll||(Pl&4194048)!==Pl&&Ua.current!==null||(Rl=!0),!(Hl&134217727)&&!(Ul&134217727)||Ml===null||gu(Ml,Pl,Gl,!1)}function Tu(e,t,n){var r=jl;jl|=2;var i=Su(),a=Cu();(Ml!==e||Pl!==t)&&($l=null,yu(e,t)),t=!1;var o=Vl;a:do try{if(Fl!==0&&Nl!==null){var s=Nl,c=Il;switch(Fl){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Ua.current===null&&(t=!0);var l=Fl;if(Fl=0,Il=null,ju(e,s,c,l),n&&Rl){o=0;break a}break;default:l=Fl,Fl=0,Il=null,ju(e,s,c,l)}}Eu(),o=Vl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ni=Mi=null,jl=r,P.H=i,P.A=a,Nl===null&&(Ml=null,Pl=0,zr()),o}function Eu(){for(;Nl!==null;)ku(Nl)}function Du(e,t){var n=jl;jl|=2;var r=Su(),a=Cu();Ml!==e||Pl!==t?($l=null,Ql=be()+500,yu(e,t)):Rl=Ve(e,t);a:do try{if(Fl!==0&&Nl!==null){t=Nl;var o=Il;b:switch(Fl){case 1:Fl=0,Il=null,ju(e,t,o,1);break;case 2:case 9:if(fa(o)){Fl=0,Il=null,Au(t);break}t=function(){Fl!==2&&Fl!==9||Ml!==e||(Fl=7),td(e)},o.then(t,t);break a;case 3:Fl=7;break a;case 4:Fl=5;break a;case 7:fa(o)?(Fl=0,Il=null,Au(t)):(Fl=0,Il=null,ju(e,t,o,7));break;case 5:var s=null;switch(Nl.tag){case 26:s=Nl.memoizedState;case 5:case 27:var c=Nl;if(s?Wf(s):c.stateNode.complete){Fl=0,Il=null;var l=c.sibling;if(l!==null)Nl=l;else{var u=c.return;u===null?Nl=null:(Nl=u,Mu(u))}break b}}Fl=0,Il=null,ju(e,t,o,5);break;case 6:Fl=0,Il=null,ju(e,t,o,6);break;case 8:vu(),Vl=6;break a;default:throw Error(i(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Ni=Mi=null,P.H=r,P.A=a,jl=n,Nl===null?(Ml=null,Pl=0,zr(),Vl):0}function Ou(){for(;Nl!==null&&!ve();)ku(Nl)}function ku(e){var t=Sc(e.alternate,e,Bl);e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=oc(n,t,t.pendingProps,t.type,void 0,Pl);break;case 11:t=oc(n,t,t.pendingProps,t.type.render,t.ref,Pl);break;case 5:vo(t);default:jc(n,t),t=Nl=Xr(t,Bl),t=Sc(n,t,Bl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):Nl=t}function ju(e,t,n,r){Ni=Mi=null,vo(t),va=null,ya=0;var i=t.return;try{if(Gs(e,i,t,n,Pl)){Vl=1,Bs(e,ri(n,e.current)),Nl=null;return}}catch(t){if(i!==null)throw Nl=i,t;Vl=1,Bs(e,ri(n,e.current)),Nl=null;return}t.flags&32768?(bi||r===1?e=!0:Rl||Pl&536870912?e=!1:(Ll=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ua.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Ll);return}e=t.return;var n=kc(t.alternate,t,Bl);if(n!==null){Nl=n;return}if(t=t.sibling,t!==null){Nl=t;return}Nl=t=e}while(t!==null);Vl===0&&(Vl=5)}function Nu(e,t){do{var n=Ac(e.alternate,e);if(n!==null){n.flags&=32767,Nl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Nl=e;return}Nl=e=n}while(e!==null);Vl=6,Nl=null}function Pu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==0);if(jl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=Rr,Ke(e,n,o,s,c,l),e===Ml&&(Nl=Ml=null,Pl=0),ru=t,nu=e,iu=n,au=o,ou=a,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(we,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=jl,jl|=4;try{Xc(e,t,n)}finally{jl=s,F.p=a,P.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=jl;jl|=4;try{ll(t,e);var a=zd,o=fr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&dr(s.ownerDocument.documentElement,s)){if(c!==null&&pr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=ur(s,h),v=ur(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{jl=i,F.p=r,P.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=jl;jl|=4;try{Zc(e,t.alternate,t)}finally{jl=i,F.p=r,P.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,ye();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),Je(n),t=t.stateNode,Ae&&typeof Ae.onCommitFiberRoot==`function`)try{Ae.onCommitFiberRoot(ke,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Yi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=Je(iu),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,jl&6)throw Error(i(331));var c=jl;if(jl|=4,El(o.current),vl(o,o.current,s,n),jl=c,nd(0,!1),Ae&&typeof Ae.onPostCommitFiberRoot==`function`)try{Ae.onPostCommitFiberRoot(ke,o)}catch{}return!0}finally{F.p=a,P.T=r,Ru(e,t)}}function Vu(e,t,n){t=ri(n,t),t=Hs(e.stateNode,t,2),e=Aa(e,t,2),e!==null&&(Ge(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=ri(n,e),n=Us(2),r=Aa(t,n,2),r!==null&&(Ws(n,r,t,e),Ge(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Al;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ml===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>be()-Xl?!(jl&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=Ue()),e=Hr(e,t),e!==null&&(Ge(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return ge(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Me(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Be(r,r===Ml?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ve(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=be(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Me(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=He(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ml,n=Pl,n=Be(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Fl===2||Fl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&_e(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ve(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&_e(r),Je(n)){case 2:case 8:n=Ce;break;case 32:n=we;break;case 268435456:n=Ee;break;default:n=we}return r=od.bind(null,e),n=ge(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&_e(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=Pl;return r=Be(e,e===Ml?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,be()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){jl&6?ge(Se,rd):id()})}function ld(){if(ed===0){var e=Qi;e===0&&(e=Ie,Ie<<=1,!(Ie&261888)&&(Ie=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Rt(``+e)}function dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new sn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(i,o):new FormData(i);ms(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?dd(i,o):new FormData(i),ms(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Nr.length;pd++){var md=Nr[pd];Pr(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Pr(Tr,`onAnimationEnd`),Pr(Er,`onAnimationIteration`),Pr(Dr,`onAnimationStart`),Pr(`dblclick`,`onDoubleClick`),Pr(`focusin`,`onFocus`),Pr(`focusout`,`onBlur`),Pr(Or,`onTransitionRun`),Pr(kr,`onTransitionStart`),Pr(Ar,`onTransitionCancel`),Pr(jr,`onTransitionEnd`),pt(`onMouseEnter`,[`mouseout`,`mouseover`]),pt(`onMouseLeave`,[`mouseout`,`mouseover`]),pt(`onPointerEnter`,[`pointerout`,`pointerover`]),pt(`onPointerLeave`,[`pointerout`,`pointerover`]),ft(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ft(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ft(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ft(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ft(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Fr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Fr(e)}i.currentTarget=null,a=c}}}}function vd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,ut.forEach(function(t){t!==`selectionchange`&&(gd.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!Yt||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=st(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Kt(function(){var r=a,i=Vt(n),s=[];a:{var c=Mr.get(e);if(c!==void 0){var l=sn,u=e;switch(e){case`keypress`:if(tn(n)===0)break a;case`keydown`:case`keyup`:l=$;break;case`focusin`:u=`focus`,l=gn;break;case`focusout`:u=`blur`,l=gn;break;case`beforeblur`:case`afterblur`:l=gn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=mn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=hn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=En;break;case Tr:case Er:case Dr:l=_n;break;case jr:l=Dn;break;case`scroll`:case`scrollend`:l=ln;break;case`wheel`:l=On;break;case`copy`:case`cut`:case`paste`:l=vn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Tn;break;case`toggle`:case`beforetoggle`:l=kn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=qt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Bt&&(u=n.relatedTarget||n.fromElement)&&(st(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?st(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=mn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Tn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:q(l),h=u==null?c:q(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,st(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(s,c,l,d,!1),u!==null&&f!==null&&Dd(s,f,u,d,!0)}}a:{if(c=r?q(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Yn;else if(Un(c))if(Xn)v=ar;else{v=rr;var y=nr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&It(r.elementType)&&(v=Yn):v=ir;if(v&&=v(e,r)){Wn(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ot(c,`number`,c.value)}switch(y=r?q(r):window,e){case`focusin`:(Un(y)||y.contentEditable===`true`)&&(hr=y,gr=r,_r=null);break;case`focusout`:_r=gr=hr=null;break;case`mousedown`:vr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:vr=!1,yr(s,n,i);break;case`selectionchange`:if(mr)break;case`keydown`:case`keyup`:yr(s,n,i)}var b;if(jn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else zn?Ln(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Pn&&n.locale!==`ko`&&(zn||x!==`onCompositionStart`?x===`onCompositionEnd`&&zn&&(b=en()):(Zt=i,Qt=`value`in Zt?Zt.value:Zt.textContent,zn=!0)),y=Td(r,x),0<y.length&&(x=new yn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Rn(n),b!==null&&(x.data=b)))),(b=Nn?Bn(e,n):Vn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new yn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),fd(s,e,r,n,i)}_d(s,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=qt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=qt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=qt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=qt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
|
|
10
|
-
`).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Mt(e,``+r);break;case`className`:gt(e,`class`,r);break;case`tabIndex`:gt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:gt(e,n,r);break;case`style`:Ft(e,r,o);break;case`data`:if(t!==`object`){gt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Rt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Rt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=zt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Rt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),ht(e,`popover`,r);break;case`xlinkActuate`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:ht(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Lt.get(n)||n,ht(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Ft(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Mt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=zt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!dt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):ht(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}Dt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&kt(e,!!r,n,!0):kt(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}jt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(It(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Et(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?kt(e,!!n,n?[]:``,!1):kt(e,!!n,t,!0)):kt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}At(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(It(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[at]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[at])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ot(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=ct(e);t!==null&&t.tag===5&&t.type===`form`?gs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Tt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Tt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Tt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Tt(n.imageSizes)+`"]`)):i+=`[href="`+Tt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Tt(r)+`"][href="`+Tt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),lt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=J(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);lt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=J(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=J(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=re.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=J(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=J(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=J(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Tt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),lt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Tt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Tt(n.href)+`"]`);if(r)return t.instance=r,lt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),lt(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,lt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),lt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,lt(a),a):(r=n,(a=mf.get(o))&&(r=f({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),lt(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[at]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,lt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=We(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=We(0),this.hiddenUpdates=We(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=qr(3,null,null,t),e.current=a,a.stateNode=e,t=Ji(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Da(a),e}function tp(e){return e?(e=Gr,e):Gr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=ka(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Aa(e,r,t),n!==null&&(fu(n,e,t),ja(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Hr(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=K(t);var n=Hr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=ct(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ze(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Me(o);s.entanglements[1]|=c,o&=~c}td(a),!(jl&6)&&(Ql=be()+500,nd(0,!1))}}break;case 31:case 13:s=Hr(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Vt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=st(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(xe()){case Se:return 2;case Ce:return 8;case we:case Te:return 32;case Ee:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ct(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=st(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Bt=r,n.target.dispatchEvent(r),Bt=null}else return t=ct(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=ct(n);a!==null&&(e.splice(t,3),t-=3,ms(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.6`)throw Error(i(527,Lp,`19.2.6`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.6`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.6`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{ke=zp.inject(Rp),Ae=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ls,s=Rs,c=zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),y=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=v()})),b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},x=new class extends b{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},S={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},C=new class{#e=S;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function w(e){setTimeout(e,0)}var T=typeof window>`u`||`Deno`in globalThis;function E(){}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return typeof e==`number`&&e>=0&&e!==1/0}function k(e,t){return Math.max(e+(t||0)-Date.now(),0)}function A(e,t){return typeof e==`function`?e(t):e}function j(e,t){return typeof e==`function`?e(t):e}function M(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==N(o,t.options))return!1}else if(!P(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ee(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(te(t.options.mutationKey)!==te(a))return!1}else if(!P(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function N(e,t){return(t?.queryKeyHashFn||te)(e)}function te(e){return JSON.stringify(e,(e,t)=>z(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function P(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>P(e[n],t[n])):!1}var F=Object.prototype.hasOwnProperty;function I(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=R(e)&&R(t);if(!r&&!(z(e)&&z(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:F.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=I(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function L(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function R(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function z(e){if(!B(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!B(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function B(e){return Object.prototype.toString.call(e)===`[object Object]`}function V(e){return new Promise(t=>{C.setTimeout(t,e)})}function ne(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:I(e,t)}function H(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function re(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ie=Symbol();function ae(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ie?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function oe(e,t){return typeof e==`function`?e(...t):!!e}function se(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ce=(()=>{let e=()=>T;return{isServer(){return e()},setIsServer(t){e=t}}})();function U(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var le=w;function ue(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=le,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var de=ue(),fe=new class extends b{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function pe(e){return Math.min(1e3*2**e,3e4)}function me(e){return(e??`online`)===`online`?fe.isOnline():!0}var he=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ge(e){let t=!1,n=0,r,i=U(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new he(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>x.isFocused()&&(e.networkMode===`always`||fe.isOnline())&&e.canRun(),u=()=>me(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ce.isServer()?0:3),o=e.retryDelay??pe,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),V(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var _e=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),O(this.gcTime)&&(this.#e=C.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ce.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(C.clearTimeout(this.#e),this.#e=void 0)}};function ve(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{se(e,()=>t.signal,()=>n=!0)},u=ae(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?re:H;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?be:ye,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:ye(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ye(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function be(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function xe(e,t){return t?ye(e,t)!=null:!1}function Se(e,t){return!t||!e.getPreviousPageParam?!1:be(e,t)!=null}var Ce=class extends _e{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Ee(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ee(this.options);e.data!==void 0&&(this.setState(Te(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ne(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(E).catch(E):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>j(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ie||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>A(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!k(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ae(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ve(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=ge({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof he&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof he){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...we(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Te(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),de.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function we(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:me(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Te(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ee(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var De=class extends b{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=U(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ke(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ae(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ae(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof j(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!L(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&je(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||j(this.options.enabled,this.#t)!==j(t.enabled,this.#t)||A(this.options.staleTime,this.#t)!==A(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||j(this.options.enabled,this.#t)!==j(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ne(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(E)),t}#g(){this.#b();let e=A(this.options.staleTime,this.#t);if(ce.isServer()||this.#r.isStale||!O(e))return;let t=k(this.#r.dataUpdatedAt,e)+1;this.#d=C.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ce.isServer()||j(this.options.enabled,this.#t)===!1||!O(this.#p)||this.#p===0)&&(this.#f=C.setInterval(()=>{(this.options.refetchIntervalInBackground||x.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(C.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(C.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ke(e,t),o=i&&je(e,n,t,r);(a||o)&&(l={...l,...we(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ne(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ne(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Me(e,t),refetch:this.refetch,promise:this.#o,isEnabled:j(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=U())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!L(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){de.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Oe(e,t){return j(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&j(t.retryOnMount,e)===!1)}function ke(e,t){return Oe(e,t)||e.state.data!==void 0&&Ae(e,t,t.refetchOnMount)}function Ae(e,t,n){if(j(t.enabled,e)!==!1&&A(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Me(e,t)}return!1}function je(e,t,n,r){return(e!==t||j(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Me(e,n)}function Me(e,t){return j(t.enabled,e)!==!1&&e.isStaleByTime(A(t.staleTime,e))}function Ne(e,t){return!L(e.getCurrentResult(),t)}var Pe=class extends De{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(t,n.data),hasPreviousPage:Se(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Fe=class extends _e{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ie(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ge({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),de.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ie(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Le=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Fe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Re(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){de.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){return this.getAll().filter(t=>ee(e,t))}notify(e){de.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return de.batch(()=>Promise.all(e.map(e=>e.continue().catch(E))))}};function Re(e){return e.options.scope?.id}var ze=class extends b{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),L(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&te(t.mutationKey)!==te(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ie();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){de.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Be(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ve(e,t,n){let r=e.slice(0);return r[t]=n,r}var He=class extends b{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,de.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!L(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Be(e,n).forEach(e=>{e.destroy()}),Be(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=I(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new De(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ve(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&de.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Ue=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??N(r,t),a=this.get(i);return a||(a=new Ce({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){de.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>M(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>M(e,t)):t}notify(e){de.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){de.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){de.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},We=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ue,this.#t=e.mutationCache||new Le,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=x.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(A(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=D(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return de.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;de.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return de.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=de.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(E).catch(E)}invalidateQueries(e,t={}){return de.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=de.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(E)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(E)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(A(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(E).catch(E)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(E).catch(E)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(te(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{P(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(te(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{P(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=N(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ie&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ge=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ke=s(((e,t)=>{t.exports=Ge()})),W=u(p(),1),G=Ke(),qe=W.createContext(void 0),K=e=>{let t=W.useContext(qe);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Je=({client:e,children:t})=>(W.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,G.jsx)(qe.Provider,{value:e,children:t})),Ye=W.createContext(!1),Xe=()=>W.useContext(Ye);Ye.Provider;function Ze(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Qe=W.createContext(Ze()),$e=()=>W.useContext(Qe),et=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?oe(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},tt=e=>{W.useEffect(()=>{e.clearReset()},[e])},nt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||oe(n,[e.error,r])),rt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},it=(e,t)=>e.isLoading&&e.isFetching&&!t,at=(e,t)=>e?.suspense&&t.isPending,ot=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function st({queries:e,...t},n){let r=K(n),i=Xe(),a=$e(),o=W.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{rt(e),et(e,a,r.getQueryCache().get(e.queryHash))}),tt(a);let[s]=W.useState(()=>new He(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;W.useSyncExternalStore(W.useCallback(e=>d?s.subscribe(de.batchCalls(e)):E,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),W.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>at(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&at(n,e)?ot(n,new De(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&nt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function ct(e,t,n){let r=Xe(),i=$e(),a=K(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,rt(o),et(o,i,s),tt(i);let l=!a.getQueryCache().get(o.queryHash),[u]=W.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(W.useSyncExternalStore(W.useCallback(e=>{let t=f?u.subscribe(de.batchCalls(e)):E;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),W.useEffect(()=>{u.setOptions(o)},[o,u]),at(o,d))throw ot(o,u,i);if(nt({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ce.isServer()&&it(d,r)&&(l?ot(o,u,i):s?.promise)?.catch(E).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function q(e,t){return ct(e,De,t)}function J(e,t){let n=K(t),[r]=W.useState(()=>new ze(n,e));W.useEffect(()=>{r.setOptions(e)},[r,e]);let i=W.useSyncExternalStore(W.useCallback(e=>r.subscribe(de.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=W.useCallback((e,t)=>{r.mutate(e,t).catch(E)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function lt(e,t){return ct(e,Pe,t)}var ut=u(y(),1),dt=(typeof document<`u`?document.querySelector(`meta[name="recall-token"]`)?.getAttribute(`content`):null)??``;function ft(){return dt}function pt(e){let t=ft(),n={...e};return t&&(n[`x-recall-token`]=t),n}function mt(e){let t=ft();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}async function Y(e){let t=await fetch(e,{headers:pt()});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`${t.status} ${t.statusText}: ${e.slice(0,200)}`)}return await t.json()}async function X(e,t,n,r){let i=await fetch(t,{method:e,headers:pt(n===void 0?void 0:{"content-type":`application/json`}),body:n===void 0?void 0:JSON.stringify(n),signal:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`${i.status} ${i.statusText}: ${e.slice(0,200)}`)}return await i.json()}var Z={stats:()=>Y(`/api/stats`),health:()=>Y(`/api/health`),neighborhood:(e,t={})=>{let n=new URLSearchParams;t.budget&&n.set(`budget`,String(t.budget)),t.scoring&&n.set(`scoring`,t.scoring);let r=n.toString();return Y(`/api/neighborhood/${encodeURIComponent(e)}${r?`?${r}`:``}`)},projects:async(e=`folder`)=>{if(e===`folder`)return{mode:`folder`,projects:await Y(`/api/projects`)};let t=await Y(`/api/projects?groupBy=${encodeURIComponent(e)}`);return{mode:t.groupBy,groups:t.groups}},sessions:(e={})=>{let t=new URLSearchParams({limit:String(e.limit??100)});return e.projectName&&t.set(`project`,e.projectName),e.since&&t.set(`since`,e.since),e.until&&t.set(`until`,e.until),e.collectionId&&t.set(`collection`,e.collectionId),e.cursor&&t.set(`cursor`,e.cursor),Y(`/api/sessions?${t}`)},session:e=>Y(`/api/sessions/${encodeURIComponent(e)}`),graph:e=>Y(`/api/graph/${encodeURIComponent(e)}`),search:(e,t=40,n,r)=>{let i=new URLSearchParams({q:e,limit:String(t)});return n&&i.set(`project`,n),r&&i.set(`mode`,r),Y(`/api/search?${i}`)},allTags:()=>Y(`/api/tags`),sessionTags:e=>Y(`/api/sessions/${encodeURIComponent(e)}/tags`),addSessionTag:async(e,t)=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/tags`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({tag:t})});if(!n.ok)throw Error(`${n.status}: ${await n.text()}`);return await n.json()},removeSessionTag:async(e,t)=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/tags/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok)throw Error(`${n.status}: ${await n.text()}`);return await n.json()},shareStats:e=>Y(`/api/sessions/${encodeURIComponent(e)}/share-stats`),listCollections:(e=!1)=>{let t=new URLSearchParams;e&&t.set(`archived`,`1`);let n=t.toString();return Y(`/api/collections${n?`?${n}`:``}`)},getCollection:e=>Y(`/api/collections/${encodeURIComponent(e)}`),createCollection:e=>X(`POST`,`/api/collections`,e),patchCollection:(e,t)=>X(`PATCH`,`/api/collections/${encodeURIComponent(e)}`,t),archiveCollection:e=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/archive`),restoreCollection:e=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/restore`),addSessionToCollection:(e,t,n)=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/members`,{session_id:t,note:n??null}),removeSessionFromCollection:(e,t)=>X(`DELETE`,`/api/collections/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`),sessionCollections:e=>Y(`/api/sessions/${encodeURIComponent(e)}/collections`),getAutoTagConfig:()=>Y(`/api/config/auto-tag`),putAutoTagConfig:e=>X(`PUT`,`/api/config/auto-tag`,e),startScan:e=>X(`POST`,`/api/tags/scan`,{scope:e}),getScan:e=>Y(`/api/tags/scan/${encodeURIComponent(e)}`),applyScan:(e,t)=>X(`POST`,`/api/tags/scan/${encodeURIComponent(e)}/apply`,{selection:t}),cancelScan:e=>X(`DELETE`,`/api/tags/scan/${encodeURIComponent(e)}`),getMcpInstallStatus:()=>Y(`/api/config/mcp-install`),installMcp:()=>X(`POST`,`/api/config/mcp-install`),uninstallMcp:()=>X(`DELETE`,`/api/config/mcp-install`),getAutopilotStatus:()=>Y(`/api/autopilot/status`),kickAutopilot:()=>X(`POST`,`/api/autopilot/kick`),runClaudeCliScan:(e,t={})=>X(`POST`,`/api/tags/scan/claude-cli`,t.scanId?{scope:e,scanId:t.scanId}:{scope:e}),subscribeToScanProgress:e=>new EventSource(mt(`/api/claude-cli/scan/${encodeURIComponent(e)}/progress`)),listPrompts:()=>Y(`/api/prompts`),runPrompt:(e,t)=>X(`POST`,`/api/prompts/run`,{name:e,args:t}),getSemanticStatus:()=>Y(`/api/semantic/status`),setSemanticEnabled:e=>X(`PUT`,`/api/semantic/config`,{enabled:e}),triggerSemanticBackfill:(e=200)=>X(`POST`,`/api/semantic/backfill`,{limit:e}),reindexProjectVectors:(e,t=!1,n=0)=>X(`POST`,`/api/semantic/reindex-project`,{project:e,force:t,maxChunks:n}),getReindexPreview:e=>Y(`/api/semantic/reindex-preview?project=${encodeURIComponent(e)}`),getVectorStatus:e=>Y(e?`/api/semantic/vector-status?project=${encodeURIComponent(e)}`:`/api/semantic/vector-status`),installVectorModel:()=>X(`POST`,`/api/semantic/install`,{}),cancelReindex:(e,t)=>X(`POST`,`/api/semantic/cancel-reindex`,e?{project:e}:{},t),getSessionStats:e=>Y(`/api/stats/session/${encodeURIComponent(e)}`),getProjectStats:e=>Y(`/api/stats/project/${encodeURIComponent(e)}`),getOverviewStats:(e=`all`)=>Y(`/api/stats/overview?range=${e}`),triggerStatsBackfill:e=>X(`POST`,`/api/stats/backfill`,e?{limit:e}:{}),getOnboarding:()=>Y(`/api/onboarding`),patchOnboarding:e=>X(`PUT`,`/api/onboarding`,e),resetOnboarding:()=>X(`POST`,`/api/onboarding/reset`),getSessionCommits:e=>Y(`/api/sessions/${encodeURIComponent(e)}/commits`),refreshSessionCommits:e=>Y(`/api/sessions/${encodeURIComponent(e)}/commits?refresh=1`),getCommitSessions:e=>Y(`/api/commits/${encodeURIComponent(e)}/session`),getDiscoverToday:()=>Y(`/api/discover/today`),getAutoTitleConfig:()=>Y(`/api/config/auto-title`),putAutoTitleConfig:e=>X(`PUT`,`/api/config/auto-title`,e),generateAutoTitle:e=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/auto-title`),regenerateTitle:(e,t={})=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/regenerate-title`,t),revertAutoTitle:e=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/auto-title/revert`),listAutoRules:()=>Y(`/api/auto-collections/rules`),createAutoRule:e=>X(`POST`,`/api/auto-collections/rules`,e),patchAutoRule:(e,t)=>X(`PATCH`,`/api/auto-collections/rules/${encodeURIComponent(e)}`,t),deleteAutoRule:e=>X(`DELETE`,`/api/auto-collections/rules/${encodeURIComponent(e)}`),listAutoSuggestions:(e=!1)=>Y(`/api/auto-collections/suggestions${e?`?dismissed=1`:``}`),acceptAutoSuggestion:e=>X(`POST`,`/api/auto-collections/suggestions/${encodeURIComponent(e)}/accept`),dismissAutoSuggestion:e=>X(`POST`,`/api/auto-collections/suggestions/${encodeURIComponent(e)}/dismiss`),detectAutoSuggestionsNow:()=>X(`POST`,`/api/auto-collections/detect`),previewAutoSuggestion:(e,t=3)=>Y(`/api/auto-collections/suggestions/${encodeURIComponent(e)}/preview?limit=${t}`),listAutoCollectionIds:()=>Y(`/api/auto-collections/parents`),healthScores:()=>Y(`/api/stats/health`),healthScore:e=>Y(`/api/stats/health/${e}`),getVerificationConfig:()=>Y(`/api/config/verification`),setVerificationConfig:e=>X(`PUT`,`/api/config/verification`,{enabled:e}),getVerificationDetail:e=>Y(`/api/sessions/${encodeURIComponent(e)}/verification`),listThreads:(e=!1)=>Y(`/api/threads${e?`?archived=1`:``}`),getThread:e=>Y(`/api/threads/${encodeURIComponent(e)}`),createThread:e=>X(`POST`,`/api/threads`,e),patchThread:(e,t)=>X(`PATCH`,`/api/threads/${encodeURIComponent(e)}`,t),listThreadFolders:()=>Y(`/api/thread-folders`),createThreadFolder:e=>X(`POST`,`/api/thread-folders`,{name:e.name,parent_folder_id:e.parentFolderId??null,project_scope:e.projectScope??null}),patchThreadFolder:(e,t)=>X(`PATCH`,`/api/thread-folders/${encodeURIComponent(e)}`,t),deleteThreadFolder:e=>X(`DELETE`,`/api/thread-folders/${encodeURIComponent(e)}`),reorderThreadFolders:e=>X(`POST`,`/api/thread-folders/reorder`,{parent_folder_id:e.parentFolderId,project_scope:e.projectScope,ordered_ids:e.orderedIds}),addSessionToThread:(e,t)=>X(`POST`,`/api/threads/${encodeURIComponent(e)}/sessions`,t),removeSessionFromThread:(e,t)=>X(`DELETE`,`/api/threads/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`),setThreadSessionParent:(e,t,n)=>X(`PATCH`,`/api/threads/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`,{parentSessionId:n}),threadsForSession:e=>Y(`/api/sessions/${encodeURIComponent(e)}/threads`),threadTitlesPreflight:e=>Y(`/api/threads/${encodeURIComponent(e)}/titles/preflight`),startThreadTitlesJob:(e,t)=>X(`POST`,`/api/threads/${encodeURIComponent(e)}/titles/generate`,{force:t}),cancelJob:e=>X(`DELETE`,`/api/jobs/${encodeURIComponent(e)}`),listSuggestions:(e={})=>{let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.linkType&&t.set(`type`,e.linkType),e.inferredBy&&t.set(`inferred_by`,e.inferredBy),e.sourceSessionId&&t.set(`source_id`,e.sourceSessionId),e.targetSessionId&&t.set(`target_id`,e.targetSessionId),typeof e.limit==`number`&&t.set(`limit`,String(e.limit));let n=t.toString();return Y(n?`/api/links/suggestions?${n}`:`/api/links/suggestions`)},decideSuggestion:(e,t)=>X(`PATCH`,`/api/links/suggestions/${e}`,{status:t}),bulkDecideSuggestions:(e,t)=>X(`POST`,`/api/links/suggestions/bulk-decide`,{ids:e,status:t}),sessionLinks:e=>Y(`/api/sessions/${encodeURIComponent(e)}/links?type=wiki_link`),createWikiLink:(e,t,n={created_via:`context_menu`})=>X(`POST`,`/api/links`,{source_session_id:e,target_session_id:t,link_type:`wiki_link`,evidence:n}),removeLink:e=>X(`DELETE`,`/api/links/${e}`),listBugPatterns:(e={})=>{let t=new URLSearchParams;typeof e.minCount==`number`&&t.set(`min_count`,String(e.minCount)),e.status&&t.set(`status`,e.status),e.project&&t.set(`project`,e.project),typeof e.limit==`number`&&t.set(`limit`,String(e.limit)),typeof e.offset==`number`&&t.set(`offset`,String(e.offset));let n=t.toString();return Y(n?`/api/bug-patterns?${n}`:`/api/bug-patterns`)},getBugPattern:e=>Y(`/api/bug-patterns/${encodeURIComponent(e)}`),resolveBugPattern:(e,t,n)=>X(`POST`,`/api/bug-patterns/${encodeURIComponent(e)}/resolve`,{resolved_in_session_id:t,fix_summary:n}),splitBugPattern:(e,t)=>X(`POST`,`/api/bug-patterns/${encodeURIComponent(e)}/split`,{member_session_ids:t}),getBugPatternsSetupStatus:()=>Y(`/api/bug-patterns/setup-status`),bugSignatures:(e,t=100)=>{let n=new URLSearchParams;return e&&n.set(`project`,e),n.set(`limit`,String(t)),Y(`/api/bug-signatures?${n.toString()}`)},resolveBugSignature:(e,t)=>X(`POST`,`/api/bug-signatures/${encodeURIComponent(e)}/resolve`,t),unresolveBugSignature:e=>X(`POST`,`/api/bug-signatures/${encodeURIComponent(e)}/unresolve`),bugPatternsGraph:(e,t=!0)=>{let n=new URLSearchParams;e&&n.set(`project`,e),t||n.set(`include_resolved`,`0`);let r=n.toString();return Y(`/api/bug-patterns/graph${r?`?${r}`:``}`)},extractOutputsPreflight:e=>ht(`/api/extract-outputs/preflight`,e),extractOutputsRun:e=>ht(`/api/extract-outputs/run`,{preflight_token:e}),extractOutputsCancel:e=>gt(`/api/extract-outputs/jobs/${encodeURIComponent(e)}`),extractOutputsJobSnapshot:e=>Y(`/api/extract-outputs/jobs/${encodeURIComponent(e)}`),launcherBudget:()=>Y(`/api/extract-outputs/budget`),synthesizePreflight:e=>ht(`/api/bug-patterns/synthesize/preflight`,e),synthesizeRun:e=>ht(`/api/bug-patterns/synthesize/run`,{preflight_token:e}),synthesizeJobSnapshot:e=>Y(`/api/bug-patterns/synthesize/jobs/${encodeURIComponent(e)}`),synthesizeCancel:e=>gt(`/api/bug-patterns/synthesize/jobs/${encodeURIComponent(e)}`),threadScanPreflight:e=>ht(`/api/threads/scan/preflight`,e),threadScanApply:e=>ht(`/api/threads/scan/apply`,e),threadScanJobSnapshot:e=>Y(`/api/threads/scan/jobs/${encodeURIComponent(e)}`),threadScanCancel:e=>gt(`/api/threads/scan/jobs/${encodeURIComponent(e)}`),syncActivePreflight:e=>X(`POST`,`/api/threads/sync-active`,{...e,mode:`preflight`}),syncActiveApply:e=>X(`POST`,`/api/threads/sync-active`,{...e,mode:`apply`}),listMacroRepos:()=>Y(`/api/macro-repos`),createMacroRepo:e=>X(`POST`,`/api/macro-repos`,e),patchMacroRepo:(e,t)=>X(`PATCH`,`/api/macro-repos/${e}`,t),deleteMacroRepo:e=>X(`DELETE`,`/api/macro-repos/${e}`),addMacroRepoMember:(e,t)=>X(`POST`,`/api/macro-repos/${e}/members`,{project_id:t}),removeMacroRepoMember:(e,t)=>X(`DELETE`,`/api/macro-repos/${e}/members/${t}`),listBugSynthesisResults:e=>{let t=new URLSearchParams;e?.scope&&t.set(`scope`,e.scope),e?.target_id&&t.set(`target_id`,e.target_id),e?.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return Y(`/api/bug-synthesis${n?`?${n}`:``}`)},bugSynthesisCounts:e=>Y(`/api/bug-synthesis/counts?scope=${e}`),getBugSynthesisResult:e=>Y(`/api/bug-synthesis/${e}`),deleteBugSynthesisResult:e=>X(`DELETE`,`/api/bug-synthesis/${e}`)};async function ht(e,t){let n=await fetch(e,{method:`POST`,headers:pt({"content-type":`application/json`,"x-recall-launcher":`1`}),body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`${n.status} ${n.statusText}: ${e.slice(0,300)}`)}return await n.json()}async function gt(e){let t=await fetch(e,{method:`DELETE`,headers:pt({"x-recall-launcher":`1`})});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`${t.status} ${t.statusText}: ${e.slice(0,300)}`)}return await t.json()}function _t(e){return e?e.slice(0,8):``}function vt(e,t){if(!e)return``;let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:n.slice(0,t-1)+`…`}function yt(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);if(o<30)return`${o}d ago`;let s=Math.floor(o/30);return s<12?`${s}mo ago`:`${Math.floor(o/365)}y ago`}function bt(e){return e==null?`0`:e.toLocaleString()}function xt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function St(e){let t=e.split(/\s+/).filter(e=>e.length>1).map(xt);return t.length===0?null:RegExp(`(${t.join(`|`)})`,`gi`)}function Ct(){let[e,t]=(0,W.useState)(null),n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=new EventSource(mt(`/api/autopilot/events`));return n.current=e,e.addEventListener(`state`,e=>{try{t(JSON.parse(e.data))}catch(e){console.error(`autopilot state parse failed`,e)}}),e.onerror=()=>{},()=>e.close()},[]),e}function wt(){return q({queryKey:[`auto-tag-config`],queryFn:()=>Z.getAutoTagConfig()})}function Tt(){let e=K();return J({mutationFn:e=>Z.putAutoTagConfig(e),onSuccess:()=>void e.invalidateQueries({queryKey:[`auto-tag-config`]})})}function Et(){let e=wt(),t=Ct();return!e.data?.autopilot||!t||t.status===`idle`?null:t.status===`error`?(0,G.jsx)(`div`,{className:`text-[11px] px-2 py-1 rounded-full border border-role-user/40 bg-role-user/10 text-role-user`,title:t.lastError??`autopilot error`,children:`⚠ autopilot error`}):(0,G.jsxs)(`div`,{className:`text-[11px] px-2 py-1 rounded-full border border-accent/40 bg-accent/10 text-accent flex items-center gap-1.5`,title:`Autopilot is tagging untagged sessions in the background.`,children:[(0,G.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse`}),`tagging `,t.processed,`/`,t.total]})}var Dt=[{value:1,label:`bad`,emoji:`😡`},{value:2,label:`meh`,emoji:`😕`},{value:3,label:`ok`,emoji:`😐`},{value:4,label:`good`,emoji:`🙂`},{value:5,label:`great`,emoji:`🤩`}];function Ot(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(`idle`),[c,l]=(0,W.useState)(null);(0,W.useEffect)(()=>{function n(n){n.key===`Escape`&&e&&t(!1)}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]);function u(){r(null),a(``),s(`idle`),l(null)}async function d(){if(n!==null){s(`sending`),l(null);try{let e=await fetch(`/api/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,...pt()},body:JSON.stringify({score:n,comment:i.trim()||null,trigger_kind:`manual`})});if(e.ok){s(`sent`),setTimeout(()=>{t(!1),u()},1400);return}let r=await e.json().catch(()=>({}));e.status===429?l(r.detail??`You sent feedback recently. Try again later.`):l(r.detail??r.error??`Failed (${e.status})`),s(`error`)}catch(e){l(e instanceof Error?e.message:`network error`),s(`error`)}}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors text-accent border-accent/40 hover:bg-accent hover:text-bg hover:border-accent`,"aria-label":`Send feedback`,title:`Send feedback to the Claude Recall team`,children:`💬 Feedback`}),e&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center bg-black/40 p-4 backdrop-blur-sm sm:items-center`,onClick:()=>{t(!1),u()},children:(0,G.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl bg-white p-5 shadow-2xl dark:bg-neutral-900`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-start justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900 dark:text-neutral-100`,children:`Tell us how it's going`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-neutral-500 dark:text-neutral-400`,children:`Sent to the Claude Recall team. Pro users are attributed automatically.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{t(!1),u()},className:`text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200`,"aria-label":`Close`,children:`×`})]}),(0,G.jsx)(`div`,{className:`mb-3 flex justify-between gap-1`,children:Dt.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),className:`flex flex-1 flex-col items-center rounded-lg border px-2 py-2 text-xs transition ${n===e.value?`border-accent bg-accent/15 text-accent`:`border-line text-fg-dim hover:border-accent/60`}`,"aria-pressed":n===e.value,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,G.jsx)(`span`,{className:`mt-1`,children:e.label})]},e.value))}),(0,G.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),placeholder:n!==null&&n<=2?`What is the biggest pain point?`:`Anything you'd add? (optional)`,maxLength:2e3,rows:4,className:`w-full resize-none rounded-lg border border-line bg-bg-elevated px-3 py-2 text-sm text-fg placeholder-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),c&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:c}),o===`sent`&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-emerald-600 dark:text-emerald-400`,children:`Thanks. Your feedback landed.`}),(0,G.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-neutral-400`,children:[i.length,`/2000`]}),(0,G.jsx)(`button`,{type:`button`,onClick:d,disabled:n===null||o===`sending`||o===`sent`,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-bg shadow-sm hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50`,children:o===`sending`?`Sending…`:o===`sent`?`Sent`:`Send feedback`})]})]})})]})}function kt(){return q({queryKey:[`license-status`],queryFn:async()=>{let e=await fetch(`/api/license/status`,{headers:pt()});if(!e.ok)throw Error(`${e.status}: ${await e.text()}`);return await e.json()},staleTime:6e4})}function At(){return kt().data?.tier===`pro`}var jt=`https://clauderecall.com/pricing`;function Mt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Nt(){let{data:e,isLoading:t}=kt(),[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null);if((0,W.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&(i.current.contains(e.target)||r(!1))},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),t||!e)return null;if(e.tier===`pro`){let t=Mt(e.activated_at);return(0,G.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`text-[11px] font-bold tracking-wide px-2 py-0.5 rounded-md bg-accent text-bg hover:brightness-110 transition`,title:`Pro license active. Click for details.`,"aria-haspopup":`dialog`,"aria-expanded":n,children:[`PRO`,e.test_mode&&(0,G.jsx)(`span`,{className:`ml-1 font-medium opacity-80`,children:`· TEST`})]}),n&&(0,G.jsxs)(`div`,{role:`dialog`,className:`absolute right-0 top-full mt-2 w-72 z-50 rounded-lg border border-line bg-bg-elevated shadow-lg p-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-bold tracking-wide px-1.5 py-0.5 rounded bg-accent text-bg`,children:`PRO`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Lifetime`})]}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.key_short&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Key`}),(0,G.jsx)(`dd`,{className:`font-mono text-fg truncate`,children:e.key_short})]}),e.customer_email&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Email`}),(0,G.jsx)(`dd`,{className:`text-fg truncate`,children:e.customer_email})]}),t&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Activated`}),(0,G.jsx)(`dd`,{className:`text-fg`,children:t})]}),e.test_mode&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Mode`}),(0,G.jsx)(`dd`,{className:`text-accent`,children:`Test mode`})]})]})]})]})}return(0,G.jsxs)(`a`,{href:jt,target:`_blank`,rel:`noreferrer noopener`,className:`text-[11px] font-medium px-2 py-0.5 rounded-md border border-line text-fg-dim hover:text-fg hover:border-accent/60 transition`,title:`Free tier. Click to view Pro pricing.`,children:[`Free `,(0,G.jsx)(`span`,{className:`text-accent`,children:`· Upgrade`})]})}var Pt=new Set,Ft=[],It=1;function Lt(){for(let e of Pt)e([...Ft])}function Q(e){let t=e.id??`t-${It++}`,n={id:t,message:e.message,tone:e.tone??`info`,duration:e.duration??4e3,action:e.action};return Ft=[...Ft.filter(e=>e.id!==t),n],Lt(),n.duration>0&&setTimeout(()=>Rt(t),n.duration),t}function Rt(e){Ft=Ft.filter(t=>t.id!==e),Lt()}function zt(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>(Pt.add(t),()=>{Pt.delete(t)}),[]),e.length===0?null:(0,G.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2 items-end max-w-[calc(100vw-2rem)]`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`min-w-[260px] max-w-[420px] rounded-lg border shadow-lg px-3 py-2 text-xs flex items-start gap-3 ${e.tone===`error`?`bg-bg-elevated border-role-user/60 text-fg`:e.tone===`success`?`bg-bg-elevated border-accent/60 text-fg`:`bg-bg-elevated border-line text-fg`}`,children:[(0,G.jsx)(`div`,{className:`flex-1 break-words`,children:e.message}),e.action&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{e.action.onClick(),Rt(e.id)},className:`text-accent hover:underline whitespace-nowrap`,children:e.action.label}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Rt(e.id),className:`text-fg-muted hover:text-fg leading-none`,title:`dismiss`,children:`×`})]},e.id))})}var Bt=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20width='64'%20height='64'%20role='img'%20aria-label='Claude%20Recall'%3e%3ctitle%3eClaude%20Recall%20—%20Scrollback%20mark%20(dark%20bg)%3c/title%3e%3cg%20stroke='%23e7e9ee'%20stroke-width='3'%20stroke-linecap='round'%20fill='none'%3e%3cline%20x1='14'%20y1='16'%20x2='46'%20y2='16'/%3e%3cline%20x1='14'%20y1='24'%20x2='38'%20y2='24'/%3e%3c/g%3e%3cline%20x1='10'%20y1='32'%20x2='54'%20y2='32'%20stroke='%23f97316'%20stroke-width='5'%20stroke-linecap='round'/%3e%3cg%20stroke='%23e7e9ee'%20stroke-width='3'%20stroke-linecap='round'%20fill='none'%3e%3cline%20x1='14'%20y1='40'%20x2='42'%20y2='40'/%3e%3cline%20x1='14'%20y1='48'%20x2='36'%20y2='48'/%3e%3c/g%3e%3c/svg%3e`;function Vt({query:e,onQueryChange:t,matchCount:n,scope:r,onScopeChange:i,canScope:a,projectName:o,onOpenHelp:s,helpActive:c,onOpenStats:l,statsActive:u,onOpenThreads:d,threadsActive:f,onOpenGraph:p,graphActive:m,onOpenSuggestions:h,suggestionsActive:g,onOpenPatterns:_,patternsActive:v,onOpenShare:y,onGoHome:b,semanticMode:x,onSemanticModeChange:S,semanticAvailable:C}){let w=q({queryKey:[`stats`],queryFn:Z.stats,refetchInterval:3e4,refetchIntervalInBackground:!1,staleTime:1e4}).data,T=K(),[E,D]=(0,W.useState)(!1),O=async()=>{if(!E){D(!0);try{await T.invalidateQueries(),await T.refetchQueries({type:`active`}),Q({message:`Refreshed all data from the daemon`,tone:`success`,duration:1500})}catch(e){Q({message:`Refresh failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{D(!1)}}};return(0,G.jsxs)(`header`,{className:`flex items-center gap-5 px-5 py-3 border-b border-line bg-bg shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:b,className:`flex items-center gap-2.5 text-left hover:opacity-80 transition-opacity`,title:`Home — back to project list`,"aria-label":`Go to home`,children:[(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-9 w-9 rounded-md shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-base font-bold leading-none flex items-center gap-2`,children:(0,G.jsxs)(`span`,{children:[`Claude `,(0,G.jsx)(`span`,{className:`text-accent`,children:`Recall`})]})}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:`local · offline · yours`})]})]}),(0,G.jsx)(Nt,{}),(0,G.jsx)(Ht,{})]}),w&&(0,G.jsxs)(`div`,{className:`hidden md:flex items-center gap-5 text-xs text-fg-dim`,children:[(0,G.jsxs)(`div`,{title:`${bt(w.projects)} distinct cwds across ${bt(w.repos)} repos`,children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.repos)}),` repos`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.sessions)}),` sessions`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.messages)}),` messages`]})]}),(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-end gap-3`,children:[a&&e&&(0,G.jsxs)(`div`,{className:`flex items-center text-xs border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(`all`),className:`px-3 py-1.5 transition-colors `+(r===`all`?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),children:`All projects`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(`project`),className:`px-3 py-1.5 transition-colors border-l border-line `+(r===`project`?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),title:o?`search only within ${o}`:void 0,children:[`In `,o??`project`]})]}),(0,G.jsxs)(`div`,{className:`relative w-full max-w-xl`,children:[(0,G.jsx)(`input`,{type:`search`,placeholder:`Search every session…`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-bg-elevated border border-line rounded-lg pl-10 pr-14 py-2 text-sm focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent placeholder:text-fg-muted`}),(0,G.jsxs)(`svg`,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-fg-muted`,fill:`none`,stroke:`currentColor`,strokeWidth:2,viewBox:`0 0 24 24`,children:[(0,G.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,G.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),!e&&(0,G.jsx)(`kbd`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-[10px] font-mono text-fg-muted border border-line rounded px-1.5 py-0.5`,children:`/`}),e&&n!=null&&(0,G.jsxs)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-fg-muted`,children:[n,` `,n===1?`match`:`matches`]})]}),C&&S&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>S(!x),className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(x?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Toggle semantic search — also matches sessions by AI-generated summary + keywords (v0.11)`,children:`Semantic`}),(0,G.jsx)(Et,{}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:E,className:`text-fg-muted hover:text-fg text-xs px-2 py-1 border border-line rounded-md disabled:opacity-60 disabled:cursor-wait`,title:`refresh all data from the daemon`,children:(0,G.jsx)(`span`,{className:`inline-block `+(E?`animate-spin`:`transition-transform`),"aria-hidden":`true`,children:`↻`})}),(0,G.jsx)(`button`,{type:`button`,onClick:d,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(f?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Threads — group sessions by intent (planning + children)`,children:`🧵 Threads`}),(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(m?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Cognitive Graph — Galaxy + Focus views over project sessions (v0.17)`,children:`🌌 Graph`}),h&&(0,G.jsx)(`button`,{type:`button`,onClick:h,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(g?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Suggestions Queue — review citation/skill/wiki suggestions inferred by L1–L4 (v0.18 Phase F)`,children:`📋 Queue`}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:_,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(v?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Bug Patterns — recurring bugs across sessions, with linked fixes (v0.20 Phase H)`,children:`🐛 Patterns`}),(0,G.jsx)(`button`,{type:`button`,onClick:l,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(u?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Cost & token dashboard (v0.10a)`,children:`📊 Stats`}),(0,G.jsx)(Ot,{}),y&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors text-fg-dim hover:text-fg border-line hover:border-accent/60`,title:`Share — pick what to share (Stats, Thread, Patterns, Session)`,children:`↗ Share`}),(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(c?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`open Command Center — docs, CLI reference, keyboard shortcuts (press ?)`,children:`Help`})]})]})}function Ht(){let{data:e}=q({queryKey:[`health`],queryFn:()=>Z.health(),staleTime:300*1e3});return e?.version?(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-fg-muted border border-line rounded px-1.5 py-0.5 leading-none`,title:`Claude Recall daemon version`,children:[`v`,e.version]}):null}function Ut(){return q({queryKey:[`auto-title-config`],queryFn:()=>Z.getAutoTitleConfig()})}function Wt(){let e=K();return J({mutationFn:e=>Z.putAutoTitleConfig(e),onSuccess:()=>void e.invalidateQueries({queryKey:[`auto-title-config`]})})}var Gt=`claude-recall:dismissed-autotitle-banner-v1`;function Kt(){try{return window.localStorage.getItem(Gt)===`true`}catch{return!1}}function qt(){let{data:e,isLoading:t}=Ut(),[n,r]=(0,W.useState)(Kt),[i,a]=(0,W.useState)(!1);if(t||!e||e.agentEnabled!==!1||n)return null;let o=()=>{r(!0);try{window.localStorage.setItem(Gt,`true`)}catch{}},s=async()=>{try{await navigator.clipboard.writeText(`recall semantic verify-spawn`),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}};return(0,G.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 px-5 py-2.5 bg-bg-elevated border-b border-line text-xs`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-sm leading-none mt-0.5`,children:`🔇`}),(0,G.jsxs)(`div`,{className:`flex-1 leading-relaxed`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`Agent titles paused.`}),` `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`New sessions get heuristic titles only. Run`}),` `,(0,G.jsx)(`button`,{type:`button`,onClick:()=>void s(),className:`font-mono text-[11px] px-1.5 py-0.5 bg-bg border border-line rounded hover:border-accent hover:text-accent transition-colors align-baseline`,title:i?`copied`:`click to copy`,children:`recall semantic verify-spawn`}),i&&(0,G.jsx)(`span`,{className:`text-accent text-[11px] ml-1`,children:`✓ copied`}),` `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`in your terminal first, then re-enable in`}),` `,(0,G.jsx)(`code`,{className:`text-[11px] text-fg`,children:`~/.recall/config.json`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-fg-muted hover:text-fg shrink-0 leading-none px-1`,"aria-label":`dismiss`,title:`dismiss`,children:`✕`})]})}var Jt=[{kind:`stats`,emoji:`📊`,name:`Stats`,blurb:`Activity for a time range — cost, top model, top project, sessions.`,status:`live`},{kind:`thread`,emoji:`🧵`,name:`Thread`,blurb:`Multi-session story — N sessions, total cost, project, span.`,status:`live`},{kind:`patterns`,emoji:`🐛`,name:`Patterns`,blurb:`Recurring bug clusters — top 3 by occurrence, resolved rate.`,status:`live`},{kind:`graph`,emoji:`🌐`,name:`Cog-graph`,blurb:`Snapshot of your skill / topic graph. Only Claude Recall has this.`,status:`soon`},{kind:`session`,emoji:`🖥️`,name:`Session`,blurb:`One-session receipt — prompt, cost, files, model.`,status:`live`}];function Yt({onPick:e,onClose:t}){return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[600px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mb-4`,children:`Pick what to share. Each option produces a downloadable card with your handle and the Claude Recall mark.`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:Jt.map(t=>{let n=t.status!==`live`;return(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>e(t.kind),className:`flex items-start gap-3 text-left p-3 rounded border transition-colors `+(n?`border-line bg-bg/40 opacity-55 cursor-not-allowed`:`border-line hover:border-accent hover:bg-accent/5`),children:[(0,G.jsx)(`span`,{className:`text-2xl leading-none mt-0.5`,children:t.emoji}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.name}),n&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-fg-muted border border-line rounded px-1 py-0.5`,children:`coming soon`})]}),(0,G.jsx)(`span`,{className:`block text-xs text-fg-muted mt-0.5`,children:t.blurb})]})]},t.kind)})})]})})}async function Xt(e){let t=new File([e.blob],e.fileName,{type:`image/png`}),n=navigator;if(typeof navigator.share==`function`&&n.canShare?.({files:[t]}))try{return await navigator.share({title:e.title,text:e.text,url:e.url,files:[t]}),`shared`}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return`cancelled`}if(typeof URL.createObjectURL==`function`){let t=URL.createObjectURL(e.blob),n=document.createElement(`a`);return n.href=t,n.download=e.fileName,n.click(),URL.revokeObjectURL(t),`download`}return`unsupported`}function Zt(){return typeof navigator.share==`function`}function Qt(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}async function $t(e){try{let t=window.ClipboardItem;if(!t||!navigator.clipboard?.write)return!1;let n=new t({"image/png":e});return await navigator.clipboard.write([n]),!0}catch{return!1}}var en=`https://clauderecall.com`;function tn(){return typeof window<`u`&&window.RECALL_SHARE_API?window.RECALL_SHARE_API.replace(/\/+$/,``):en}async function nn(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`blob → base64 failed`)),r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`unexpected reader result`));return}let i=e.indexOf(`,`);t(i>=0?e.slice(i+1):e)},r.readAsDataURL(e)})}async function rn(e){let t=await nn(e.blob),n=await fetch(`${tn()}/api/cards`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,title:e.title,description:e.description,width:e.width??1080,height:e.height??1350,pngBase64:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`upload failed (${n.status}): ${e||n.statusText}`)}let r=await n.json();return{id:r.id,url:r.url,imageUrl:r.image_url,expiresAt:r.expires_at}}function an(e,t,n){let r=encodeURIComponent(t),i=encodeURIComponent(n);switch(e){case`x`:return`https://twitter.com/intent/tweet?text=${i}&url=${r}`;case`linkedin`:return`https://www.linkedin.com/sharing/share-offsite/?url=${r}`;case`reddit`:return`https://www.reddit.com/submit?url=${r}&title=${i}`;case`facebook`:return`https://www.facebook.com/sharer/sharer.php?u=${r}`;case`threads`:return`https://www.threads.net/intent/post?text=${i}%20${r}`;case`whatsapp`:return`https://wa.me/?text=${i}%20${r}`}}var on=[{key:`x`,label:`X`,emoji:`𝕏`},{key:`linkedin`,label:`LinkedIn`,emoji:`in`},{key:`reddit`,label:`Reddit`,emoji:`r/`},{key:`facebook`,label:`Facebook`,emoji:`f`},{key:`threads`,label:`Threads`,emoji:`@`},{key:`whatsapp`,label:`WhatsApp`,emoji:`✉`}];function sn({getBlob:e,kind:t,title:n,description:r,caption:i,disabled:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useCallback)(async()=>{if(!o){s(!0);try{let i=await e();if(!i){Q({message:`Card not ready yet — wait for the preview.`,tone:`error`});return}let a=await rn({kind:t,title:n,description:r,blob:i});l(a);try{await navigator.clipboard.writeText(a.url),Q({message:`Link copied — preview ready on social platforms`,tone:`success`})}catch{Q({message:`Link ready (clipboard not available)`,tone:`info`})}}catch(e){console.error(`[SocialShareRow] upload failed:`,e),Q({message:`Could not create shareable link: `+(e instanceof Error?e.message:`unknown error`),tone:`error`})}finally{s(!1)}}},[e,t,n,r,o]),d=(0,W.useCallback)(async()=>{if(c)try{await navigator.clipboard.writeText(c.url),Q({message:`Link copied`,tone:`success`})}catch{Q({message:`Clipboard not available`,tone:`error`})}},[c]);return c?(0,G.jsxs)(`div`,{className:`mt-3 border border-line rounded p-3 bg-bg/40 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`shareable link`}),(0,G.jsxs)(`span`,{className:`ml-auto text-fg-dim normal-case tracking-normal`,children:[`expires `,new Date(c.expiresAt).toLocaleDateString(`en-US`)]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void d(),className:`w-full text-left text-xs text-accent font-mono break-all hover:underline`,title:`Click to copy`,children:c.url}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-2 pt-2`,children:on.map(e=>(0,G.jsxs)(`a`,{href:an(e.key,c.url,i),target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-1.5 px-2 py-2 rounded border border-line text-fg-muted text-xs font-medium hover:text-fg hover:border-accent/60 transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm leading-none`,children:e.emoji}),(0,G.jsx)(`span`,{children:e.label})]},e.key))}),(0,G.jsx)(`p`,{className:`text-[10px] text-fg-muted pt-1`,children:`TikTok and Instagram have no web share intent — use Save image and upload manually there.`})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:a||o,className:`w-full px-4 py-2 mt-3 rounded border border-line text-fg-muted text-xs font-medium hover:text-fg hover:border-accent/60 transition-colors disabled:opacity-50`,title:`Upload the card and get a public link with Open Graph preview`,children:o?`Generating link…`:`🔗 Get shareable link (with social preview)`})}var cn=`modulepreload`,ln=function(e,t){return new URL(e,t).href},un={},dn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ln(t,n),t in un)return;un[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:cn,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fn=[{key:`7d`,label:`Last 7 days`},{key:`30d`,label:`Last 30 days`},{key:`all`,label:`All time`}],pn=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function mn(e){return e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).trim().slice(0,120)}function hn(e){if(!e)return``;let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function gn(e){return e===`7d`?`Last 7 days`:e===`30d`?`Last 30 days`:`All time`}function _n({initialRange:e=`30d`,onClose:t}){let[n,r]=(0,W.useState)(e),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!0),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(),f=q({queryKey:[`stats-overview`,n],queryFn:()=>Z.getOverviewStats(n),staleTime:6e4}),p=(0,W.useMemo)(()=>{let e=f.data,t=e?.display?.dollars??`$—`,r=e?.totalSessions??0,a=(e?.inputTokens??0)+(e?.outputTokens??0),o=e?.cacheReadTokens??0,s=e?.byModel?.[0]?.modelLabel??null,c=null;if(e?.topRepos&&e.topRepos.length>0){let t=e.topRepos.reduce((e,t)=>e+(t.cost?.cents??0),0)||1,n=e.topRepos[0],r=hn(n.project);c=pn.some(e=>e.test(r))?null:{name:r||`unknown`,sharePct:Math.round((n.cost?.cents??0)/t*100)}}let l=(e?.daily??[]).filter(e=>e.tokens>0).length;return{rangeLabel:gn(n),scopeLabel:`All projects`,costDollars:t,totalSessions:r,workingTokens:a,cachedTokens:o,topModel:s,topProject:c,peakHours:null,activeDays:l,verdict:mn(i)}},[f.data,n,i]),m=(0,W.useCallback)(async()=>{s(!0),l(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-Zvhj1IwK.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./stats-Db9NRYik.js`),__vite__mapDeps([0,1]),import.meta.url),[n,r,i,a]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),o=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:a,weight:700,style:`normal`}],c=await e(t.render(p),{width:1080,height:1350,fonts:o}),d=u.current;if(!d)return;d.width=1080,d.height=1350;let f=d.getContext(`2d`);if(!f)return;let m=new Image;m.onload=()=>{f.drawImage(m,0,0),s(!1)},m.onerror=()=>{l(`Failed to render card image`),s(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(c)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareWrappedModal] renderPreview failed:`,e),l(t),s(!1)}},[p]);(0,W.useEffect)(()=>(clearTimeout(d.current),d.current=setTimeout(m,300),()=>clearTimeout(d.current)),[m]);let h=`claude-recall-stats-${n}.png`,g=(0,W.useCallback)(e=>{let t=u.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),_=(0,W.useCallback)(()=>new Promise(e=>{let t=u.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),v=(0,W.useCallback)(()=>{g(async e=>{let t=await Xt({fileName:h,blob:e,title:`Claude Recall — stats`,text:`My Claude Code stats — ${gn(n)} via Claude Recall`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[g,h,n]),y=(0,W.useCallback)(()=>{g(e=>{Qt(e,h),Q({message:`Saved to Downloads`,tone:`success`})})},[g,h]),b=(0,W.useCallback)(()=>{g(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[g]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Stats`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:u,className:`w-full h-full`,style:{display:o||c?`none`:`block`}}),o&&!c&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),c&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:c})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`range`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:fn.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),className:`text-xs px-2 py-1.5 rounded border transition-colors `+(n===e.key?`border-accent bg-accent/10 text-accent font-semibold`:`border-line text-fg-muted hover:text-fg`),children:e.label},e.key))})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:o,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:o,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:o,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:_,kind:`stats`,title:`Claude Code stats — ${gn(n)}`,description:`${p.costDollars} on ${p.totalSessions.toLocaleString(`en-US`)} sessions in ${p.scopeLabel.toLowerCase()}.`,caption:`My Claude Code stats — ${p.costDollars} via Claude Recall`,disabled:o})]})})}var vn=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function yn(e){if(!e)return``;let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function bn(e,t=80){if(!e)return null;let n=e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).trim();if(!n||vn.some(e=>e.test(n)))return null;let r=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).replace(/\s+/g,` `).trim();return r?r.length<=t?r:r.slice(0,t-1).trimEnd()+`…`:null}function xn(e){for(let t of[e.alias,e.auto_title,e.first_user_message]){let e=bn(t,70);if(e)return e}return e.session_id.slice(0,8)}function Sn({threadId:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(!0),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(),u=q({queryKey:[`thread-detail`,e],queryFn:()=>Z.getThread(e),staleTime:3e4}),d=st({queries:(0,W.useMemo)(()=>(u.data?.thread?.edges??[]).slice(0,24).map(e=>e.session_id),[u.data]).map(e=>({queryKey:[`session-stats`,e],queryFn:()=>Z.getSessionStats(e),staleTime:6e4}))}).reduce((e,t)=>e+(t.data?.cost?.cents??0),0),f=d>0?`$${(d/100).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:null,p=(0,W.useMemo)(()=>{let e=u.data?.thread,t=e?.edges??[],r=new Set,i=[];for(let e of t)r.has(e.session_id)||(r.add(e.session_id),i.push({id:e.session_id,title:xn(e),project:e.project?yn(e.project):null}));let a=t.filter(e=>!!e.parent_session_id).map(e=>({childId:e.session_id,parentId:e.parent_session_id})),o=t.filter(e=>e.role===`origin`||!e.parent_session_id).map(e=>e.session_id),s=bn(e?.name)??`Untitled thread`,c=e?.session_count??i.length,l=[`${c.toLocaleString(`en-US`)} ${c===1?`session`:`sessions`}`];return f&&l.push(f),(e?.project_count??0)>1?l.push(`cross-project`):e?.project&&l.push(yn(e.project)),{threadName:s,metaLine:l.join(` · `),sessions:i,edges:a,rootIds:o,verdict:bn(n,120)??``}},[u.data,f,n]),m=(0,W.useCallback)(async()=>{a(!0),s(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-Zvhj1IwK.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./thread-4KmPh02n.js`),__vite__mapDeps([2,1]),import.meta.url),[n,r,i,o]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),l=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:o,weight:700,style:`normal`}],u=await e(t.render(p),{width:1080,height:1350,fonts:l}),d=c.current;if(!d)return;d.width=1080*2,d.height=1350*2;let f=d.getContext(`2d`);if(!f)return;f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`;let m=new Image;m.onload=()=>{f.drawImage(m,0,0,d.width,d.height),a(!1)},m.onerror=()=>{s(`Failed to render card image`),a(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(u)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareThreadModal] renderPreview failed:`,e),s(t),a(!1)}},[p]);(0,W.useEffect)(()=>(clearTimeout(l.current),l.current=setTimeout(m,300),()=>clearTimeout(l.current)),[m]);let h=`claude-recall-thread-${e.slice(0,8)}.png`,g=(0,W.useCallback)(e=>{let t=c.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),_=(0,W.useCallback)(()=>new Promise(e=>{let t=c.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),v=(0,W.useCallback)(()=>{g(async e=>{let t=await Xt({fileName:h,blob:e,title:`Claude Recall — thread`,text:`${p.threadName} · ${p.metaLine}`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[g,h,p.threadName,p.metaLine]),y=(0,W.useCallback)(()=>{g(e=>{Qt(e,h),Q({message:`Saved to Downloads`,tone:`success`})})},[g,h]),b=(0,W.useCallback)(()=>{g(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[g]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Thread`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:c,className:`w-full h-full`,style:{display:i||o?`none`:`block`}}),i&&!o&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),o&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:o})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:i,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:i,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:i,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:_,kind:`thread`,title:p.threadName,description:p.metaLine,caption:`${p.threadName} — built with Claude Recall`,disabled:i})]})})}function Cn({heroImage:e,scopeLabel:t,onClose:n}){let[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(),d=q({queryKey:[`bug-patterns-graph`,`share`],queryFn:()=>Z.bugPatternsGraph(void 0,!0),staleTime:6e4}),f=(0,W.useMemo)(()=>{let n=d.data?.totals,i=n?.recurring_count??d.data?.clusters?.length??0,a=n?.resolved_count??0,o=n?.session_count??0,s=e=>e.toLocaleString(`en-US`),c=[t];return c.push(`${s(i)} ${i===1?`pattern`:`patterns`}`),a>0&&c.push(`${s(a)} resolved`),o>0&&c.push(`${s(o)} ${o===1?`session`:`sessions`}`),{heroImage:e,metaLine:c.join(` · `),verdict:r.slice(0,120)}},[d.data,e,r,t]),p=(0,W.useCallback)(async()=>{o(!0),c(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-Zvhj1IwK.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./patterns-Dsv_eCME.js`),__vite__mapDeps([3,1]),import.meta.url),[n,r,i,a]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),s=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:a,weight:700,style:`normal`}],u=await e(t.render(f),{width:1080,height:1350,fonts:s}),d=l.current;if(!d)return;d.width=1080*2,d.height=1350*2;let p=d.getContext(`2d`);if(!p)return;p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`;let m=new Image;m.onload=()=>{p.drawImage(m,0,0,d.width,d.height),o(!1)},m.onerror=()=>{c(`Failed to render card image`),o(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(u)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[SharePatternsModal] renderPreview failed:`,e),c(t),o(!1)}},[f]);(0,W.useEffect)(()=>(clearTimeout(u.current),u.current=setTimeout(p,300),()=>clearTimeout(u.current)),[p]);let m=`claude-recall-patterns.png`,h=(0,W.useCallback)(e=>{let t=l.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),g=(0,W.useCallback)(()=>new Promise(e=>{let t=l.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),_=(0,W.useCallback)(()=>{h(async e=>{let t=await Xt({fileName:m,blob:e,title:`Claude Recall — patterns`,text:f.metaLine,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[h,f.metaLine]),v=(0,W.useCallback)(()=>{h(e=>{Qt(e,m),Q({message:`Saved to Downloads`,tone:`success`})})},[h]),y=(0,W.useCallback)(()=>{h(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[h]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Patterns`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:l,className:`w-full h-full`,style:{display:a||s?`none`:`block`}}),a&&!s&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),s&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:s})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:_,disabled:a,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:a,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:a,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:g,kind:`patterns`,title:`Recurring patterns`,description:f.metaLine,caption:`${f.metaLine} — tracked with Claude Recall`,disabled:a})]})})}function wn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=wn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function $(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=wn(e))&&(r&&(r+=` `),r+=t);return r}function Tn(){return q({queryKey:[`tags`],queryFn:Z.allTags,staleTime:1e4})}function En(e){e.invalidateQueries({queryKey:[`tags`]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`search`]})}function Dn(){let e=K();return J({mutationFn:({sessionId:e,tag:t})=>Z.addSessionTag(e,t),onSuccess:()=>En(e)})}function On(){let e=K();return J({mutationFn:({sessionId:e,tag:t})=>Z.removeSessionTag(e,t),onSuccess:()=>En(e)})}var kn=new Set;function An(){for(let e of kn)e()}function jn(){let e=window.location.hash.replace(/^#/,``);if(!e)return{project:null,session:null,msg:null,q:``,view:null,helpSection:null,compareWith:null,col:null,thread:null};let t=new URLSearchParams(e),n=t.get(`view`);return{project:t.get(`p`),session:t.get(`s`),msg:t.get(`m`),q:t.get(`q`)??``,view:n===`help`?`help`:n===`stats`?`stats`:n===`auto-rules`?`auto-rules`:n===`threads`?`threads`:n===`graph`?`graph`:n===`suggestions`?`suggestions`:n===`patterns`?`patterns`:null,helpSection:t.get(`h`),compareWith:t.get(`cmp`),col:t.get(`col`),thread:t.get(`t`)}}function Mn(e){let t=new URLSearchParams;e.project&&t.set(`p`,e.project),e.session&&t.set(`s`,e.session),e.msg&&t.set(`m`,e.msg),e.q&&t.set(`q`,e.q),e.view&&t.set(`view`,e.view),e.helpSection&&t.set(`h`,e.helpSection),e.compareWith&&t.set(`cmp`,e.compareWith),e.col&&t.set(`col`,e.col),e.thread&&t.set(`t`,e.thread);let n=t.toString();return n?`#${n}`:``}function Nn(){let[e,t]=(0,W.useState)(jn);return(0,W.useEffect)(()=>{let e=()=>t(jn());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,W.useEffect)(()=>{let e=()=>t(jn());return kn.add(e),()=>{kn.delete(e)}},[]),[e,(0,W.useCallback)(e=>{let n={...jn(),...e},r=Mn(n);window.location.hash!==r&&window.history.replaceState(null,``,r||window.location.pathname),t(n),An()},[])]}function Pn(e,t,n){return Math.max(t,Math.min(n,e))}function Fn(e,t){try{let n=localStorage.getItem(e);if(n==null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}}function In(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}var Ln=new Map;function Rn(e){Ln.get(e)?.forEach(e=>e())}function zn(e){let t=e.minWidth??240,n=e.maxWidth??640,r=e.collapsedWidth??36,i=`${e.storageKey}:width`,a=`${e.storageKey}:collapsed`,[o,s]=(0,W.useState)(()=>Pn(Fn(i,e.defaultWidth),t,n)),[c,l]=(0,W.useState)(()=>In(a));(0,W.useEffect)(()=>{let r=Ln.get(e.storageKey);r||(r=new Set,Ln.set(e.storageKey,r));let o=()=>{s(Pn(Fn(i,e.defaultWidth),t,n)),l(In(a))};return r.add(o),()=>{r?.delete(o)}},[e.storageKey,i,a,e.defaultWidth,t,n]),(0,W.useEffect)(()=>{let t=t=>{(t.key===i||t.key===a)&&Rn(e.storageKey)};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[i,a,e.storageKey]);let u=(0,W.useCallback)(r=>{let a=Pn(r,t,n);s(a);try{localStorage.setItem(i,String(a))}catch{}Rn(e.storageKey)},[t,n,i,e.storageKey]),d=(0,W.useCallback)(t=>{l(t);try{localStorage.setItem(a,t?`1`:`0`)}catch{}Rn(e.storageKey)},[a,e.storageKey]),f=(0,W.useCallback)((e,t)=>{let n=n=>{u(t+(n.clientX-e))},r=()=>{window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[u]),p=(0,W.useCallback)(()=>{d(!c)},[d,c]);return{width:o,effectiveWidth:c?r:o,collapsed:c,minWidth:t,maxWidth:n,collapsedWidth:r,setWidth:u,setCollapsed:d,toggleCollapsed:p,beginResize:f}}function Bn(e){e.invalidateQueries({queryKey:[`collections`]}),e.invalidateQueries({queryKey:[`collection`]}),e.invalidateQueries({queryKey:[`sessionCollections`]}),e.invalidateQueries({queryKey:[`sessions`]})}function Vn(e=!1){return q({queryKey:[`collections`,{archived:e}],queryFn:()=>Z.listCollections(e),staleTime:5e3})}function Hn(e){return q({queryKey:[`collection`,e],queryFn:()=>Z.getCollection(e),enabled:!!e,staleTime:3e3})}function Un(e){return q({queryKey:[`sessionCollections`,e],queryFn:()=>Z.sessionCollections(e),enabled:!!e,staleTime:3e3})}function Wn(){let e=K();return J({mutationFn:e=>Z.createCollection(e),onSuccess:()=>Bn(e)})}function Gn(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchCollection(e,t),onSuccess:()=>Bn(e)})}function Kn(){let e=K();return J({mutationFn:e=>Z.archiveCollection(e),onSuccess:()=>Bn(e)})}function qn(){let e=K();return J({mutationFn:e=>Z.restoreCollection(e),onSuccess:()=>Bn(e)})}function Jn(){let e=K();return J({mutationFn:({collectionId:e,sessionId:t,note:n})=>Z.addSessionToCollection(e,t,n),onSuccess:()=>Bn(e)})}function Yn(){let e=K();return J({mutationFn:({collectionId:e,sessionId:t})=>Z.removeSessionFromCollection(e,t),onSuccess:()=>Bn(e)})}function Xn(e){if(!e||e.length===0)return[];let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0,total_session_count:n.session_count});let n=[];for(let e of t.values()){let r=e.parent_id?t.get(e.parent_id):null;r?r.children.push(e):n.push(e)}let r=(e,t)=>{e.sort((e,t)=>e.sort_key===t.sort_key?e.name.toLowerCase().localeCompare(t.name.toLowerCase()):e.sort_key.localeCompare(t.sort_key));for(let n of e)n.depth=t,r(n.children,t+1)};r(n,0);let i=e=>{let t=e.session_count;for(let n of e.children)t+=i(n);return e.total_session_count=t,t};for(let e of n)i(e);return n}function Zn(e,t){let n=[],r=e=>{for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)};return r(e),n}function Qn(e=!1){let t=Vn(e),n=(0,W.useMemo)(()=>Xn(t.data?.collections),[t.data]);return{...t,tree:n}}function $n(e){return[e.id,...e.children.flatMap($n)]}var er=[{value:``,label:`default`},{value:`#f97316`,label:`orange`},{value:`#eab308`,label:`yellow`},{value:`#10b981`,label:`green`},{value:`#06b6d4`,label:`cyan`},{value:`#3b82f6`,label:`blue`},{value:`#a855f7`,label:`purple`},{value:`#ec4899`,label:`pink`},{value:`#64748b`,label:`slate`}],tr=`📂.📁.🗂.📦.🗃.🛠.🔧.🧪.🔬.⚗️.🏗.🎨.🎯.🚀.🧩.🧠.💡.📝.📊.📈.🐛.🔒.🔑.⚡.🔥.❤️.⭐.✨.🌿.🏠`.split(`.`);function nr({mode:e,existing:t,initialParentId:n,pinnedSessionId:r,onClose:i,onCreated:a,onUpdated:o}){let[s,c]=(0,W.useState)(t?.name??``),[l,u]=(0,W.useState)(t?.description??``),[d,f]=(0,W.useState)(t?.icon??`📂`),[p,m]=(0,W.useState)(t?.color??``),[h,g]=(0,W.useState)(e===`rename`?t?.parent_id??null:n??null),[_,v]=(0,W.useState)(null),y=(0,W.useRef)(null),b=Qn(!1),x=Wn(),S=Gn();(0,W.useEffect)(()=>{requestAnimationFrame(()=>y.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let C=(0,W.useMemo)(()=>{let n=new Set(b.tree.flatMap($n)),r=Zn(b.tree,n);if(e===`rename`&&t){let e=new Set,n=t=>{e.add(t);for(let e of r)e.parent_id===t&&n(e.id)};return n(t.id),r.filter(t=>!e.has(t.id))}return r},[b.tree,e,t]),w=async()=>{let n=s.trim();if(!n){v(`name required`);return}try{if(e===`create`){let e=await x.mutateAsync({name:n,description:l.trim()||null,icon:d||null,color:p||null,parent_id:h});if(r)try{await fetch(`/api/collections/${encodeURIComponent(e.id)}/members`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({session_id:r})})}catch{}a?.(e)}else if(t){let e=await S.mutateAsync({id:t.id,patch:{name:n,description:l.trim()||null,icon:d||null,color:p||null,parent_id:h}});o?.(e)}i()}catch(e){v(e.message)}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:i,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[440px] max-w-[90vw] p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e===`create`?`New collection`:`Rename collection`}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative flex items-center gap-2 px-3 py-2 mb-4 rounded border border-line bg-bg`,style:{background:p?`linear-gradient(90deg, ${p}1a 0%, transparent 50%)`:void 0},children:[p&&(0,G.jsx)(`span`,{className:`absolute top-1 bottom-1 left-0 w-[3px] rounded-full`,style:{background:p},"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`text-base`,children:d||`📂`}),(0,G.jsx)(`span`,{className:`text-sm text-fg truncate flex-1`,children:s.trim()||(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(name)`})}),(0,G.jsx)(`span`,{className:`text-[10px] font-medium`,style:{color:p||void 0},children:`preview`})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Name`}),(0,G.jsx)(`input`,{ref:y,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()},maxLength:120,placeholder:`Pest Control — Scraping`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm text-fg focus:outline-none focus:border-accent`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Description (optional)`}),(0,G.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:2,maxLength:500,placeholder:`Short summary — shows on hover`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm text-fg focus:outline-none focus:border-accent resize-none`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Icon`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:tr.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:$(`w-7 h-7 rounded flex items-center justify-center text-sm hover:bg-bg-hover`,d===e&&`bg-accent/20 border border-accent`),title:e,children:e},e))}),(0,G.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value.slice(0,4)),className:`mt-1 w-full bg-bg border border-line rounded px-2 py-1 text-sm text-fg focus:outline-none focus:border-accent`,placeholder:`or paste your own`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Color`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:er.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(e.value),className:$(`w-7 h-7 rounded border transition-colors`,p===e.value?`border-accent ring-2 ring-accent/40`:`border-line hover:border-fg-muted`),style:{background:e.value||`transparent`},title:e.label},e.value||`default`))})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Parent collection`}),(0,G.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value||null),className:`w-full bg-bg border border-line rounded px-2 py-2 text-sm text-fg focus:outline-none focus:border-accent`,children:[(0,G.jsx)(`option`,{value:``,children:`— no parent (root) —`}),C.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[` `.repeat(e.depth),e.icon??`📂`,` `,e.name]},e.id))]}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-muted leading-snug`,children:C.length===0?`No other collections yet — this one will live at the root. Once you have two or more, you can nest them.`:`Parent = another collection, not a repo. Collections cut across projects — one collection can hold sessions from many repos.`})]}),_&&(0,G.jsx)(`div`,{className:`text-xs text-role-user bg-role-user/10 border border-role-user/30 rounded px-2 py-1.5`,children:_}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`px-3 py-1.5 text-sm text-fg-dim border border-line rounded hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:w,disabled:!s.trim()||x.isPending||S.isPending,className:`px-4 py-1.5 text-sm bg-accent text-bg rounded font-medium hover:bg-accent/90 disabled:opacity-50`,children:e===`create`?`Create`:`Save`})]})]})]})})}function rr(e){e.invalidateQueries({queryKey:[`autoRules`]}),e.invalidateQueries({queryKey:[`autoSuggestions`]}),e.invalidateQueries({queryKey:[`autoCollectionIds`]}),e.invalidateQueries({queryKey:[`collections`]}),e.invalidateQueries({queryKey:[`collection`]}),e.invalidateQueries({queryKey:[`sessionCollections`]}),e.invalidateQueries({queryKey:[`sessions`]})}function ir(){return q({queryKey:[`autoRules`],queryFn:()=>Z.listAutoRules(),staleTime:5e3})}function ar(e=!1){return q({queryKey:[`autoSuggestions`,{dismissed:e}],queryFn:()=>Z.listAutoSuggestions(e),staleTime:3e4})}function or(){return q({queryKey:[`autoCollectionIds`],queryFn:()=>Z.listAutoCollectionIds(),staleTime:3e4})}function sr(){let e=K();return J({mutationFn:e=>Z.createAutoRule(e),onSuccess:()=>rr(e)})}function cr(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchAutoRule(e,t),onSuccess:()=>rr(e)})}function lr(){let e=K();return J({mutationFn:e=>Z.deleteAutoRule(e),onSuccess:()=>rr(e)})}function ur(){let e=K();return J({mutationFn:e=>Z.acceptAutoSuggestion(e),onSuccess:()=>rr(e)})}function dr(){let e=K();return J({mutationFn:e=>Z.dismissAutoSuggestion(e),onSuccess:()=>rr(e)})}function fr(){let e=K();return J({mutationFn:()=>Z.detectAutoSuggestionsNow(),onSuccess:()=>rr(e)})}function pr(e,t=!0){return q({queryKey:[`autoSuggestionPreview`,e],queryFn:()=>Z.previewAutoSuggestion(e,3),enabled:!!e&&t,staleTime:6e4})}function mr(){let{data:e,isLoading:t}=ar(),[,n]=Nn(),r=e?.suggestions??[];return t||r.length===0?null:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n({view:`auto-rules`}),className:`mx-2 my-1 w-[calc(100%-1rem)] flex items-center justify-between gap-2 rounded border border-accent/30 bg-accent/5 px-2 py-1 text-[11px] text-fg-muted hover:bg-accent/10 hover:text-accent`,title:`Open Auto-rules to review suggestions`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[`💡 `,r.length,` auto-collection`,` `,r.length===1?`suggestion`:`suggestions`,` pending`]}),(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`Review →`})]})}var hr=`application/x-recall-collection`,gr=`application/x-recall-session`;function _r({selectedCollection:e,onSelect:t,onCreateCollection:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(()=>{try{return localStorage.getItem(`recall.collectionsPaneOpen`)===`1`}catch{return!1}});(0,W.useEffect)(()=>{try{localStorage.setItem(`recall.collectionsPaneOpen`,a?`1`:`0`)}catch{}},[a]);let[s,c]=(0,W.useState)(()=>new Set),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),{tree:h,isLoading:g,isError:_,error:v,data:y}=Qn(r),b=Kn(),x=qn(),S=Gn(),C=Jn(),[,w]=Nn(),T=or(),E=(0,W.useMemo)(()=>new Set(T.data?.auto_collection_ids??[]),[T.data]),[D,O]=(0,W.useState)(null),[k,A]=(0,W.useState)(null),j=(0,W.useRef)(new Map),M=(0,W.useCallback)(e=>{let t=j.current.get(e);t&&(window.clearTimeout(t),j.current.delete(e))},[]),ee=(0,W.useCallback)(e=>{if(s.has(e)||j.current.has(e))return;let t=window.setTimeout(()=>{c(t=>{let n=new Set(t);return n.add(e),n}),j.current.delete(e)},450);j.current.set(e,t)},[s]);(0,W.useEffect)(()=>()=>{for(let e of j.current.values())window.clearTimeout(e);j.current.clear()},[]);let N=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(!y||N.current)return;let e=new Set;for(let t of h)e.add(t.id);c(e),N.current=!0},[y,h]);let te=(0,W.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=(0,W.useCallback)((e,t)=>{t.preventDefault(),m({id:e,x:t.clientX,y:t.clientY})},[]);(0,W.useEffect)(()=>{if(!p)return;let e=()=>m(null),t=e=>{e.key===`Escape`&&m(null)};return window.addEventListener(`click`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`keydown`,t)}},[p]);let F=(0,W.useMemo)(()=>{let e=new Map,t=n=>{for(let r of n)e.set(r.id,r),t(r.children)};return t(h),e},[h]),I=e?F.get(e)??null:null,L=async(e,t)=>{if(!e||e===t)return;let n=F.get(e),r=F.get(t);if(!n||!r||n.parent_id!==r.parent_id)return;let i=n.parent_id?F.get(n.parent_id)?.children:h;if(!i)return;let a=[...i].sort((e,t)=>e.sort_key.localeCompare(t.sort_key)),o=a.findIndex(e=>e.id===t);if(o===-1)return;let s=a[o-1]?.sort_key??``,c=a[o].sort_key,l=br(s,c);try{await S.mutateAsync({id:e,patch:{sort_key:l}})}catch(e){console.error(`reorder failed`,e)}},R=async(e,t)=>{let n=F.get(t);try{let r=await C.mutateAsync({collectionId:t,sessionId:e});c(e=>{let n=new Set(e);return n.add(t),n});let i=n?.name??`collection`;A(r.added?`Added session to "${i}"`:`Already in "${i}"`),window.setTimeout(()=>A(null),2600)}catch(e){console.error(`add session via drop failed`,e),A(`Failed: ${e.message.slice(0,80)}`),window.setTimeout(()=>A(null),3500)}},z=()=>w({view:`help`,helpSection:`taxonomy`});return(0,G.jsxs)(`div`,{className:`border-t border-line mt-2`,children:[(0,G.jsxs)(`div`,{className:`pane-header flex items-center justify-between`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 hover:text-accent`,title:a?`collapse Collections`:`expand Collections`,"aria-expanded":a,children:[(0,G.jsx)(`span`,{className:$(`inline-block text-[10px] text-fg-muted transition-transform`,a?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{children:`📂 Collections`}),(0,G.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),z()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),z())},className:`text-xs font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent cursor-pointer`,title:`Collection vs Tag vs Project — what's the difference?`,children:`(?)`})]}),(0,G.jsxs)(`span`,{className:$(`flex items-center gap-1.5`,!a&&`hidden`),children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>w({view:`auto-rules`}),className:`text-xs font-medium normal-case tracking-normal px-2 py-1 rounded border border-line text-fg-muted hover:text-accent hover:border-accent/60 hover:bg-accent/5`,title:`Auto-collections — rules that group sessions automatically by repo / tag / plan file`,children:`⚙ Auto-rules`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs font-medium normal-case tracking-normal px-2 py-1 rounded bg-accent/10 text-accent hover:bg-accent/20`,title:`new collection (c)`,"data-collections-focus":!0,children:`+ New`})]})]}),a&&(0,G.jsx)(mr,{}),(0,G.jsxs)(`div`,{className:$(`px-2 pt-1 pb-2`,!a&&`hidden`),children:[g&&(0,G.jsx)(`div`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`Loading…`}),_&&(0,G.jsxs)(`div`,{className:`px-2 py-1 text-xs text-role-user`,children:[`Failed: `,v?.message]}),y&&h.length===0&&(0,G.jsx)(`div`,{className:`px-2 py-1 text-xs text-fg-muted italic`,children:`No collections yet. Hit "+ new" to curate sessions that belong together.`}),h.map(n=>(0,G.jsx)(yr,{node:n,selected:e,expanded:s,onToggle:te,onSelect:e=>t(e),onContext:P,onReorder:L,onSessionDrop:R,dropTargetId:D,setDropTargetId:O,onDragEnter:ee,onDragLeaveRow:M,autoIds:E},n.id)),k&&(0,G.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 bg-accent text-bg text-sm font-medium px-4 py-2 rounded-full shadow-xl animate-in fade-in slide-in-from-bottom-2`,role:`status`,"aria-live":`polite`,children:k}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`w-full mt-2 text-xs text-fg-muted hover:text-fg text-left px-2 py-1`,children:r?`☑ hide archived`:`☐ show archived`})]}),p&&(()=>{let t=F.get(p.id);if(!t)return null;let n=!!t.archived_at;return(0,G.jsxs)(`div`,{className:`fixed z-40 bg-bg-elevated border border-line rounded-md shadow-lg py-1 min-w-[180px]`,style:{top:p.y,left:p.x},onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(vr,{label:`New child collection`,onClick:()=>{m(null),f(t.id)}}),(0,G.jsx)(vr,{label:`Rename / edit…`,onClick:()=>{m(null),u(t)}}),(0,G.jsx)(vr,{label:`Copy link to this collection`,onClick:()=>{m(null);let e=new URL(window.location.href),n=new URLSearchParams(e.hash.replace(/^#/,``));n.set(`col`,t.id),e.hash=`#${n.toString()}`,navigator.clipboard.writeText(e.toString())}}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),n?(0,G.jsx)(vr,{label:`Restore`,onClick:()=>{m(null),x.mutateAsync(t.id)}}):(0,G.jsx)(vr,{label:`Archive (soft-delete)`,onClick:()=>{m(null),b.mutateAsync(t.id),e===t.id&&w({col:null})}})]})})(),l&&(0,G.jsx)(nr,{mode:`rename`,existing:l,onClose:()=>u(null),onUpdated:()=>u(null)}),d&&(0,G.jsx)(nr,{mode:`create`,initialParentId:d,onClose:()=>f(null),onCreated:()=>f(null)}),I&&(0,G.jsxs)(`div`,{className:`px-4 py-2 text-[10px] text-fg-muted border-t border-line mt-2`,children:[(0,G.jsxs)(`span`,{className:`block truncate`,children:[`Filtering: `,(0,G.jsx)(`span`,{className:`text-fg`,children:I.name})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(null),className:`mt-1 text-accent hover:underline`,children:`clear collection filter`})]})]})}function vr({label:e,onClick:t}){return(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-bg-hover`,children:e})}function yr({node:e,selected:t,expanded:n,onToggle:r,onSelect:i,onContext:a,onReorder:o,onSessionDrop:s,dropTargetId:c,setDropTargetId:l,onDragEnter:u,onDragLeaveRow:d,autoIds:f}){let p=n.has(e.id),m=e.children.length>0,h=!!e.archived_at,g=c===e.id,_=f.has(e.id);return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`relative group flex items-stretch`,onDragEnter:t=>{Array.from(t.dataTransfer.types).includes(`application/x-recall-session`)&&u(e.id)},onDragOver:t=>{let n=Array.from(t.dataTransfer.types),r=n.includes(gr),i=n.includes(hr);!r&&!i||(t.preventDefault(),t.dataTransfer.dropEffect=r?`copy`:`move`,c!==e.id&&l(e.id))},onDragLeave:t=>{let n=t.relatedTarget;(!n||!t.currentTarget.contains(n))&&(c===e.id&&l(null),d(e.id))},onDrop:t=>{t.preventDefault(),l(null),d(e.id);let n=t.dataTransfer.getData(gr);if(n){s(n,e.id);return}let r=t.dataTransfer.getData(hr);r&&r!==e.id&&o(r,e.id)},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onContextMenu:t=>a(e.id,t),className:$(`relative flex-1 min-w-0 flex items-center gap-1.5 py-1 pr-1 rounded text-sm text-left transition-colors`,t===e.id?`bg-accent/15 text-fg`:`hover:bg-bg-hover`,g&&`outline outline-2 outline-accent bg-accent/30 text-fg font-semibold shadow-[0_0_0_4px_rgba(249,115,22,0.15)]`,h&&`opacity-50 italic`),style:{paddingLeft:`${8+e.depth*12}px`,background:e.color?t===e.id?`linear-gradient(90deg, ${e.color}33 0%, transparent 40%)`:`linear-gradient(90deg, ${e.color}1a 0%, transparent 40%)`:void 0},title:e.description??e.name,children:[e.color&&(0,G.jsx)(`span`,{className:`absolute top-1 bottom-1 left-0 w-[3px] rounded-full`,style:{background:e.color},"aria-hidden":`true`}),m?(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:t=>{t.stopPropagation(),r(e.id)},className:$(`inline-block w-3 text-fg-muted text-[10px] transition-transform`,p&&`rotate-90`),"aria-hidden":`true`,children:`▸`}):(0,G.jsx)(`span`,{className:`inline-block w-3`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`shrink-0`,children:e.icon??`📂`}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),g?(0,G.jsx)(`span`,{className:`text-[10px] shrink-0 font-semibold text-accent px-1.5 py-0.5 rounded-full bg-accent/20 whitespace-nowrap`,children:`← drop here`}):(0,G.jsxs)(G.Fragment,{children:[_&&(0,G.jsx)(`span`,{className:`text-[10px] shrink-0 text-fg-muted/70`,title:`auto-collection (rule-managed). Manual memberships are never overwritten.`,"aria-label":`auto-managed`,children:`⚙`}),(0,G.jsx)(`span`,{className:$(`text-[10px] shrink-0 font-medium`,!e.color&&`text-fg-muted`),style:{color:e.color??void 0},children:e.total_session_count===e.session_count?e.session_count:`${e.session_count}/${e.total_session_count}`})]})]}),!h&&(0,G.jsx)(`span`,{draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-recall-collection`,e.id),t.dataTransfer.setData(`text/plain`,`recall-collection:${e.id}`)},className:`shrink-0 px-1.5 flex items-center text-fg-muted/40 hover:text-fg-muted cursor-grab active:cursor-grabbing text-[11px] select-none opacity-0 group-hover:opacity-100 transition-opacity`,title:`drag to reorder this collection among its siblings`,"aria-label":`drag to reorder ${e.name}`,children:`⋮⋮`})]}),p&&m&&(0,G.jsx)(`div`,{children:e.children.map(e=>(0,G.jsx)(yr,{node:e,selected:t,expanded:n,onToggle:r,onSelect:i,onContext:a,onReorder:o,onSessionDrop:s,dropTargetId:c,setDropTargetId:l,onDragEnter:u,onDragLeaveRow:d,autoIds:f},e.id))})]})}function br(e,t){return e?`${e}m`:`${t?t.charAt(0):`n`}0`}var xr=`claude-recall:foryou`;function Sr(e=new Date){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Cr(e){try{let t=window.localStorage.getItem(`${xr}:${e}`);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>e===`rediscovered`||e===`expensive`||e===`authored`)):new Set}catch{return new Set}}function wr(e,t){try{window.localStorage.setItem(`${xr}:${e}`,JSON.stringify([...t]))}catch{}}function Tr(){let[e,t]=(0,W.useState)(()=>Sr()),[n,r]=(0,W.useState)(()=>Cr(Sr())),[i,a]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{a(!0)},[]),(0,W.useEffect)(()=>{let n=()=>{let n=Sr();n!==e&&(t(n),r(Cr(n)))};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,n)}},[e]),{dismissed:n,dismiss:(0,W.useCallback)(t=>{r(n=>{if(n.has(t))return n;let r=new Set(n);return r.add(t),wr(e,r),r})},[e]),isReady:i}}function Er(e){return{id:`rediscovered`,icon:`✦`,label:`Rediscovered`,accent:`text-role-tool border-role-tool/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:`${e.daysAgo} day${e.daysAgo===1?``:`s`} ago`+(e.project?` · ${e.project}`:``),trailing:e.matchedKeywords.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.matchedKeywords.slice(0,4).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded bg-role-tool/10 text-role-tool text-[10px] border border-role-tool/30`,children:[`#`,e]},e))}):void 0,sessionId:e.sessionId}}function Dr(e){return{id:`expensive`,icon:`$`,label:`Most expensive · 7d`,accent:`text-accent border-accent/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:(e.project?`${e.project} · `:``)+`${e.costDisplay} · ${e.tokensDisplay} · ${e.primaryModelLabel}`+(e.startedAt?` · ${yt(e.startedAt)}`:``),sessionId:e.sessionId}}function Or(e){return{id:`authored`,icon:`⎇`,label:`Authored current HEAD`,accent:`text-role-assistant border-role-assistant/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:`${e.shortSha} · `+(e.subject?vt(e.subject,50):`current HEAD`)+(e.committedAt?` · ${yt(e.committedAt)}`:``),sessionId:e.sessionId}}function kr({onSelectSession:e}){let t=q({queryKey:[`discover`,`today`],queryFn:()=>Z.getDiscoverToday(),staleTime:300*1e3,refetchOnWindowFocus:!1,retry:1}),{dismissed:n,dismiss:r,isReady:i}=Tr(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(()=>{try{return localStorage.getItem(`recall.forYouPaneOpen`)===`1`}catch{return!1}});if((0,W.useEffect)(()=>{try{localStorage.setItem(`recall.forYouPaneOpen`,s?`1`:`0`)}catch{}},[s]),!i||!t.data)return null;let l=[];return t.data.rediscovered&&!n.has(`rediscovered`)&&l.push(Er(t.data.rediscovered)),t.data.expensive&&!n.has(`expensive`)&&l.push(Dr(t.data.expensive)),t.data.authored&&!n.has(`authored`)&&l.push(Or(t.data.authored)),l.length===0?null:(0,G.jsxs)(`div`,{className:`border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`flex items-center gap-2 hover:text-accent`,title:s?`collapse For you`:`expand For you`,"aria-expanded":s,children:[(0,G.jsx)(`span`,{className:$(`inline-block text-[10px] text-fg-muted transition-transform`,s?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{children:`For you`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:$(`text-xs font-normal normal-case tracking-normal hover:text-accent`,a?`text-accent`:`text-fg-muted/70`),title:`What is For you?`,"aria-expanded":a,children:`(?)`})]}),(0,G.jsx)(`span`,{children:l.length})]}),a&&(0,G.jsxs)(`div`,{className:`px-4 py-2 text-[11px] text-fg-muted bg-bg-elevated/50 border-b border-line/50 leading-relaxed`,children:[`Suggested sessions for today, picked from your activity:`,(0,G.jsxs)(`ul`,{className:`mt-1 ml-4 list-disc space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`$ Most expensive · 7d`}),` — your highest-cost session in the last week.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-role-assistant`,children:`⎇ Authored current HEAD`}),` — the session that produced the commit you're on.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-role-tool`,children:`✦ Rediscovered`}),` — an older session matching your current keywords.`]})]}),(0,G.jsx)(`div`,{className:`mt-1`,children:`Click × on a card to dismiss it for the day; suggestions reset overnight.`})]}),(0,G.jsx)(`div`,{className:$(`flex flex-col`,!s&&`hidden`),children:l.map(t=>(0,G.jsxs)(`div`,{className:$(`group relative px-4 py-2.5 border-b border-line/50 hover:bg-bg-hover transition-colors cursor-pointer`),role:`button`,tabIndex:0,onClick:()=>e(t.sessionId),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.sessionId))},title:`Open ${t.title}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-0.5`,children:[(0,G.jsxs)(`span`,{className:$(`inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wider font-medium px-1.5 py-0.5 rounded border`,t.accent),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:t.icon}),(0,G.jsx)(`span`,{children:t.label})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.id)},className:`opacity-0 group-hover:opacity-100 focus:opacity-100 text-fg-muted/70 hover:text-role-user transition-opacity text-sm leading-none px-1`,title:`Dismiss for today`,"aria-label":`Dismiss ${t.label} for today`,children:`×`})]}),(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg truncate`,children:t.title}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate mt-0.5`,children:t.subtitle}),t.trailing]},t.id))})]})}function Ar(e){return e>=70?`text-green-500`:e>=40?`text-yellow-500`:`text-red-500`}function jr(e){return e>=70?`bg-green-500`:e>=40?`bg-yellow-500`:`bg-red-500`}function Mr({projectId:e}){let t=q({queryKey:[`health`,e],queryFn:()=>Z.healthScore(e),staleTime:3e4,refetchInterval:6e4,refetchIntervalInBackground:!1});if(!t.data)return null;let{score:n}=t.data;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs ${Ar(n)}`,title:`Memory health: ${n}/100`,children:[(0,G.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${jr(n)}`}),n]})}var Nr=`sqlite3 ~/.recall/db.sqlite \\
|
|
10
|
+
`).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Mt(e,``+r);break;case`className`:gt(e,`class`,r);break;case`tabIndex`:gt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:gt(e,n,r);break;case`style`:Ft(e,r,o);break;case`data`:if(t!==`object`){gt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Rt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Rt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=zt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Rt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),ht(e,`popover`,r);break;case`xlinkActuate`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:_t(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:_t(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:ht(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Lt.get(n)||n,ht(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:Ft(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Mt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Mt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=zt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!dt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):ht(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}Dt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&kt(e,!!r,n,!0):kt(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}jt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(It(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Et(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?kt(e,!!n,n?[]:``,!1):kt(e,!!n,t,!0)):kt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}At(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(It(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[at]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[at])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ot(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=ct(e);t!==null&&t.tag===5&&t.type===`form`?gs(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Tt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Tt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Tt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Tt(n.imageSizes)+`"]`)):i+=`[href="`+Tt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Tt(r)+`"][href="`+Tt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),lt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=J(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);lt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=J(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=J(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=re.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=J(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=J(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=J(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Tt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),lt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Tt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Tt(n.href)+`"]`);if(r)return t.instance=r,lt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),lt(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,lt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),lt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,lt(a),a):(r=n,(a=mf.get(o))&&(r=f({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),lt(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[at]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,lt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=We(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=We(0),this.hiddenUpdates=We(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=qr(3,null,null,t),e.current=a,a.stateNode=e,t=Ji(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Da(a),e}function tp(e){return e?(e=Gr,e):Gr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=ka(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Aa(e,r,t),n!==null&&(fu(n,e,t),ja(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Hr(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=K(t);var n=Hr(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=ct(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=ze(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Me(o);s.entanglements[1]|=c,o&=~c}td(a),!(jl&6)&&(Ql=be()+500,nd(0,!1))}}break;case 31:case 13:s=Hr(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Vt(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=st(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(xe()){case Se:return 2;case Ce:return 8;case we:case Te:return 32;case Ee:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ct(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=st(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Bt=r,n.target.dispatchEvent(r),Bt=null}else return t=ct(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=ct(n);a!==null&&(e.splice(t,3),t-=3,ms(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.7`)throw Error(i(527,Lp,`19.2.7`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{ke=zp.inject(Rp),Ae=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ls,s=Rs,c=zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),y=s(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=v()})),b=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},x=new class extends b{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},S={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},C=new class{#e=S;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function w(e){setTimeout(e,0)}var T=typeof window>`u`||`Deno`in globalThis;function E(){}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return typeof e==`number`&&e>=0&&e!==1/0}function k(e,t){return Math.max(e+(t||0)-Date.now(),0)}function A(e,t){return typeof e==`function`?e(t):e}function j(e,t){return typeof e==`function`?e(t):e}function M(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==N(o,t.options))return!1}else if(!P(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ee(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(te(t.options.mutationKey)!==te(a))return!1}else if(!P(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function N(e,t){return(t?.queryKeyHashFn||te)(e)}function te(e){return JSON.stringify(e,(e,t)=>z(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function P(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>P(e[n],t[n])):!1}var F=Object.prototype.hasOwnProperty;function I(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=R(e)&&R(t);if(!r&&!(z(e)&&z(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:F.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=I(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function L(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function R(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function z(e){if(!B(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!B(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function B(e){return Object.prototype.toString.call(e)===`[object Object]`}function V(e){return new Promise(t=>{C.setTimeout(t,e)})}function ne(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:I(e,t)}function H(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function re(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ie=Symbol();function ae(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ie?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function oe(e,t){return typeof e==`function`?e(...t):!!e}function se(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ce=(()=>{let e=()=>T;return{isServer(){return e()},setIsServer(t){e=t}}})();function U(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var le=w;function ue(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=le,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var de=ue(),fe=new class extends b{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function pe(e){return Math.min(1e3*2**e,3e4)}function me(e){return(e??`online`)===`online`?fe.isOnline():!0}var he=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ge(e){let t=!1,n=0,r,i=U(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new he(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>x.isFocused()&&(e.networkMode===`always`||fe.isOnline())&&e.canRun(),u=()=>me(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ce.isServer()?0:3),o=e.retryDelay??pe,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),V(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var _e=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),O(this.gcTime)&&(this.#e=C.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ce.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(C.clearTimeout(this.#e),this.#e=void 0)}};function ve(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{se(e,()=>t.signal,()=>n=!0)},u=ae(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?re:H;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?be:ye,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:ye(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ye(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function be(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function xe(e,t){return t?ye(e,t)!=null:!1}function Se(e,t){return!t||!e.getPreviousPageParam?!1:be(e,t)!=null}var Ce=class extends _e{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Ee(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ee(this.options);e.data!==void 0&&(this.setState(Te(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ne(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(E).catch(E):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>j(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ie||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>A(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!k(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ae(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?ve(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=ge({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof he&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof he){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...we(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Te(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),de.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function we(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:me(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Te(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ee(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var De=class extends b{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=U(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ke(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ae(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ae(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof j(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!L(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&je(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||j(this.options.enabled,this.#t)!==j(t.enabled,this.#t)||A(this.options.staleTime,this.#t)!==A(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||j(this.options.enabled,this.#t)!==j(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ne(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(E)),t}#g(){this.#b();let e=A(this.options.staleTime,this.#t);if(ce.isServer()||this.#r.isStale||!O(e))return;let t=k(this.#r.dataUpdatedAt,e)+1;this.#d=C.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ce.isServer()||j(this.options.enabled,this.#t)===!1||!O(this.#p)||this.#p===0)&&(this.#f=C.setInterval(()=>{(this.options.refetchIntervalInBackground||x.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(C.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(C.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ke(e,t),o=i&&je(e,n,t,r);(a||o)&&(l={...l,...we(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ne(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ne(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Me(e,t),refetch:this.refetch,promise:this.#o,isEnabled:j(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=U())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!L(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){de.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Oe(e,t){return j(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&j(t.retryOnMount,e)===!1)}function ke(e,t){return Oe(e,t)||e.state.data!==void 0&&Ae(e,t,t.refetchOnMount)}function Ae(e,t,n){if(j(t.enabled,e)!==!1&&A(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Me(e,t)}return!1}function je(e,t,n,r){return(e!==t||j(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Me(e,n)}function Me(e,t){return j(t.enabled,e)!==!1&&e.isStaleByTime(A(t.staleTime,e))}function Ne(e,t){return!L(e.getCurrentResult(),t)}var Pe=class extends De{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xe(t,n.data),hasPreviousPage:Se(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Fe=class extends _e{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ie(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ge({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),de.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ie(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Le=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Fe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Re(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Re(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){de.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){return this.getAll().filter(t=>ee(e,t))}notify(e){de.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return de.batch(()=>Promise.all(e.map(e=>e.continue().catch(E))))}};function Re(e){return e.options.scope?.id}var ze=class extends b{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),L(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&te(t.mutationKey)!==te(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ie();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){de.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Be(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ve(e,t,n){let r=e.slice(0);return r[t]=n,r}var He=class extends b{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,de.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!L(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Be(e,n).forEach(e=>{e.destroy()}),Be(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=I(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new De(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ve(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&de.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Ue=class extends b{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??N(r,t),a=this.get(i);return a||(a=new Ce({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){de.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>M(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>M(e,t)):t}notify(e){de.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){de.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){de.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},We=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ue,this.#t=e.mutationCache||new Le,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=x.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(A(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=D(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return de.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;de.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return de.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=de.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(E).catch(E)}invalidateQueries(e,t={}){return de.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=de.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(E)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(E)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(A(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(E).catch(E)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(E).catch(E)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(te(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{P(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(te(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{P(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=N(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ie&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Ge=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Ke=s(((e,t)=>{t.exports=Ge()})),W=u(p(),1),G=Ke(),qe=W.createContext(void 0),K=e=>{let t=W.useContext(qe);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Je=({client:e,children:t})=>(W.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,G.jsx)(qe.Provider,{value:e,children:t})),Ye=W.createContext(!1),Xe=()=>W.useContext(Ye);Ye.Provider;function Ze(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Qe=W.createContext(Ze()),$e=()=>W.useContext(Qe),et=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?oe(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},tt=e=>{W.useEffect(()=>{e.clearReset()},[e])},nt=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||oe(n,[e.error,r])),rt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},it=(e,t)=>e.isLoading&&e.isFetching&&!t,at=(e,t)=>e?.suspense&&t.isPending,ot=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function st({queries:e,...t},n){let r=K(n),i=Xe(),a=$e(),o=W.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{rt(e),et(e,a,r.getQueryCache().get(e.queryHash))}),tt(a);let[s]=W.useState(()=>new He(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;W.useSyncExternalStore(W.useCallback(e=>d?s.subscribe(de.batchCalls(e)):E,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),W.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>at(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&at(n,e)?ot(n,new De(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&nt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function ct(e,t,n){let r=Xe(),i=$e(),a=K(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,rt(o),et(o,i,s),tt(i);let l=!a.getQueryCache().get(o.queryHash),[u]=W.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(W.useSyncExternalStore(W.useCallback(e=>{let t=f?u.subscribe(de.batchCalls(e)):E;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),W.useEffect(()=>{u.setOptions(o)},[o,u]),at(o,d))throw ot(o,u,i);if(nt({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ce.isServer()&&it(d,r)&&(l?ot(o,u,i):s?.promise)?.catch(E).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function q(e,t){return ct(e,De,t)}function J(e,t){let n=K(t),[r]=W.useState(()=>new ze(n,e));W.useEffect(()=>{r.setOptions(e)},[r,e]);let i=W.useSyncExternalStore(W.useCallback(e=>r.subscribe(de.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=W.useCallback((e,t)=>{r.mutate(e,t).catch(E)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function lt(e,t){return ct(e,Pe,t)}var ut=u(y(),1),dt=(typeof document<`u`?document.querySelector(`meta[name="recall-token"]`)?.getAttribute(`content`):null)??``;function ft(){return dt}function pt(e){let t=ft(),n={...e};return t&&(n[`x-recall-token`]=t),n}function mt(e){let t=ft();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}async function Y(e){let t=await fetch(e,{headers:pt()});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`${t.status} ${t.statusText}: ${e.slice(0,200)}`)}return await t.json()}async function X(e,t,n,r){let i=await fetch(t,{method:e,headers:pt(n===void 0?void 0:{"content-type":`application/json`}),body:n===void 0?void 0:JSON.stringify(n),signal:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`${i.status} ${i.statusText}: ${e.slice(0,200)}`)}return await i.json()}var Z={stats:()=>Y(`/api/stats`),health:()=>Y(`/api/health`),neighborhood:(e,t={})=>{let n=new URLSearchParams;t.budget&&n.set(`budget`,String(t.budget)),t.scoring&&n.set(`scoring`,t.scoring);let r=n.toString();return Y(`/api/neighborhood/${encodeURIComponent(e)}${r?`?${r}`:``}`)},projects:async(e=`folder`)=>{if(e===`folder`)return{mode:`folder`,projects:await Y(`/api/projects`)};let t=await Y(`/api/projects?groupBy=${encodeURIComponent(e)}`);return{mode:t.groupBy,groups:t.groups}},sessions:(e={})=>{let t=new URLSearchParams({limit:String(e.limit??100)});return e.projectName&&t.set(`project`,e.projectName),e.since&&t.set(`since`,e.since),e.until&&t.set(`until`,e.until),e.collectionId&&t.set(`collection`,e.collectionId),e.cursor&&t.set(`cursor`,e.cursor),Y(`/api/sessions?${t}`)},session:e=>Y(`/api/sessions/${encodeURIComponent(e)}`),graph:e=>Y(`/api/graph/${encodeURIComponent(e)}`),search:(e,t=40,n,r)=>{let i=new URLSearchParams({q:e,limit:String(t)});return n&&i.set(`project`,n),r&&i.set(`mode`,r),Y(`/api/search?${i}`)},allTags:()=>Y(`/api/tags`),sessionTags:e=>Y(`/api/sessions/${encodeURIComponent(e)}/tags`),addSessionTag:async(e,t)=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/tags`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({tag:t})});if(!n.ok)throw Error(`${n.status}: ${await n.text()}`);return await n.json()},removeSessionTag:async(e,t)=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/tags/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok)throw Error(`${n.status}: ${await n.text()}`);return await n.json()},shareStats:e=>Y(`/api/sessions/${encodeURIComponent(e)}/share-stats`),listCollections:(e=!1)=>{let t=new URLSearchParams;e&&t.set(`archived`,`1`);let n=t.toString();return Y(`/api/collections${n?`?${n}`:``}`)},getCollection:e=>Y(`/api/collections/${encodeURIComponent(e)}`),createCollection:e=>X(`POST`,`/api/collections`,e),patchCollection:(e,t)=>X(`PATCH`,`/api/collections/${encodeURIComponent(e)}`,t),archiveCollection:e=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/archive`),restoreCollection:e=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/restore`),addSessionToCollection:(e,t,n)=>X(`POST`,`/api/collections/${encodeURIComponent(e)}/members`,{session_id:t,note:n??null}),removeSessionFromCollection:(e,t)=>X(`DELETE`,`/api/collections/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`),sessionCollections:e=>Y(`/api/sessions/${encodeURIComponent(e)}/collections`),getAutoTagConfig:()=>Y(`/api/config/auto-tag`),putAutoTagConfig:e=>X(`PUT`,`/api/config/auto-tag`,e),startScan:e=>X(`POST`,`/api/tags/scan`,{scope:e}),getScan:e=>Y(`/api/tags/scan/${encodeURIComponent(e)}`),applyScan:(e,t)=>X(`POST`,`/api/tags/scan/${encodeURIComponent(e)}/apply`,{selection:t}),cancelScan:e=>X(`DELETE`,`/api/tags/scan/${encodeURIComponent(e)}`),getMcpInstallStatus:()=>Y(`/api/config/mcp-install`),installMcp:()=>X(`POST`,`/api/config/mcp-install`),uninstallMcp:()=>X(`DELETE`,`/api/config/mcp-install`),getAutopilotStatus:()=>Y(`/api/autopilot/status`),kickAutopilot:()=>X(`POST`,`/api/autopilot/kick`),runClaudeCliScan:(e,t={})=>X(`POST`,`/api/tags/scan/claude-cli`,t.scanId?{scope:e,scanId:t.scanId}:{scope:e}),subscribeToScanProgress:e=>new EventSource(mt(`/api/claude-cli/scan/${encodeURIComponent(e)}/progress`)),listPrompts:()=>Y(`/api/prompts`),runPrompt:(e,t)=>X(`POST`,`/api/prompts/run`,{name:e,args:t}),getSemanticStatus:()=>Y(`/api/semantic/status`),setSemanticEnabled:e=>X(`PUT`,`/api/semantic/config`,{enabled:e}),triggerSemanticBackfill:(e=200)=>X(`POST`,`/api/semantic/backfill`,{limit:e}),reindexProjectVectors:(e,t=!1,n=0)=>X(`POST`,`/api/semantic/reindex-project`,{project:e,force:t,maxChunks:n}),getReindexPreview:e=>Y(`/api/semantic/reindex-preview?project=${encodeURIComponent(e)}`),getVectorStatus:e=>Y(e?`/api/semantic/vector-status?project=${encodeURIComponent(e)}`:`/api/semantic/vector-status`),installVectorModel:()=>X(`POST`,`/api/semantic/install`,{}),cancelReindex:(e,t)=>X(`POST`,`/api/semantic/cancel-reindex`,e?{project:e}:{},t),getSessionStats:e=>Y(`/api/stats/session/${encodeURIComponent(e)}`),getProjectStats:e=>Y(`/api/stats/project/${encodeURIComponent(e)}`),getOverviewStats:(e=`all`)=>Y(`/api/stats/overview?range=${e}`),triggerStatsBackfill:e=>X(`POST`,`/api/stats/backfill`,e?{limit:e}:{}),getOnboarding:()=>Y(`/api/onboarding`),patchOnboarding:e=>X(`PUT`,`/api/onboarding`,e),resetOnboarding:()=>X(`POST`,`/api/onboarding/reset`),getSessionCommits:e=>Y(`/api/sessions/${encodeURIComponent(e)}/commits`),refreshSessionCommits:e=>Y(`/api/sessions/${encodeURIComponent(e)}/commits?refresh=1`),getCommitSessions:e=>Y(`/api/commits/${encodeURIComponent(e)}/session`),getDiscoverToday:()=>Y(`/api/discover/today`),getAutoTitleConfig:()=>Y(`/api/config/auto-title`),putAutoTitleConfig:e=>X(`PUT`,`/api/config/auto-title`,e),generateAutoTitle:e=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/auto-title`),regenerateTitle:(e,t={})=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/regenerate-title`,t),revertAutoTitle:e=>X(`POST`,`/api/sessions/${encodeURIComponent(e)}/auto-title/revert`),listAutoRules:()=>Y(`/api/auto-collections/rules`),createAutoRule:e=>X(`POST`,`/api/auto-collections/rules`,e),patchAutoRule:(e,t)=>X(`PATCH`,`/api/auto-collections/rules/${encodeURIComponent(e)}`,t),deleteAutoRule:e=>X(`DELETE`,`/api/auto-collections/rules/${encodeURIComponent(e)}`),listAutoSuggestions:(e=!1)=>Y(`/api/auto-collections/suggestions${e?`?dismissed=1`:``}`),acceptAutoSuggestion:e=>X(`POST`,`/api/auto-collections/suggestions/${encodeURIComponent(e)}/accept`),dismissAutoSuggestion:e=>X(`POST`,`/api/auto-collections/suggestions/${encodeURIComponent(e)}/dismiss`),detectAutoSuggestionsNow:()=>X(`POST`,`/api/auto-collections/detect`),previewAutoSuggestion:(e,t=3)=>Y(`/api/auto-collections/suggestions/${encodeURIComponent(e)}/preview?limit=${t}`),listAutoCollectionIds:()=>Y(`/api/auto-collections/parents`),healthScores:()=>Y(`/api/stats/health`),healthScore:e=>Y(`/api/stats/health/${e}`),getVerificationConfig:()=>Y(`/api/config/verification`),setVerificationConfig:e=>X(`PUT`,`/api/config/verification`,{enabled:e}),getVerificationDetail:e=>Y(`/api/sessions/${encodeURIComponent(e)}/verification`),listThreads:(e=!1)=>Y(`/api/threads${e?`?archived=1`:``}`),getThread:e=>Y(`/api/threads/${encodeURIComponent(e)}`),createThread:e=>X(`POST`,`/api/threads`,e),patchThread:(e,t)=>X(`PATCH`,`/api/threads/${encodeURIComponent(e)}`,t),listThreadFolders:()=>Y(`/api/thread-folders`),createThreadFolder:e=>X(`POST`,`/api/thread-folders`,{name:e.name,parent_folder_id:e.parentFolderId??null,project_scope:e.projectScope??null}),patchThreadFolder:(e,t)=>X(`PATCH`,`/api/thread-folders/${encodeURIComponent(e)}`,t),deleteThreadFolder:e=>X(`DELETE`,`/api/thread-folders/${encodeURIComponent(e)}`),reorderThreadFolders:e=>X(`POST`,`/api/thread-folders/reorder`,{parent_folder_id:e.parentFolderId,project_scope:e.projectScope,ordered_ids:e.orderedIds}),addSessionToThread:(e,t)=>X(`POST`,`/api/threads/${encodeURIComponent(e)}/sessions`,t),removeSessionFromThread:(e,t)=>X(`DELETE`,`/api/threads/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`),setThreadSessionParent:(e,t,n)=>X(`PATCH`,`/api/threads/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}`,{parentSessionId:n}),threadsForSession:e=>Y(`/api/sessions/${encodeURIComponent(e)}/threads`),threadTitlesPreflight:e=>Y(`/api/threads/${encodeURIComponent(e)}/titles/preflight`),startThreadTitlesJob:(e,t)=>X(`POST`,`/api/threads/${encodeURIComponent(e)}/titles/generate`,{force:t}),cancelJob:e=>X(`DELETE`,`/api/jobs/${encodeURIComponent(e)}`),listSuggestions:(e={})=>{let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.linkType&&t.set(`type`,e.linkType),e.inferredBy&&t.set(`inferred_by`,e.inferredBy),e.sourceSessionId&&t.set(`source_id`,e.sourceSessionId),e.targetSessionId&&t.set(`target_id`,e.targetSessionId),typeof e.limit==`number`&&t.set(`limit`,String(e.limit));let n=t.toString();return Y(n?`/api/links/suggestions?${n}`:`/api/links/suggestions`)},decideSuggestion:(e,t)=>X(`PATCH`,`/api/links/suggestions/${e}`,{status:t}),bulkDecideSuggestions:(e,t)=>X(`POST`,`/api/links/suggestions/bulk-decide`,{ids:e,status:t}),sessionLinks:e=>Y(`/api/sessions/${encodeURIComponent(e)}/links?type=wiki_link`),createWikiLink:(e,t,n={created_via:`context_menu`})=>X(`POST`,`/api/links`,{source_session_id:e,target_session_id:t,link_type:`wiki_link`,evidence:n}),removeLink:e=>X(`DELETE`,`/api/links/${e}`),listBugPatterns:(e={})=>{let t=new URLSearchParams;typeof e.minCount==`number`&&t.set(`min_count`,String(e.minCount)),e.status&&t.set(`status`,e.status),e.project&&t.set(`project`,e.project),typeof e.limit==`number`&&t.set(`limit`,String(e.limit)),typeof e.offset==`number`&&t.set(`offset`,String(e.offset));let n=t.toString();return Y(n?`/api/bug-patterns?${n}`:`/api/bug-patterns`)},getBugPattern:e=>Y(`/api/bug-patterns/${encodeURIComponent(e)}`),resolveBugPattern:(e,t,n)=>X(`POST`,`/api/bug-patterns/${encodeURIComponent(e)}/resolve`,{resolved_in_session_id:t,fix_summary:n}),splitBugPattern:(e,t)=>X(`POST`,`/api/bug-patterns/${encodeURIComponent(e)}/split`,{member_session_ids:t}),getBugPatternsSetupStatus:()=>Y(`/api/bug-patterns/setup-status`),bugSignatures:(e,t=100)=>{let n=new URLSearchParams;return e&&n.set(`project`,e),n.set(`limit`,String(t)),Y(`/api/bug-signatures?${n.toString()}`)},resolveBugSignature:(e,t)=>X(`POST`,`/api/bug-signatures/${encodeURIComponent(e)}/resolve`,t),unresolveBugSignature:e=>X(`POST`,`/api/bug-signatures/${encodeURIComponent(e)}/unresolve`),bugPatternsGraph:(e,t=!0)=>{let n=new URLSearchParams;e&&n.set(`project`,e),t||n.set(`include_resolved`,`0`);let r=n.toString();return Y(`/api/bug-patterns/graph${r?`?${r}`:``}`)},extractOutputsPreflight:e=>ht(`/api/extract-outputs/preflight`,e),extractOutputsRun:e=>ht(`/api/extract-outputs/run`,{preflight_token:e}),extractOutputsCancel:e=>gt(`/api/extract-outputs/jobs/${encodeURIComponent(e)}`),extractOutputsJobSnapshot:e=>Y(`/api/extract-outputs/jobs/${encodeURIComponent(e)}`),launcherBudget:()=>Y(`/api/extract-outputs/budget`),synthesizePreflight:e=>ht(`/api/bug-patterns/synthesize/preflight`,e),synthesizeRun:e=>ht(`/api/bug-patterns/synthesize/run`,{preflight_token:e}),synthesizeJobSnapshot:e=>Y(`/api/bug-patterns/synthesize/jobs/${encodeURIComponent(e)}`),synthesizeCancel:e=>gt(`/api/bug-patterns/synthesize/jobs/${encodeURIComponent(e)}`),threadScanPreflight:e=>ht(`/api/threads/scan/preflight`,e),threadScanApply:e=>ht(`/api/threads/scan/apply`,e),threadScanJobSnapshot:e=>Y(`/api/threads/scan/jobs/${encodeURIComponent(e)}`),threadScanCancel:e=>gt(`/api/threads/scan/jobs/${encodeURIComponent(e)}`),syncActivePreflight:e=>X(`POST`,`/api/threads/sync-active`,{...e,mode:`preflight`}),syncActiveApply:e=>X(`POST`,`/api/threads/sync-active`,{...e,mode:`apply`}),listMacroRepos:()=>Y(`/api/macro-repos`),createMacroRepo:e=>X(`POST`,`/api/macro-repos`,e),patchMacroRepo:(e,t)=>X(`PATCH`,`/api/macro-repos/${e}`,t),deleteMacroRepo:e=>X(`DELETE`,`/api/macro-repos/${e}`),addMacroRepoMember:(e,t)=>X(`POST`,`/api/macro-repos/${e}/members`,{project_id:t}),removeMacroRepoMember:(e,t)=>X(`DELETE`,`/api/macro-repos/${e}/members/${t}`),listBugSynthesisResults:e=>{let t=new URLSearchParams;e?.scope&&t.set(`scope`,e.scope),e?.target_id&&t.set(`target_id`,e.target_id),e?.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return Y(`/api/bug-synthesis${n?`?${n}`:``}`)},bugSynthesisCounts:e=>Y(`/api/bug-synthesis/counts?scope=${e}`),getBugSynthesisResult:e=>Y(`/api/bug-synthesis/${e}`),deleteBugSynthesisResult:e=>X(`DELETE`,`/api/bug-synthesis/${e}`)};async function ht(e,t){let n=await fetch(e,{method:`POST`,headers:pt({"content-type":`application/json`,"x-recall-launcher":`1`}),body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`${n.status} ${n.statusText}: ${e.slice(0,300)}`)}return await n.json()}async function gt(e){let t=await fetch(e,{method:`DELETE`,headers:pt({"x-recall-launcher":`1`})});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`${t.status} ${t.statusText}: ${e.slice(0,300)}`)}return await t.json()}function _t(e){return e?e.slice(0,8):``}function vt(e,t){if(!e)return``;let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:n.slice(0,t-1)+`…`}function yt(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);if(o<30)return`${o}d ago`;let s=Math.floor(o/30);return s<12?`${s}mo ago`:`${Math.floor(o/365)}y ago`}function bt(e){return e==null?`0`:e.toLocaleString()}function xt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function St(e){let t=e.split(/\s+/).filter(e=>e.length>1).map(xt);return t.length===0?null:RegExp(`(${t.join(`|`)})`,`gi`)}function Ct(){let[e,t]=(0,W.useState)(null),n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=new EventSource(mt(`/api/autopilot/events`));return n.current=e,e.addEventListener(`state`,e=>{try{t(JSON.parse(e.data))}catch(e){console.error(`autopilot state parse failed`,e)}}),e.onerror=()=>{},()=>e.close()},[]),e}function wt(){return q({queryKey:[`auto-tag-config`],queryFn:()=>Z.getAutoTagConfig()})}function Tt(){let e=K();return J({mutationFn:e=>Z.putAutoTagConfig(e),onSuccess:()=>void e.invalidateQueries({queryKey:[`auto-tag-config`]})})}function Et(){let e=wt(),t=Ct();return!e.data?.autopilot||!t||t.status===`idle`?null:t.status===`error`?(0,G.jsx)(`div`,{className:`text-[11px] px-2 py-1 rounded-full border border-role-user/40 bg-role-user/10 text-role-user`,title:t.lastError??`autopilot error`,children:`⚠ autopilot error`}):(0,G.jsxs)(`div`,{className:`text-[11px] px-2 py-1 rounded-full border border-accent/40 bg-accent/10 text-accent flex items-center gap-1.5`,title:`Autopilot is tagging untagged sessions in the background.`,children:[(0,G.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse`}),`tagging `,t.processed,`/`,t.total]})}var Dt=[{value:1,label:`bad`,emoji:`😡`},{value:2,label:`meh`,emoji:`😕`},{value:3,label:`ok`,emoji:`😐`},{value:4,label:`good`,emoji:`🙂`},{value:5,label:`great`,emoji:`🤩`}];function Ot(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(`idle`),[c,l]=(0,W.useState)(null);(0,W.useEffect)(()=>{function n(n){n.key===`Escape`&&e&&t(!1)}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]);function u(){r(null),a(``),s(`idle`),l(null)}async function d(){if(n!==null){s(`sending`),l(null);try{let e=await fetch(`/api/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`,...pt()},body:JSON.stringify({score:n,comment:i.trim()||null,trigger_kind:`manual`})});if(e.ok){s(`sent`),setTimeout(()=>{t(!1),u()},1400);return}let r=await e.json().catch(()=>({}));e.status===429?l(r.detail??`You sent feedback recently. Try again later.`):l(r.detail??r.error??`Failed (${e.status})`),s(`error`)}catch(e){l(e instanceof Error?e.message:`network error`),s(`error`)}}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(!0),className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors text-accent border-accent/40 hover:bg-accent hover:text-bg hover:border-accent`,"aria-label":`Send feedback`,title:`Send feedback to the Claude Recall team`,children:`💬 Feedback`}),e&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center bg-black/40 p-4 backdrop-blur-sm sm:items-center`,onClick:()=>{t(!1),u()},children:(0,G.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl bg-white p-5 shadow-2xl dark:bg-neutral-900`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-start justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900 dark:text-neutral-100`,children:`Tell us how it's going`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-neutral-500 dark:text-neutral-400`,children:`Sent to the Claude Recall team. Pro users are attributed automatically.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{t(!1),u()},className:`text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200`,"aria-label":`Close`,children:`×`})]}),(0,G.jsx)(`div`,{className:`mb-3 flex justify-between gap-1`,children:Dt.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),className:`flex flex-1 flex-col items-center rounded-lg border px-2 py-2 text-xs transition ${n===e.value?`border-accent bg-accent/15 text-accent`:`border-line text-fg-dim hover:border-accent/60`}`,"aria-pressed":n===e.value,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,G.jsx)(`span`,{className:`mt-1`,children:e.label})]},e.value))}),(0,G.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),placeholder:n!==null&&n<=2?`What is the biggest pain point?`:`Anything you'd add? (optional)`,maxLength:2e3,rows:4,className:`w-full resize-none rounded-lg border border-line bg-bg-elevated px-3 py-2 text-sm text-fg placeholder-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),c&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:c}),o===`sent`&&(0,G.jsx)(`p`,{className:`mt-2 text-xs text-emerald-600 dark:text-emerald-400`,children:`Thanks. Your feedback landed.`}),(0,G.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-neutral-400`,children:[i.length,`/2000`]}),(0,G.jsx)(`button`,{type:`button`,onClick:d,disabled:n===null||o===`sending`||o===`sent`,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-bg shadow-sm hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50`,children:o===`sending`?`Sending…`:o===`sent`?`Sent`:`Send feedback`})]})]})})]})}function kt(){return q({queryKey:[`license-status`],queryFn:async()=>{let e=await fetch(`/api/license/status`,{headers:pt()});if(!e.ok)throw Error(`${e.status}: ${await e.text()}`);return await e.json()},staleTime:6e4})}function At(){return kt().data?.tier===`pro`}var jt=`https://clauderecall.com/pricing`;function Mt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Nt(){let{data:e,isLoading:t}=kt(),[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null);if((0,W.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&(i.current.contains(e.target)||r(!1))},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),t||!e)return null;if(e.tier===`pro`){let t=Mt(e.activated_at);return(0,G.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`text-[11px] font-bold tracking-wide px-2 py-0.5 rounded-md bg-accent text-bg hover:brightness-110 transition`,title:`Pro license active. Click for details.`,"aria-haspopup":`dialog`,"aria-expanded":n,children:[`PRO`,e.test_mode&&(0,G.jsx)(`span`,{className:`ml-1 font-medium opacity-80`,children:`· TEST`})]}),n&&(0,G.jsxs)(`div`,{role:`dialog`,className:`absolute right-0 top-full mt-2 w-72 z-50 rounded-lg border border-line bg-bg-elevated shadow-lg p-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-bold tracking-wide px-1.5 py-0.5 rounded bg-accent text-bg`,children:`PRO`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Lifetime`})]}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.key_short&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Key`}),(0,G.jsx)(`dd`,{className:`font-mono text-fg truncate`,children:e.key_short})]}),e.customer_email&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Email`}),(0,G.jsx)(`dd`,{className:`text-fg truncate`,children:e.customer_email})]}),t&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Activated`}),(0,G.jsx)(`dd`,{className:`text-fg`,children:t})]}),e.test_mode&&(0,G.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-fg-muted`,children:`Mode`}),(0,G.jsx)(`dd`,{className:`text-accent`,children:`Test mode`})]})]})]})]})}return(0,G.jsxs)(`a`,{href:jt,target:`_blank`,rel:`noreferrer noopener`,className:`text-[11px] font-medium px-2 py-0.5 rounded-md border border-line text-fg-dim hover:text-fg hover:border-accent/60 transition`,title:`Free tier. Click to view Pro pricing.`,children:[`Free `,(0,G.jsx)(`span`,{className:`text-accent`,children:`· Upgrade`})]})}var Pt=new Set,Ft=[],It=1;function Lt(){for(let e of Pt)e([...Ft])}function Q(e){let t=e.id??`t-${It++}`,n={id:t,message:e.message,tone:e.tone??`info`,duration:e.duration??4e3,action:e.action};return Ft=[...Ft.filter(e=>e.id!==t),n],Lt(),n.duration>0&&setTimeout(()=>Rt(t),n.duration),t}function Rt(e){Ft=Ft.filter(t=>t.id!==e),Lt()}function zt(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>(Pt.add(t),()=>{Pt.delete(t)}),[]),e.length===0?null:(0,G.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2 items-end max-w-[calc(100vw-2rem)]`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`min-w-[260px] max-w-[420px] rounded-lg border shadow-lg px-3 py-2 text-xs flex items-start gap-3 ${e.tone===`error`?`bg-bg-elevated border-role-user/60 text-fg`:e.tone===`success`?`bg-bg-elevated border-accent/60 text-fg`:`bg-bg-elevated border-line text-fg`}`,children:[(0,G.jsx)(`div`,{className:`flex-1 break-words`,children:e.message}),e.action&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{e.action.onClick(),Rt(e.id)},className:`text-accent hover:underline whitespace-nowrap`,children:e.action.label}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Rt(e.id),className:`text-fg-muted hover:text-fg leading-none`,title:`dismiss`,children:`×`})]},e.id))})}var Bt=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20width='64'%20height='64'%20role='img'%20aria-label='Claude%20Recall'%3e%3ctitle%3eClaude%20Recall%20—%20Scrollback%20mark%20(dark%20bg)%3c/title%3e%3cg%20stroke='%23e7e9ee'%20stroke-width='3'%20stroke-linecap='round'%20fill='none'%3e%3cline%20x1='14'%20y1='16'%20x2='46'%20y2='16'/%3e%3cline%20x1='14'%20y1='24'%20x2='38'%20y2='24'/%3e%3c/g%3e%3cline%20x1='10'%20y1='32'%20x2='54'%20y2='32'%20stroke='%23f97316'%20stroke-width='5'%20stroke-linecap='round'/%3e%3cg%20stroke='%23e7e9ee'%20stroke-width='3'%20stroke-linecap='round'%20fill='none'%3e%3cline%20x1='14'%20y1='40'%20x2='42'%20y2='40'/%3e%3cline%20x1='14'%20y1='48'%20x2='36'%20y2='48'/%3e%3c/g%3e%3c/svg%3e`;function Vt({query:e,onQueryChange:t,matchCount:n,scope:r,onScopeChange:i,canScope:a,projectName:o,onOpenHelp:s,helpActive:c,onOpenStats:l,statsActive:u,onOpenThreads:d,threadsActive:f,onOpenGraph:p,graphActive:m,onOpenSuggestions:h,suggestionsActive:g,onOpenPatterns:_,patternsActive:v,onOpenShare:y,onGoHome:b,semanticMode:x,onSemanticModeChange:S,semanticAvailable:C}){let w=q({queryKey:[`stats`],queryFn:Z.stats,refetchInterval:3e4,refetchIntervalInBackground:!1,staleTime:1e4}).data,T=K(),[E,D]=(0,W.useState)(!1),O=async()=>{if(!E){D(!0);try{await T.invalidateQueries(),await T.refetchQueries({type:`active`}),Q({message:`Refreshed all data from the daemon`,tone:`success`,duration:1500})}catch(e){Q({message:`Refresh failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{D(!1)}}};return(0,G.jsxs)(`header`,{className:`flex items-center gap-5 px-5 py-3 border-b border-line bg-bg shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:b,className:`flex items-center gap-2.5 text-left hover:opacity-80 transition-opacity`,title:`Home — back to project list`,"aria-label":`Go to home`,children:[(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-9 w-9 rounded-md shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-base font-bold leading-none flex items-center gap-2`,children:(0,G.jsxs)(`span`,{children:[`Claude `,(0,G.jsx)(`span`,{className:`text-accent`,children:`Recall`})]})}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:`local · offline · yours`})]})]}),(0,G.jsx)(Nt,{}),(0,G.jsx)(Ht,{})]}),w&&(0,G.jsxs)(`div`,{className:`hidden md:flex items-center gap-5 text-xs text-fg-dim`,children:[(0,G.jsxs)(`div`,{title:`${bt(w.projects)} distinct cwds across ${bt(w.repos)} repos`,children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.repos)}),` repos`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.sessions)}),` sessions`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:bt(w.messages)}),` messages`]})]}),(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-end gap-3`,children:[a&&e&&(0,G.jsxs)(`div`,{className:`flex items-center text-xs border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(`all`),className:`px-3 py-1.5 transition-colors `+(r===`all`?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),children:`All projects`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(`project`),className:`px-3 py-1.5 transition-colors border-l border-line `+(r===`project`?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),title:o?`search only within ${o}`:void 0,children:[`In `,o??`project`]})]}),(0,G.jsxs)(`div`,{className:`relative w-full max-w-xl`,children:[(0,G.jsx)(`input`,{type:`search`,placeholder:`Search every session…`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-bg-elevated border border-line rounded-lg pl-10 pr-14 py-2 text-sm focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent placeholder:text-fg-muted`}),(0,G.jsxs)(`svg`,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-fg-muted`,fill:`none`,stroke:`currentColor`,strokeWidth:2,viewBox:`0 0 24 24`,children:[(0,G.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,G.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),!e&&(0,G.jsx)(`kbd`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-[10px] font-mono text-fg-muted border border-line rounded px-1.5 py-0.5`,children:`/`}),e&&n!=null&&(0,G.jsxs)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-fg-muted`,children:[n,` `,n===1?`match`:`matches`]})]}),C&&S&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>S(!x),className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(x?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Toggle semantic search — also matches sessions by AI-generated summary + keywords (v0.11)`,children:`Semantic`}),(0,G.jsx)(Et,{}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:E,className:`text-fg-muted hover:text-fg text-xs px-2 py-1 border border-line rounded-md disabled:opacity-60 disabled:cursor-wait`,title:`refresh all data from the daemon`,children:(0,G.jsx)(`span`,{className:`inline-block `+(E?`animate-spin`:`transition-transform`),"aria-hidden":`true`,children:`↻`})}),(0,G.jsx)(`button`,{type:`button`,onClick:d,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(f?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Threads — group sessions by intent (planning + children)`,children:`🧵 Threads`}),(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(m?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Cognitive Graph — Galaxy + Focus views over project sessions (v0.17)`,children:`🌌 Graph`}),h&&(0,G.jsx)(`button`,{type:`button`,onClick:h,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(g?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Suggestions Queue — review citation/skill/wiki suggestions inferred by L1–L4 (v0.18 Phase F)`,children:`📋 Queue`}),_&&(0,G.jsx)(`button`,{type:`button`,onClick:_,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(v?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Bug Patterns — recurring bugs across sessions, with linked fixes (v0.20 Phase H)`,children:`🐛 Patterns`}),(0,G.jsx)(`button`,{type:`button`,onClick:l,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(u?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`Cost & token dashboard (v0.10a)`,children:`📊 Stats`}),(0,G.jsx)(Ot,{}),y&&(0,G.jsx)(`button`,{type:`button`,onClick:y,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors text-fg-dim hover:text-fg border-line hover:border-accent/60`,title:`Share — pick what to share (Stats, Thread, Patterns, Session)`,children:`↗ Share`}),(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`text-xs px-2.5 py-1 border rounded-md font-medium transition-colors `+(c?`bg-accent text-bg border-accent`:`text-fg-dim hover:text-fg border-line hover:border-accent/60`),title:`open Command Center — docs, CLI reference, keyboard shortcuts (press ?)`,children:`Help`})]})]})}function Ht(){let{data:e}=q({queryKey:[`health`],queryFn:()=>Z.health(),staleTime:300*1e3});return e?.version?(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-fg-muted border border-line rounded px-1.5 py-0.5 leading-none`,title:`Claude Recall daemon version`,children:[`v`,e.version]}):null}function Ut(){return q({queryKey:[`auto-title-config`],queryFn:()=>Z.getAutoTitleConfig()})}function Wt(){let e=K();return J({mutationFn:e=>Z.putAutoTitleConfig(e),onSuccess:()=>void e.invalidateQueries({queryKey:[`auto-title-config`]})})}var Gt=`claude-recall:dismissed-autotitle-banner-v1`;function Kt(){try{return window.localStorage.getItem(Gt)===`true`}catch{return!1}}function qt(){let{data:e,isLoading:t}=Ut(),[n,r]=(0,W.useState)(Kt),[i,a]=(0,W.useState)(!1);if(t||!e||e.agentEnabled!==!1||n)return null;let o=()=>{r(!0);try{window.localStorage.setItem(Gt,`true`)}catch{}},s=async()=>{try{await navigator.clipboard.writeText(`recall semantic verify-spawn`),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}};return(0,G.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 px-5 py-2.5 bg-bg-elevated border-b border-line text-xs`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-sm leading-none mt-0.5`,children:`🔇`}),(0,G.jsxs)(`div`,{className:`flex-1 leading-relaxed`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`Agent titles paused.`}),` `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`New sessions get heuristic titles only. Run`}),` `,(0,G.jsx)(`button`,{type:`button`,onClick:()=>void s(),className:`font-mono text-[11px] px-1.5 py-0.5 bg-bg border border-line rounded hover:border-accent hover:text-accent transition-colors align-baseline`,title:i?`copied`:`click to copy`,children:`recall semantic verify-spawn`}),i&&(0,G.jsx)(`span`,{className:`text-accent text-[11px] ml-1`,children:`✓ copied`}),` `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`in your terminal first, then re-enable in`}),` `,(0,G.jsx)(`code`,{className:`text-[11px] text-fg`,children:`~/.recall/config.json`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-fg-muted hover:text-fg shrink-0 leading-none px-1`,"aria-label":`dismiss`,title:`dismiss`,children:`✕`})]})}var Jt=[{kind:`stats`,emoji:`📊`,name:`Stats`,blurb:`Activity for a time range — cost, top model, top project, sessions.`,status:`live`},{kind:`thread`,emoji:`🧵`,name:`Thread`,blurb:`Multi-session story — N sessions, total cost, project, span.`,status:`live`},{kind:`patterns`,emoji:`🐛`,name:`Patterns`,blurb:`Recurring bug clusters — top 3 by occurrence, resolved rate.`,status:`live`},{kind:`graph`,emoji:`🌐`,name:`Cog-graph`,blurb:`Snapshot of your skill / topic graph. Only Claude Recall has this.`,status:`soon`},{kind:`session`,emoji:`🖥️`,name:`Session`,blurb:`One-session receipt — prompt, cost, files, model.`,status:`live`}];function Yt({onPick:e,onClose:t}){return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[600px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mb-4`,children:`Pick what to share. Each option produces a downloadable card with your handle and the Claude Recall mark.`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:Jt.map(t=>{let n=t.status!==`live`;return(0,G.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>e(t.kind),className:`flex items-start gap-3 text-left p-3 rounded border transition-colors `+(n?`border-line bg-bg/40 opacity-55 cursor-not-allowed`:`border-line hover:border-accent hover:bg-accent/5`),children:[(0,G.jsx)(`span`,{className:`text-2xl leading-none mt-0.5`,children:t.emoji}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.name}),n&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-fg-muted border border-line rounded px-1 py-0.5`,children:`coming soon`})]}),(0,G.jsx)(`span`,{className:`block text-xs text-fg-muted mt-0.5`,children:t.blurb})]})]},t.kind)})})]})})}async function Xt(e){let t=new File([e.blob],e.fileName,{type:`image/png`}),n=navigator;if(typeof navigator.share==`function`&&n.canShare?.({files:[t]}))try{return await navigator.share({title:e.title,text:e.text,url:e.url,files:[t]}),`shared`}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return`cancelled`}if(typeof URL.createObjectURL==`function`){let t=URL.createObjectURL(e.blob),n=document.createElement(`a`);return n.href=t,n.download=e.fileName,n.click(),URL.revokeObjectURL(t),`download`}return`unsupported`}function Zt(){return typeof navigator.share==`function`}function Qt(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}async function $t(e){try{let t=window.ClipboardItem;if(!t||!navigator.clipboard?.write)return!1;let n=new t({"image/png":e});return await navigator.clipboard.write([n]),!0}catch{return!1}}var en=`https://clauderecall.com`;function tn(){return typeof window<`u`&&window.RECALL_SHARE_API?window.RECALL_SHARE_API.replace(/\/+$/,``):en}async function nn(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`blob → base64 failed`)),r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`unexpected reader result`));return}let i=e.indexOf(`,`);t(i>=0?e.slice(i+1):e)},r.readAsDataURL(e)})}async function rn(e){let t=await nn(e.blob),n=await fetch(`${tn()}/api/cards`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,title:e.title,description:e.description,width:e.width??1080,height:e.height??1350,pngBase64:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`upload failed (${n.status}): ${e||n.statusText}`)}let r=await n.json();return{id:r.id,url:r.url,imageUrl:r.image_url,expiresAt:r.expires_at}}function an(e,t,n){let r=encodeURIComponent(t),i=encodeURIComponent(n);switch(e){case`x`:return`https://twitter.com/intent/tweet?text=${i}&url=${r}`;case`linkedin`:return`https://www.linkedin.com/sharing/share-offsite/?url=${r}`;case`reddit`:return`https://www.reddit.com/submit?url=${r}&title=${i}`;case`facebook`:return`https://www.facebook.com/sharer/sharer.php?u=${r}`;case`threads`:return`https://www.threads.net/intent/post?text=${i}%20${r}`;case`whatsapp`:return`https://wa.me/?text=${i}%20${r}`}}var on=[{key:`x`,label:`X`,emoji:`𝕏`},{key:`linkedin`,label:`LinkedIn`,emoji:`in`},{key:`reddit`,label:`Reddit`,emoji:`r/`},{key:`facebook`,label:`Facebook`,emoji:`f`},{key:`threads`,label:`Threads`,emoji:`@`},{key:`whatsapp`,label:`WhatsApp`,emoji:`✉`}];function sn({getBlob:e,kind:t,title:n,description:r,caption:i,disabled:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useCallback)(async()=>{if(!o){s(!0);try{let i=await e();if(!i){Q({message:`Card not ready yet — wait for the preview.`,tone:`error`});return}let a=await rn({kind:t,title:n,description:r,blob:i});l(a);try{await navigator.clipboard.writeText(a.url),Q({message:`Link copied — preview ready on social platforms`,tone:`success`})}catch{Q({message:`Link ready (clipboard not available)`,tone:`info`})}}catch(e){console.error(`[SocialShareRow] upload failed:`,e),Q({message:`Could not create shareable link: `+(e instanceof Error?e.message:`unknown error`),tone:`error`})}finally{s(!1)}}},[e,t,n,r,o]),d=(0,W.useCallback)(async()=>{if(c)try{await navigator.clipboard.writeText(c.url),Q({message:`Link copied`,tone:`success`})}catch{Q({message:`Clipboard not available`,tone:`error`})}},[c]);return c?(0,G.jsxs)(`div`,{className:`mt-3 border border-line rounded p-3 bg-bg/40 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`shareable link`}),(0,G.jsxs)(`span`,{className:`ml-auto text-fg-dim normal-case tracking-normal`,children:[`expires `,new Date(c.expiresAt).toLocaleDateString(`en-US`)]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void d(),className:`w-full text-left text-xs text-accent font-mono break-all hover:underline`,title:`Click to copy`,children:c.url}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-2 pt-2`,children:on.map(e=>(0,G.jsxs)(`a`,{href:an(e.key,c.url,i),target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-1.5 px-2 py-2 rounded border border-line text-fg-muted text-xs font-medium hover:text-fg hover:border-accent/60 transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm leading-none`,children:e.emoji}),(0,G.jsx)(`span`,{children:e.label})]},e.key))}),(0,G.jsx)(`p`,{className:`text-[10px] text-fg-muted pt-1`,children:`TikTok and Instagram have no web share intent — use Save image and upload manually there.`})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>void u(),disabled:a||o,className:`w-full px-4 py-2 mt-3 rounded border border-line text-fg-muted text-xs font-medium hover:text-fg hover:border-accent/60 transition-colors disabled:opacity-50`,title:`Upload the card and get a public link with Open Graph preview`,children:o?`Generating link…`:`🔗 Get shareable link (with social preview)`})}var cn=`modulepreload`,ln=function(e,t){return new URL(e,t).href},un={},dn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ln(t,n),t in un)return;un[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:cn,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fn=[{key:`7d`,label:`Last 7 days`},{key:`30d`,label:`Last 30 days`},{key:`all`,label:`All time`}],pn=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function mn(e){return e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).trim().slice(0,120)}function hn(e){if(!e)return``;let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function gn(e){return e===`7d`?`Last 7 days`:e===`30d`?`Last 30 days`:`All time`}function _n({initialRange:e=`30d`,onClose:t}){let[n,r]=(0,W.useState)(e),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!0),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(),f=q({queryKey:[`stats-overview`,n],queryFn:()=>Z.getOverviewStats(n),staleTime:6e4}),p=(0,W.useMemo)(()=>{let e=f.data,t=e?.display?.dollars??`$—`,r=e?.totalSessions??0,a=(e?.inputTokens??0)+(e?.outputTokens??0),o=e?.cacheReadTokens??0,s=e?.byModel?.[0]?.modelLabel??null,c=null;if(e?.topRepos&&e.topRepos.length>0){let t=e.topRepos.reduce((e,t)=>e+(t.cost?.cents??0),0)||1,n=e.topRepos[0],r=hn(n.project);c=pn.some(e=>e.test(r))?null:{name:r||`unknown`,sharePct:Math.round((n.cost?.cents??0)/t*100)}}let l=(e?.daily??[]).filter(e=>e.tokens>0).length;return{rangeLabel:gn(n),scopeLabel:`All projects`,costDollars:t,totalSessions:r,workingTokens:a,cachedTokens:o,topModel:s,topProject:c,peakHours:null,activeDays:l,verdict:mn(i)}},[f.data,n,i]),m=(0,W.useCallback)(async()=>{s(!0),l(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-C3F6ixrp.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./stats-Db9NRYik.js`),__vite__mapDeps([0,1]),import.meta.url),[n,r,i,a]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),o=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:a,weight:700,style:`normal`}],c=await e(t.render(p),{width:1080,height:1350,fonts:o}),d=u.current;if(!d)return;d.width=1080,d.height=1350;let f=d.getContext(`2d`);if(!f)return;let m=new Image;m.onload=()=>{f.drawImage(m,0,0),s(!1)},m.onerror=()=>{l(`Failed to render card image`),s(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(c)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareWrappedModal] renderPreview failed:`,e),l(t),s(!1)}},[p]);(0,W.useEffect)(()=>(clearTimeout(d.current),d.current=setTimeout(m,300),()=>clearTimeout(d.current)),[m]);let h=`claude-recall-stats-${n}.png`,g=(0,W.useCallback)(e=>{let t=u.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),_=(0,W.useCallback)(()=>new Promise(e=>{let t=u.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),v=(0,W.useCallback)(()=>{g(async e=>{let t=await Xt({fileName:h,blob:e,title:`Claude Recall — stats`,text:`My Claude Code stats — ${gn(n)} via Claude Recall`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[g,h,n]),y=(0,W.useCallback)(()=>{g(e=>{Qt(e,h),Q({message:`Saved to Downloads`,tone:`success`})})},[g,h]),b=(0,W.useCallback)(()=>{g(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[g]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Stats`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:u,className:`w-full h-full`,style:{display:o||c?`none`:`block`}}),o&&!c&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),c&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:c})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`range`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:fn.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.key),className:`text-xs px-2 py-1.5 rounded border transition-colors `+(n===e.key?`border-accent bg-accent/10 text-accent font-semibold`:`border-line text-fg-muted hover:text-fg`),children:e.label},e.key))})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:o,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:o,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:o,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:_,kind:`stats`,title:`Claude Code stats — ${gn(n)}`,description:`${p.costDollars} on ${p.totalSessions.toLocaleString(`en-US`)} sessions in ${p.scopeLabel.toLowerCase()}.`,caption:`My Claude Code stats — ${p.costDollars} via Claude Recall`,disabled:o})]})})}var vn=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function yn(e){if(!e)return``;let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n>=0?t.slice(n+1):t}function bn(e,t=80){if(!e)return null;let n=e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).trim();if(!n||vn.some(e=>e.test(n)))return null;let r=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).replace(/\s+/g,` `).trim();return r?r.length<=t?r:r.slice(0,t-1).trimEnd()+`…`:null}function xn(e){for(let t of[e.alias,e.auto_title,e.first_user_message]){let e=bn(t,70);if(e)return e}return e.session_id.slice(0,8)}function Sn({threadId:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(!0),[o,s]=(0,W.useState)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(),u=q({queryKey:[`thread-detail`,e],queryFn:()=>Z.getThread(e),staleTime:3e4}),d=st({queries:(0,W.useMemo)(()=>(u.data?.thread?.edges??[]).slice(0,24).map(e=>e.session_id),[u.data]).map(e=>({queryKey:[`session-stats`,e],queryFn:()=>Z.getSessionStats(e),staleTime:6e4}))}).reduce((e,t)=>e+(t.data?.cost?.cents??0),0),f=d>0?`$${(d/100).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:null,p=(0,W.useMemo)(()=>{let e=u.data?.thread,t=e?.edges??[],r=new Set,i=[];for(let e of t)r.has(e.session_id)||(r.add(e.session_id),i.push({id:e.session_id,title:xn(e),project:e.project?yn(e.project):null}));let a=t.filter(e=>!!e.parent_session_id).map(e=>({childId:e.session_id,parentId:e.parent_session_id})),o=t.filter(e=>e.role===`origin`||!e.parent_session_id).map(e=>e.session_id),s=bn(e?.name)??`Untitled thread`,c=e?.session_count??i.length,l=[`${c.toLocaleString(`en-US`)} ${c===1?`session`:`sessions`}`];return f&&l.push(f),(e?.project_count??0)>1?l.push(`cross-project`):e?.project&&l.push(yn(e.project)),{threadName:s,metaLine:l.join(` · `),sessions:i,edges:a,rootIds:o,verdict:bn(n,120)??``}},[u.data,f,n]),m=(0,W.useCallback)(async()=>{a(!0),s(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-C3F6ixrp.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./thread-4KmPh02n.js`),__vite__mapDeps([2,1]),import.meta.url),[n,r,i,o]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),l=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:o,weight:700,style:`normal`}],u=await e(t.render(p),{width:1080,height:1350,fonts:l}),d=c.current;if(!d)return;d.width=1080*2,d.height=1350*2;let f=d.getContext(`2d`);if(!f)return;f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`;let m=new Image;m.onload=()=>{f.drawImage(m,0,0,d.width,d.height),a(!1)},m.onerror=()=>{s(`Failed to render card image`),a(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(u)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareThreadModal] renderPreview failed:`,e),s(t),a(!1)}},[p]);(0,W.useEffect)(()=>(clearTimeout(l.current),l.current=setTimeout(m,300),()=>clearTimeout(l.current)),[m]);let h=`claude-recall-thread-${e.slice(0,8)}.png`,g=(0,W.useCallback)(e=>{let t=c.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),_=(0,W.useCallback)(()=>new Promise(e=>{let t=c.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),v=(0,W.useCallback)(()=>{g(async e=>{let t=await Xt({fileName:h,blob:e,title:`Claude Recall — thread`,text:`${p.threadName} · ${p.metaLine}`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[g,h,p.threadName,p.metaLine]),y=(0,W.useCallback)(()=>{g(e=>{Qt(e,h),Q({message:`Saved to Downloads`,tone:`success`})})},[g,h]),b=(0,W.useCallback)(()=>{g(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[g]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Thread`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:c,className:`w-full h-full`,style:{display:i||o?`none`:`block`}}),i&&!o&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),o&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:o})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:i,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:i,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:i,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:_,kind:`thread`,title:p.threadName,description:p.metaLine,caption:`${p.threadName} — built with Claude Recall`,disabled:i})]})})}function Cn({heroImage:e,scopeLabel:t,onClose:n}){let[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(),d=q({queryKey:[`bug-patterns-graph`,`share`],queryFn:()=>Z.bugPatternsGraph(void 0,!0),staleTime:6e4}),f=(0,W.useMemo)(()=>{let n=d.data?.totals,i=n?.recurring_count??d.data?.clusters?.length??0,a=n?.resolved_count??0,o=n?.session_count??0,s=e=>e.toLocaleString(`en-US`),c=[t];return c.push(`${s(i)} ${i===1?`pattern`:`patterns`}`),a>0&&c.push(`${s(a)} resolved`),o>0&&c.push(`${s(o)} ${o===1?`session`:`sessions`}`),{heroImage:e,metaLine:c.join(` · `),verdict:r.slice(0,120)}},[d.data,e,r,t]),p=(0,W.useCallback)(async()=>{o(!0),c(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-C3F6ixrp.js`);return{default:e}},[],import.meta.url)).default,t=await dn(()=>import(`./patterns-Dsv_eCME.js`),__vite__mapDeps([3,1]),import.meta.url),[n,r,i,a]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),s=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:r,weight:700,style:`normal`},{name:`JetBrains Mono`,data:i,weight:400,style:`normal`},{name:`JetBrains Mono`,data:a,weight:700,style:`normal`}],u=await e(t.render(f),{width:1080,height:1350,fonts:s}),d=l.current;if(!d)return;d.width=1080*2,d.height=1350*2;let p=d.getContext(`2d`);if(!p)return;p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`;let m=new Image;m.onload=()=>{p.drawImage(m,0,0,d.width,d.height),o(!1)},m.onerror=()=>{c(`Failed to render card image`),o(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(u)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[SharePatternsModal] renderPreview failed:`,e),c(t),o(!1)}},[f]);(0,W.useEffect)(()=>(clearTimeout(u.current),u.current=setTimeout(p,300),()=>clearTimeout(u.current)),[p]);let m=`claude-recall-patterns.png`,h=(0,W.useCallback)(e=>{let t=l.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),g=(0,W.useCallback)(()=>new Promise(e=>{let t=l.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),_=(0,W.useCallback)(()=>{h(async e=>{let t=await Xt({fileName:m,blob:e,title:`Claude Recall — patterns`,text:f.metaLine,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[h,f.metaLine]),v=(0,W.useCallback)(()=>{h(e=>{Qt(e,m),Q({message:`Saved to Downloads`,tone:`success`})})},[h]),y=(0,W.useCallback)(()=>{h(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[h]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Patterns`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:l,className:`w-full h-full`,style:{display:a||s?`none`:`block`}}),a&&!s&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),s&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:s})]}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:_,disabled:a,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:v,disabled:a,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:y,disabled:a,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:g,kind:`patterns`,title:`Recurring patterns`,description:f.metaLine,caption:`${f.metaLine} — tracked with Claude Recall`,disabled:a})]})})}function wn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=wn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function $(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=wn(e))&&(r&&(r+=` `),r+=t);return r}function Tn(){return q({queryKey:[`tags`],queryFn:Z.allTags,staleTime:1e4})}function En(e){e.invalidateQueries({queryKey:[`tags`]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`search`]})}function Dn(){let e=K();return J({mutationFn:({sessionId:e,tag:t})=>Z.addSessionTag(e,t),onSuccess:()=>En(e)})}function On(){let e=K();return J({mutationFn:({sessionId:e,tag:t})=>Z.removeSessionTag(e,t),onSuccess:()=>En(e)})}var kn=new Set;function An(){for(let e of kn)e()}function jn(){let e=window.location.hash.replace(/^#/,``);if(!e)return{project:null,session:null,msg:null,q:``,view:null,helpSection:null,compareWith:null,col:null,thread:null};let t=new URLSearchParams(e),n=t.get(`view`);return{project:t.get(`p`),session:t.get(`s`),msg:t.get(`m`),q:t.get(`q`)??``,view:n===`help`?`help`:n===`stats`?`stats`:n===`auto-rules`?`auto-rules`:n===`threads`?`threads`:n===`graph`?`graph`:n===`suggestions`?`suggestions`:n===`patterns`?`patterns`:null,helpSection:t.get(`h`),compareWith:t.get(`cmp`),col:t.get(`col`),thread:t.get(`t`)}}function Mn(e){let t=new URLSearchParams;e.project&&t.set(`p`,e.project),e.session&&t.set(`s`,e.session),e.msg&&t.set(`m`,e.msg),e.q&&t.set(`q`,e.q),e.view&&t.set(`view`,e.view),e.helpSection&&t.set(`h`,e.helpSection),e.compareWith&&t.set(`cmp`,e.compareWith),e.col&&t.set(`col`,e.col),e.thread&&t.set(`t`,e.thread);let n=t.toString();return n?`#${n}`:``}function Nn(){let[e,t]=(0,W.useState)(jn);return(0,W.useEffect)(()=>{let e=()=>t(jn());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,W.useEffect)(()=>{let e=()=>t(jn());return kn.add(e),()=>{kn.delete(e)}},[]),[e,(0,W.useCallback)(e=>{let n={...jn(),...e},r=Mn(n);window.location.hash!==r&&window.history.replaceState(null,``,r||window.location.pathname),t(n),An()},[])]}function Pn(e,t,n){return Math.max(t,Math.min(n,e))}function Fn(e,t){try{let n=localStorage.getItem(e);if(n==null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}}function In(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}var Ln=new Map;function Rn(e){Ln.get(e)?.forEach(e=>e())}function zn(e){let t=e.minWidth??240,n=e.maxWidth??640,r=e.collapsedWidth??36,i=`${e.storageKey}:width`,a=`${e.storageKey}:collapsed`,[o,s]=(0,W.useState)(()=>Pn(Fn(i,e.defaultWidth),t,n)),[c,l]=(0,W.useState)(()=>In(a));(0,W.useEffect)(()=>{let r=Ln.get(e.storageKey);r||(r=new Set,Ln.set(e.storageKey,r));let o=()=>{s(Pn(Fn(i,e.defaultWidth),t,n)),l(In(a))};return r.add(o),()=>{r?.delete(o)}},[e.storageKey,i,a,e.defaultWidth,t,n]),(0,W.useEffect)(()=>{let t=t=>{(t.key===i||t.key===a)&&Rn(e.storageKey)};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[i,a,e.storageKey]);let u=(0,W.useCallback)(r=>{let a=Pn(r,t,n);s(a);try{localStorage.setItem(i,String(a))}catch{}Rn(e.storageKey)},[t,n,i,e.storageKey]),d=(0,W.useCallback)(t=>{l(t);try{localStorage.setItem(a,t?`1`:`0`)}catch{}Rn(e.storageKey)},[a,e.storageKey]),f=(0,W.useCallback)((e,t)=>{let n=n=>{u(t+(n.clientX-e))},r=()=>{window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),document.body.style.cursor=``,document.body.style.userSelect=``};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[u]),p=(0,W.useCallback)(()=>{d(!c)},[d,c]);return{width:o,effectiveWidth:c?r:o,collapsed:c,minWidth:t,maxWidth:n,collapsedWidth:r,setWidth:u,setCollapsed:d,toggleCollapsed:p,beginResize:f}}function Bn(e){e.invalidateQueries({queryKey:[`collections`]}),e.invalidateQueries({queryKey:[`collection`]}),e.invalidateQueries({queryKey:[`sessionCollections`]}),e.invalidateQueries({queryKey:[`sessions`]})}function Vn(e=!1){return q({queryKey:[`collections`,{archived:e}],queryFn:()=>Z.listCollections(e),staleTime:5e3})}function Hn(e){return q({queryKey:[`collection`,e],queryFn:()=>Z.getCollection(e),enabled:!!e,staleTime:3e3})}function Un(e){return q({queryKey:[`sessionCollections`,e],queryFn:()=>Z.sessionCollections(e),enabled:!!e,staleTime:3e3})}function Wn(){let e=K();return J({mutationFn:e=>Z.createCollection(e),onSuccess:()=>Bn(e)})}function Gn(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchCollection(e,t),onSuccess:()=>Bn(e)})}function Kn(){let e=K();return J({mutationFn:e=>Z.archiveCollection(e),onSuccess:()=>Bn(e)})}function qn(){let e=K();return J({mutationFn:e=>Z.restoreCollection(e),onSuccess:()=>Bn(e)})}function Jn(){let e=K();return J({mutationFn:({collectionId:e,sessionId:t,note:n})=>Z.addSessionToCollection(e,t,n),onSuccess:()=>Bn(e)})}function Yn(){let e=K();return J({mutationFn:({collectionId:e,sessionId:t})=>Z.removeSessionFromCollection(e,t),onSuccess:()=>Bn(e)})}function Xn(e){if(!e||e.length===0)return[];let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0,total_session_count:n.session_count});let n=[];for(let e of t.values()){let r=e.parent_id?t.get(e.parent_id):null;r?r.children.push(e):n.push(e)}let r=(e,t)=>{e.sort((e,t)=>e.sort_key===t.sort_key?e.name.toLowerCase().localeCompare(t.name.toLowerCase()):e.sort_key.localeCompare(t.sort_key));for(let n of e)n.depth=t,r(n.children,t+1)};r(n,0);let i=e=>{let t=e.session_count;for(let n of e.children)t+=i(n);return e.total_session_count=t,t};for(let e of n)i(e);return n}function Zn(e,t){let n=[],r=e=>{for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)};return r(e),n}function Qn(e=!1){let t=Vn(e),n=(0,W.useMemo)(()=>Xn(t.data?.collections),[t.data]);return{...t,tree:n}}function $n(e){return[e.id,...e.children.flatMap($n)]}var er=[{value:``,label:`default`},{value:`#f97316`,label:`orange`},{value:`#eab308`,label:`yellow`},{value:`#10b981`,label:`green`},{value:`#06b6d4`,label:`cyan`},{value:`#3b82f6`,label:`blue`},{value:`#a855f7`,label:`purple`},{value:`#ec4899`,label:`pink`},{value:`#64748b`,label:`slate`}],tr=`📂.📁.🗂.📦.🗃.🛠.🔧.🧪.🔬.⚗️.🏗.🎨.🎯.🚀.🧩.🧠.💡.📝.📊.📈.🐛.🔒.🔑.⚡.🔥.❤️.⭐.✨.🌿.🏠`.split(`.`);function nr({mode:e,existing:t,initialParentId:n,pinnedSessionId:r,onClose:i,onCreated:a,onUpdated:o}){let[s,c]=(0,W.useState)(t?.name??``),[l,u]=(0,W.useState)(t?.description??``),[d,f]=(0,W.useState)(t?.icon??`📂`),[p,m]=(0,W.useState)(t?.color??``),[h,g]=(0,W.useState)(e===`rename`?t?.parent_id??null:n??null),[_,v]=(0,W.useState)(null),y=(0,W.useRef)(null),b=Qn(!1),x=Wn(),S=Gn();(0,W.useEffect)(()=>{requestAnimationFrame(()=>y.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let C=(0,W.useMemo)(()=>{let n=new Set(b.tree.flatMap($n)),r=Zn(b.tree,n);if(e===`rename`&&t){let e=new Set,n=t=>{e.add(t);for(let e of r)e.parent_id===t&&n(e.id)};return n(t.id),r.filter(t=>!e.has(t.id))}return r},[b.tree,e,t]),w=async()=>{let n=s.trim();if(!n){v(`name required`);return}try{if(e===`create`){let e=await x.mutateAsync({name:n,description:l.trim()||null,icon:d||null,color:p||null,parent_id:h});if(r)try{await fetch(`/api/collections/${encodeURIComponent(e.id)}/members`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({session_id:r})})}catch{}a?.(e)}else if(t){let e=await S.mutateAsync({id:t.id,patch:{name:n,description:l.trim()||null,icon:d||null,color:p||null,parent_id:h}});o?.(e)}i()}catch(e){v(e.message)}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:i,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[440px] max-w-[90vw] p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e===`create`?`New collection`:`Rename collection`}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative flex items-center gap-2 px-3 py-2 mb-4 rounded border border-line bg-bg`,style:{background:p?`linear-gradient(90deg, ${p}1a 0%, transparent 50%)`:void 0},children:[p&&(0,G.jsx)(`span`,{className:`absolute top-1 bottom-1 left-0 w-[3px] rounded-full`,style:{background:p},"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`text-base`,children:d||`📂`}),(0,G.jsx)(`span`,{className:`text-sm text-fg truncate flex-1`,children:s.trim()||(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(name)`})}),(0,G.jsx)(`span`,{className:`text-[10px] font-medium`,style:{color:p||void 0},children:`preview`})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Name`}),(0,G.jsx)(`input`,{ref:y,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()},maxLength:120,placeholder:`e.g. Auth refactor`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm text-fg focus:outline-none focus:border-accent`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Description (optional)`}),(0,G.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:2,maxLength:500,placeholder:`Short summary — shows on hover`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm text-fg focus:outline-none focus:border-accent resize-none`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Icon`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:tr.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:$(`w-7 h-7 rounded flex items-center justify-center text-sm hover:bg-bg-hover`,d===e&&`bg-accent/20 border border-accent`),title:e,children:e},e))}),(0,G.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value.slice(0,4)),className:`mt-1 w-full bg-bg border border-line rounded px-2 py-1 text-sm text-fg focus:outline-none focus:border-accent`,placeholder:`or paste your own`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Color`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:er.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(e.value),className:$(`w-7 h-7 rounded border transition-colors`,p===e.value?`border-accent ring-2 ring-accent/40`:`border-line hover:border-fg-muted`),style:{background:e.value||`transparent`},title:e.label},e.value||`default`))})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,children:`Parent collection`}),(0,G.jsxs)(`select`,{value:h??``,onChange:e=>g(e.target.value||null),className:`w-full bg-bg border border-line rounded px-2 py-2 text-sm text-fg focus:outline-none focus:border-accent`,children:[(0,G.jsx)(`option`,{value:``,children:`— no parent (root) —`}),C.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[` `.repeat(e.depth),e.icon??`📂`,` `,e.name]},e.id))]}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-muted leading-snug`,children:C.length===0?`No other collections yet — this one will live at the root. Once you have two or more, you can nest them.`:`Parent = another collection, not a repo. Collections cut across projects — one collection can hold sessions from many repos.`})]}),_&&(0,G.jsx)(`div`,{className:`text-xs text-role-user bg-role-user/10 border border-role-user/30 rounded px-2 py-1.5`,children:_}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`px-3 py-1.5 text-sm text-fg-dim border border-line rounded hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:w,disabled:!s.trim()||x.isPending||S.isPending,className:`px-4 py-1.5 text-sm bg-accent text-bg rounded font-medium hover:bg-accent/90 disabled:opacity-50`,children:e===`create`?`Create`:`Save`})]})]})]})})}function rr(e){e.invalidateQueries({queryKey:[`autoRules`]}),e.invalidateQueries({queryKey:[`autoSuggestions`]}),e.invalidateQueries({queryKey:[`autoCollectionIds`]}),e.invalidateQueries({queryKey:[`collections`]}),e.invalidateQueries({queryKey:[`collection`]}),e.invalidateQueries({queryKey:[`sessionCollections`]}),e.invalidateQueries({queryKey:[`sessions`]})}function ir(){return q({queryKey:[`autoRules`],queryFn:()=>Z.listAutoRules(),staleTime:5e3})}function ar(e=!1){return q({queryKey:[`autoSuggestions`,{dismissed:e}],queryFn:()=>Z.listAutoSuggestions(e),staleTime:3e4})}function or(){return q({queryKey:[`autoCollectionIds`],queryFn:()=>Z.listAutoCollectionIds(),staleTime:3e4})}function sr(){let e=K();return J({mutationFn:e=>Z.createAutoRule(e),onSuccess:()=>rr(e)})}function cr(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchAutoRule(e,t),onSuccess:()=>rr(e)})}function lr(){let e=K();return J({mutationFn:e=>Z.deleteAutoRule(e),onSuccess:()=>rr(e)})}function ur(){let e=K();return J({mutationFn:e=>Z.acceptAutoSuggestion(e),onSuccess:()=>rr(e)})}function dr(){let e=K();return J({mutationFn:e=>Z.dismissAutoSuggestion(e),onSuccess:()=>rr(e)})}function fr(){let e=K();return J({mutationFn:()=>Z.detectAutoSuggestionsNow(),onSuccess:()=>rr(e)})}function pr(e,t=!0){return q({queryKey:[`autoSuggestionPreview`,e],queryFn:()=>Z.previewAutoSuggestion(e,3),enabled:!!e&&t,staleTime:6e4})}function mr(){let{data:e,isLoading:t}=ar(),[,n]=Nn(),r=e?.suggestions??[];return t||r.length===0?null:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n({view:`auto-rules`}),className:`mx-2 my-1 w-[calc(100%-1rem)] flex items-center justify-between gap-2 rounded border border-accent/30 bg-accent/5 px-2 py-1 text-[11px] text-fg-muted hover:bg-accent/10 hover:text-accent`,title:`Open Auto-rules to review suggestions`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[`💡 `,r.length,` auto-collection`,` `,r.length===1?`suggestion`:`suggestions`,` pending`]}),(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`Review →`})]})}var hr=`application/x-recall-collection`,gr=`application/x-recall-session`;function _r({selectedCollection:e,onSelect:t,onCreateCollection:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(()=>{try{return localStorage.getItem(`recall.collectionsPaneOpen`)===`1`}catch{return!1}});(0,W.useEffect)(()=>{try{localStorage.setItem(`recall.collectionsPaneOpen`,a?`1`:`0`)}catch{}},[a]);let[s,c]=(0,W.useState)(()=>new Set),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),{tree:h,isLoading:g,isError:_,error:v,data:y}=Qn(r),b=Kn(),x=qn(),S=Gn(),C=Jn(),[,w]=Nn(),T=or(),E=(0,W.useMemo)(()=>new Set(T.data?.auto_collection_ids??[]),[T.data]),[D,O]=(0,W.useState)(null),[k,A]=(0,W.useState)(null),j=(0,W.useRef)(new Map),M=(0,W.useCallback)(e=>{let t=j.current.get(e);t&&(window.clearTimeout(t),j.current.delete(e))},[]),ee=(0,W.useCallback)(e=>{if(s.has(e)||j.current.has(e))return;let t=window.setTimeout(()=>{c(t=>{let n=new Set(t);return n.add(e),n}),j.current.delete(e)},450);j.current.set(e,t)},[s]);(0,W.useEffect)(()=>()=>{for(let e of j.current.values())window.clearTimeout(e);j.current.clear()},[]);let N=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(!y||N.current)return;let e=new Set;for(let t of h)e.add(t.id);c(e),N.current=!0},[y,h]);let te=(0,W.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=(0,W.useCallback)((e,t)=>{t.preventDefault(),m({id:e,x:t.clientX,y:t.clientY})},[]);(0,W.useEffect)(()=>{if(!p)return;let e=()=>m(null),t=e=>{e.key===`Escape`&&m(null)};return window.addEventListener(`click`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`keydown`,t)}},[p]);let F=(0,W.useMemo)(()=>{let e=new Map,t=n=>{for(let r of n)e.set(r.id,r),t(r.children)};return t(h),e},[h]),I=e?F.get(e)??null:null,L=async(e,t)=>{if(!e||e===t)return;let n=F.get(e),r=F.get(t);if(!n||!r||n.parent_id!==r.parent_id)return;let i=n.parent_id?F.get(n.parent_id)?.children:h;if(!i)return;let a=[...i].sort((e,t)=>e.sort_key.localeCompare(t.sort_key)),o=a.findIndex(e=>e.id===t);if(o===-1)return;let s=a[o-1]?.sort_key??``,c=a[o].sort_key,l=br(s,c);try{await S.mutateAsync({id:e,patch:{sort_key:l}})}catch(e){console.error(`reorder failed`,e)}},R=async(e,t)=>{let n=F.get(t);try{let r=await C.mutateAsync({collectionId:t,sessionId:e});c(e=>{let n=new Set(e);return n.add(t),n});let i=n?.name??`collection`;A(r.added?`Added session to "${i}"`:`Already in "${i}"`),window.setTimeout(()=>A(null),2600)}catch(e){console.error(`add session via drop failed`,e),A(`Failed: ${e.message.slice(0,80)}`),window.setTimeout(()=>A(null),3500)}},z=()=>w({view:`help`,helpSection:`taxonomy`});return(0,G.jsxs)(`div`,{className:`border-t border-line mt-2`,children:[(0,G.jsxs)(`div`,{className:`pane-header flex items-center justify-between`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 hover:text-accent`,title:a?`collapse Collections`:`expand Collections`,"aria-expanded":a,children:[(0,G.jsx)(`span`,{className:$(`inline-block text-[10px] text-fg-muted transition-transform`,a?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{children:`📂 Collections`}),(0,G.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),z()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),z())},className:`text-xs font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent cursor-pointer`,title:`Collection vs Tag vs Project — what's the difference?`,children:`(?)`})]}),(0,G.jsxs)(`span`,{className:$(`flex items-center gap-1.5`,!a&&`hidden`),children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>w({view:`auto-rules`}),className:`text-xs font-medium normal-case tracking-normal px-2 py-1 rounded border border-line text-fg-muted hover:text-accent hover:border-accent/60 hover:bg-accent/5`,title:`Auto-collections — rules that group sessions automatically by repo / tag / plan file`,children:`⚙ Auto-rules`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs font-medium normal-case tracking-normal px-2 py-1 rounded bg-accent/10 text-accent hover:bg-accent/20`,title:`new collection (c)`,"data-collections-focus":!0,children:`+ New`})]})]}),a&&(0,G.jsx)(mr,{}),(0,G.jsxs)(`div`,{className:$(`px-2 pt-1 pb-2`,!a&&`hidden`),children:[g&&(0,G.jsx)(`div`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`Loading…`}),_&&(0,G.jsxs)(`div`,{className:`px-2 py-1 text-xs text-role-user`,children:[`Failed: `,v?.message]}),y&&h.length===0&&(0,G.jsx)(`div`,{className:`px-2 py-1 text-xs text-fg-muted italic`,children:`No collections yet. Hit "+ new" to curate sessions that belong together.`}),h.map(n=>(0,G.jsx)(yr,{node:n,selected:e,expanded:s,onToggle:te,onSelect:e=>t(e),onContext:P,onReorder:L,onSessionDrop:R,dropTargetId:D,setDropTargetId:O,onDragEnter:ee,onDragLeaveRow:M,autoIds:E},n.id)),k&&(0,G.jsx)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 bg-accent text-bg text-sm font-medium px-4 py-2 rounded-full shadow-xl animate-in fade-in slide-in-from-bottom-2`,role:`status`,"aria-live":`polite`,children:k}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`w-full mt-2 text-xs text-fg-muted hover:text-fg text-left px-2 py-1`,children:r?`☑ hide archived`:`☐ show archived`})]}),p&&(()=>{let t=F.get(p.id);if(!t)return null;let n=!!t.archived_at;return(0,G.jsxs)(`div`,{className:`fixed z-40 bg-bg-elevated border border-line rounded-md shadow-lg py-1 min-w-[180px]`,style:{top:p.y,left:p.x},onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(vr,{label:`New child collection`,onClick:()=>{m(null),f(t.id)}}),(0,G.jsx)(vr,{label:`Rename / edit…`,onClick:()=>{m(null),u(t)}}),(0,G.jsx)(vr,{label:`Copy link to this collection`,onClick:()=>{m(null);let e=new URL(window.location.href),n=new URLSearchParams(e.hash.replace(/^#/,``));n.set(`col`,t.id),e.hash=`#${n.toString()}`,navigator.clipboard.writeText(e.toString())}}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),n?(0,G.jsx)(vr,{label:`Restore`,onClick:()=>{m(null),x.mutateAsync(t.id)}}):(0,G.jsx)(vr,{label:`Archive (soft-delete)`,onClick:()=>{m(null),b.mutateAsync(t.id),e===t.id&&w({col:null})}})]})})(),l&&(0,G.jsx)(nr,{mode:`rename`,existing:l,onClose:()=>u(null),onUpdated:()=>u(null)}),d&&(0,G.jsx)(nr,{mode:`create`,initialParentId:d,onClose:()=>f(null),onCreated:()=>f(null)}),I&&(0,G.jsxs)(`div`,{className:`px-4 py-2 text-[10px] text-fg-muted border-t border-line mt-2`,children:[(0,G.jsxs)(`span`,{className:`block truncate`,children:[`Filtering: `,(0,G.jsx)(`span`,{className:`text-fg`,children:I.name})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(null),className:`mt-1 text-accent hover:underline`,children:`clear collection filter`})]})]})}function vr({label:e,onClick:t}){return(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-bg-hover`,children:e})}function yr({node:e,selected:t,expanded:n,onToggle:r,onSelect:i,onContext:a,onReorder:o,onSessionDrop:s,dropTargetId:c,setDropTargetId:l,onDragEnter:u,onDragLeaveRow:d,autoIds:f}){let p=n.has(e.id),m=e.children.length>0,h=!!e.archived_at,g=c===e.id,_=f.has(e.id);return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`relative group flex items-stretch`,onDragEnter:t=>{Array.from(t.dataTransfer.types).includes(`application/x-recall-session`)&&u(e.id)},onDragOver:t=>{let n=Array.from(t.dataTransfer.types),r=n.includes(gr),i=n.includes(hr);!r&&!i||(t.preventDefault(),t.dataTransfer.dropEffect=r?`copy`:`move`,c!==e.id&&l(e.id))},onDragLeave:t=>{let n=t.relatedTarget;(!n||!t.currentTarget.contains(n))&&(c===e.id&&l(null),d(e.id))},onDrop:t=>{t.preventDefault(),l(null),d(e.id);let n=t.dataTransfer.getData(gr);if(n){s(n,e.id);return}let r=t.dataTransfer.getData(hr);r&&r!==e.id&&o(r,e.id)},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),onContextMenu:t=>a(e.id,t),className:$(`relative flex-1 min-w-0 flex items-center gap-1.5 py-1 pr-1 rounded text-sm text-left transition-colors`,t===e.id?`bg-accent/15 text-fg`:`hover:bg-bg-hover`,g&&`outline outline-2 outline-accent bg-accent/30 text-fg font-semibold shadow-[0_0_0_4px_rgba(249,115,22,0.15)]`,h&&`opacity-50 italic`),style:{paddingLeft:`${8+e.depth*12}px`,background:e.color?t===e.id?`linear-gradient(90deg, ${e.color}33 0%, transparent 40%)`:`linear-gradient(90deg, ${e.color}1a 0%, transparent 40%)`:void 0},title:e.description??e.name,children:[e.color&&(0,G.jsx)(`span`,{className:`absolute top-1 bottom-1 left-0 w-[3px] rounded-full`,style:{background:e.color},"aria-hidden":`true`}),m?(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,onClick:t=>{t.stopPropagation(),r(e.id)},className:$(`inline-block w-3 text-fg-muted text-[10px] transition-transform`,p&&`rotate-90`),"aria-hidden":`true`,children:`▸`}):(0,G.jsx)(`span`,{className:`inline-block w-3`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`shrink-0`,children:e.icon??`📂`}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),g?(0,G.jsx)(`span`,{className:`text-[10px] shrink-0 font-semibold text-accent px-1.5 py-0.5 rounded-full bg-accent/20 whitespace-nowrap`,children:`← drop here`}):(0,G.jsxs)(G.Fragment,{children:[_&&(0,G.jsx)(`span`,{className:`text-[10px] shrink-0 text-fg-muted/70`,title:`auto-collection (rule-managed). Manual memberships are never overwritten.`,"aria-label":`auto-managed`,children:`⚙`}),(0,G.jsx)(`span`,{className:$(`text-[10px] shrink-0 font-medium`,!e.color&&`text-fg-muted`),style:{color:e.color??void 0},children:e.total_session_count===e.session_count?e.session_count:`${e.session_count}/${e.total_session_count}`})]})]}),!h&&(0,G.jsx)(`span`,{draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-recall-collection`,e.id),t.dataTransfer.setData(`text/plain`,`recall-collection:${e.id}`)},className:`shrink-0 px-1.5 flex items-center text-fg-muted/40 hover:text-fg-muted cursor-grab active:cursor-grabbing text-[11px] select-none opacity-0 group-hover:opacity-100 transition-opacity`,title:`drag to reorder this collection among its siblings`,"aria-label":`drag to reorder ${e.name}`,children:`⋮⋮`})]}),p&&m&&(0,G.jsx)(`div`,{children:e.children.map(e=>(0,G.jsx)(yr,{node:e,selected:t,expanded:n,onToggle:r,onSelect:i,onContext:a,onReorder:o,onSessionDrop:s,dropTargetId:c,setDropTargetId:l,onDragEnter:u,onDragLeaveRow:d,autoIds:f},e.id))})]})}function br(e,t){return e?`${e}m`:`${t?t.charAt(0):`n`}0`}var xr=`claude-recall:foryou`;function Sr(e=new Date){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Cr(e){try{let t=window.localStorage.getItem(`${xr}:${e}`);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>e===`rediscovered`||e===`expensive`||e===`authored`)):new Set}catch{return new Set}}function wr(e,t){try{window.localStorage.setItem(`${xr}:${e}`,JSON.stringify([...t]))}catch{}}function Tr(){let[e,t]=(0,W.useState)(()=>Sr()),[n,r]=(0,W.useState)(()=>Cr(Sr())),[i,a]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{a(!0)},[]),(0,W.useEffect)(()=>{let n=()=>{let n=Sr();n!==e&&(t(n),r(Cr(n)))};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,n)}},[e]),{dismissed:n,dismiss:(0,W.useCallback)(t=>{r(n=>{if(n.has(t))return n;let r=new Set(n);return r.add(t),wr(e,r),r})},[e]),isReady:i}}function Er(e){return{id:`rediscovered`,icon:`✦`,label:`Rediscovered`,accent:`text-role-tool border-role-tool/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:`${e.daysAgo} day${e.daysAgo===1?``:`s`} ago`+(e.project?` · ${e.project}`:``),trailing:e.matchedKeywords.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.matchedKeywords.slice(0,4).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded bg-role-tool/10 text-role-tool text-[10px] border border-role-tool/30`,children:[`#`,e]},e))}):void 0,sessionId:e.sessionId}}function Dr(e){return{id:`expensive`,icon:`$`,label:`Most expensive · 7d`,accent:`text-accent border-accent/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:(e.project?`${e.project} · `:``)+`${e.costDisplay} · ${e.tokensDisplay} · ${e.primaryModelLabel}`+(e.startedAt?` · ${yt(e.startedAt)}`:``),sessionId:e.sessionId}}function Or(e){return{id:`authored`,icon:`⎇`,label:`Authored current HEAD`,accent:`text-role-assistant border-role-assistant/40`,title:e.alias??vt(e.firstUserMessage,60)??e.sessionId.slice(0,8),subtitle:`${e.shortSha} · `+(e.subject?vt(e.subject,50):`current HEAD`)+(e.committedAt?` · ${yt(e.committedAt)}`:``),sessionId:e.sessionId}}function kr({onSelectSession:e}){let t=q({queryKey:[`discover`,`today`],queryFn:()=>Z.getDiscoverToday(),staleTime:300*1e3,refetchOnWindowFocus:!1,retry:1}),{dismissed:n,dismiss:r,isReady:i}=Tr(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(()=>{try{return localStorage.getItem(`recall.forYouPaneOpen`)===`1`}catch{return!1}});if((0,W.useEffect)(()=>{try{localStorage.setItem(`recall.forYouPaneOpen`,s?`1`:`0`)}catch{}},[s]),!i||!t.data)return null;let l=[];return t.data.rediscovered&&!n.has(`rediscovered`)&&l.push(Er(t.data.rediscovered)),t.data.expensive&&!n.has(`expensive`)&&l.push(Dr(t.data.expensive)),t.data.authored&&!n.has(`authored`)&&l.push(Or(t.data.authored)),l.length===0?null:(0,G.jsxs)(`div`,{className:`border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`flex items-center gap-2 hover:text-accent`,title:s?`collapse For you`:`expand For you`,"aria-expanded":s,children:[(0,G.jsx)(`span`,{className:$(`inline-block text-[10px] text-fg-muted transition-transform`,s?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{children:`For you`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:$(`text-xs font-normal normal-case tracking-normal hover:text-accent`,a?`text-accent`:`text-fg-muted/70`),title:`What is For you?`,"aria-expanded":a,children:`(?)`})]}),(0,G.jsx)(`span`,{children:l.length})]}),a&&(0,G.jsxs)(`div`,{className:`px-4 py-2 text-[11px] text-fg-muted bg-bg-elevated/50 border-b border-line/50 leading-relaxed`,children:[`Suggested sessions for today, picked from your activity:`,(0,G.jsxs)(`ul`,{className:`mt-1 ml-4 list-disc space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`$ Most expensive · 7d`}),` — your highest-cost session in the last week.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-role-assistant`,children:`⎇ Authored current HEAD`}),` — the session that produced the commit you're on.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-role-tool`,children:`✦ Rediscovered`}),` — an older session matching your current keywords.`]})]}),(0,G.jsx)(`div`,{className:`mt-1`,children:`Click × on a card to dismiss it for the day; suggestions reset overnight.`})]}),(0,G.jsx)(`div`,{className:$(`flex flex-col`,!s&&`hidden`),children:l.map(t=>(0,G.jsxs)(`div`,{className:$(`group relative px-4 py-2.5 border-b border-line/50 hover:bg-bg-hover transition-colors cursor-pointer`),role:`button`,tabIndex:0,onClick:()=>e(t.sessionId),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.sessionId))},title:`Open ${t.title}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-0.5`,children:[(0,G.jsxs)(`span`,{className:$(`inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wider font-medium px-1.5 py-0.5 rounded border`,t.accent),children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:t.icon}),(0,G.jsx)(`span`,{children:t.label})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.id)},className:`opacity-0 group-hover:opacity-100 focus:opacity-100 text-fg-muted/70 hover:text-role-user transition-opacity text-sm leading-none px-1`,title:`Dismiss for today`,"aria-label":`Dismiss ${t.label} for today`,children:`×`})]}),(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg truncate`,children:t.title}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate mt-0.5`,children:t.subtitle}),t.trailing]},t.id))})]})}function Ar(e){return e>=70?`text-green-500`:e>=40?`text-yellow-500`:`text-red-500`}function jr(e){return e>=70?`bg-green-500`:e>=40?`bg-yellow-500`:`bg-red-500`}function Mr({projectId:e}){let t=q({queryKey:[`health`,e],queryFn:()=>Z.healthScore(e),staleTime:3e4,refetchInterval:6e4,refetchIntervalInBackground:!1});if(!t.data)return null;let{score:n}=t.data;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs ${Ar(n)}`,title:`Memory health: ${n}/100`,children:[(0,G.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${jr(n)}`}),n]})}var Nr=`sqlite3 ~/.recall/db.sqlite \\
|
|
11
11
|
"DELETE FROM thread_edges WHERE source='auto-scan-v1';
|
|
12
|
-
DELETE FROM threads WHERE id LIKE 'auto-scan-%';"`,Pr=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,note:`fastest, cheapest, plenty smart for short titles. Recommended.`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,note:`slightly nicer phrasing, but ~3x the cost of Haiku for the same task.`},{value:`claude-opus-4-7`,label:`Opus 4.7`,note:`overkill for naming. Costs ~15x Haiku and burns ~10x more of your 5-hour window.`}];function Fr({project:e,onClose:t,onOpenThreadsPage:n}){let r=K(),[i,a]=(0,W.useState)(`preflighting`),[o,s]=(0,W.useState)(.7),[c,l]=(0,W.useState)(!0),[u,d]=(0,W.useState)(Pr[0].value),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(.4),[g,_]=(0,W.useState)(.7),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)([]),O=(0,W.useRef)(null);(0,W.useEffect)(()=>{let t=!1;return a(`preflighting`),x(null),(async()=>{try{let n=f?{enabled:!0,band_lo:m,band_hi:g,model:`claude-haiku-4-5-20251001`}:void 0,r=await Z.threadScanPreflight({project:e,threshold:o,model:u,llm_rescore:n});if(t)return;y(r),a(`preview`)}catch(e){if(t)return;x(e instanceof Error?e.message:String(e)),a(`preview`)}})(),()=>{t=!0}},[e,o,u,f,m,g]),(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`launching`&&t()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,t]),(0,W.useEffect)(()=>{if(!S)return;let e=new EventSource(mt(`/api/threads/scan/jobs/${encodeURIComponent(S)}/stream`));return O.current=e,e.addEventListener(`progress`,e=>{try{let t=JSON.parse(e.data);t.phase===`naming`&&t.thread_name&&t.total&&D(e=>[...e,{current:t.current??0,total:t.total??0,thread_name:t.thread_name}].slice(-8))}catch{}}),e.addEventListener(`done`,t=>{try{let e=JSON.parse(t.data);T(e),e.status===`failed`?(x(e.error),a(`failed`)):e.status===`cancelled`?a(`cancelled`):a(`done`)}catch{a(`done`)}e.close(),r.invalidateQueries({queryKey:[`threads`]}),r.invalidateQueries({queryKey:[`thread-folders`]})}),e.addEventListener(`error`,()=>{x(`Stream disconnected`),a(`failed`),e.close()}),()=>{e.close(),O.current=null}},[S,r]);async function k(){x(null),D([]),a(`launching`);try{let t=f?{enabled:!0,band_lo:m,band_hi:g,model:`claude-haiku-4-5-20251001`}:void 0,{jobId:n,reused:r}=await Z.threadScanApply({project:e,threshold:o,llm_names:c,model:u,llm_rescore:t});C(n),a(`running`),r&&Q({message:`A scan for ${e} was already running. Attached.`,tone:`info`})}catch(e){x(e instanceof Error?e.message:String(e)),a(`preview`)}}async function A(){if(S)try{await Z.threadScanCancel(S),Q({message:`Cancellation requested`,tone:`info`})}catch(e){Q({message:`Cancel failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}function j(){navigator.clipboard?.writeText(Nr),Q({message:`Rollback command copied`,tone:`info`})}let M=i===`preview`&&v!==null&&v.eligible_sessions>0&&v.proposed_edges>0;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`launching`&&t()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg`,children:[`🧵 Detect threads in `,e]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:i===`launching`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`running`?`run in background ↗`:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(i===`preflighting`||i===`preview`)&&(0,G.jsx)(Ir,{loading:i===`preflighting`,preflight:v,threshold:o,onThresholdChange:s,llmNames:c,onLlmNamesChange:l,model:u,onModelChange:d,rescoreEnabled:f,onRescoreEnabledChange:p,rescoreLo:m,rescoreHi:g,onRescoreBandChange:(e,t)=>{h(e),_(t)}}),(i===`launching`||i===`running`||i===`cancelled`)&&(0,G.jsx)(Ur,{project:e,snapshot:w,recentNames:E,estimatedThreads:v?.estimated_threads??0,cancelled:i===`cancelled`}),i===`done`&&w&&(0,G.jsx)(Wr,{project:e,snapshot:w,onOpenThreadsPage:n,onCopyRollback:j}),i===`failed`&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-1`,children:`Scan failed`}),(0,G.jsx)(`div`,{children:b??`Unknown error`})]}),b&&i===`preview`&&(0,G.jsx)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:b})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[i===`preview`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded border border-line hover:bg-bg-hover`,children:`Cancel`}),(0,G.jsxs)(`button`,{type:`button`,onClick:k,disabled:!M,className:`text-xs px-3 py-1.5 rounded bg-accent text-white disabled:opacity-40 disabled:cursor-not-allowed hover:bg-accent/80`,children:[`Apply (`,v?.estimated_threads??0,` thread`,v?.estimated_threads===1?``:`s`,`)`]})]}),i===`running`&&(0,G.jsx)(`button`,{type:`button`,onClick:A,className:`text-xs px-3 py-1.5 rounded border border-role-user/40 text-role-user hover:bg-role-user/10`,children:`Cancel scan`}),(i===`done`||i===`cancelled`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded bg-accent text-white hover:bg-accent/80`,children:`Close`})]})]})})}function Ir({loading:e,preflight:t,threshold:n,onThresholdChange:r,llmNames:i,onLlmNamesChange:a,model:o,onModelChange:s,rescoreEnabled:c,onRescoreEnabledChange:l,rescoreLo:u,rescoreHi:d,onRescoreBandChange:f}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gr,{label:`What is a thread?`,children:(0,G.jsxs)(`div`,{className:`space-y-2 leading-relaxed`,children:[(0,G.jsxs)(`p`,{children:[`A `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`thread`}),` is a chain of past sessions in this project that belong to one workflow. You closed one session, opened another, kept going.`]}),(0,G.jsx)(`p`,{children:`Six signals decide whether two sessions belong together. All run locally on your machine. None of them spend tokens.`}),(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Time proximity.`}),` `,`Did the next session start soon after the last one ended?`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Continuation cues.`}),` `,`We scan the first 7 user messages for phrases like "let's commit", "next step", "continuing from". Catches openings that start with banter and pivot in a few prompts.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`File overlap.`}),` `,`Did both sessions touch the same files?`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Semantic similarity.`}),` `,`Three views of the same local embeddings: full-session means, parent ending vs child opening, and the single best chunk-to-chunk match. Tool-output chunks (file dumps, command listings) are filtered out so they do not muddy the signal.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Cluster prior.`}),` `,`If both sessions land in the same workflow cluster (computed from the same embeddings, no extra cost), small bonus.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Shared brand.`}),` `,`Same skill or brand marker. Weak tiebreaker.`]})]})]})]})}),(0,G.jsx)(zr,{threadCount:t?.estimated_threads??0,sessionCount:t?.eligible_sessions??0,edgeCount:t?.proposed_edges??0,model:o,llmNames:i}),(0,G.jsx)(Rr,{value:n,onChange:r}),(0,G.jsx)(Br,{value:o,onChange:s,disabled:!i}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!i,onChange:e=>a(!e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Skip LLM thread-naming (free, uses root session text)`}),(0,G.jsx)(`div`,{className:`text-fg-muted/70`,children:`Less polished names, but zero token cost and zero plan-window use.`})]})]}),(0,G.jsx)(Lr,{enabled:c,onEnabledChange:l,lo:u,hi:d,onBandChange:f,preflight:t}),e&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30 flex items-center gap-3 text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-accent border-t-transparent animate-spin`}),(0,G.jsx)(`span`,{children:`Counting eligible sessions and proposed edges…`})]}),!e&&t&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(Vr,{preflight:t,llmNames:i}),i&&t.estimated_threads>0&&(0,G.jsx)(Hr,{estimate:t.plan_window_estimate,llmCalls:t.estimated_llm_calls}),i&&(0,G.jsxs)(Gr,{label:`Token + USD detail (for API-key users on ${Pr.find(e=>e.value===t.model)?.label??`this model`})`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1.5 mb-3`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Input tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:t.estimated_input_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Output tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:t.estimated_output_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg font-medium`,children:`Estimated cost (max)`}),(0,G.jsxs)(`div`,{className:`text-accent font-mono tabular-nums text-right font-semibold`,children:[`$`,t.estimated_cost_usd_max.toFixed(4)]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`These numbers only apply if you pay Anthropic directly through your own API key. On Claude Pro or Max, ignore the dollar amount. Your real cost is the 5-hour window slice shown in the bars above.`})]}),(0,G.jsx)(Gr,{label:`How accurate is this estimate?`,children:(0,G.jsxs)(`ul`,{className:`space-y-2 leading-relaxed`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Session, edge, and thread counts are exact.`}),` `,`We compute them by running the same graph algorithm the scan itself uses. They will not change between this preview and the actual run.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Token, cost, and window numbers are an upper bound.`}),` `,`Each thread triggers one short Haiku 4.5 call (about`,` `,`500 input + 30 output tokens). Bigger threads make slightly bigger prompts, so real usage is typically within plus or minus 20% of what you see here.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Your session content stays local.`}),` `,`Only short session titles or first-message snippets are sent to Anthropic for naming. Your JSONL transcripts never leave your machine.`]})]})]})}),t.existing_auto_scan_threads>0&&(0,G.jsxs)(`div`,{className:`p-2 rounded border border-role-tool/40 bg-role-tool/10 text-role-tool`,children:[`⚠ This project already has`,` `,t.existing_auto_scan_threads,` auto-scan thread`,t.existing_auto_scan_threads===1?``:`s`,`. Running again creates new threads alongside the old ones. Use the rollback command (shown on the done panel) to clear the previous scan first if you want a clean rerun.`]}),t.proposed_edges===0&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`No edges above threshold. Lower the slider or accept that this project has no detectable workflow chains at the current setting.`})]})]})}function Lr({enabled:e,onEnabledChange:t,lo:n,hi:r,onBandChange:i,preflight:a}){let o=a?.llm_rescore??null;return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/20 space-y-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`LLM re-score on borderline pairs`}),(0,G.jsx)(`div`,{className:`text-fg-muted/70`,children:`Spend a small Haiku 4.5 call on each pair whose deterministic confidence falls inside the band below. Promotes confirmed continuations, demotes false positives, leaves uncertain pairs alone. Pairs outside the band are decided by the free 6-signal stack.`})]})]}),e&&(0,G.jsxs)(`div`,{className:`pl-6 space-y-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Borderline band`}),(0,G.jsxs)(`span`,{className:`font-mono text-fg-muted tabular-nums`,children:[n.toFixed(2),` – `,r.toFixed(2)]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`low`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:n,onChange:e=>{let t=Number(e.target.value);i(Math.min(t,r),r)},className:`w-full accent-accent`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`high`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:r,onChange:e=>{let t=Number(e.target.value);i(n,Math.max(t,n))},className:`w-full accent-accent`})]})]})]}),o&&(0,G.jsxs)(`div`,{className:`border border-line/60 rounded p-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-1`,children:[(0,G.jsx)(`div`,{children:`Borderline pairs`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_borderline_pairs}),(0,G.jsx)(`div`,{children:`LLM input tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_input_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{children:`LLM output tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_output_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg font-medium`,children:`Estimated cost (max)`}),(0,G.jsxs)(`div`,{className:`text-accent font-mono tabular-nums text-right font-semibold`,children:[`$`,o.estimated_cost_usd_max.toFixed(4)]})]}),o.exceeds_cap&&(0,G.jsxs)(`div`,{className:`text-role-user mt-1`,children:[`⚠ `,o.estimated_borderline_pairs,` pairs exceeds the cap of `,o.cap,`. Tighten the band or scan a smaller project — the rescore step will be skipped at this size.`]}),o.estimated_borderline_pairs===0&&(0,G.jsx)(`div`,{children:`No borderline pairs at this band. The deterministic scorer already decided every proposal — rescore is a no-op.`})]})]})]})}function Rr({value:e,onChange:t}){let n=``,r=`text-fg-muted`;return e<=.6?(n=`Loose: catches more chains, more false positives`,r=`text-role-tool`):e<=.75?(n=`Balanced (recommended): drops file-only coincidences`,r=`text-accent`):e<=.9?(n=`Strict: requires multiple strong signals`,r=`text-fg`):(n=`Very strict: only near-certain chains`,r=`text-fg`),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Confidence threshold`}),(0,G.jsx)(`span`,{className:`font-mono text-fg-muted tabular-nums`,children:e.toFixed(2)})]}),(0,G.jsx)(`input`,{type:`range`,min:.5,max:1,step:.05,value:e,onChange:e=>t(Number(e.target.value)),className:`w-full accent-accent`}),(0,G.jsx)(`div`,{className:`mt-1.5 font-medium ${r}`,children:n}),(0,G.jsx)(`div`,{className:`text-fg-muted mt-2 leading-relaxed`,children:`Every pair of sessions gets a confidence score from 0 to 1. The higher you set this slider, the more sure we have to be that two sessions belong to the same workflow before we link them. 0.7 is a good middle ground, and it's what the CLI uses by default.`})]})}function zr({threadCount:e,sessionCount:t,edgeCount:n,model:r,llmNames:i}){let a=Pr.find(e=>e.value===r)?.label??`Haiku 4.5`,o=r.includes(`opus`)?8:r.includes(`sonnet`)?5:3,s=i?e*o:0,c=Math.max(1,Math.round(s/60));return(0,G.jsx)(Gr,{label:`How does this work, technically?`,children:(0,G.jsxs)(`div`,{className:`space-y-3 leading-relaxed`,children:[(0,G.jsx)(`p`,{children:`The scan runs in two steps inside Claude Recall. Only the second step talks to Claude.`}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`Step 1`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Find the connections (stays on your machine)`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`no Claude, no internet, no subprocess`})]}),(0,G.jsx)(`p`,{className:`text-fg-muted mb-2`,children:`For every pair of sessions, we score how likely they belong to the same workflow. Six signals, real session data, not just titles. All local, zero tokens.`}),(0,G.jsxs)(`ul`,{className:`space-y-1.5 ml-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`1.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Files they touched.`}),` `,`Every Read, Edit, Write, and Bash file path from each session's JSONL. Two sessions editing the same files are very likely one workflow. Strongest signal.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`2.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`How the next session opens.`}),` `,`We scan up to the first 7 user messages for cues like "let's commit", "next step", "continuing from". Catches openings that start with banter and pivot a few prompts in.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`3.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Time gap.`}),` `,`Closing one session and starting another within an hour scores way higher than two days apart.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`4.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Semantic similarity.`}),` `,`Three views of the same local embeddings, we take the strongest match: full-session means, parent ending vs child opening, and the single best chunk-to-chunk pair. Tool-output chunks (file dumps, command listings) are filtered out before pooling. Skipped silently for any session that has no embedding yet.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`5.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Cluster prior.`}),` `,`Quick connected-components clustering over the same embeddings groups sessions that talk about the same workflow. Pairs that land in the same cluster get a small bonus.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`6.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Shared brand or skill.`}),` `,`Small bonus when both sessions share a skill prefix or brand marker.`]})]})]}),(0,G.jsxs)(`p`,{className:`text-fg-muted mt-2`,children:[`Pairs at or above your threshold become edges. Edges group into chains. Each chain is one thread.`,` `,t>0&&(0,G.jsxs)(`span`,{className:`text-fg`,children:[`Right now: `,t,` session`,t===1?``:`s`,`, `,n,` edge`,n===1?``:`s`,`, `,e,` thread`,e===1?``:`s`,`.`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted/70 mt-2 text-[10px] leading-relaxed`,children:`Step 1 finishes in seconds even on huge projects, and the numbers are exact, not a sample. We deliberately do not send full transcripts to a model here. For hundreds of sessions that would be slow, costly, and prone to false connections. The six signals above catch the obvious cases for free.`})]}),(0,G.jsxs)(`div`,{className:`border rounded p-3 ${i?`border-accent/40 bg-accent/5`:`border-line bg-bg-hover/30 opacity-60`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`Step 2`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:i?`Name each thread (one ${a} call per thread)`:`Name each thread (skipped, free)`})]}),i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-fg-muted mb-2`,children:[`Step 1 already decided which sessions belong together. Now we give each chain one short workflow name like "Remotion Dependency Update and Inspection".`,` `,(0,G.jsx)(`span`,{className:`text-fg`,children:`Your session titles stay exactly as they are. The new name is for the thread itself, not the sessions inside it.`})]}),(0,G.jsxs)(`ol`,{className:`space-y-1.5 ml-1`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`1.`}),` For each thread, the daemon spawns one short`,` `,(0,G.jsx)(`code`,{className:`text-fg bg-bg px-1 rounded text-[10px]`,children:`claude -p`}),` `,`subprocess running `,a,`.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`2.`}),` The prompt is the chronological list of that thread's session labels (alias, auto-title, or first-message snippet). About 500 input tokens. No transcripts here, because the job is just "produce a 6-word title". The decision about which sessions belong together was already made in Step 1.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`3.`}),` Claude returns a 4–8 word workflow name (about 30 output tokens). The daemon writes the thread row, then moves to the next thread.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`4.`}),` Calls run`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`sequentially`}),`, one at a time. No parallel agents, no background terminals, no fan-out.`]})]}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-[10px]`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Subprocesses spawned:`}),(0,G.jsxs)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:[e,` (sequential, ~`,o,`s each)`]}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Estimated wall time:`}),(0,G.jsxs)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:[`~`,c,` min`]}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Concurrent Claude calls:`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:`1 at any moment`})]})]}):(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`You opted out of LLM naming. Each thread takes its name from the root session's alias or auto-title. Zero subprocesses, zero token cost, zero plan-window use.`})]}),(0,G.jsxs)(`div`,{className:`border border-role-tool/30 rounded p-3 bg-role-tool/5`,children:[(0,G.jsx)(`div`,{className:`text-fg font-medium mb-1.5`,children:`What does NOT happen`}),(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` spawn one agent per session. The naming runs at the thread level, not the session level.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` send transcript content, code, tool outputs, or file contents to Claude. Only short titles.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` open a terminal, run claude in interactive mode, or leave anything running in the background after the scan finishes.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` fan out to parallel sub-agents. Switching to Sonnet or Opus does not buy you more concurrency, only different per-call quality and cost.`]})]})]})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted/80 text-[10px]`,children:[`Source files if you want to read it: graph algorithm in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/utils/threadScan.ts`}),`, naming subprocess in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/commands/thread-scan.ts`}),`, job runtime in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/daemon/thread-scan-jobs.ts`}),`.`]})]})})}function Br({value:e,onChange:t,disabled:n}){let r=Pr.find(t=>t.value===e);return(0,G.jsxs)(`label`,{className:`block ${n?`opacity-50`:``}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Naming model`}),r&&(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:r.note})]}),(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),disabled:n,className:`w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg focus:border-accent focus:outline-none disabled:cursor-not-allowed`,children:Pr.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(`div`,{className:`text-fg-muted/70 mt-1 leading-relaxed`,children:`Picks the model used to generate each thread name. Cost and the 5-hour window bars below update as you change this.`})]})}function Vr({preflight:e,llmNames:t}){return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-1.5 bg-bg-hover/30`,children:[(0,G.jsx)(Kr,{label:`Eligible sessions in project`,value:e.eligible_sessions.toString(),hint:`Excludes [meta], [output-index], and [skill] infra sessions.`}),(0,G.jsx)(Kr,{label:`Proposed parent-child edges`,value:e.proposed_edges.toString(),hint:`Pairs scoring at or above your threshold.`}),(0,G.jsx)(Kr,{label:`Resulting threads`,value:e.estimated_threads.toString(),hint:`Connected components in the edge graph (one thread per chain).`}),(0,G.jsx)(Kr,{label:`LLM naming calls`,value:t?`${e.estimated_llm_calls} (${Pr.find(t=>t.value===e.model)?.label??e.model})`:`0 (skipped)`,hint:t?`One short call per thread to generate a 4-8 word workflow name.`:`Thread names will fall back to the root session label.`})]})}function Hr({estimate:e,llmCalls:t}){let n={pro:`Pro`,"max-5x":`Max 5x`,"max-20x":`Max 20x`};return(0,G.jsxs)(`div`,{className:`border border-accent/30 rounded p-3 space-y-2 bg-accent/5`,children:[(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:`Claude Code 5-hour window impact`}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,t,` Haiku call`,t===1?``:`s`,`, multiplier`,` `,e.model_multiplier,`x)`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`If you're on Pro/Max (not your own API key), each thread-naming call burns a slice of your 5-hour message window. Bars show how much of one window this scan consumes per plan tier.`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.per_plan.map(e=>{let t=e.would_exhaust_window,r=!t&&e.fraction>.5,i=Math.min(100,e.pct);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted w-16 shrink-0`,children:n[e.plan]}),(0,G.jsx)(`div`,{className:`flex-1 h-2 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:t?`h-full bg-role-user`:r?`h-full bg-role-tool`:`h-full bg-accent`,style:{width:`${i}%`}})}),(0,G.jsxs)(`span`,{className:`tabular-nums w-16 text-right `+(t?`text-role-user font-semibold`:`text-fg`),children:[e.pct>=1e3?`>1000`:e.pct.toFixed(1),`%`]})]},e.plan)})}),(0,G.jsxs)(`div`,{className:`text-fg-muted/80 text-[10px] leading-relaxed`,children:[`ⓘ `,e.caveat]})]})}function Ur({project:e,snapshot:t,recentNames:n,estimatedThreads:r,cancelled:i}){let a=t?.total_threads??r,o=t?.threads_named??0;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:i?`Cancellation requested for ${e}. Already-written threads kept.`:`Linking edges for ${e}…`}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`span`,{className:`text-fg`,children:[`Naming thread `,o,` of `,a]}),t?.current_thread_name&&(0,G.jsx)(`span`,{className:`text-fg-muted truncate ml-3`,children:t.current_thread_name})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:a>0?`${Math.min(100,o/a*100)}%`:`0%`}})})]}),n.length>0&&(0,G.jsx)(`ul`,{className:`space-y-1 text-fg-muted`,children:n.map((e,t)=>(0,G.jsxs)(`li`,{className:`font-mono text-[11px]`,children:[(0,G.jsxs)(`span`,{className:`text-fg-muted/60`,children:[`[`,e.current,`/`,e.total,`]`]}),` `,e.thread_name]},t))})]})}function Wr({project:e,snapshot:t,onOpenThreadsPage:n,onCopyRollback:r}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`p-3 rounded border border-accent/40 bg-accent/10 text-fg`,children:[`Created `,t.threads_created,` thread`,t.threads_created===1?``:`s`,` with `,t.edges_written,` `,`edges in `,e,`.`]}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-accent hover:underline`,children:`Open Threads page →`}),(0,G.jsxs)(`details`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:`Rollback this scan`}),(0,G.jsx)(`pre`,{className:`mt-2 text-[10px] font-mono text-fg-muted whitespace-pre-wrap`,children:Nr}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`mt-2 text-[11px] px-2 py-1 rounded border border-line hover:bg-bg-hover`,children:`Copy command`})]})]})}function Gr({label:e,children:t}){return(0,G.jsxs)(`details`,{className:`group border border-line rounded bg-bg-hover/20 overflow-hidden`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer select-none flex items-center justify-between px-3 py-2 text-fg-muted hover:text-fg hover:bg-bg-hover/40 transition-colors`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`transition-transform group-open:rotate-90 text-fg-muted/60`,children:`▸`})]}),(0,G.jsx)(`div`,{className:`px-3 py-3 border-t border-line/60 text-fg-muted`,children:t})]})}function Kr({label:e,value:t,hint:n}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:e}),(0,G.jsx)(`span`,{className:`font-mono text-fg tabular-nums`,children:t})]}),n&&(0,G.jsx)(`div`,{className:`text-fg-muted/70 text-[10px] mt-0.5`,children:n})]})}var qr=`(temporary sessions)`,Jr=`recall.projectGroupBy`,Yr=new Set([`folder`,`repo`,`repo-flat`]);function Xr(){let[e,t]=(0,W.useState)(()=>{if(typeof window>`u`)return`repo`;let e=window.localStorage.getItem(Jr);return e&&Yr.has(e)?e:`repo`});return[e,(0,W.useCallback)(e=>{t(e);try{window.localStorage.setItem(Jr,e)}catch{}},[])]}function Zr({selected:e,selectedCollection:t,onSelect:n,onCreateCollection:r,onSelectSession:i}){let[a,o]=Xr(),s=q({queryKey:[`projects`,a],queryFn:()=>Z.projects(a),refetchInterval:15e3,refetchIntervalInBackground:!1,staleTime:6e3}),c=Tn(),[,l]=Nn(),[u,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(null),m=zn({storageKey:`claude-recall:projects-pane`,defaultWidth:256,minWidth:200,maxWidth:600,collapsedWidth:40}),h=(0,W.useCallback)(e=>{e.preventDefault(),m.beginResize(e.clientX,m.width)},[m]),g=e=>{l({col:e,project:null,session:null,msg:null})},_=()=>l({view:`help`,helpSection:`taxonomy`}),v=s.data?s.data.mode===`folder`?s.data.projects.length:s.data.groups.length:null;return m.collapsed?(0,G.jsxs)(`aside`,{className:`pane shrink-0 relative flex flex-col items-center`,style:{width:`${m.effectiveWidth}px`},children:[(0,G.jsx)(`button`,{type:`button`,onClick:m.toggleCollapsed,className:`w-full py-2 text-xs text-fg-muted hover:text-fg hover:bg-bg-hover border-b border-line`,title:`expand projects pane`,children:`»`}),(0,G.jsxs)(`div`,{className:`flex-1 w-full flex items-center justify-center px-1 text-[10px] text-fg-muted tracking-wider`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:[`Projects`,v===null?``:` (${v})`]})]}):(0,G.jsxs)(`aside`,{className:`pane shrink-0 relative`,style:{width:`${m.effectiveWidth}px`},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize projects pane`,onMouseDown:h,onDoubleClick:()=>m.setWidth(256),className:`absolute top-0 right-0 bottom-0 w-1.5 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 z-10`,title:`Drag to resize · double-click to reset`}),(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:m.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal shrink-0`,title:`collapse projects pane`,children:`«`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Projects`}),(0,G.jsx)(`button`,{type:`button`,onClick:_,className:`text-[10px] font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent shrink-0`,title:`Project vs Collection vs Tag vs Pin vs Alias vs Note — what's the difference?`,children:`(?)`})]}),v!==null&&(0,G.jsx)(`span`,{children:v})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,G.jsx)(kr,{onSelectSession:i}),(0,G.jsx)(_r,{selectedCollection:t,onSelect:g,onCreateCollection:r}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group projects by`,className:`flex items-center gap-1 px-3 py-2 border-b border-line text-xs`,children:[`folder`,`repo`,`repo-flat`].map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a===e,onClick:()=>o(e),className:$(`px-2 py-0.5 rounded transition-colors`,a===e?`bg-bg-hover text-fg font-medium`:`text-fg-muted hover:text-fg`),"data-testid":`group-mode-${e}`,children:[e===`folder`&&`Folders`,e===`repo`&&`Repositories`,e===`repo-flat`&&`Repositories (flat)`]},e))}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`all-sessions`,onClick:()=>n(null),className:$(`list-item text-sm flex items-center justify-between gap-2`,e===null&&!t&&`list-item-active`),children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`All sessions`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:s.data?s.data.mode===`folder`?s.data.projects.reduce((e,t)=>e+t.session_count,0):s.data.groups.reduce((e,t)=>e+t.session_count_total,0):`—`})]}),s.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Loading…`}),s.isError&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-role-user`,children:[`Failed to load: `,s.error.message]}),s.data?.mode===`folder`&&(0,G.jsx)(Qr,{projects:s.data.projects,selected:e,onSelect:n,onScanThreads:p}),(s.data?.mode===`repo`||s.data?.mode===`repo-flat`)&&(0,G.jsx)($r,{groups:s.data.groups,selected:e,onSelect:n,onScanThreads:p}),c.data&&c.data.length>0&&(0,G.jsxs)(`div`,{className:`border-t border-line mt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`w-full pane-header hover:bg-bg-hover`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:$(`transition-transform`,u&&`rotate-90`),children:`▸`}),`Tags`]}),(0,G.jsx)(`span`,{children:c.data.length})]}),u&&(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 py-2`,children:c.data.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l({q:`#${e.tag}`,session:null,msg:null}),className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-role-tool/10 text-role-tool text-xs border border-role-tool/30 hover:bg-role-tool/20 transition-colors`,title:`filter to ${e.count} session${e.count===1?``:`s`} tagged #${e.tag}`,children:[(0,G.jsxs)(`span`,{children:[`#`,e.tag]}),(0,G.jsx)(`span`,{className:`text-fg-muted/60 text-[10px]`,children:e.count})]},e.tag))})]})]}),f&&(0,G.jsx)(Fr,{project:f,onClose:()=>p(null),onOpenThreadsPage:e=>{p(null),l({view:`threads`,project:e,session:null,msg:null})}})]})}function Qr({projects:e,selected:t,onSelect:n,onScanThreads:r}){return(0,G.jsx)(G.Fragment,{children:e.map(e=>(0,G.jsxs)(`div`,{className:$(`list-item group relative`,t===e.name&&`list-item-active`),title:e.decoded_path,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`project-row`,onClick:()=>n(e.name),className:`block w-full text-left`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.name}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-fg-muted shrink-0`,children:[(0,G.jsx)(Mr,{projectId:e.id}),bt(e.session_count)]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate font-mono`,children:vt(e.decoded_path,44)}),e.latest&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:yt(e.latest)})]}),(0,G.jsxs)(`div`,{className:`absolute right-2 bottom-2 group/scan`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`thread-scan-button`,onClick:t=>{t.stopPropagation(),r(e.name)},className:`text-[10px] px-1.5 py-0.5 rounded border border-line bg-bg-hover/60 text-fg-muted hover:text-accent hover:border-accent/40 transition-colors`,children:`🧵 Scan threads`}),(0,G.jsxs)(`div`,{role:`tooltip`,className:`pointer-events-none absolute right-0 bottom-full mb-1.5 w-64 z-20 opacity-0 group-hover/scan:opacity-100 transition-opacity rounded-md border border-accent/40 bg-bg shadow-lg px-3 py-2 text-[11px] leading-snug text-fg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-accent mb-1`,children:`Detect workflow threads`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Opens a preflight modal for `,(0,G.jsx)(`span`,{className:`text-fg`,children:e.name}),`: shows eligible session count, proposed parent-child edges, estimated threads, and max LLM cost in USD before you commit. Nothing is written until you click Apply.`]}),(0,G.jsx)(`div`,{className:`absolute right-3 top-full -mt-px h-2 w-2 rotate-45 border-r border-b border-accent/40 bg-bg`})]})]})]},e.id))})}function $r({groups:e,selected:t,onSelect:n,onScanThreads:r}){let[i,a]=(0,W.useState)(new Set),o=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,G.jsx)(G.Fragment,{children:e.map(e=>{let a=i.has(e.repo_root),s=e.folders.length>1,c=e.folders[0],l=c!=null&&t===c.name,u=e.repo_root===qr;return(0,G.jsxs)(`div`,{className:$(`list-item group relative`,l&&`list-item-active`),title:e.repo_root||`No repository path`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-1`,children:[s&&(0,G.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e.repo_root)},className:`text-fg-muted hover:text-fg text-xs mt-1 px-0.5`,"aria-label":a?`Collapse subfolders`:`Expand subfolders`,"data-testid":`expand-${e.repo_root}`,children:a?`▾`:`▸`}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`project-row`,onClick:()=>{u||c&&n(c.name)},className:$(`block flex-1 text-left`,u&&`cursor-default`),title:u?`${e.folders.length} ephemeral sessions from tmpdirs (cold-email batches, scratch dirs). Click an individual folder below to view its session.`:e.repo_root,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-medium truncate flex items-center gap-1`,children:[e.name,e.is_worktree&&(0,G.jsx)(`span`,{className:`text-[10px] px-1 rounded bg-accent/15 text-accent`,children:`worktree`}),!e.is_repo&&(0,G.jsx)(`span`,{className:`text-[10px] px-1 rounded bg-bg-hover text-fg-muted`,children:`folder`})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-fg-muted shrink-0`,children:[c&&(0,G.jsx)(Mr,{projectId:c.id}),bt(e.session_count_total)]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate font-mono`,children:vt(e.repo_root||e.name,44)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted mt-1`,children:[s&&(0,G.jsxs)(`span`,{children:[e.folders.length,` subfolders`]}),e.latest&&(0,G.jsx)(`span`,{children:yt(e.latest)})]})]})]}),c&&(0,G.jsx)(`div`,{className:`absolute right-2 bottom-2 group/scan`,children:(0,G.jsx)(`button`,{type:`button`,"data-testid":`thread-scan-button`,onClick:e=>{e.stopPropagation(),r(c.name)},className:`text-[10px] px-1.5 py-0.5 rounded border border-line bg-bg-hover/60 text-fg-muted hover:text-accent hover:border-accent/40 transition-colors`,children:`🧵 Scan threads`})}),a&&s&&(0,G.jsx)(`ul`,{className:`mt-1 ml-4 border-l border-line`,children:e.folders.map(r=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`button`,{type:`button`,"data-testid":`project-subfolder-row`,onClick:()=>n(r.name),className:$(`block w-full text-left text-xs px-2 py-1`,t===r.name?`text-fg font-medium`:`text-fg-muted hover:text-fg`),title:r.decoded_path,children:(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.repo_root&&r.decoded_path.startsWith(e.repo_root)?`.`+r.decoded_path.slice(e.repo_root.length)||`.`:r.decoded_path})})},r.id))})]},e.repo_root||`(unknown-${e.name})`)})})}var ei=`claude-recall:pinned-sessions:v1`;function ti(){try{let e=localStorage.getItem(ei);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function ni(e){try{localStorage.setItem(ei,JSON.stringify(e))}catch{}}var ri=new Set;function ii(){for(let e of ri)e()}function ai(){let[e,t]=(0,W.useState)(()=>ti());return(0,W.useEffect)(()=>{let e=()=>t(ti());return ri.add(e),()=>{ri.delete(e)}},[]),(0,W.useEffect)(()=>{let e=e=>{e.key===ei&&t(ti())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{pinned:e,isPinned:(0,W.useCallback)(t=>e.includes(t),[e]),togglePin:(0,W.useCallback)(e=>{let t=ti();ni(t.includes(e)?t.filter(t=>t!==e):[...t,e]),ii()},[])}}function oi({status:e}){return!e||e===`neutral`?null:e===`verified`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-green-500`,title:`Verified: completion claim backed by 2+ evidence categories`,children:[(0,G.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,className:`shrink-0`,children:(0,G.jsx)(`path`,{d:`M6 10.8L3.2 8l-.9.9L6 12.6l8-8-.9-.9L6 10.8z`,fill:`currentColor`})}),`verified`]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-yellow-500`,title:`Unverified: completion claimed but insufficient evidence`,children:[(0,G.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,className:`shrink-0`,children:(0,G.jsx)(`path`,{d:`M8 1L1 14h14L8 1zm0 3.5l4.9 8.5H3.1L8 4.5zM7.25 7v3h1.5V7h-1.5zm0 4v1.5h1.5V11h-1.5z`,fill:`currentColor`})}),`unverified`]})}function si(e){return e.trim().toLowerCase().replace(/^#+/,``).replace(/[\s/\\]+/g,`-`).replace(/[^a-z0-9\-._]/g,``).slice(0,40)}function ci({sessionId:e,existingTags:t,onDone:n,variant:r=`bar`,placeholder:i=`tag-name`}){let[a,o]=(0,W.useState)(``),s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=Dn(),u=Tn();(0,W.useEffect)(()=>{requestAnimationFrame(()=>s.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&n()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[n]);let d=si(a),f=u.data?d?u.data.filter(e=>!t.includes(e.tag)&&e.tag.includes(d)).slice(0,8):u.data.filter(e=>!t.includes(e.tag)).slice(0,8):[],p=async t=>{let r=si(t);if(r)try{await l.mutateAsync({sessionId:e,tag:r}),n()}catch(e){console.error(`add tag failed`,e)}},m=r===`row`?`w-48 text-[10px] px-2`:`w-56 text-xs px-3`,h=r===`row`?`text-[10px]`:`text-xs`,g=i===`tag-name`?`type new tag + Enter`:i,_=d.length>0;return(0,G.jsxs)(`div`,{ref:c,className:`relative inline-flex`,children:[(0,G.jsx)(`input`,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),p(a)):e.key===`Escape`?(e.preventDefault(),n()):e.key===`Tab`&&f.length>0&&(e.preventDefault(),o(f[0].tag))},placeholder:g,maxLength:40,className:`bg-bg-elevated border border-accent rounded-full py-0.5 text-fg focus:outline-none placeholder:text-fg-muted ${m}`}),(0,G.jsxs)(`div`,{className:`absolute left-0 top-full mt-1 min-w-full w-56 bg-bg-elevated border border-line rounded-lg shadow-lg py-1 z-30 ${h}`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1 text-fg-muted text-[10px] uppercase tracking-wider border-b border-line/50 mb-1`,children:_?(0,G.jsxs)(G.Fragment,{children:[`Press `,(0,G.jsx)(`span`,{className:`font-mono text-accent`,children:`Enter`}),` to create`,` `,(0,G.jsxs)(`span`,{className:`text-role-tool`,children:[`#`,d]})]}):(0,G.jsx)(G.Fragment,{children:`Type to create, or pick existing:`})}),f.length>0?f.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void p(e.tag),className:`block w-full text-left px-3 py-1 hover:bg-bg-hover`,children:[(0,G.jsxs)(`span`,{className:`text-role-tool`,children:[`#`,e.tag]}),(0,G.jsx)(`span`,{className:`text-fg-muted ml-2`,children:e.count})]},e.tag)):(0,G.jsx)(`div`,{className:`px-3 py-1 text-fg-muted italic`,children:_?`no matches — hit Enter to create`:`no tags yet — type one above`})]})]})}function li(){let[e,t]=(0,W.useState)({id:null,snapshot:null,error:null}),n=(0,W.useRef)(null),r=async e=>{try{let{scanId:n}=await Z.startScan(e);return t({id:n,snapshot:{id:n,status:`running`,createdAt:new Date().toISOString(),finishedAt:null,total:0,completed:0,results:[],error:null},error:null}),i(n),n}catch(e){return t(t=>({...t,error:e instanceof Error?e.message:String(e)})),null}},i=e=>{n.current&&n.current.close();let r=new EventSource(mt(`/api/tags/scan/${encodeURIComponent(e)}/events`));n.current=r,r.addEventListener(`state`,e=>{let n=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,...n}}:e)}),r.addEventListener(`result`,e=>{let n=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,results:[...e.snapshot.results,n]}}:e)}),r.addEventListener(`progress`,e=>{let{completed:n,total:r}=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,completed:n,total:r}}:e)}),r.addEventListener(`status`,e=>{let{status:n}=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,status:n}}:e)}),r.addEventListener(`done`,()=>{t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,status:`completed`,finishedAt:new Date().toISOString()}}:e),r.close()}),r.onerror=()=>{r.close()}},a=async t=>e.id?Z.applyScan(e.id,t):null,o=async()=>{e.id&&(await Z.cancelScan(e.id),n.current?.close())},s=()=>{n.current?.close(),t({id:null,snapshot:null,error:null})};return(0,W.useEffect)(()=>()=>n.current?.close(),[]),{...e,start:r,apply:a,cancel:o,reset:s}}function ui(e,t){(0,W.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}var di=[{id:`claude-opus-4-7`,label:`Opus 4.7 (recommended for quality)`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (balanced)`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5 (fast, cheap)`}];function fi({open:e,onClose:t}){let n=wt(),r=Tt(),i=K();ui(e,t);let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(`api`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(`claude-opus-4-7`),[p,m]=(0,W.useState)([2,4]),[h,g]=(0,W.useState)(!1),_=n.data&&!n.data.enabled&&!n.data.hasApiKey,v=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:e&&s===`mcp`});if((0,W.useEffect)(()=>{n.data&&(o(n.data.enabled),c(n.data.backend),f(n.data.model),m([n.data.minTagsPerSession,n.data.maxTagsPerSession]),g(n.data.autopilot))},[n.data]),!e)return null;let y=async()=>{await r.mutateAsync({enabled:a,backend:s,model:d,minTagsPerSession:p[0],maxTagsPerSession:p[1],autopilot:h,...l?{apiKey:l}:{}}),t()},b=async()=>{try{await Z.installMcp(),await i.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`Claude Recall MCP installed. Restart Claude Code to load it.`,tone:`success`,duration:8e3})}catch(e){Q({message:`Install failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}},x=async()=>{try{await Z.uninstallMcp(),await i.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`MCP entry removed from Claude Code config.`,tone:`info`})}catch(e){Q({message:`Uninstall failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}},S=a&&s===`api`&&(l.length>0||!!n.data?.hasApiKey);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[560px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-center justify-between sticky top-0 bg-bg`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Auto-tagging settings`}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg text-lg leading-none`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-4 text-xs`,children:[_&&(0,G.jsxs)(`div`,{className:`rounded border border-accent/40 bg-accent/10 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-accent mb-1`,children:`First time here?`}),`Auto-tag picks 2–4 tags per session using an LLM. Two ways to run it: pay Anthropic per scan (API key) or use your existing Claude Code agent (MCP, free). Both are opt-in. Turn on `,(0,G.jsx)(`strong`,{children:`Autopilot`}),` `,`to let the daemon tag every session automatically in the background — then forget this dialog exists.`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,G.jsx)(`span`,{className:`text-fg`,children:`Enable auto-tagging`})]}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:`When enabled, scanning sends session content (first message + sampled messages) to your chosen backend. Nothing is sent automatically — every scan is user-triggered. (Unless you turn on Autopilot below.)`}),(0,G.jsxs)(`fieldset`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`legend`,{className:`px-1 text-fg-muted`,children:`Backend`}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`backend`,checked:s===`api`,onChange:()=>c(`api`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Anthropic API key`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Recall calls Anthropic directly. You pay per scan. Works with Autopilot.`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`backend`,checked:s===`mcp`,onChange:()=>c(`mcp`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Claude Code (via MCP)`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Use your existing Claude Code agent. Zero extra cost. Manual trigger only (no Autopilot).`})]})]})]}),s===`api`&&(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Anthropic API key`}),(0,G.jsx)(`input`,{type:`password`,value:l,onChange:e=>u(e.target.value),placeholder:n.data?.hasApiKey?`sk-ant-… (key on file, leave blank to keep)`:`sk-ant-…`,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]}),s===`mcp`&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:"Install Claude Recall into your Claude Code MCP config (`~/.claude.json`) with one click — no copy-paste required."}),v.isLoading?(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Checking install status…`}):v.data?.installed?(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`text-accent text-[11px]`,children:[`✓ Installed in `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:v.data.configPath.replace(/^.*\//,`~/…/`)}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Restart Claude Code if it's running.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),className:`text-[11px] text-fg-muted hover:text-role-user px-2 py-1`,children:`Uninstall`})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Install in Claude Code`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-1`,children:[`Model`,(0,G.jsx)(`span`,{className:`text-[10px] ml-2 font-normal`,children:`— used for both API-key scans and the MCP one-click run`})]}),(0,G.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`,children:di.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Min tags / session`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:10,value:p[0],onChange:e=>m([Math.max(1,Number(e.target.value)),Math.max(Number(e.target.value),p[1])]),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Max tags / session`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:10,value:p[1],onChange:e=>m([Math.min(p[0],Number(e.target.value)),Number(e.target.value)]),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]})]}),(0,G.jsxs)(`fieldset`,{className:`border rounded p-3 ${S?`border-accent/50`:`border-line opacity-60`}`,children:[(0,G.jsx)(`legend`,{className:`px-1 text-fg-muted`,children:`Autopilot`}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,disabled:!S,onChange:e=>g(e.target.checked)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Tag sessions automatically in the background`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:[`When on, the daemon scans every untagged session (existing + new) and applies tags without a review step. You can still × any tag on any session. Costs ~$0.01–0.05 per session at Opus pricing. `,S?``:`Requires backend = Anthropic API key + a saved key.`]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2 sticky bottom-0 bg-bg`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:r.isPending,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-50`,children:r.isPending?`Saving…`:`Save`})]})]})})}function pi({open:e,snapshot:t,onApply:n,onCancel:r,onClose:i,onRetryFailed:a}){let[o,s]=(0,W.useState)({}),[c,l]=(0,W.useState)(!1);ui(e,i),(0,W.useEffect)(()=>{t&&s(e=>{let n={...e};for(let e of t.results)n[e.sessionId]||(n[e.sessionId]={enabled:!!e.suggestion,rejected:new Set});return n})},[t?.results.length,t]);let u=(0,W.useMemo)(()=>t?t.results.map(e=>{let t=o[e.sessionId];if(!t||!t.enabled||!e.suggestion)return null;let n=e.suggestion.tags.filter(e=>!t.rejected.has(e));return n.length===0?null:{sessionId:e.sessionId,tags:n}}).filter(e=>e!==null):[],[t,o]);if(!e||!t)return null;let d=e=>{s(t=>{let n=t[e]??{enabled:!1,rejected:new Set};return{...t,[e]:{...n,enabled:!n.enabled}}})},f=(e,t)=>{s(n=>{let r=n[e]??{enabled:!0,rejected:new Set},i=new Set(r.rejected);return i.has(t)?i.delete(t):i.add(t),{...n,[e]:{...r,rejected:i}}})},p=async()=>{l(!0);try{await n(u)&&i()}finally{l(!1)}},m=t.status===`running`||t.status===`pending`,h=t.results.filter(e=>e.error).length;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[900px] max-w-[calc(100vw-2rem)] max-h-[85vh] flex flex-col shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[`Auto-tag review — `,t.completed,`/`,t.total,m&&(0,G.jsx)(`span`,{className:`ml-2 text-fg-muted text-xs`,children:`(scanning…)`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-lg leading-none`,children:`×`})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`sticky top-0 bg-bg border-b border-line`,children:(0,G.jsxs)(`tr`,{className:`text-left text-fg-muted`,children:[(0,G.jsx)(`th`,{className:`px-3 py-2 w-8`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Session`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Current`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Suggested`}),(0,G.jsx)(`th`,{className:`px-3 py-2 w-20 text-right`,children:`Confidence`})]})}),(0,G.jsxs)(`tbody`,{children:[t.results.map(e=>(0,G.jsx)(mi,{r:e,enabled:o[e.sessionId]?.enabled??!1,rejected:o[e.sessionId]?.rejected??new Set,onToggleRow:()=>d(e.sessionId),onToggleTag:t=>f(e.sessionId,t)},e.sessionId)),m&&t.results.length<t.total&&(0,G.jsx)(`tr`,{children:(0,G.jsxs)(`td`,{colSpan:5,className:`px-3 py-3 text-center text-fg-muted italic`,children:[`scanning `,t.total-t.results.length,` more…`]})})]})]})}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs`,children:[u.length,` session`,u.length===1?``:`s`,` selected`,` `,`(`,(0,G.jsxs)(`span`,{children:[u.reduce((e,t)=>e+t.tags.length,0),` tags`]}),`)`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m&&(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-role-user hover:text-role-user/80 text-xs px-3 py-1`,children:`Cancel scan`}),!m&&h>0&&a&&(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`text-xs border border-role-user/40 text-role-user hover:bg-role-user/10 rounded px-3 py-1`,title:`re-run the ${h} session${h===1?``:`s`} that failed`,children:[`Retry `,h,` failed`]}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:u.length===0||c,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-40`,children:c?`Applying…`:`Apply ${u.length}`})]})]})]})})}function mi({r:e,enabled:t,rejected:n,onToggleRow:r,onToggleTag:i}){let a=!!e.error;return(0,G.jsxs)(`tr`,{className:$(`border-b border-line/50`,a&&`opacity-60`),children:[(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t,onChange:r,disabled:a||!e.suggestion})}),(0,G.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-fg font-medium truncate max-w-[280px]`,title:e.first_user_message,children:e.alias||e.first_user_message.slice(0,60)||`(no prompt)`}),(0,G.jsxs)(`div`,{className:`font-mono text-[10px] text-fg-muted`,children:[e.sessionId.slice(0,8),` · `,e.project]})]}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:e.current_tags.length===0?(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`—`}):(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.current_tags.map(e=>(0,G.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-role-tool/15 text-role-tool text-[10px]`,children:[`#`,e]},e))})}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:a?(0,G.jsxs)(`span`,{className:`text-role-user text-[11px]`,children:[`⚠ `,e.error]}):e.suggestion?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.suggestion.tags.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:$(`px-1.5 py-0.5 rounded-full text-[10px] border transition-colors`,n.has(e)?`line-through text-fg-muted border-line bg-transparent`:`bg-accent/10 text-accent border-accent/40 hover:bg-accent/20`),title:n.has(e)?`click to re-include`:`click to reject`,children:[`#`,e]},e))}):(0,G.jsx)(`span`,{className:`text-fg-muted italic`,children:`pending…`})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right font-mono text-[10px] text-fg-muted`,children:e.suggestion?e.suggestion.confidence.toFixed(2):`—`})]})}function hi({open:e,sessionId:t,projectName:n,onClose:r,onOpenSettings:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(0),[p,m]=(0,W.useState)(null),h=K();ui(e,r),(0,W.useEffect)(()=>{if(!s||l===null)return;let e=setInterval(()=>f(Date.now()-l),250);return()=>clearInterval(e)},[s,l]);let g=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:e}),_=!!g.data?.claudeCliAvailable,v=async()=>{c(!0),m(null);let e=Date.now();u(e),f(0);try{let r=t?{sessionIds:[t]}:n?{project:n,untaggedOnly:!0}:{untaggedOnly:!0},i=await Z.runClaudeCliScan(r);m({success:i.success,tagsAdded:i.tagsAdded,stderrTail:i.stderrTail,elapsedMs:Date.now()-e}),h.invalidateQueries({queryKey:[`sessions`]}),h.invalidateQueries({queryKey:[`tags`]}),t&&h.invalidateQueries({queryKey:[`session`,t]}),Q({message:i.success?`Auto-tag complete — ${i.tagsAdded} new tag${i.tagsAdded===1?``:`s`} written.`:`Auto-tag finished with errors (exit ${i.exitCode}). See dialog for details.`,tone:i.success?`success`:`error`,duration:8e3})}catch(e){Q({message:`Run failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{c(!1)}};if(!e)return null;let y=t?`Using my Recall MCP tools, auto-tag session ${t}. First call list_tags to see existing tags I already use (prefer those for consistency). Then call list_sessions_to_tag with limit 1 and match the session. Pick 2–4 tags based on the content. Finally call apply_tags to write them.`:`Using my Recall MCP tools, scan and tag my sessions. First call list_tags to see existing tags (prefer those for consistency). Then call list_sessions_to_tag with untaggedOnly: true. For each session, pick 2–4 tags based on the content. Finally call apply_tags for each session to write them.`,b=async()=>{try{await navigator.clipboard.writeText(y),o(!0),setTimeout(()=>o(!1),1800)}catch(e){console.error(`copy failed`,e)}},x=async()=>{try{await Z.installMcp(),await h.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`Claude Recall MCP installed. Restart Claude Code to load it.`,tone:`success`,duration:8e3})}catch(e){Q({message:`Install failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[600px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`MCP-mode auto-tagging`}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] mt-1`,children:`You're set to use your Claude Code agent (no Anthropic key needed). The web UI can't call your agent directly — you trigger it from Claude Code.`})]}),i&&(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-[11px] text-fg-muted hover:text-fg px-2 py-1 shrink-0`,title:`change auto-tagging settings`,children:`⚙ Settings`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-4 text-xs`,children:[(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px] font-semibold uppercase tracking-wider`,children:`Step 1 — install Recall in Claude Code`}),g.isLoading?(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Checking…`}):g.data?.installed?(0,G.jsxs)(`div`,{className:`text-accent text-[11px]`,children:[`✓ Installed in `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`~/.claude.json`}),`. If you haven't already, restart Claude Code to load it.`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[`One click — no copy-paste JSON. Writes `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`{ "mcpServers": { "recall": … } }`}),` into your Claude Code config at `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`~/.claude.json`}),`, preserving every other key you already have.`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Install in Claude Code`})]})]}),g.data?.installed&&_&&(0,G.jsxs)(`div`,{className:`border border-accent/50 bg-accent/5 rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-accent text-[11px] font-semibold uppercase tracking-wider`,children:`Step 2 — one click (recommended)`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:[`Recall will spawn your local `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`claude`}),` CLI in the background and have it tag `,t?`this session`:n?(0,G.jsxs)(G.Fragment,{children:[`every untagged session in `,(0,G.jsx)(`span`,{className:`text-fg`,children:n})]}):`every untagged session`,` via the Recall MCP tools. Uses your Claude Code subscription — `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`no API key, no copy-paste`}),`.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void v(),disabled:s,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-50 disabled:cursor-wait inline-flex items-center gap-2`,children:[s&&(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-bg border-t-transparent rounded-full animate-spin`}),s?`Running…`:`🏷 Auto-run via Claude Code`]}),s&&(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-muted font-mono tabular-nums`,children:[gi(d),` elapsed · typical 30s–3min`]})]}),p&&(0,G.jsx)(`div`,{className:`text-[11px] mt-2 p-2 rounded border ${p.success?`border-accent/40 bg-accent/10 text-accent`:`border-role-user/40 bg-role-user/10 text-role-user`}`,children:p.success?(0,G.jsxs)(G.Fragment,{children:[`✓ Done in `,gi(p.elapsedMs),` — `,p.tagsAdded,` new tag`,p.tagsAdded===1?``:`s`,` written.`]}):(0,G.jsxs)(G.Fragment,{children:[`Exit with errors after `,gi(p.elapsedMs),`. Tail of stderr:`,(0,G.jsx)(`pre`,{className:`mt-1 font-mono text-[10px] whitespace-pre-wrap overflow-auto max-h-40`,children:p.stderrTail||`(empty)`})]})})]}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px] font-semibold uppercase tracking-wider`,children:g.data?.installed&&_?`Or — paste the prompt into an open Claude Code session`:`Step 2 — ask your agent (in Claude Code)`}),!_&&g.data?.installed&&(0,G.jsxs)(`div`,{className:`text-role-user text-[11px]`,children:[`⚠ `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`claude`}),` CLI not found on PATH, so one-click auto-run isn't available. Install Claude Code locally to enable it, or use the copy-paste path below.`]}),(0,G.jsx)(`pre`,{className:`bg-bg-elevated border border-line rounded p-2 text-[11px] whitespace-pre-wrap`,children:y}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-[11px] bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1`,children:a?`✓ copied`:`📋 copy prompt`})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[`Your agent will use the `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`list_tags`}),`,`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`list_sessions_to_tag`}),`, and`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`apply_tags`}),` MCP tools. Tags appear in Recall on the next poll (≤4 seconds).`]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] pt-2 border-t border-line`,children:[`Want hands-off tagging that doesn't need Claude Code running?`,` `,i?(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-accent hover:underline`,children:`Switch to API-key mode + enable Autopilot`}):(0,G.jsx)(`span`,{children:`Switch backend to API key in settings and enable Autopilot.`}),`.`]})]}),(0,G.jsx)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})})}function gi(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function _i({projectName:e,collectionId:t}){let n=wt(),r=li(),i=K(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(`untagged`);ui(s,()=>c(!1)),ui(!!r.error,()=>r.reset());let p=()=>{let e=n.data;if(!e||!e.enabled){o(!0);return}if(e.backend===`api`&&!e.hasApiKey){o(!0);return}if(e.backend===`mcp`){u(!0);return}c(!0)},m=async()=>{let n={};d===`untagged`&&(n.untaggedOnly=!0),d===`project`&&e&&(n.project=e),d===`collection`&&t&&(n.collectionId=t),c(!1),await r.start(n)},h=()=>{i.invalidateQueries({queryKey:[`sessions`]}),i.invalidateQueries({queryKey:[`tags`]}),i.invalidateQueries({queryKey:[`session`]})},g=async e=>{let t=await r.apply(e);if(t&&t.applied>0){h();let n=e.reduce((e,t)=>e+t.tags.length,0);Q({message:`Applied ${t.applied} tag${t.applied===1?``:`s`} across ${e.length} session${e.length===1?``:`s`}.`,tone:`success`,duration:1e4,action:{label:`Undo`,onClick:()=>{_(e,n)}}})}else t&&Q({message:`Nothing to apply — all selected tags were already on those sessions.`,tone:`info`});return t},_=async(e,t)=>{let n=0;for(let t of e)for(let e of t.tags)try{await Z.removeSessionTag(t.sessionId,e),n+=1}catch(n){console.error(`undo: remove failed`,t.sessionId,e,n)}h(),Q({message:`Undone — removed ${n} of ${t} tag${t===1?``:`s`}.`,tone:`info`})},v=async()=>{if(!r.snapshot)return;let e=r.snapshot.results.filter(e=>e.error).map(e=>e.sessionId);e.length!==0&&(r.reset(),await r.start({sessionIds:e}))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`inline-flex items-center rounded border border-accent/40 bg-accent/10 overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs text-accent hover:bg-accent hover:text-bg px-2 py-1 font-medium border-r border-accent/40`,title:n.data?.enabled?`auto-tag sessions with an LLM`:`configure auto-tagging`,children:`🏷 auto-tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`text-xs text-accent hover:bg-accent hover:text-bg px-1.5 py-1`,title:`auto-tag settings (enable autopilot, install MCP, change model, paste API key)`,"aria-label":`auto-tag settings`,children:`⚙`})]}),(0,G.jsx)(fi,{open:a,onClose:()=>o(!1)}),(0,G.jsx)(hi,{open:l,projectName:e,onClose:()=>{u(!1),Q({message:`MCP scan triggered. New tags will appear here as your Claude Code agent writes them.`,tone:`info`,duration:8e3})},onOpenSettings:()=>{u(!1),o(!0)}}),r.error&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-role-user/60 rounded-lg w-[440px] shadow-xl p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-role-user font-semibold mb-2`,children:`Scan failed`}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-3 break-words`,children:r.error}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>r.reset(),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})}),s&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[480px] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Auto-tag sessions`}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] mt-1`,children:`Pick how many sessions to send to the LLM. Each session is one model call.`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-3 text-xs`,children:[[{id:`untagged`,label:`Untagged sessions only`,desc:`Every session with zero tags, across ALL projects. Usually what you want for the first run.`,available:!0},{id:`all`,label:`All sessions`,desc:`Every indexed session, across ALL projects. Includes sessions that already have tags (new tags will merge, never replace).`,available:!0},{id:`project`,label:`Current project${e?` — ${e}`:``}`,desc:e?`Only sessions in "${e}".`:`Not available — click a project in the left pane first.`,available:!!e},{id:`collection`,label:`Current collection`,desc:t?`Only sessions in the collection you are currently viewing.`:`Not available — open a collection in the left pane first.`,available:!!t}].map(e=>(0,G.jsxs)(`label`,{className:`flex items-start gap-2 ${e.available?`cursor-pointer`:`opacity-40`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`scope`,className:`mt-0.5`,checked:d===e.id,disabled:!e.available,onChange:()=>f(e.id)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e.label}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:e.desc})]})]},e.id)),(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-line text-[11px] text-fg-muted space-y-1`,children:[(0,G.jsxs)(`div`,{children:[`• Capped at `,(0,G.jsx)(`span`,{className:`text-fg`,children:`500 sessions per scan`}),` (safety rail).`]}),(0,G.jsxs)(`div`,{children:[`• Uses model `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:n.data?.model??`claude-opus-4-7`}),`.`,n.data?.backend===`api`&&(0,G.jsxs)(G.Fragment,{children:[` API-key mode: roughly `,(0,G.jsx)(`span`,{className:`text-fg`,children:`$0.01–0.05`}),` per session at Opus pricing.`]}),n.data?.backend===`mcp`&&(0,G.jsx)(G.Fragment,{children:` MCP mode: uses your Claude Code subscription, no extra cost.`})]}),(0,G.jsx)(`div`,{children:`• Nothing is written until you Apply in the review step.`}),(0,G.jsxs)(`div`,{children:[`• Press `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Esc`}),` to cancel any dialog.`]})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Start scan`})]})]})}),(0,G.jsx)(pi,{open:!!r.id&&!r.error,snapshot:r.snapshot,onApply:g,onCancel:()=>void r.cancel(),onClose:()=>r.reset(),onRetryFailed:()=>void v()})]})}function vi({open:e,title:t,message:n,confirmLabel:r=`Confirm`,cancelLabel:i=`Cancel`,tone:a=`accent`,icon:o,onConfirm:s,onCancel:c}){return ui(e,c),e?(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:c,role:`presentation`,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[440px] max-w-[90vw] p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,children:[(0,G.jsxs)(`h3`,{id:`confirm-dialog-title`,className:`text-base font-semibold mb-3 flex items-center gap-2`,children:[o&&(0,G.jsx)(`span`,{"aria-hidden":`true`,children:o}),(0,G.jsx)(`span`,{children:t})]}),(0,G.jsx)(`div`,{className:`text-sm text-fg-muted mb-5 leading-relaxed`,children:n}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`px-4 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:i}),(0,G.jsx)(`button`,{type:`button`,onClick:s,className:a===`danger`?`px-4 py-1.5 text-sm border border-red-400/60 rounded text-red-400 hover:bg-red-400/10`:`px-4 py-1.5 text-sm border border-accent rounded text-accent hover:bg-accent/10`,children:r})]})]})}):null}var yi=`200`,bi=30,xi=60,Si=120,Ci=15,wi=30,Ti=90,Ei=92,Di={quick:{chunks:5,messages:`~20`,label:`Quick`,sub:`First few exchanges. Captures intent + opening response. Fastest.`},standard:{chunks:80,messages:`~300`,label:`Standard`,sub:`Most working sessions fit here. Good balance of accuracy and time.`},full:{chunks:0,messages:`~600-1000`,label:`Full (safety-capped)`,sub:`First 200 chunks per session. Hard cap protects the daemon from giant sessions. Override with RECALL_VECTOR_HARD_CAP=N if needed.`}};function Oi(e){if(!isFinite(e)||e<=0)return`instant`;if(e<60)return`${Math.max(1,Math.round(e))}s`;let t=Math.floor(e/60),n=Math.round(e%60);return t<60?n>0?`${t}m ${n}s`:`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}function ki(e){return new Intl.NumberFormat().format(e)}function Ai({projectName:e,onClose:t}){let n=K(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(`standard`),[s,c]=(0,W.useState)(40),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null);ui(!0,t);let _=q({queryKey:[`vectorize-preview`,e],queryFn:()=>Z.getReindexPreview(e)}),v=q({queryKey:[`vector-status`,e],queryFn:()=>Z.getVectorStatus(e),refetchInterval:e=>{let t=e.state.data,n=t?.queueDepthForProject??t?.worker.queueDepth??0,r=t?.worker.queueDepth??0;return n>0||r>0?2e3:3e4},staleTime:1500}),y=_.data,b=v.data,x=_.isLoading,S=_.error,[C]=(0,W.useState)(()=>Date.now()),w=b?.queueDepthForProject??b?.worker.queueDepth??0,T=b?.worker.queueDepth??0,E=Math.max(0,T-w),D=w>0,O=b?.worker.lastProcessedAt??null,k=y?!y.modelInstalled:!1,A=(0,W.useMemo)(()=>a===`custom`?Math.max(1,Math.floor(s)):Di[a].chunks,[a,s]),j=(0,W.useMemo)(()=>{if(!y||y.chunksPerSec<=0)return 0;let e=r?y.pendingForce:y.pendingNew;if(e===0)return 0;let t=r?y.estimatedChunksByDepth.force:y.estimatedChunksByDepth.new,n;if(a===`quick`||a===`standard`||a===`full`)n=t[a];else{let t=Math.max(1,Math.floor(s));n=e*Math.min(t,y.avgChunksPerSession||t)}return n<=0?0:Math.ceil(n/y.chunksPerSec)},[y,r,a,s]),[M,ee]=(0,W.useState)(null),[N,te]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(D&&N===null&&w>0&&(te(w),F(Date.now()),L(null)),!D&&N!==null){let e=!!O&&!!P&&new Date(O).getTime()>P;if(M===null&&N>0&&e){let e=P?Math.max(1,Math.round((Date.now()-P)/1e3)):0;L({drained:N,elapsedSec:e,observedChunksPerSec:e>0?N/e:0,completedAt:Date.now()}),Q({message:`Vectorization complete — ${ki(N)} chunk${N===1?``:`s`} embedded in ${Oi(e)}.`,tone:`success`,duration:8e3})}te(null),F(null)}},[D,w,N,M]);let R=N===null?0:Math.max(0,N-w),z=N&&N>0?Math.min(100,R/N*100):0,B=b?.throughput?.chunksPerSec??0,V=(b?.throughput?.samples??0)>=5,ne=b?.etaSecondsDetail??null,H=ne?.source??`no-samples`,re=b?.queueGrowthChunksPerSec??0,ie=ne?.currentQueue??b?.etaSeconds??0,ae=ne?.withGrowth??null,oe=V&&re>0&&ae===null&&B>0,se=b?.etaForProject??ie,ce=v.dataUpdatedAt,U=(0,W.useMemo)(()=>{if(!P||R<=0)return 0;let e=(Date.now()-P)/1e3;return e<1?0:R/e},[P,R,ce]),le=!!O&&Date.now()-new Date(O).getTime()<5e3,ue=D&&R===0&&P!==null&&b?.throughput?.source!==`local-measured`&&!le,de=U>0?U:B>0?B:y?.chunksPerSec??0,fe=ue?0:se>0?se:de>0?Math.ceil(w/de):0,pe=P?Math.max(0,Math.round((Date.now()-P)/1e3)):0,me=ue?`warming up · loading embedder model (~5-10s on first start)`:U>0?`observed · ${ki(R)} drained in ${pe}s on this run`:b?.throughput?.source===`local-measured`?`measured · ${b.throughput.samples} sample${b.throughput.samples===1?``:`s`}`:y?.throughputSource===`live-benchmark`?`benchmark estimate · refines once chunks start draining`:`warming up · waiting for first session to complete`,[he,ge]=(0,W.useState)(0),[_e,ve]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!D||fe<=0){ge(0),ve(null);return}ve({ts:Date.now(),eta:fe}),ge(fe)},[D,fe,ce]),(0,W.useEffect)(()=>{if(!D||!_e)return;let e=setInterval(()=>{let e=Math.floor((Date.now()-_e.ts)/1e3);ge(Math.max(0,_e.eta-e))},1e3);return()=>clearInterval(e)},[D,_e]);let ye=r?y?.pendingForce??0:y?.pendingNew??0,be=l||x||!!S||k||ye===0,xe=async()=>{if(!p){m(!0),g(null);try{let e=await Z.installVectorModel();if(!e.ok){g(e.error??`install failed`);return}Q({message:`Vectorizer installed. Ready to vectorize.`,tone:`success`,duration:5e3}),await _.refetch(),n.invalidateQueries({queryKey:[`vector-status`]})}catch(e){g(e instanceof Error?e.message:`unknown error`)}finally{m(!1)}}},[Se,Ce]=(0,W.useState)(null),[we,Te]=(0,W.useState)(null),Ee=Se!==null,De=async()=>{if(!l){Ce(null),Te(null),u(!0);try{let t=await Z.reindexProjectVectors(e,r,A);if(t.enqueued===0){Te(t.message??`Already vectorized — every eligible session in ${e} has embeddings. Toggle "Re-embed already-vectorized sessions" below if you want to regenerate.`),Ce(Date.now()),Q({message:`${e} is already vectorized — nothing to do.`,tone:`info`,duration:5e3});return}let i=A===0?`cap ${yi} chunks/session (safety)`:`cap ${A} chunk${A===1?``:`s`}/session`;Q({message:`Vectorizing ${ki(t.enqueued)} session${t.enqueued===1?``:`s`} (${i}). Free, on-device.`,tone:`success`,duration:7e3}),n.setQueryData([`vector-status`,e],n=>({embedder:n?.embedder??{loaded:!0,modelId:`BAAI/bge-base-en-v1.5`,dim:768},worker:{running:!0,queueDepth:t.queueDepth,lastProcessedAt:n?.worker?.lastProcessedAt??null},modelInstalled:n?.modelInstalled??!0,project:e,queueDepthForProject:t.enqueued,etaForProject:n?.etaForProject??0,remainingChunks:n?.remainingChunks,throughput:n?.throughput??{chunksPerSec:0,samples:0,source:`no-samples-yet`},etaSeconds:n?.etaSeconds??0,etaSecondsDetail:n?.etaSecondsDetail,queueGrowthChunksPerSec:n?.queueGrowthChunksPerSec})),n.invalidateQueries({queryKey:[`vector-status`,e],refetchType:`active`})}catch(e){let t=e instanceof Error?e.message:`unknown error`;Q({message:t.startsWith(`403`)?"Vectorize requires a Pro license. Run `recall license activate <KEY>` or upgrade at clauderecall.com.":`Vectorize failed: ${t}`,tone:`error`,duration:1e4})}finally{u(!1)}}},[Oe,ke]=(0,W.useState)(!1),Ae=()=>{d||ke(!0)},je=async()=>{if(ke(!1),d)return;f(!0),ee(Date.now());let e=new AbortController,t=!1,r=setTimeout(()=>{t=!0,e.abort(),f(!1),n.invalidateQueries({queryKey:[`vector-status`]})},8e3);try{let i=await Z.cancelReindex(void 0,e.signal);if(t)return;clearTimeout(r),Q({message:i.cleared>0?`Stop signalled. Cleared ${ki(i.cleared)} queued chunk${i.cleared===1?``:`s`} across all projects. Worker will finish its current batch (~5-15s) and then halt.`:`Nothing to cancel — queue was already empty.`,tone:`info`,duration:6e3}),n.invalidateQueries({queryKey:[`vector-status`]})}catch(e){if(t)return;clearTimeout(r),Q({message:`Stop failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`,duration:6e3}),ee(null)}finally{t||(clearTimeout(r),f(!1))}},Me=M!==null&&b?.worker.running&&Date.now()-M<Ti*1e3,[Ne,Pe]=(0,W.useState)(null),Fe=Ne!==null&&Date.now()-Ne<4e3,Ie=I!==null&&Date.now()-I.completedAt<1e4;(0,W.useEffect)(()=>{if(M!==null){if(!b?.worker.running){Pe(Date.now());let e=setTimeout(()=>ee(null),1500);return()=>clearTimeout(e)}Date.now()-M>Ti*1e3&&ee(null)}},[M,b?.worker.running]);let[,Le]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(!ue&&!Me&&!x&&!Fe&&!Ie)return;let e=setInterval(()=>Le(e=>e+1),500);return()=>clearInterval(e)},[ue,Me,x,Fe,Ie]);let Re=x?Math.max(0,Math.floor((Date.now()-C)/1e3)):0,ze=Math.min(Ei,Re/bi*Ei),Be=Re>=xi,Ve=Re>=Si,He=ue&&P?Math.max(0,Math.floor((Date.now()-P)/1e3)):0,Ue=Math.min(Ei,He/bi*Ei),We=He>=xi,Ge=He>=Si,Ke=Me&&M?Math.max(0,Math.floor((Date.now()-M)/1e3)):0,qe=Math.min(Ei,Ke/Ci*Ei),Je=Ke>=wi;return(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:[(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[560px] max-w-[92vw] max-h-[88vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`vectorize-dialog-title`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{id:`vectorize-dialog-title`,className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧠`}),(0,G.jsxs)(`span`,{children:[D?`Vectorizing`:`Vectorize`,` `,(0,G.jsx)(`span`,{className:`text-accent`,children:e})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),x&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-4 bg-yellow-400/5 border-yellow-400/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-yellow-400 animate-pulse`}),(0,G.jsx)(`span`,{className:`text-sm font-medium text-yellow-400`,children:`Warming up — preparing the embedder`})]}),(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-yellow-400/90 uppercase tracking-wide`,children:[Ve?`Still working`:`Loading`,` · `,Re,`s elapsed`]}),(0,G.jsx)(`span`,{className:`font-mono text-yellow-400/70`,children:Ve?`stuck?`:`${ze.toFixed(0)}%`})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-yellow-400/30`,children:(0,G.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out ${Ve?`bg-red-400/70`:`bg-yellow-400/70`}`,style:{width:`${ze}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-3 leading-snug`,children:Ve?`Preview has been loading for ${Re}s. Something may be wrong — check the daemon log at ~/.recall/daemon.log or run \`recall doctor\`.`:Be?`Still preparing after ${Re}s — slower than usual. Older machines or first-ever start can take up to 60-90s. Embedder is a 140MB local model; nothing leaves your computer.`:`Loading the 140MB embedder model and running a quick benchmark. First start usually takes ~30 seconds, sometimes up to a minute on slower machines. Subsequent runs are much faster (model stays cached in memory).`})]}),S&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400 py-4`,children:[`Failed to load preview: `,S.message]}),Fe&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none`,children:`✓`}),(0,G.jsx)(`span`,{className:`text-sm font-medium text-green-400`,children:`Stopped — worker halted and queue cleared`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1.5 pl-7`,children:`Nothing is running in the background. Click Start vectorization later to resume.`})]}),Ie&&I&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none`,children:`✓`}),(0,G.jsxs)(`span`,{className:`text-sm font-medium text-green-400`,children:[`Vectorization complete — `,ki(I.drained),` chunk`,I.drained===1?``:`s`,` embedded in `,Oi(I.elapsedSec)]})]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-1.5 pl-7`,children:[I.observedChunksPerSec>0&&(0,G.jsxs)(G.Fragment,{children:[`Observed `,I.observedChunksPerSec.toFixed(1),` chunks/sec on this CPU · `]}),`local-only · no telemetry. Run another scope below, or close this dialog.`]})]}),Ee&&(0,G.jsx)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none mt-0.5`,children:`✓`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-green-400`,children:`Already vectorized`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1 leading-snug`,children:we??`Every eligible session in ${e} has embeddings.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{Ce(null),Te(null)},className:`text-fg-muted hover:text-fg text-sm leading-none`,"aria-label":`dismiss already-vectorized notice`,title:`Dismiss`,children:`✕`})]})}),k&&!D&&(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg p-4 mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl`,children:`📦`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium text-base mb-1`,children:`Vectorizer not installed yet`}),(0,G.jsxs)(`div`,{className:`text-sm text-fg-muted`,children:[`One-time setup. Downloads `,(0,G.jsx)(`code`,{className:`text-fg`,children:`BAAI/bge-base-en-v1.5`}),` `,`(~110\xA0MB) and runs the embedder entirely on this machine.`]})]})]}),(0,G.jsxs)(`ul`,{className:`text-sm space-y-0.5 mb-4 ml-9`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No account required`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No telemetry — model runs locally only`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` Resumable — re-running picks up where it stopped`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` SHA-256 verified per file`]})]}),h&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400 mb-3 bg-red-400/10 border border-red-400/30 rounded p-2`,children:[`Install failed: `,h]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:xe,disabled:p,className:`px-4 py-2 text-sm border border-accent rounded text-accent hover:bg-accent/10 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2`,children:p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,G.jsx)(`span`,{children:`Downloading model…`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`⬇`}),(0,G.jsx)(`span`,{children:`Install vectorizer (~110 MB)`})]})}),(0,G.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:`Prefer the terminal?`}),(0,G.jsx)(`code`,{className:`block mt-2 bg-black/30 px-2 py-1 rounded text-xs`,children:`recall semantic install`})]})]}),p&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-3`,children:`Downloading from HuggingFace. Typically 30s-2min depending on your connection. Safe to leave the dialog open.`})]}),D&&y&&!k&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-4 ${Me?`bg-red-400/5 border-red-400/40`:`bg-accent/5 border-accent/40`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${Me?`bg-red-400 animate-pulse`:ue?`bg-yellow-400 animate-pulse`:b?.worker.running?`bg-accent animate-pulse`:`bg-accent`}`}),(0,G.jsx)(`span`,{className:`text-sm font-medium ${Me?`text-red-400`:ue?`text-yellow-400`:`text-accent`}`,children:Me?ue?`Stopping — will abort as soon as the embedder finishes loading`:`Stopping — finishing current batch (≤10 chunks)`:ue?`Warming up — loading embedder model`:b?.worker.running?`Vectorizing now`:`Queue ready, worker idle`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:[`Queued for `,e]}),(0,G.jsxs)(`div`,{className:`font-mono text-base`,children:[ki(w),` chunks`]}),E>0&&(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-0.5 leading-snug`,children:[`+`,ki(E),` queued from other projects`,(0,G.jsx)(`br`,{}),`(drain ahead of yours, FIFO)`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`Throughput`}),(0,G.jsx)(`div`,{className:`font-mono text-base`,children:ue?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`warming up…`}):de>0?`${de.toFixed(1)}/s`:`—`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`ETA remaining`}),(0,G.jsx)(`div`,{className:`font-mono text-base tabular-nums`,children:ue?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`computing…`}):!V&&B===0?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`warming up — ETA pending`}):oe?(0,G.jsx)(`span`,{className:`text-red-400/90 text-sm`,children:`queue growing faster than draining`}):he>0?`~${Oi(he)}`:`—`}),V&&H===`live`&&ae!==null&&(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-0.5 leading-snug`,children:[`queue growing · with growth: ~`,Oi(ae)]}),oe&&(0,G.jsx)(`div`,{className:`text-[10px] text-red-400/80 mt-0.5 leading-snug`,children:`may not complete at current rate`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`Last completed`}),(0,G.jsx)(`div`,{className:`font-mono text-xs`,children:O?new Date(O).toLocaleTimeString():`none yet`})]})]}),ue&&!Me&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-yellow-400/90 uppercase tracking-wide`,children:[`Warming up · `,He,`s elapsed`]}),(0,G.jsx)(`span`,{className:`font-mono text-yellow-400/70`,children:Ge?`stuck?`:`${Ue.toFixed(0)}%`})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-yellow-400/30`,children:(0,G.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out ${Ge?`bg-red-400/70`:`bg-yellow-400/70`}`,style:{width:`${Ue}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-2 leading-snug`,children:Ge?`Still warming up after ${He}s. Something may be wrong — check the daemon log at ~/.recall/daemon.log or run \`recall doctor\`.`:We?`Still loading after ${He}s — slower than usual. Older machines or first-ever start can take up to 60-90s. Embedder is a 140MB local model; nothing leaves your computer.`:b?.embedder?.loaded?`Embedder is loaded — worker preparing the first batch. Should be moments away.`:`Loading the 140MB embedder model into memory. First start usually takes ~30 seconds, sometimes up to a minute on slower machines. Subsequent runs are much faster (model stays cached).`})]}),Me&&!ue&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-red-400/90 uppercase tracking-wide`,children:[`Winding down · `,Ke,`s elapsed`]}),(0,G.jsxs)(`span`,{className:`font-mono text-red-400/70`,children:[qe.toFixed(0),`%`]})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-red-400/30`,children:(0,G.jsx)(`div`,{className:`h-full bg-red-400/70 transition-all duration-500 ease-out`,style:{width:`${qe}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-2 leading-snug`,children:Je?`Wind-down at ${Ke}s — slower than usual. The worker may be mid-cold-start; it will stop as soon as the current batch finishes embedding.`:`Worker finishes its current 10-chunk batch before stopping. Typically 5-15 seconds, sometimes longer during a cold start.`})]}),N!==null&&N>0&&!ue&&!Me&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted uppercase tracking-wide`,children:`Progress this session`}),(0,G.jsxs)(`span`,{className:`font-mono text-fg`,children:[ki(R),` / `,ki(N),` (`,z.toFixed(1),`%)`]})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-accent/20`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all duration-700 ease-out`,style:{width:`${z}%`}})})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-3 pt-3 border-t border-accent/20`,children:[me,` · polled every 2s · ETA ticks every 1s · local-only`]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mb-4`,children:`Worker drains the queue in the background. Closing this dialog doesn't stop it — only the Stop button does. Re-open the dialog any time to check progress.`})]}),!D&&y&&!k&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Scope`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-semibold text-accent`,children:ki(ye)}),` `,`of `,ki(y.eligible),` eligible session`,y.eligible===1?``:`s`,` `,`will be vectorized`]}),!r&&y.indexed>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[ki(y.indexed),` already vectorized — skipped (toggle below to re-embed)`]}),r&&y.indexed>0&&(0,G.jsxs)(`div`,{className:`text-accent text-xs mt-1`,children:[`Force re-embed ON: existing vectors for `,ki(y.indexed),` session`,y.indexed===1?``:`s`,` will be deleted and regenerated.`]}),y.total!==y.eligible&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[ki(y.total-y.eligible),` session`,y.total-y.eligible===1?``:`s`,` excluded (fewer than 3 messages)`]})]})]}),(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Cost`}),(0,G.jsxs)(`ul`,{className:`text-sm space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` Free — zero plan tokens`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` On-device CPU only — no Anthropic calls`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No network — model runs locally (`,y.modelName,`)`]})]})]}),(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Depth per session`}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[[`quick`,`standard`,`full`].map(e=>{let t=Di[e];return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded border cursor-pointer transition-colors ${a===e?`border-accent bg-accent/5`:`border-line hover:border-fg-muted`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`depth`,value:e,checked:a===e,onChange:()=>o(e),className:`mt-1 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`div`,{className:`flex-1 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:t.label}),(0,G.jsxs)(`span`,{className:`text-fg-muted text-xs font-mono`,children:[t.messages,` msgs / session · `,t.chunks===0?`no cap`:`cap ${t.chunks} chunks`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:t.sub})]})]},e)}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded border cursor-pointer transition-colors ${a===`custom`?`border-accent bg-accent/5`:`border-line hover:border-fg-muted`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`depth`,value:`custom`,checked:a===`custom`,onChange:()=>o(`custom`),className:`mt-1 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`div`,{className:`flex-1 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Custom`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:1e3,value:s,onChange:e=>{o(`custom`),c(Math.max(1,Math.min(1e3,Number(e.target.value)||1)))},onClick:e=>e.stopPropagation(),className:`bg-bg border border-line rounded px-1.5 py-0.5 text-xs w-16 font-mono`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:`chunks per session`})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:`Each chunk ≈ 3-5 messages. Set the cap that fits your sessions.`})]})]})]})]}),ye===0?(0,G.jsx)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none mt-0.5`,children:`✓`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-green-400`,children:y.eligible===0?`No eligible sessions in ${e}`:`No need to vectorize — ${e} is already done`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1 leading-snug`,children:y.eligible===0?`Every session in this project has fewer than 3 messages, which is below the vectorize threshold. Nothing to embed.`:`All ${ki(y.indexed)} eligible session${y.indexed===1?``:`s`} in this project already have embeddings. Toggle "Re-embed already-vectorized sessions" below if you want to regenerate them.`})]})]})}):(0,G.jsxs)(`section`,{className:`mb-4 bg-bg border border-line rounded p-3`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Estimated time`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{className:`font-semibold`,children:[`~`,Oi(j)]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[y.throughputSource===`local-measured`&&(0,G.jsxs)(G.Fragment,{children:[`Based on your last `,y.throughputSamples,` vectorized session`,y.throughputSamples===1?``:`s`,` on this machine`,` `,`(`,y.chunksPerSec.toFixed(1),` chunks/sec). Local measurement, no telemetry.`]}),y.throughputSource===`live-benchmark`&&(0,G.jsxs)(G.Fragment,{children:[`Just measured: `,y.chunksPerSec.toFixed(1),` chunks/sec on this CPU`,` `,`(quick benchmark on dialog open). Estimate refines as the worker runs. Local measurement, no telemetry.`]}),y.throughputSource===`fallback-baseline`&&(0,G.jsx)(G.Fragment,{children:`Generic baseline — embedder isn't loaded yet so no live measurement. Will refine after the first sessions complete. Local-only, never sent off-device.`})]})]})]}),y.queueDepthOther>0&&(0,G.jsxs)(`section`,{className:`mb-4 text-xs text-fg-muted bg-bg border border-line rounded p-2`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg mb-0.5`,children:`Heads up`}),ki(y.queueDepthOther),` chunk`,y.queueDepthOther===1?``:`s`,` already queued from other projects. Your sessions will be vectorized after those drain.`]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 mb-4 p-2 rounded border border-line hover:border-fg-muted text-sm cursor-pointer transition-colors`,title:`Re-embed deletes existing vectors for already-vectorized sessions and regenerates them from scratch using the depth setting above. Useful when changing depth on existing data, or if you suspect bad embeddings. Skip otherwise — vectors are stable.`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-0.5 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{children:`Re-embed already-vectorized sessions`}),r&&y.indexed>0&&(0,G.jsxs)(`span`,{className:`text-xs text-accent font-mono`,children:[`+`,ki(y.indexed),` session`,y.indexed===1?``:`s`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:`Deletes existing vectors and regenerates them from scratch. Use only if you're changing depth on existing data or suspect bad embeddings.`})]})]})]}),(0,G.jsx)(`div`,{className:`flex justify-end gap-2 pt-2 border-t border-line`,children:D?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:`Run in background`}),(0,G.jsx)(`button`,{type:`button`,onClick:Ae,disabled:d||Me,className:`px-3 py-1.5 text-sm border border-red-400/60 rounded text-red-400 hover:bg-red-400/10 disabled:opacity-40 disabled:cursor-not-allowed inline-flex items-center gap-1.5`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-red-400 border-t-transparent rounded-full animate-spin`}),`Stopping…`]}):Me?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-red-400 border-t-transparent rounded-full animate-spin`}),`Winding down…`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`■`}),` Stop`]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:De,disabled:be,className:`px-3 py-1.5 text-sm border border-accent rounded text-accent hover:bg-accent/10 disabled:opacity-40 disabled:cursor-not-allowed disabled:border-line disabled:text-fg-muted`,children:l?`Starting…`:`Start vectorization`})]})})]}),(0,G.jsx)(vi,{open:Oe,icon:`⏹`,title:`Stop ALL vectorization?`,tone:`danger`,confirmLabel:`Stop everything`,cancelLabel:`Keep going`,message:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`mb-2`,children:[`Clears the entire vectorize queue across every project`,` `,`and halts the worker. The in-flight batch`,` `,`(≤\xA010\xA0chunks) finishes first, then the worker stops.`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Already-vectorized sessions stay. Cleared sessions go back to`,` `,`"needs vectorization" — click Start later (per project) to`,` `,`resume just the ones you want.`]})]}),onConfirm:je,onCancel:()=>ke(!1)})]})}function ji(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Mi({projectName:e}){let[t,n]=(0,W.useState)(!1),r=At(),i=q({queryKey:[`vector-status`,e],queryFn:()=>Z.getVectorStatus(e??void 0),enabled:r&&!!e,refetchInterval:e=>{let t=e.state.data;return(t?.queueDepthForProject??t?.worker.queueDepth??0)>0?3e3:3e4},staleTime:2e3});if(!e||!r)return null;let a=i.data,o=a?.queueDepthForProject??a?.worker.queueDepth??0,s=a?.modelInstalled??!0,c=o>0,l=!s&&a!==void 0,u=c?`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-accent/60 rounded text-accent bg-accent/10 hover:bg-accent/20 transition-colors`:l?`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-accent/60 rounded text-accent hover:bg-accent/10 transition-colors`:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-line rounded text-fg-muted hover:text-accent hover:border-accent transition-colors`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),title:c?`Tier-2 vectorizer is running (${o.toLocaleString()} chunk${o===1?``:`s`} queued). Click for live progress + stop button. Free, on-device, zero tokens.`:l?`Vector model not installed yet. Click to install in one tap (~110 MB, on-device, no account, no telemetry).`:`Embed every session in this project for similarity search. Tier-2 — free, on-device CPU, zero plan tokens. Opens a confirmation with scope and ETA before anything runs.`,className:u,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧠`}),c?(0,G.jsxs)(`span`,{children:[`Vectorizing\xA0`,(0,G.jsx)(`span`,{className:`font-mono`,children:ji(o)}),`\xA0queued`]}):l?(0,G.jsx)(`span`,{children:`Set up vectorizer`}):(0,G.jsx)(`span`,{children:`Vectorize`})]}),t&&(0,G.jsx)(Ai,{projectName:e,onClose:()=>n(!1)})]})}var Ni=new Set([`low_signal`,`recursive_meta`,`programmatic`]);function Pi({sessionId:e,x:t,y:n,pinned:r,recallPromptsAvailable:i,titleQuality:a,onClose:o,onTogglePin:s,onAddToCollection:c,onCompareWith:l,onOpen:u,onLinkToSession:d,onRegenerateTitle:f,onRunPrompt:p}){let m=!!f&&!!a&&Ni.has(a),h=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&o()},t=e=>{e.key===`Escape`&&o()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[o]);let g=Math.min(t,window.innerWidth-240-8),_=Math.min(n,window.innerHeight-300-8),v=()=>{navigator.clipboard.writeText(e),Q({message:`Session ID copied: ${e.slice(0,8)}…`,tone:`info`}),o()},y=async t=>{o();try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/context?mode=${t}`);if(!n.ok)throw Error(`${n.status} ${n.statusText}`);let r=await n.text();await navigator.clipboard.writeText(r),Q({message:`Copied ${r.length.toLocaleString()} chars (${t}). Paste into a new Claude session.`,tone:`success`,duration:6e3})}catch(e){Q({message:`Copy failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsxs)(`div`,{ref:h,role:`menu`,"aria-label":`session actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:g,top:_,width:240},children:[(0,G.jsx)(Fi,{label:`Open session`,hint:`jump to transcript`,onClick:()=>{o(),u()}}),(0,G.jsx)(Fi,{label:r?`★ Unpin`:`☆ Pin to top`,onClick:()=>{o(),s()}}),(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`Copy session ID`,hint:`${e.slice(0,8)}…`,onClick:v}),(0,G.jsx)(Fi,{label:`📋 Copy as context`,hint:`condensed markdown, paste into new Claude`,onClick:()=>void y(`condensed`)}),(0,G.jsx)(Fi,{label:`📋 Copy full markdown`,hint:`uncondensed transcript with tool I/O`,onClick:()=>void y(`full`)}),(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`📂 Add to collection…`,onClick:()=>{o(),c()}}),(0,G.jsx)(Fi,{label:`⇄ Compare with another session`,onClick:()=>{o(),l()}}),(0,G.jsx)(Fi,{label:`🔗 Link to session…`,hint:`manual wiki-link, surfaces under both sessions' Linked panel`,onClick:()=>{o(),d()}}),m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`✨ Regenerate title from context`,hint:`uses parent / child / cited sessions to mint a new title`,onClick:()=>{o(),f?.()}})]}),p&&i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ii,{}),(0,G.jsx)(`div`,{className:`px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wider text-fg-muted`,children:`Ask Claude Code (via MCP)`}),(0,G.jsx)(Fi,{label:`📝 Summarize this session`,hint:`3–5 bullets of what shipped / was tried / is open`,onClick:()=>{o(),p(`summarize_session`,`Summarize this session`,{sessionId:e})}}),(0,G.jsx)(Fi,{label:`🎯 Extract decisions`,hint:`architectural / product decisions with why + alternatives`,onClick:()=>{o(),p(`extract_decisions`,`Extract decisions`,{sessionId:e})}}),(0,G.jsx)(Fi,{label:`🔍 Find similar sessions`,hint:`5 sessions that touched the same topic, with reasons`,onClick:()=>{o(),p(`find_similar_sessions`,`Find similar sessions`,{sessionId:e})}})]})]})}function Fi({label:e,hint:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:n,className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:t})]})}function Ii(){return(0,G.jsx)(`div`,{className:`border-t border-line my-1`})}function Li({sessionIds:e,x:t,y:n,onClose:r,onClearSelection:i}){let a=(0,W.useRef)(null),o=e.length;(0,W.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[r]);let s=Math.min(t,window.innerWidth-260-8),c=Math.min(n,window.innerHeight-180-8),l=async(e,t)=>{try{await navigator.clipboard.writeText(e),Q({message:`Copied ${o} session ID${o===1?``:`s`} (${t})`,tone:`success`})}catch(e){Q({message:`Copy failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsxs)(`div`,{ref:a,role:`menu`,"aria-label":`multi-select session actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:s,top:c,width:260},children:[(0,G.jsxs)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted`,children:[o,` session`,o===1?``:`s`,` selected`]}),(0,G.jsx)(zi,{}),(0,G.jsx)(Ri,{label:`Copy session IDs`,hint:`one per line`,onClick:()=>{r(),l(e.join(`
|
|
12
|
+
DELETE FROM threads WHERE id LIKE 'auto-scan-%';"`,Pr=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,note:`fastest, cheapest, plenty smart for short titles. Recommended.`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,note:`slightly nicer phrasing, but ~3x the cost of Haiku for the same task.`},{value:`claude-opus-4-7`,label:`Opus 4.7`,note:`overkill for naming. Costs ~15x Haiku and burns ~10x more of your 5-hour window.`}];function Fr({project:e,onClose:t,onOpenThreadsPage:n}){let r=K(),[i,a]=(0,W.useState)(`preflighting`),[o,s]=(0,W.useState)(.7),[c,l]=(0,W.useState)(!0),[u,d]=(0,W.useState)(Pr[0].value),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(.4),[g,_]=(0,W.useState)(.7),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)([]),O=(0,W.useRef)(null);(0,W.useEffect)(()=>{let t=!1;return a(`preflighting`),x(null),(async()=>{try{let n=f?{enabled:!0,band_lo:m,band_hi:g,model:`claude-haiku-4-5-20251001`}:void 0,r=await Z.threadScanPreflight({project:e,threshold:o,model:u,llm_rescore:n});if(t)return;y(r),a(`preview`)}catch(e){if(t)return;x(e instanceof Error?e.message:String(e)),a(`preview`)}})(),()=>{t=!0}},[e,o,u,f,m,g]),(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`launching`&&t()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,t]),(0,W.useEffect)(()=>{if(!S)return;let e=new EventSource(mt(`/api/threads/scan/jobs/${encodeURIComponent(S)}/stream`));return O.current=e,e.addEventListener(`progress`,e=>{try{let t=JSON.parse(e.data);t.phase===`naming`&&t.thread_name&&t.total&&D(e=>[...e,{current:t.current??0,total:t.total??0,thread_name:t.thread_name}].slice(-8))}catch{}}),e.addEventListener(`done`,t=>{try{let e=JSON.parse(t.data);T(e),e.status===`failed`?(x(e.error),a(`failed`)):e.status===`cancelled`?a(`cancelled`):a(`done`)}catch{a(`done`)}e.close(),r.invalidateQueries({queryKey:[`threads`]}),r.invalidateQueries({queryKey:[`thread-folders`]})}),e.addEventListener(`error`,()=>{x(`Stream disconnected`),a(`failed`),e.close()}),()=>{e.close(),O.current=null}},[S,r]);async function k(){x(null),D([]),a(`launching`);try{let t=f?{enabled:!0,band_lo:m,band_hi:g,model:`claude-haiku-4-5-20251001`}:void 0,{jobId:n,reused:r}=await Z.threadScanApply({project:e,threshold:o,llm_names:c,model:u,llm_rescore:t});C(n),a(`running`),r&&Q({message:`A scan for ${e} was already running. Attached.`,tone:`info`})}catch(e){x(e instanceof Error?e.message:String(e)),a(`preview`)}}async function A(){if(S)try{await Z.threadScanCancel(S),Q({message:`Cancellation requested`,tone:`info`})}catch(e){Q({message:`Cancel failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}function j(){navigator.clipboard?.writeText(Nr),Q({message:`Rollback command copied`,tone:`info`})}let M=i===`preview`&&v!==null&&v.eligible_sessions>0&&v.proposed_edges>0;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`launching`&&t()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg`,children:[`🧵 Detect threads in `,e]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:i===`launching`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`running`?`run in background ↗`:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(i===`preflighting`||i===`preview`)&&(0,G.jsx)(Ir,{loading:i===`preflighting`,preflight:v,threshold:o,onThresholdChange:s,llmNames:c,onLlmNamesChange:l,model:u,onModelChange:d,rescoreEnabled:f,onRescoreEnabledChange:p,rescoreLo:m,rescoreHi:g,onRescoreBandChange:(e,t)=>{h(e),_(t)}}),(i===`launching`||i===`running`||i===`cancelled`)&&(0,G.jsx)(Ur,{project:e,snapshot:w,recentNames:E,estimatedThreads:v?.estimated_threads??0,cancelled:i===`cancelled`}),i===`done`&&w&&(0,G.jsx)(Wr,{project:e,snapshot:w,onOpenThreadsPage:n,onCopyRollback:j}),i===`failed`&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-1`,children:`Scan failed`}),(0,G.jsx)(`div`,{children:b??`Unknown error`})]}),b&&i===`preview`&&(0,G.jsx)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:b})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[i===`preview`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded border border-line hover:bg-bg-hover`,children:`Cancel`}),(0,G.jsxs)(`button`,{type:`button`,onClick:k,disabled:!M,className:`text-xs px-3 py-1.5 rounded bg-accent text-white disabled:opacity-40 disabled:cursor-not-allowed hover:bg-accent/80`,children:[`Apply (`,v?.estimated_threads??0,` thread`,v?.estimated_threads===1?``:`s`,`)`]})]}),i===`running`&&(0,G.jsx)(`button`,{type:`button`,onClick:A,className:`text-xs px-3 py-1.5 rounded border border-role-user/40 text-role-user hover:bg-role-user/10`,children:`Cancel scan`}),(i===`done`||i===`cancelled`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded bg-accent text-white hover:bg-accent/80`,children:`Close`})]})]})})}function Ir({loading:e,preflight:t,threshold:n,onThresholdChange:r,llmNames:i,onLlmNamesChange:a,model:o,onModelChange:s,rescoreEnabled:c,onRescoreEnabledChange:l,rescoreLo:u,rescoreHi:d,onRescoreBandChange:f}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Gr,{label:`What is a thread?`,children:(0,G.jsxs)(`div`,{className:`space-y-2 leading-relaxed`,children:[(0,G.jsxs)(`p`,{children:[`A `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`thread`}),` is a chain of past sessions in this project that belong to one workflow. You closed one session, opened another, kept going.`]}),(0,G.jsx)(`p`,{children:`Six signals decide whether two sessions belong together. All run locally on your machine. None of them spend tokens.`}),(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Time proximity.`}),` `,`Did the next session start soon after the last one ended?`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Continuation cues.`}),` `,`We scan the first 7 user messages for phrases like "let's commit", "next step", "continuing from". Catches openings that start with banter and pivot in a few prompts.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`File overlap.`}),` `,`Did both sessions touch the same files?`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Semantic similarity.`}),` `,`Three views of the same local embeddings: full-session means, parent ending vs child opening, and the single best chunk-to-chunk match. Tool-output chunks (file dumps, command listings) are filtered out so they do not muddy the signal.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Cluster prior.`}),` `,`If both sessions land in the same workflow cluster (computed from the same embeddings, no extra cost), small bonus.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`•`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Shared brand.`}),` `,`Same skill or brand marker. Weak tiebreaker.`]})]})]})]})}),(0,G.jsx)(zr,{threadCount:t?.estimated_threads??0,sessionCount:t?.eligible_sessions??0,edgeCount:t?.proposed_edges??0,model:o,llmNames:i}),(0,G.jsx)(Rr,{value:n,onChange:r}),(0,G.jsx)(Br,{value:o,onChange:s,disabled:!i}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!i,onChange:e=>a(!e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Skip LLM thread-naming (free, uses root session text)`}),(0,G.jsx)(`div`,{className:`text-fg-muted/70`,children:`Less polished names, but zero token cost and zero plan-window use.`})]})]}),(0,G.jsx)(Lr,{enabled:c,onEnabledChange:l,lo:u,hi:d,onBandChange:f,preflight:t}),e&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30 flex items-center gap-3 text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-accent border-t-transparent animate-spin`}),(0,G.jsx)(`span`,{children:`Counting eligible sessions and proposed edges…`})]}),!e&&t&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(Vr,{preflight:t,llmNames:i}),i&&t.estimated_threads>0&&(0,G.jsx)(Hr,{estimate:t.plan_window_estimate,llmCalls:t.estimated_llm_calls}),i&&(0,G.jsxs)(Gr,{label:`Token + USD detail (for API-key users on ${Pr.find(e=>e.value===t.model)?.label??`this model`})`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1.5 mb-3`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Input tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:t.estimated_input_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Output tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:t.estimated_output_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg font-medium`,children:`Estimated cost (max)`}),(0,G.jsxs)(`div`,{className:`text-accent font-mono tabular-nums text-right font-semibold`,children:[`$`,t.estimated_cost_usd_max.toFixed(4)]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`These numbers only apply if you pay Anthropic directly through your own API key. On Claude Pro or Max, ignore the dollar amount. Your real cost is the 5-hour window slice shown in the bars above.`})]}),(0,G.jsx)(Gr,{label:`How accurate is this estimate?`,children:(0,G.jsxs)(`ul`,{className:`space-y-2 leading-relaxed`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Session, edge, and thread counts are exact.`}),` `,`We compute them by running the same graph algorithm the scan itself uses. They will not change between this preview and the actual run.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Token, cost, and window numbers are an upper bound.`}),` `,`Each thread triggers one short Haiku 4.5 call (about`,` `,`500 input + 30 output tokens). Bigger threads make slightly bigger prompts, so real usage is typically within plus or minus 20% of what you see here.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`●`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Your session content stays local.`}),` `,`Only short session titles or first-message snippets are sent to Anthropic for naming. Your JSONL transcripts never leave your machine.`]})]})]})}),t.existing_auto_scan_threads>0&&(0,G.jsxs)(`div`,{className:`p-2 rounded border border-role-tool/40 bg-role-tool/10 text-role-tool`,children:[`⚠ This project already has`,` `,t.existing_auto_scan_threads,` auto-scan thread`,t.existing_auto_scan_threads===1?``:`s`,`. Running again creates new threads alongside the old ones. Use the rollback command (shown on the done panel) to clear the previous scan first if you want a clean rerun.`]}),t.proposed_edges===0&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`No edges above threshold. Lower the slider or accept that this project has no detectable workflow chains at the current setting.`})]})]})}function Lr({enabled:e,onEnabledChange:t,lo:n,hi:r,onBandChange:i,preflight:a}){let o=a?.llm_rescore??null;return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/20 space-y-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`LLM re-score on borderline pairs`}),(0,G.jsx)(`div`,{className:`text-fg-muted/70`,children:`Spend a small Haiku 4.5 call on each pair whose deterministic confidence falls inside the band below. Promotes confirmed continuations, demotes false positives, leaves uncertain pairs alone. Pairs outside the band are decided by the free 6-signal stack.`})]})]}),e&&(0,G.jsxs)(`div`,{className:`pl-6 space-y-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Borderline band`}),(0,G.jsxs)(`span`,{className:`font-mono text-fg-muted tabular-nums`,children:[n.toFixed(2),` – `,r.toFixed(2)]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`low`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:n,onChange:e=>{let t=Number(e.target.value);i(Math.min(t,r),r)},className:`w-full accent-accent`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`high`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:r,onChange:e=>{let t=Number(e.target.value);i(n,Math.max(t,n))},className:`w-full accent-accent`})]})]})]}),o&&(0,G.jsxs)(`div`,{className:`border border-line/60 rounded p-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-1`,children:[(0,G.jsx)(`div`,{children:`Borderline pairs`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_borderline_pairs}),(0,G.jsx)(`div`,{children:`LLM input tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_input_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{children:`LLM output tokens (max)`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:o.estimated_output_tokens_max.toLocaleString()}),(0,G.jsx)(`div`,{className:`text-fg font-medium`,children:`Estimated cost (max)`}),(0,G.jsxs)(`div`,{className:`text-accent font-mono tabular-nums text-right font-semibold`,children:[`$`,o.estimated_cost_usd_max.toFixed(4)]})]}),o.exceeds_cap&&(0,G.jsxs)(`div`,{className:`text-role-user mt-1`,children:[`⚠ `,o.estimated_borderline_pairs,` pairs exceeds the cap of `,o.cap,`. Tighten the band or scan a smaller project — the rescore step will be skipped at this size.`]}),o.estimated_borderline_pairs===0&&(0,G.jsx)(`div`,{children:`No borderline pairs at this band. The deterministic scorer already decided every proposal — rescore is a no-op.`})]})]})]})}function Rr({value:e,onChange:t}){let n=``,r=`text-fg-muted`;return e<=.6?(n=`Loose: catches more chains, more false positives`,r=`text-role-tool`):e<=.75?(n=`Balanced (recommended): drops file-only coincidences`,r=`text-accent`):e<=.9?(n=`Strict: requires multiple strong signals`,r=`text-fg`):(n=`Very strict: only near-certain chains`,r=`text-fg`),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Confidence threshold`}),(0,G.jsx)(`span`,{className:`font-mono text-fg-muted tabular-nums`,children:e.toFixed(2)})]}),(0,G.jsx)(`input`,{type:`range`,min:.5,max:1,step:.05,value:e,onChange:e=>t(Number(e.target.value)),className:`w-full accent-accent`}),(0,G.jsx)(`div`,{className:`mt-1.5 font-medium ${r}`,children:n}),(0,G.jsx)(`div`,{className:`text-fg-muted mt-2 leading-relaxed`,children:`Every pair of sessions gets a confidence score from 0 to 1. The higher you set this slider, the more sure we have to be that two sessions belong to the same workflow before we link them. 0.7 is a good middle ground, and it's what the CLI uses by default.`})]})}function zr({threadCount:e,sessionCount:t,edgeCount:n,model:r,llmNames:i}){let a=Pr.find(e=>e.value===r)?.label??`Haiku 4.5`,o=r.includes(`opus`)?8:r.includes(`sonnet`)?5:3,s=i?e*o:0,c=Math.max(1,Math.round(s/60));return(0,G.jsx)(Gr,{label:`How does this work, technically?`,children:(0,G.jsxs)(`div`,{className:`space-y-3 leading-relaxed`,children:[(0,G.jsx)(`p`,{children:`The scan runs in two steps inside Claude Recall. Only the second step talks to Claude.`}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`Step 1`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Find the connections (stays on your machine)`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:`no Claude, no internet, no subprocess`})]}),(0,G.jsx)(`p`,{className:`text-fg-muted mb-2`,children:`For every pair of sessions, we score how likely they belong to the same workflow. Six signals, real session data, not just titles. All local, zero tokens.`}),(0,G.jsxs)(`ul`,{className:`space-y-1.5 ml-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`1.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Files they touched.`}),` `,`Every Read, Edit, Write, and Bash file path from each session's JSONL. Two sessions editing the same files are very likely one workflow. Strongest signal.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`2.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`How the next session opens.`}),` `,`We scan up to the first 7 user messages for cues like "let's commit", "next step", "continuing from". Catches openings that start with banter and pivot a few prompts in.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`3.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Time gap.`}),` `,`Closing one session and starting another within an hour scores way higher than two days apart.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`4.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Semantic similarity.`}),` `,`Three views of the same local embeddings, we take the strongest match: full-session means, parent ending vs child opening, and the single best chunk-to-chunk pair. Tool-output chunks (file dumps, command listings) are filtered out before pooling. Skipped silently for any session that has no embedding yet.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`5.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Cluster prior.`}),` `,`Quick connected-components clustering over the same embeddings groups sessions that talk about the same workflow. Pairs that land in the same cluster get a small bonus.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0`,children:`6.`}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Shared brand or skill.`}),` `,`Small bonus when both sessions share a skill prefix or brand marker.`]})]})]}),(0,G.jsxs)(`p`,{className:`text-fg-muted mt-2`,children:[`Pairs at or above your threshold become edges. Edges group into chains. Each chain is one thread.`,` `,t>0&&(0,G.jsxs)(`span`,{className:`text-fg`,children:[`Right now: `,t,` session`,t===1?``:`s`,`, `,n,` edge`,n===1?``:`s`,`, `,e,` thread`,e===1?``:`s`,`.`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted/70 mt-2 text-[10px] leading-relaxed`,children:`Step 1 finishes in seconds even on huge projects, and the numbers are exact, not a sample. We deliberately do not send full transcripts to a model here. For hundreds of sessions that would be slow, costly, and prone to false connections. The six signals above catch the obvious cases for free.`})]}),(0,G.jsxs)(`div`,{className:`border rounded p-3 ${i?`border-accent/40 bg-accent/5`:`border-line bg-bg-hover/30 opacity-60`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`Step 2`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:i?`Name each thread (one ${a} call per thread)`:`Name each thread (skipped, free)`})]}),i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-fg-muted mb-2`,children:[`Step 1 already decided which sessions belong together. Now we give each chain one short workflow name like "Remotion Dependency Update and Inspection".`,` `,(0,G.jsx)(`span`,{className:`text-fg`,children:`Your session titles stay exactly as they are. The new name is for the thread itself, not the sessions inside it.`})]}),(0,G.jsxs)(`ol`,{className:`space-y-1.5 ml-1`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`1.`}),` For each thread, the daemon spawns one short`,` `,(0,G.jsx)(`code`,{className:`text-fg bg-bg px-1 rounded text-[10px]`,children:`claude -p`}),` `,`subprocess running `,a,`.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`2.`}),` The prompt is the chronological list of that thread's session labels (alias, auto-title, or first-message snippet). About 500 input tokens. No transcripts here, because the job is just "produce a 6-word title". The decision about which sessions belong together was already made in Step 1.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`3.`}),` Claude returns a 4–8 word workflow name (about 30 output tokens). The daemon writes the thread row, then moves to the next thread.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`4.`}),` Calls run`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`sequentially`}),`, one at a time. No parallel agents, no background terminals, no fan-out.`]})]}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-[10px]`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Subprocesses spawned:`}),(0,G.jsxs)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:[e,` (sequential, ~`,o,`s each)`]}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Estimated wall time:`}),(0,G.jsxs)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:[`~`,c,` min`]}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Concurrent Claude calls:`}),(0,G.jsx)(`div`,{className:`text-fg font-mono tabular-nums text-right`,children:`1 at any moment`})]})]}):(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`You opted out of LLM naming. Each thread takes its name from the root session's alias or auto-title. Zero subprocesses, zero token cost, zero plan-window use.`})]}),(0,G.jsxs)(`div`,{className:`border border-role-tool/30 rounded p-3 bg-role-tool/5`,children:[(0,G.jsx)(`div`,{className:`text-fg font-medium mb-1.5`,children:`What does NOT happen`}),(0,G.jsxs)(`ul`,{className:`space-y-1`,children:[(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` spawn one agent per session. The naming runs at the thread level, not the session level.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` send transcript content, code, tool outputs, or file contents to Claude. Only short titles.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` open a terminal, run claude in interactive mode, or leave anything running in the background after the scan finishes.`]})]}),(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`text-role-tool shrink-0`,children:`✗`}),(0,G.jsxs)(`span`,{children:[`We do`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`not`}),` fan out to parallel sub-agents. Switching to Sonnet or Opus does not buy you more concurrency, only different per-call quality and cost.`]})]})]})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted/80 text-[10px]`,children:[`Source files if you want to read it: graph algorithm in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/utils/threadScan.ts`}),`, naming subprocess in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/commands/thread-scan.ts`}),`, job runtime in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`src/daemon/thread-scan-jobs.ts`}),`.`]})]})})}function Br({value:e,onChange:t,disabled:n}){let r=Pr.find(t=>t.value===e);return(0,G.jsxs)(`label`,{className:`block ${n?`opacity-50`:``}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:`Naming model`}),r&&(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px]`,children:r.note})]}),(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),disabled:n,className:`w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg focus:border-accent focus:outline-none disabled:cursor-not-allowed`,children:Pr.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(`div`,{className:`text-fg-muted/70 mt-1 leading-relaxed`,children:`Picks the model used to generate each thread name. Cost and the 5-hour window bars below update as you change this.`})]})}function Vr({preflight:e,llmNames:t}){return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-1.5 bg-bg-hover/30`,children:[(0,G.jsx)(Kr,{label:`Eligible sessions in project`,value:e.eligible_sessions.toString(),hint:`Excludes [meta], [output-index], and [skill] infra sessions.`}),(0,G.jsx)(Kr,{label:`Proposed parent-child edges`,value:e.proposed_edges.toString(),hint:`Pairs scoring at or above your threshold.`}),(0,G.jsx)(Kr,{label:`Resulting threads`,value:e.estimated_threads.toString(),hint:`Connected components in the edge graph (one thread per chain).`}),(0,G.jsx)(Kr,{label:`LLM naming calls`,value:t?`${e.estimated_llm_calls} (${Pr.find(t=>t.value===e.model)?.label??e.model})`:`0 (skipped)`,hint:t?`One short call per thread to generate a 4-8 word workflow name.`:`Thread names will fall back to the root session label.`})]})}function Hr({estimate:e,llmCalls:t}){let n={pro:`Pro`,"max-5x":`Max 5x`,"max-20x":`Max 20x`};return(0,G.jsxs)(`div`,{className:`border border-accent/30 rounded p-3 space-y-2 bg-accent/5`,children:[(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:`Claude Code 5-hour window impact`}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,t,` Haiku call`,t===1?``:`s`,`, multiplier`,` `,e.model_multiplier,`x)`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`If you're on Pro/Max (not your own API key), each thread-naming call burns a slice of your 5-hour message window. Bars show how much of one window this scan consumes per plan tier.`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.per_plan.map(e=>{let t=e.would_exhaust_window,r=!t&&e.fraction>.5,i=Math.min(100,e.pct);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted w-16 shrink-0`,children:n[e.plan]}),(0,G.jsx)(`div`,{className:`flex-1 h-2 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:t?`h-full bg-role-user`:r?`h-full bg-role-tool`:`h-full bg-accent`,style:{width:`${i}%`}})}),(0,G.jsxs)(`span`,{className:`tabular-nums w-16 text-right `+(t?`text-role-user font-semibold`:`text-fg`),children:[e.pct>=1e3?`>1000`:e.pct.toFixed(1),`%`]})]},e.plan)})}),(0,G.jsxs)(`div`,{className:`text-fg-muted/80 text-[10px] leading-relaxed`,children:[`ⓘ `,e.caveat]})]})}function Ur({project:e,snapshot:t,recentNames:n,estimatedThreads:r,cancelled:i}){let a=t?.total_threads??r,o=t?.threads_named??0;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:i?`Cancellation requested for ${e}. Already-written threads kept.`:`Linking edges for ${e}…`}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`span`,{className:`text-fg`,children:[`Naming thread `,o,` of `,a]}),t?.current_thread_name&&(0,G.jsx)(`span`,{className:`text-fg-muted truncate ml-3`,children:t.current_thread_name})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:a>0?`${Math.min(100,o/a*100)}%`:`0%`}})})]}),n.length>0&&(0,G.jsx)(`ul`,{className:`space-y-1 text-fg-muted`,children:n.map((e,t)=>(0,G.jsxs)(`li`,{className:`font-mono text-[11px]`,children:[(0,G.jsxs)(`span`,{className:`text-fg-muted/60`,children:[`[`,e.current,`/`,e.total,`]`]}),` `,e.thread_name]},t))})]})}function Wr({project:e,snapshot:t,onOpenThreadsPage:n,onCopyRollback:r}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`p-3 rounded border border-accent/40 bg-accent/10 text-fg`,children:[`Created `,t.threads_created,` thread`,t.threads_created===1?``:`s`,` with `,t.edges_written,` `,`edges in `,e,`.`]}),n&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`text-accent hover:underline`,children:`Open Threads page →`}),(0,G.jsxs)(`details`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:`Rollback this scan`}),(0,G.jsx)(`pre`,{className:`mt-2 text-[10px] font-mono text-fg-muted whitespace-pre-wrap`,children:Nr}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`mt-2 text-[11px] px-2 py-1 rounded border border-line hover:bg-bg-hover`,children:`Copy command`})]})]})}function Gr({label:e,children:t}){return(0,G.jsxs)(`details`,{className:`group border border-line rounded bg-bg-hover/20 overflow-hidden`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer select-none flex items-center justify-between px-3 py-2 text-fg-muted hover:text-fg hover:bg-bg-hover/40 transition-colors`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`transition-transform group-open:rotate-90 text-fg-muted/60`,children:`▸`})]}),(0,G.jsx)(`div`,{className:`px-3 py-3 border-t border-line/60 text-fg-muted`,children:t})]})}function Kr({label:e,value:t,hint:n}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:e}),(0,G.jsx)(`span`,{className:`font-mono text-fg tabular-nums`,children:t})]}),n&&(0,G.jsx)(`div`,{className:`text-fg-muted/70 text-[10px] mt-0.5`,children:n})]})}var qr=`(temporary sessions)`,Jr=`recall.projectGroupBy`,Yr=new Set([`folder`,`repo`,`repo-flat`]);function Xr(){let[e,t]=(0,W.useState)(()=>{if(typeof window>`u`)return`repo`;let e=window.localStorage.getItem(Jr);return e&&Yr.has(e)?e:`repo`});return[e,(0,W.useCallback)(e=>{t(e);try{window.localStorage.setItem(Jr,e)}catch{}},[])]}function Zr({selected:e,selectedCollection:t,onSelect:n,onCreateCollection:r,onSelectSession:i}){let[a,o]=Xr(),s=q({queryKey:[`projects`,a],queryFn:()=>Z.projects(a),refetchInterval:15e3,refetchIntervalInBackground:!1,staleTime:6e3}),c=Tn(),[,l]=Nn(),[u,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(null),m=zn({storageKey:`claude-recall:projects-pane`,defaultWidth:256,minWidth:200,maxWidth:600,collapsedWidth:40}),h=(0,W.useCallback)(e=>{e.preventDefault(),m.beginResize(e.clientX,m.width)},[m]),g=e=>{l({col:e,project:null,session:null,msg:null})},_=()=>l({view:`help`,helpSection:`taxonomy`}),v=s.data?s.data.mode===`folder`?s.data.projects.length:s.data.groups.length:null;return m.collapsed?(0,G.jsxs)(`aside`,{className:`pane shrink-0 relative flex flex-col items-center`,style:{width:`${m.effectiveWidth}px`},children:[(0,G.jsx)(`button`,{type:`button`,onClick:m.toggleCollapsed,className:`w-full py-2 text-xs text-fg-muted hover:text-fg hover:bg-bg-hover border-b border-line`,title:`expand projects pane`,children:`»`}),(0,G.jsxs)(`div`,{className:`flex-1 w-full flex items-center justify-center px-1 text-[10px] text-fg-muted tracking-wider`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:[`Projects`,v===null?``:` (${v})`]})]}):(0,G.jsxs)(`aside`,{className:`pane shrink-0 relative`,style:{width:`${m.effectiveWidth}px`},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize projects pane`,onMouseDown:h,onDoubleClick:()=>m.setWidth(256),className:`absolute top-0 right-0 bottom-0 w-1.5 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 z-10`,title:`Drag to resize · double-click to reset`}),(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:m.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal shrink-0`,title:`collapse projects pane`,children:`«`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Projects`}),(0,G.jsx)(`button`,{type:`button`,onClick:_,className:`text-[10px] font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent shrink-0`,title:`Project vs Collection vs Tag vs Pin vs Alias vs Note — what's the difference?`,children:`(?)`})]}),v!==null&&(0,G.jsx)(`span`,{children:v})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,G.jsx)(kr,{onSelectSession:i}),(0,G.jsx)(_r,{selectedCollection:t,onSelect:g,onCreateCollection:r}),(0,G.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group projects by`,className:`flex items-center gap-1 px-3 py-2 border-b border-line text-xs`,children:[`folder`,`repo`,`repo-flat`].map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a===e,onClick:()=>o(e),className:$(`px-2 py-0.5 rounded transition-colors`,a===e?`bg-bg-hover text-fg font-medium`:`text-fg-muted hover:text-fg`),"data-testid":`group-mode-${e}`,children:[e===`folder`&&`Folders`,e===`repo`&&`Repositories`,e===`repo-flat`&&`Repositories (flat)`]},e))}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`all-sessions`,onClick:()=>n(null),className:$(`list-item text-sm flex items-center justify-between gap-2`,e===null&&!t&&`list-item-active`),children:[(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`All sessions`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:s.data?s.data.mode===`folder`?s.data.projects.reduce((e,t)=>e+t.session_count,0):s.data.groups.reduce((e,t)=>e+t.session_count_total,0):`—`})]}),s.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Loading…`}),s.isError&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-role-user`,children:[`Failed to load: `,s.error.message]}),s.data?.mode===`folder`&&(0,G.jsx)(Qr,{projects:s.data.projects,selected:e,onSelect:n,onScanThreads:p}),(s.data?.mode===`repo`||s.data?.mode===`repo-flat`)&&(0,G.jsx)($r,{groups:s.data.groups,selected:e,onSelect:n,onScanThreads:p}),c.data&&c.data.length>0&&(0,G.jsxs)(`div`,{className:`border-t border-line mt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`w-full pane-header hover:bg-bg-hover`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:$(`transition-transform`,u&&`rotate-90`),children:`▸`}),`Tags`]}),(0,G.jsx)(`span`,{children:c.data.length})]}),u&&(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 py-2`,children:c.data.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l({q:`#${e.tag}`,session:null,msg:null}),className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-role-tool/10 text-role-tool text-xs border border-role-tool/30 hover:bg-role-tool/20 transition-colors`,title:`filter to ${e.count} session${e.count===1?``:`s`} tagged #${e.tag}`,children:[(0,G.jsxs)(`span`,{children:[`#`,e.tag]}),(0,G.jsx)(`span`,{className:`text-fg-muted/60 text-[10px]`,children:e.count})]},e.tag))})]})]}),f&&(0,G.jsx)(Fr,{project:f,onClose:()=>p(null),onOpenThreadsPage:e=>{p(null),l({view:`threads`,project:e,session:null,msg:null})}})]})}function Qr({projects:e,selected:t,onSelect:n,onScanThreads:r}){return(0,G.jsx)(G.Fragment,{children:e.map(e=>(0,G.jsxs)(`div`,{className:$(`list-item group relative`,t===e.name&&`list-item-active`),title:e.decoded_path,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`project-row`,onClick:()=>n(e.name),className:`block w-full text-left`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.name}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-fg-muted shrink-0`,children:[(0,G.jsx)(Mr,{projectId:e.id}),bt(e.session_count)]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate font-mono`,children:vt(e.decoded_path,44)}),e.latest&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:yt(e.latest)})]}),(0,G.jsxs)(`div`,{className:`absolute right-2 bottom-2 group/scan`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`thread-scan-button`,onClick:t=>{t.stopPropagation(),r(e.name)},className:`text-[10px] px-1.5 py-0.5 rounded border border-line bg-bg-hover/60 text-fg-muted hover:text-accent hover:border-accent/40 transition-colors`,children:`🧵 Scan threads`}),(0,G.jsxs)(`div`,{role:`tooltip`,className:`pointer-events-none absolute right-0 bottom-full mb-1.5 w-64 z-20 opacity-0 group-hover/scan:opacity-100 transition-opacity rounded-md border border-accent/40 bg-bg shadow-lg px-3 py-2 text-[11px] leading-snug text-fg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-accent mb-1`,children:`Detect workflow threads`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Opens a preflight modal for `,(0,G.jsx)(`span`,{className:`text-fg`,children:e.name}),`: shows eligible session count, proposed parent-child edges, estimated threads, and max LLM cost in USD before you commit. Nothing is written until you click Apply.`]}),(0,G.jsx)(`div`,{className:`absolute right-3 top-full -mt-px h-2 w-2 rotate-45 border-r border-b border-accent/40 bg-bg`})]})]})]},e.id))})}function $r({groups:e,selected:t,onSelect:n,onScanThreads:r}){let[i,a]=(0,W.useState)(new Set),o=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,G.jsx)(G.Fragment,{children:e.map(e=>{let a=i.has(e.repo_root),s=e.folders.length>1,c=e.folders[0],l=c!=null&&t===c.name,u=e.repo_root===qr;return(0,G.jsxs)(`div`,{className:$(`list-item group relative`,l&&`list-item-active`),title:e.repo_root||`No repository path`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-1`,children:[s&&(0,G.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e.repo_root)},className:`text-fg-muted hover:text-fg text-xs mt-1 px-0.5`,"aria-label":a?`Collapse subfolders`:`Expand subfolders`,"data-testid":`expand-${e.repo_root}`,children:a?`▾`:`▸`}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`project-row`,onClick:()=>{u||c&&n(c.name)},className:$(`block flex-1 text-left`,u&&`cursor-default`),title:u?`${e.folders.length} ephemeral sessions from tmpdirs (batch jobs, scratch dirs). Click an individual folder below to view its session.`:e.repo_root,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-medium truncate flex items-center gap-1`,children:[e.name,e.is_worktree&&(0,G.jsx)(`span`,{className:`text-[10px] px-1 rounded bg-accent/15 text-accent`,children:`worktree`}),!e.is_repo&&(0,G.jsx)(`span`,{className:`text-[10px] px-1 rounded bg-bg-hover text-fg-muted`,children:`folder`})]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-fg-muted shrink-0`,children:[c&&(0,G.jsx)(Mr,{projectId:c.id}),bt(e.session_count_total)]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted truncate font-mono`,children:vt(e.repo_root||e.name,44)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted mt-1`,children:[s&&(0,G.jsxs)(`span`,{children:[e.folders.length,` subfolders`]}),e.latest&&(0,G.jsx)(`span`,{children:yt(e.latest)})]})]})]}),c&&(0,G.jsx)(`div`,{className:`absolute right-2 bottom-2 group/scan`,children:(0,G.jsx)(`button`,{type:`button`,"data-testid":`thread-scan-button`,onClick:e=>{e.stopPropagation(),r(c.name)},className:`text-[10px] px-1.5 py-0.5 rounded border border-line bg-bg-hover/60 text-fg-muted hover:text-accent hover:border-accent/40 transition-colors`,children:`🧵 Scan threads`})}),a&&s&&(0,G.jsx)(`ul`,{className:`mt-1 ml-4 border-l border-line`,children:e.folders.map(r=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`button`,{type:`button`,"data-testid":`project-subfolder-row`,onClick:()=>n(r.name),className:$(`block w-full text-left text-xs px-2 py-1`,t===r.name?`text-fg font-medium`:`text-fg-muted hover:text-fg`),title:r.decoded_path,children:(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.repo_root&&r.decoded_path.startsWith(e.repo_root)?`.`+r.decoded_path.slice(e.repo_root.length)||`.`:r.decoded_path})})},r.id))})]},e.repo_root||`(unknown-${e.name})`)})})}var ei=`claude-recall:pinned-sessions:v1`;function ti(){try{let e=localStorage.getItem(ei);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function ni(e){try{localStorage.setItem(ei,JSON.stringify(e))}catch{}}var ri=new Set;function ii(){for(let e of ri)e()}function ai(){let[e,t]=(0,W.useState)(()=>ti());return(0,W.useEffect)(()=>{let e=()=>t(ti());return ri.add(e),()=>{ri.delete(e)}},[]),(0,W.useEffect)(()=>{let e=e=>{e.key===ei&&t(ti())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{pinned:e,isPinned:(0,W.useCallback)(t=>e.includes(t),[e]),togglePin:(0,W.useCallback)(e=>{let t=ti();ni(t.includes(e)?t.filter(t=>t!==e):[...t,e]),ii()},[])}}function oi({status:e}){return!e||e===`neutral`?null:e===`verified`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-green-500`,title:`Verified: completion claim backed by 2+ evidence categories`,children:[(0,G.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,className:`shrink-0`,children:(0,G.jsx)(`path`,{d:`M6 10.8L3.2 8l-.9.9L6 12.6l8-8-.9-.9L6 10.8z`,fill:`currentColor`})}),`verified`]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-yellow-500`,title:`Unverified: completion claimed but insufficient evidence`,children:[(0,G.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,className:`shrink-0`,children:(0,G.jsx)(`path`,{d:`M8 1L1 14h14L8 1zm0 3.5l4.9 8.5H3.1L8 4.5zM7.25 7v3h1.5V7h-1.5zm0 4v1.5h1.5V11h-1.5z`,fill:`currentColor`})}),`unverified`]})}function si(e){return e.trim().toLowerCase().replace(/^#+/,``).replace(/[\s/\\]+/g,`-`).replace(/[^a-z0-9\-._]/g,``).slice(0,40)}function ci({sessionId:e,existingTags:t,onDone:n,variant:r=`bar`,placeholder:i=`tag-name`}){let[a,o]=(0,W.useState)(``),s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=Dn(),u=Tn();(0,W.useEffect)(()=>{requestAnimationFrame(()=>s.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&n()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[n]);let d=si(a),f=u.data?d?u.data.filter(e=>!t.includes(e.tag)&&e.tag.includes(d)).slice(0,8):u.data.filter(e=>!t.includes(e.tag)).slice(0,8):[],p=async t=>{let r=si(t);if(r)try{await l.mutateAsync({sessionId:e,tag:r}),n()}catch(e){console.error(`add tag failed`,e)}},m=r===`row`?`w-48 text-[10px] px-2`:`w-56 text-xs px-3`,h=r===`row`?`text-[10px]`:`text-xs`,g=i===`tag-name`?`type new tag + Enter`:i,_=d.length>0;return(0,G.jsxs)(`div`,{ref:c,className:`relative inline-flex`,children:[(0,G.jsx)(`input`,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),p(a)):e.key===`Escape`?(e.preventDefault(),n()):e.key===`Tab`&&f.length>0&&(e.preventDefault(),o(f[0].tag))},placeholder:g,maxLength:40,className:`bg-bg-elevated border border-accent rounded-full py-0.5 text-fg focus:outline-none placeholder:text-fg-muted ${m}`}),(0,G.jsxs)(`div`,{className:`absolute left-0 top-full mt-1 min-w-full w-56 bg-bg-elevated border border-line rounded-lg shadow-lg py-1 z-30 ${h}`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1 text-fg-muted text-[10px] uppercase tracking-wider border-b border-line/50 mb-1`,children:_?(0,G.jsxs)(G.Fragment,{children:[`Press `,(0,G.jsx)(`span`,{className:`font-mono text-accent`,children:`Enter`}),` to create`,` `,(0,G.jsxs)(`span`,{className:`text-role-tool`,children:[`#`,d]})]}):(0,G.jsx)(G.Fragment,{children:`Type to create, or pick existing:`})}),f.length>0?f.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void p(e.tag),className:`block w-full text-left px-3 py-1 hover:bg-bg-hover`,children:[(0,G.jsxs)(`span`,{className:`text-role-tool`,children:[`#`,e.tag]}),(0,G.jsx)(`span`,{className:`text-fg-muted ml-2`,children:e.count})]},e.tag)):(0,G.jsx)(`div`,{className:`px-3 py-1 text-fg-muted italic`,children:_?`no matches — hit Enter to create`:`no tags yet — type one above`})]})]})}function li(){let[e,t]=(0,W.useState)({id:null,snapshot:null,error:null}),n=(0,W.useRef)(null),r=async e=>{try{let{scanId:n}=await Z.startScan(e);return t({id:n,snapshot:{id:n,status:`running`,createdAt:new Date().toISOString(),finishedAt:null,total:0,completed:0,results:[],error:null},error:null}),i(n),n}catch(e){return t(t=>({...t,error:e instanceof Error?e.message:String(e)})),null}},i=e=>{n.current&&n.current.close();let r=new EventSource(mt(`/api/tags/scan/${encodeURIComponent(e)}/events`));n.current=r,r.addEventListener(`state`,e=>{let n=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,...n}}:e)}),r.addEventListener(`result`,e=>{let n=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,results:[...e.snapshot.results,n]}}:e)}),r.addEventListener(`progress`,e=>{let{completed:n,total:r}=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,completed:n,total:r}}:e)}),r.addEventListener(`status`,e=>{let{status:n}=JSON.parse(e.data);t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,status:n}}:e)}),r.addEventListener(`done`,()=>{t(e=>e.snapshot?{...e,snapshot:{...e.snapshot,status:`completed`,finishedAt:new Date().toISOString()}}:e),r.close()}),r.onerror=()=>{r.close()}},a=async t=>e.id?Z.applyScan(e.id,t):null,o=async()=>{e.id&&(await Z.cancelScan(e.id),n.current?.close())},s=()=>{n.current?.close(),t({id:null,snapshot:null,error:null})};return(0,W.useEffect)(()=>()=>n.current?.close(),[]),{...e,start:r,apply:a,cancel:o,reset:s}}function ui(e,t){(0,W.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}var di=[{id:`claude-opus-4-7`,label:`Opus 4.7 (recommended for quality)`},{id:`claude-sonnet-4-6`,label:`Sonnet 4.6 (balanced)`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5 (fast, cheap)`}];function fi({open:e,onClose:t}){let n=wt(),r=Tt(),i=K();ui(e,t);let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(`api`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(`claude-opus-4-7`),[p,m]=(0,W.useState)([2,4]),[h,g]=(0,W.useState)(!1),_=n.data&&!n.data.enabled&&!n.data.hasApiKey,v=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:e&&s===`mcp`});if((0,W.useEffect)(()=>{n.data&&(o(n.data.enabled),c(n.data.backend),f(n.data.model),m([n.data.minTagsPerSession,n.data.maxTagsPerSession]),g(n.data.autopilot))},[n.data]),!e)return null;let y=async()=>{await r.mutateAsync({enabled:a,backend:s,model:d,minTagsPerSession:p[0],maxTagsPerSession:p[1],autopilot:h,...l?{apiKey:l}:{}}),t()},b=async()=>{try{await Z.installMcp(),await i.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`Claude Recall MCP installed. Restart Claude Code to load it.`,tone:`success`,duration:8e3})}catch(e){Q({message:`Install failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}},x=async()=>{try{await Z.uninstallMcp(),await i.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`MCP entry removed from Claude Code config.`,tone:`info`})}catch(e){Q({message:`Uninstall failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}},S=a&&s===`api`&&(l.length>0||!!n.data?.hasApiKey);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[560px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-center justify-between sticky top-0 bg-bg`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Auto-tagging settings`}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg text-lg leading-none`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-4 text-xs`,children:[_&&(0,G.jsxs)(`div`,{className:`rounded border border-accent/40 bg-accent/10 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-accent mb-1`,children:`First time here?`}),`Auto-tag picks 2–4 tags per session using an LLM. Two ways to run it: pay Anthropic per scan (API key) or use your existing Claude Code agent (MCP, free). Both are opt-in. Turn on `,(0,G.jsx)(`strong`,{children:`Autopilot`}),` `,`to let the daemon tag every session automatically in the background — then forget this dialog exists.`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,G.jsx)(`span`,{className:`text-fg`,children:`Enable auto-tagging`})]}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:`When enabled, scanning sends session content (first message + sampled messages) to your chosen backend. Nothing is sent automatically — every scan is user-triggered. (Unless you turn on Autopilot below.)`}),(0,G.jsxs)(`fieldset`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`legend`,{className:`px-1 text-fg-muted`,children:`Backend`}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`backend`,checked:s===`api`,onChange:()=>c(`api`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Anthropic API key`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Recall calls Anthropic directly. You pay per scan. Works with Autopilot.`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`backend`,checked:s===`mcp`,onChange:()=>c(`mcp`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Claude Code (via MCP)`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Use your existing Claude Code agent. Zero extra cost. Manual trigger only (no Autopilot).`})]})]})]}),s===`api`&&(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Anthropic API key`}),(0,G.jsx)(`input`,{type:`password`,value:l,onChange:e=>u(e.target.value),placeholder:n.data?.hasApiKey?`sk-ant-… (key on file, leave blank to keep)`:`sk-ant-…`,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]}),s===`mcp`&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:"Install Claude Recall into your Claude Code MCP config (`~/.claude.json`) with one click — no copy-paste required."}),v.isLoading?(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Checking install status…`}):v.data?.installed?(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`text-accent text-[11px]`,children:[`✓ Installed in `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:v.data.configPath.replace(/^.*\//,`~/…/`)}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Restart Claude Code if it's running.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),className:`text-[11px] text-fg-muted hover:text-role-user px-2 py-1`,children:`Uninstall`})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Install in Claude Code`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-1`,children:[`Model`,(0,G.jsx)(`span`,{className:`text-[10px] ml-2 font-normal`,children:`— used for both API-key scans and the MCP one-click run`})]}),(0,G.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`,children:di.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Min tags / session`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:10,value:p[0],onChange:e=>m([Math.max(1,Number(e.target.value)),Math.max(Number(e.target.value),p[1])]),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Max tags / session`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:10,value:p[1],onChange:e=>m([Math.min(p[0],Number(e.target.value)),Number(e.target.value)]),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-fg`})]})]}),(0,G.jsxs)(`fieldset`,{className:`border rounded p-3 ${S?`border-accent/50`:`border-line opacity-60`}`,children:[(0,G.jsx)(`legend`,{className:`px-1 text-fg-muted`,children:`Autopilot`}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,disabled:!S,onChange:e=>g(e.target.checked)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Tag sessions automatically in the background`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:[`When on, the daemon scans every untagged session (existing + new) and applies tags without a review step. You can still × any tag on any session. Costs ~$0.01–0.05 per session at Opus pricing. `,S?``:`Requires backend = Anthropic API key + a saved key.`]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2 sticky bottom-0 bg-bg`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:r.isPending,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-50`,children:r.isPending?`Saving…`:`Save`})]})]})})}function pi({open:e,snapshot:t,onApply:n,onCancel:r,onClose:i,onRetryFailed:a}){let[o,s]=(0,W.useState)({}),[c,l]=(0,W.useState)(!1);ui(e,i),(0,W.useEffect)(()=>{t&&s(e=>{let n={...e};for(let e of t.results)n[e.sessionId]||(n[e.sessionId]={enabled:!!e.suggestion,rejected:new Set});return n})},[t?.results.length,t]);let u=(0,W.useMemo)(()=>t?t.results.map(e=>{let t=o[e.sessionId];if(!t||!t.enabled||!e.suggestion)return null;let n=e.suggestion.tags.filter(e=>!t.rejected.has(e));return n.length===0?null:{sessionId:e.sessionId,tags:n}}).filter(e=>e!==null):[],[t,o]);if(!e||!t)return null;let d=e=>{s(t=>{let n=t[e]??{enabled:!1,rejected:new Set};return{...t,[e]:{...n,enabled:!n.enabled}}})},f=(e,t)=>{s(n=>{let r=n[e]??{enabled:!0,rejected:new Set},i=new Set(r.rejected);return i.has(t)?i.delete(t):i.add(t),{...n,[e]:{...r,rejected:i}}})},p=async()=>{l(!0);try{await n(u)&&i()}finally{l(!1)}},m=t.status===`running`||t.status===`pending`,h=t.results.filter(e=>e.error).length;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[900px] max-w-[calc(100vw-2rem)] max-h-[85vh] flex flex-col shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[`Auto-tag review — `,t.completed,`/`,t.total,m&&(0,G.jsx)(`span`,{className:`ml-2 text-fg-muted text-xs`,children:`(scanning…)`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-lg leading-none`,children:`×`})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`sticky top-0 bg-bg border-b border-line`,children:(0,G.jsxs)(`tr`,{className:`text-left text-fg-muted`,children:[(0,G.jsx)(`th`,{className:`px-3 py-2 w-8`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Session`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Current`}),(0,G.jsx)(`th`,{className:`px-3 py-2`,children:`Suggested`}),(0,G.jsx)(`th`,{className:`px-3 py-2 w-20 text-right`,children:`Confidence`})]})}),(0,G.jsxs)(`tbody`,{children:[t.results.map(e=>(0,G.jsx)(mi,{r:e,enabled:o[e.sessionId]?.enabled??!1,rejected:o[e.sessionId]?.rejected??new Set,onToggleRow:()=>d(e.sessionId),onToggleTag:t=>f(e.sessionId,t)},e.sessionId)),m&&t.results.length<t.total&&(0,G.jsx)(`tr`,{children:(0,G.jsxs)(`td`,{colSpan:5,className:`px-3 py-3 text-center text-fg-muted italic`,children:[`scanning `,t.total-t.results.length,` more…`]})})]})]})}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs`,children:[u.length,` session`,u.length===1?``:`s`,` selected`,` `,`(`,(0,G.jsxs)(`span`,{children:[u.reduce((e,t)=>e+t.tags.length,0),` tags`]}),`)`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m&&(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-role-user hover:text-role-user/80 text-xs px-3 py-1`,children:`Cancel scan`}),!m&&h>0&&a&&(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`text-xs border border-role-user/40 text-role-user hover:bg-role-user/10 rounded px-3 py-1`,title:`re-run the ${h} session${h===1?``:`s`} that failed`,children:[`Retry `,h,` failed`]}),(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:u.length===0||c,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-40`,children:c?`Applying…`:`Apply ${u.length}`})]})]})]})})}function mi({r:e,enabled:t,rejected:n,onToggleRow:r,onToggleTag:i}){let a=!!e.error;return(0,G.jsxs)(`tr`,{className:$(`border-b border-line/50`,a&&`opacity-60`),children:[(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:t,onChange:r,disabled:a||!e.suggestion})}),(0,G.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`text-fg font-medium truncate max-w-[280px]`,title:e.first_user_message,children:e.alias||e.first_user_message.slice(0,60)||`(no prompt)`}),(0,G.jsxs)(`div`,{className:`font-mono text-[10px] text-fg-muted`,children:[e.sessionId.slice(0,8),` · `,e.project]})]}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:e.current_tags.length===0?(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`—`}):(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.current_tags.map(e=>(0,G.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-role-tool/15 text-role-tool text-[10px]`,children:[`#`,e]},e))})}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:a?(0,G.jsxs)(`span`,{className:`text-role-user text-[11px]`,children:[`⚠ `,e.error]}):e.suggestion?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.suggestion.tags.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:$(`px-1.5 py-0.5 rounded-full text-[10px] border transition-colors`,n.has(e)?`line-through text-fg-muted border-line bg-transparent`:`bg-accent/10 text-accent border-accent/40 hover:bg-accent/20`),title:n.has(e)?`click to re-include`:`click to reject`,children:[`#`,e]},e))}):(0,G.jsx)(`span`,{className:`text-fg-muted italic`,children:`pending…`})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right font-mono text-[10px] text-fg-muted`,children:e.suggestion?e.suggestion.confidence.toFixed(2):`—`})]})}function hi({open:e,sessionId:t,projectName:n,onClose:r,onOpenSettings:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(0),[p,m]=(0,W.useState)(null),h=K();ui(e,r),(0,W.useEffect)(()=>{if(!s||l===null)return;let e=setInterval(()=>f(Date.now()-l),250);return()=>clearInterval(e)},[s,l]);let g=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:e}),_=!!g.data?.claudeCliAvailable,v=async()=>{c(!0),m(null);let e=Date.now();u(e),f(0);try{let r=t?{sessionIds:[t]}:n?{project:n,untaggedOnly:!0}:{untaggedOnly:!0},i=await Z.runClaudeCliScan(r);m({success:i.success,tagsAdded:i.tagsAdded,stderrTail:i.stderrTail,elapsedMs:Date.now()-e}),h.invalidateQueries({queryKey:[`sessions`]}),h.invalidateQueries({queryKey:[`tags`]}),t&&h.invalidateQueries({queryKey:[`session`,t]}),Q({message:i.success?`Auto-tag complete — ${i.tagsAdded} new tag${i.tagsAdded===1?``:`s`} written.`:`Auto-tag finished with errors (exit ${i.exitCode}). See dialog for details.`,tone:i.success?`success`:`error`,duration:8e3})}catch(e){Q({message:`Run failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{c(!1)}};if(!e)return null;let y=t?`Using my Recall MCP tools, auto-tag session ${t}. First call list_tags to see existing tags I already use (prefer those for consistency). Then call list_sessions_to_tag with limit 1 and match the session. Pick 2–4 tags based on the content. Finally call apply_tags to write them.`:`Using my Recall MCP tools, scan and tag my sessions. First call list_tags to see existing tags (prefer those for consistency). Then call list_sessions_to_tag with untaggedOnly: true. For each session, pick 2–4 tags based on the content. Finally call apply_tags for each session to write them.`,b=async()=>{try{await navigator.clipboard.writeText(y),o(!0),setTimeout(()=>o(!1),1800)}catch(e){console.error(`copy failed`,e)}},x=async()=>{try{await Z.installMcp(),await h.invalidateQueries({queryKey:[`mcp-install-status`]}),Q({message:`Claude Recall MCP installed. Restart Claude Code to load it.`,tone:`success`,duration:8e3})}catch(e){Q({message:`Install failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[600px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`MCP-mode auto-tagging`}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] mt-1`,children:`You're set to use your Claude Code agent (no Anthropic key needed). The web UI can't call your agent directly — you trigger it from Claude Code.`})]}),i&&(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-[11px] text-fg-muted hover:text-fg px-2 py-1 shrink-0`,title:`change auto-tagging settings`,children:`⚙ Settings`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-4 text-xs`,children:[(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px] font-semibold uppercase tracking-wider`,children:`Step 1 — install Recall in Claude Code`}),g.isLoading?(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:`Checking…`}):g.data?.installed?(0,G.jsxs)(`div`,{className:`text-accent text-[11px]`,children:[`✓ Installed in `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`~/.claude.json`}),`. If you haven't already, restart Claude Code to load it.`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[`One click — no copy-paste JSON. Writes `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`{ "mcpServers": { "recall": … } }`}),` into your Claude Code config at `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`~/.claude.json`}),`, preserving every other key you already have.`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Install in Claude Code`})]})]}),g.data?.installed&&_&&(0,G.jsxs)(`div`,{className:`border border-accent/50 bg-accent/5 rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-accent text-[11px] font-semibold uppercase tracking-wider`,children:`Step 2 — one click (recommended)`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] leading-relaxed`,children:[`Recall will spawn your local `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`claude`}),` CLI in the background and have it tag `,t?`this session`:n?(0,G.jsxs)(G.Fragment,{children:[`every untagged session in `,(0,G.jsx)(`span`,{className:`text-fg`,children:n})]}):`every untagged session`,` via the Recall MCP tools. Uses your Claude Code subscription — `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`no API key, no copy-paste`}),`.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void v(),disabled:s,className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90 disabled:opacity-50 disabled:cursor-wait inline-flex items-center gap-2`,children:[s&&(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-bg border-t-transparent rounded-full animate-spin`}),s?`Running…`:`🏷 Auto-run via Claude Code`]}),s&&(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-muted font-mono tabular-nums`,children:[gi(d),` elapsed · typical 30s–3min`]})]}),p&&(0,G.jsx)(`div`,{className:`text-[11px] mt-2 p-2 rounded border ${p.success?`border-accent/40 bg-accent/10 text-accent`:`border-role-user/40 bg-role-user/10 text-role-user`}`,children:p.success?(0,G.jsxs)(G.Fragment,{children:[`✓ Done in `,gi(p.elapsedMs),` — `,p.tagsAdded,` new tag`,p.tagsAdded===1?``:`s`,` written.`]}):(0,G.jsxs)(G.Fragment,{children:[`Exit with errors after `,gi(p.elapsedMs),`. Tail of stderr:`,(0,G.jsx)(`pre`,{className:`mt-1 font-mono text-[10px] whitespace-pre-wrap overflow-auto max-h-40`,children:p.stderrTail||`(empty)`})]})})]}),(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px] font-semibold uppercase tracking-wider`,children:g.data?.installed&&_?`Or — paste the prompt into an open Claude Code session`:`Step 2 — ask your agent (in Claude Code)`}),!_&&g.data?.installed&&(0,G.jsxs)(`div`,{className:`text-role-user text-[11px]`,children:[`⚠ `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`claude`}),` CLI not found on PATH, so one-click auto-run isn't available. Install Claude Code locally to enable it, or use the copy-paste path below.`]}),(0,G.jsx)(`pre`,{className:`bg-bg-elevated border border-line rounded p-2 text-[11px] whitespace-pre-wrap`,children:y}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`text-[11px] bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1`,children:a?`✓ copied`:`📋 copy prompt`})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[`Your agent will use the `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`list_tags`}),`,`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`list_sessions_to_tag`}),`, and`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`apply_tags`}),` MCP tools. Tags appear in Recall on the next poll (≤4 seconds).`]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] pt-2 border-t border-line`,children:[`Want hands-off tagging that doesn't need Claude Code running?`,` `,i?(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-accent hover:underline`,children:`Switch to API-key mode + enable Autopilot`}):(0,G.jsx)(`span`,{children:`Switch backend to API key in settings and enable Autopilot.`}),`.`]})]}),(0,G.jsx)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2`,children:(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})})}function gi(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function _i({projectName:e,collectionId:t}){let n=wt(),r=li(),i=K(),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(`untagged`);ui(s,()=>c(!1)),ui(!!r.error,()=>r.reset());let p=()=>{let e=n.data;if(!e||!e.enabled){o(!0);return}if(e.backend===`api`&&!e.hasApiKey){o(!0);return}if(e.backend===`mcp`){u(!0);return}c(!0)},m=async()=>{let n={};d===`untagged`&&(n.untaggedOnly=!0),d===`project`&&e&&(n.project=e),d===`collection`&&t&&(n.collectionId=t),c(!1),await r.start(n)},h=()=>{i.invalidateQueries({queryKey:[`sessions`]}),i.invalidateQueries({queryKey:[`tags`]}),i.invalidateQueries({queryKey:[`session`]})},g=async e=>{let t=await r.apply(e);if(t&&t.applied>0){h();let n=e.reduce((e,t)=>e+t.tags.length,0);Q({message:`Applied ${t.applied} tag${t.applied===1?``:`s`} across ${e.length} session${e.length===1?``:`s`}.`,tone:`success`,duration:1e4,action:{label:`Undo`,onClick:()=>{_(e,n)}}})}else t&&Q({message:`Nothing to apply — all selected tags were already on those sessions.`,tone:`info`});return t},_=async(e,t)=>{let n=0;for(let t of e)for(let e of t.tags)try{await Z.removeSessionTag(t.sessionId,e),n+=1}catch(n){console.error(`undo: remove failed`,t.sessionId,e,n)}h(),Q({message:`Undone — removed ${n} of ${t} tag${t===1?``:`s`}.`,tone:`info`})},v=async()=>{if(!r.snapshot)return;let e=r.snapshot.results.filter(e=>e.error).map(e=>e.sessionId);e.length!==0&&(r.reset(),await r.start({sessionIds:e}))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`inline-flex items-center rounded border border-accent/40 bg-accent/10 overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs text-accent hover:bg-accent hover:text-bg px-2 py-1 font-medium border-r border-accent/40`,title:n.data?.enabled?`auto-tag sessions with an LLM`:`configure auto-tagging`,children:`🏷 auto-tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`text-xs text-accent hover:bg-accent hover:text-bg px-1.5 py-1`,title:`auto-tag settings (enable autopilot, install MCP, change model, paste API key)`,"aria-label":`auto-tag settings`,children:`⚙`})]}),(0,G.jsx)(fi,{open:a,onClose:()=>o(!1)}),(0,G.jsx)(hi,{open:l,projectName:e,onClose:()=>{u(!1),Q({message:`MCP scan triggered. New tags will appear here as your Claude Code agent writes them.`,tone:`info`,duration:8e3})},onOpenSettings:()=>{u(!1),o(!0)}}),r.error&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-role-user/60 rounded-lg w-[440px] shadow-xl p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-role-user font-semibold mb-2`,children:`Scan failed`}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-3 break-words`,children:r.error}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>r.reset(),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})}),s&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[480px] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Auto-tag sessions`}),(0,G.jsx)(`p`,{className:`text-fg-muted text-[11px] mt-1`,children:`Pick how many sessions to send to the LLM. Each session is one model call.`})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 space-y-3 text-xs`,children:[[{id:`untagged`,label:`Untagged sessions only`,desc:`Every session with zero tags, across ALL projects. Usually what you want for the first run.`,available:!0},{id:`all`,label:`All sessions`,desc:`Every indexed session, across ALL projects. Includes sessions that already have tags (new tags will merge, never replace).`,available:!0},{id:`project`,label:`Current project${e?` — ${e}`:``}`,desc:e?`Only sessions in "${e}".`:`Not available — click a project in the left pane first.`,available:!!e},{id:`collection`,label:`Current collection`,desc:t?`Only sessions in the collection you are currently viewing.`:`Not available — open a collection in the left pane first.`,available:!!t}].map(e=>(0,G.jsxs)(`label`,{className:`flex items-start gap-2 ${e.available?`cursor-pointer`:`opacity-40`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`scope`,className:`mt-0.5`,checked:d===e.id,disabled:!e.available,onChange:()=>f(e.id)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e.label}),(0,G.jsx)(`div`,{className:`text-fg-muted text-[11px]`,children:e.desc})]})]},e.id)),(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-line text-[11px] text-fg-muted space-y-1`,children:[(0,G.jsxs)(`div`,{children:[`• Capped at `,(0,G.jsx)(`span`,{className:`text-fg`,children:`500 sessions per scan`}),` (safety rail).`]}),(0,G.jsxs)(`div`,{children:[`• Uses model `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:n.data?.model??`claude-opus-4-7`}),`.`,n.data?.backend===`api`&&(0,G.jsxs)(G.Fragment,{children:[` API-key mode: roughly `,(0,G.jsx)(`span`,{className:`text-fg`,children:`$0.01–0.05`}),` per session at Opus pricing.`]}),n.data?.backend===`mcp`&&(0,G.jsx)(G.Fragment,{children:` MCP mode: uses your Claude Code subscription, no extra cost.`})]}),(0,G.jsx)(`div`,{children:`• Nothing is written until you Apply in the review step.`}),(0,G.jsxs)(`div`,{children:[`• Press `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Esc`}),` to cancel any dialog.`]})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`bg-accent text-bg rounded px-3 py-1 text-xs font-medium hover:opacity-90`,children:`Start scan`})]})]})}),(0,G.jsx)(pi,{open:!!r.id&&!r.error,snapshot:r.snapshot,onApply:g,onCancel:()=>void r.cancel(),onClose:()=>r.reset(),onRetryFailed:()=>void v()})]})}function vi({open:e,title:t,message:n,confirmLabel:r=`Confirm`,cancelLabel:i=`Cancel`,tone:a=`accent`,icon:o,onConfirm:s,onCancel:c}){return ui(e,c),e?(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center`,onClick:c,role:`presentation`,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[440px] max-w-[90vw] p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,children:[(0,G.jsxs)(`h3`,{id:`confirm-dialog-title`,className:`text-base font-semibold mb-3 flex items-center gap-2`,children:[o&&(0,G.jsx)(`span`,{"aria-hidden":`true`,children:o}),(0,G.jsx)(`span`,{children:t})]}),(0,G.jsx)(`div`,{className:`text-sm text-fg-muted mb-5 leading-relaxed`,children:n}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`px-4 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:i}),(0,G.jsx)(`button`,{type:`button`,onClick:s,className:a===`danger`?`px-4 py-1.5 text-sm border border-red-400/60 rounded text-red-400 hover:bg-red-400/10`:`px-4 py-1.5 text-sm border border-accent rounded text-accent hover:bg-accent/10`,children:r})]})]})}):null}var yi=`200`,bi=30,xi=60,Si=120,Ci=15,wi=30,Ti=90,Ei=92,Di={quick:{chunks:5,messages:`~20`,label:`Quick`,sub:`First few exchanges. Captures intent + opening response. Fastest.`},standard:{chunks:80,messages:`~300`,label:`Standard`,sub:`Most working sessions fit here. Good balance of accuracy and time.`},full:{chunks:0,messages:`~600-1000`,label:`Full (safety-capped)`,sub:`First 200 chunks per session. Hard cap protects the daemon from giant sessions. Override with RECALL_VECTOR_HARD_CAP=N if needed.`}};function Oi(e){if(!isFinite(e)||e<=0)return`instant`;if(e<60)return`${Math.max(1,Math.round(e))}s`;let t=Math.floor(e/60),n=Math.round(e%60);return t<60?n>0?`${t}m ${n}s`:`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}function ki(e){return new Intl.NumberFormat().format(e)}function Ai({projectName:e,onClose:t}){let n=K(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(`standard`),[s,c]=(0,W.useState)(40),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null);ui(!0,t);let _=q({queryKey:[`vectorize-preview`,e],queryFn:()=>Z.getReindexPreview(e)}),v=q({queryKey:[`vector-status`,e],queryFn:()=>Z.getVectorStatus(e),refetchInterval:e=>{let t=e.state.data,n=t?.queueDepthForProject??t?.worker.queueDepth??0,r=t?.worker.queueDepth??0;return n>0||r>0?2e3:3e4},staleTime:1500}),y=_.data,b=v.data,x=_.isLoading,S=_.error,[C]=(0,W.useState)(()=>Date.now()),w=b?.queueDepthForProject??b?.worker.queueDepth??0,T=b?.worker.queueDepth??0,E=Math.max(0,T-w),D=w>0,O=b?.worker.lastProcessedAt??null,k=y?!y.modelInstalled:!1,A=(0,W.useMemo)(()=>a===`custom`?Math.max(1,Math.floor(s)):Di[a].chunks,[a,s]),j=(0,W.useMemo)(()=>{if(!y||y.chunksPerSec<=0)return 0;let e=r?y.pendingForce:y.pendingNew;if(e===0)return 0;let t=r?y.estimatedChunksByDepth.force:y.estimatedChunksByDepth.new,n;if(a===`quick`||a===`standard`||a===`full`)n=t[a];else{let t=Math.max(1,Math.floor(s));n=e*Math.min(t,y.avgChunksPerSession||t)}return n<=0?0:Math.ceil(n/y.chunksPerSec)},[y,r,a,s]),[M,ee]=(0,W.useState)(null),[N,te]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),[I,L]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(D&&N===null&&w>0&&(te(w),F(Date.now()),L(null)),!D&&N!==null){let e=!!O&&!!P&&new Date(O).getTime()>P;if(M===null&&N>0&&e){let e=P?Math.max(1,Math.round((Date.now()-P)/1e3)):0;L({drained:N,elapsedSec:e,observedChunksPerSec:e>0?N/e:0,completedAt:Date.now()}),Q({message:`Vectorization complete — ${ki(N)} chunk${N===1?``:`s`} embedded in ${Oi(e)}.`,tone:`success`,duration:8e3})}te(null),F(null)}},[D,w,N,M]);let R=N===null?0:Math.max(0,N-w),z=N&&N>0?Math.min(100,R/N*100):0,B=b?.throughput?.chunksPerSec??0,V=(b?.throughput?.samples??0)>=5,ne=b?.etaSecondsDetail??null,H=ne?.source??`no-samples`,re=b?.queueGrowthChunksPerSec??0,ie=ne?.currentQueue??b?.etaSeconds??0,ae=ne?.withGrowth??null,oe=V&&re>0&&ae===null&&B>0,se=b?.etaForProject??ie,ce=v.dataUpdatedAt,U=(0,W.useMemo)(()=>{if(!P||R<=0)return 0;let e=(Date.now()-P)/1e3;return e<1?0:R/e},[P,R,ce]),le=!!O&&Date.now()-new Date(O).getTime()<5e3,ue=D&&R===0&&P!==null&&b?.throughput?.source!==`local-measured`&&!le,de=U>0?U:B>0?B:y?.chunksPerSec??0,fe=ue?0:se>0?se:de>0?Math.ceil(w/de):0,pe=P?Math.max(0,Math.round((Date.now()-P)/1e3)):0,me=ue?`warming up · loading embedder model (~5-10s on first start)`:U>0?`observed · ${ki(R)} drained in ${pe}s on this run`:b?.throughput?.source===`local-measured`?`measured · ${b.throughput.samples} sample${b.throughput.samples===1?``:`s`}`:y?.throughputSource===`live-benchmark`?`benchmark estimate · refines once chunks start draining`:`warming up · waiting for first session to complete`,[he,ge]=(0,W.useState)(0),[_e,ve]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!D||fe<=0){ge(0),ve(null);return}ve({ts:Date.now(),eta:fe}),ge(fe)},[D,fe,ce]),(0,W.useEffect)(()=>{if(!D||!_e)return;let e=setInterval(()=>{let e=Math.floor((Date.now()-_e.ts)/1e3);ge(Math.max(0,_e.eta-e))},1e3);return()=>clearInterval(e)},[D,_e]);let ye=r?y?.pendingForce??0:y?.pendingNew??0,be=l||x||!!S||k||ye===0,xe=async()=>{if(!p){m(!0),g(null);try{let e=await Z.installVectorModel();if(!e.ok){g(e.error??`install failed`);return}Q({message:`Vectorizer installed. Ready to vectorize.`,tone:`success`,duration:5e3}),await _.refetch(),n.invalidateQueries({queryKey:[`vector-status`]})}catch(e){g(e instanceof Error?e.message:`unknown error`)}finally{m(!1)}}},[Se,Ce]=(0,W.useState)(null),[we,Te]=(0,W.useState)(null),Ee=Se!==null,De=async()=>{if(!l){Ce(null),Te(null),u(!0);try{let t=await Z.reindexProjectVectors(e,r,A);if(t.enqueued===0){Te(t.message??`Already vectorized — every eligible session in ${e} has embeddings. Toggle "Re-embed already-vectorized sessions" below if you want to regenerate.`),Ce(Date.now()),Q({message:`${e} is already vectorized — nothing to do.`,tone:`info`,duration:5e3});return}let i=A===0?`cap ${yi} chunks/session (safety)`:`cap ${A} chunk${A===1?``:`s`}/session`;Q({message:`Vectorizing ${ki(t.enqueued)} session${t.enqueued===1?``:`s`} (${i}). Free, on-device.`,tone:`success`,duration:7e3}),n.setQueryData([`vector-status`,e],n=>({embedder:n?.embedder??{loaded:!0,modelId:`BAAI/bge-base-en-v1.5`,dim:768},worker:{running:!0,queueDepth:t.queueDepth,lastProcessedAt:n?.worker?.lastProcessedAt??null},modelInstalled:n?.modelInstalled??!0,project:e,queueDepthForProject:t.enqueued,etaForProject:n?.etaForProject??0,remainingChunks:n?.remainingChunks,throughput:n?.throughput??{chunksPerSec:0,samples:0,source:`no-samples-yet`},etaSeconds:n?.etaSeconds??0,etaSecondsDetail:n?.etaSecondsDetail,queueGrowthChunksPerSec:n?.queueGrowthChunksPerSec})),n.invalidateQueries({queryKey:[`vector-status`,e],refetchType:`active`})}catch(e){let t=e instanceof Error?e.message:`unknown error`;Q({message:t.startsWith(`403`)?"Vectorize requires a Pro license. Run `recall license activate <KEY>` or upgrade at clauderecall.com.":`Vectorize failed: ${t}`,tone:`error`,duration:1e4})}finally{u(!1)}}},[Oe,ke]=(0,W.useState)(!1),Ae=()=>{d||ke(!0)},je=async()=>{if(ke(!1),d)return;f(!0),ee(Date.now());let e=new AbortController,t=!1,r=setTimeout(()=>{t=!0,e.abort(),f(!1),n.invalidateQueries({queryKey:[`vector-status`]})},8e3);try{let i=await Z.cancelReindex(void 0,e.signal);if(t)return;clearTimeout(r),Q({message:i.cleared>0?`Stop signalled. Cleared ${ki(i.cleared)} queued chunk${i.cleared===1?``:`s`} across all projects. Worker will finish its current batch (~5-15s) and then halt.`:`Nothing to cancel — queue was already empty.`,tone:`info`,duration:6e3}),n.invalidateQueries({queryKey:[`vector-status`]})}catch(e){if(t)return;clearTimeout(r),Q({message:`Stop failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`,duration:6e3}),ee(null)}finally{t||(clearTimeout(r),f(!1))}},Me=M!==null&&b?.worker.running&&Date.now()-M<Ti*1e3,[Ne,Pe]=(0,W.useState)(null),Fe=Ne!==null&&Date.now()-Ne<4e3,Ie=I!==null&&Date.now()-I.completedAt<1e4;(0,W.useEffect)(()=>{if(M!==null){if(!b?.worker.running){Pe(Date.now());let e=setTimeout(()=>ee(null),1500);return()=>clearTimeout(e)}Date.now()-M>Ti*1e3&&ee(null)}},[M,b?.worker.running]);let[,Le]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(!ue&&!Me&&!x&&!Fe&&!Ie)return;let e=setInterval(()=>Le(e=>e+1),500);return()=>clearInterval(e)},[ue,Me,x,Fe,Ie]);let Re=x?Math.max(0,Math.floor((Date.now()-C)/1e3)):0,ze=Math.min(Ei,Re/bi*Ei),Be=Re>=xi,Ve=Re>=Si,He=ue&&P?Math.max(0,Math.floor((Date.now()-P)/1e3)):0,Ue=Math.min(Ei,He/bi*Ei),We=He>=xi,Ge=He>=Si,Ke=Me&&M?Math.max(0,Math.floor((Date.now()-M)/1e3)):0,qe=Math.min(Ei,Ke/Ci*Ei),Je=Ke>=wi;return(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:[(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[560px] max-w-[92vw] max-h-[88vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`vectorize-dialog-title`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{id:`vectorize-dialog-title`,className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧠`}),(0,G.jsxs)(`span`,{children:[D?`Vectorizing`:`Vectorize`,` `,(0,G.jsx)(`span`,{className:`text-accent`,children:e})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),x&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-4 bg-yellow-400/5 border-yellow-400/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-yellow-400 animate-pulse`}),(0,G.jsx)(`span`,{className:`text-sm font-medium text-yellow-400`,children:`Warming up — preparing the embedder`})]}),(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-yellow-400/90 uppercase tracking-wide`,children:[Ve?`Still working`:`Loading`,` · `,Re,`s elapsed`]}),(0,G.jsx)(`span`,{className:`font-mono text-yellow-400/70`,children:Ve?`stuck?`:`${ze.toFixed(0)}%`})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-yellow-400/30`,children:(0,G.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out ${Ve?`bg-red-400/70`:`bg-yellow-400/70`}`,style:{width:`${ze}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-3 leading-snug`,children:Ve?`Preview has been loading for ${Re}s. Something may be wrong — check the daemon log at ~/.recall/daemon.log or run \`recall doctor\`.`:Be?`Still preparing after ${Re}s — slower than usual. Older machines or first-ever start can take up to 60-90s. Embedder is a 140MB local model; nothing leaves your computer.`:`Loading the 140MB embedder model and running a quick benchmark. First start usually takes ~30 seconds, sometimes up to a minute on slower machines. Subsequent runs are much faster (model stays cached in memory).`})]}),S&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400 py-4`,children:[`Failed to load preview: `,S.message]}),Fe&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none`,children:`✓`}),(0,G.jsx)(`span`,{className:`text-sm font-medium text-green-400`,children:`Stopped — worker halted and queue cleared`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1.5 pl-7`,children:`Nothing is running in the background. Click Start vectorization later to resume.`})]}),Ie&&I&&(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none`,children:`✓`}),(0,G.jsxs)(`span`,{className:`text-sm font-medium text-green-400`,children:[`Vectorization complete — `,ki(I.drained),` chunk`,I.drained===1?``:`s`,` embedded in `,Oi(I.elapsedSec)]})]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-1.5 pl-7`,children:[I.observedChunksPerSec>0&&(0,G.jsxs)(G.Fragment,{children:[`Observed `,I.observedChunksPerSec.toFixed(1),` chunks/sec on this CPU · `]}),`local-only · no telemetry. Run another scope below, or close this dialog.`]})]}),Ee&&(0,G.jsx)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none mt-0.5`,children:`✓`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-green-400`,children:`Already vectorized`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1 leading-snug`,children:we??`Every eligible session in ${e} has embeddings.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{Ce(null),Te(null)},className:`text-fg-muted hover:text-fg text-sm leading-none`,"aria-label":`dismiss already-vectorized notice`,title:`Dismiss`,children:`✕`})]})}),k&&!D&&(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg p-4 mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-2xl`,children:`📦`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium text-base mb-1`,children:`Vectorizer not installed yet`}),(0,G.jsxs)(`div`,{className:`text-sm text-fg-muted`,children:[`One-time setup. Downloads `,(0,G.jsx)(`code`,{className:`text-fg`,children:`BAAI/bge-base-en-v1.5`}),` `,`(~110\xA0MB) and runs the embedder entirely on this machine.`]})]})]}),(0,G.jsxs)(`ul`,{className:`text-sm space-y-0.5 mb-4 ml-9`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No account required`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No telemetry — model runs locally only`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` Resumable — re-running picks up where it stopped`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` SHA-256 verified per file`]})]}),h&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400 mb-3 bg-red-400/10 border border-red-400/30 rounded p-2`,children:[`Install failed: `,h]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:xe,disabled:p,className:`px-4 py-2 text-sm border border-accent rounded text-accent hover:bg-accent/10 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2`,children:p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,G.jsx)(`span`,{children:`Downloading model…`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`⬇`}),(0,G.jsx)(`span`,{children:`Install vectorizer (~110 MB)`})]})}),(0,G.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-fg`,children:`Prefer the terminal?`}),(0,G.jsx)(`code`,{className:`block mt-2 bg-black/30 px-2 py-1 rounded text-xs`,children:`recall semantic install`})]})]}),p&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-3`,children:`Downloading from HuggingFace. Typically 30s-2min depending on your connection. Safe to leave the dialog open.`})]}),D&&y&&!k&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`mb-4 border rounded-lg p-4 ${Me?`bg-red-400/5 border-red-400/40`:`bg-accent/5 border-accent/40`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full ${Me?`bg-red-400 animate-pulse`:ue?`bg-yellow-400 animate-pulse`:b?.worker.running?`bg-accent animate-pulse`:`bg-accent`}`}),(0,G.jsx)(`span`,{className:`text-sm font-medium ${Me?`text-red-400`:ue?`text-yellow-400`:`text-accent`}`,children:Me?ue?`Stopping — will abort as soon as the embedder finishes loading`:`Stopping — finishing current batch (≤10 chunks)`:ue?`Warming up — loading embedder model`:b?.worker.running?`Vectorizing now`:`Queue ready, worker idle`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:[`Queued for `,e]}),(0,G.jsxs)(`div`,{className:`font-mono text-base`,children:[ki(w),` chunks`]}),E>0&&(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-0.5 leading-snug`,children:[`+`,ki(E),` queued from other projects`,(0,G.jsx)(`br`,{}),`(drain ahead of yours, FIFO)`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`Throughput`}),(0,G.jsx)(`div`,{className:`font-mono text-base`,children:ue?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`warming up…`}):de>0?`${de.toFixed(1)}/s`:`—`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`ETA remaining`}),(0,G.jsx)(`div`,{className:`font-mono text-base tabular-nums`,children:ue?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`computing…`}):!V&&B===0?(0,G.jsx)(`span`,{className:`text-yellow-400/80 text-sm`,children:`warming up — ETA pending`}):oe?(0,G.jsx)(`span`,{className:`text-red-400/90 text-sm`,children:`queue growing faster than draining`}):he>0?`~${Oi(he)}`:`—`}),V&&H===`live`&&ae!==null&&(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-0.5 leading-snug`,children:[`queue growing · with growth: ~`,Oi(ae)]}),oe&&(0,G.jsx)(`div`,{className:`text-[10px] text-red-400/80 mt-0.5 leading-snug`,children:`may not complete at current rate`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted`,children:`Last completed`}),(0,G.jsx)(`div`,{className:`font-mono text-xs`,children:O?new Date(O).toLocaleTimeString():`none yet`})]})]}),ue&&!Me&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-yellow-400/90 uppercase tracking-wide`,children:[`Warming up · `,He,`s elapsed`]}),(0,G.jsx)(`span`,{className:`font-mono text-yellow-400/70`,children:Ge?`stuck?`:`${Ue.toFixed(0)}%`})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-yellow-400/30`,children:(0,G.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out ${Ge?`bg-red-400/70`:`bg-yellow-400/70`}`,style:{width:`${Ue}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-2 leading-snug`,children:Ge?`Still warming up after ${He}s. Something may be wrong — check the daemon log at ~/.recall/daemon.log or run \`recall doctor\`.`:We?`Still loading after ${He}s — slower than usual. Older machines or first-ever start can take up to 60-90s. Embedder is a 140MB local model; nothing leaves your computer.`:b?.embedder?.loaded?`Embedder is loaded — worker preparing the first batch. Should be moments away.`:`Loading the 140MB embedder model into memory. First start usually takes ~30 seconds, sometimes up to a minute on slower machines. Subsequent runs are much faster (model stays cached).`})]}),Me&&!ue&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsxs)(`span`,{className:`text-red-400/90 uppercase tracking-wide`,children:[`Winding down · `,Ke,`s elapsed`]}),(0,G.jsxs)(`span`,{className:`font-mono text-red-400/70`,children:[qe.toFixed(0),`%`]})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-red-400/30`,children:(0,G.jsx)(`div`,{className:`h-full bg-red-400/70 transition-all duration-500 ease-out`,style:{width:`${qe}%`}})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-2 leading-snug`,children:Je?`Wind-down at ${Ke}s — slower than usual. The worker may be mid-cold-start; it will stop as soon as the current batch finishes embedding.`:`Worker finishes its current 10-chunk batch before stopping. Typically 5-15 seconds, sometimes longer during a cold start.`})]}),N!==null&&N>0&&!ue&&!Me&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`text-xs flex justify-between mb-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted uppercase tracking-wide`,children:`Progress this session`}),(0,G.jsxs)(`span`,{className:`font-mono text-fg`,children:[ki(R),` / `,ki(N),` (`,z.toFixed(1),`%)`]})]}),(0,G.jsx)(`div`,{className:`h-2 bg-bg rounded overflow-hidden border border-accent/20`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all duration-700 ease-out`,style:{width:`${z}%`}})})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-3 pt-3 border-t border-accent/20`,children:[me,` · polled every 2s · ETA ticks every 1s · local-only`]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mb-4`,children:`Worker drains the queue in the background. Closing this dialog doesn't stop it — only the Stop button does. Re-open the dialog any time to check progress.`})]}),!D&&y&&!k&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Scope`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-semibold text-accent`,children:ki(ye)}),` `,`of `,ki(y.eligible),` eligible session`,y.eligible===1?``:`s`,` `,`will be vectorized`]}),!r&&y.indexed>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[ki(y.indexed),` already vectorized — skipped (toggle below to re-embed)`]}),r&&y.indexed>0&&(0,G.jsxs)(`div`,{className:`text-accent text-xs mt-1`,children:[`Force re-embed ON: existing vectors for `,ki(y.indexed),` session`,y.indexed===1?``:`s`,` will be deleted and regenerated.`]}),y.total!==y.eligible&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[ki(y.total-y.eligible),` session`,y.total-y.eligible===1?``:`s`,` excluded (fewer than 3 messages)`]})]})]}),(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Cost`}),(0,G.jsxs)(`ul`,{className:`text-sm space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` Free — zero plan tokens`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` On-device CPU only — no Anthropic calls`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`✓`}),` No network — model runs locally (`,y.modelName,`)`]})]})]}),(0,G.jsxs)(`section`,{className:`mb-4`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Depth per session`}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[[`quick`,`standard`,`full`].map(e=>{let t=Di[e];return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded border cursor-pointer transition-colors ${a===e?`border-accent bg-accent/5`:`border-line hover:border-fg-muted`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`depth`,value:e,checked:a===e,onChange:()=>o(e),className:`mt-1 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`div`,{className:`flex-1 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:t.label}),(0,G.jsxs)(`span`,{className:`text-fg-muted text-xs font-mono`,children:[t.messages,` msgs / session · `,t.chunks===0?`no cap`:`cap ${t.chunks} chunks`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:t.sub})]})]},e)}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 p-2 rounded border cursor-pointer transition-colors ${a===`custom`?`border-accent bg-accent/5`:`border-line hover:border-fg-muted`}`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`depth`,value:`custom`,checked:a===`custom`,onChange:()=>o(`custom`),className:`mt-1 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`div`,{className:`flex-1 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`Custom`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:1e3,value:s,onChange:e=>{o(`custom`),c(Math.max(1,Math.min(1e3,Number(e.target.value)||1)))},onClick:e=>e.stopPropagation(),className:`bg-bg border border-line rounded px-1.5 py-0.5 text-xs w-16 font-mono`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:`chunks per session`})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:`Each chunk ≈ 3-5 messages. Set the cap that fits your sessions.`})]})]})]})]}),ye===0?(0,G.jsx)(`section`,{className:`mb-4 border rounded-lg p-3 bg-green-500/5 border-green-500/40`,role:`status`,"aria-live":`polite`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-green-400 text-lg leading-none mt-0.5`,children:`✓`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-green-400`,children:y.eligible===0?`No eligible sessions in ${e}`:`No need to vectorize — ${e} is already done`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1 leading-snug`,children:y.eligible===0?`Every session in this project has fewer than 3 messages, which is below the vectorize threshold. Nothing to embed.`:`All ${ki(y.indexed)} eligible session${y.indexed===1?``:`s`} in this project already have embeddings. Toggle "Re-embed already-vectorized sessions" below if you want to regenerate them.`})]})]})}):(0,G.jsxs)(`section`,{className:`mb-4 bg-bg border border-line rounded p-3`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-muted mb-1`,children:`Estimated time`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{className:`font-semibold`,children:[`~`,Oi(j)]}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs mt-1`,children:[y.throughputSource===`local-measured`&&(0,G.jsxs)(G.Fragment,{children:[`Based on your last `,y.throughputSamples,` vectorized session`,y.throughputSamples===1?``:`s`,` on this machine`,` `,`(`,y.chunksPerSec.toFixed(1),` chunks/sec). Local measurement, no telemetry.`]}),y.throughputSource===`live-benchmark`&&(0,G.jsxs)(G.Fragment,{children:[`Just measured: `,y.chunksPerSec.toFixed(1),` chunks/sec on this CPU`,` `,`(quick benchmark on dialog open). Estimate refines as the worker runs. Local measurement, no telemetry.`]}),y.throughputSource===`fallback-baseline`&&(0,G.jsx)(G.Fragment,{children:`Generic baseline — embedder isn't loaded yet so no live measurement. Will refine after the first sessions complete. Local-only, never sent off-device.`})]})]})]}),y.queueDepthOther>0&&(0,G.jsxs)(`section`,{className:`mb-4 text-xs text-fg-muted bg-bg border border-line rounded p-2`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg mb-0.5`,children:`Heads up`}),ki(y.queueDepthOther),` chunk`,y.queueDepthOther===1?``:`s`,` already queued from other projects. Your sessions will be vectorized after those drain.`]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 mb-4 p-2 rounded border border-line hover:border-fg-muted text-sm cursor-pointer transition-colors`,title:`Re-embed deletes existing vectors for already-vectorized sessions and regenerates them from scratch using the depth setting above. Useful when changing depth on existing data, or if you suspect bad embeddings. Skip otherwise — vectors are stable.`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-0.5 accent-[var(--color-accent,_currentColor)]`}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{children:`Re-embed already-vectorized sessions`}),r&&y.indexed>0&&(0,G.jsxs)(`span`,{className:`text-xs text-accent font-mono`,children:[`+`,ki(y.indexed),` session`,y.indexed===1?``:`s`]})]}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5`,children:`Deletes existing vectors and regenerates them from scratch. Use only if you're changing depth on existing data or suspect bad embeddings.`})]})]})]}),(0,G.jsx)(`div`,{className:`flex justify-end gap-2 pt-2 border-t border-line`,children:D?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:`Run in background`}),(0,G.jsx)(`button`,{type:`button`,onClick:Ae,disabled:d||Me,className:`px-3 py-1.5 text-sm border border-red-400/60 rounded text-red-400 hover:bg-red-400/10 disabled:opacity-40 disabled:cursor-not-allowed inline-flex items-center gap-1.5`,children:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-red-400 border-t-transparent rounded-full animate-spin`}),`Stopping…`]}):Me?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-red-400 border-t-transparent rounded-full animate-spin`}),`Winding down…`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`■`}),` Stop`]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-1.5 text-sm border border-line rounded hover:bg-bg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:De,disabled:be,className:`px-3 py-1.5 text-sm border border-accent rounded text-accent hover:bg-accent/10 disabled:opacity-40 disabled:cursor-not-allowed disabled:border-line disabled:text-fg-muted`,children:l?`Starting…`:`Start vectorization`})]})})]}),(0,G.jsx)(vi,{open:Oe,icon:`⏹`,title:`Stop ALL vectorization?`,tone:`danger`,confirmLabel:`Stop everything`,cancelLabel:`Keep going`,message:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`mb-2`,children:[`Clears the entire vectorize queue across every project`,` `,`and halts the worker. The in-flight batch`,` `,`(≤\xA010\xA0chunks) finishes first, then the worker stops.`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Already-vectorized sessions stay. Cleared sessions go back to`,` `,`"needs vectorization" — click Start later (per project) to`,` `,`resume just the ones you want.`]})]}),onConfirm:je,onCancel:()=>ke(!1)})]})}function ji(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Mi({projectName:e}){let[t,n]=(0,W.useState)(!1),r=At(),i=q({queryKey:[`vector-status`,e],queryFn:()=>Z.getVectorStatus(e??void 0),enabled:r&&!!e,refetchInterval:e=>{let t=e.state.data;return(t?.queueDepthForProject??t?.worker.queueDepth??0)>0?3e3:3e4},staleTime:2e3});if(!e||!r)return null;let a=i.data,o=a?.queueDepthForProject??a?.worker.queueDepth??0,s=a?.modelInstalled??!0,c=o>0,l=!s&&a!==void 0,u=c?`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-accent/60 rounded text-accent bg-accent/10 hover:bg-accent/20 transition-colors`:l?`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-accent/60 rounded text-accent hover:bg-accent/10 transition-colors`:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-line rounded text-fg-muted hover:text-accent hover:border-accent transition-colors`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),title:c?`Tier-2 vectorizer is running (${o.toLocaleString()} chunk${o===1?``:`s`} queued). Click for live progress + stop button. Free, on-device, zero tokens.`:l?`Vector model not installed yet. Click to install in one tap (~110 MB, on-device, no account, no telemetry).`:`Embed every session in this project for similarity search. Tier-2 — free, on-device CPU, zero plan tokens. Opens a confirmation with scope and ETA before anything runs.`,className:u,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧠`}),c?(0,G.jsxs)(`span`,{children:[`Vectorizing\xA0`,(0,G.jsx)(`span`,{className:`font-mono`,children:ji(o)}),`\xA0queued`]}):l?(0,G.jsx)(`span`,{children:`Set up vectorizer`}):(0,G.jsx)(`span`,{children:`Vectorize`})]}),t&&(0,G.jsx)(Ai,{projectName:e,onClose:()=>n(!1)})]})}var Ni=new Set([`low_signal`,`recursive_meta`,`programmatic`]);function Pi({sessionId:e,x:t,y:n,pinned:r,recallPromptsAvailable:i,titleQuality:a,onClose:o,onTogglePin:s,onAddToCollection:c,onCompareWith:l,onOpen:u,onLinkToSession:d,onRegenerateTitle:f,onRunPrompt:p}){let m=!!f&&!!a&&Ni.has(a),h=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&o()},t=e=>{e.key===`Escape`&&o()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[o]);let g=Math.min(t,window.innerWidth-240-8),_=Math.min(n,window.innerHeight-300-8),v=()=>{navigator.clipboard.writeText(e),Q({message:`Session ID copied: ${e.slice(0,8)}…`,tone:`info`}),o()},y=async t=>{o();try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/context?mode=${t}`);if(!n.ok)throw Error(`${n.status} ${n.statusText}`);let r=await n.text();await navigator.clipboard.writeText(r),Q({message:`Copied ${r.length.toLocaleString()} chars (${t}). Paste into a new Claude session.`,tone:`success`,duration:6e3})}catch(e){Q({message:`Copy failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsxs)(`div`,{ref:h,role:`menu`,"aria-label":`session actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:g,top:_,width:240},children:[(0,G.jsx)(Fi,{label:`Open session`,hint:`jump to transcript`,onClick:()=>{o(),u()}}),(0,G.jsx)(Fi,{label:r?`★ Unpin`:`☆ Pin to top`,onClick:()=>{o(),s()}}),(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`Copy session ID`,hint:`${e.slice(0,8)}…`,onClick:v}),(0,G.jsx)(Fi,{label:`📋 Copy as context`,hint:`condensed markdown, paste into new Claude`,onClick:()=>void y(`condensed`)}),(0,G.jsx)(Fi,{label:`📋 Copy full markdown`,hint:`uncondensed transcript with tool I/O`,onClick:()=>void y(`full`)}),(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`📂 Add to collection…`,onClick:()=>{o(),c()}}),(0,G.jsx)(Fi,{label:`⇄ Compare with another session`,onClick:()=>{o(),l()}}),(0,G.jsx)(Fi,{label:`🔗 Link to session…`,hint:`manual wiki-link, surfaces under both sessions' Linked panel`,onClick:()=>{o(),d()}}),m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ii,{}),(0,G.jsx)(Fi,{label:`✨ Regenerate title from context`,hint:`uses parent / child / cited sessions to mint a new title`,onClick:()=>{o(),f?.()}})]}),p&&i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ii,{}),(0,G.jsx)(`div`,{className:`px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wider text-fg-muted`,children:`Ask Claude Code (via MCP)`}),(0,G.jsx)(Fi,{label:`📝 Summarize this session`,hint:`3–5 bullets of what shipped / was tried / is open`,onClick:()=>{o(),p(`summarize_session`,`Summarize this session`,{sessionId:e})}}),(0,G.jsx)(Fi,{label:`🎯 Extract decisions`,hint:`architectural / product decisions with why + alternatives`,onClick:()=>{o(),p(`extract_decisions`,`Extract decisions`,{sessionId:e})}}),(0,G.jsx)(Fi,{label:`🔍 Find similar sessions`,hint:`5 sessions that touched the same topic, with reasons`,onClick:()=>{o(),p(`find_similar_sessions`,`Find similar sessions`,{sessionId:e})}})]})]})}function Fi({label:e,hint:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:n,className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:t})]})}function Ii(){return(0,G.jsx)(`div`,{className:`border-t border-line my-1`})}function Li({sessionIds:e,x:t,y:n,onClose:r,onClearSelection:i}){let a=(0,W.useRef)(null),o=e.length;(0,W.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[r]);let s=Math.min(t,window.innerWidth-260-8),c=Math.min(n,window.innerHeight-180-8),l=async(e,t)=>{try{await navigator.clipboard.writeText(e),Q({message:`Copied ${o} session ID${o===1?``:`s`} (${t})`,tone:`success`})}catch(e){Q({message:`Copy failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsxs)(`div`,{ref:a,role:`menu`,"aria-label":`multi-select session actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:s,top:c,width:260},children:[(0,G.jsxs)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted`,children:[o,` session`,o===1?``:`s`,` selected`]}),(0,G.jsx)(zi,{}),(0,G.jsx)(Ri,{label:`Copy session IDs`,hint:`one per line`,onClick:()=>{r(),l(e.join(`
|
|
13
13
|
`),`one per line`)}}),(0,G.jsx)(Ri,{label:`Copy IDs (space-separated)`,hint:`ready to paste into a prompt`,onClick:()=>{r(),l(e.join(` `),`space-separated`)}}),(0,G.jsx)(Ri,{label:`Copy IDs (comma-separated)`,hint:`for CSV / lists`,onClick:()=>{r(),l(e.join(`, `),`comma-separated`)}}),(0,G.jsx)(zi,{}),(0,G.jsx)(Ri,{label:`Clear selection`,hint:`esc`,onClick:()=>{r(),i()}})]})}function Ri({label:e,hint:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:n,className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:t})]})}function zi(){return(0,G.jsx)(`div`,{className:`border-t border-line my-1`})}function Bi({sessionId:e,onClose:t,anchor:n=`center`,position:r=null}){let[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),c=(0,W.useRef)(null),l=Qn(!1),u=Un(e),d=Jn();(0,W.useEffect)(()=>{requestAnimationFrame(()=>c.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=(0,W.useMemo)(()=>{let e=Zn(l.tree,new Set(l.tree.flatMap(e=>Vi(e)))),t=i.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)):e},[l.tree,i]),p=(0,W.useMemo)(()=>new Set((u.data?.collections??[]).map(e=>e.id)),[u.data]),m=async n=>{try{await d.mutateAsync({collectionId:n,sessionId:e})}catch(e){console.error(`add to collection failed`,e)}t()},h=(0,G.jsxs)(`div`,{className:$(`bg-bg-elevated border border-line rounded-lg shadow-xl overflow-hidden`,n===`center`?`w-[400px] max-w-[90vw]`:`w-[320px]`),onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 border-b border-line`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`📂`}),(0,G.jsx)(`input`,{ref:c,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search collections…`,className:`flex-1 bg-transparent text-sm text-fg placeholder:text-fg-muted focus:outline-none`}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg text-xs`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`max-h-72 overflow-y-auto`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`w-full px-3 py-2 text-left text-sm text-accent hover:bg-bg-hover flex items-center gap-2 border-b border-line`,children:[(0,G.jsx)(`span`,{children:`+`}),(0,G.jsx)(`span`,{children:`Create new collection…`})]}),l.isLoading&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-fg-muted`,children:`Loading…`}),l.data&&f.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-4 text-xs text-fg-muted`,children:`No collections match. Try "Create new collection".`}),f.map(e=>{let t=p.has(e.id);return(0,G.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>m(e.id),className:$(`w-full text-left px-3 py-2 text-sm flex items-center gap-2 transition-colors`,t?`text-fg-muted cursor-not-allowed opacity-70`:`text-fg hover:bg-bg-hover`),style:{paddingLeft:`${12+e.depth*16}px`},title:t?`already in this collection`:void 0,children:[(0,G.jsx)(`span`,{children:e.icon??`📂`}),(0,G.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),t&&(0,G.jsx)(`span`,{className:`text-xs text-accent`,children:`✓`}),!t&&(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.session_count})]},e.id)})]})]});return n===`center`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/40 flex items-center justify-center`,onClick:t,children:h}),o&&(0,G.jsx)(nr,{mode:`create`,pinnedSessionId:e,onClose:()=>s(!1),onCreated:()=>{s(!1),t()}})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:t,"aria-hidden":`true`}),(0,G.jsx)(`div`,{className:`fixed z-40`,style:{top:r?.top??100,left:r?.left??100},children:h}),o&&(0,G.jsx)(nr,{mode:`create`,pinnedSessionId:e,onClose:()=>s(!1),onCreated:()=>{s(!1),t()}})]})}function Vi(e){return[e.id,...e.children.flatMap(e=>Vi(e))]}function Hi(e){return q({queryKey:[`note`,e],queryFn:async()=>{if(!e)return null;let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/notes`,{headers:pt()});if(t.status===204)return null;if(!t.ok)throw Error(`${t.status}: ${await t.text()}`);return await t.json()},enabled:!!e,staleTime:2e3})}function Ui(){let e=K();return J({mutationFn:async({sessionId:e,content:t})=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/notes`,{method:`PUT`,headers:pt({"content-type":`application/json`}),body:JSON.stringify({content:t})});if(!n.ok)throw Error(`${n.status}: ${await n.text()}`);return await n.json()},onSuccess:t=>{e.setQueryData([`note`,t.session_id],t),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session`]})}})}function Wi(){let e=K();return J({mutationFn:async e=>{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/generate-note`,{method:`POST`,headers:pt()});if(!t.ok){let e=await t.text();throw Error(`${t.status}: ${e}`)}return await t.json()},onSuccess:t=>{e.setQueryData([`note`,t.session_id],t),e.invalidateQueries({queryKey:[`sessions`]})}})}function Gi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ki=Gi();function qi(e){Ki=e}var Ji={exec:()=>null};function Yi(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Xi(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Qi.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Zi=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Qi={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Yi(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Yi(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Yi(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Yi(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Yi(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Yi(e=>RegExp(`^ {0,${e}}>`))},$i=/^(?:[ \t]*(?:\n|$))+/,ea=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ta=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,na=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ra=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ia=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,aa=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oa=Xi(aa).replace(/bull/g,ia).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),sa=Xi(aa).replace(/bull/g,ia).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ca=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,la=/^[^\n]+/,ua=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,da=Xi(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ua).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fa=Xi(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ia).getRegex(),pa=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,ma=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ha=Xi(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,ma).replace(`tag`,pa).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ga=Xi(ca).replace(`hr`,na).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pa).getRegex(),_a={blockquote:Xi(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ga).getRegex(),code:ea,def:da,fences:ta,heading:ra,hr:na,html:ha,lheading:oa,list:fa,newline:$i,paragraph:ga,table:Ji,text:la},va=Xi(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,na).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pa).getRegex(),ya={..._a,lheading:sa,table:va,paragraph:Xi(ca).replace(`hr`,na).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,va).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pa).getRegex()},ba={..._a,html:Xi(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,ma).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ji,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Xi(ca).replace(`hr`,na).replace(`heading`,` *#{1,6} *[^
|
|
14
14
|
]`).replace(`lheading`,oa).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},xa=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Sa=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ca=/^( {2,}|\\)\n(?!\s*$)/,wa=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ta=/[\p{P}\p{S}]/u,Ea=/[\s\p{P}\p{S}]/u,Da=/[^\s\p{P}\p{S}]/u,Oa=Xi(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Ea).getRegex(),ka=/(?!~)[\p{P}\p{S}]/u,Aa=/(?!~)[\s\p{P}\p{S}]/u,ja=/(?:[^\s\p{P}\p{S}]|~)/u,Ma=Xi(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Zi?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Na=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Pa=Xi(Na,`u`).replace(/punct/g,Ta).getRegex(),Fa=Xi(Na,`u`).replace(/punct/g,ka).getRegex(),Ia=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,La=Xi(Ia,`gu`).replace(/notPunctSpace/g,Da).replace(/punctSpace/g,Ea).replace(/punct/g,Ta).getRegex(),Ra=Xi(Ia,`gu`).replace(/notPunctSpace/g,ja).replace(/punctSpace/g,Aa).replace(/punct/g,ka).getRegex(),za=Xi(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Da).replace(/punctSpace/g,Ea).replace(/punct/g,Ta).getRegex(),Ba=Xi(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Ta).getRegex(),Va=Xi(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Da).replace(/punctSpace/g,Ea).replace(/punct/g,Ta).getRegex(),Ha=Xi(/\\(punct)/,`gu`).replace(/punct/g,Ta).getRegex(),Ua=Xi(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Wa=Xi(ma).replace(`(?:-->|$)`,`-->`).getRegex(),Ga=Xi(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Wa).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ka=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,qa=Xi(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Ka).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ja=Xi(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ka).replace(`ref`,ua).getRegex(),Ya=Xi(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ua).getRegex(),Xa=Xi(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Ja).replace(`nolink`,Ya).getRegex(),Za=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qa={_backpedal:Ji,anyPunctuation:Ha,autolink:Ua,blockSkip:Ma,br:Ca,code:Sa,del:Ji,delLDelim:Ji,delRDelim:Ji,emStrongLDelim:Pa,emStrongRDelimAst:La,emStrongRDelimUnd:za,escape:xa,link:qa,nolink:Ya,punctuation:Oa,reflink:Ja,reflinkSearch:Xa,tag:Ga,text:wa,url:Ji},$a={...Qa,link:Xi(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Ka).getRegex(),reflink:Xi(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Ka).getRegex()},eo={...Qa,emStrongRDelimAst:Ra,emStrongLDelim:Fa,delLDelim:Ba,delRDelim:Va,url:Xi(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Za).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Xi(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Za).getRegex()},to={...eo,br:Xi(Ca).replace(`{2,}`,`*`).getRegex(),text:Xi(eo.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},no={normal:_a,gfm:ya,pedantic:ba},ro={normal:Qa,gfm:eo,breaks:to,pedantic:$a},io={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ao=e=>io[e];function oo(e,t){if(t){if(Qi.escapeTest.test(e))return e.replace(Qi.escapeReplace,ao)}else if(Qi.escapeTestNoEncode.test(e))return e.replace(Qi.escapeReplaceNoEncode,ao);return e}function so(e){try{e=encodeURI(e).replace(Qi.percentDecode,`%`)}catch{return null}return e}function co(e,t){let n=e.replace(Qi.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Qi.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Qi.slashPipe,`|`);return n}function lo(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function uo(e){let t=e.split(`
|
|
15
15
|
`),n=t.length-1;for(;n>=0&&Qi.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
@@ -76,11 +76,11 @@ ${e}</tr>
|
|
|
76
76
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+oo(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Co(e,t){return So.parse(e,t)}Co.options=Co.setOptions=function(e){return So.setOptions(e),Co.defaults=So.defaults,qi(Co.defaults),Co},Co.getDefaults=Gi,Co.defaults=Ki,Co.use=function(...e){return So.use(...e),Co.defaults=So.defaults,qi(Co.defaults),Co},Co.walkTokens=function(e,t){return So.walkTokens(e,t)},Co.parseInline=So.parseInline,Co.Parser=bo,Co.parser=bo.parse,Co.Renderer=vo,Co.TextRenderer=yo,Co.Lexer=_o,Co.lexer=_o.lex,Co.Tokenizer=go,Co.Hooks=xo,Co.parse=Co,Co.options,Co.setOptions,Co.use,Co.walkTokens,Co.parseInline,bo.parse,_o.lex;function wo(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function To(e){if(Array.isArray(e))return e}function Eo(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Do(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
77
77
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oo(e,t){return To(e)||Eo(e,t)||ko(e,t)||Do()}function ko(e,t){if(e){if(typeof e==`string`)return wo(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wo(e,t):void 0}}var Ao=Object.entries,jo=Object.setPrototypeOf,Mo=Object.isFrozen,No=Object.getPrototypeOf,Po=Object.getOwnPropertyDescriptor,Fo=Object.freeze,Io=Object.seal,Lo=Object.create,Ro=typeof Reflect<`u`&&Reflect,zo=Ro.apply,Bo=Ro.construct;Fo||=function(e){return e},Io||=function(e){return e},zo||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Bo||=function(e){return new e(...[...arguments].slice(1))};var Vo=ss(Array.prototype.forEach),Ho=ss(Array.prototype.lastIndexOf),Uo=ss(Array.prototype.pop),Wo=ss(Array.prototype.push),Go=ss(Array.prototype.splice),Ko=Array.isArray,qo=ss(String.prototype.toLowerCase),Jo=ss(String.prototype.toString),Yo=ss(String.prototype.match),Xo=ss(String.prototype.replace),Zo=ss(String.prototype.indexOf),Qo=ss(String.prototype.trim),$o=ss(Number.prototype.toString),es=ss(Boolean.prototype.toString),ts=typeof BigInt>`u`?null:ss(BigInt.prototype.toString),ns=typeof Symbol>`u`?null:ss(Symbol.prototype.toString),rs=ss(Object.prototype.hasOwnProperty),is=ss(Object.prototype.toString),as=ss(RegExp.prototype.test),os=cs(TypeError);function ss(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return zo(e,t,n)}}function cs(e){return function(){return Bo(e,[...arguments])}}function ls(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qo;if(jo&&jo(e,null),!Ko(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Mo(t)||(t[r]=e),i=e)}e[i]=!0}return e}function us(e){for(let t=0;t<e.length;t++)rs(e,t)||(e[t]=null);return e}function ds(e){let t=Lo(null);for(let r of Ao(e)){var n=Oo(r,2);let i=n[0],a=n[1];rs(e,i)&&(Ko(a)?t[i]=us(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=ds(a):t[i]=a)}return t}function fs(e){switch(typeof e){case`string`:return e;case`number`:return $o(e);case`boolean`:return es(e);case`bigint`:return ts?ts(e):`0`;case`symbol`:return ns?ns(e):`Symbol()`;case`undefined`:return is(e);case`function`:case`object`:{if(e===null)return is(e);let t=e,n=ps(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:is(e)}return is(e)}default:return is(e)}}function ps(e,t){for(;e!==null;){let n=Po(e,t);if(n){if(n.get)return ss(n.get);if(typeof n.value==`function`)return ss(n.value)}e=No(e)}function n(){return null}return n}function ms(e){try{return as(e,``),!0}catch{return!1}}var hs=Fo(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),gs=Fo(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),_s=Fo([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),vs=Fo([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ys=Fo(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),bs=Fo([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),xs=Fo([`#text`]),Ss=Fo(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Cs=Fo(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),ws=Fo(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Ts=Fo([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Es=Io(/{{[\w\W]*|^[\w\W]*}}/g),Ds=Io(/<%[\w\W]*|^[\w\W]*%>/g),Os=Io(/\${[\w\W]*/g),ks=Io(/^data-[\-\w.\u00B7-\uFFFF]+$/),As=Io(/^aria-[\-\w]+$/),js=Io(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ms=Io(/^(?:\w+script|data):/i),Ns=Io(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ps=Io(/^html$/i),Fs=Io(/^[a-z][.\w]*(-[.\w]+)+$/i),Is={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ls=function(){return typeof window>`u`?null:window},Rs=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},zs=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Bs(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ls(),t=e=>Bs(e);if(t.version=`3.4.7`,t.removed=[],!e||!e.document||e.document.nodeType!==Is.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=ps(d,`cloneNode`),p=ps(d,`remove`),m=ps(d,`nextSibling`),h=ps(d,`childNodes`),g=ps(d,`parentNode`),_=ps(d,`shadowRoot`),v=ps(d,`attributes`),y=o&&o.prototype?ps(o.prototype,`nodeType`):null,b=o&&o.prototype?ps(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C=n,w=C.implementation,T=C.createNodeIterator,E=C.createDocumentFragment,D=C.getElementsByTagName,O=r.importNode,k=zs();t.isSupported=typeof Ao==`function`&&typeof g==`function`&&w&&w.createHTMLDocument!==void 0;let A=Es,j=Ds,M=Os,ee=ks,N=As,te=Ms,P=Ns,F=Fs,I=js,L=null,R=ls({},[...hs,...gs,..._s,...ys,...xs]),z=null,B=ls({},[...Ss,...Cs,...ws,...Ts]),V=Object.seal(Lo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ne=null,H=null,re=Object.seal(Lo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ie=!0,ae=!0,oe=!1,se=!0,ce=!1,U=!0,le=!1,ue=!1,de=!1,fe=!1,pe=!1,me=!1,he=!0,ge=!1,_e=`user-content-`,ve=!0,ye=!1,be={},xe=null,Se=ls({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Ce=null,we=ls({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Te=null,Ee=ls({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),De=`http://www.w3.org/1998/Math/MathML`,Oe=`http://www.w3.org/2000/svg`,ke=`http://www.w3.org/1999/xhtml`,Ae=ke,je=!1,Me=null,Ne=ls({},[De,Oe,ke],Jo),Pe=ls({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Fe=ls({},[`annotation-xml`]),Ie=ls({},[`title`,`style`,`font`,`a`,`script`]),Le=null,Re=[`application/xhtml+xml`,`text/html`],ze=null,Be=null,Ve=n.createElement(`form`),He=function(e){return e instanceof RegExp||e instanceof Function},Ue=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Be&&Be===e)return;(!e||typeof e!=`object`)&&(e={}),e=ds(e),Le=Re.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ze=Le===`application/xhtml+xml`?Jo:qo,L=rs(e,`ALLOWED_TAGS`)&&Ko(e.ALLOWED_TAGS)?ls({},e.ALLOWED_TAGS,ze):R,z=rs(e,`ALLOWED_ATTR`)&&Ko(e.ALLOWED_ATTR)?ls({},e.ALLOWED_ATTR,ze):B,Me=rs(e,`ALLOWED_NAMESPACES`)&&Ko(e.ALLOWED_NAMESPACES)?ls({},e.ALLOWED_NAMESPACES,Jo):Ne,Te=rs(e,`ADD_URI_SAFE_ATTR`)&&Ko(e.ADD_URI_SAFE_ATTR)?ls(ds(Ee),e.ADD_URI_SAFE_ATTR,ze):Ee,Ce=rs(e,`ADD_DATA_URI_TAGS`)&&Ko(e.ADD_DATA_URI_TAGS)?ls(ds(we),e.ADD_DATA_URI_TAGS,ze):we,xe=rs(e,`FORBID_CONTENTS`)&&Ko(e.FORBID_CONTENTS)?ls({},e.FORBID_CONTENTS,ze):Se,ne=rs(e,`FORBID_TAGS`)&&Ko(e.FORBID_TAGS)?ls({},e.FORBID_TAGS,ze):ds({}),H=rs(e,`FORBID_ATTR`)&&Ko(e.FORBID_ATTR)?ls({},e.FORBID_ATTR,ze):ds({}),be=rs(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?ds(e.USE_PROFILES):e.USE_PROFILES:!1,ie=e.ALLOW_ARIA_ATTR!==!1,ae=e.ALLOW_DATA_ATTR!==!1,oe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,se=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ce=e.SAFE_FOR_TEMPLATES||!1,U=e.SAFE_FOR_XML!==!1,le=e.WHOLE_DOCUMENT||!1,fe=e.RETURN_DOM||!1,pe=e.RETURN_DOM_FRAGMENT||!1,me=e.RETURN_TRUSTED_TYPE||!1,de=e.FORCE_BODY||!1,he=e.SANITIZE_DOM!==!1,ge=e.SANITIZE_NAMED_PROPS||!1,ve=e.KEEP_CONTENT!==!1,ye=e.IN_PLACE||!1,I=ms(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:js,Ae=typeof e.NAMESPACE==`string`?e.NAMESPACE:ke,Pe=rs(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?ds(e.MATHML_TEXT_INTEGRATION_POINTS):ls({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Fe=rs(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?ds(e.HTML_INTEGRATION_POINTS):ls({},[`annotation-xml`]);let t=rs(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?ds(e.CUSTOM_ELEMENT_HANDLING):Lo(null);if(V=Lo(null),rs(t,`tagNameCheck`)&&He(t.tagNameCheck)&&(V.tagNameCheck=t.tagNameCheck),rs(t,`attributeNameCheck`)&&He(t.attributeNameCheck)&&(V.attributeNameCheck=t.attributeNameCheck),rs(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(V.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ce&&(ae=!1),pe&&(fe=!0),be&&(L=ls({},xs),z=Lo(null),be.html===!0&&(ls(L,hs),ls(z,Ss)),be.svg===!0&&(ls(L,gs),ls(z,Cs),ls(z,Ts)),be.svgFilters===!0&&(ls(L,_s),ls(z,Cs),ls(z,Ts)),be.mathMl===!0&&(ls(L,ys),ls(z,ws),ls(z,Ts))),re.tagCheck=null,re.attributeCheck=null,rs(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?re.tagCheck=e.ADD_TAGS:Ko(e.ADD_TAGS)&&(L===R&&(L=ds(L)),ls(L,e.ADD_TAGS,ze))),rs(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?re.attributeCheck=e.ADD_ATTR:Ko(e.ADD_ATTR)&&(z===B&&(z=ds(z)),ls(z,e.ADD_ATTR,ze))),rs(e,`ADD_URI_SAFE_ATTR`)&&Ko(e.ADD_URI_SAFE_ATTR)&&ls(Te,e.ADD_URI_SAFE_ATTR,ze),rs(e,`FORBID_CONTENTS`)&&Ko(e.FORBID_CONTENTS)&&(xe===Se&&(xe=ds(xe)),ls(xe,e.FORBID_CONTENTS,ze)),rs(e,`ADD_FORBID_CONTENTS`)&&Ko(e.ADD_FORBID_CONTENTS)&&(xe===Se&&(xe=ds(xe)),ls(xe,e.ADD_FORBID_CONTENTS,ze)),ve&&(L[`#text`]=!0),le&&ls(L,[`html`,`head`,`body`]),L.table&&(ls(L,[`tbody`]),delete ne.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw os(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw os(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);x=e.TRUSTED_TYPES_POLICY,S=x.createHTML(``)}else x===void 0&&(x=Rs(u,i)),x!==null&&typeof S==`string`&&(S=x.createHTML(``));(k.uponSanitizeElement.length>0||k.uponSanitizeAttribute.length>0)&&L===R&&(L=ds(L)),k.uponSanitizeAttribute.length>0&&z===B&&(z=ds(z)),Fo&&Fo(e),Be=e},We=ls({},[...gs,..._s,...vs]),Ge=ls({},[...ys,...bs]),Ke=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Ae,tagName:`template`});let n=qo(e.tagName),r=qo(t.tagName);return Me[e.namespaceURI]?e.namespaceURI===Oe?t.namespaceURI===ke?n===`svg`:t.namespaceURI===De?n===`svg`&&(r===`annotation-xml`||Pe[r]):!!We[n]:e.namespaceURI===De?t.namespaceURI===ke?n===`math`:t.namespaceURI===Oe?n===`math`&&Fe[r]:!!Ge[n]:e.namespaceURI===ke?t.namespaceURI===Oe&&!Fe[r]||t.namespaceURI===De&&!Pe[r]?!1:!Ge[n]&&(Ie[n]||!We[n]):!!(Le===`application/xhtml+xml`&&Me[e.namespaceURI]):!1},W=function(e){Wo(t.removed,{element:e});try{g(e).removeChild(e)}catch{p(e)}},G=function(e,n){try{Wo(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Wo(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(fe||pe)try{W(n)}catch{}else try{n.setAttribute(e,``)}catch{}},qe=function(e){let t=null,r=null;if(de)e=`<remove></remove>`+e;else{let t=Yo(e,/^[\r\n\t ]+/);r=t&&t[0]}Le===`application/xhtml+xml`&&Ae===ke&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?x.createHTML(e):e;if(Ae===ke)try{t=new l().parseFromString(i,Le)}catch{}if(!t||!t.documentElement){t=w.createDocument(Ae,`template`,null);try{t.documentElement.innerHTML=je?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ae===ke?D.call(t,le?`html`:`body`)[0]:le?t.documentElement:a},K=function(e){return T.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Je=function(e){e.normalize();let t=T.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;){let e=n.data;Vo([A,j,M],t=>{e=Xo(e,t,` `)}),n.data=e,n=t.nextNode()}},Ye=function(e){let t=b?b(e):null;return typeof t!=`string`||ze(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Xe=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===Is.documentFragment}catch{return!1}},Ze=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Qe(e,n,r){Vo(e,e=>{e.call(t,n,r,Be)})}let $e=function(e){let n=null;if(Qe(k.beforeSanitizeElements,e,null),Ye(e))return W(e),!0;let r=ze(e.nodeName);if(Qe(k.uponSanitizeElement,e,{tagName:r,allowedTags:L}),U&&e.hasChildNodes()&&!Ze(e.firstElementChild)&&as(/<[/\w!]/g,e.innerHTML)&&as(/<[/\w!]/g,e.textContent)||U&&e.namespaceURI===ke&&r===`style`&&Ze(e.firstElementChild)||e.nodeType===Is.progressingInstruction||U&&e.nodeType===Is.comment&&as(/<[/\w]/g,e.data))return W(e),!0;if(ne[r]||!(re.tagCheck instanceof Function&&re.tagCheck(r))&&!L[r]){if(!ne[r]&&nt(r)&&(V.tagNameCheck instanceof RegExp&&as(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r)))return!1;if(ve&&!xe[r]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=f(n[i],!0);t.insertBefore(r,m(e))}}}return W(e),!0}return(y?y(e):e.nodeType)===Is.element&&!Ke(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&as(/<\/no(script|embed|frames)/i,e.innerHTML)?(W(e),!0):(ce&&e.nodeType===Is.text&&(n=e.textContent,Vo([A,j,M],e=>{n=Xo(n,e,` `)}),e.textContent!==n&&(Wo(t.removed,{element:e.cloneNode()}),e.textContent=n)),Qe(k.afterSanitizeElements,e,null),!1)},et=function(e,t,r){if(H[t]||he&&(t===`id`||t===`name`)&&(r in n||r in Ve))return!1;let i=z[t]||re.attributeCheck instanceof Function&&re.attributeCheck(t,e);if(!(ae&&!H[t]&&as(ee,t))&&!(ie&&as(N,t))){if(!i||H[t]){if(!(nt(e)&&(V.tagNameCheck instanceof RegExp&&as(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&as(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t,e))||t===`is`&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&as(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r))))return!1}else if(!Te[t]&&!as(I,Xo(r,P,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Zo(r,`data:`)===0&&Ce[e])&&!(oe&&!as(te,Xo(r,P,``)))&&r)return!1}return!0},tt=ls({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),nt=function(e){return!tt[qo(e)]&&as(F,e)},rt=function(e){Qe(k.beforeSanitizeAttributes,e,null);let n=e.attributes;if(!n||Ye(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0},i=n.length;for(;i--;){let a=n[i],o=a.name,s=a.namespaceURI,c=a.value,l=ze(o),d=c,f=o===`value`?d:Qo(d);if(r.attrName=l,r.attrValue=f,r.keepAttr=!0,r.forceKeepAttr=void 0,Qe(k.uponSanitizeAttribute,e,r),f=r.attrValue,ge&&(l===`id`||l===`name`)&&Zo(f,_e)!==0&&(G(o,e),f=_e+f),U&&as(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){G(o,e);continue}if(l===`attributename`&&Yo(f,`href`)){G(o,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){G(o,e);continue}if(!se&&as(/\/>/i,f)){G(o,e);continue}ce&&Vo([A,j,M],e=>{f=Xo(f,e,` `)});let p=ze(e.nodeName);if(!et(p,l,f)){G(o,e);continue}if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!s)switch(u.getAttributeType(p,l)){case`TrustedHTML`:f=x.createHTML(f);break;case`TrustedScriptURL`:f=x.createScriptURL(f);break}if(f!==d)try{s?e.setAttributeNS(s,o,f):e.setAttribute(o,f),Ye(e)?W(e):Uo(t.removed)}catch{G(o,e)}}Qe(k.afterSanitizeAttributes,e,null)},it=function(e){let t=null,n=K(e);for(Qe(k.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Qe(k.uponSanitizeShadowNode,t,null),$e(t),rt(t),Xe(t.content)&&it(t.content),(y?y(t):t.nodeType)===Is.element){let e=_?_(t):t.shadowRoot;Xe(e)&&(at(e),it(e))}Qe(k.afterSanitizeShadowDOM,e,null)},at=function(e){let t=y?y(e):e.nodeType;if(t===Is.element){let t=_?_(e):e.shadowRoot;Xe(t)&&(at(t),it(t))}let n=h?h(e):e.childNodes;if(!n)return;let r=[];Vo(n,e=>{Wo(r,e)});for(let e of r)at(e);if(t===Is.element){let t=b?b(e):null;if(typeof t==`string`&&ze(t)===`template`){let t=e.content;Xe(t)&&at(t)}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(je=!e,je&&(e=`<!-->`),typeof e!=`string`&&!Ze(e)&&(e=fs(e),typeof e!=`string`))throw os(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(ue||Ue(n),t.removed=[],typeof e==`string`&&(ye=!1),ye){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=ze(t);if(!L[e]||ne[e])throw os(`root node is forbidden and cannot be sanitized in-place`)}if(Ye(e))throw os(`root node is clobbered and cannot be sanitized in-place`);at(e)}else if(Ze(e))i=qe(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Is.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),at(a);else{if(!fe&&!ce&&!le&&e.indexOf(`<`)===-1)return x&&me?x.createHTML(e):e;if(i=qe(e),!i)return fe?null:me?S:``}i&&de&&W(i.firstChild);let c=K(ye?e:i);for(;o=c.nextNode();)$e(o),rt(o),Xe(o.content)&&it(o.content);if(ye)return ce&&Je(e),e;if(fe){if(ce&&Je(i),pe)for(s=E.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(z.shadowroot||z.shadowrootmode)&&(s=O.call(r,s,!0)),s}let l=le?i.outerHTML:i.innerHTML;return le&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&as(Ps,i.ownerDocument.doctype.name)&&(l=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
78
78
|
`+l),ce&&Vo([A,j,M],e=>{l=Xo(l,e,` `)}),x&&me?x.createHTML(l):l},t.setConfig=function(){Ue(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),ue=!0},t.clearConfig=function(){Be=null,ue=!1},t.isValidAttribute=function(e,t,n){return Be||Ue({}),et(ze(e),ze(t),n)},t.addHook=function(e,t){typeof t==`function`&&Wo(k[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=Ho(k[e],t);return n===-1?void 0:Go(k[e],n,1)[0]}return Uo(k[e])},t.removeHooks=function(e){k[e]=[]},t.removeAllHooks=function(){k=zs()},t}var Vs=Bs(),Hs={ALLOWED_TAGS:`p.br.h1.h2.h3.h4.h5.h6.ul.ol.li.strong.em.code.pre.blockquote.table.thead.tbody.tr.th.td.hr.mark.div.span`.split(`.`),ALLOWED_ATTR:[`class`,`title`],FORBID_TAGS:[`style`,`form`,`input`,`button`,`iframe`,`object`,`embed`,`script`],FORBID_ATTR:[`style`,`onerror`,`onload`,`onclick`,`href`,`src`],ALLOW_DATA_ATTR:!1};function Us(e){let t=Co.parse(e??``,{gfm:!0,breaks:!1,async:!1});return Vs.sanitize(t,Hs)}function Ws({text:e,className:t}){let n=(0,W.useMemo)(()=>Us(e??``),[e]);return!e||!e.trim()?null:(0,G.jsx)(`article`,{className:[`prose-message`,t??``].join(` `),dangerouslySetInnerHTML:{__html:n}})}function Gs({open:e,promptName:t,title:n,args:r,sessionId:i,onClose:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(0),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(!1),g=K(),_=Ui();if(ui(e,a),(0,W.useEffect)(()=>{e||(s(!1),l(null),d(0),p(null),h(!1))},[e]),(0,W.useEffect)(()=>{if(!o||c===null)return;let e=setInterval(()=>d(Date.now()-c),250);return()=>clearInterval(e)},[o,c]),(0,W.useEffect)(()=>{!e||f||o||v()},[e]),!e)return null;let v=async()=>{s(!0),l(Date.now());try{let e=await Z.runPrompt(t,r),n=qs(e.stdout);p({success:e.success,stdout:n,stderrTail:e.stderrTail,model:e.model})}catch(e){p({success:!1,stdout:``,stderrTail:e instanceof Error?e.message:String(e),model:``})}finally{s(!1)}},y=async()=>{if(f)try{await navigator.clipboard.writeText(f.stdout),h(!0),setTimeout(()=>h(!1),1800)}catch(e){console.error(`copy failed`,e)}},b=async()=>{if(!(!f||!i))try{let e=`# ${n}\n_Generated ${new Date().toLocaleString()} via ${f.model}_\n\n`;await _.mutateAsync({sessionId:i,content:e+f.stdout}),g.invalidateQueries({queryKey:[`session`,i]}),Q({message:`Saved as session note.`,tone:`success`})}catch(e){Q({message:`Save failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}};return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[720px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] flex flex-col shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`px-5 py-4 border-b border-line flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),(0,G.jsxs)(`p`,{className:`text-fg-muted text-[11px] mt-0.5 font-mono`,children:[`prompt: `,t,f?.model&&(0,G.jsxs)(G.Fragment,{children:[` · model: `,f.model]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`text-fg-muted hover:text-fg text-lg leading-none`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[o&&(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,G.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[Ks(u),` elapsed`]}),(0,G.jsx)(`span`,{children:`· running claude with the Recall MCP tools…`})]}),f&&(0,G.jsx)(G.Fragment,{children:f.success?f.stdout?(0,G.jsx)(Ws,{text:f.stdout}):(0,G.jsx)(`div`,{className:`text-xs italic text-fg-muted`,children:`(empty output)`}):(0,G.jsxs)(`div`,{className:`text-xs`,children:[(0,G.jsx)(`div`,{className:`text-role-user font-semibold mb-2`,children:`Run failed.`}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Tail of stderr:`}),(0,G.jsx)(`pre`,{className:`font-mono text-[11px] whitespace-pre-wrap overflow-auto max-h-64 bg-bg-elevated border border-line rounded p-2`,children:f.stderrTail||`(empty)`})]})})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-line flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:o?`Typical: 20s–3min depending on model and session size.`:f?.success?`Output above is what the model returned verbatim.`:f?`Adjust the scope / model and retry, or check that Recall MCP is installed.`:``}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f?.success&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void y(),className:`text-[11px] bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1`,children:m?`✓ copied`:`📋 copy`}),i&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:_.isPending,className:`text-[11px] bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1 disabled:opacity-50`,children:`📝 save as note`})]}),f&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:o,className:`text-[11px] text-fg-muted hover:text-fg px-2 py-1`,children:`↻ re-run`}),(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs text-fg-muted hover:text-fg px-3 py-1`,children:`Close`})]})]})]})})}function Ks(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function qs(e){if(!e)return``;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&typeof t.result==`string`)return t.result}catch{}return e}function Js({excludeSessionId:e,onPick:t,onClose:n,label:r}){let[i,a]=(0,W.useState)(``),o=(0,W.useRef)(null);(0,W.useEffect)(()=>{requestAnimationFrame(()=>o.current?.focus());let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let s=q({queryKey:[`sessions`,`picker`],queryFn:()=>Z.sessions({limit:300})}),c=i.trim().toLowerCase(),l=(s.data?.items??[]).filter(t=>e&&t.id===e?!1:c?[t.alias,t.project,t.first_user_message,t.id,...t.tags.map(e=>`#${e}`)].filter(Boolean).join(` `).toLowerCase().includes(c):!0);return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-40 flex items-start justify-center pt-24 px-6`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-xl shadow-2xl w-full max-w-2xl max-h-[70vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`p-4 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-fg-dim mb-2`,children:r??`Compare with another session`}),(0,G.jsx)(`input`,{ref:o,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`filter by alias, project, tag, prompt, id…`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm focus:outline-none focus:border-accent`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-muted`,children:`Loading sessions…`}),l.length===0&&!s.isLoading&&(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-muted`,children:`No sessions match.`}),l.map(e=>(0,G.jsx)(Ys,{session:e,onPick:()=>t(e.id)},e.id))]}),(0,G.jsxs)(`div`,{className:`p-3 border-t border-line text-xs text-fg-muted flex justify-between`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Esc`}),` to close`]}),(0,G.jsxs)(`span`,{children:[l.length,` available`]})]})]})})}function Ys({session:e,onPick:t}){return(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:$(`block w-full text-left px-4 py-3 border-b border-line/60 hover:bg-bg-hover transition-colors`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-accent shrink-0`,children:_t(e.id)}),(0,G.jsx)(`span`,{className:`badge bg-bg-active text-fg-dim shrink-0 truncate`,children:e.project}),e.alias&&(0,G.jsx)(`span`,{className:`font-semibold text-sm text-fg truncate`,children:e.alias})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted shrink-0`,children:yt(e.started_at)})]}),!e.alias&&(0,G.jsx)(`div`,{className:`text-xs text-fg-dim line-clamp-1`,children:vt(e.first_user_message,160)||(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(no prompt)`})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[e.message_count,` msgs`]}),e.tags.slice(0,3).map(e=>(0,G.jsxs)(`span`,{className:`text-role-tool`,children:[`#`,e]},e))]})]})}function Xs(){let[e,t]=(0,W.useState)(()=>new Set),[n,r]=(0,W.useState)(null),i=(0,W.useCallback)(t=>e.has(t),[e]),a=(0,W.useCallback)(()=>{t(new Set),r(null)},[]),o=(0,W.useCallback)((i,a,o)=>{let s=o.metaKey||o.ctrlKey;if(o.shiftKey&&n&&n!==i){let e=a.indexOf(n),r=a.indexOf(i);if(e>=0&&r>=0){let[n,i]=e<r?[e,r]:[r,e];return t(e=>{let t=new Set(e);for(let e=n;e<=i;e++){let n=a[e];n&&t.add(n)}return t}),!0}}return s?(t(e=>{let t=new Set(e);return t.has(i)?t.delete(i):t.add(i),t}),r(i),!0):(e.size>0&&t(new Set),r(i),!1)},[n,e]);return(0,W.useEffect)(()=>{let t=t=>{if(t.key!==`Escape`||e.size===0)return;let n=t.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||a()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.size,a]),{selected:e,ids:(0,W.useMemo)(()=>Array.from(e),[e]),count:e.size,isSelected:i,handleRowClick:o,clear:a}}var Zs=60;function Qs(e){if(e==null)return null;let t=e.trim();return t.length>0?t:null}function $s(e){let t=e.split(`
|
|
79
|
-
`,1)[0].trim();return t?t.length>Zs?t.slice(0,Zs):t:null}function ec(e){let t=Qs(e.alias),n=Qs(e.autoTitle),r=Qs(e.firstUserMessage),i=e.aliasSource??null,a=e.autoTitleSource??null;if(n&&a===`agent`)return n;if(t&&i===`manual`)return t;if(n&&(i===`auto`||t===null))return n;if(t)return t;if(n)return n;if(r){let e=$s(r);if(e)return e}return e.sessionId.slice(0,8)}function tc(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;let n=new Date(t);return`${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}`}function nc(e){let t=new Map,n=new Map;for(let t of e){let e=n.get(t.label);e?e.push(t):n.set(t.label,[t])}for(let[,e]of n){if(e.length===1){t.set(e[0].sessionId,``);continue}let n=e.map(e=>tc(e.startedAt));if(n.every(e=>e!==null)&&new Set(n).size===n.length){e.forEach((e,r)=>t.set(e.sessionId,` · ${n[r]}`));continue}let r=e.map((e,t)=>{let r=n[t],i=e.messageCount,a=Number.isFinite(i)&&i!=null?`${i} msgs`:null;return r&&a?`${r} · ${a}`:r||a||null});if(r.every(e=>e!==null)&&new Set(r).size===r.length){e.forEach((e,n)=>t.set(e.sessionId,` · ${r[n]}`));continue}for(let n of e)t.set(n.sessionId,` · ${n.sessionId.slice(0,6)}`)}return t}var rc={agent:{icon:`🔮`,tooltip:`agent-generated title (sacred)`},manual_alias:{icon:`✏️`,tooltip:`manual alias set by you`},programmatic:{icon:`🤖`,tooltip:`bot-loop / batch-job session`},recursive_meta:{icon:`🪞`,tooltip:`recursive meta prompt — needs context regen`},low_signal:{icon:`⚠️`,tooltip:`low-signal title — regenerate from context`}},ic={low_signal:0,recursive_meta:1,programmatic:2,template_pending:3,"fixed_v0.16.1":4,clean:5,agent:6,manual_alias:7},ac=new Set([`low_signal`,`recursive_meta`,`programmatic`]),oc=new Set([`low_signal`,`recursive_meta`,`programmatic`]),sc=new Set([`clean`,`fixed_v0.16.1`,`agent`,`manual_alias`]);function cc(e){switch(e){case`all`:return()=>!0;case`needs_work`:return e=>oc.has(e);case`clean_set`:return e=>sc.has(e);default:return t=>t===e}}function lc({projectName:e,collectionId:t,selectedSessionId:n,onSelect:r,searchQuery:i,searchScope:a,semanticMode:o}){let s=i.trim().length>1,c=!!t&&!s,l=a===`project`&&e?e:void 0,[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(`all`),[v,y]=(0,W.useState)(!1),[b,x]=hc(e),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(null),E=(0,W.useRef)(null),{isPinned:D,togglePin:O}=ai(),[,k]=Nn(),A=Xs(),j=K(),M=zn({storageKey:`claude-recall:sessions-pane`,defaultWidth:384,minWidth:260,maxWidth:680,collapsedWidth:40}),ee=Hn(t),N=Vn(!1),te=Yn(),P=lt({queryKey:[`sessions`,e??`all`,u,f,t??`none`],queryFn:({pageParam:n})=>Z.sessions({projectName:e??void 0,since:u||void 0,until:f||void 0,collectionId:t??void 0,limit:100,cursor:n}),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!s,refetchInterval:8e3,refetchIntervalInBackground:!1,staleTime:4e3}),F=(0,W.useMemo)(()=>P.data?.pages.flatMap(e=>e.items),[P.data]),I=q({queryKey:[`search`,i,l??`global`,o?`semantic`:`fts`],queryFn:()=>Z.search(i,60,l,o?`semantic`:void 0),enabled:s}),L=(0,W.useMemo)(()=>{let e=F;if(!e)return e;let t=cc(g),n=e.filter(e=>!b&&e.title_quality===`programmatic`?!1:t(e.title_quality)),r=[],i=[];for(let e of n)(D(e.id)?r:i).push(e);if(v){let e=(e,t)=>(ic[e.title_quality]??99)-(ic[t.title_quality]??99);r.sort(e),i.sort(e)}return[...r,...i]},[F,g,b,v,D]),R=L?L.map(e=>e.id):[],z=(0,W.useMemo)(()=>L?nc(L.map(e=>{let t=e.alias?.trim()||e.auto_title?.trim()||e.id.slice(0,8);return{sessionId:e.id,label:t,startedAt:e.started_at,messageCount:e.message_count}})):new Map,[L]),B=(0,W.useMemo)(()=>L?L.filter(e=>ac.has(e.title_quality)).map(e=>e.id):[],[L]),[V,ne]=(0,W.useState)(null),[H,re]=(0,W.useState)(null),[ie,ae]=(0,W.useState)(null),[oe,se]=(0,W.useState)(null),ce=uc(oe);if(M.collapsed)return(0,G.jsxs)(`section`,{className:`pane shrink-0 border-r border-line relative flex flex-col items-center`,style:{width:`${M.effectiveWidth}px`},children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`w-full py-2 text-xs text-fg-muted hover:text-fg hover:bg-bg-hover border-b border-line`,title:`expand sessions pane (Cmd+\\\\)`,children:`»`}),(0,G.jsxs)(`div`,{className:`flex-1 w-full flex items-center justify-center px-1 text-[10px] text-fg-muted tracking-wider`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:[`Sessions`,L?` (${L.length})`:``]})]});if(s)return(0,G.jsxs)(`section`,{className:`pane shrink-0 relative`,style:{width:`${M.effectiveWidth}px`},children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal`,title:`collapse sessions pane (Cmd+\\\\)`,children:`«`}),(0,G.jsx)(`span`,{children:l?`Results in ${l}`:`Results across all projects`})]}),I.data&&(0,G.jsx)(`span`,{children:I.data.hits.length})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[I.isFetching&&!I.data&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Searching…`}),I.isError&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-role-user`,children:[`Search failed: `,I.error.message]}),I.data?.hits.length===0&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:[`No matches for "`,i,`"`,l?` in ${l}`:``,`.`]}),I.data?.hits.map((e,t)=>(0,G.jsx)(mc,{hit:e,active:e.session_id===n,onSelect:()=>r(e.session_id,e.message_uuid),onContextMenu:(t,n)=>re({sessionId:e.session_id,x:t,y:n})},`${e.session_id}-${e.message_uuid??t}`))]}),(0,G.jsx)(dc,{onStart:e=>M.beginResize(e,M.width)}),H&&(0,G.jsx)(Pi,{sessionId:H.sessionId,x:H.x,y:H.y,pinned:D(H.sessionId),onClose:()=>re(null),onTogglePin:()=>O(H.sessionId),onAddToCollection:()=>{ae(H.sessionId),re(null)},onCompareWith:()=>k({session:H.sessionId,compareWith:null}),onLinkToSession:()=>se(H.sessionId),onOpen:()=>r(H.sessionId)}),ie&&(0,G.jsx)(Bi,{sessionId:ie,onClose:()=>ae(null),anchor:`center`}),oe&&(0,G.jsx)(Js,{label:`Link to another session`,excludeSessionId:oe,onPick:e=>{ce.mutate(e),se(null)},onClose:()=>se(null)})]});let U=ee.data?.collection??null,le=fc(U,N.data?.collections??[]);return(0,G.jsxs)(`section`,{className:`pane shrink-0 relative`,style:{width:`${M.effectiveWidth}px`},children:[c&&U?(0,G.jsxs)(`div`,{className:`border-b border-line bg-bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 text-xs text-fg-muted normal-case tracking-normal`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1 min-w-0`,children:le.map((e,t)=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 min-w-0`,children:[t>0&&(0,G.jsx)(`span`,{className:`text-fg-muted/60`,children:`›`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>k({col:e.id,session:null,msg:null}),className:$(`truncate`,t===le.length-1?`text-fg font-medium`:`hover:text-fg`),children:[e.icon??`📂`,` `,e.name]})]},e.id))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k({col:null,session:null,msg:null}),className:`text-fg-muted hover:text-fg shrink-0`,title:`exit collection view`,children:`✕ clear`})]}),U.description&&(0,G.jsx)(`div`,{className:`px-4 pb-2 text-xs text-fg-muted italic`,children:U.description})]}):null,(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal shrink-0`,title:`collapse sessions pane (Cmd+\\\\)`,children:`«`}),(0,G.jsx)(`span`,{className:`truncate`,children:c&&U?`${U.icon??`📂`} ${U.name}`:e||`All sessions`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k({view:`help`,helpSection:`taxonomy`}),className:`text-[10px] font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent shrink-0`,title:`Session vs Project vs Collection vs Tag — what's the difference?`,children:`(?)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 normal-case tracking-normal`,children:[(0,G.jsx)(_i,{projectName:e,collectionId:t}),(0,G.jsx)(Mi,{projectName:e}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:$(`text-xs hover:text-fg`,m?`text-accent`:`text-fg-muted`),children:m?`hide dates`:`dates`}),L&&(0,G.jsx)(`span`,{className:`text-xs`,children:L.length})]})]}),m&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 border-b border-line bg-bg text-xs`,children:[(0,G.jsx)(`input`,{type:`date`,value:u,onChange:e=>d(e.target.value),className:`flex-1 bg-bg-elevated border border-line rounded px-2 py-1 text-fg`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`to`}),(0,G.jsx)(`input`,{type:`date`,value:f,onChange:e=>p(e.target.value),className:`flex-1 bg-bg-elevated border border-line rounded px-2 py-1 text-fg`}),(u||f)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{d(``),p(``)},className:`text-fg-muted hover:text-fg`,title:`clear date filter`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b border-line bg-bg text-xs normal-case tracking-normal`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`label`,{className:`text-fg-muted shrink-0`,htmlFor:`quality-filter`,children:`quality:`}),(0,G.jsxs)(`select`,{id:`quality-filter`,value:g,onChange:e=>_(e.target.value),className:`bg-bg-elevated border border-line rounded px-2 py-1 text-fg`,title:`filter sessions by title-quality classification`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),(0,G.jsx)(`option`,{value:`needs_work`,children:`⚠️ needs work`}),(0,G.jsx)(`option`,{value:`clean_set`,children:`clean`}),(0,G.jsx)(`option`,{value:`low_signal`,children:`⚠️ low signal`}),(0,G.jsx)(`option`,{value:`recursive_meta`,children:`🪞 recursive meta`}),(0,G.jsx)(`option`,{value:`programmatic`,children:`🤖 programmatic`}),(0,G.jsx)(`option`,{value:`agent`,children:`🔮 agent ✨`}),(0,G.jsx)(`option`,{value:`manual_alias`,children:`✏️ manual alias`}),(0,G.jsx)(`option`,{value:`clean`,children:`clean only`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:$(`shrink-0 hover:text-fg`,v?`text-accent`:`text-fg-muted`),title:`sort needs-work sessions to the top`,children:v?`↕ sorted by quality`:`↕ sort by quality`})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-3 shrink-0`,children:(0,G.jsxs)(`label`,{className:`flex items-center gap-1 text-fg-muted hover:text-fg cursor-pointer select-none`,title:`Show 🤖 programmatic / bot-loop sessions in the list`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`accent-accent`}),`show bots`]})})]}),g===`needs_work`&&B.length>0&&(0,G.jsx)(`div`,{className:`px-4 py-2 border-b border-line bg-accent/5`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!0),disabled:w!=null,className:`text-xs text-accent hover:underline disabled:text-fg-muted disabled:cursor-not-allowed`,children:w?`regenerating ${w.current}/${w.total}…`:`✨ Regenerate ${B.length} sessions from graph context`})}),w&&(0,G.jsx)(_c,{progress:w,onCancel:()=>{E.current?.abort()}}),A.count>0&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-1.5 border-b border-line bg-accent/10 text-xs normal-case tracking-normal`,children:[(0,G.jsxs)(`span`,{className:`text-accent`,children:[A.count,` selected`,(0,G.jsx)(`span`,{className:`text-fg-muted ml-2`,children:`right-click for actions · esc to clear`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,className:`text-accent hover:text-fg`,onClick:()=>{navigator.clipboard.writeText(A.ids.join(`
|
|
79
|
+
`,1)[0].trim();return t?t.length>Zs?t.slice(0,Zs):t:null}function ec(e){let t=Qs(e.alias),n=Qs(e.autoTitle),r=Qs(e.firstUserMessage),i=e.aliasSource??null,a=e.autoTitleSource??null;if(n&&a===`agent`)return n;if(t&&i===`manual`)return t;if(n&&(i===`auto`||t===null))return n;if(t)return t;if(n)return n;if(r){let e=$s(r);if(e)return e}return e.sessionId.slice(0,8)}function tc(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;let n=new Date(t);return`${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}`}function nc(e){let t=new Map,n=new Map;for(let t of e){let e=n.get(t.label);e?e.push(t):n.set(t.label,[t])}for(let[,e]of n){if(e.length===1){t.set(e[0].sessionId,``);continue}let n=e.map(e=>tc(e.startedAt));if(n.every(e=>e!==null)&&new Set(n).size===n.length){e.forEach((e,r)=>t.set(e.sessionId,` · ${n[r]}`));continue}let r=e.map((e,t)=>{let r=n[t],i=e.messageCount,a=Number.isFinite(i)&&i!=null?`${i} msgs`:null;return r&&a?`${r} · ${a}`:r||a||null});if(r.every(e=>e!==null)&&new Set(r).size===r.length){e.forEach((e,n)=>t.set(e.sessionId,` · ${r[n]}`));continue}for(let n of e)t.set(n.sessionId,` · ${n.sessionId.slice(0,6)}`)}return t}var rc={agent:{icon:`🔮`,tooltip:`agent-generated title (sacred)`},manual_alias:{icon:`✏️`,tooltip:`manual alias set by you`},programmatic:{icon:`🤖`,tooltip:`bot-loop / batch-job session`},recursive_meta:{icon:`🪞`,tooltip:`recursive meta prompt — needs context regen`},low_signal:{icon:`⚠️`,tooltip:`low-signal title — regenerate from context`}},ic={low_signal:0,recursive_meta:1,programmatic:2,template_pending:3,"fixed_v0.16.1":4,clean:5,agent:6,manual_alias:7},ac=new Set([`low_signal`,`recursive_meta`,`programmatic`]),oc=new Set([`low_signal`,`recursive_meta`,`programmatic`]),sc=new Set([`clean`,`fixed_v0.16.1`,`agent`,`manual_alias`]);function cc(e){switch(e){case`all`:return()=>!0;case`needs_work`:return e=>oc.has(e);case`clean_set`:return e=>sc.has(e);default:return t=>t===e}}function lc({projectName:e,collectionId:t,selectedSessionId:n,onSelect:r,searchQuery:i,searchScope:a,semanticMode:o}){let s=i.trim().length>1,c=!!t&&!s,l=a===`project`&&e?e:void 0,[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(`all`),[v,y]=(0,W.useState)(!1),[b,x]=hc(e),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(null),E=(0,W.useRef)(null),{isPinned:D,togglePin:O}=ai(),[,k]=Nn(),A=Xs(),j=K(),M=zn({storageKey:`claude-recall:sessions-pane`,defaultWidth:384,minWidth:260,maxWidth:680,collapsedWidth:40}),ee=Hn(t),N=Vn(!1),te=Yn(),P=lt({queryKey:[`sessions`,e??`all`,u,f,t??`none`],queryFn:({pageParam:n})=>Z.sessions({projectName:e??void 0,since:u||void 0,until:f||void 0,collectionId:t??void 0,limit:100,cursor:n}),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor??void 0,enabled:!s,refetchInterval:8e3,refetchIntervalInBackground:!1,staleTime:4e3}),F=(0,W.useMemo)(()=>P.data?.pages.flatMap(e=>e.items),[P.data]),I=q({queryKey:[`search`,i,l??`global`,o?`semantic`:`fts`],queryFn:()=>Z.search(i,60,l,o?`semantic`:void 0),enabled:s}),L=(0,W.useMemo)(()=>{let e=F;if(!e)return e;let t=cc(g),n=e.filter(e=>!b&&e.title_quality===`programmatic`?!1:t(e.title_quality)),r=[],i=[];for(let e of n)(D(e.id)?r:i).push(e);if(v){let e=(e,t)=>(ic[e.title_quality]??99)-(ic[t.title_quality]??99);r.sort(e),i.sort(e)}return[...r,...i]},[F,g,b,v,D]),R=L?L.map(e=>e.id):[],z=(0,W.useMemo)(()=>L?nc(L.map(e=>{let t=e.alias?.trim()||e.auto_title?.trim()||e.id.slice(0,8);return{sessionId:e.id,label:t,startedAt:e.started_at,messageCount:e.message_count}})):new Map,[L]),B=(0,W.useMemo)(()=>L?L.filter(e=>ac.has(e.title_quality)).map(e=>e.id):[],[L]),[V,ne]=(0,W.useState)(null),[H,re]=(0,W.useState)(null),[ie,ae]=(0,W.useState)(null),[oe,se]=(0,W.useState)(null),ce=uc(oe);if(M.collapsed)return(0,G.jsxs)(`section`,{className:`pane shrink-0 border-r border-line relative flex flex-col items-center`,style:{width:`${M.effectiveWidth}px`},children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`w-full py-2 text-xs text-fg-muted hover:text-fg hover:bg-bg-hover border-b border-line`,title:`expand sessions pane (Cmd+\\\\)`,children:`»`}),(0,G.jsxs)(`div`,{className:`flex-1 w-full flex items-center justify-center px-1 text-[10px] text-fg-muted tracking-wider`,style:{writingMode:`vertical-rl`,transform:`rotate(180deg)`},children:[`Sessions`,L?` (${L.length})`:``]})]});if(s)return(0,G.jsxs)(`section`,{className:`pane shrink-0 relative`,style:{width:`${M.effectiveWidth}px`},children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal`,title:`collapse sessions pane (Cmd+\\\\)`,children:`«`}),(0,G.jsx)(`span`,{children:l?`Results in ${l}`:`Results across all projects`})]}),I.data&&(0,G.jsx)(`span`,{children:I.data.hits.length})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[I.isFetching&&!I.data&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Searching…`}),I.isError&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-role-user`,children:[`Search failed: `,I.error.message]}),I.data?.hits.length===0&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:[`No matches for "`,i,`"`,l?` in ${l}`:``,`.`]}),I.data?.hits.map((e,t)=>(0,G.jsx)(mc,{hit:e,active:e.session_id===n,onSelect:()=>r(e.session_id,e.message_uuid),onContextMenu:(t,n)=>re({sessionId:e.session_id,x:t,y:n})},`${e.session_id}-${e.message_uuid??t}`))]}),(0,G.jsx)(dc,{onStart:e=>M.beginResize(e,M.width)}),H&&(0,G.jsx)(Pi,{sessionId:H.sessionId,x:H.x,y:H.y,pinned:D(H.sessionId),onClose:()=>re(null),onTogglePin:()=>O(H.sessionId),onAddToCollection:()=>{ae(H.sessionId),re(null)},onCompareWith:()=>k({session:H.sessionId,compareWith:null}),onLinkToSession:()=>se(H.sessionId),onOpen:()=>r(H.sessionId)}),ie&&(0,G.jsx)(Bi,{sessionId:ie,onClose:()=>ae(null),anchor:`center`}),oe&&(0,G.jsx)(Js,{label:`Link to another session`,excludeSessionId:oe,onPick:e=>{ce.mutate(e),se(null)},onClose:()=>se(null)})]});let U=ee.data?.collection??null,le=fc(U,N.data?.collections??[]);return(0,G.jsxs)(`section`,{className:`pane shrink-0 relative`,style:{width:`${M.effectiveWidth}px`},children:[c&&U?(0,G.jsxs)(`div`,{className:`border-b border-line bg-bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 text-xs text-fg-muted normal-case tracking-normal`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1 min-w-0`,children:le.map((e,t)=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 min-w-0`,children:[t>0&&(0,G.jsx)(`span`,{className:`text-fg-muted/60`,children:`›`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>k({col:e.id,session:null,msg:null}),className:$(`truncate`,t===le.length-1?`text-fg font-medium`:`hover:text-fg`),children:[e.icon??`📂`,` `,e.name]})]},e.id))}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k({col:null,session:null,msg:null}),className:`text-fg-muted hover:text-fg shrink-0`,title:`exit collection view`,children:`✕ clear`})]}),U.description&&(0,G.jsx)(`div`,{className:`px-4 pb-2 text-xs text-fg-muted italic`,children:U.description})]}):null,(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:M.toggleCollapsed,className:`text-fg-muted hover:text-fg text-xs normal-case tracking-normal shrink-0`,title:`collapse sessions pane (Cmd+\\\\)`,children:`«`}),(0,G.jsx)(`span`,{className:`truncate`,children:c&&U?`${U.icon??`📂`} ${U.name}`:e||`All sessions`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>k({view:`help`,helpSection:`taxonomy`}),className:`text-[10px] font-normal normal-case tracking-normal text-fg-muted/70 hover:text-accent shrink-0`,title:`Session vs Project vs Collection vs Tag — what's the difference?`,children:`(?)`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5 normal-case tracking-normal`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Mi,{projectName:e}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:$(`text-xs hover:text-fg`,m?`text-accent`:`text-fg-muted`),children:m?`hide dates`:`dates`}),L&&(0,G.jsx)(`span`,{className:`text-xs`,children:L.length})]}),(0,G.jsx)(_i,{projectName:e,collectionId:t})]})]}),m&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2.5 border-b border-line bg-bg text-xs`,children:[(0,G.jsx)(`input`,{type:`date`,value:u,onChange:e=>d(e.target.value),className:`flex-1 bg-bg-elevated border border-line rounded px-2 py-1 text-fg`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`to`}),(0,G.jsx)(`input`,{type:`date`,value:f,onChange:e=>p(e.target.value),className:`flex-1 bg-bg-elevated border border-line rounded px-2 py-1 text-fg`}),(u||f)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{d(``),p(``)},className:`text-fg-muted hover:text-fg`,title:`clear date filter`,children:`×`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-2 border-b border-line bg-bg text-xs normal-case tracking-normal`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`label`,{className:`text-fg-muted shrink-0`,htmlFor:`quality-filter`,children:`quality:`}),(0,G.jsxs)(`select`,{id:`quality-filter`,value:g,onChange:e=>_(e.target.value),className:`bg-bg-elevated border border-line rounded px-2 py-1 text-fg`,title:`filter sessions by title-quality classification`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),(0,G.jsx)(`option`,{value:`needs_work`,children:`⚠️ needs work`}),(0,G.jsx)(`option`,{value:`clean_set`,children:`clean`}),(0,G.jsx)(`option`,{value:`low_signal`,children:`⚠️ low signal`}),(0,G.jsx)(`option`,{value:`recursive_meta`,children:`🪞 recursive meta`}),(0,G.jsx)(`option`,{value:`programmatic`,children:`🤖 programmatic`}),(0,G.jsx)(`option`,{value:`agent`,children:`🔮 agent ✨`}),(0,G.jsx)(`option`,{value:`manual_alias`,children:`✏️ manual alias`}),(0,G.jsx)(`option`,{value:`clean`,children:`clean only`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:$(`shrink-0 hover:text-fg`,v?`text-accent`:`text-fg-muted`),title:`sort needs-work sessions to the top`,children:v?`↕ sorted by quality`:`↕ sort by quality`})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-3 shrink-0`,children:(0,G.jsxs)(`label`,{className:`flex items-center gap-1 text-fg-muted hover:text-fg cursor-pointer select-none`,title:`Show 🤖 programmatic / bot-loop sessions in the list`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`accent-accent`}),`show bots`]})})]}),g===`needs_work`&&B.length>0&&(0,G.jsx)(`div`,{className:`px-4 py-2 border-b border-line bg-accent/5`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>C(!0),disabled:w!=null,className:`text-xs text-accent hover:underline disabled:text-fg-muted disabled:cursor-not-allowed`,children:w?`regenerating ${w.current}/${w.total}…`:`✨ Regenerate ${B.length} sessions from graph context`})}),w&&(0,G.jsx)(_c,{progress:w,onCancel:()=>{E.current?.abort()}}),A.count>0&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 py-1.5 border-b border-line bg-accent/10 text-xs normal-case tracking-normal`,children:[(0,G.jsxs)(`span`,{className:`text-accent`,children:[A.count,` selected`,(0,G.jsx)(`span`,{className:`text-fg-muted ml-2`,children:`right-click for actions · esc to clear`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,className:`text-accent hover:text-fg`,onClick:()=>{navigator.clipboard.writeText(A.ids.join(`
|
|
80
80
|
`))},title:`copy selected session IDs (one per line)`,children:`copy IDs`}),(0,G.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,onClick:A.clear,title:`clear selection (esc)`,children:`clear`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[P.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Loading sessions…`}),P.isError&&(0,G.jsxs)(`div`,{className:`px-4 py-6 text-xs text-role-user`,children:[`Failed to load: `,P.error.message]}),L?.length===0&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`No sessions match the current filter.`}),L?.map(i=>(0,G.jsx)(pc,{session:i,active:i.id===n,onSelect:()=>r(i.id),showProject:!e,pinned:D(i.id),onTogglePin:()=>O(i.id),removableFrom:c&&t?t:null,onRemoveFromCollection:c&&t?async()=>{try{await te.mutateAsync({collectionId:t,sessionId:i.id})}catch(e){console.error(`remove from collection failed`,e)}}:void 0,selection:A,orderedIds:R,onMultiContext:(e,t)=>ne({x:e,y:t}),disambiguator:z.get(i.id)??``},i.id)),P.hasNextPage&&(0,G.jsx)(Sc,{onIntersect:()=>{P.isFetchingNextPage||P.fetchNextPage()}}),P.isFetchingNextPage&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted py-2 text-center`,children:`Loading more…`})]}),(0,G.jsx)(dc,{onStart:e=>M.beginResize(e,M.width)}),V&&A.count>1&&(0,G.jsx)(Li,{sessionIds:A.ids,x:V.x,y:V.y,onClose:()=>ne(null),onClearSelection:A.clear}),S&&(0,G.jsx)(bc,{projectName:e,candidateIds:B,onClose:()=>C(!1),onConfirm:t=>{C(!1),xc({project:e,candidateIds:B,model:t.model,setProgress:T,abortRef:E,invalidate:()=>{j.invalidateQueries({queryKey:[`sessions`]})}})}})]})}function uc(e){let t=K();return J({mutationFn:async t=>{if(!e)throw Error(`source session id missing`);if(e===t)throw Error(`a session cannot link to itself`);return Z.createWikiLink(e,t)},onSuccess:(n,r)=>{Q({message:`Linked to ${r.slice(0,8)}…`,tone:`success`}),e&&t.invalidateQueries({queryKey:[`session-links`,e,`wiki_link`]}),t.invalidateQueries({queryKey:[`session-links`,r,`wiki_link`]})},onError:e=>{Q({message:`Link failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}})}function dc({onStart:e}){return(0,G.jsx)(`div`,{className:`absolute top-0 right-0 h-full w-2 cursor-col-resize group z-10`,onMouseDown:t=>{t.preventDefault(),e(t.clientX)},role:`separator`,"aria-orientation":`vertical`,title:`drag to resize sessions pane`,children:(0,G.jsx)(`div`,{className:`absolute top-0 right-0 h-full w-px bg-line group-hover:bg-accent transition-colors`})})}function fc(e,t){if(!e)return[];let n=new Map;for(let e of t)n.set(e.id,e);n.has(e.id)||n.set(e.id,e);let r=[],i=n.get(e.id),a=new Set;for(;i&&!a.has(i.id);)a.add(i.id),r.unshift(i),i=i.parent_id?n.get(i.parent_id):void 0;return r}function pc({session:e,active:t,onSelect:n,showProject:r,pinned:i,onTogglePin:a,removableFrom:o,onRemoveFromCollection:s,selection:c,orderedIds:l,onMultiContext:u,disambiguator:d}){let[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(!1),S=uc(e.id),C=gc(e.id),[,w]=Nn(),T=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),staleTime:3e4}),E=!!(T.data?.installed&&T.data?.claudeCliAvailable),D=c.isSelected(e.id),O=t=>c.handleRowClick(e.id,l,{metaKey:t.metaKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey})?(t.preventDefault(),t.stopPropagation(),!0):!1;return(0,G.jsxs)(`div`,{"data-testid":`session-row`,"data-session-id":e.id,className:$(`list-item group !cursor-default`,t&&`list-item-active`,D&&`ring-2 ring-accent/60 ring-inset bg-accent/5`),draggable:!0,onContextMenu:e=>{if(e.preventDefault(),D&&c.count>1){u(e.clientX,e.clientY);return}h({x:e.clientX,y:e.clientY})},onDragStart:t=>{t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(gr,e.id),t.dataTransfer.setData(`text/plain`,`recall-session:${e.id}`)},title:`drag onto a collection in the left pane to add this session to it`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:$(`shrink-0 text-sm transition-colors`,i?`text-accent`:`text-fg-muted hover:text-fg opacity-60 hover:opacity-100`),title:i?`unpin`:`pin to top`,children:i?`★`:`☆`}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{O(e)||n()},className:`font-mono text-xs text-accent shrink-0 hover:underline cursor-pointer`,children:_t(e.id)}),r&&(0,G.jsx)(`span`,{className:`badge bg-bg-active text-fg-dim shrink-0 truncate`,children:e.project})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[o&&s&&(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},className:`text-[10px] text-fg-muted hover:text-role-user opacity-0 group-hover:opacity-100 transition-opacity`,title:`remove from this collection (session itself is preserved)`,children:`remove`}),(0,G.jsxs)(`div`,{className:`text-xs text-right`,title:`started ${yt(e.started_at)}${e.ended_at&&e.ended_at!==e.started_at?`\nlast activity ${yt(e.ended_at)}`:``}`,children:[(0,G.jsx)(`div`,{className:e.ended_at?`text-accent`:`text-fg-muted`,children:yt(e.ended_at??e.started_at)}),e.ended_at&&e.started_at&&e.ended_at!==e.started_at&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] mt-0.5`,children:[`started `,yt(e.started_at)]})]})]})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:e=>{O(e)||n()},className:`text-left w-full cursor-pointer`,children:[(()=>{let t=e.alias_source===`auto`,n=e.alias?e.alias:e.auto_title?e.auto_title:null,r=!!e.auto_title&&n===e.auto_title,i=r&&e.auto_title_source===`agent`,a=r?e.alias?`${e.auto_title_source??`heuristic`} title · overriding ${t?`auto-alias`:`manual alias`} "${e.alias}"`:`auto-generated title (${e.auto_title_source??`heuristic`})`:void 0,o=!!n,s=e.first_user_message,c=rc[e.title_quality],l=!!c&&!i;return(0,G.jsxs)(G.Fragment,{children:[o&&(0,G.jsxs)(`div`,{className:$(`text-sm font-semibold text-fg leading-snug mb-1`,(i||l)&&`flex items-center gap-1.5`),title:a,children:[i&&(0,G.jsx)(`span`,{className:`text-accent text-[11px]`,"aria-hidden":`true`,children:`✨`}),l&&c&&(0,G.jsx)(`span`,{className:`text-[11px] shrink-0`,title:c.tooltip,"aria-label":c.tooltip,children:c.icon}),(0,G.jsxs)(`span`,{className:`truncate`,children:[n,d&&(0,G.jsx)(`span`,{className:`text-fg-muted font-normal`,title:`this row's title also appears on another session in the list — suffix added so they don't look identical`,children:d})]})]}),(0,G.jsx)(`div`,{className:$(`leading-snug`,o?`text-xs text-fg-muted line-clamp-1`:`text-sm text-fg/90 line-clamp-2`),children:vt(s,240)||(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(no user prompt captured)`})})]})})(),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[e.message_count,` msgs`]}),e.git_branch&&(0,G.jsxs)(`span`,{className:`font-mono`,children:[`⎇ `,e.git_branch]}),e.origin&&(0,G.jsx)(`span`,{className:`text-xs bg-accent/10 text-accent px-1.5 py-0.5 rounded`,title:`started from ${e.origin.label} (v0.15 auto-detected)`,children:e.origin.label}),e.has_notes===1&&(0,G.jsx)(`span`,{className:`text-accent`,title:`this session has notes`,children:`📝`}),e.verification_status&&(0,G.jsx)(oi,{status:e.verification_status})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2 normal-case tracking-normal`,onClick:e=>e.stopPropagation(),children:[e.tags?.slice(0,5).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full bg-role-tool/15 text-role-tool text-[10px] font-medium`,children:[`#`,e]},e)),e.tags&&e.tags.length>5&&(0,G.jsxs)(`span`,{className:`text-[10px] text-fg-muted`,children:[`+`,e.tags.length-5]}),f?(0,G.jsx)(ci,{sessionId:e.id,existingTags:e.tags??[],onDone:()=>p(!1),variant:`row`}):(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p(!0)},className:`inline-flex items-center px-1.5 py-0.5 rounded-full border border-dashed border-line/60 text-[10px] text-fg-muted opacity-0 group-hover:opacity-70 hover:!opacity-100 hover:text-fg transition-opacity`,title:`add tag`,children:`+ tag`})]}),m&&(0,G.jsx)(Pi,{sessionId:e.id,x:m.x,y:m.y,pinned:i,recallPromptsAvailable:E,titleQuality:e.title_quality,onClose:()=>h(null),onTogglePin:a,onAddToCollection:()=>_(!0),onCompareWith:()=>w({session:e.id,compareWith:null}),onLinkToSession:()=>x(!0),onOpen:n,onRegenerateTitle:()=>C.mutate({}),onRunPrompt:(e,t,n)=>y({name:e,title:t,args:n})}),b&&(0,G.jsx)(Js,{label:`Link to another session`,excludeSessionId:e.id,onPick:e=>{S.mutate(e),x(!1)},onClose:()=>x(!1)}),g&&(0,G.jsx)(Bi,{sessionId:e.id,onClose:()=>_(!1),anchor:`center`}),v&&(0,G.jsx)(Gs,{open:!!v,promptName:v.name,title:v.title,args:v.args,sessionId:e.id,onClose:()=>y(null)})]})}function mc({hit:e,active:t,onSelect:n,onContextMenu:r}){let i=(()=>{let t=e.snippet.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n=``,r=!1,i=0;for(;i<t.length;)t.startsWith(`<<`,i)?(r||=(n+=`<mark>`,!0),i+=8):t.startsWith(`>>`,i)?(r&&=(n+=`</mark>`,!1),i+=8):(n+=t[i],i+=1);return r&&(n+=`</mark>`),n})();return(0,G.jsxs)(`button`,{type:`button`,onClick:n,onContextMenu:e=>{r&&(e.preventDefault(),r(e.clientX,e.clientY))},draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(gr,e.session_id),t.dataTransfer.setData(`text/plain`,`recall-session:${e.session_id}`)},title:`right-click for actions · drag onto a collection in the left pane`,className:$(`list-item`,t&&`list-item-active`),children:[e.alias&&(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg leading-snug mb-1`,children:e.alias}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-accent shrink-0`,children:_t(e.session_id)}),(0,G.jsx)(`span`,{className:`badge bg-bg-active text-fg-dim shrink-0 truncate`,children:e.project}),e.role&&(0,G.jsx)(`span`,{className:$(`badge shrink-0`,e.role===`user`&&`bg-role-user/15 text-role-user`,e.role===`assistant`&&`bg-role-assistant/15 text-role-assistant`,e.role===`system`&&`bg-role-system/15 text-fg-dim`),children:e.role}),e.matched_via===`semantic`&&(0,G.jsx)(`span`,{className:`badge shrink-0 bg-accent/20 text-accent`,title:`Matched via semantic summary (v0.11)`,children:`AI`})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted shrink-0`,children:yt(e.started_at)})]}),(0,G.jsx)(`div`,{className:`text-sm text-fg/90 leading-snug whitespace-pre-wrap [&_mark]:bg-accent/40 [&_mark]:text-fg [&_mark]:rounded [&_mark]:px-0.5`,dangerouslySetInnerHTML:{__html:i}})]})}function hc(e){let t=e?`claude-recall:show-bots:${e}`:`claude-recall:show-bots:__all__`,[n,r]=(0,W.useState)(()=>{try{return window.localStorage.getItem(t)===`true`}catch{return!1}});return(0,W.useEffect)(()=>{try{r(window.localStorage.getItem(t)===`true`)}catch{r(!1)}},[t]),[n,e=>{r(e);try{window.localStorage.setItem(t,e?`true`:`false`)}catch{}}]}function gc(e){let t=K();return J({mutationFn:async t=>Z.regenerateTitle(e,t),onSuccess:n=>{if(t.invalidateQueries({queryKey:[`sessions`]}),!n.written){Q({message:`No regen needed — ${n.skipped??`session is already in good shape`}.`,tone:`info`});return}Q({id:`regen-${e}`,message:`✨ ${n.title}`,tone:`success`,duration:6e4,action:{label:`undo`,onClick:()=>{Z.revertAutoTitle(e).then(()=>{Q({message:`Title reverted.`,tone:`info`}),t.invalidateQueries({queryKey:[`sessions`]})}).catch(e=>{Q({message:`Revert failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})})}}})},onError:e=>{let t=e instanceof Error?e.message:String(e);if(/no-context-available/.test(t)){Q({message:`No related sessions to derive a title from. Use ✨ Generate (transcript-only) instead.`,tone:`info`,duration:6e3});return}Q({message:`Regenerate failed: ${t}`,tone:`error`})}})}function _c({progress:e,onCancel:t}){let n=e.total===0?0:Math.round(e.current/e.total*100),r=e.status===`running`;return(0,G.jsxs)(`div`,{className:`px-4 py-2 border-b border-line bg-bg-elevated text-xs normal-case tracking-normal`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:r?`✨ Regenerating titles…`:`✨ Bulk regenerate finished`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[e.current,`/`,e.total]}),r&&(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-role-user hover:underline`,title:`cancel — sessions completed so far keep their new titles`,children:`cancel`})]})]}),(0,G.jsx)(`div`,{className:`h-1 bg-bg rounded`,children:(0,G.jsx)(`div`,{className:$(`h-1 rounded transition-all`,e.status===`cancelled`?`bg-role-user`:`bg-accent`),style:{width:`${n}%`}})}),(0,G.jsxs)(`div`,{className:`mt-1 text-[10px] text-fg-muted`,children:[e.generated,` regenerated · `,e.skipped,` skipped · `,e.failed,` failed`]})]})}var vc=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5 (fast — ~10 sec/session)`,secsPerSession:10},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6 (slower, deeper — ~30 sec/session)`,secsPerSession:30}];function yc(e){if(e<60)return`${e} sec`;let t=Math.round(e/60);return t<60?`${t} min`:`${(t/60).toFixed(1)} hr`}function bc({projectName:e,candidateIds:t,onClose:n,onConfirm:r}){let[i,a]=(0,W.useState)(vc[0].value),o=(vc.find(e=>e.value===i)??vc[0]).secsPerSession*t.length;return(0,G.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`bulk regenerate titles`,className:`fixed inset-0 z-40 flex items-center justify-center bg-black/40 px-4`,onClick:n,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-full max-w-md p-4`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`h2`,{className:`text-sm font-semibold text-fg mb-2`,children:[`✨ Regenerate `,t.length,` session`,t.length===1?``:`s`,` from graph context`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mb-3`,children:[`Each session`,`'`,`s neighborhood (parents, children, citations, similar sessions) is fed to Claude Haiku, which mints a new descriptive title. Manual aliases are never touched. Sessions with no neighborhood will surface as “no context available” and remain unchanged.`]}),(0,G.jsx)(`label`,{className:`block text-xs text-fg-muted mb-1`,htmlFor:`regen-model`,children:`Model`}),(0,G.jsx)(`select`,{id:`regen-model`,value:i,onChange:e=>a(e.target.value),className:`w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg mb-3`,children:vc.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mb-4`,children:[`Estimated time: `,yc(o),e&&(0,G.jsxs)(G.Fragment,{children:[` · scope: `,e]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs text-fg-muted hover:text-fg px-3 py-1.5`,children:`cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>r({model:i}),className:`text-xs bg-accent text-bg rounded px-3 py-1.5 hover:bg-accent/90`,disabled:t.length===0,children:`✨ Regenerate`})]})]})})}async function xc(e){if(!e.project){Q({message:`Pick a project — bulk regenerate is project-scoped.`,tone:`info`});return}let t=new AbortController;e.abortRef.current=t,e.setProgress({total:e.candidateIds.length,current:0,generated:0,skipped:0,failed:0,lastSessionId:null,status:`running`});let n;try{n=await fetch(`/api/sessions/regenerate-titles-batch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({project:e.project,quality_filter:[`low_signal`,`recursive_meta`,`programmatic`],model:e.model}),signal:t.signal})}catch(t){if(e.setProgress(null),t instanceof DOMException&&t.name===`AbortError`)return;Q({message:`Bulk regenerate failed to start: ${t instanceof Error?t.message:String(t)}`,tone:`error`});return}if(!n.ok){e.setProgress(null),Q({message:`Bulk regenerate rejected: ${await n.text().catch(()=>n.statusText)}`,tone:`error`});return}let r=n.body?.getReader();if(!r){e.setProgress(null),Q({message:`Bulk regenerate stream unavailable.`,tone:`error`});return}let i=new TextDecoder,a=``,o={total:e.candidateIds.length,current:0,generated:0,skipped:0,failed:0,lastSessionId:null,status:`running`},s=()=>{e.setProgress({...o})};s();try{for(;;){let{value:t,done:n}=await r.read();if(n)break;a+=i.decode(t,{stream:!0});let c;for(;(c=a.indexOf(`
|
|
81
81
|
|
|
82
82
|
`))!==-1;){let t=a.slice(0,c);a=a.slice(c+2);let n=`message`,r=``;for(let e of t.split(`
|
|
83
|
-
`))e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r=e.slice(5).trim());let i={};if(r)try{i=JSON.parse(r)}catch{}switch(n){case`start`:o.total=typeof i.total==`number`?i.total:o.total,s();break;case`progress`:o.current=typeof i.current==`number`?i.current:o.current+1,o.generated+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s(),e.invalidate();break;case`skipped`:o.current=typeof i.current==`number`?i.current:o.current+1,o.skipped+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s();break;case`error`:o.current=typeof i.current==`number`?i.current:o.current+1,o.failed+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s();break;case`done`:o.status=i.cancelled===!0?`cancelled`:`done`,s();break}}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||Q({message:`Bulk regenerate stream error: ${e instanceof Error?e.message:String(e)}`,tone:`error`}),o.status=t.signal.aborted?`cancelled`:o.status,s()}e.invalidate();let c=o.status===`cancelled`?4e3:2500;setTimeout(()=>e.setProgress(null),c),e.abortRef.current=null}function Sc({onIntersect:e}){let t=(0,W.useRef)(null),n=(0,W.useRef)(e);return(0,W.useEffect)(()=>{n.current=e},[e]),(0,W.useEffect)(()=>{let e=t.current;if(!e)return;let r=new IntersectionObserver(e=>{e[0]?.isIntersecting&&n.current()});return r.observe(e),()=>r.disconnect()},[]),(0,G.jsx)(`div`,{ref:t,className:`h-8`})}var Cc=_();function wc(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Tc(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Ec(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Dc=(e,t)=>Math.abs(e-t)<1.01,Oc=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},kc,Ac=()=>{if(kc!==void 0)return kc;if(typeof navigator>`u`)return kc=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kc=!0;let e=navigator.maxTouchPoints;return kc=navigator.platform===`MacIntel`&&e!==void 0&&e>0},jc=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Mc=e=>e,Nc=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Pc=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(jc(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(jc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Fc={passive:!0},Ic=typeof window>`u`?!0:`onscrollend`in window,Lc=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Ic,o=0,s=a?null:Oc(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Fc),a&&r.addEventListener(`scrollend`,u,Fc),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Rc=(e,t)=>Lc(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),zc=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Bc=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Vc=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Mc,rangeExtractor:Nc,onChange:()=>{},measureElement:zc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,a=t.count,o=this.getMeasurements(),s=e>0?o[0]?.key??n.getItemKey(0):null,c=e>0?o[e-1]?.key??n.getItemKey(e-1):null;if(a!==e||e>0&&a>0&&(t.getItemKey(0)!==s||t.getItemKey(a-1)!==c)){let s=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??o[0]:null;s&&(r=[s.key,this.getScrollOffset()-s.start]);let l=t.followOnAppend===!0?`auto`:t.followOnAppend||null;l&&a>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(a-1)!==c)&&(i=l)}}this.options=t,(r||i)&&(this.pendingScrollAnchor=[r?.[0]??null,r?.[1]??0,i])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Tc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Ac()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Fc),e.addEventListener(`touchend`,n,Fc),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r]=t;if(e!==null){let{count:t,getItemKey:r}=this.options,i=0;for(;i<t&&r(i)!==e;)i++;let a=i<t?this.getMeasurements()[i]:void 0;if(a){let e=a.start+n-this.getScrollOffset();Dc(e,0)||this.applyScrollAdjustment(e)}}r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Tc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=Tc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=wc(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Uc({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tc(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=Tc(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return Ec(t[Hc(0,t.length-1,r?e=>n[e*2]:e=>Ec(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(Ac()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Dc(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Hc=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Uc({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Hc(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var Wc=typeof document<`u`?W.useLayoutEffect:W.useEffect;function Gc({useFlushSync:e=!0,...t}){let n=W.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Cc.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=W.useState(()=>new Vc(r));return i.setOptions(r),Wc(()=>i._didMount(),[]),Wc(()=>i._willUpdate()),i}function Kc(e){return Gc({observeElementRect:Pc,observeElementOffset:Rc,scrollToFn:Bc,...e})}var qc=s(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},ee={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},N={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},te={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},P=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},F=P(`//`,`$`),I=P(`/\\*`,`\\*/`),L=P(`#`,`$`),R=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:P,C_BLOCK_COMMENT_MODE:I,C_LINE_COMMENT_MODE:F,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:L,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:te,QUOTE_STRING_MODE:N,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function z(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function B(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function V(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=z,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ne(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function H(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function re(e,t){e.relevance===void 0&&(e.relevance=1)}var ie=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},ae=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],oe=`keyword`;function se(e,t,n=oe){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,se(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,ce(n[0],n[1])]})}}function ce(e,t){return t?Number(t):+!U(e)}function U(e){return ae.includes(e.toLowerCase())}var le={},ue=e=>{console.error(e)},de=(e,...t)=>{console.log(`WARN: ${e}`,...t)},fe=(e,t)=>{le[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),le[`${e}/${t}`]=!0)},pe=Error();function me(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function he(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ue(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),pe;if(typeof e.beginScope!=`object`||e.beginScope===null)throw ue(`beginScope must be object`),pe;me(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function ge(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ue(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),pe;if(typeof e.endScope!=`object`||e.endScope===null)throw ue(`endScope must be object`),pe;me(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function _e(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function ve(e){_e(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),he(e),ge(e)}function ye(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[B,H,ve,ie].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[V,ne,re].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=se(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return xe(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function be(e){return e?e.endsWithParent||be(e.starts):!1}function xe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:be(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Se=`11.11.1`,Ce=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},we=i,Te=a,Ee=Symbol(`nomatch`),De=7,Oe=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=ee(n[1]);return t||(de(s.replace(`{}`,n[1])),de(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||ee(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(fe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),fe(`10.7.0`,`Please use highlight(code, options) instead.
|
|
83
|
+
`))e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r=e.slice(5).trim());let i={};if(r)try{i=JSON.parse(r)}catch{}switch(n){case`start`:o.total=typeof i.total==`number`?i.total:o.total,s();break;case`progress`:o.current=typeof i.current==`number`?i.current:o.current+1,o.generated+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s(),e.invalidate();break;case`skipped`:o.current=typeof i.current==`number`?i.current:o.current+1,o.skipped+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s();break;case`error`:o.current=typeof i.current==`number`?i.current:o.current+1,o.failed+=1,o.lastSessionId=typeof i.sessionId==`string`?i.sessionId:o.lastSessionId,s();break;case`done`:o.status=i.cancelled===!0?`cancelled`:`done`,s();break}}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||Q({message:`Bulk regenerate stream error: ${e instanceof Error?e.message:String(e)}`,tone:`error`}),o.status=t.signal.aborted?`cancelled`:o.status,s()}e.invalidate();let c=o.status===`cancelled`?4e3:2500;setTimeout(()=>e.setProgress(null),c),e.abortRef.current=null}function Sc({onIntersect:e}){let t=(0,W.useRef)(null),n=(0,W.useRef)(e);return(0,W.useEffect)(()=>{n.current=e},[e]),(0,W.useEffect)(()=>{let e=t.current;if(!e)return;let r=new IntersectionObserver(e=>{e[0]?.isIntersecting&&n.current()});return r.observe(e),()=>r.disconnect()},[]),(0,G.jsx)(`div`,{ref:t,className:`h-8`})}var Cc=_();function wc(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Tc(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Ec(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Dc=(e,t)=>Math.abs(e-t)<1.01,Oc=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},kc,Ac=()=>{if(kc!==void 0)return kc;if(typeof navigator>`u`)return kc=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kc=!0;let e=navigator.maxTouchPoints;return kc=navigator.platform===`MacIntel`&&e!==void 0&&e>0},jc=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Mc=e=>e,Nc=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Pc=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(jc(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(jc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Fc={passive:!0},Ic=typeof window>`u`?!0:`onscrollend`in window,Lc=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Ic,o=0,s=a?null:Oc(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Fc),a&&r.addEventListener(`scrollend`,u,Fc),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Rc=(e,t)=>Lc(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),zc=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Bc=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Vc=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Mc,rangeExtractor:Nc,onChange:()=>{},measureElement:zc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Tc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Ac()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Fc),e.addEventListener(`touchend`,n,Fc),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Ac()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Tc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=Tc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=wc(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Uc({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tc(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=Tc(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return Ec(t[Hc(0,t.length-1,r?e=>n[e*2]:e=>Ec(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(Ac()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&Dc(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Hc=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Uc({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Hc(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var Wc=typeof document<`u`?W.useLayoutEffect:W.useEffect;function Gc({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=W.useReducer(e=>e+1,0)[1],a=W.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled)return;let n=e.getTotalSize();if(t.container&&n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,Cc.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=W.useState(()=>{let e=new Vc(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),Wc(()=>c._didMount(),[]),Wc(()=>c._willUpdate()),Wc(()=>{o(c)}),c}function Kc(e){return Gc({observeElementRect:Pc,observeElementOffset:Rc,scrollToFn:Bc,...e})}var qc=s(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},ee={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},N={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},te={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},P=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},F=P(`//`,`$`),I=P(`/\\*`,`\\*/`),L=P(`#`,`$`),R=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:P,C_BLOCK_COMMENT_MODE:I,C_LINE_COMMENT_MODE:F,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:L,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:te,QUOTE_STRING_MODE:N,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function z(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function B(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function V(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=z,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ne(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function H(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function re(e,t){e.relevance===void 0&&(e.relevance=1)}var ie=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},ae=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],oe=`keyword`;function se(e,t,n=oe){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,se(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,ce(n[0],n[1])]})}}function ce(e,t){return t?Number(t):+!U(e)}function U(e){return ae.includes(e.toLowerCase())}var le={},ue=e=>{console.error(e)},de=(e,...t)=>{console.log(`WARN: ${e}`,...t)},fe=(e,t)=>{le[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),le[`${e}/${t}`]=!0)},pe=Error();function me(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function he(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ue(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),pe;if(typeof e.beginScope!=`object`||e.beginScope===null)throw ue(`beginScope must be object`),pe;me(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function ge(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ue(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),pe;if(typeof e.endScope!=`object`||e.endScope===null)throw ue(`endScope must be object`),pe;me(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function _e(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function ve(e){_e(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),he(e),ge(e)}function ye(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[B,H,ve,ie].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[V,ne,re].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=se(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return xe(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function be(e){return e?e.endsWithParent||be(e.starts):!1}function xe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:be(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var Se=`11.11.1`,Ce=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},we=i,Te=a,Ee=Symbol(`nomatch`),De=7,Oe=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=ee(n[1]);return t||(de(s.replace(`{}`,n[1])),de(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||ee(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(fe(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),fe(`10.7.0`,`Please use highlight(code, options) instead.
|
|
84
84
|
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};L(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,L(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){M.addText(N);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(N),n=``;for(;t;){n+=N.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(M.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=De&&(te+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(N)}n+=N.substring(e),M.addText(n)}function f(){if(N===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){M.addText(N);return}e=v(A.subLanguage,N,!0,j[A.subLanguage]),j[A.subLanguage]=e._top}else e=S(N,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(te+=e.relevance),M.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),N=``}function m(e,t){e!==``&&(M.startScope(t),M.addText(e),M.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(N=i,d(),N=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&M.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(N,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),N=``):e.beginScope._multi&&(h(e.beginScope,t),N=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(N+=e[0],1):(I=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?N+=t:(n.excludeBegin&&(N+=t),p(),!n.returnBegin&&!n.excludeBegin&&(N=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return Ee;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?N+=t:(a.returnEnd||a.excludeEnd||(N+=t),p(),a.excludeEnd&&(N=t));do A.scope&&M.closeNode(),!A.skip&&!A.subLanguage&&(te+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>M.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(N+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(N+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==Ee)return e}if(r.type===`illegal`&&a===``)return N+=`
|
|
85
85
|
`,1;if(F>1e5&&F>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return N+=a,a.length}let D=ee(e);if(!D)throw ue(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=ye(D),k=``,A=a||O,j={},M=new l.__emitter(l);w();let N=``,te=0,P=0,F=0,I=!1;try{if(D.__emitTokens)D.__emitTokens(n,M);else{for(A.matcher.considerAll();;){F++,I?I=!1:A.matcher.considerAll(),A.matcher.lastIndex=P;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(P,e.index),e);P=e.index+t}E(n.substring(P))}return M.finalize(),k=M.toHTML(),{language:e,value:k,relevance:te,illegal:!1,_emitter:M,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:we(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:P,context:n.slice(P-100,P+100),mode:t.mode,resultSoFar:k},_emitter:M};if(o)return{language:e,value:we(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:A};throw t}}function b(e){let t={value:we(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(ee).filter(te).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(ee(e.language).supersetOf===t.language)return 1;if(ee(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(L(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new Ce(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),L(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Te(l,e)}let E=()=>{k(),fe(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),fe(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(ue(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)ue(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&N(i.aliases,{languageName:n})}function j(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function M(){return Object.keys(t)}function ee(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function N(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function te(e){let t=ee(e);return t&&!t.disableAutodetect}function P(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function F(e){P(e),a.push(e)}function I(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function L(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function z(e){return fe(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),fe(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:z,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:j,listLanguages:M,getLanguage:ee,registerAliases:N,autoDetection:te,inherit:Te,addPlugin:F,removePlugin:I}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=Se,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in R)typeof R[e]==`object`&&n(R[e]);return Object.assign(e,R),e},ke=Oe({});ke.newInstance=()=>Oe({}),t.exports=ke,ke.HighlightJS=ke,ke.default=ke})),Jc=s(((e,t)=>{function n(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}t.exports=n})),Yc=s(((e,t)=>{function n(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}t.exports=n})),Xc=s(((e,t)=>{function n(e){let t=e.regex,n=e.COMMENT(`//`,`$`,{contains:[{begin:/\\\n/}]}),r=`[a-zA-Z_]\\w*::`,i=`(decltype\\(auto\\)|`+t.optional(r)+`[a-zA-Z_]\\w*`+t.optional(`<[^<>]+>`)+`)`,a={className:`type`,variants:[{begin:`\\b[a-z\\d_]*_t\\b`},{match:/\batomic_[a-z]{3,6}\b/}]},o={className:`string`,variants:[{begin:`(u8?|U|L)?"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]},{begin:`(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)`,end:`'`,illegal:`.`},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},s={className:`number`,variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},c={className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(o,{className:`string`}),{className:`string`,begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},l={className:`title`,begin:t.optional(r)+e.IDENT_RE,relevance:0},u=t.optional(r)+e.IDENT_RE+`\\s*\\(`,d={keyword:`asm.auto.break.case.continue.default.do.else.enum.extern.for.fortran.goto.if.inline.register.restrict.return.sizeof.typeof.typeof_unqual.struct.switch.typedef.union.volatile.while._Alignas._Alignof._Atomic._Generic._Noreturn._Static_assert._Thread_local.alignas.alignof.noreturn.static_assert.thread_local._Pragma`.split(`.`),type:`float.double.signed.unsigned.int.short.long.char.void._Bool._BitInt._Complex._Imaginary._Decimal32._Decimal64._Decimal96._Decimal128._Decimal64x._Decimal128x._Float16._Float32._Float64._Float128._Float32x._Float64x._Float128x.const.static.constexpr.complex.bool.imaginary`.split(`.`),literal:`true false NULL`,built_in:`std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr`},f=[c,a,n,e.C_BLOCK_COMMENT_MODE,s,o],p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:`new throw return else`,end:/;/}],keywords:d,contains:f.concat([{begin:/\(/,end:/\)/,keywords:d,contains:f.concat([`self`]),relevance:0}]),relevance:0},m={begin:`(`+i+`[\\*&\\s]+)+`+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:d,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:`decltype\\(auto\\)`,keywords:d,relevance:0},{begin:u,returnBegin:!0,contains:[e.inherit(l,{className:`title.function`})],relevance:0},{relevance:0,match:/,/},{className:`params`,begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,o,s,a,{begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[`self`,n,e.C_BLOCK_COMMENT_MODE,o,s,a]}]},a,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:`C`,aliases:[`h`],keywords:d,disableAutodetect:!0,illegal:`</`,contains:[].concat(p,m,f,[c,{begin:e.IDENT_RE+`::`,keywords:d},{className:`class`,beginKeywords:`enum class struct union`,end:/[{;:<>=]/,contains:[{beginKeywords:`final class struct`},e.TITLE_MODE]}]),exports:{preprocessor:c,strings:o,keywords:d}}}t.exports=n})),Zc=s(((e,t)=>{function n(e){let t=e.regex,n=e.COMMENT(`//`,`$`,{contains:[{begin:/\\\n/}]}),r=`[a-zA-Z_]\\w*::`,i=`(?!struct)(decltype\\(auto\\)|`+t.optional(r)+`[a-zA-Z_]\\w*`+t.optional(`<[^<>]+>`)+`)`,a={className:`type`,begin:`\\b[a-z\\d_]*_t\\b`},o={className:`string`,variants:[{begin:`(u8?|U|L)?"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]},{begin:`(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)`,end:`'`,illegal:`.`},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},s={className:`number`,variants:[{begin:`[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)`},{begin:`[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)`}],relevance:0},c={className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(o,{className:`string`}),{className:`string`,begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},l={className:`title`,begin:t.optional(r)+e.IDENT_RE,relevance:0},u=t.optional(r)+e.IDENT_RE+`\\s*\\(`,d=`alignas.alignof.and.and_eq.asm.atomic_cancel.atomic_commit.atomic_noexcept.auto.bitand.bitor.break.case.catch.class.co_await.co_return.co_yield.compl.concept.const_cast|10.consteval.constexpr.constinit.continue.decltype.default.delete.do.dynamic_cast|10.else.enum.explicit.export.extern.false.final.for.friend.goto.if.import.inline.module.mutable.namespace.new.noexcept.not.not_eq.nullptr.operator.or.or_eq.override.private.protected.public.reflexpr.register.reinterpret_cast|10.requires.return.sizeof.static_assert.static_cast|10.struct.switch.synchronized.template.this.thread_local.throw.transaction_safe.transaction_safe_dynamic.true.try.typedef.typeid.typename.union.using.virtual.volatile.while.xor.xor_eq`.split(`.`),f=[`bool`,`char`,`char16_t`,`char32_t`,`char8_t`,`double`,`float`,`int`,`long`,`short`,`void`,`wchar_t`,`unsigned`,`signed`,`const`,`static`],p=`any.auto_ptr.barrier.binary_semaphore.bitset.complex.condition_variable.condition_variable_any.counting_semaphore.deque.false_type.flat_map.flat_set.future.imaginary.initializer_list.istringstream.jthread.latch.lock_guard.multimap.multiset.mutex.optional.ostringstream.packaged_task.pair.promise.priority_queue.queue.recursive_mutex.recursive_timed_mutex.scoped_lock.set.shared_future.shared_lock.shared_mutex.shared_timed_mutex.shared_ptr.stack.string_view.stringstream.timed_mutex.thread.true_type.tuple.unique_lock.unique_ptr.unordered_map.unordered_multimap.unordered_multiset.unordered_set.variant.vector.weak_ptr.wstring.wstring_view`.split(`.`),m=`abort.abs.acos.apply.as_const.asin.atan.atan2.calloc.ceil.cerr.cin.clog.cos.cosh.cout.declval.endl.exchange.exit.exp.fabs.floor.fmod.forward.fprintf.fputs.free.frexp.fscanf.future.invoke.isalnum.isalpha.iscntrl.isdigit.isgraph.islower.isprint.ispunct.isspace.isupper.isxdigit.labs.launder.ldexp.log.log10.make_pair.make_shared.make_shared_for_overwrite.make_tuple.make_unique.malloc.memchr.memcmp.memcpy.memset.modf.move.pow.printf.putchar.puts.realloc.scanf.sin.sinh.snprintf.sprintf.sqrt.sscanf.std.stderr.stdin.stdout.strcat.strchr.strcmp.strcpy.strcspn.strlen.strncat.strncmp.strncpy.strpbrk.strrchr.strspn.strstr.swap.tan.tanh.terminate.to_underlying.tolower.toupper.vfprintf.visit.vprintf.vsprintf`.split(`.`),h={type:f,keyword:d,literal:[`NULL`,`false`,`nullopt`,`nullptr`,`true`],built_in:[`_Pragma`],_type_hints:p},g={className:`function.dispatch`,relevance:0,keywords:{_hint:m},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},_=[g,c,a,n,e.C_BLOCK_COMMENT_MODE,s,o],v={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:`new throw return else`,end:/;/}],keywords:h,contains:_.concat([{begin:/\(/,end:/\)/,keywords:h,contains:_.concat([`self`]),relevance:0}]),relevance:0},y={className:`function`,begin:`(`+i+`[\\*&\\s]+)+`+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:`decltype\\(auto\\)`,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[l],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[o,s]},{relevance:0,match:/,/},{className:`params`,begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,o,s,a,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[`self`,n,e.C_BLOCK_COMMENT_MODE,o,s,a]}]},a,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:`C++`,aliases:[`cc`,`c++`,`h++`,`hpp`,`hh`,`hxx`,`cxx`],keywords:h,illegal:`</`,classNameAliases:{"function.dispatch":`built_in`},contains:[].concat(v,y,g,_,[c,{begin:`\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)`,end:`>`,keywords:h,contains:[`self`,a]},{begin:e.IDENT_RE+`::`,keywords:h},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:`keyword`,3:`title.class`}}])}}t.exports=n})),Qc=s(((e,t)=>{function n(e){let t=[`bool`,`byte`,`char`,`decimal`,`delegate`,`double`,`dynamic`,`enum`,`float`,`int`,`long`,`nint`,`nuint`,`object`,`sbyte`,`short`,`string`,`ulong`,`uint`,`ushort`],n=[`public`,`private`,`protected`,`static`,`internal`,`protected`,`abstract`,`async`,`extern`,`override`,`unsafe`,`virtual`,`new`,`sealed`,`partial`],r={keyword:`abstract.as.base.break.case.catch.class.const.continue.do.else.event.explicit.extern.finally.fixed.for.foreach.goto.if.implicit.in.interface.internal.is.lock.namespace.new.operator.out.override.params.private.protected.public.readonly.record.ref.return.scoped.sealed.sizeof.stackalloc.static.struct.switch.this.throw.try.typeof.unchecked.unsafe.using.virtual.void.volatile.while`.split(`.`).concat(`add.alias.and.ascending.args.async.await.by.descending.dynamic.equals.file.from.get.global.group.init.into.join.let.nameof.not.notnull.on.or.orderby.partial.record.remove.required.scoped.select.set.unmanaged.value|0.var.when.where.with.yield`.split(`.`)),built_in:t,literal:[`default`,`false`,`null`,`true`]},i=e.inherit(e.TITLE_MODE,{begin:`[a-zA-Z](\\.?\\w)*`}),a={className:`number`,variants:[{begin:`\\b(0b[01']+)`},{begin:`(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)`},{begin:`(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)`}],relevance:0},o={className:`string`,begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},s={className:`string`,begin:`@"`,end:`"`,contains:[{begin:`""`}]},c=e.inherit(s,{illegal:/\n/}),l={className:`subst`,begin:/\{/,end:/\}/,keywords:r},u=e.inherit(l,{illegal:/\n/}),d={className:`string`,begin:/\$"/,end:`"`,illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,u]},f={className:`string`,begin:/\$@"/,end:`"`,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:`""`},l]},p=e.inherit(f,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:`""`},u]});l.contains=[f,d,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],u.contains=[p,d,c,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let m={variants:[o,f,d,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h={begin:`<`,end:`>`,contains:[{beginKeywords:`in out`},i]},g=e.IDENT_RE+`(<`+e.IDENT_RE+`(\\s*,\\s*`+e.IDENT_RE+`)*>)?(\\[\\])?`,_={begin:`@`+e.IDENT_RE,relevance:0};return{name:`C#`,aliases:[`cs`,`c#`],keywords:r,illegal:/::/,contains:[e.COMMENT(`///`,`$`,{returnBegin:!0,contains:[{className:`doctag`,variants:[{begin:`///`,relevance:0},{begin:`<!--|-->`},{begin:`</?`,end:`>`}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:`meta`,begin:`#`,end:`$`,keywords:{keyword:`if else elif endif define undef warning error line region endregion pragma checksum`}},m,a,{beginKeywords:`class interface`,relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:`where class`},i,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`namespace`,relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[i,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`record`,relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[i,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:`meta`,begin:`^\\s*\\[(?=[\\w])`,excludeBegin:!0,end:`\\]`,excludeEnd:!0,contains:[{className:`string`,begin:/"/,end:/"/}]},{beginKeywords:`new return throw await else`,relevance:0},{className:`function`,begin:`(`+g+`\\s+)+`+e.IDENT_RE+`\\s*(<[^=]+>\\s*)?\\(`,returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:r,contains:[{beginKeywords:n.join(` `),relevance:0},{begin:e.IDENT_RE+`\\s*(<[^=]+>\\s*)?\\(`,returnBegin:!0,contains:[e.TITLE_MODE,h],relevance:0},{match:/\(\)/},{className:`params`,begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:r,relevance:0,contains:[m,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},_]}}t.exports=n})),$c=s(((e,t)=>{var n=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),r=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),i=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),a=[...r,...i],o=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),s=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),c=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),l=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function u(e){let t=e.regex,r=n(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},u=/@-?\w[\w]*(-\w+)*/,d=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[r.BLOCK_COMMENT,i,r.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},r.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+s.join(`|`)+`)`},{begin:`:(:)?(`+c.join(`|`)+`)`}]},r.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+l.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[r.BLOCK_COMMENT,r.HEXCOLOR,r.IMPORTANT,r.CSS_NUMBER_MODE,...d,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...d,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},r.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:u},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:o.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...d,r.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+a.join(`|`)+`)\\b`}]}}t.exports=u})),el=s(((e,t)=>{function n(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}t.exports=n})),tl=s(((e,t)=>{function n(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}t.exports=n})),nl=s(((e,t)=>{function n(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),a={"variable.constant":[`__FILE__`,`__LINE__`,`__ENCODING__`],"variable.language":[`self`,`super`],keyword:`alias.and.begin.BEGIN.break.case.class.defined.do.else.elsif.end.END.ensure.for.if.in.module.next.not.or.redo.require.rescue.retry.return.then.undef.unless.until.when.while.yield.include.extend.prepend.public.private.protected.raise.throw`.split(`.`),built_in:[`proc`,`lambda`,`attr_accessor`,`attr_reader`,`attr_writer`,`define_method`,`private_constant`,`module_function`],literal:[`true`,`false`,`nil`]},o={className:`doctag`,begin:`@[A-Za-z]+`},s={begin:`#<`,end:`>`},c=[e.COMMENT(`#`,`$`,{contains:[o]}),e.COMMENT(`^=begin`,`^=end`,{contains:[o],relevance:10}),e.COMMENT(`^__END__`,e.MATCH_NOTHING_RE)],l={className:`subst`,begin:/#\{/,end:/\}/,keywords:a},u={className:`string`,contains:[e.BACKSLASH_ESCAPE,l],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,l]})]}]},d=`[0-9](_?[0-9])*`,f={className:`number`,relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${d}))?([eE][+-]?(${d})|r)?i?\\b`},{begin:`\\b0[dD][0-9](_?[0-9])*r?i?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*r?i?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*r?i?\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b`},{begin:`\\b0(_?[0-7])+r?i?\\b`}]},p={variants:[{match:/\(\)/},{className:`params`,begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:a}]},m=[u,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:`title.class`,4:`title.class.inherited`},keywords:a},{match:[/(include|extend)\s+/,i],scope:{2:`title.class`},keywords:a},{relevance:0,match:[i,/\.new[. (]/],scope:{1:`title.class`}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`},{relevance:0,match:r,scope:`title.class`},{match:[/def/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[p]},{begin:e.IDENT_RE+`::`},{className:`symbol`,begin:e.UNDERSCORE_IDENT_RE+`(!|\\?)?:`,relevance:0},{className:`symbol`,begin:`:(?!\\s)`,contains:[u,{begin:n}],relevance:0},f,{className:`variable`,begin:`(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])`},{className:`params`,begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:a},{begin:`(`+e.RE_STARTERS_RE+`|unless)\\s*`,keywords:`unless`,contains:[{className:`regexp`,contains:[e.BACKSLASH_ESCAPE,l],illegal:/\n/,variants:[{begin:`/`,end:`/[a-z]*`},{begin:/%r\{/,end:/\}[a-z]*/},{begin:`%r\\(`,end:`\\)[a-z]*`},{begin:`%r!`,end:`![a-z]*`},{begin:`%r\\[`,end:`\\][a-z]*`}]}].concat(s,c),relevance:0}].concat(s,c);l.contains=m,p.contains=m;let h=[{begin:/^\s*=>/,starts:{end:`$`,contains:m}},{className:`meta.prompt`,begin:`^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])`,starts:{end:`$`,keywords:a,contains:m}}];return c.unshift(s),{name:`Ruby`,aliases:[`rb`,`gemspec`,`podspec`,`thor`,`irb`],keywords:a,illegal:/\/\*/,contains:[e.SHEBANG({binary:`ruby`})].concat(h,c,m)}}t.exports=n})),rl=s(((e,t)=>{function n(e){let t={keyword:[`break`,`case`,`chan`,`const`,`continue`,`default`,`defer`,`else`,`fallthrough`,`for`,`func`,`go`,`goto`,`if`,`import`,`interface`,`map`,`package`,`range`,`return`,`select`,`struct`,`switch`,`type`,`var`],type:[`bool`,`byte`,`complex64`,`complex128`,`error`,`float32`,`float64`,`int8`,`int16`,`int32`,`int64`,`string`,`uint8`,`uint16`,`uint32`,`uint64`,`int`,`uint`,`uintptr`,`rune`],literal:[`true`,`false`,`iota`,`nil`],built_in:[`append`,`cap`,`close`,`complex`,`copy`,`imag`,`len`,`make`,`new`,`panic`,`print`,`println`,`real`,`recover`,`delete`]};return{name:`Go`,aliases:[`golang`],keywords:t,illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:`string`,variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:`number`,variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:`function`,beginKeywords:`func`,end:`\\s*(\\{|$)`,excludeEnd:!0,contains:[e.TITLE_MODE,{className:`params`,begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}t.exports=n})),il=s(((e,t)=>{function n(e){let t=e.regex;return{name:`GraphQL`,aliases:[`gql`],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:[`query`,`mutation`,`subscription`,`type`,`input`,`schema`,`directive`,`interface`,`union`,`scalar`,`fragment`,`enum`,`on`],literal:[`true`,`false`,`null`]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:`punctuation`,match:/[.]{3}/,relevance:0},{scope:`punctuation`,begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:`variable`,begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:`meta`,match:/@\w+/,excludeEnd:!0},{scope:`symbol`,begin:t.concat(/[_A-Za-z][_0-9A-Za-z]*/,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}t.exports=n})),al=s(((e,t)=>{function n(e){let t=e.regex,n={className:`number`,relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:`variable`,variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:`literal`,begin:/\bon|off|true|false|yes|no\b/},o={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:`'''`,end:`'''`,relevance:10},{begin:`"""`,end:`"""`,relevance:10},{begin:`"`,end:`"`},{begin:`'`,end:`'`}]},s={begin:/\[/,end:/\]/,contains:[r,a,i,o,n,`self`],relevance:0},c=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:`TOML, also INI`,aliases:[`toml`],case_insensitive:!0,illegal:/\S/,contains:[r,{className:`section`,begin:/\[+/,end:/\]+/},{begin:t.concat(c,`(\\s*\\.\\s*`,c,`)*`,t.lookahead(/\s*=\s*[^#\s]/)),className:`attr`,starts:{end:/$/,contains:[r,s,a,i,o,n]}}]}}t.exports=n})),ol=s(((e,t)=>{var n=`[0-9](_*[0-9])*`,r=`\\.(${n})`,i=`[0-9a-fA-F](_*[0-9a-fA-F])*`,a={className:`number`,variants:[{begin:`(\\b(${n})((${r})|\\.)?|(${r}))[eE][+-]?(${n})[fFdD]?\\b`},{begin:`\\b(${n})((${r})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${r})[fFdD]?\\b`},{begin:`\\b(${n})[fFdD]\\b`},{begin:`\\b0[xX]((${i})\\.?|(${i})?\\.(${i}))[pP][+-]?(${n})[fFdD]?\\b`},{begin:`\\b(0|[1-9](_*[0-9])*)[lL]?\\b`},{begin:`\\b0[xX](${i})[lL]?\\b`},{begin:`\\b0(_*[0-7])*[lL]?\\b`},{begin:`\\b0[bB][01](_*[01])*[lL]?\\b`}],relevance:0};function o(e,t,n){return n===-1?``:e.replace(t,r=>o(e,t,n-1))}function s(e){let t=e.regex,n=`[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*`,r=n+o(`(?:<[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*~~~(?:\\s*,\\s*[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*~~~)*>)?`,/~~~/g,2),i={keyword:`synchronized.abstract.private.var.static.if.const .for.while.strictfp.finally.protected.import.native.final.void.enum.else.break.transient.catch.instanceof.volatile.case.assert.package.default.public.try.switch.continue.throws.protected.public.private.module.requires.exports.do.sealed.yield.permits.goto.when`.split(`.`),literal:[`false`,`true`,`null`],type:[`char`,`boolean`,`long`,`float`,`int`,`byte`,`short`,`double`],built_in:[`super`,`this`]},s={className:`meta`,begin:`@[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*`,contains:[{begin:/\(/,end:/\)/,contains:[`self`]}]},c={className:`params`,begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:`Java`,aliases:[`jsp`],keywords:i,illegal:/<\/|#/,contains:[e.COMMENT(`/\\*\\*`,`\\*/`,{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:`doctag`,begin:`@[A-Za-z]+`}]}),{begin:/import java\.[a-z]+\./,keywords:`import`,relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:`string`,contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:`keyword`,3:`title.class`}},{match:/non-sealed/,scope:`keyword`},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:`type`,3:`variable`,5:`operator`}},{begin:[/record/,/\s+/,n],className:{1:`keyword`,3:`title.class`},contains:[c,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:`new throw return else`,relevance:0},{begin:[`(?:`+r+`\\s+)`,e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:`title.function`},keywords:i,contains:[{className:`params`,begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},a,s]}}t.exports=s})),sl=s(((e,t)=>{var n=`[A-Za-z$_][0-9A-Za-z$_]*`,r=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),i=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],a=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),o=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],s=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],c=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],l=[].concat(s,a,o);function u(e){let t=e.regex,u=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},d=n,f={begin:`<>`,end:`</>`},p=/<[A-Za-z0-9\\._:-]+\s*\/>/,m={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let n=e[0].length+e.index,r=e.input[n];if(r===`<`||r===`,`){t.ignoreMatch();return}r===`>`&&(u(e,{after:n})||t.ignoreMatch());let i,a=e.input.substring(n);if(i=a.match(/^\s*=/)){t.ignoreMatch();return}if((i=a.match(/^\s+extends\s+/))&&i.index===0){t.ignoreMatch();return}}},h={$pattern:n,keyword:r,literal:i,built_in:l,"variable.language":c},g=`[0-9](_?[0-9])*`,_=`\\.(${g})`,v=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,y={className:`number`,variants:[{begin:`(\\b(${v})((${_})|\\.)?|(${_}))[eE][+-]?(${g})\\b`},{begin:`\\b(${v})\\b((${_})\\b|\\.)?|(${_})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},b={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:h,contains:[]},x={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:`xml`}},S={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:`css`}},C={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:`graphql`}},w={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,b]},T={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},E=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,S,C,w,{match:/\$\d+/},y];b.contains=E.concat({begin:/\{/,end:/\}/,keywords:h,contains:[`self`].concat(E)});let D=[].concat(T,b.contains),O=D.concat([{begin:/(\s*)\(/,end:/\)/,keywords:h,contains:[`self`].concat(D)}]),k={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:O},A={variants:[{match:[/class/,/\s+/,d,/\s+/,/extends/,/\s+/,t.concat(d,`(`,t.concat(/\./,d),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,d],scope:{1:`keyword`,3:`title.class`}}]},j={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...a,...o]}},M={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},ee={variants:[{match:[/function/,/\s+/,d,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[k],illegal:/%/},N={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function te(e){return t.concat(`(?!`,e.join(`|`),`)`)}let P={match:t.concat(/\b/,te([...s,`super`,`import`].map(e=>`${e}\\s*\\(`)),d,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},F={begin:t.concat(/\./,t.lookahead(t.concat(d,/(?![0-9A-Za-z$_(])/))),end:d,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},I={match:[/get|set/,/\s+/,d,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},k]},L=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,R={match:[/const|var|let/,/\s+/,d,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[k]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:h,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:j},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,S,C,w,T,{match:/\$\d+/},y,j,{scope:`attr`,match:d+t.lookahead(`:`),relevance:0},R,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[T,e.REGEXP_MODE,{className:`function`,begin:L,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:h,contains:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:f.begin,end:f.end},{match:p},{begin:m.begin,"on:begin":m.isTrulyOpeningTag,end:m.end}],subLanguage:`xml`,contains:[{begin:m.begin,end:m.end,skip:!0,contains:[`self`]}]}]},ee,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[k,e.inherit(e.TITLE_MODE,{begin:d,className:`title.function`})]},{match:/\.\.\./,relevance:0},F,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[k]},P,N,A,I,{match:/\$[(.]/}]}}t.exports=u})),cl=s(((e,t)=>{function n(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}t.exports=n})),ll=s(((e,t)=>{var n=`[0-9](_*[0-9])*`,r=`\\.(${n})`,i=`[0-9a-fA-F](_*[0-9a-fA-F])*`,a={className:`number`,variants:[{begin:`(\\b(${n})((${r})|\\.)?|(${r}))[eE][+-]?(${n})[fFdD]?\\b`},{begin:`\\b(${n})((${r})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${r})[fFdD]?\\b`},{begin:`\\b(${n})[fFdD]\\b`},{begin:`\\b0[xX]((${i})\\.?|(${i})?\\.(${i}))[pP][+-]?(${n})[fFdD]?\\b`},{begin:`\\b(0|[1-9](_*[0-9])*)[lL]?\\b`},{begin:`\\b0[xX](${i})[lL]?\\b`},{begin:`\\b0(_*[0-7])*[lL]?\\b`},{begin:`\\b0[bB][01](_*[01])*[lL]?\\b`}],relevance:0};function o(e){let t={keyword:`abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual`,built_in:`Byte Short Char Int Long Boolean Float Double Void Unit Nothing`,literal:`true false null`},n={className:`keyword`,begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:`symbol`,begin:/@\w+/}]}},r={className:`symbol`,begin:e.UNDERSCORE_IDENT_RE+`@`},i={className:`subst`,begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},o={className:`variable`,begin:`\\$`+e.UNDERSCORE_IDENT_RE},s={className:`string`,variants:[{begin:`"""`,end:`"""(?=[^"])`,contains:[o,i]},{begin:`'`,end:`'`,illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:`"`,end:`"`,illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,o,i]}]};i.contains.push(s);let c={className:`meta`,begin:`@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*`+e.UNDERSCORE_IDENT_RE+`)?`},l={className:`meta`,begin:`@`+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(s,{className:`string`}),`self`]}]},u=a,d=e.COMMENT(`/\\*`,`\\*/`,{contains:[e.C_BLOCK_COMMENT_MODE]}),f={variants:[{className:`type`,begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},p=f;return p.variants[1].contains=[f],f.variants[1].contains=[p],{name:`Kotlin`,aliases:[`kt`,`kts`],keywords:t,contains:[e.COMMENT(`/\\*\\*`,`\\*/`,{relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`}]}),e.C_LINE_COMMENT_MODE,d,n,r,c,l,{className:`function`,beginKeywords:`fun`,end:`[(]|$`,returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+`\\s*\\(`,returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:`type`,begin:/</,end:/>/,keywords:`reified`,relevance:0},{className:`params`,begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[f,e.C_LINE_COMMENT_MODE,d],relevance:0},e.C_LINE_COMMENT_MODE,d,c,l,s,e.C_NUMBER_MODE]},d]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:`title.class`},keywords:`class interface trait`,end:/[:\{(]|$/,excludeEnd:!0,illegal:`extends implements`,contains:[{beginKeywords:`public protected internal private constructor`},e.UNDERSCORE_TITLE_MODE,{className:`type`,begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,l]},s,{className:`meta`,begin:`^#!/usr/bin/env`,end:`$`,illegal:`
|
|
86
86
|
`},u]}}t.exports=o})),ul=s(((e,t)=>{var n=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),r=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),i=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),a=[...r,...i],o=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),s=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),c=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),l=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse(),u=s.concat(c).sort().reverse();function d(e){let t=n(e),r=u,i=`([\\w-]+|@\\{[\\w-]+\\})`,d=[],f=[],p=function(e){return{className:`string`,begin:`~?`+e+`.*?`+e}},m=function(e,t,n){return{className:e,begin:t,relevance:n}},h={$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:o.join(` `)},g={begin:`\\(`,end:`\\)`,contains:f,keywords:h,relevance:0};f.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,p(`'`),p(`"`),t.CSS_NUMBER_MODE,{begin:`(url|data-uri)\\(`,starts:{className:`string`,end:`[\\)\\n]`,excludeEnd:!0}},t.HEXCOLOR,g,m(`variable`,`@@?[\\w-]+`,10),m(`variable`,`@\\{[\\w-]+\\}`),m(`built_in`,"~?`[^`]*?`"),{className:`attribute`,begin:`[\\w-]+\\s*:`,end:`:`,returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:`and not`},t.FUNCTION_DISPATCH);let _=f.concat({begin:/\{/,end:/\}/,contains:d}),v={beginKeywords:`when`,endsWithParent:!0,contains:[{beginKeywords:`and not`}].concat(f)},y={begin:`([\\w-]+|@\\{[\\w-]+\\})\\s*:`,returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+l.join(`|`)+`)\\b`,end:/(?=:)/,starts:{endsWithParent:!0,illegal:`[<=$]`,relevance:0,contains:f}}]},b={className:`keyword`,begin:`@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b`,starts:{end:`[;{}]`,keywords:h,returnEnd:!0,contains:f,relevance:0}},x={className:`variable`,variants:[{begin:`@[\\w-]+\\s*:`,relevance:15},{begin:`@[\\w-]+`}],starts:{end:`[;}]`,returnEnd:!0,contains:_}},S={variants:[{begin:`[\\.#:&\\[>]`,end:`[;{}]`},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,v,m(`keyword`,`all\\b`),m(`variable`,`@\\{[\\w-]+\\}`),{begin:`\\b(`+a.join(`|`)+`)\\b`,className:`selector-tag`},t.CSS_NUMBER_MODE,m(`selector-tag`,i,0),m(`selector-id`,`#([\\w-]+|@\\{[\\w-]+\\})`),m(`selector-class`,`\\.([\\w-]+|@\\{[\\w-]+\\})`,0),m(`selector-tag`,`&`,0),t.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,begin:`:(`+s.join(`|`)+`)`},{className:`selector-pseudo`,begin:`:(:)?(`+c.join(`|`)+`)`},{begin:/\(/,end:/\)/,relevance:0,contains:_},{begin:`!important`},t.FUNCTION_DISPATCH]},C={begin:`[\\w-]+:(:)?(${r.join(`|`)})`,returnBegin:!0,contains:[S]};return d.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,x,C,y,S,v,t.FUNCTION_DISPATCH),{name:`Less`,case_insensitive:!0,illegal:`[=>'/<($"]`,contains:d}}t.exports=d})),dl=s(((e,t)=>{function n(e){let t=`\\[=*\\[`,n=`\\]=*\\]`,r={begin:t,end:n,contains:[`self`]},i=[e.COMMENT(`--(?!\\[=*\\[)`,`$`),e.COMMENT(`--\\[=*\\[`,n,{contains:[r],relevance:10})];return{name:`Lua`,aliases:[`pluto`],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:`true false nil`,keyword:`and break do else elseif end for goto if in local not or repeat return then until while`,built_in:`_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove`},contains:i.concat([{className:`function`,beginKeywords:`function`,end:`\\)`,contains:[e.inherit(e.TITLE_MODE,{begin:`([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*`}),{className:`params`,begin:`\\(`,endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:`string`,begin:t,end:n,contains:[r],relevance:5}])}}t.exports=n})),fl=s(((e,t)=>{function n(e){let t={className:`variable`,variants:[{begin:`\\$\\(`+e.UNDERSCORE_IDENT_RE+`\\)`,contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:`variable`,begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:`subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value`},contains:[t,n]},i={begin:`^`+e.UNDERSCORE_IDENT_RE+`\\s*(?=[:+?]?=)`},a={className:`meta`,begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:`.PHONY`}},o={className:`section`,begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:`Makefile`,aliases:[`mk`,`mak`,`make`],keywords:{$pattern:/[\w-]+/,keyword:`define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath`},contains:[e.HASH_COMMENT_MODE,t,n,r,i,a,o]}}t.exports=n})),pl=s(((e,t)=>{function n(e){let t=e.regex,n=`abs.accept.alarm.and.atan2.bind.binmode.bless.break.caller.chdir.chmod.chomp.chop.chown.chr.chroot.class.close.closedir.connect.continue.cos.crypt.dbmclose.dbmopen.defined.delete.die.do.dump.each.else.elsif.endgrent.endhostent.endnetent.endprotoent.endpwent.endservent.eof.eval.exec.exists.exit.exp.fcntl.field.fileno.flock.for.foreach.fork.format.formline.getc.getgrent.getgrgid.getgrnam.gethostbyaddr.gethostbyname.gethostent.getlogin.getnetbyaddr.getnetbyname.getnetent.getpeername.getpgrp.getpriority.getprotobyname.getprotobynumber.getprotoent.getpwent.getpwnam.getpwuid.getservbyname.getservbyport.getservent.getsockname.getsockopt.given.glob.gmtime.goto.grep.gt.hex.if.index.int.ioctl.join.keys.kill.last.lc.lcfirst.length.link.listen.local.localtime.log.lstat.lt.ma.map.method.mkdir.msgctl.msgget.msgrcv.msgsnd.my.ne.next.no.not.oct.open.opendir.or.ord.our.pack.package.pipe.pop.pos.print.printf.prototype.push.q|0.qq.quotemeta.qw.qx.rand.read.readdir.readline.readlink.readpipe.recv.redo.ref.rename.require.reset.return.reverse.rewinddir.rindex.rmdir.say.scalar.seek.seekdir.select.semctl.semget.semop.send.setgrent.sethostent.setnetent.setpgrp.setpriority.setprotoent.setpwent.setservent.setsockopt.shift.shmctl.shmget.shmread.shmwrite.shutdown.sin.sleep.socket.socketpair.sort.splice.split.sprintf.sqrt.srand.stat.state.study.sub.substr.symlink.syscall.sysopen.sysread.sysseek.system.syswrite.tell.telldir.tie.tied.time.times.tr.truncate.uc.ucfirst.umask.undef.unless.unlink.unpack.unshift.untie.until.use.utime.values.vec.wait.waitpid.wantarray.warn.when.while.write.x|0.xor.y|0`.split(`.`),r=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(` `)},a={className:`subst`,begin:`[$@]\\{`,end:`\\}`,keywords:i},o={begin:/->\{/,end:/\}/},s={scope:`attr`,match:/\s+:\s*\w+(\s*\(.*?\))?/},c={scope:`variable`,variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,`(?![A-Za-z])(?![@$%])`)},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[s]},l={className:`number`,variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},u=[e.BACKSLASH_ESCAPE,a,c],d=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],f=(e,n,i=`\\1`)=>{let a=i===`\\1`?i:t.concat(i,n);return t.concat(t.concat(`(?:`,e,`)`),n,/(?:\\.|[^\\\/])*?/,a,/(?:\\.|[^\\\/])*?/,i,r)},p=(e,n,i)=>t.concat(t.concat(`(?:`,e,`)`),n,/(?:\\.|[^\\\/])*?/,i,r),m=[c,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:`string`,contains:u,variants:[{begin:`q[qwxr]?\\s*\\(`,end:`\\)`,relevance:5},{begin:`q[qwxr]?\\s*\\[`,end:`\\]`,relevance:5},{begin:`q[qwxr]?\\s*\\{`,end:`\\}`,relevance:5},{begin:`q[qwxr]?\\s*\\|`,end:`\\|`,relevance:5},{begin:`q[qwxr]?\\s*<`,end:`>`,relevance:5},{begin:`qw\\s+q`,end:`q`,relevance:5},{begin:`'`,end:`'`,contains:[e.BACKSLASH_ESCAPE]},{begin:`"`,end:`"`},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:`-?\\w+\\s*=>`,relevance:0}]},l,{begin:`(\\/\\/|`+e.RE_STARTERS_RE+`|\\b(split|return|print|reverse|grep)\\b)\\s*`,keywords:`split return print reverse grep`,relevance:0,contains:[e.HASH_COMMENT_MODE,{className:`regexp`,variants:[{begin:f(`s|tr|y`,t.either(...d,{capture:!0}))},{begin:f(`s|tr|y`,`\\(`,`\\)`)},{begin:f(`s|tr|y`,`\\[`,`\\]`)},{begin:f(`s|tr|y`,`\\{`,`\\}`)}],relevance:2},{className:`regexp`,variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:p(`(?:m|qr)?`,/\//,/\//)},{begin:p(`m|qr`,t.either(...d,{capture:!0}),/\1/)},{begin:p(`m|qr`,/\(/,/\)/)},{begin:p(`m|qr`,/\[/,/\]/)},{begin:p(`m|qr`,/\{/,/\}/)}]}]},{className:`function`,beginKeywords:`sub method`,end:`(\\s*\\(.*?\\))?[;{]`,excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s]},{className:`class`,beginKeywords:`class`,end:`[;{]`,excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s,l]},{begin:`-\\w\\b`,relevance:0},{begin:`^__DATA__$`,end:`^__END__$`,subLanguage:`mojolicious`,contains:[{begin:`^@@.*`,end:`$`,className:`comment`}]}];return a.contains=m,o.contains=m,{name:`Perl`,aliases:[`pl`,`pm`],keywords:i,contains:m}}t.exports=n})),ml=s(((e,t)=>{function n(e){let t={className:`built_in`,begin:`\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+`},n=/[a-zA-Z@][a-zA-Z0-9_]*/,r={"variable.language":[`this`,`super`],$pattern:n,keyword:`while.export.sizeof.typedef.const.struct.for.union.volatile.static.mutable.if.do.return.goto.enum.else.break.extern.asm.case.default.register.explicit.typename.switch.continue.inline.readonly.assign.readwrite.self.@synchronized.id.typeof.nonatomic.IBOutlet.IBAction.strong.weak.copy.in.out.inout.bycopy.byref.oneway.__strong.__weak.__block.__autoreleasing.@private.@protected.@public.@try.@property.@end.@throw.@catch.@finally.@autoreleasepool.@synthesize.@dynamic.@selector.@optional.@required.@encode.@package.@import.@defs.@compatibility_alias.__bridge.__bridge_transfer.__bridge_retained.__bridge_retain.__covariant.__contravariant.__kindof._Nonnull._Nullable._Null_unspecified.__FUNCTION__.__PRETTY_FUNCTION__.__attribute__.getter.setter.retain.unsafe_unretained.nonnull.nullable.null_unspecified.null_resettable.class.instancetype.NS_DESIGNATED_INITIALIZER.NS_UNAVAILABLE.NS_REQUIRES_SUPER.NS_RETURNS_INNER_POINTER.NS_INLINE.NS_AVAILABLE.NS_DEPRECATED.NS_ENUM.NS_OPTIONS.NS_SWIFT_UNAVAILABLE.NS_ASSUME_NONNULL_BEGIN.NS_ASSUME_NONNULL_END.NS_REFINED_FOR_SWIFT.NS_SWIFT_NAME.NS_SWIFT_NOTHROW.NS_DURING.NS_HANDLER.NS_ENDHANDLER.NS_VALUERETURN.NS_VOIDRETURN`.split(`.`),literal:[`false`,`true`,`FALSE`,`TRUE`,`nil`,`YES`,`NO`,`NULL`],built_in:[`dispatch_once_t`,`dispatch_queue_t`,`dispatch_sync`,`dispatch_async`,`dispatch_once`],type:[`int`,`float`,`char`,`unsigned`,`signed`,`short`,`long`,`double`,`wchar_t`,`unichar`,`void`,`bool`,`BOOL`,`id|0`,`_Bool`]},i={$pattern:n,keyword:[`@interface`,`@class`,`@protocol`,`@implementation`]};return{name:`Objective-C`,aliases:[`mm`,`objc`,`obj-c`,`obj-c++`,`objective-c++`],keywords:r,illegal:`</`,contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:`string`,variants:[{begin:`@"`,end:`"`,illegal:`\\n`,contains:[e.BACKSLASH_ESCAPE]}]},{className:`meta`,begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:`if else elif endif define undef warning error line pragma ifdef ifndef include`},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),{className:`string`,begin:/<.*?>/,end:/$/,illegal:`\\n`},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:`class`,begin:`(`+i.keyword.join(`|`)+`)\\b`,end:/(\{|$)/,excludeEnd:!0,keywords:i,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:`\\.`+e.UNDERSCORE_IDENT_RE,relevance:0}]}}t.exports=n})),hl=s(((e,t)=>{function n(e){let t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),a=t.concat(/[A-Z]+/,n),o={scope:`variable`,match:`\\$+`+r},s={scope:`meta`,variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},c={scope:`subst`,variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},l=e.inherit(e.APOS_STRING_MODE,{illegal:null}),u=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(c)}),d={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(c),"on:begin":(e,t)=>{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},f=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p=`[
|
|
@@ -90,7 +90,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
90
90
|
title="copy this code block to clipboard">copy</button>
|
|
91
91
|
${t}
|
|
92
92
|
</div>`)}function Hl(e,t){let n=St(t);return n?e.replace(/(>)([^<]+)(<)/g,(e,t,r,i)=>t+r.replace(n,e=>`<mark>${Ul(e)}</mark>`)+i):e}function Ul(e){return e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e])}var Wl=(0,W.forwardRef)(function({message:e,searchQuery:t,sessionId:n,isMatch:r,isActiveMatch:i,activationTick:a,collapseDefault:o=!1},s){let[c,l]=(0,W.useState)(`pretty`),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(o);(0,W.useEffect)(()=>{p(o)},[o]);let m=(0,W.useMemo)(()=>Nl(e.content_text??``),[e.content_text]),h=(0,W.useMemo)(()=>{let t=e.content_text??``;if(!t)return{html:``,strippedCount:0,rawLen:0};if(c===`raw`)return{html:`<pre>${Ul(t)}</pre>`,strippedCount:0,rawLen:t.length};let{cleaned:n,stripped:r}=c===`include-system`?{cleaned:t,stripped:0}:Il(t);return{html:Bl(n||`_(content was entirely system-only)_`),strippedCount:r,rawLen:t.length}},[e.content_text,c]),g=(0,W.useMemo)(()=>h.html?c===`raw`?h.html:t?Hl(h.html,t):h.html:``,[h.html,t,c]),_=h.strippedCount,v=h.rawLen,y=e.role===`user`?`text-role-user border-role-user/40`:e.role===`assistant`?`text-role-assistant border-role-assistant/40`:`text-fg-dim border-line`,b=e.role===`user`?`user`:e.role===`assistant`?`assistant`:e.type,x=e.tool_names?e.tool_names.split(`,`).filter(Boolean):[],S=(e.content_text??``).slice(0,64),C=e.role===`user`&&(S.startsWith(`**Tool result**`)||S.startsWith(`_(tool result was empty`)),w=x.length>0||C,T=v>6e3,E=T&&!u&&c!==`raw`&&!f;return(0,G.jsxs)(`article`,{ref:s,className:$(`border-l-2 pl-4 py-3 group scroll-mt-4`,y,e.is_sidechain&&`opacity-70`,r&&`match-highlight-border rounded`,i&&`match-flash`),children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-2 text-xs mb-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:$(`font-semibold uppercase tracking-wider`,y),children:b}),e.is_sidechain===1&&(0,G.jsx)(`span`,{className:`badge bg-bg-active text-fg-muted`,children:`subagent`}),e.timestamp&&(0,G.jsx)(`span`,{className:`text-fg-muted font-mono`,children:new Date(e.timestamp).toLocaleTimeString()}),x.length>0&&(0,G.jsxs)(`span`,{className:`badge bg-role-tool/15 text-role-tool`,children:[`⚡ `,x.join(`, `)]}),_>0&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(e=>e===`include-system`?`pretty`:`include-system`),className:`badge bg-bg-active text-fg-muted hover:text-fg`,title:`some system-injected content was hidden — click to toggle`,children:c===`include-system`?`— hide system`:`+ ${_} system`}),w&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`text-fg-muted hover:text-fg text-xs border border-line rounded px-1.5 py-0.5`,title:f?`expand this tool message`:`collapse this tool message`,"aria-expanded":!f,children:f?`▸ expand`:`▾ collapse`}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>{e.content_text&&navigator.clipboard.writeText(e.content_text)},className:`hover:text-fg-dim text-xs`,title:`copy message content`,children:`copy`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(e=>e===`raw`?`pretty`:`raw`),className:`hover:text-fg-dim text-xs`,title:`toggle raw plain-text view`,children:c===`raw`?`rendered`:`raw`})]})]}),f?(0,G.jsxs)(`div`,{className:`text-xs italic text-fg-muted`,children:[`(collapsed`,v?` · ${v.toLocaleString()} chars`:``,` — click expand to view)`]}):m&&c!==`raw`?(0,G.jsx)(jl,{sessionId:n,messageUuid:e.uuid,pasteNumber:m.pasteNumber,lineCount:m.lineCount,filePath:m.filePath}):g?(0,G.jsx)(`div`,{className:$(`prose-message relative`,E&&`max-h-72 overflow-hidden`),onClick:e=>{let t=e.target;if(t.dataset?.copyCode!==`1`)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`.recall-code-block`);if(!n)return;let r=n.querySelector(`code`)?.textContent??``;navigator.clipboard.writeText(r).then(()=>{let e=t.textContent;t.textContent=`copied!`,t.classList.add(`!text-accent`),setTimeout(()=>{t.textContent=e,t.classList.remove(`!text-accent`)},1200)})},dangerouslySetInnerHTML:{__html:g}}):(0,G.jsx)(`div`,{className:`text-xs italic text-fg-muted`,children:`(empty message)`}),E&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-xs text-accent hover:underline`,children:[`expand full message (`,v.toLocaleString(),` chars)`]}),T&&u&&c!==`raw`&&!f&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`mt-2 text-xs text-fg-muted hover:text-fg-dim`,children:`collapse`})]},a??0)}),Gl=(0,W.memo)(Wl,(e,t)=>e.message===t.message&&e.searchQuery===t.searchQuery&&e.sessionId===t.sessionId&&e.isMatch===t.isMatch&&e.isActiveMatch===t.isActiveMatch&&e.activationTick===t.activationTick&&e.collapseDefault===t.collapseDefault);function Kl(){let e=K();return J({mutationFn:async({sessionId:e,alias:t})=>{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/alias`,{method:`PUT`,headers:pt({"content-type":`application/json`}),body:JSON.stringify({alias:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`${n.status}: ${e.slice(0,200)}`)}return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`search`]}),e.invalidateQueries({queryKey:[`searchCount`]}),e.invalidateQueries({queryKey:[`thread`]}),e.invalidateQueries({queryKey:[`sessionThreads`]})}})}function ql(){let e=K();return J({mutationFn:async e=>{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/alias`,{method:`DELETE`,headers:pt()});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`${t.status}: ${e.slice(0,200)}`)}},onSuccess:()=>{e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`session`]}),e.invalidateQueries({queryKey:[`search`]}),e.invalidateQueries({queryKey:[`searchCount`]}),e.invalidateQueries({queryKey:[`thread`]}),e.invalidateQueries({queryKey:[`sessionThreads`]})}})}function Jl(e){return q({queryKey:[`linked-terminal`,e],queryFn:async()=>{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/linked-terminal`,{headers:pt()});if(!t.ok)throw Error(`${t.status}`);return t.json()},enabled:!!e,staleTime:5e3})}function Yl(e){return q({queryKey:[`terminal-registry`],queryFn:async()=>{let e=await fetch(`/api/terminal/registry`,{headers:pt()});if(!e.ok)throw Error(`${e.status}`);return e.json()},enabled:e,refetchInterval:e?5e3:!1,staleTime:2500})}function Xl(){let e=K();return J({mutationFn:async e=>{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/auto-relink`,{method:`POST`,headers:pt()});if(!t.ok)throw Error(`${t.status}`);return t.json()},onSuccess:(t,n)=>{t.applied&&(e.invalidateQueries({queryKey:[`linked-terminal`,n]}),e.invalidateQueries({queryKey:[`session`,n]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`search`]}),e.invalidateQueries({queryKey:[`thread`]}),e.invalidateQueries({queryKey:[`sessionThreads`]}))}})}function Zl(){let e=K();return J({mutationFn:async({sessionId:e,shell_pid:t,clear:n})=>{let r=await fetch(`/api/sessions/${encodeURIComponent(e)}/relink`,{method:`POST`,headers:pt({"content-type":`application/json`}),body:JSON.stringify(n?{clear:!0}:{shell_pid:t})});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`${r.status}: ${e.slice(0,200)}`)}return r.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`linked-terminal`,n.sessionId]}),e.invalidateQueries({queryKey:[`session`,n.sessionId]}),e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`search`]}),e.invalidateQueries({queryKey:[`thread`]}),e.invalidateQueries({queryKey:[`sessionThreads`]})}})}var Ql=`recall:transcript-sections:set-open:`,$l=(0,W.createContext)(`default`);function eu({scope:e,children:t}){return(0,G.jsx)($l.Provider,{value:e,children:t})}function tu(){return(0,W.useContext)($l)}function nu(e){let t=(0,W.useContext)($l);(0,W.useEffect)(()=>{if(typeof window>`u`)return;let n=`${Ql}${t}`,r=t=>{let n=t;typeof n.detail==`boolean`&&e(n.detail)};return window.addEventListener(n,r),()=>window.removeEventListener(n,r)},[t,e])}function ru(){let e=(0,W.useContext)($l);return(0,W.useCallback)(t=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`${Ql}${e}`,{detail:t}))},[e])}function iu({sessionId:e}){let t=Hi(e),n=Ui(),r=Wi(),i=t.data,a=i?.content??``,o=a.length>0,s=i?.auto_synopsis??null,c=i?.auto_synopsis_generated_at??null,l=!!s&&s.length>0,u=o||l,[d,f]=(0,W.useState)(!1);nu(f);let[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(!1);(0,W.useEffect)(()=>{v(!1)},[e]);let y=(0,W.useRef)(null);(0,W.useEffect)(()=>{m(!1),f(u),g(a)},[e,u,a]),(0,W.useEffect)(()=>{p&&(g(a),requestAnimationFrame(()=>{y.current?.focus();let e=y.current;e&&(e.selectionStart=e.selectionEnd=e.value.length)}))},[p,a]);let b=async()=>{try{await n.mutateAsync({sessionId:e,content:h}),m(!1)}catch(e){console.error(`note save failed`,e)}},x=()=>{g(a),m(!1)},S=async()=>{try{await r.mutateAsync(e),Q({message:`Synopsis generated`,tone:`success`,duration:4e3})}catch(e){let t=e?.message??`unknown error`;Q({message:/403/.test(t)?`Agent generation disabled — open a session and click ✨ on the title bar to enable`:`Synopsis generation failed: ${t}`,tone:`error`,duration:6e3})}},C=h!==a,w=i?.updated_at?new Date(i.updated_at):null,T=c?new Date(c):null;return(0,G.jsxs)(`div`,{className:`border-b border-line bg-bg/30`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`w-full flex items-center justify-between px-5 py-2 text-xs text-fg-dim hover:text-fg transition-colors`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:$(`transition-transform`,d&&`rotate-90`),children:`▸`}),(0,G.jsx)(`span`,{className:`font-medium uppercase tracking-wider`,children:`📝 Notes`}),o&&!d&&(0,G.jsx)(`span`,{className:`text-fg-muted normal-case tracking-normal truncate max-w-lg`,children:a.split(`
|
|
93
|
-
`)[0].slice(0,120)}),!o&&!d&&(0,G.jsx)(`span`,{className:`text-fg-muted normal-case tracking-normal italic`,children:`none yet — click to add`})]}),w&&o&&(0,G.jsxs)(`span`,{className:`text-fg-muted normal-case tracking-normal font-mono`,children:[`updated `,w.toLocaleString()]})]}),d&&(0,G.jsx)(`div`,{className:`px-5 pb-3`,children:p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`textarea`,{ref:y,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),b()):e.key===`Escape`&&(e.preventDefault(),x())},placeholder:`Your markdown notes for this session…\\n\\nCmd/Ctrl+Enter saves. Esc cancels.`,rows:8,className:`w-full bg-bg-elevated border border-line rounded p-3 text-sm text-fg font-mono leading-relaxed focus:outline-none focus:border-accent placeholder:text-fg-muted resize-y`,spellCheck:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[h.length.toLocaleString(),` chars`,C&&(0,G.jsx)(`span`,{className:`text-accent ml-2`,children:`· unsaved`}),(0,G.jsxs)(`span`,{className:`ml-3 text-fg-muted`,children:[`mirrored to `,(0,G.jsxs)(`span`,{className:`font-mono`,children:[`~/.recall/notes/`,e.slice(0,8),`.md`]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:x,className:`px-3 py-1 text-fg-muted hover:text-fg`,children:`cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:!C||n.isPending,className:`px-3 py-1 rounded border border-accent bg-accent/10 text-accent font-medium hover:bg-accent hover:text-bg disabled:opacity-50 disabled:cursor-not-allowed`,children:n.isPending?`saving…`:`save`})]})]})]}):(0,G.jsxs)(G.Fragment,{children:[o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded p-3 max-h-72 overflow-y-auto`,children:(0,G.jsx)(Ws,{text:a})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-2`,children:[(0,G.jsx)(au,{hasSynopsis:l,pending:r.isPending,onClick:S}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`text-xs text-accent hover:underline`,children:`✎ edit`})]})]}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`w-full border border-dashed border-line rounded p-4 text-sm text-fg-muted hover:border-accent hover:text-fg-dim transition-colors`,children:`+ add a note for this session`}),(0,G.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,G.jsx)(au,{hasSynopsis:l,pending:r.isPending,onClick:S})})]}),l&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 text-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex items-center gap-1.5 text-fg-muted hover:text-fg transition-colors`,title:_?`expand auto-synopsis`:`collapse auto-synopsis`,"aria-expanded":!_,children:[(0,G.jsx)(`span`,{className:$(`transition-transform`,!_&&`rotate-90`),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{className:`text-accent`,"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`font-medium uppercase tracking-wider`,children:`Auto-synopsis`}),T&&(0,G.jsxs)(`span`,{className:`text-fg-muted normal-case tracking-normal font-mono`,children:[`· generated `,T.toLocaleString()]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`text-xs text-fg-muted hover:text-fg`,title:_?`expand auto-synopsis`:`collapse auto-synopsis`,children:_?`▸ expand`:`▾ collapse`}),(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:r.isPending,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`run claude -p again over the latest transcript`,children:r.isPending?`regenerating…`:`↻ regenerate`})]})]}),!_&&(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-accent/40 rounded p-3 border-l-2 max-h-96 overflow-y-auto`,children:(0,G.jsx)(Ws,{text:s??``})})]})]})})]})}function au({hasSynopsis:e,pending:t,onClick:n}){return e?null:(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`reads this session's transcript and writes a markdown synopsis below your note`,children:t?`generating…`:`✨ generate synopsis`})}function ou({sessionId:e,tags:t}){let[n,r]=(0,W.useState)(!1),i=On(),[,a]=Nn();return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 normal-case tracking-normal`,children:[t.map(t=>(0,G.jsxs)(`span`,{className:`group inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-role-tool/15 text-role-tool text-xs font-medium border border-role-tool/30`,children:[(0,G.jsxs)(`span`,{children:[`#`,t]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i.mutate({sessionId:e,tag:t}),className:`opacity-60 hover:opacity-100 transition-opacity`,title:`remove #${t}`,children:`×`})]},t)),n?(0,G.jsx)(ci,{sessionId:e,existingTags:t,onDone:()=>r(!1),variant:`bar`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:$(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-dashed text-xs transition-colors`,t.length===0?`border-line text-fg-muted hover:text-fg hover:border-accent`:`border-line/50 text-fg-muted opacity-60 hover:opacity-100 hover:text-fg`),title:`add a tag — typing #tagname in the search box also filters by tag`,children:`+ tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a({view:`help`,helpSection:`taxonomy`}),className:`inline-flex items-center justify-center w-4 h-4 rounded-full text-[10px] text-fg-muted/70 hover:text-accent hover:bg-accent/10 transition-colors`,title:`Tag vs Collection vs Alias vs Note — what's the difference?`,"aria-label":`Tag vs other organizers — what's the difference?`,children:`?`})]})}function su({sessionId:e}){let t=wt(),n=li(),r=K(),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1);ui(!!n.error,()=>n.reset());let c=()=>{let r=t.data;if(!r||!r.enabled){a(!0);return}if(r.backend===`api`&&!r.hasApiKey){a(!0);return}if(r.backend===`mcp`){s(!0);return}n.start({sessionIds:[e]})},l=()=>{r.invalidateQueries({queryKey:[`sessions`]}),r.invalidateQueries({queryKey:[`session`,e]}),r.invalidateQueries({queryKey:[`tags`]})},u=async e=>{let t=await n.apply(e);if(t&&t.applied>0){l();let n=e.reduce((e,t)=>e+t.tags.length,0);Q({message:`Applied ${t.applied} tag${t.applied===1?``:`s`} to this session.`,tone:`success`,duration:1e4,action:{label:`Undo`,onClick:()=>{d(e,n)}}})}else t&&Q({message:`Nothing to apply — all selected tags were already present.`,tone:`info`});return t},d=async(e,t)=>{let n=0;for(let t of e)for(let e of t.tags)try{await Z.removeSessionTag(t.sessionId,e),n+=1}catch(n){console.error(`undo: remove failed`,t.sessionId,e,n)}l(),Q({message:`Undone — removed ${n} of ${t} tag${t===1?``:`s`}.`,tone:`info`})},f=async()=>{if(!n.snapshot)return;let e=n.snapshot.results.filter(e=>e.error).map(e=>e.sessionId);e.length!==0&&(n.reset(),await n.start({sessionIds:e}))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`inline-flex items-center rounded border border-accent/40 bg-accent/10 overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:!!n.id,className:`text-xs text-accent hover:bg-accent hover:text-bg px-2 py-1 font-medium border-r border-accent/40 disabled:opacity-50 disabled:cursor-wait`,title:t.data?.enabled?`auto-tag this session with an LLM`:`configure auto-tagging`,children:n.id?`🏷 scanning…`:`🏷 auto-tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`text-xs text-accent hover:bg-accent hover:text-bg px-1.5 py-1`,title:`auto-tag settings (enable autopilot, install MCP, change model, paste API key)`,"aria-label":`auto-tag settings`,children:`⚙`})]}),(0,G.jsx)(fi,{open:i,onClose:()=>a(!1)}),(0,G.jsx)(hi,{open:o,sessionId:e,onClose:()=>{s(!1),Q({message:`MCP scan triggered. New tags will appear on this session as your Claude Code agent writes them.`,tone:`info`,duration:8e3})},onOpenSettings:()=>{s(!1),a(!0)}}),n.error&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-role-user/60 rounded-lg w-[440px] shadow-xl p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-role-user font-semibold mb-2`,children:`Scan failed`}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-3 break-words`,children:n.error}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.reset(),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})}),(0,G.jsx)(pi,{open:!!n.id&&!n.error,snapshot:n.snapshot,onApply:u,onCancel:()=>void n.cancel(),onClose:()=>n.reset(),onRetryFailed:()=>void f()})]})}function cu({sessionId:e}){let t=q({queryKey:[`sessionStats`,e],queryFn:()=>Z.getSessionStats(e),staleTime:3e4}).data;return!t||t.totalTokens===0?null:(0,G.jsxs)(`a`,{href:`#/stats`,className:`normal-case tracking-normal shrink-0 inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-dim hover:text-accent border border-line hover:border-accent/60 rounded px-2 py-0.5 transition-colors`,title:`session cost — derived from token counts (pricing may change)\n\ninput: ${t.inputTokens.toLocaleString()}\noutput: ${t.outputTokens.toLocaleString()}\ncache write: ${t.cacheCreateTokens.toLocaleString()}\ncache read: ${t.cacheReadTokens.toLocaleString()}\ntotal: ${t.totalTokens.toLocaleString()}\n\nmodel: ${t.primaryModelLabel}${t.primaryModel?` (${t.primaryModel})`:``}`+(t.byModel.length>1?`\n\n${t.byModel.length} models used — click to view dashboard`:``),children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:t.display.dollars}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsxs)(`span`,{children:[t.display.tokens,` tok`]}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:t.primaryModelLabel})]})}function lu({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`sessionCommits`,e],queryFn:()=>Z.getSessionCommits(e),staleTime:3e4}).data?.commits??[];if(r.length===0)return null;let i=`${r.length} commit${r.length===1?``:`s`}`;return(0,G.jsxs)(`div`,{className:`px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal text-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-1.5 text-fg-muted hover:text-fg`,title:`commits authored during this session`,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`font-medium text-fg-dim`,children:`⎇`}),(0,G.jsxs)(`span`,{children:[i,` authored during this session`]})]}),t&&(0,G.jsx)(`ul`,{className:`mt-2 space-y-1.5 pl-5`,children:r.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px]`,children:[(0,G.jsx)(`code`,{className:`font-mono text-accent shrink-0`,title:e.commit_sha,children:e.commit_sha.slice(0,8)}),(0,G.jsx)(`span`,{className:`text-fg truncate min-w-0 flex-1`,children:e.subject??(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(no subject)`})}),e.committed_at&&(0,G.jsx)(`time`,{className:`text-fg-muted shrink-0 font-mono`,children:e.committed_at.replace(`T`,` `).slice(0,19)})]},e.commit_sha))})]})}function uu(e,t){e.invalidateQueries({queryKey:[`threads`]}),t&&e.invalidateQueries({queryKey:[`thread`,t]}),e.invalidateQueries({queryKey:[`sessionThreads`]})}function du(e=!1){return q({queryKey:[`threads`,{archived:e}],queryFn:()=>Z.listThreads(e),staleTime:1e4})}function fu(e){return q({queryKey:[`thread`,e],queryFn:()=>Z.getThread(e),enabled:!!e,staleTime:1e4})}function pu(e){return q({queryKey:[`sessionThreads`,e],queryFn:()=>Z.threadsForSession(e),enabled:!!e,staleTime:3e4})}function mu(){let e=K();return J({mutationFn:e=>Z.createThread(e),onSuccess:t=>uu(e,t.thread.id)})}function hu(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchThread(e,t),onSuccess:t=>uu(e,t.thread.id)})}function gu(){return q({queryKey:[`thread-folders`],queryFn:()=>Z.listThreadFolders(),staleTime:3e4})}function _u(){let e=K();return J({mutationFn:e=>Z.createThreadFolder(e),onSuccess:()=>e.invalidateQueries({queryKey:[`thread-folders`]})})}function vu(){let e=K();return J({mutationFn:e=>Z.deleteThreadFolder(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`thread-folders`]}),e.invalidateQueries({queryKey:[`threads`]})}})}function yu(){let e=K();return J({mutationFn:e=>Z.reorderThreadFolders(e),onSuccess:()=>e.invalidateQueries({queryKey:[`thread-folders`]})})}function bu(){let e=K();return J({mutationFn:({threadId:e,sessionId:t,parentSessionId:n,role:r})=>Z.addSessionToThread(e,{sessionId:t,parentSessionId:n,role:r}),onSuccess:(t,n)=>uu(e,n.threadId)})}function xu(){let e=K();return J({mutationFn:({threadId:e,sessionId:t})=>Z.removeSessionFromThread(e,t),onSuccess:(t,n)=>uu(e,n.threadId)})}function Su(){let e=K();return J({mutationFn:({threadId:e,sessionId:t,parentSessionId:n})=>Z.setThreadSessionParent(e,t,n),onSuccess:(t,n)=>uu(e,n.threadId)})}function Cu(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)):[...e]}function wu({sessionId:e}){let[,t]=Nn(),n=pu(e),r=du(),i=mu(),a=bu(),o=xu(),[s,c]=(0,W.useState)(!1);nu(c);let[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),p=n.data?.threads??[],m=new Set(p.map(e=>e.id)),h=(r.data?.threads??[]).filter(e=>!m.has(e.id));return(0,G.jsxs)(`div`,{className:`px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s&&l&&u(!1),c(e=>!e)},className:`flex items-center gap-1.5 text-fg-muted hover:text-fg text-xs`,title:`Threads group a session with related sessions (for example, a planning session plus the execution sessions it spawned).`,"aria-expanded":s,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:s?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`uppercase tracking-wider`,children:`🧵 Threads`}),p.length>0&&(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] font-mono tabular-nums`,children:p.length})]}),s&&(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-start gap-1.5`,children:[p.map(n=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent/10 text-accent text-xs border border-accent/30`,title:`${n.session_count} session${n.session_count===1?``:`s`} in this thread`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:`threads`,thread:n.id}),className:`hover:underline`,title:`open the "${n.name}" thread graph`,children:n.name}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o.mutate({threadId:n.id,sessionId:e}),className:`text-fg-muted hover:text-role-user text-[11px]`,title:`unlink this session from the thread (thread keeps existing)`,children:`✕`})]},n.id)),l?(0,G.jsx)(Tu,{sessionId:e,available:h,activeCount:p.length,newName:d,setNewName:f,creating:i.isPending,adding:a.isPending,onPickExisting:t=>{a.mutate({threadId:t,sessionId:e},{onSuccess:()=>u(!1)})},onCreate:()=>{let t=d.trim();t&&i.mutate({name:t,originSessionId:e},{onSuccess:()=>{f(``),u(!1)}})},onCancel:()=>{u(!1),f(``)}}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs text-accent hover:underline`,title:`Link this session into an existing thread, or create a new one with this session as the origin (reverse path is + Add session from the thread detail page).`,children:`+ Add to thread`})]})]})}function Tu({available:e,activeCount:t,newName:n,setNewName:r,creating:i,adding:a,onPickExisting:o,onCreate:s,onCancel:c}){let[l,u]=(0,W.useState)(``),d=(0,W.useMemo)(()=>Cu(e,l),[e,l]),f=l.trim().length>0;return(0,G.jsxs)(`div`,{className:`w-full mt-1 rounded border border-line bg-bg-elevated p-2 space-y-2 border-l-2 border-l-accent/60`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider font-medium text-fg-muted`,children:`Link to a thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`text-[11px] text-fg-muted hover:text-fg`,title:`Close the picker without linking this session to any thread.`,children:`cancel`})]}),e.length>0&&(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d.length===1?(e.preventDefault(),o(d[0].id)):e.key===`Escape`&&(e.preventDefault(),l?u(``):c())},placeholder:`search threads by name`,"aria-label":`Search threads by name`,className:`w-full text-xs bg-bg border border-line rounded px-2 py-1`}),e.length>0?d.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted mb-1`,children:f?`${d.length} match${d.length===1?``:`es`}: click to link this session.`:`Click an existing thread to link this session into it:`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:a,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full border border-line hover:border-accent hover:bg-accent/10 text-xs disabled:opacity-50`,title:`Link this session into "${e.name}" (${e.session_count} session${e.session_count===1?``:`s`}, ${e.closed_at?`closed`:`open`})`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:e.session_count})]},e.id))})]}):(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted italic`,children:[`No threads match "`,l.trim(),`". Create a new one below.`]}):(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted italic`,children:t>0?`No other threads available. Create a new one below.`:`No threads exist yet. Create the first one below.`}),(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s()},className:`flex items-center gap-1.5 pt-1 border-t border-line`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-muted`,title:`Creating a new thread with this session as the first member (origin)`,children:`Or create new:`}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`thread name (this session becomes the origin)`,className:`flex-1 text-xs bg-bg border border-line rounded px-2 py-1`}),(0,G.jsx)(`button`,{type:`submit`,disabled:!n.trim()||i,className:`text-xs px-2 py-1 rounded bg-accent text-bg font-medium disabled:opacity-50`,title:`Create a new thread with this session set as the origin`,children:`Create`})]})]})}function Eu({content:e,children:t,side:n=`bottom`,delayMs:r=300,maxWidth:i=300}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);let f=()=>{d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>o(!0),r)},p=()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null,o(!1),c(null)};return(0,W.useLayoutEffect)(()=>{if(!a)return;let e=l.current,t=u.current;if(!e||!t)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=n,s=window.innerHeight-r.bottom,d=r.top;o===`bottom`&&s<i.height+8&&d>s?o=`top`:o===`top`&&d<i.height+8&&s>d&&(o=`bottom`);let f=o===`bottom`?r.bottom+8:r.top-i.height-8,p=r.left+r.width/2,m=p-i.width/2;m=Math.max(8,Math.min(m,window.innerWidth-i.width-8));let h=p-m;c({top:f,left:m,arrowLeft:h,side:o})},[a,n,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{ref:l,className:`relative inline-flex`,onMouseEnter:f,onMouseLeave:p,onFocus:f,onBlur:p,children:t}),a&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:u,role:`tooltip`,style:{position:`fixed`,top:s?.top??-9999,left:s?.left??-9999,width:i,visibility:s?`visible`:`hidden`,zIndex:9999},className:`pointer-events-none px-3 py-2 rounded-md bg-bg-elevated border border-accent/50 shadow-[0_8px_24px_-8px_rgba(138,120,255,0.45),0_2px_8px_rgba(0,0,0,0.4)] text-[11px] leading-snug text-fg-muted normal-case tracking-normal whitespace-normal text-left`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-accent/70`}),(0,G.jsx)(`div`,{className:`pl-1.5`,children:e}),s&&(0,G.jsx)(`span`,{"aria-hidden":`true`,style:{position:`absolute`,left:s.arrowLeft-5,...s.side===`bottom`?{top:-5}:{bottom:-5}},className:`w-2.5 h-2.5 rotate-45 bg-bg-elevated border border-accent/50 `+(s.side===`bottom`?`border-r-0 border-b-0`:`border-l-0 border-t-0`)})]}),document.body)]})}function Du(e,t){return e.length<=t?{visible:e.slice(),overflow:0}:{visible:e.slice(0,t),overflow:e.length-t}}var Ou=12;function ku({sessionId:e}){let[,t]=Nn(),n=K(),[r,i]=(0,W.useState)(!1),a=q({queryKey:[`session-links`,e,`wiki_link`],queryFn:()=>Z.sessionLinks(e),enabled:!!e}),o=J({mutationFn:e=>Z.removeLink(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`session-links`,e,`wiki_link`]})},onError:e=>{Q({message:`Unlink failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),s=a.data?.links??[];if(a.isLoading||s.length===0)return null;let{visible:c,overflow:l}=r?{visible:s,overflow:0}:Du(s,Ou);return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start gap-1.5 px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mr-1 pt-0.5`,title:`Wiki-style links between sessions. Right-click any session in the list to add one.`,children:`🔗 Linked`}),(0,G.jsxs)(`span`,{className:`text-[10px] text-fg-muted pt-0.5`,children:[s.length,` `,s.length===1?`session`:`sessions`]}),c.map(e=>(0,G.jsx)(Au,{link:e,onNavigate:()=>t({session:e.otherSessionId,msg:null}),onUnlink:()=>o.mutate(e.linkId)},e.linkId)),l>0&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex items-center px-2 py-0.5 rounded-full border border-dashed border-line/60 text-[10px] text-fg-muted hover:text-fg hover:border-accent`,title:`Show ${l} more linked session${l===1?``:`s`}`,children:[`+`,l,` more`]})]})}function Au({link:e,onNavigate:t,onUnlink:n}){let r=e.direction===`outbound`?`→`:`←`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent/10 text-accent text-xs border border-accent/30`,title:e.direction===`outbound`?`${e.title} (this session links to it)`:`${e.title} (this session is linked from it)`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-[10px] text-accent/70`,children:r}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`hover:underline truncate max-w-[18rem]`,title:`open ${e.title}`,children:e.title}),e.project&&(0,G.jsx)(`span`,{className:`text-[10px] text-fg-muted/80 italic truncate max-w-[8rem]`,children:e.project}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-role-user text-[10px]`,title:`unlink from "${e.title}"`,"aria-label":`unlink from ${e.title}`,children:`✕`})]})}function ju({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`neighborhood`,e],queryFn:()=>Z.neighborhood(e,{budget:4e3,scoring:`hybrid`}),enabled:t,staleTime:60*1e3});function i(){r.data?.bundle&&(navigator.clipboard?.writeText(r.data.bundle),Q({message:`Neighborhood bundle copied — paste into Claude`,tone:`info`}))}return(0,G.jsxs)(`section`,{className:`border-b border-line`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-3 px-5 py-3 cursor-pointer hover:bg-bg-hover/40`,onClick:()=>n(e=>!e),children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] uppercase tracking-wider w-3`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Neighborhood`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:`parents · children · citations · similar (bundle for piping into Claude)`}),r.data&&(0,G.jsxs)(`span`,{className:`ml-auto text-fg-muted text-xs font-mono tabular-nums`,children:[r.data.budgetUsed,` / `,r.data.budgetUsed+r.data.budgetRemaining,` tokens`]})]}),t&&(0,G.jsxs)(`div`,{className:`px-5 pb-4 space-y-3`,children:[r.isLoading&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`h-3 w-3 rounded-full border-2 border-accent border-t-transparent animate-spin`}),`Assembling neighborhood…`]}),r.isError&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user text-xs`,children:[`Failed to load neighborhood:`,` `,r.error instanceof Error?r.error.message:`unknown error`]}),r.data&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`px-2.5 py-1 rounded border border-line hover:bg-bg-hover`,title:`Copy the markdown bundle. Paste into a fresh Claude chat to seed it with the related context.`,children:`Copy bundle`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`Or in your terminal: `,(0,G.jsxs)(`code`,{className:`text-fg`,children:[`recall neighborhood `,e.slice(0,8),` | claude`]})]})]}),r.data.truncated.length>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[r.data.truncated.length,` ref(s) didn't fit the budget. Increase the budget on the CLI for the full bundle.`]}),(0,G.jsx)(`pre`,{className:`bg-bg-elevated border border-line rounded p-3 text-xs leading-relaxed text-fg whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:r.data.bundle||"(empty bundle — this session has no inferred neighborhood yet. Run `recall infer-l1` or `recall infer-citations` for this project.)"})]})]})]})}function Mu({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`verification-detail`,e],queryFn:()=>Z.getVerificationDetail(e),staleTime:6e4});if(!r.data||r.data.status===`neutral`)return null;let{status:i,evidence:a}=r.data,o=[[`File writes`,a.fileWrites],[`Test runs`,a.testRuns],[`Git commits`,a.commits],[`Build success`,a.buildSuccess]],s=o.filter(([,e])=>e).length;return(0,G.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-2 text-xs overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 p-3 hover:bg-bg-hover/40 transition-colors text-left`,onClick:()=>n(e=>!e),"aria-expanded":t,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] uppercase tracking-wider w-3`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`font-medium ${i===`verified`?`text-green-500`:`text-yellow-500`}`,children:i===`verified`?`Verified`:`Unverified`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`completion evidence`}),(0,G.jsxs)(`span`,{className:`ml-auto text-fg-muted text-[10px] font-mono tabular-nums`,children:[s,` / `,o.length]})]}),t&&(0,G.jsx)(`div`,{className:`px-3 pb-3 grid grid-cols-2 gap-1`,children:o.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:t?`text-green-500`:`text-fg-muted/40`,children:t?`✓`:`✗`}),(0,G.jsx)(`span`,{className:t?`text-fg`:`text-fg-muted`,children:e})]},e))})]})}var Nu=[{key:`A`,name:`Minimal`,swatch:`#1a1b1e`},{key:`B`,name:`Terminal`,swatch:`#0d0d0f`},{key:`C`,name:`Gradient`,swatch:`linear-gradient(135deg,#b1370f,#fbbf24)`},{key:`D`,name:`Dashboard`,swatch:`#f6f7f9`}],Pu=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function Fu(e,t=80){if(!e)return null;let n=e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).trim();if(!n||Pu.some(e=>e.test(n)))return null;let r=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).replace(/\s+/g,` `).trim();return r?r.length<=t?r:r.slice(0,t-1).trimEnd()+`…`:null}function Iu(e){for(let t of[e.alias,e.auto_title,e.first_user_message]){let e=Fu(t);if(e)return e}return e.id.slice(0,8)}function Lu(e,t){if(!e||!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(!Number.isFinite(n)||n<=0)return null;let r=Math.round(n/6e4);if(r<1)return`< 1 min`;if(r<60)return`${r} min`;let i=Math.floor(r/60),a=r%60;return a===0?`${i}h`:`${i}h ${a}m`}function Ru({session:e,onClose:t}){let n=(0,W.useMemo)(()=>Fu(e.first_user_message,120)??``,[e.first_user_message]),[r,i]=(0,W.useState)(`A`),[a,o]=(0,W.useState)(n),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(null),d=(0,W.useRef)(null),f=(0,W.useRef)(),p=q({queryKey:[`share-stats`,e.id],queryFn:()=>Z.shareStats(e.id),staleTime:6e4}),m=q({queryKey:[`session-stats`,e.id],queryFn:()=>Z.getSessionStats(e.id),staleTime:6e4}),h=(0,W.useMemo)(()=>Iu(e),[e]),g=(0,W.useMemo)(()=>Lu(e.started_at,e.ended_at),[e.started_at,e.ended_at]),_=(0,W.useMemo)(()=>({sessionTitle:h,sessionDate:e.started_at??new Date().toISOString(),recallDate:new Date().toISOString(),costDollars:m.data?.display.dollars??`$—`,durationLabel:g,model:m.data?.primaryModelLabel??null,cachedTokens:m.data?.cacheReadTokens??0,messageCount:e.message_count,filesReferenced:p.data?.filesReferenced??0,toolCallCount:p.data?.toolCallCount??0,verdict:a}),[h,e.started_at,g,m.data,e.message_count,p.data,a]),v=(0,W.useCallback)(async()=>{c(!0),u(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-Zvhj1IwK.js`);return{default:e}},[],import.meta.url)).default,t=await dn(r===`A`?()=>import(`./card-a-minimal-Beg8-vFs.js`):r===`B`?()=>import(`./card-b-terminal-BxIeub6M.js`):r===`C`?()=>import(`./card-c-gradient-Dp20rmwu.js`):()=>import(`./card-d-dashboard-Dix1TgTv.js`),__vite__mapDeps([7,1]),import.meta.url),[n,i,a,o]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),s=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:i,weight:700,style:`normal`},{name:`JetBrains Mono`,data:a,weight:400,style:`normal`},{name:`JetBrains Mono`,data:o,weight:700,style:`normal`}],l=await e(t.render(_),{width:1080,height:1350,fonts:s}),f=d.current;if(!f)return;f.width=1080,f.height=1350;let p=f.getContext(`2d`);if(!p)return;let m=new Image;m.onload=()=>{p.drawImage(m,0,0),c(!1)},m.onerror=()=>{u(`Failed to render card image`),c(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(l)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareModal] renderPreview failed:`,e),u(t),c(!1)}},[r,_]);(0,W.useEffect)(()=>(clearTimeout(f.current),f.current=setTimeout(v,300),()=>clearTimeout(f.current)),[v]);let y=`claude-recall-session-${e.id.slice(0,8)}.png`,b=(0,W.useCallback)(e=>{let t=d.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),x=(0,W.useCallback)(()=>new Promise(e=>{let t=d.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),S=(0,W.useCallback)(()=>{b(async e=>{let t=await Xt({fileName:y,blob:e,title:`Claude Recall — session`,text:`${h} via Claude Recall`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[b,y,h]),C=(0,W.useCallback)(()=>{b(e=>{Qt(e,y),Q({message:`Saved to Downloads`,tone:`success`})})},[b,y]),w=(0,W.useCallback)(()=>{b(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[b]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Receipt`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:d,className:`w-full h-full`,style:{display:s||l?`none`:`block`}}),s&&!l&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),l&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:l})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-2 mb-3`,children:Nu.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.key),className:`flex flex-col items-center gap-1 rounded border p-1.5 transition-colors ${r===e.key?`border-accent bg-accent/10`:`border-line hover:border-fg-muted`}`,title:e.name,children:[(0,G.jsx)(`span`,{className:`w-full h-8 rounded`,style:{background:e.swatch},"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`text-[11px] ${r===e.key?`text-accent font-semibold`:`text-fg-muted`}`,children:e.name})]},e.key))}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:s,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:C,disabled:s,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:w,disabled:s,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:x,kind:`session`,title:h,description:`Built with Claude Recall — ${_.costDollars??``}`.trim(),caption:`${h} — built with Claude Recall`,disabled:s})]})})}function zu({size:e=16}){return(0,G.jsxs)(`svg`,{"aria-hidden":`true`,className:`${e===24?`h-6 w-6`:`h-4 w-4`} animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`3`}),(0,G.jsx)(`path`,{d:`M12 2a10 10 0 0 1 10 10`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`})]})}var Bu=150;function Vu({label:e,hint:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-bg-hover transition-colors`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-fg-muted text-[10px] mt-0.5 font-mono truncate`,children:t})]})}function Hu({sessionId:e,currentAlias:t,aliasSource:n,autoTitle:r,autoTitleSource:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(``),l=Kl(),u=ql(),d=(0,W.useRef)(null);(0,W.useEffect)(()=>{a&&(c(t??``),requestAnimationFrame(()=>d.current?.select()))},[a,t]);let f=async()=>{let n=s.trim();try{n?n!==t&&await l.mutateAsync({sessionId:e,alias:n}):t&&await u.mutateAsync(e)}catch(e){console.error(`alias save failed`,e)}finally{o(!1)}};if(a)return(0,G.jsx)(`input`,{ref:d,type:`text`,value:s,onChange:e=>c(e.target.value),onBlur:f,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),o(!1))},placeholder:`give this session a name…`,className:`bg-bg-elevated border border-accent rounded px-2 py-0.5 text-sm text-fg normal-case tracking-normal min-w-[14rem] focus:outline-none`,maxLength:80});let p=n===`auto`,m=t||r||null,h=m===r&&i===`agent`&&!!r,g=m??`Click to name this session`,_=(()=>{if(m===r&&r){let e=i??`heuristic`;return t?`${e} title · overriding ${p?`auto-alias`:`manual alias`} "${t}" — click to set a custom alias`:`auto-generated title (${e}) — click to override with a custom alias`}return t?`click to rename this session`:`give this session a custom name — click to edit`})();return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`group flex items-center gap-1.5 normal-case tracking-normal text-left min-w-0 px-2 py-0.5 rounded border border-dashed hover:border-accent transition-colors `+(m?`text-fg font-semibold border-transparent hover:bg-bg-hover`:`text-fg-muted italic border-line hover:text-fg hover:bg-bg-hover`),title:_,children:[h&&(0,G.jsx)(`span`,{className:`text-accent text-xs shrink-0`,"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`truncate`,children:g}),(0,G.jsx)(`span`,{className:`text-xs shrink-0 `+(m?`text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity`:`text-accent`),children:`✎`})]})}function Uu({sessionId:e,currentSource:t}){let n=K(),r=Ut(),i=Wt(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),d=J({mutationFn:()=>Z.generateAutoTitle(e),onSuccess:t=>{n.invalidateQueries({queryKey:[`session`,e]}),n.invalidateQueries({queryKey:[`sessions`]}),Q({message:t?.auto_title?`Generated title: "${t.auto_title}"`:`Title generated`,tone:`success`,duration:4e3})},onError:e=>{let t=e?.message??`unknown error`;Q({message:/403/.test(t)?`Agent titles disabled — click ✨ to enable`:`Title generation failed: ${t}`,tone:`error`,duration:6e3})}}),f=(0,W.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();u({top:t.bottom+4,right:Math.max(8,window.innerWidth-t.right)})},[]);if((0,W.useLayoutEffect)(()=>{if(!a){u(null);return}f()},[a,f]),(0,W.useEffect)(()=>{if(!a)return;let e=()=>f(),t=()=>f(),n=e=>{let t=e.target;c.current&&!c.current.contains(t)&&s.current&&!s.current.contains(t)&&o(!1)},r=e=>{e.key===`Escape`&&o(!1)};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`mousedown`,n),window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`mousedown`,n),window.removeEventListener(`keydown`,r)}},[a,f]),t===`agent`&&!d.isError)return null;let p=r.data?.agentEnabled??!1,m=d.isError&&/403/.test(d.error?.message??``),h=()=>{if(!p){o(e=>!e);return}d.mutate()},g=async()=>{try{await i.mutateAsync({agentEnabled:!0}),o(!1),d.mutate()}catch{}},_=d.isPending||i.isPending;return(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{ref:s,type:`button`,onClick:h,disabled:_||r.isLoading,className:`flex items-center gap-1 text-xs bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1 font-medium disabled:opacity-60 disabled:cursor-not-allowed normal-case tracking-normal`,title:p?`Generate a descriptive title with claude -p (uses your Claude Code subscription)`:`Enable agent-generated titles (requires confirmation) and generate one now`,children:_?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:`generating…`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:`Generate title`})]})}),a&&l&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:c,className:`fixed w-72 bg-bg-elevated border border-line rounded shadow-xl p-3 z-50 normal-case tracking-normal`,style:{top:l.top,right:l.right},role:`dialog`,"aria-label":`Enable agent-generated titles`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg mb-2 font-medium`,children:`Enable agent-generated titles?`}),(0,G.jsxs)(`p`,{className:`text-[11px] text-fg-dim leading-snug mb-3`,children:[`This shells out to your local `,(0,G.jsx)(`code`,{className:`text-fg`,children:`claude`}),` `,`CLI and uses your Claude Code subscription to summarise the first 20 user messages. Runs only when you click ✨. You can flip it off later via the`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`autoTitle.agentEnabled`}),` key in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`$RECALL_HOME/config.json`}),`.`]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!1),disabled:_,className:`text-[11px] text-fg-dim hover:text-fg px-2 py-1 rounded disabled:opacity-60`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:g,disabled:_,className:`text-[11px] bg-accent text-bg hover:bg-accent/90 px-2 py-1 rounded font-medium disabled:opacity-60`,children:i.isPending?`Enabling…`:`Enable and generate`})]}),i.isError&&(0,G.jsxs)(`p`,{className:`mt-2 text-[10px] text-role-user`,role:`alert`,children:[`Failed to enable: `,i.error.message]})]}),document.body),d.isError&&!a&&(0,G.jsx)(`div`,{className:`absolute top-full right-0 mt-1 text-[10px] text-role-user bg-bg-elevated border border-role-user/40 rounded px-2 py-1 shadow-lg z-20 whitespace-nowrap`,role:`alert`,children:m?`Agent titles disabled — click ✨ to enable`:`title generation failed`})]})}function Wu({sessionId:e,sessionCwd:t}){let n=Jl(e),[r,i]=(0,W.useState)(!1),a=Yl(r),o=Zl(),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),d=n.data?.linked??null,f=n.data?.suggested??[],p=new Set(f.map(e=>e.shell_pid)),[m,h]=(0,W.useState)(``),g=(0,W.useRef)(null),_=(0,W.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();u({top:t.bottom+4,right:Math.max(8,window.innerWidth-t.right)})},[]);(0,W.useLayoutEffect)(()=>{if(!r){u(null),h(``);return}_(),requestAnimationFrame(()=>g.current?.focus())},[r,_]),(0,W.useEffect)(()=>{if(!r)return;let e=()=>_(),t=()=>_(),n=e=>{let t=e.target;c.current&&!c.current.contains(t)&&s.current&&!s.current.contains(t)&&i(!1)},a=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`mousedown`,n),window.addEventListener(`keydown`,a),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`mousedown`,n),window.removeEventListener(`keydown`,a)}},[r,_]);let v=async t=>{try{await o.mutateAsync(t?{sessionId:e,shell_pid:t.shell_pid}:{sessionId:e,clear:!0}),i(!1),Q({message:t?`Linked to terminal "${t.tab_name}"`:`Terminal link cleared`,tone:`success`,duration:3500})}catch(e){Q({message:`Relink failed: ${e?.message??`unknown error`}`,tone:`error`,duration:5e3})}},y=d?`🔗 ${d.tab_name}`:n.isLoading?`🔗 …`:f.length>0?`🔗 ${f.length} suggested`:`🔗 unlinked`,b=d?`Currently linked to terminal "${d.tab_name}" (pid ${d.shell_pid}). Click to fix or unlink.`:f.length>0?`${f.length} terminals were open in this cwd when the session started. Click to pick one.`:`No terminal linked to this session. Click to pick one.`,x=a.data?.terminals??[],S=(t??``).replace(/\/+$/,``),C=e=>{if(!S||!e)return!1;let t=e.replace(/\/+$/,``);return t===S?!0:t.startsWith(S+`/`)||S.startsWith(t+`/`)},w=x.filter(e=>C(e.cwd)),T=m.toLowerCase().split(/\s+/).filter(Boolean),E=e=>{if(T.length===0)return!0;let t=e.toLowerCase();return T.every(e=>t.includes(e))},D=[...w].filter(e=>E(e.tab_name)).sort((e,t)=>{let n=S&&e.cwd&&e.cwd.replace(/\/+$/,``)===S?1:0,r=S&&t.cwd&&t.cwd.replace(/\/+$/,``)===S?1:0;return n===r?Date.parse(t.last_seen_at)-Date.parse(e.last_seen_at):r-n});return(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{ref:s,type:`button`,onClick:()=>i(e=>!e),className:`flex items-center gap-1 text-[11px] border rounded px-2 py-0.5 normal-case tracking-normal transition-colors `+(d?`border-line/60 text-fg-dim hover:text-fg hover:border-accent/40`:`border-dashed border-line text-fg-muted hover:text-fg hover:border-accent/40`),title:b,children:(0,G.jsx)(`span`,{className:`truncate max-w-[10rem]`,children:y})}),r&&l&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:c,className:`fixed w-[30rem] max-w-[calc(100vw-2rem)] bg-bg-elevated border border-line rounded shadow-xl z-50 normal-case tracking-normal`,style:{top:l.top,right:l.right},role:`dialog`,"aria-label":`Pick the right terminal for this session`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-semibold text-fg`,children:`Linked terminal`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-dim leading-snug mt-0.5 mb-2`,children:[d?`Currently: ${d.tab_name} (pid ${d.shell_pid})`:`No terminal linked.`,` `,`Pick a terminal to copy its name as this session's title.`]}),(0,G.jsx)(`input`,{ref:g,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search ${w.length} terminals in this project…`,className:`w-full text-[11px] bg-bg border border-line rounded px-2 py-1 focus:outline-none focus:border-accent normal-case tracking-normal`})]}),(0,G.jsxs)(`div`,{className:`max-h-72 overflow-y-auto`,children:[a.isLoading&&(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-fg-dim italic`,children:`Loading terminals…`}),!a.isLoading&&D.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-fg-dim italic`,children:x.length===0?(0,G.jsxs)(G.Fragment,{children:[`No terminals registered. Open a terminal and run `,(0,G.jsx)(`code`,{className:`text-fg`,children:`claude`}),`, or install the VS Code extension.`]}):w.length===0?(0,G.jsxs)(G.Fragment,{children:[`No terminals registered for this project. `,x.length,` terminal`,x.length===1?``:`s`,` `,x.length===1?`is`:`are`,` open elsewhere on your machine.`]}):(0,G.jsx)(G.Fragment,{children:`No terminals match your search.`})}),f.length>0&&!d&&(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-accent uppercase tracking-wider border-b border-accent/30 bg-accent/5`,children:`Suggested (open during session)`}),!d&&f.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v({shell_pid:e.shell_pid,tab_name:e.tab_name,cwd:e.cwd,opened_at:e.opened_at,last_seen_at:e.last_seen_at}),disabled:o.isPending,className:`block w-full text-left px-3 py-1.5 text-[11px] hover:bg-bg-hover transition-colors disabled:opacity-60 bg-accent/5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate text-fg font-medium`,children:e.tab_name||`(unnamed)`}),(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`time match`})]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted font-mono truncate mt-0.5`,children:[`pid `,e.shell_pid,` · open since `,new Date(e.opened_at).toISOString().slice(5,16).replace(`T`,` `)]})]},`sug-${e.shell_pid}`)),f.length>0&&!d&&D.length>0&&(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-fg-dim uppercase tracking-wider border-y border-line bg-bg-hover/30`,children:`All registered terminals`}),D.filter(e=>!p.has(e.shell_pid)||d).map(e=>{let t=S&&e.cwd&&e.cwd.replace(/\/+$/,``)===S,n=d?.shell_pid===e.shell_pid;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v(e),disabled:o.isPending,className:`block w-full text-left px-3 py-1.5 text-[11px] hover:bg-bg-hover transition-colors disabled:opacity-60 `+(n?`bg-accent/10`:``),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate text-fg font-medium`,children:e.tab_name||`(unnamed)`}),t&&(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`same cwd`}),n&&(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`✓ linked`})]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted font-mono truncate mt-0.5`,children:[`pid `,e.shell_pid,` · `,e.cwd??`(no cwd)`]})]},e.shell_pid)})]}),(0,G.jsxs)(`div`,{className:`border-t border-line px-3 py-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>v(null),disabled:o.isPending||!d,className:`text-[10px] text-fg-dim hover:text-role-user disabled:opacity-40 disabled:hover:text-fg-dim`,children:`Unlink`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!1),disabled:o.isPending,className:`text-[10px] text-fg-dim hover:text-fg`,children:`Close`})]})]}),document.body)]})}function Gu(e,t){if(!e.content_text||t.length===0)return!1;let n=e.content_text.toLowerCase();return t.every(e=>n.includes(e))}function Ku(e){return e.toLowerCase().split(/\s+/).filter(e=>e.length>1)}function qu(e){return e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e])}function Ju(e){if(!e)return!1;let t=e.slice(0,64);return t.startsWith(`**Tool result**`)||t.startsWith(`_(tool result was empty`)}var Yu=`recall:collapseToolCalls`,Xu=`recall:collapseToolResults`,Zu=`recall:sectionsHidden`;function Qu(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}function $u(e,t){try{localStorage.setItem(e,t?`1`:`0`)}catch{}}function ed(e){return(0,G.jsx)(eu,{scope:e.isCompareLeft?`compare-left`:e.isCompareRight?`compare-right`:`main`,children:(0,G.jsx)(td,{...e})})}function td({sessionId:e,targetMessageUuid:t,onTargetChange:n,searchQuery:r,isCompareLeft:i=!1,isCompareRight:a=!1,onExitCompare:o}){let s=tu(),c=ru(),l=s===`main`?Zu:`${Zu}:${s}`,[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(0),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!0),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),[,E]=Nn(),[D,O]=(0,W.useState)(()=>Qu(Yu)),[k,A]=(0,W.useState)(()=>Qu(Xu));(0,W.useEffect)(()=>{$u(Yu,D)},[D]),(0,W.useEffect)(()=>{$u(Xu,k)},[k]);let[j,M]=(0,W.useState)(()=>Qu(l));(0,W.useEffect)(()=>{$u(l,j)},[j,l]);let ee=Un(e),N=Yn(),te=(0,W.useRef)(null),P=(0,W.useRef)(new Map),F=(0,W.useRef)(null),{isPinned:I,togglePin:L}=ai();(0,W.useEffect)(()=>{if(!g)return;let e=e=>{F.current&&!F.current.contains(e.target)&&_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[g]);let R=q({queryKey:[`session`,e],queryFn:()=>Z.session(e),enabled:!!e,refetchInterval:5e3,refetchIntervalInBackground:!1,staleTime:2e3});(0,W.useEffect)(()=>{p(!1),te.current&&(te.current.scrollTop=0),P.current.clear()},[e]);let z=Xl(),B=(0,W.useRef)(new Set);(0,W.useEffect)(()=>{if(!e)return;let t=R.data;t&&(B.current.has(e)||t.session.alias||(B.current.add(e),z.mutateAsync(e).then(e=>{e.applied&&e.linked_tab_name&&Q({message:`Auto-linked to terminal "${e.linked_tab_name}"`,tone:`success`,duration:4e3})}).catch(()=>{})))},[e,R.data]);let V=(0,W.useMemo)(()=>R.data?R.data.messages.filter(e=>{if(!u&&e.is_sidechain===1)return!1;let t=!!(e.content_text&&e.content_text.trim()),n=!!(e.tool_names&&e.tool_names.length>0);return!(!t&&!n)}):[],[R.data,u]),ne=(0,W.useMemo)(()=>Ku(r),[r]),H=(0,W.useMemo)(()=>{if(ne.length===0)return[];let e=[];for(let t of V)Gu(t,ne)&&e.push(t.uuid);return e},[V,ne]),re=(0,W.useMemo)(()=>f?V:V.slice(0,Bu),[V,f]),ie=Kc({count:re.length,getScrollElement:()=>te.current,estimateSize:()=>220,overscan:6,getItemKey:e=>re[e]?.uuid??e});(0,W.useEffect)(()=>{t&&V.findIndex(e=>e.uuid===t)>=Bu&&p(!0)},[t,V]),(0,W.useEffect)(()=>{if(!t)return;let e=re.findIndex(e=>e.uuid===t);if(e<0)return;let n=requestAnimationFrame(()=>{ie.scrollToIndex(e,{align:`center`,behavior:`smooth`}),h(e=>e+1)});return()=>cancelAnimationFrame(n)},[t,re,ie,f]),(0,W.useEffect)(()=>{let e=te.current;if(!e)return;let t=()=>{x(e.scrollHeight-(e.scrollTop+e.clientHeight)<120)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[e,re.length]);let ae=(0,W.useCallback)(()=>{re.length!==0&&(!f&&V.length>re.length&&p(!0),ie.scrollToIndex(re.length-1,{align:`end`,behavior:`smooth`}))},[re.length,ie,f,V.length]),oe=(0,W.useCallback)(()=>{te.current&&te.current.scrollTo({top:0,behavior:`smooth`})},[]);(0,W.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.key===`End`?(e.preventDefault(),ae()):e.key===`Home`&&(e.preventDefault(),oe()))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,ae,oe]);let se=t&&H.includes(t)?H.indexOf(t):-1,ce=(0,W.useCallback)(e=>{H.length!==0&&n(H[((se===-1?e===1?-1:0:se)+e+H.length)%H.length])},[se,H,n]);if((0,W.useEffect)(()=>{if(H.length===0)return;let e=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.key===`n`?(e.preventDefault(),ce(e.shiftKey?-1:1)):e.key===`p`&&(e.preventDefault(),ce(-1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ce,H.length]),!e)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-8`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-sm mb-2`,children:`No session selected`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs`,children:`Pick a project on the left, then a session from the middle. Or type in the search box above — your data never leaves this machine.`})]})})});if(R.isLoading)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-fg-muted text-sm`,children:`Loading session…`})});if(R.isError)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-center text-role-user text-sm`,children:[`Failed: `,R.error.message]})});let{session:U,messages:le}=R.data,ue=I(U.id),de=()=>{let e=[];e.push(`# Claude Code session · ${U.project_name}`),e.push(``),e.push(`- session id: \`${U.id}\``),U.started_at&&e.push(`- started: ${U.started_at}`),U.git_branch&&e.push(`- branch: \`${U.git_branch}\``),e.push(`- messages: ${le.length}`),e.push(``),e.push(`---`),e.push(``);for(let t of V){let n=t.role??t.type,r=t.timestamp?` \`${t.timestamp}\``:``;e.push(`## ${n}${r}`),t.tool_names&&e.push(`\n_tools: ${t.tool_names}_\n`),t.content_text&&e.push(t.content_text),e.push(``)}navigator.clipboard.writeText(e.join(`
|
|
93
|
+
`)[0].slice(0,120)}),!o&&!d&&(0,G.jsx)(`span`,{className:`text-fg-muted normal-case tracking-normal italic`,children:`none yet — click to add`})]}),w&&o&&(0,G.jsxs)(`span`,{className:`text-fg-muted normal-case tracking-normal font-mono`,children:[`updated `,w.toLocaleString()]})]}),d&&(0,G.jsx)(`div`,{className:`px-5 pb-3`,children:p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`textarea`,{ref:y,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),b()):e.key===`Escape`&&(e.preventDefault(),x())},placeholder:`Your markdown notes for this session…\\n\\nCmd/Ctrl+Enter saves. Esc cancels.`,rows:8,className:`w-full bg-bg-elevated border border-line rounded p-3 text-sm text-fg font-mono leading-relaxed focus:outline-none focus:border-accent placeholder:text-fg-muted resize-y`,spellCheck:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[h.length.toLocaleString(),` chars`,C&&(0,G.jsx)(`span`,{className:`text-accent ml-2`,children:`· unsaved`}),(0,G.jsxs)(`span`,{className:`ml-3 text-fg-muted`,children:[`mirrored to `,(0,G.jsxs)(`span`,{className:`font-mono`,children:[`~/.recall/notes/`,e.slice(0,8),`.md`]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:x,className:`px-3 py-1 text-fg-muted hover:text-fg`,children:`cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:b,disabled:!C||n.isPending,className:`px-3 py-1 rounded border border-accent bg-accent/10 text-accent font-medium hover:bg-accent hover:text-bg disabled:opacity-50 disabled:cursor-not-allowed`,children:n.isPending?`saving…`:`save`})]})]})]}):(0,G.jsxs)(G.Fragment,{children:[o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded p-3 max-h-72 overflow-y-auto`,children:(0,G.jsx)(Ws,{text:a})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-3 mt-2`,children:[(0,G.jsx)(au,{hasSynopsis:l,pending:r.isPending,onClick:S}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`text-xs text-accent hover:underline`,children:`✎ edit`})]})]}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`w-full border border-dashed border-line rounded p-4 text-sm text-fg-muted hover:border-accent hover:text-fg-dim transition-colors`,children:`+ add a note for this session`}),(0,G.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,G.jsx)(au,{hasSynopsis:l,pending:r.isPending,onClick:S})})]}),l&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 text-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex items-center gap-1.5 text-fg-muted hover:text-fg transition-colors`,title:_?`expand auto-synopsis`:`collapse auto-synopsis`,"aria-expanded":!_,children:[(0,G.jsx)(`span`,{className:$(`transition-transform`,!_&&`rotate-90`),"aria-hidden":`true`,children:`▸`}),(0,G.jsx)(`span`,{className:`text-accent`,"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`font-medium uppercase tracking-wider`,children:`Auto-synopsis`}),T&&(0,G.jsxs)(`span`,{className:`text-fg-muted normal-case tracking-normal font-mono`,children:[`· generated `,T.toLocaleString()]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`text-xs text-fg-muted hover:text-fg`,title:_?`expand auto-synopsis`:`collapse auto-synopsis`,children:_?`▸ expand`:`▾ collapse`}),(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:r.isPending,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`run claude -p again over the latest transcript`,children:r.isPending?`regenerating…`:`↻ regenerate`})]})]}),!_&&(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-accent/40 rounded p-3 border-l-2 max-h-96 overflow-y-auto`,children:(0,G.jsx)(Ws,{text:s??``})})]})]})})]})}function au({hasSynopsis:e,pending:t,onClick:n}){return e?null:(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:t,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`reads this session's transcript and writes a markdown synopsis below your note`,children:t?`generating…`:`✨ generate synopsis`})}function ou({sessionId:e,tags:t}){let[n,r]=(0,W.useState)(!1),i=On(),[,a]=Nn();return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 normal-case tracking-normal`,children:[t.map(t=>(0,G.jsxs)(`span`,{className:`group inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-role-tool/15 text-role-tool text-xs font-medium border border-role-tool/30`,children:[(0,G.jsxs)(`span`,{children:[`#`,t]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i.mutate({sessionId:e,tag:t}),className:`opacity-60 hover:opacity-100 transition-opacity`,title:`remove #${t}`,children:`×`})]},t)),n?(0,G.jsx)(ci,{sessionId:e,existingTags:t,onDone:()=>r(!1),variant:`bar`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:$(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-dashed text-xs transition-colors`,t.length===0?`border-line text-fg-muted hover:text-fg hover:border-accent`:`border-line/50 text-fg-muted opacity-60 hover:opacity-100 hover:text-fg`),title:`add a tag — typing #tagname in the search box also filters by tag`,children:`+ tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a({view:`help`,helpSection:`taxonomy`}),className:`inline-flex items-center justify-center w-4 h-4 rounded-full text-[10px] text-fg-muted/70 hover:text-accent hover:bg-accent/10 transition-colors`,title:`Tag vs Collection vs Alias vs Note — what's the difference?`,"aria-label":`Tag vs other organizers — what's the difference?`,children:`?`})]})}function su({sessionId:e}){let t=wt(),n=li(),r=K(),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1);ui(!!n.error,()=>n.reset());let c=()=>{let r=t.data;if(!r||!r.enabled){a(!0);return}if(r.backend===`api`&&!r.hasApiKey){a(!0);return}if(r.backend===`mcp`){s(!0);return}n.start({sessionIds:[e]})},l=()=>{r.invalidateQueries({queryKey:[`sessions`]}),r.invalidateQueries({queryKey:[`session`,e]}),r.invalidateQueries({queryKey:[`tags`]})},u=async e=>{let t=await n.apply(e);if(t&&t.applied>0){l();let n=e.reduce((e,t)=>e+t.tags.length,0);Q({message:`Applied ${t.applied} tag${t.applied===1?``:`s`} to this session.`,tone:`success`,duration:1e4,action:{label:`Undo`,onClick:()=>{d(e,n)}}})}else t&&Q({message:`Nothing to apply — all selected tags were already present.`,tone:`info`});return t},d=async(e,t)=>{let n=0;for(let t of e)for(let e of t.tags)try{await Z.removeSessionTag(t.sessionId,e),n+=1}catch(n){console.error(`undo: remove failed`,t.sessionId,e,n)}l(),Q({message:`Undone — removed ${n} of ${t} tag${t===1?``:`s`}.`,tone:`info`})},f=async()=>{if(!n.snapshot)return;let e=n.snapshot.results.filter(e=>e.error).map(e=>e.sessionId);e.length!==0&&(n.reset(),await n.start({sessionIds:e}))};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`inline-flex items-center rounded border border-accent/40 bg-accent/10 overflow-hidden`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:c,disabled:!!n.id,className:`text-xs text-accent hover:bg-accent hover:text-bg px-2 py-1 font-medium border-r border-accent/40 disabled:opacity-50 disabled:cursor-wait`,title:t.data?.enabled?`auto-tag this session with an LLM`:`configure auto-tagging`,children:n.id?`🏷 scanning…`:`🏷 auto-tag`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`text-xs text-accent hover:bg-accent hover:text-bg px-1.5 py-1`,title:`auto-tag settings (enable autopilot, install MCP, change model, paste API key)`,"aria-label":`auto-tag settings`,children:`⚙`})]}),(0,G.jsx)(fi,{open:i,onClose:()=>a(!1)}),(0,G.jsx)(hi,{open:o,sessionId:e,onClose:()=>{s(!1),Q({message:`MCP scan triggered. New tags will appear on this session as your Claude Code agent writes them.`,tone:`info`,duration:8e3})},onOpenSettings:()=>{s(!1),a(!0)}}),n.error&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/40 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-role-user/60 rounded-lg w-[440px] shadow-xl p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-role-user font-semibold mb-2`,children:`Scan failed`}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-3 break-words`,children:n.error}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.reset(),className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Close`})})]})}),(0,G.jsx)(pi,{open:!!n.id&&!n.error,snapshot:n.snapshot,onApply:u,onCancel:()=>void n.cancel(),onClose:()=>n.reset(),onRetryFailed:()=>void f()})]})}function cu({sessionId:e}){let t=q({queryKey:[`sessionStats`,e],queryFn:()=>Z.getSessionStats(e),staleTime:3e4}).data;return!t||t.totalTokens===0?null:(0,G.jsxs)(`a`,{href:`#/stats`,className:`normal-case tracking-normal shrink-0 inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-dim hover:text-accent border border-line hover:border-accent/60 rounded px-2 py-0.5 transition-colors`,title:`session cost — derived from token counts (pricing may change)\n\ninput: ${t.inputTokens.toLocaleString()}\noutput: ${t.outputTokens.toLocaleString()}\ncache write: ${t.cacheCreateTokens.toLocaleString()}\ncache read: ${t.cacheReadTokens.toLocaleString()}\ntotal: ${t.totalTokens.toLocaleString()}\n\nmodel: ${t.primaryModelLabel}${t.primaryModel?` (${t.primaryModel})`:``}`+(t.byModel.length>1?`\n\n${t.byModel.length} models used — click to view dashboard`:``),children:[(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:t.display.dollars}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsxs)(`span`,{children:[t.display.tokens,` tok`]}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:t.primaryModelLabel})]})}function lu({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`sessionCommits`,e],queryFn:()=>Z.getSessionCommits(e),staleTime:3e4}).data?.commits??[];if(r.length===0)return null;let i=`${r.length} commit${r.length===1?``:`s`}`;return(0,G.jsxs)(`div`,{className:`px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal text-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex items-center gap-1.5 text-fg-muted hover:text-fg`,title:`commits authored during this session`,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`font-medium text-fg-dim`,children:`⎇`}),(0,G.jsxs)(`span`,{children:[i,` authored during this session`]})]}),t&&(0,G.jsx)(`ul`,{className:`mt-2 space-y-1.5 pl-5`,children:r.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px]`,children:[(0,G.jsx)(`code`,{className:`font-mono text-accent shrink-0`,title:e.commit_sha,children:e.commit_sha.slice(0,8)}),(0,G.jsx)(`span`,{className:`text-fg truncate min-w-0 flex-1`,children:e.subject??(0,G.jsx)(`span`,{className:`italic text-fg-muted`,children:`(no subject)`})}),e.committed_at&&(0,G.jsx)(`time`,{className:`text-fg-muted shrink-0 font-mono`,children:e.committed_at.replace(`T`,` `).slice(0,19)})]},e.commit_sha))})]})}function uu(e,t){e.invalidateQueries({queryKey:[`threads`]}),t&&e.invalidateQueries({queryKey:[`thread`,t]}),e.invalidateQueries({queryKey:[`sessionThreads`]})}function du(e=!1){return q({queryKey:[`threads`,{archived:e}],queryFn:()=>Z.listThreads(e),staleTime:1e4})}function fu(e){return q({queryKey:[`thread`,e],queryFn:()=>Z.getThread(e),enabled:!!e,staleTime:1e4})}function pu(e){return q({queryKey:[`sessionThreads`,e],queryFn:()=>Z.threadsForSession(e),enabled:!!e,staleTime:3e4})}function mu(){let e=K();return J({mutationFn:e=>Z.createThread(e),onSuccess:t=>uu(e,t.thread.id)})}function hu(){let e=K();return J({mutationFn:({id:e,patch:t})=>Z.patchThread(e,t),onSuccess:t=>uu(e,t.thread.id)})}function gu(){return q({queryKey:[`thread-folders`],queryFn:()=>Z.listThreadFolders(),staleTime:3e4})}function _u(){let e=K();return J({mutationFn:e=>Z.createThreadFolder(e),onSuccess:()=>e.invalidateQueries({queryKey:[`thread-folders`]})})}function vu(){let e=K();return J({mutationFn:e=>Z.deleteThreadFolder(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`thread-folders`]}),e.invalidateQueries({queryKey:[`threads`]})}})}function yu(){let e=K();return J({mutationFn:e=>Z.reorderThreadFolders(e),onSuccess:()=>e.invalidateQueries({queryKey:[`thread-folders`]})})}function bu(){let e=K();return J({mutationFn:({threadId:e,sessionId:t,parentSessionId:n,role:r})=>Z.addSessionToThread(e,{sessionId:t,parentSessionId:n,role:r}),onSuccess:(t,n)=>uu(e,n.threadId)})}function xu(){let e=K();return J({mutationFn:({threadId:e,sessionId:t})=>Z.removeSessionFromThread(e,t),onSuccess:(t,n)=>uu(e,n.threadId)})}function Su(){let e=K();return J({mutationFn:({threadId:e,sessionId:t,parentSessionId:n})=>Z.setThreadSessionParent(e,t,n),onSuccess:(t,n)=>uu(e,n.threadId)})}function Cu(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)):[...e]}function wu({sessionId:e}){let[,t]=Nn(),n=pu(e),r=du(),i=mu(),a=bu(),o=xu(),[s,c]=(0,W.useState)(!1);nu(c);let[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(``),p=n.data?.threads??[],m=new Set(p.map(e=>e.id)),h=(r.data?.threads??[]).filter(e=>!m.has(e.id));return(0,G.jsxs)(`div`,{className:`px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s&&l&&u(!1),c(e=>!e)},className:`flex items-center gap-1.5 text-fg-muted hover:text-fg text-xs`,title:`Threads group a session with related sessions (for example, a planning session plus the execution sessions it spawned).`,"aria-expanded":s,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:s?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`uppercase tracking-wider`,children:`🧵 Threads`}),p.length>0&&(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] font-mono tabular-nums`,children:p.length})]}),s&&(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-start gap-1.5`,children:[p.map(n=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent/10 text-accent text-xs border border-accent/30`,title:`${n.session_count} session${n.session_count===1?``:`s`} in this thread`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:`threads`,thread:n.id}),className:`hover:underline`,title:`open the "${n.name}" thread graph`,children:n.name}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>o.mutate({threadId:n.id,sessionId:e}),className:`text-fg-muted hover:text-role-user text-[11px]`,title:`unlink this session from the thread (thread keeps existing)`,children:`✕`})]},n.id)),l?(0,G.jsx)(Tu,{sessionId:e,available:h,activeCount:p.length,newName:d,setNewName:f,creating:i.isPending,adding:a.isPending,onPickExisting:t=>{a.mutate({threadId:t,sessionId:e},{onSuccess:()=>u(!1)})},onCreate:()=>{let t=d.trim();t&&i.mutate({name:t,originSessionId:e},{onSuccess:()=>{f(``),u(!1)}})},onCancel:()=>{u(!1),f(``)}}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs text-accent hover:underline`,title:`Link this session into an existing thread, or create a new one with this session as the origin (reverse path is + Add session from the thread detail page).`,children:`+ Add to thread`})]})]})}function Tu({available:e,activeCount:t,newName:n,setNewName:r,creating:i,adding:a,onPickExisting:o,onCreate:s,onCancel:c}){let[l,u]=(0,W.useState)(``),d=(0,W.useMemo)(()=>Cu(e,l),[e,l]),f=l.trim().length>0;return(0,G.jsxs)(`div`,{className:`w-full mt-1 rounded border border-line bg-bg-elevated p-2 space-y-2 border-l-2 border-l-accent/60`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider font-medium text-fg-muted`,children:`Link to a thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`text-[11px] text-fg-muted hover:text-fg`,title:`Close the picker without linking this session to any thread.`,children:`cancel`})]}),e.length>0&&(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d.length===1?(e.preventDefault(),o(d[0].id)):e.key===`Escape`&&(e.preventDefault(),l?u(``):c())},placeholder:`search threads by name`,"aria-label":`Search threads by name`,className:`w-full text-xs bg-bg border border-line rounded px-2 py-1`}),e.length>0?d.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted mb-1`,children:f?`${d.length} match${d.length===1?``:`es`}: click to link this session.`:`Click an existing thread to link this session into it:`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),disabled:a,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full border border-line hover:border-accent hover:bg-accent/10 text-xs disabled:opacity-50`,title:`Link this session into "${e.name}" (${e.session_count} session${e.session_count===1?``:`s`}, ${e.closed_at?`closed`:`open`})`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:e.session_count})]},e.id))})]}):(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted italic`,children:[`No threads match "`,l.trim(),`". Create a new one below.`]}):(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted italic`,children:t>0?`No other threads available. Create a new one below.`:`No threads exist yet. Create the first one below.`}),(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s()},className:`flex items-center gap-1.5 pt-1 border-t border-line`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-muted`,title:`Creating a new thread with this session as the first member (origin)`,children:`Or create new:`}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`thread name (this session becomes the origin)`,className:`flex-1 text-xs bg-bg border border-line rounded px-2 py-1`}),(0,G.jsx)(`button`,{type:`submit`,disabled:!n.trim()||i,className:`text-xs px-2 py-1 rounded bg-accent text-bg font-medium disabled:opacity-50`,title:`Create a new thread with this session set as the origin`,children:`Create`})]})]})}function Eu({content:e,children:t,side:n=`bottom`,delayMs:r=300,maxWidth:i=300}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(null);(0,W.useEffect)(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);let f=()=>{d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>o(!0),r)},p=()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null,o(!1),c(null)};return(0,W.useLayoutEffect)(()=>{if(!a)return;let e=l.current,t=u.current;if(!e||!t)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),o=n,s=window.innerHeight-r.bottom,d=r.top;o===`bottom`&&s<i.height+8&&d>s?o=`top`:o===`top`&&d<i.height+8&&s>d&&(o=`bottom`);let f=o===`bottom`?r.bottom+8:r.top-i.height-8,p=r.left+r.width/2,m=p-i.width/2;m=Math.max(8,Math.min(m,window.innerWidth-i.width-8));let h=p-m;c({top:f,left:m,arrowLeft:h,side:o})},[a,n,e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{ref:l,className:`relative inline-flex`,onMouseEnter:f,onMouseLeave:p,onFocus:f,onBlur:p,children:t}),a&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:u,role:`tooltip`,style:{position:`fixed`,top:s?.top??-9999,left:s?.left??-9999,width:i,visibility:s?`visible`:`hidden`,zIndex:9999},className:`pointer-events-none px-3 py-2 rounded-md bg-bg-elevated border border-accent/50 shadow-[0_8px_24px_-8px_rgba(138,120,255,0.45),0_2px_8px_rgba(0,0,0,0.4)] text-[11px] leading-snug text-fg-muted normal-case tracking-normal whitespace-normal text-left`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-accent/70`}),(0,G.jsx)(`div`,{className:`pl-1.5`,children:e}),s&&(0,G.jsx)(`span`,{"aria-hidden":`true`,style:{position:`absolute`,left:s.arrowLeft-5,...s.side===`bottom`?{top:-5}:{bottom:-5}},className:`w-2.5 h-2.5 rotate-45 bg-bg-elevated border border-accent/50 `+(s.side===`bottom`?`border-r-0 border-b-0`:`border-l-0 border-t-0`)})]}),document.body)]})}function Du(e,t){return e.length<=t?{visible:e.slice(),overflow:0}:{visible:e.slice(0,t),overflow:e.length-t}}var Ou=12;function ku({sessionId:e}){let[,t]=Nn(),n=K(),[r,i]=(0,W.useState)(!1),a=q({queryKey:[`session-links`,e,`wiki_link`],queryFn:()=>Z.sessionLinks(e),enabled:!!e}),o=J({mutationFn:e=>Z.removeLink(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`session-links`,e,`wiki_link`]})},onError:e=>{Q({message:`Unlink failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),s=a.data?.links??[];if(a.isLoading||s.length===0)return null;let{visible:c,overflow:l}=r?{visible:s,overflow:0}:Du(s,Ou);return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start gap-1.5 px-5 py-2 border-b border-line bg-bg/60 normal-case tracking-normal`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mr-1 pt-0.5`,title:`Wiki-style links between sessions. Right-click any session in the list to add one.`,children:`🔗 Linked`}),(0,G.jsxs)(`span`,{className:`text-[10px] text-fg-muted pt-0.5`,children:[s.length,` `,s.length===1?`session`:`sessions`]}),c.map(e=>(0,G.jsx)(Au,{link:e,onNavigate:()=>t({session:e.otherSessionId,msg:null}),onUnlink:()=>o.mutate(e.linkId)},e.linkId)),l>0&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex items-center px-2 py-0.5 rounded-full border border-dashed border-line/60 text-[10px] text-fg-muted hover:text-fg hover:border-accent`,title:`Show ${l} more linked session${l===1?``:`s`}`,children:[`+`,l,` more`]})]})}function Au({link:e,onNavigate:t,onUnlink:n}){let r=e.direction===`outbound`?`→`:`←`;return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-accent/10 text-accent text-xs border border-accent/30`,title:e.direction===`outbound`?`${e.title} (this session links to it)`:`${e.title} (this session is linked from it)`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`text-[10px] text-accent/70`,children:r}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`hover:underline truncate max-w-[18rem]`,title:`open ${e.title}`,children:e.title}),e.project&&(0,G.jsx)(`span`,{className:`text-[10px] text-fg-muted/80 italic truncate max-w-[8rem]`,children:e.project}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-role-user text-[10px]`,title:`unlink from "${e.title}"`,"aria-label":`unlink from ${e.title}`,children:`✕`})]})}function ju({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`neighborhood`,e],queryFn:()=>Z.neighborhood(e,{budget:4e3,scoring:`hybrid`}),enabled:t,staleTime:60*1e3});function i(){r.data?.bundle&&(navigator.clipboard?.writeText(r.data.bundle),Q({message:`Neighborhood bundle copied — paste into Claude`,tone:`info`}))}return(0,G.jsxs)(`section`,{className:`border-b border-line`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-3 px-5 py-3 cursor-pointer hover:bg-bg-hover/40`,onClick:()=>n(e=>!e),children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] uppercase tracking-wider w-3`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`Neighborhood`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:`parents · children · citations · similar (bundle for piping into Claude)`}),r.data&&(0,G.jsxs)(`span`,{className:`ml-auto text-fg-muted text-xs font-mono tabular-nums`,children:[r.data.budgetUsed,` / `,r.data.budgetUsed+r.data.budgetRemaining,` tokens`]})]}),t&&(0,G.jsxs)(`div`,{className:`px-5 pb-4 space-y-3`,children:[r.isLoading&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`h-3 w-3 rounded-full border-2 border-accent border-t-transparent animate-spin`}),`Assembling neighborhood…`]}),r.isError&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user text-xs`,children:[`Failed to load neighborhood:`,` `,r.error instanceof Error?r.error.message:`unknown error`]}),r.data&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`px-2.5 py-1 rounded border border-line hover:bg-bg-hover`,title:`Copy the markdown bundle. Paste into a fresh Claude chat to seed it with the related context.`,children:`Copy bundle`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`Or in your terminal: `,(0,G.jsxs)(`code`,{className:`text-fg`,children:[`recall neighborhood `,e.slice(0,8),` | claude`]})]})]}),r.data.truncated.length>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[r.data.truncated.length,` ref(s) didn't fit the budget. Increase the budget on the CLI for the full bundle.`]}),(0,G.jsx)(`pre`,{className:`bg-bg-elevated border border-line rounded p-3 text-xs leading-relaxed text-fg whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:r.data.bundle||"(empty bundle — this session has no inferred neighborhood yet. Run `recall infer-l1` or `recall infer-citations` for this project.)"})]})]})]})}function Mu({sessionId:e}){let[t,n]=(0,W.useState)(!1);nu(n);let r=q({queryKey:[`verification-detail`,e],queryFn:()=>Z.getVerificationDetail(e),staleTime:6e4});if(!r.data||r.data.status===`neutral`)return null;let{status:i,evidence:a}=r.data,o=[[`File writes`,a.fileWrites],[`Test runs`,a.testRuns],[`Git commits`,a.commits],[`Build success`,a.buildSuccess]],s=o.filter(([,e])=>e).length;return(0,G.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-2 text-xs overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 p-3 hover:bg-bg-hover/40 transition-colors text-left`,onClick:()=>n(e=>!e),"aria-expanded":t,children:[(0,G.jsx)(`span`,{className:`text-fg-muted text-[10px] uppercase tracking-wider w-3`,children:t?`▾`:`▸`}),(0,G.jsx)(`span`,{className:`font-medium ${i===`verified`?`text-green-500`:`text-yellow-500`}`,children:i===`verified`?`Verified`:`Unverified`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`completion evidence`}),(0,G.jsxs)(`span`,{className:`ml-auto text-fg-muted text-[10px] font-mono tabular-nums`,children:[s,` / `,o.length]})]}),t&&(0,G.jsx)(`div`,{className:`px-3 pb-3 grid grid-cols-2 gap-1`,children:o.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:t?`text-green-500`:`text-fg-muted/40`,children:t?`✓`:`✗`}),(0,G.jsx)(`span`,{className:t?`text-fg`:`text-fg-muted`,children:e})]},e))})]})}var Nu=[{key:`A`,name:`Minimal`,swatch:`#1a1b1e`},{key:`B`,name:`Terminal`,swatch:`#0d0d0f`},{key:`C`,name:`Gradient`,swatch:`linear-gradient(135deg,#b1370f,#fbbf24)`},{key:`D`,name:`Dashboard`,swatch:`#f6f7f9`}],Pu=[/^~\//,/^\/Users\//,/^\/home\//,/^[A-Za-z]:\\/];function Fu(e,t=80){if(!e)return null;let n=e.replace(/\x1b\[[0-9;]*[A-Za-z]/g,``).trim();if(!n||Pu.some(e=>e.test(n)))return null;let r=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,``).replace(/\s+/g,` `).trim();return r?r.length<=t?r:r.slice(0,t-1).trimEnd()+`…`:null}function Iu(e){for(let t of[e.alias,e.auto_title,e.first_user_message]){let e=Fu(t);if(e)return e}return e.id.slice(0,8)}function Lu(e,t){if(!e||!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(!Number.isFinite(n)||n<=0)return null;let r=Math.round(n/6e4);if(r<1)return`< 1 min`;if(r<60)return`${r} min`;let i=Math.floor(r/60),a=r%60;return a===0?`${i}h`:`${i}h ${a}m`}function Ru({session:e,onClose:t}){let n=(0,W.useMemo)(()=>Fu(e.first_user_message,120)??``,[e.first_user_message]),[r,i]=(0,W.useState)(`A`),[a,o]=(0,W.useState)(n),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(null),d=(0,W.useRef)(null),f=(0,W.useRef)(),p=q({queryKey:[`share-stats`,e.id],queryFn:()=>Z.shareStats(e.id),staleTime:6e4}),m=q({queryKey:[`session-stats`,e.id],queryFn:()=>Z.getSessionStats(e.id),staleTime:6e4}),h=(0,W.useMemo)(()=>Iu(e),[e]),g=(0,W.useMemo)(()=>Lu(e.started_at,e.ended_at),[e.started_at,e.ended_at]),_=(0,W.useMemo)(()=>({sessionTitle:h,sessionDate:e.started_at??new Date().toISOString(),recallDate:new Date().toISOString(),costDollars:m.data?.display.dollars??`$—`,durationLabel:g,model:m.data?.primaryModelLabel??null,cachedTokens:m.data?.cacheReadTokens??0,messageCount:e.message_count,filesReferenced:p.data?.filesReferenced??0,toolCallCount:p.data?.toolCallCount??0,verdict:a}),[h,e.started_at,g,m.data,e.message_count,p.data,a]),v=(0,W.useCallback)(async()=>{c(!0),u(null);try{let e=(await dn(async()=>{let{default:e}=await import(`./dist-C3F6ixrp.js`);return{default:e}},[],import.meta.url)).default,t=await dn(r===`A`?()=>import(`./card-a-minimal-Beg8-vFs.js`):r===`B`?()=>import(`./card-b-terminal-BxIeub6M.js`):r===`C`?()=>import(`./card-c-gradient-Dp20rmwu.js`):()=>import(`./card-d-dashboard-Dix1TgTv.js`),__vite__mapDeps([7,1]),import.meta.url),[n,i,a,o]=await Promise.all([fetch(new URL(``+new URL(`inter-latin-400-normal-CyCys3Eg.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`inter-latin-700-normal-BLAVimhd.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-400-normal-6-qcROiO.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer()),fetch(new URL(``+new URL(`jetbrains-mono-latin-700-normal-D3wTyLJW.woff`,import.meta.url).href,``+import.meta.url).href).then(e=>e.arrayBuffer())]),s=[{name:`Inter`,data:n,weight:400,style:`normal`},{name:`Inter`,data:i,weight:700,style:`normal`},{name:`JetBrains Mono`,data:a,weight:400,style:`normal`},{name:`JetBrains Mono`,data:o,weight:700,style:`normal`}],l=await e(t.render(_),{width:1080,height:1350,fonts:s}),f=d.current;if(!f)return;f.width=1080,f.height=1350;let p=f.getContext(`2d`);if(!p)return;let m=new Image;m.onload=()=>{p.drawImage(m,0,0),c(!1)},m.onerror=()=>{u(`Failed to render card image`),c(!1)},m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(l)))}`}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ShareModal] renderPreview failed:`,e),u(t),c(!1)}},[r,_]);(0,W.useEffect)(()=>(clearTimeout(f.current),f.current=setTimeout(v,300),()=>clearTimeout(f.current)),[v]);let y=`claude-recall-session-${e.id.slice(0,8)}.png`,b=(0,W.useCallback)(e=>{let t=d.current;t&&t.toBlob(t=>{t&&e(t)},`image/png`)},[]),x=(0,W.useCallback)(()=>new Promise(e=>{let t=d.current;if(!t)return e(null);t.toBlob(t=>e(t??null),`image/png`)}),[]),S=(0,W.useCallback)(()=>{b(async e=>{let t=await Xt({fileName:y,blob:e,title:`Claude Recall — session`,text:`${h} via Claude Recall`,url:`https://clauderecall.com`});t===`shared`?Q({message:`Shared`,tone:`success`}):t===`download`?Q({message:`Card downloaded`,tone:`success`}):t===`cancelled`||Q({message:`Sharing not supported in this browser`,tone:`error`})})},[b,y,h]),C=(0,W.useCallback)(()=>{b(e=>{Qt(e,y),Q({message:`Saved to Downloads`,tone:`success`})})},[b,y]),w=(0,W.useCallback)(()=>{b(async e=>{let t=await $t(e);Q({message:t?`Image copied — paste anywhere`:`Clipboard not available; use Save instead`,tone:t?`success`:`error`})})},[b]);return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,G.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 flex items-center justify-center`,onClick:t,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg shadow-xl w-[520px] max-w-[95vw] max-h-[92vh] overflow-y-auto p-5`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg-muted uppercase tracking-wider`,children:`Share Receipt`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-accent/15 text-accent border border-accent/30`,children:`beta`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-fg`,"aria-label":`close`,children:`✕`})]}),(0,G.jsxs)(`div`,{className:`relative mb-4 rounded-lg overflow-hidden border border-line bg-bg`,style:{aspectRatio:`1080/1350`},children:[(0,G.jsx)(`canvas`,{ref:d,className:`w-full h-full`,style:{display:s||l?`none`:`block`}}),s&&!l&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-muted text-sm`,children:`Rendering…`}),l&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-red-400 text-xs px-4 text-center`,children:l})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-2 mb-3`,children:Nu.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i(e.key),className:`flex flex-col items-center gap-1 rounded border p-1.5 transition-colors ${r===e.key?`border-accent bg-accent/10`:`border-line hover:border-fg-muted`}`,title:e.name,children:[(0,G.jsx)(`span`,{className:`w-full h-8 rounded`,style:{background:e.swatch},"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`text-[11px] ${r===e.key?`text-accent font-semibold`:`text-fg-muted`}`,children:e.name})]},e.key))}),(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`label`,{className:`block text-[10px] uppercase tracking-wider text-fg-muted mb-1`,children:`verdict (optional, ≤120 chars)`}),(0,G.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`add your take…`,className:`w-full px-3 py-2 rounded border border-line bg-bg text-fg text-sm focus:outline-none focus:ring-2 focus:ring-accent/60`,maxLength:120})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[Zt()&&(0,G.jsx)(`button`,{type:`button`,onClick:S,disabled:s,className:`w-full px-4 py-2.5 rounded bg-accent text-white text-sm font-semibold hover:bg-accent/90 transition-colors disabled:opacity-50`,children:`↗ Share…`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:C,disabled:s,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`⬇ Save image`}),(0,G.jsx)(`button`,{type:`button`,onClick:w,disabled:s,className:`px-4 py-2 rounded border border-line text-fg text-xs font-medium hover:bg-bg hover:border-accent/60 transition-colors disabled:opacity-50`,children:`📋 Copy image`})]})]}),(0,G.jsx)(sn,{getBlob:x,kind:`session`,title:h,description:`Built with Claude Recall — ${_.costDollars??``}`.trim(),caption:`${h} — built with Claude Recall`,disabled:s})]})})}function zu({size:e=16}){return(0,G.jsxs)(`svg`,{"aria-hidden":`true`,className:`${e===24?`h-6 w-6`:`h-4 w-4`} animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`3`}),(0,G.jsx)(`path`,{d:`M12 2a10 10 0 0 1 10 10`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`})]})}var Bu=150;function Vu({label:e,hint:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-bg-hover transition-colors`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-fg-muted text-[10px] mt-0.5 font-mono truncate`,children:t})]})}function Hu({sessionId:e,currentAlias:t,aliasSource:n,autoTitle:r,autoTitleSource:i}){let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(``),l=Kl(),u=ql(),d=(0,W.useRef)(null);(0,W.useEffect)(()=>{a&&(c(t??``),requestAnimationFrame(()=>d.current?.select()))},[a,t]);let f=async()=>{let n=s.trim();try{n?n!==t&&await l.mutateAsync({sessionId:e,alias:n}):t&&await u.mutateAsync(e)}catch(e){console.error(`alias save failed`,e)}finally{o(!1)}};if(a)return(0,G.jsx)(`input`,{ref:d,type:`text`,value:s,onChange:e=>c(e.target.value),onBlur:f,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),o(!1))},placeholder:`give this session a name…`,className:`bg-bg-elevated border border-accent rounded px-2 py-0.5 text-sm text-fg normal-case tracking-normal min-w-[14rem] focus:outline-none`,maxLength:80});let p=n===`auto`,m=t||r||null,h=m===r&&i===`agent`&&!!r,g=m??`Click to name this session`,_=(()=>{if(m===r&&r){let e=i??`heuristic`;return t?`${e} title · overriding ${p?`auto-alias`:`manual alias`} "${t}" — click to set a custom alias`:`auto-generated title (${e}) — click to override with a custom alias`}return t?`click to rename this session`:`give this session a custom name — click to edit`})();return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`group flex items-center gap-1.5 normal-case tracking-normal text-left min-w-0 px-2 py-0.5 rounded border border-dashed hover:border-accent transition-colors `+(m?`text-fg font-semibold border-transparent hover:bg-bg-hover`:`text-fg-muted italic border-line hover:text-fg hover:bg-bg-hover`),title:_,children:[h&&(0,G.jsx)(`span`,{className:`text-accent text-xs shrink-0`,"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`truncate`,children:g}),(0,G.jsx)(`span`,{className:`text-xs shrink-0 `+(m?`text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity`:`text-accent`),children:`✎`})]})}function Uu({sessionId:e,currentSource:t}){let n=K(),r=Ut(),i=Wt(),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),d=J({mutationFn:()=>Z.generateAutoTitle(e),onSuccess:t=>{n.invalidateQueries({queryKey:[`session`,e]}),n.invalidateQueries({queryKey:[`sessions`]}),Q({message:t?.auto_title?`Generated title: "${t.auto_title}"`:`Title generated`,tone:`success`,duration:4e3})},onError:e=>{let t=e?.message??`unknown error`;Q({message:/403/.test(t)?`Agent titles disabled — click ✨ to enable`:`Title generation failed: ${t}`,tone:`error`,duration:6e3})}}),f=(0,W.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();u({top:t.bottom+4,right:Math.max(8,window.innerWidth-t.right)})},[]);if((0,W.useLayoutEffect)(()=>{if(!a){u(null);return}f()},[a,f]),(0,W.useEffect)(()=>{if(!a)return;let e=()=>f(),t=()=>f(),n=e=>{let t=e.target;c.current&&!c.current.contains(t)&&s.current&&!s.current.contains(t)&&o(!1)},r=e=>{e.key===`Escape`&&o(!1)};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`mousedown`,n),window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`mousedown`,n),window.removeEventListener(`keydown`,r)}},[a,f]),t===`agent`&&!d.isError)return null;let p=r.data?.agentEnabled??!1,m=d.isError&&/403/.test(d.error?.message??``),h=()=>{if(!p){o(e=>!e);return}d.mutate()},g=async()=>{try{await i.mutateAsync({agentEnabled:!0}),o(!1),d.mutate()}catch{}},_=d.isPending||i.isPending;return(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{ref:s,type:`button`,onClick:h,disabled:_||r.isLoading,className:`flex items-center gap-1 text-xs bg-accent/10 text-accent hover:bg-accent hover:text-bg border border-accent/40 rounded px-2 py-1 font-medium disabled:opacity-60 disabled:cursor-not-allowed normal-case tracking-normal`,title:p?`Generate a descriptive title with claude -p (uses your Claude Code subscription)`:`Enable agent-generated titles (requires confirmation) and generate one now`,children:_?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:`generating…`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`✨`}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:`Generate title`})]})}),a&&l&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:c,className:`fixed w-72 bg-bg-elevated border border-line rounded shadow-xl p-3 z-50 normal-case tracking-normal`,style:{top:l.top,right:l.right},role:`dialog`,"aria-label":`Enable agent-generated titles`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg mb-2 font-medium`,children:`Enable agent-generated titles?`}),(0,G.jsxs)(`p`,{className:`text-[11px] text-fg-dim leading-snug mb-3`,children:[`This shells out to your local `,(0,G.jsx)(`code`,{className:`text-fg`,children:`claude`}),` `,`CLI and uses your Claude Code subscription to summarise the first 20 user messages. Runs only when you click ✨. You can flip it off later via the`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`autoTitle.agentEnabled`}),` key in`,` `,(0,G.jsx)(`code`,{className:`text-fg`,children:`$RECALL_HOME/config.json`}),`.`]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(!1),disabled:_,className:`text-[11px] text-fg-dim hover:text-fg px-2 py-1 rounded disabled:opacity-60`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:g,disabled:_,className:`text-[11px] bg-accent text-bg hover:bg-accent/90 px-2 py-1 rounded font-medium disabled:opacity-60`,children:i.isPending?`Enabling…`:`Enable and generate`})]}),i.isError&&(0,G.jsxs)(`p`,{className:`mt-2 text-[10px] text-role-user`,role:`alert`,children:[`Failed to enable: `,i.error.message]})]}),document.body),d.isError&&!a&&(0,G.jsx)(`div`,{className:`absolute top-full right-0 mt-1 text-[10px] text-role-user bg-bg-elevated border border-role-user/40 rounded px-2 py-1 shadow-lg z-20 whitespace-nowrap`,role:`alert`,children:m?`Agent titles disabled — click ✨ to enable`:`title generation failed`})]})}function Wu({sessionId:e,sessionCwd:t}){let n=Jl(e),[r,i]=(0,W.useState)(!1),a=Yl(r),o=Zl(),s=(0,W.useRef)(null),c=(0,W.useRef)(null),[l,u]=(0,W.useState)(null),d=n.data?.linked??null,f=n.data?.suggested??[],p=new Set(f.map(e=>e.shell_pid)),[m,h]=(0,W.useState)(``),g=(0,W.useRef)(null),_=(0,W.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect();u({top:t.bottom+4,right:Math.max(8,window.innerWidth-t.right)})},[]);(0,W.useLayoutEffect)(()=>{if(!r){u(null),h(``);return}_(),requestAnimationFrame(()=>g.current?.focus())},[r,_]),(0,W.useEffect)(()=>{if(!r)return;let e=()=>_(),t=()=>_(),n=e=>{let t=e.target;c.current&&!c.current.contains(t)&&s.current&&!s.current.contains(t)&&i(!1)},a=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`mousedown`,n),window.addEventListener(`keydown`,a),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`mousedown`,n),window.removeEventListener(`keydown`,a)}},[r,_]);let v=async t=>{try{await o.mutateAsync(t?{sessionId:e,shell_pid:t.shell_pid}:{sessionId:e,clear:!0}),i(!1),Q({message:t?`Linked to terminal "${t.tab_name}"`:`Terminal link cleared`,tone:`success`,duration:3500})}catch(e){Q({message:`Relink failed: ${e?.message??`unknown error`}`,tone:`error`,duration:5e3})}},y=d?`🔗 ${d.tab_name}`:n.isLoading?`🔗 …`:f.length>0?`🔗 ${f.length} suggested`:`🔗 unlinked`,b=d?`Currently linked to terminal "${d.tab_name}" (pid ${d.shell_pid}). Click to fix or unlink.`:f.length>0?`${f.length} terminals were open in this cwd when the session started. Click to pick one.`:`No terminal linked to this session. Click to pick one.`,x=a.data?.terminals??[],S=(t??``).replace(/\/+$/,``),C=e=>{if(!S||!e)return!1;let t=e.replace(/\/+$/,``);return t===S?!0:t.startsWith(S+`/`)||S.startsWith(t+`/`)},w=x.filter(e=>C(e.cwd)),T=m.toLowerCase().split(/\s+/).filter(Boolean),E=e=>{if(T.length===0)return!0;let t=e.toLowerCase();return T.every(e=>t.includes(e))},D=[...w].filter(e=>E(e.tab_name)).sort((e,t)=>{let n=S&&e.cwd&&e.cwd.replace(/\/+$/,``)===S?1:0,r=S&&t.cwd&&t.cwd.replace(/\/+$/,``)===S?1:0;return n===r?Date.parse(t.last_seen_at)-Date.parse(e.last_seen_at):r-n});return(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{ref:s,type:`button`,onClick:()=>i(e=>!e),className:`flex items-center gap-1 text-[11px] border rounded px-2 py-0.5 normal-case tracking-normal transition-colors `+(d?`border-line/60 text-fg-dim hover:text-fg hover:border-accent/40`:`border-dashed border-line text-fg-muted hover:text-fg hover:border-accent/40`),title:b,children:(0,G.jsx)(`span`,{className:`truncate max-w-[10rem]`,children:y})}),r&&l&&(0,Cc.createPortal)((0,G.jsxs)(`div`,{ref:c,className:`fixed w-[30rem] max-w-[calc(100vw-2rem)] bg-bg-elevated border border-line rounded shadow-xl z-50 normal-case tracking-normal`,style:{top:l.top,right:l.right},role:`dialog`,"aria-label":`Pick the right terminal for this session`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-semibold text-fg`,children:`Linked terminal`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-dim leading-snug mt-0.5 mb-2`,children:[d?`Currently: ${d.tab_name} (pid ${d.shell_pid})`:`No terminal linked.`,` `,`Pick a terminal to copy its name as this session's title.`]}),(0,G.jsx)(`input`,{ref:g,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search ${w.length} terminals in this project…`,className:`w-full text-[11px] bg-bg border border-line rounded px-2 py-1 focus:outline-none focus:border-accent normal-case tracking-normal`})]}),(0,G.jsxs)(`div`,{className:`max-h-72 overflow-y-auto`,children:[a.isLoading&&(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-fg-dim italic`,children:`Loading terminals…`}),!a.isLoading&&D.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-fg-dim italic`,children:x.length===0?(0,G.jsxs)(G.Fragment,{children:[`No terminals registered. Open a terminal and run `,(0,G.jsx)(`code`,{className:`text-fg`,children:`claude`}),`, or install the VS Code extension.`]}):w.length===0?(0,G.jsxs)(G.Fragment,{children:[`No terminals registered for this project. `,x.length,` terminal`,x.length===1?``:`s`,` `,x.length===1?`is`:`are`,` open elsewhere on your machine.`]}):(0,G.jsx)(G.Fragment,{children:`No terminals match your search.`})}),f.length>0&&!d&&(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-accent uppercase tracking-wider border-b border-accent/30 bg-accent/5`,children:`Suggested (open during session)`}),!d&&f.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v({shell_pid:e.shell_pid,tab_name:e.tab_name,cwd:e.cwd,opened_at:e.opened_at,last_seen_at:e.last_seen_at}),disabled:o.isPending,className:`block w-full text-left px-3 py-1.5 text-[11px] hover:bg-bg-hover transition-colors disabled:opacity-60 bg-accent/5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate text-fg font-medium`,children:e.tab_name||`(unnamed)`}),(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`time match`})]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted font-mono truncate mt-0.5`,children:[`pid `,e.shell_pid,` · open since `,new Date(e.opened_at).toISOString().slice(5,16).replace(`T`,` `)]})]},`sug-${e.shell_pid}`)),f.length>0&&!d&&D.length>0&&(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] text-fg-dim uppercase tracking-wider border-y border-line bg-bg-hover/30`,children:`All registered terminals`}),D.filter(e=>!p.has(e.shell_pid)||d).map(e=>{let t=S&&e.cwd&&e.cwd.replace(/\/+$/,``)===S,n=d?.shell_pid===e.shell_pid;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>v(e),disabled:o.isPending,className:`block w-full text-left px-3 py-1.5 text-[11px] hover:bg-bg-hover transition-colors disabled:opacity-60 `+(n?`bg-accent/10`:``),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate text-fg font-medium`,children:e.tab_name||`(unnamed)`}),t&&(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`same cwd`}),n&&(0,G.jsx)(`span`,{className:`text-[9px] text-accent shrink-0`,children:`✓ linked`})]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted font-mono truncate mt-0.5`,children:[`pid `,e.shell_pid,` · `,e.cwd??`(no cwd)`]})]},e.shell_pid)})]}),(0,G.jsxs)(`div`,{className:`border-t border-line px-3 py-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>v(null),disabled:o.isPending||!d,className:`text-[10px] text-fg-dim hover:text-role-user disabled:opacity-40 disabled:hover:text-fg-dim`,children:`Unlink`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!1),disabled:o.isPending,className:`text-[10px] text-fg-dim hover:text-fg`,children:`Close`})]})]}),document.body)]})}function Gu(e,t){if(!e.content_text||t.length===0)return!1;let n=e.content_text.toLowerCase();return t.every(e=>n.includes(e))}function Ku(e){return e.toLowerCase().split(/\s+/).filter(e=>e.length>1)}function qu(e){return e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e])}function Ju(e){if(!e)return!1;let t=e.slice(0,64);return t.startsWith(`**Tool result**`)||t.startsWith(`_(tool result was empty`)}var Yu=`recall:collapseToolCalls`,Xu=`recall:collapseToolResults`,Zu=`recall:sectionsHidden`;function Qu(e){try{return localStorage.getItem(e)===`1`}catch{return!1}}function $u(e,t){try{localStorage.setItem(e,t?`1`:`0`)}catch{}}function ed(e){return(0,G.jsx)(eu,{scope:e.isCompareLeft?`compare-left`:e.isCompareRight?`compare-right`:`main`,children:(0,G.jsx)(td,{...e})})}function td({sessionId:e,targetMessageUuid:t,onTargetChange:n,searchQuery:r,isCompareLeft:i=!1,isCompareRight:a=!1,onExitCompare:o}){let s=tu(),c=ru(),l=s===`main`?Zu:`${Zu}:${s}`,[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(0),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!0),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),[,E]=Nn(),[D,O]=(0,W.useState)(()=>Qu(Yu)),[k,A]=(0,W.useState)(()=>Qu(Xu));(0,W.useEffect)(()=>{$u(Yu,D)},[D]),(0,W.useEffect)(()=>{$u(Xu,k)},[k]);let[j,M]=(0,W.useState)(()=>Qu(l));(0,W.useEffect)(()=>{$u(l,j)},[j,l]);let ee=Un(e),N=Yn(),te=(0,W.useRef)(null),P=(0,W.useRef)(new Map),F=(0,W.useRef)(null),{isPinned:I,togglePin:L}=ai();(0,W.useEffect)(()=>{if(!g)return;let e=e=>{F.current&&!F.current.contains(e.target)&&_(!1)},t=e=>{e.key===`Escape`&&_(!1)};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[g]);let R=q({queryKey:[`session`,e],queryFn:()=>Z.session(e),enabled:!!e,refetchInterval:5e3,refetchIntervalInBackground:!1,staleTime:2e3});(0,W.useEffect)(()=>{p(!1),te.current&&(te.current.scrollTop=0),P.current.clear()},[e]);let z=Xl(),B=(0,W.useRef)(new Set);(0,W.useEffect)(()=>{if(!e)return;let t=R.data;t&&(B.current.has(e)||t.session.alias||(B.current.add(e),z.mutateAsync(e).then(e=>{e.applied&&e.linked_tab_name&&Q({message:`Auto-linked to terminal "${e.linked_tab_name}"`,tone:`success`,duration:4e3})}).catch(()=>{})))},[e,R.data]);let V=(0,W.useMemo)(()=>R.data?R.data.messages.filter(e=>{if(!u&&e.is_sidechain===1)return!1;let t=!!(e.content_text&&e.content_text.trim()),n=!!(e.tool_names&&e.tool_names.length>0);return!(!t&&!n)}):[],[R.data,u]),ne=(0,W.useMemo)(()=>Ku(r),[r]),H=(0,W.useMemo)(()=>{if(ne.length===0)return[];let e=[];for(let t of V)Gu(t,ne)&&e.push(t.uuid);return e},[V,ne]),re=(0,W.useMemo)(()=>f?V:V.slice(0,Bu),[V,f]),ie=Kc({count:re.length,getScrollElement:()=>te.current,estimateSize:()=>220,overscan:6,getItemKey:e=>re[e]?.uuid??e});(0,W.useEffect)(()=>{t&&V.findIndex(e=>e.uuid===t)>=Bu&&p(!0)},[t,V]),(0,W.useEffect)(()=>{if(!t)return;let e=re.findIndex(e=>e.uuid===t);if(e<0)return;let n=requestAnimationFrame(()=>{ie.scrollToIndex(e,{align:`center`,behavior:`smooth`}),h(e=>e+1)});return()=>cancelAnimationFrame(n)},[t,re,ie,f]),(0,W.useEffect)(()=>{let e=te.current;if(!e)return;let t=()=>{x(e.scrollHeight-(e.scrollTop+e.clientHeight)<120)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[e,re.length]);let ae=(0,W.useCallback)(()=>{re.length!==0&&(!f&&V.length>re.length&&p(!0),ie.scrollToIndex(re.length-1,{align:`end`,behavior:`smooth`}))},[re.length,ie,f,V.length]),oe=(0,W.useCallback)(()=>{te.current&&te.current.scrollTo({top:0,behavior:`smooth`})},[]);(0,W.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.key===`End`?(e.preventDefault(),ae()):e.key===`Home`&&(e.preventDefault(),oe()))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,ae,oe]);let se=t&&H.includes(t)?H.indexOf(t):-1,ce=(0,W.useCallback)(e=>{H.length!==0&&n(H[((se===-1?e===1?-1:0:se)+e+H.length)%H.length])},[se,H,n]);if((0,W.useEffect)(()=>{if(H.length===0)return;let e=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.key===`n`?(e.preventDefault(),ce(e.shiftKey?-1:1)):e.key===`p`&&(e.preventDefault(),ce(-1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ce,H.length]),!e)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-center px-8`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-sm mb-2`,children:`No session selected`}),(0,G.jsx)(`div`,{className:`text-fg-muted text-xs`,children:`Pick a project on the left, then a session from the middle. Or type in the search box above — your data never leaves this machine.`})]})})});if(R.isLoading)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-fg-muted text-sm`,children:`Loading session…`})});if(R.isError)return(0,G.jsx)(`section`,{className:`pane flex-1 border-r-0`,children:(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-center text-role-user text-sm`,children:[`Failed: `,R.error.message]})});let{session:U,messages:le}=R.data,ue=I(U.id),de=()=>{let e=[];e.push(`# Claude Code session · ${U.project_name}`),e.push(``),e.push(`- session id: \`${U.id}\``),U.started_at&&e.push(`- started: ${U.started_at}`),U.git_branch&&e.push(`- branch: \`${U.git_branch}\``),e.push(`- messages: ${le.length}`),e.push(``),e.push(`---`),e.push(``);for(let t of V){let n=t.role??t.type,r=t.timestamp?` \`${t.timestamp}\``:``;e.push(`## ${n}${r}`),t.tool_names&&e.push(`\n_tools: ${t.tool_names}_\n`),t.content_text&&e.push(t.content_text),e.push(``)}navigator.clipboard.writeText(e.join(`
|
|
94
94
|
`))},fe=()=>{let e=`${`<!doctype html><html><head><meta charset="utf-8"><title>${qu(U.project_name)} · ${U.id}</title>
|
|
95
95
|
<style>
|
|
96
96
|
:root { color-scheme: dark; }
|
|
@@ -425,7 +425,7 @@ Architecture above. Setup:
|
|
|
425
425
|
}
|
|
426
426
|
\`\`\`
|
|
427
427
|
|
|
428
|
-
In \`~/.claude.json\` (or per-project \`.mcp.json\`). If you installed via \`npm link\`, \`claude-recall-mcp\` is on your PATH; otherwise point \`command\` at \`node\` with \`args: ["/abs/path/to/dist/mcp
|
|
428
|
+
In \`~/.claude.json\` (or per-project \`.mcp.json\`). If you installed via \`npm link\`, \`claude-recall-mcp\` is on your PATH; otherwise point \`command\` at \`node\` with \`args: ["/abs/path/to/dist/mcp-server.js"]\`.
|
|
429
429
|
|
|
430
430
|
## Claude Desktop
|
|
431
431
|
|
|
@@ -477,9 +477,9 @@ Tier cards and the dead-man clause above. The honest math:
|
|
|
477
477
|
|
|
478
478
|
Your data lives on your disk. We don't run a server for it. Charging recurring for software that runs locally would be unfair.
|
|
479
479
|
|
|
480
|
-
##
|
|
480
|
+
## One price, for life
|
|
481
481
|
|
|
482
|
-
|
|
482
|
+
Pro is \`$49.69\`, one-time. Lifetime updates, dead-man clause, no subscription drift. You pay once and own it forever.
|
|
483
483
|
|
|
484
484
|
## Comparable dev tools
|
|
485
485
|
|
|
@@ -488,7 +488,7 @@ Your data lives on your disk. We don't run a server for it. Charging recurring f
|
|
|
488
488
|
| TablePlus | $89 |
|
|
489
489
|
| Tower (annual) | $69 |
|
|
490
490
|
| Proxyman | $59 |
|
|
491
|
-
| <span class="text-accent font-bold">Claude Recall
|
|
491
|
+
| <span class="text-accent font-bold">Claude Recall</span> | <span class="text-accent font-bold">$49.69</span> |
|
|
492
492
|
| Dash | $30 |
|
|
493
493
|
|
|
494
494
|
## Enterprise
|
|
@@ -515,7 +515,7 @@ Today: no, those tools don't write to \`~/.claude/projects/\`. Adapters are on t
|
|
|
515
515
|
|
|
516
516
|
### What's the license model?
|
|
517
517
|
|
|
518
|
-
Free for the basics. Pro is one-time, $
|
|
518
|
+
Free for the basics. Pro is one-time, $49.69, lifetime updates, dead-man clause. License JWT validates once at activation, then offline forever.
|
|
519
519
|
|
|
520
520
|
### Why are my session titles showing the first sentence instead of my tab name?
|
|
521
521
|
|
|
@@ -645,8 +645,8 @@ Manual override anytime: \`recall name <id-prefix> "<actual name>"\` writes a pe
|
|
|
645
645
|
├── daemon.pid
|
|
646
646
|
├── daemon.log
|
|
647
647
|
└── models/
|
|
648
|
-
└── bge-base-en-v1.5/`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-3 leading-relaxed`,children:`Tar this directory to back up everything. Untar on a new machine to restore.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 animate-[fadeInUp_0.5s_ease-out_180ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`🛡️`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Never delete user data`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Every rename archives the prior value. Cleared values stay recoverable from history.`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`💾`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Backup in one command`}),(0,G.jsx)(`code`,{className:`block mt-1 text-[11px] font-mono text-fg-muted bg-bg px-2 py-1 rounded border border-line`,children:`tar czf recall.tgz ~/.recall/`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`🔄`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Reset without data loss`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Drop db.sqlite, then recall start and recall index. Aliases and notes survive via mirrors.`})]})]})]})}function Zd(){return(0,G.jsx)(`div`,{className:`mb-10 space-y-6`,children:(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Four ways to get a session out of Recall`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Qd.map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg border ${e.featured?`border-accent/50 bg-accent/5`:`border-line bg-bg`} p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*80}ms`},children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,G.jsx)(`div`,{className:`text-2xl`,children:e.icon}),e.featured&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-2 py-0.5 rounded bg-accent text-bg`,children:`killer feature`})]}),(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1`,children:e.label}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed mb-2`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line w-fit`,children:e.cmd}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mt-3`,children:`Best for`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-dim leading-relaxed`,children:e.bestFor})]},e.label))})]})})}var Qd=[{icon:`📋`,label:`Copy as context`,body:`Condensed markdown to clipboard. Tool-call JSON and thinking blocks stripped, every prompt and response preserved.`,cmd:`recall context <id> | pbcopy`,bestFor:`Pasting into a new Claude Code conversation so it picks up where you left off.`,featured:!0},{icon:`📄`,label:`Copy as full markdown`,body:`Full transcript including tool-call JSON and tool results. Bigger, more faithful, less Claude-friendly.`,cmd:``,bestFor:`Auditing the exact tool sequence the model executed.`},{icon:`🌐`,label:`Export HTML`,body:`Self-contained dark-mode HTML, all styles inlined. Works offline forever.`,cmd:``,bestFor:`Archiving a session, committing to git, emailing it to a colleague.`},{icon:`🖨️`,label:`Print`,body:`Print-friendly layout. Chrome hidden, light background, page breaks between messages.`,cmd:``,bestFor:`PDF export via the print dialog. Sharing with non-tech reviewers.`}];function $d(){return(0,G.jsx)(`div`,{className:`mb-10 space-y-6`,children:(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Tactics from someone using Recall every day`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:ef.map((e,t)=>(0,G.jsx)(`div`,{className:`rounded-lg border border-line bg-bg p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*60}ms`},children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`text-2xl shrink-0`,children:e.icon}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm`,children:e.title}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed mt-1`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block mt-2 text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line max-w-full overflow-x-auto`,children:e.cmd})]})]})},e.title))})]})})}var ef=[{icon:`🔎`,title:`Search first, never scroll`,body:`A typed word beats your scroll wheel against 150,000+ messages. Build the reflex.`},{icon:`✏️`,title:`Alias the day you finish`,body:`A bare UUID is forgettable in a week. Spend 5 seconds naming the session while context is fresh.`},{icon:`⭐`,title:`Pin canonical decisions`,body:`The ★ floats a session to the top of its project. Pin "the auth decisions" so they are always first.`},{icon:`📝`,title:`Notes as executive summary`,body:`3 bullets after the session: what we decided, what code changed, what is unresolved. Re-read in 30 seconds three months later.`},{icon:`⛓️`,title:`Chain context with --prelude`,body:`The prelude tells Claude what to DO with the context, otherwise it summarizes instead of continuing.`,cmd:`recall context abc12345 --prelude "continue the migration" | claude`},{icon:`📦`,title:`Dotfile your ~/.recall`,body:`Commit aliases.json and notes/ to dotfiles. Your session names and personal notes follow you across machines.`},{icon:`🎯`,title:`Search for decisions, not keywords`,body:`You write phrases like "decided", "final answer", "lets go with" when you commit to something. Searching them surfaces decision moments.`,cmd:`recall search "decided"`}];function tf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Stdio MCP server. Same SQLite, no network ports.`}),(0,G.jsx)(af,{})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 animate-[fadeInUp_0.5s_ease-out_240ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`📖`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Read tools`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-1.5 py-0.5 rounded bg-fg-muted/15 text-fg-dim`,children:`always on`})]}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-1.5 m-0 p-0 list-none`,children:nf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`code`,{className:`text-[11px] font-mono text-fg shrink-0`,children:e.name}),(0,G.jsx)(`span`,{children:e.body})]},e.name))})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`✏️`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Write tools`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-1.5 py-0.5 rounded bg-accent/20 text-accent font-mono`,children:`--allow-writes`})]}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-1.5 m-0 p-0 list-none`,children:rf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`code`,{className:`text-[11px] font-mono text-fg shrink-0`,children:e.name}),(0,G.jsx)(`span`,{children:e.body})]},e.name))}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-3 leading-relaxed`,children:`All writes rate-limited (default 60/min), zod-validated, audited to ~/.recall/audit/.`})]})]})]})}var nf=[{name:`list_projects`,body:`every project + counts`},{name:`list_sessions`,body:`recent, filterable`},{name:`search`,body:`BM25 + RRF fusion`},{name:`find_similar_sessions`,body:`cosine semantic (Pro)`},{name:`get_session`,body:`full transcript`},{name:`context_for_session`,body:`condensed markdown`},{name:`recall_neighborhood`,body:`parents/children/citations`},{name:`thread_list / thread_get`,body:`thread browsing`},{name:`list_tags`,body:`every tag + counts`},{name:`apply_tags`,body:`merge-mode tagging`}],rf=[{name:`add_tag / remove_tag`,body:`tag management`},{name:`set_alias`,body:`archive prior values`},{name:`append_note`,body:`add markdown to a note`},{name:`create_collection`,body:`plus add/remove session`},{name:`thread_create`,body:`plus link, set-parent, remove`},{name:`thread_rename / archive`,body:`lifecycle`},{name:`thread_merge / split`,body:`restructuring`},{name:`sync_active_sessions`,body:`capture running terminals`}];function af(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 220`,className:`w-full h-auto`,role:`img`,"aria-label":`MCP architecture: Claude Desktop or Code talks via stdio to the local Recall MCP server, which reads from your SQLite database`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`mcp-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsx)(`rect`,{x:`20`,y:`40`,width:`180`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`34`,y:`64`,className:`fill-fg text-[12px] font-semibold`,children:`Claude Desktop`}),(0,G.jsx)(`text`,{x:`34`,y:`84`,className:`fill-fg-muted text-[10px] font-mono`,children:`claude_desktop_config.json`}),(0,G.jsx)(`rect`,{x:`20`,y:`120`,width:`180`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`34`,y:`144`,className:`fill-fg text-[12px] font-semibold`,children:`Claude Code`}),(0,G.jsx)(`text`,{x:`34`,y:`164`,className:`fill-fg-muted text-[10px] font-mono`,children:`~/.claude.json`}),(0,G.jsx)(`line`,{x1:`200`,y1:`70`,x2:`318`,y2:`105`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`line`,{x1:`200`,y1:`150`,x2:`318`,y2:`125`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`text`,{x:`245`,y:`98`,className:`fill-fg-muted text-[10px] font-semibold`,children:`stdio`}),(0,G.jsx)(`rect`,{x:`320`,y:`80`,width:`180`,height:`60`,rx:`10`,className:`fill-accent/15 stroke-accent`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`410`,y:`104`,textAnchor:`middle`,className:`fill-accent text-[12px] font-semibold`,children:`claude-recall-mcp`}),(0,G.jsx)(`text`,{x:`410`,y:`124`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`no ports · no outbound`}),(0,G.jsx)(`line`,{x1:`500`,y1:`110`,x2:`578`,y2:`110`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`rect`,{x:`580`,y:`80`,width:`120`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`640`,y:`104`,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`db.sqlite`}),(0,G.jsx)(`text`,{x:`640`,y:`122`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`~/.recall/`}),(0,G.jsx)(`text`,{x:`360`,y:`200`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`Whatever the web UI shows, the MCP client sees the same.`})]})}function of(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Auto-name Claude Code sessions with the terminal tab name you started them in`}),(0,G.jsx)(cf,{})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 animate-[fadeInUp_0.5s_ease-out_220ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`What it watches`}),(0,G.jsxs)(`ul`,{className:`text-xs text-fg-muted space-y-2 m-0 p-0 list-none`,children:[(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`onDidOpenTerminal, rename, close events`})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`POSTs shell_pid, tab_name, cwd to 127.0.0.1`})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`Daemon correlates via lsof when JSONL appears`})]})]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`What it never does`}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-2 m-0 p-0 list-none`,children:sf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0 mt-0.5`,children:`×`}),(0,G.jsx)(`span`,{className:`line-through decoration-fg-muted/60`,children:e})]},e))})]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 animate-[fadeInUp_0.5s_ease-out_360ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:`Status bar (VS Code, Cursor, Windsurf)`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-1 rounded bg-bg border border-line text-xs font-mono text-fg flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`⟳`}),(0,G.jsx)(`span`,{children:`Recall`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`3`})]}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`number of registered terminals`})]})]})]})}var sf=[`Read terminal buffer or output`,`Touch the clipboard`,`Read editor buffers or files`,`Make any outbound network call (loopback only)`];function cf(){let e=[{x:10,line1:`Terminal`,line2:`opens`,sub:`in VS Code`},{x:155,line1:`Tab name`,line2:`registered`,sub:`POST 127.0.0.1`},{x:300,line1:`Claude writes`,line2:`JSONL`,sub:`~/.claude/projects/`},{x:445,line1:`Daemon`,line2:`correlates`,sub:`lsof + shell PID`},{x:590,line1:`Auto-alias`,line2:`applied`,sub:`session named`,accent:!0}];return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 200`,className:`w-full h-auto`,role:`img`,"aria-label":`Lifecycle: terminal opens, tab name registered, JSONL appears, daemon correlates by lsof, alias applied`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`vscode-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),e.map((t,n)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:t.x,y:`60`,width:`120`,height:`80`,rx:`10`,className:t.accent?`fill-accent/15 stroke-accent`:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:t.x+60,y:`86`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:t.line1}),(0,G.jsx)(`text`,{x:t.x+60,y:`102`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:t.line2}),(0,G.jsx)(`text`,{x:t.x+60,y:`124`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:t.sub}),n<e.length-1&&(0,G.jsx)(`line`,{x1:t.x+122,y1:`100`,x2:e[n+1].x-2,y2:`100`,className:`stroke-accent/50`,strokeWidth:`1.8`,markerEnd:`url(#vscode-arrow)`})]},t.line1))]})}function lf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-warning/40 bg-warning/5 p-3 flex items-center gap-3 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`span`,{className:`text-2xl shrink-0`,children:`🚀`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-warning font-bold`,children:`Founder pricing`}),(0,G.jsx)(`div`,{className:`text-xs text-fg`,children:`$29.69 one-time through May 2026. Standard $49.69 from June onward. Lifetime updates either way.`})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4 animate-[fadeInUp_0.5s_ease-out_120ms_both]`,children:uf.map(e=>(0,G.jsxs)(`div`,{className:`rounded-xl border p-6 flex flex-col relative ${e.featured?`border-accent bg-accent/5`:`border-line bg-bg-elevated`}`,children:[e.featured&&(0,G.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-1 rounded-full bg-accent text-bg text-[10px] uppercase tracking-widest font-bold whitespace-nowrap`,children:`Most popular`}),(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:e.name}),(0,G.jsx)(`div`,{className:`flex items-baseline gap-1 mb-1`,children:(0,G.jsx)(`span`,{className:`text-3xl font-bold text-fg`,children:e.price})}),e.period&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mb-2`,children:e.period}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mb-4`,children:e.tagline}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-2 mb-6 m-0 p-0 list-none flex-1`,children:e.features.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:e})]},e))}),e.href?(0,G.jsx)(`a`,{href:e.href,target:e.href.startsWith(`mailto:`)?void 0:`_blank`,rel:e.href.startsWith(`mailto:`)?void 0:`noopener noreferrer`,className:`text-center px-4 py-2 rounded text-xs font-semibold font-mono transition-colors ${e.featured?`bg-accent text-bg hover:bg-accent/90`:`border border-line text-fg-dim hover:border-accent hover:text-accent`}`,children:e.cta}):(0,G.jsx)(`div`,{className:`text-center px-4 py-2 rounded text-xs font-semibold font-mono ${e.featured?`bg-accent text-bg`:`border border-line text-fg-dim`}`,children:e.cta})]},e.name))}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_280ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`Dead-man clause`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,G.jsx)(`span`,{className:`text-3xl shrink-0`,children:`🛡️`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1`,children:`If clauderecall.com ever disappears, every existing license stays valid.`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`Your license validates against our server exactly once at activation. After that Recall works offline forever. We will publish the validation secret if we ever shut down so you are never stranded.`})]})]})]})]})}var uf=[{name:`Free`,price:`$0`,period:``,tagline:`Keep every session you have ever run, browsable forever.`,features:[`Full indexing of every Claude Code session`,`CLI list, show, projects, status`,`Web UI: browse projects, read transcripts`,`Three-layer durability (SQLite + mirrors + source untouched)`,`No time limits, no feature expiry`],cta:`already installed`},{name:`Pro`,price:`$29.69`,period:`one-time, May 2026`,tagline:`Everything in Free, plus the features that make this a daily driver.`,features:[`Full-text BM25 search across every message`,`recall context re-injection (the moat)`,`MCP server for Claude Desktop and Code`,`VS Code, Cursor, Windsurf extension`,`Aliases, tags, notes, pins, cross-session diff`,`Semantic vector search (3-lane RRF fusion)`,`Lifetime updates · Dead-man clause`],cta:`→ get a key · $29.69`,href:`https://clauderecall.com/pricing`,featured:!0},{name:`Enterprise`,price:`custom`,period:`50+ seats`,tagline:`Everything in Pro for every seat, plus the wrapper.`,features:[`Centralized license management`,`SSO / SAML`,`NET 30 invoicing`,`Audit log export`,`Security review docs (SOC 2 readiness)`,`MSA / DPA / NDA support`,`Priority support with SLA`],cta:`hello@clauderecall.com`,href:`mailto:hello@clauderecall.com`}];function df(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`The three questions everyone asks first`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:ff.map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*80}ms`},children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-accent font-semibold mb-2`,children:e.tag}),(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-2`,children:e.q}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:e.a})]},e.q))})]}),(0,G.jsx)(mf,{})]})}var ff=[{tag:`Privacy`,q:`Does any of my data leave my machine?`,a:`No. The daemon listens on 127.0.0.1 only. The single outbound call ever made is the one-time license-validation call when you activate Pro.`},{tag:`Pricing`,q:`Is Pro a subscription?`,a:`No. One-time, both pricing windows. $29.69 in May, $49.69 from June. Pay once, own it for life.`},{tag:`Future-proofing`,q:`Will Anthropic just ship this natively?`,a:`Maybe. The moat is recall context, threads, MCP, redaction, cross-AI support, and the dead-man clause. Anthropic is a cloud company — they cannot ship "even if we disappear".`}],pf=[{label:`Privacy & data`,icon:`🔒`,items:[{q:`Can I use this if I am offline?`,a:`Yes. Works on a plane, behind firewalls, on air-gapped machines. The browser talks to http://127.0.0.1, your own laptop.`},{q:`What happens if I delete a JSONL from ~/.claude/projects/?`,a:`The SQLite copy persists. We only add and update — we never delete session rows because the source file disappeared. Your indexed memory outlives the source files.`},{q:`How big does the database get?`,a:`~800 MB for 1,100+ sessions and 150,000 messages in our reference environment. Storage is cheap; this is rarely a problem. Compression is on the roadmap if it ever becomes one.`}]},{label:`Compatibility`,icon:`🧩`,items:[{q:`Cursor / Cline / Windsurf?`,a:`Today: no, because those tools do not write to ~/.claude/projects/. Future: adapters for each (v0.8+).`},{q:`Multiple machines on one index?`,a:`Not yet. Each machine has its own ~/.recall/db.sqlite. Team sync is on the roadmap — opt-in, end-to-end encrypted, still local-first.`}]},{label:`Licensing`,icon:`💎`,items:[{q:`What is the license model?`,a:`Free tier: index, list, show, search, basic browsing. Pro tier (one-time, $29.69 May 2026 / $49.69 from June): full web UI, context re-injection, MCP, advanced search. License validates once, then offline forever. Dead-man clause: if our servers disappear, existing keys stay valid.`},{q:`Refunds?`,a:`30-day satisfaction guarantee from license activation. Email and we refund. The clock starts when you run recall activate, not when you click Buy.`}]}];function mf(){let[e,t]=(0,W.useState)(null);return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_280ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Everything else, grouped by topic`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:pf.map(n=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:n.icon}),(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-fg font-semibold`,children:n.label})]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:n.items.map(r=>{let i=`${n.label}-${r.q}`,a=e===i;return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(a?null:i),className:`w-full text-left px-3 py-2 flex items-start gap-2 hover:bg-bg-hover transition-colors`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 mt-1 inline-block w-2 h-2 border-r border-b border-fg-muted transition-transform`,style:{transform:`rotate(${a?`225deg`:`-45deg`})`}}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-fg leading-snug flex-1`,children:r.q})]}),a&&(0,G.jsx)(`div`,{className:`px-3 pb-3 text-[11px] text-fg-muted leading-relaxed`,children:r.a})]},i)})})]},n.label))})]})}function hf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Three search lanes fused with Reciprocal Rank Fusion (k = 60)`}),(0,G.jsx)(gf,{})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_220ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Same query, different lanes`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-1`,children:`Query`}),(0,G.jsx)(`div`,{className:`text-sm font-mono text-fg`,children:`"how do I expire user logins"`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:`Keyword only (Free)`}),(0,G.jsx)(`div`,{className:`text-2xl font-bold text-fg-dim mb-1`,children:`0 hits`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`No session contains the literal phrase "expire user logins".`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-accent font-semibold mb-2`,children:`+ Semantic (Pro)`}),(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent mb-1`,children:`7 hits`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`Top result: a session about JWT refresh rotation. Zero keyword overlap, semantic match.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-xs animate-[fadeInUp_0.5s_ease-out_360ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`768`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`vector dimensions`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`~110MB`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`model footprint`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`CPU`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`no GPU required`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`$0`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`no API fees, ever`})]})]})]})}function gf(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 240`,className:`w-full h-auto`,role:`img`,"aria-label":`Three search lanes fused into ranked results: BM25 over messages, BM25 over summaries, kNN over vector chunks`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`sem-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsx)(`rect`,{x:`10`,y:`100`,width:`100`,height:`40`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`60`,y:`124`,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`query`}),(0,G.jsx)(`rect`,{x:`180`,y:`20`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`42`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`BM25 messages`}),(0,G.jsx)(`text`,{x:`260`,y:`58`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`FTS5`}),(0,G.jsx)(`rect`,{x:`180`,y:`95`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`117`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`BM25 summaries`}),(0,G.jsx)(`text`,{x:`260`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`sessions_fts`}),(0,G.jsx)(`rect`,{x:`180`,y:`170`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`192`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`cosine kNN`}),(0,G.jsx)(`text`,{x:`260`,y:`208`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`sqlite-vec · bge-768`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`45`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`120`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`195`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`45`,x2:`408`,y2:`105`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`120`,x2:`408`,y2:`120`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`195`,x2:`408`,y2:`135`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`rect`,{x:`410`,y:`95`,width:`120`,height:`50`,rx:`8`,className:`fill-accent/15 stroke-accent`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`470`,y:`117`,textAnchor:`middle`,className:`fill-accent text-[11px] font-semibold`,children:`RRF fuser`}),(0,G.jsx)(`text`,{x:`470`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`k = 60`}),(0,G.jsx)(`line`,{x1:`532`,y1:`120`,x2:`598`,y2:`120`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`rect`,{x:`600`,y:`95`,width:`110`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`655`,y:`117`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`ranked results`}),(0,G.jsx)(`text`,{x:`655`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`unified, deduped`})]})}function _f(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Two-step pipeline. Reads past sessions, never your repo.`}),(0,G.jsx)(`div`,{className:`hidden md:block`,children:(0,G.jsx)(vf,{})}),(0,G.jsxs)(`div`,{className:`md:hidden flex items-center justify-between text-[11px] font-semibold text-fg gap-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`📁`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Past sessions`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-muted mt-1`,children:`read-only`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`🤖`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Extract`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-warning mt-1`,children:`tokens`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`⚙`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Cluster`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-muted mt-1`,children:`free`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`🐛`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Patterns`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-accent mt-1`,children:`output`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Step 1: Extract`}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed`,children:[`Per-session Claude sub-agent pulls bug snippets from session JSONLs. `,(0,G.jsx)(`strong`,{className:`text-warning`,children:`Costs tokens.`}),` `,`Idempotent. Default cap 200/run.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Step 2: Infer`}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed`,children:[`Local fingerprinting groups sessions by error shape. `,(0,G.jsx)(`strong`,{children:`No LLM cost.`}),` Add `,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`--semantic`}),` `,`for fuzzy merging via local embeddings.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Output`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Clusters of recurring bugs. Mark "this fix worked" once; future occurrences surface the linked resolution.`})]})]})]})}function vf(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 200`,className:`w-full h-auto`,role:`img`,"aria-label":`Pipeline: past sessions, extract (LLM, costs tokens), cluster (local, free), bug-pattern output`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`bug-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`text`,{x:190,y:42,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-semibold uppercase tracking-wider`,children:`read-only`}),(0,G.jsx)(`text`,{x:370,y:42,textAnchor:`middle`,className:`fill-warning text-[10px] font-semibold uppercase tracking-wider`,children:`costs tokens`}),(0,G.jsx)(`text`,{x:550,y:42,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-semibold uppercase tracking-wider`,children:`local · free`})]}),[190,370,550].map(e=>(0,G.jsx)(`line`,{x1:e,y1:50,x2:e,y2:102,className:`stroke-line/60`,strokeWidth:`1`,strokeDasharray:`2 3`},`drop-${e}`)),[{x1:158,x2:222},{x1:338,x2:402},{x1:518,x2:582}].map(e=>(0,G.jsx)(`line`,{x1:e.x1,y1:110,x2:e.x2,y2:110,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#bug-arrow)`},`arrow-${e.x1}`)),(0,G.jsx)(yf,{x:20,y:75,w:140,h:70,emoji:`📁`,title:`Past sessions`,sub:`~/.claude/projects`}),(0,G.jsx)(yf,{x:222,y:75,w:120,h:70,emoji:`🤖`,title:`Extract`,sub:`LLM sub-agent`}),(0,G.jsx)(yf,{x:400,y:75,w:120,h:70,emoji:`⚙`,title:`Cluster`,sub:`by fingerprint`}),(0,G.jsx)(yf,{x:580,y:75,w:120,h:70,emoji:`🐛`,title:`Patterns`,sub:`fix linked`,accent:!0}),(0,G.jsxs)(`text`,{x:360,y:185,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:[`stored locally in`,` `,(0,G.jsx)(`tspan`,{className:`fill-fg-dim font-mono`,children:`~/.recall/db.sqlite`})]})]})}function yf({x:e,y:t,w:n,h:r,emoji:i,title:a,sub:o,accent:s}){return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:e,y:t,width:n,height:r,rx:10,ry:10,className:s?`fill-accent/15 stroke-accent`:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:e+14,y:t+28,style:{fontSize:18},children:i}),(0,G.jsx)(`text`,{x:e+38,y:t+28,className:`fill-fg text-[12px] font-semibold`,children:a}),(0,G.jsx)(`text`,{x:e+14,y:t+52,className:`fill-fg-muted text-[10px] font-mono`,children:o})]})}function bf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Run the doctor first. Most issues surface as a concrete suggestion.`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4 font-mono text-[11px] leading-relaxed`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-2`,children:[`$ `,(0,G.jsx)(`span`,{className:`text-fg`,children:`recall doctor`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ DB size: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`912 MB`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ WAL size: `,(0,G.jsx)(`span`,{className:`text-warning`,children:`167 MB (large)`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ FTS5 fragmentation: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`low`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ Free disk: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`42 GB`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ Integrity check: `,(0,G.jsx)(`span`,{className:`text-accent`,children:`ok`})]}),(0,G.jsxs)(`div`,{className:`text-warning mt-2`,children:[`⚠ WAL is 167 MB. Run `,(0,G.jsx)(`span`,{className:`font-semibold`,children:`recall optimize`}),` to truncate it.`]})]})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_180ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Common scenarios`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-xs`,children:xf.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-base shrink-0`,children:e.icon}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.symptom})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed mb-2`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line w-fit max-w-full overflow-x-auto`,children:e.cmd})]},e.symptom))})]})]})}var xf=[{icon:`🐢`,symptom:`Feels slow`,body:`Run the doctor for concrete suggestions, then optimize if WAL or FTS5 is fragmented.`,cmd:`recall doctor`},{icon:`⚡`,symptom:`Daemon will not start`,body:`Tail the log. Common cause: leftover sqlite-wal/shm. Safe to delete when stopped.`,cmd:`tail -50 ~/.recall/daemon.log`},{icon:`⬜`,symptom:`Page is blank`,body:`Devtools console first. Then bounce the daemon, then hard-refresh.`,cmd:`recall stop && recall start`},{icon:`🔍`,symptom:`Search misses a known term`,body:`Terms shorter than 2 chars are dropped. FTS5 stems with porter; quoted phrases are exact. Try a forced reindex.`,cmd:`recall index --force`},{icon:`🪶`,symptom:`Empty assistant messages`,body:`Pre-v0.4.0 indexer dropped tool-call markdown. Reindex once.`,cmd:`recall index --force`},{icon:`🧹`,symptom:`Want a fully clean slate`,body:`Wipes aliases, notes, pins, the database. Only when you are sure.`,cmd:`recall stop && rm -rf ~/.recall && recall start`}];function Sf({initialSectionId:e,onClose:t,onSectionChange:n,onReplayOnboarding:r,onReplayThreadsIntro:i}){let a=rd[0].id,[o,s]=(0,W.useState)(()=>e&&rd.some(t=>t.id===e)?e:a),[c,l]=(0,W.useState)(!1),u=(0,W.useRef)(null),d=(0,W.useRef)(n);(0,W.useEffect)(()=>{d.current=n}),(0,W.useEffect)(()=>{e&&rd.some(t=>t.id===e)&&s(e)},[e]),(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){let n=e.target;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;if(c){l(!1);return}t()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,c]),(0,W.useEffect)(()=>{u.current&&(u.current.scrollTop=0),d.current?.(o),l(!1)},[o]);let f=(0,W.useMemo)(()=>{let e={};for(let t of rd)e[t.id]=sd(t.md);return e},[]),p=rd.find(e=>e.id===o);return(0,G.jsxs)(`div`,{className:`absolute inset-0 bg-bg flex flex-col z-20`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 sm:px-5 py-3 border-b border-line bg-bg shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"aria-label":c?`close section nav`:`open section nav`,className:`md:hidden shrink-0 h-9 w-9 rounded-md border border-line bg-bg-elevated hover:bg-bg-hover flex items-center justify-center text-fg-dim`,children:(0,G.jsxs)(`span`,{"aria-hidden":`true`,className:`block w-4 space-y-1`,children:[(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`}),(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`}),(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`})]})}),(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-9 w-9 sm:h-10 sm:w-10 rounded-lg shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`leading-none flex items-center gap-2 sm:gap-2.5 flex-wrap`,children:[(0,G.jsx)(`img`,{src:nd,alt:`Claude Recall`,className:`h-7 sm:h-9 w-auto`}),(0,G.jsx)(`span`,{className:`text-xs sm:text-base font-semibold text-fg-dim hidden sm:inline`,children:`· Command Center`})]}),(0,G.jsx)(`div`,{className:`text-[10px] sm:text-xs text-fg-muted mt-1 sm:mt-2 hidden sm:block`,children:`Everything you need to drive the product like a pro.`})]})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:`text-[11px] sm:text-xs text-fg-dim hover:text-fg border border-line rounded px-2 sm:px-3 py-1.5 whitespace-nowrap shrink-0`,title:`close command center (Esc)`,children:[(0,G.jsx)(`span`,{className:`sm:hidden`,"aria-hidden":`true`,children:`←`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`← back to sessions`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 relative`,children:[c&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`close nav`,onClick:()=>l(!1),className:`md:hidden fixed inset-0 bg-bg/80 backdrop-blur-sm z-30`}),(0,G.jsxs)(`aside`,{className:$(`shrink-0 border-r border-line bg-bg-elevated flex flex-col transition-transform duration-200`,`md:static md:translate-x-0 md:w-64`,`absolute inset-y-0 left-0 w-72 z-40`,c?`translate-x-0`:`-translate-x-full md:translate-x-0`),children:[(0,G.jsxs)(`div`,{className:`md:hidden flex items-center justify-between px-4 py-3 border-b border-line`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-widest text-fg-muted font-semibold`,children:`Sections`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`text-fg-dim hover:text-fg text-xs`,"aria-label":`close nav`,children:`✕`})]}),(0,G.jsx)(`nav`,{className:`py-2 md:py-4 flex-1 overflow-y-auto`,children:rd.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:$(`w-full text-left px-5 py-2.5 text-sm flex items-center gap-2.5 transition-colors`,o===e.id?`bg-bg-active text-fg border-l-2 border-l-accent font-medium`:`text-fg-dim hover:bg-bg-hover hover:text-fg border-l-2 border-l-transparent`),children:[(0,G.jsx)(`span`,{className:`w-4 text-center`,children:e.emoji}),(0,G.jsx)(`span`,{children:e.title})]},e.id))}),(r||i)&&(0,G.jsxs)(`div`,{className:`border-t border-line px-5 py-4 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-dim`,children:`Replay tours`}),r&&(0,G.jsxs)(`button`,{type:`button`,onClick:r,className:`w-full text-left text-xs text-fg-muted hover:text-fg flex items-center gap-2`,title:`Play the 3-step first-run tour again`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`↺`}),(0,G.jsx)(`span`,{children:`Replay first-run tour`})]}),i&&(0,G.jsxs)(`button`,{type:`button`,onClick:i,className:`w-full text-left text-xs text-fg-muted hover:text-fg flex items-center gap-2`,title:`Play the 3-step Threads explainer again`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧵`}),(0,G.jsx)(`span`,{children:`Replay threads tour`})]})]})]}),(0,G.jsxs)(`main`,{ref:u,className:`flex-1 overflow-y-auto min-w-0`,children:[(0,G.jsxs)(`div`,{className:`md:hidden flex items-center gap-2 px-4 py-2 border-b border-line bg-bg-elevated text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Section`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`font-semibold text-fg flex items-center gap-1.5 hover:text-accent transition-colors`,children:[(0,G.jsx)(`span`,{children:p?.emoji}),(0,G.jsx)(`span`,{children:p?.title}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`▾`})]})]}),(0,G.jsxs)(`div`,{className:`max-w-6xl mx-auto px-5 sm:px-8 lg:px-10 py-6 sm:py-10`,children:[o===`taxonomy`&&(0,G.jsx)(cd,{}),o===`threads`&&(0,G.jsx)(Ed,{}),o===`quickstart`&&(0,G.jsx)(Md,{}),o===`web-ui`&&(0,G.jsx)(Fd,{}),o===`cli`&&(0,G.jsx)(zd,{}),o===`shortcuts`&&(0,G.jsx)(Hd,{}),o===`collections`&&(0,G.jsx)(Wd,{}),o===`data`&&(0,G.jsx)(Xd,{}),o===`export`&&(0,G.jsx)(Zd,{}),o===`security`&&(0,G.jsx)(xd,{}),o===`tips`&&(0,G.jsx)($d,{}),o===`mcp`&&(0,G.jsx)(tf,{}),o===`vscode`&&(0,G.jsx)(of,{}),o===`pricing`&&(0,G.jsx)(lf,{}),o===`faq`&&(0,G.jsx)(df,{}),o===`semantic-vectors`&&(0,G.jsx)(hf,{}),o===`bug-patterns`&&(0,G.jsx)(_f,{}),o===`troubleshoot`&&(0,G.jsx)(bf,{}),(0,G.jsx)(`article`,{className:`prose-message prose-help`,dangerouslySetInnerHTML:{__html:f[o]}}),(0,G.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-line flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`Section`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:rd.findIndex(e=>e.id===o)+1}),` `,`of `,rd.length]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Cf,{active:o,direction:-1,onJump:e=>s(e),label:`← prev`}),(0,G.jsx)(Cf,{active:o,direction:1,onJump:e=>s(e),label:`next →`})]})]})]})]})]})]})}function Cf({active:e,direction:t,onJump:n,label:r}){let i=rd[rd.findIndex(t=>t.id===e)+t];return i?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(i.id),className:`text-fg-dim hover:text-fg`,children:[r,` `,i.title]}):(0,G.jsx)(`span`,{className:`text-fg-muted opacity-30`,children:r})}var wf={"cwd-prefix":`Folder path`,"project-id":`Project`,tag:`Tag`,"plan-file":`Plan file`,"git-branch-prefix":`Git branch`},Tf={"cwd-prefix":`Match sessions whose working directory starts with this path.`,"project-id":`Match every session under a specific Claude Code project (by its internal id).`,tag:`Match sessions that carry this tag.`,"plan-file":`Match sessions that reference this plan/doc filename in their transcript.`,"git-branch-prefix":`Match sessions authored on git branches starting with this prefix.`};function Ef(){let e=ir(),t=ar(),n=fr(),r=e.data?.rules??[],i=t.data?.suggestions??[];return(0,G.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6 space-y-8`,children:[(0,G.jsxs)(`header`,{className:`space-y-2`,children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Auto-collections`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Auto-collections group your Claude Code sessions into folders automatically, based on a rule you accept. One click on a suggestion turns into a live folder in the left sidebar that keeps itself populated forever.`}),(0,G.jsxs)(`div`,{className:`rounded border border-line bg-bg-elevated p-3 text-xs text-fg-muted space-y-2`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg text-sm`,children:`Three common rule shapes`}),(0,G.jsxs)(`ul`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Tag`}),` #bugfix →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "bugfix"`}),` that collects every session you tag #bugfix, forever.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Folder path`}),` /Users/you/code/monorepo/packages/web →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "web"`}),` that collects only the monorepo subfolder sessions, separate from the rest of the repo.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Plan file`}),` ROADMAP.md →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "ROADMAP.md"`}),`that collects every session whose transcript mentions that file. Lets you thread planning across repos.`]})]}),(0,G.jsx)(`div`,{className:`border-t border-line pt-2`,children:`Manually added sessions are never removed. Deleting a rule only removes the rows the rule itself added.`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Pending suggestions`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(),disabled:n.isPending,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`Re-scan your sessions right now to surface fresh grouping suggestions.`,children:n.isPending?`scanning…`:`scan now`})]}),i.length===0?(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:`No pending suggestions. New clusters will appear after the next scan.`}):(0,G.jsx)(`ul`,{className:`border border-line rounded divide-y divide-line`,children:i.map(e=>(0,G.jsx)(Df,{suggestion:e},e.id))})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Active rules`}),r.length===0?(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:`No active rules yet. Accept a suggestion above or add one below.`}):(0,G.jsx)(`ul`,{className:`border border-line rounded divide-y divide-line`,children:r.map(e=>(0,G.jsx)(kf,{rule:e},e.id))})]}),(0,G.jsx)(Af,{})]})}function Df({suggestion:e}){let t=ur(),n=dr(),[,r]=Nn(),[i,a]=(0,W.useState)(!1),o=pr(e.id,i),s=e.suggested_name||e.pattern,c=e.session_count,l=`${c} ${c===1?`session`:`sessions`}`,u=e=>r({session:e,view:null,col:null,project:null});return(0,G.jsxs)(`li`,{className:`px-3 py-2 text-sm space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-fg-muted w-20 shrink-0`,title:Tf[e.type],children:wf[e.type]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,title:s,children:s}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-fg-muted font-mono`,title:e.pattern,children:e.pattern})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted shrink-0`,children:l}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.mutate(e.id),disabled:t.isPending,className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Turn this suggestion into an active rule and create the matching sidebar folder.`,children:`Accept`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(e.id),disabled:n.isPending,className:`px-2 py-1 rounded border border-line text-xs hover:bg-bg-hover disabled:opacity-50`,title:`Hide this suggestion so the scanner stops proposing it.`,children:`Dismiss`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted pl-[calc(5rem+0.75rem)]`,children:Of(e)}),(0,G.jsxs)(`div`,{className:`pl-[calc(5rem+0.75rem)]`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`text-[11px] text-accent hover:underline`,"aria-expanded":i,title:`Preview a handful of sessions that this rule would pull in before you accept it.`,children:i?`Hide example sessions`:`See ${Math.min(3,c)} example session${c===1?``:`s`} that will join`}),i&&(0,G.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[o.isLoading&&(0,G.jsx)(`li`,{className:`text-fg-muted italic`,children:`Loading…`}),o.data?.sessions.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`w-full text-left flex items-center gap-2 px-1 py-0.5 rounded hover:bg-accent/10 hover:text-accent`,title:`Open session: ${e.title}`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0`,children:`→`}),(0,G.jsx)(`span`,{className:`truncate flex-1`,children:e.title}),e.started_at&&(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0`,children:new Date(e.started_at).toLocaleDateString()})]})},e.id)),o.data&&o.data.sessions.length===0&&(0,G.jsx)(`li`,{className:`text-fg-muted italic`,children:`No sessions currently match (may have been dismissed).`})]})]})]})}function Of(e){let t=e.suggested_name||e.pattern,n=e.session_count,r=n===1?`session`:`sessions`;switch(e.type){case`cwd-prefix`:return`Creates a folder "${t}" in the sidebar grouping the ${n} ${r} whose working directory is (or is inside) "${e.pattern}". Every future session recorded under that path joins automatically.`;case`project-id`:return`Creates a folder "${t}" grouping every session from the Claude Code project with id ${e.pattern}. Current match: ${n} ${r}.`;case`tag`:return`Creates a folder "${t}" grouping every session tagged #${e.pattern}. Current match: ${n} ${r}. Any future session tagged the same way joins automatically.`;case`plan-file`:return`Creates a folder "${t}" grouping every session whose transcript references "${e.pattern}". Current match: ${n} ${r}.`;case`git-branch-prefix`:return`Creates a folder "${t}" grouping every session whose git branch starts with "${e.pattern}". Current match: ${n} ${r}.`}}function kf({rule:e}){let t=cr(),n=lr(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(e.pattern),s=()=>{if(a===e.pattern){i(!1);return}t.mutate({id:e.id,patch:{pattern:a}},{onSuccess:()=>i(!1)})};return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2 text-sm`,children:[(0,G.jsx)(`label`,{className:`flex items-center gap-2 shrink-0`,title:`enable / disable`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:n=>t.mutate({id:e.id,patch:{enabled:n.target.checked}})})}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted w-28 shrink-0`,title:Tf[e.type],children:wf[e.type]}),r?(0,G.jsx)(`input`,{className:`min-w-0 flex-1 px-2 py-1 bg-bg-elevated border border-line rounded text-xs font-mono`,value:a,onChange:e=>o(e.target.value),onKeyDown:t=>{t.key===`Enter`&&s(),t.key===`Escape`&&(o(e.pattern),i(!1))},autoFocus:!0}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`min-w-0 flex-1 text-left font-mono text-xs truncate hover:text-accent`,title:`click to edit pattern`,children:e.pattern}),(0,G.jsx)(`span`,{className:$(`text-[10px] uppercase px-1.5 py-0.5 rounded-full shrink-0`,e.created_by===`suggestion-accepted`?`bg-role-tool/15 text-role-tool`:`bg-bg-hover text-fg-muted`),title:e.created_by===`suggestion-accepted`?`This rule started as an auto-detected suggestion that you accepted.`:`This rule was added manually through the form below.`,children:e.created_by===`suggestion-accepted`?`✨`:`⚙`}),r?(0,G.jsx)(`button`,{type:`button`,onClick:s,disabled:t.isPending,className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Save the updated pattern and re-match sessions against it.`,children:`Save`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete rule "${e.name}"? The collection stays; only rule-added rows are removed.`)&&n.mutate(e.id)},disabled:n.isPending,className:`px-2 py-1 rounded border border-line text-xs hover:bg-bg-hover disabled:opacity-50`,title:`Remove this rule; the sidebar folder stays and any sessions you added manually remain.`,children:`Delete`})]})}function Af(){let e=sr(),[t,n]=(0,W.useState)(``),[r,i]=(0,W.useState)(`cwd-prefix`),[a,o]=(0,W.useState)(``);return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Add rule manually`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1`,children:`Use this when no suggestion matches what you want. Pick a rule type, set a name (this becomes the collection name in the sidebar), and enter the pattern to match.`})]}),(0,G.jsxs)(`form`,{onSubmit:i=>{i.preventDefault(),!(!t.trim()||!a.trim())&&e.mutate({name:t.trim(),type:r,pattern:a.trim()},{onSuccess:()=>{n(``),o(``)}})},className:`flex flex-wrap gap-2 items-end`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Collection name`}),(0,G.jsx)(`input`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm`,value:t,onChange:e=>n(e.target.value),placeholder:`e.g. my-repo`,title:`Shown as the collection label in the sidebar.`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Match by`}),(0,G.jsx)(`select`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm`,value:r,onChange:e=>i(e.target.value),title:Tf[r],children:Object.keys(wf).map(e=>(0,G.jsx)(`option`,{value:e,title:Tf[e],children:wf[e]},e))})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs min-w-[16rem] flex-1`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Pattern`}),(0,G.jsx)(`input`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm font-mono`,value:a,onChange:e=>o(e.target.value),placeholder:jf(r),title:Tf[r]})]}),(0,G.jsx)(`button`,{type:`submit`,disabled:e.isPending||!t.trim()||!a.trim(),className:`px-3 py-1.5 rounded bg-accent text-bg text-sm font-medium disabled:opacity-50`,title:`Create this rule and add the matching sidebar folder; it will keep itself populated going forward.`,children:`Create`})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:Tf[r]}),e.isError&&(0,G.jsx)(`div`,{className:`text-xs text-role-user`,children:e.error.message})]})}function jf(e){switch(e){case`cwd-prefix`:return`/Users/you/code/my-repo`;case`project-id`:return`42`;case`tag`:return`security`;case`plan-file`:return`ROADMAP.md`;case`git-branch-prefix`:return`feature/`}}var Mf={status:`idle`,jobId:null,current:0,total:0,lastTitled:null,failures:[],summary:null,error:null};function Nf(e){let t=K(),[n,r]=(0,W.useState)(Mf),i=(0,W.useRef)(null),a=(0,W.useCallback)(()=>{i.current&&=(i.current.close(),null)},[]);return(0,W.useEffect)(()=>()=>a(),[a]),{state:n,start:(0,W.useCallback)(async n=>{a(),r({...Mf,status:`starting`});let o;try{o=(await Z.startThreadTitlesJob(e,n)).jobId}catch(e){r({...Mf,status:`error`,error:e instanceof Error?e.message:String(e)});return}r(e=>({...e,status:`running`,jobId:o}));let s=mt(`/api/jobs/${encodeURIComponent(o)}/stream`),c=new EventSource(s);i.current=c,c.addEventListener(`progress`,n=>{let i=JSON.parse(n.data);r(e=>({...e,current:i.current,total:i.total,lastTitled:i})),t.invalidateQueries({queryKey:[`thread`,e]})}),c.addEventListener(`skipped`,()=>{}),c.addEventListener(`error`,e=>{if(typeof e.data==`string`)try{let t=JSON.parse(e.data);r(e=>({...e,failures:[...e.failures,t]}))}catch{}}),c.addEventListener(`done`,n=>{let i=JSON.parse(n.data);r(e=>({...e,status:`done`,summary:i})),a(),t.invalidateQueries({queryKey:[`thread`,e]})})},[a,t,e]),cancel:(0,W.useCallback)(async()=>{if(r(e=>({...e,status:`cancelling`})),n.jobId)try{await Z.cancelJob(n.jobId)}catch{}},[n.jobId]),reset:(0,W.useCallback)(()=>{a(),r(Mf)},[a])}}var Pf=260,Ff=92,If=24,Lf=168,Rf=24,zf=900;function Bf(e,t=new Set,n=Lf){let r=Math.max(If,Math.round(n*If/Lf)),i=new Map;for(let t of e)i.set(t.session_id,t);let a=new Map,o=[];for(let t of e){let e=t.parent_session_id;if(e&&i.has(e)&&e!==t.session_id){let n=a.get(e)??[];n.push(t),a.set(e,n)}else o.push(t)}let s=(e,t)=>{let n=e.role===`origin`?0:1,r=t.role===`origin`?0:1;return n===r?e.added_at.localeCompare(t.added_at):n-r};o.sort(s);for(let e of a.values())e.sort(s);let c=new Map,l=new Set;function u(e){if(c.has(e))return c.get(e);if(l.has(e))return c.set(e,0),0;l.add(e);let t=a.get(e)??[],n=0;for(let e of t)n+=1+u(e.session_id);return l.delete(e),c.set(e,n),n}let d=new Map,f=new Set;function p(e){if(d.has(e))return d.get(e);if(f.has(e))return d.set(e,1),1;f.add(e);let n=t.has(e)?[]:a.get(e)??[],r=0;for(let e of n)r+=p(e.session_id);f.delete(e);let i=Math.max(1,r);return d.set(e,i),i}for(let e of o)p(e.session_id);let m=[],h=new Set,g=0;function _(e,i,o){if(h.has(e.session_id))return;h.add(e.session_id);let s=Rf+(o+(d.get(e.session_id)??1)/2)*(Pf+r)-Pf/2,c=Rf+i*n,l=a.get(e.session_id)??[],f=t.has(e.session_id);if(m.push({edge:e,x:s,y:c,depth:i,hasChildren:l.length>0,hiddenCount:f?u(e.session_id):0}),f)return;let p=o;for(let e of l){let t=d.get(e.session_id)??1;_(e,i+1,p),p+=t}}for(let e of o){let t=d.get(e.session_id)??1;_(e,0,g),g+=t}let v=new Map,y=0,b=0;for(let e of m)v.set(e.edge.session_id,e),e.x+Pf>y&&(y=e.x+Pf),e.y+Ff>b&&(b=e.y+Ff);return{nodes:m,byId:v,width:Math.max(y+Rf,400),height:Math.max(b+Rf,200)}}function Vf(e){return ec({sessionId:e.session_id,alias:e.alias,autoTitle:e.auto_title,firstUserMessage:e.first_user_message,aliasSource:e.alias_source,autoTitleSource:e.auto_title_source})}var Hf={manual:`you linked this session to its parent yourself`,"plan-file":`both sessions reference the same plan or spec file`,"uuid-ref":`one session refers directly to the other by UUID`,"recall-context-ref":`one session was piped into the other via recall context`,semantic:`transcript content overlaps in meaning`,git:`the sessions share a git branch or commit range`,temporal:`the sessions ran close together on related work`};function Uf(e){let t=Math.round(e.confidence*100);return e.source===`manual`?`Manual link (${Hf.manual}).`:`Auto-linked via ${e.source} at ${t}% confidence (${Hf[e.source]}); 100% would mean manually linked.`}function Wf(e,t,n){let r=new Map;for(let e of n)r.set(e.session_id,e);let i=new Set,a=t;for(;a;){if(i.has(a))return!1;i.add(a);let t=r.get(a);if(!t)return!1;if(t.parent_session_id===e)return!0;a=t.parent_session_id}return!1}function Gf({thread:e}){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(1024);return(0,W.useEffect)(()=>{if(!t.current)return;let e=new ResizeObserver(e=>{for(let t of e)r(t.contentRect.width)});return e.observe(t.current),()=>e.disconnect()},[]),(0,G.jsx)(`div`,{ref:t,className:`w-full`,children:n>0&&n<zf?(0,G.jsx)(Jf,{thread:e}):(0,G.jsx)(Kf,{thread:e})})}function Kf({thread:e}){let[,t]=Nn(),n=Su(),r=xu(),i=Kl(),a=`threads.collapsed.${e.id}`,[o,s]=(0,W.useState)(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(a);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}),c=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),typeof window<`u`&&window.localStorage.setItem(a,JSON.stringify(Array.from(n))),n})},l=()=>{s(new Set),typeof window<`u`&&window.localStorage.removeItem(a)},[u,d]=(0,W.useState)(!1),f=(0,W.useRef)(1),[p,m]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`recall.threadVSpacing`),t=e?parseInt(e,10):NaN;if(Number.isFinite(t)&&t>=100&&t<=900)return t}catch{}return 168});(0,W.useEffect)(()=>{try{localStorage.setItem(`recall.threadVSpacing`,String(p))}catch{}},[p]);let{nodes:h,byId:g,width:_,height:v}=(0,W.useMemo)(()=>Bf(e.edges,o,p),[e.edges,o,p]),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(null),C=(0,W.useMemo)(()=>{let t=0,n=0;for(let r of e.edges)r.role===`origin`&&t++,r.source!==`manual`&&r.confidence<1&&n++;return{total:e.edges.length,origins:t,autoPending:n}},[e.edges]),w=(0,W.useRef)(null),[T,E]=(0,W.useState)(null),[D,O]=(0,W.useState)(null),[k,A]=(0,W.useState)(!1);(0,W.useEffect)(()=>{function e(){let e=w.current;if(e&&T&&e.hasPointerCapture(T.pointerId))try{e.releasePointerCapture(T.pointerId)}catch{}E(null),O(null),A(!1)}function t(){document.visibilityState===`hidden`&&e()}return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[T]);let j=(0,W.useCallback)(n=>{t({session:n,view:null,thread:null,project:e.edges.find(e=>e.session_id===n)?.project??null,msg:null,col:null})},[t,e.edges]),M=(0,W.useCallback)((t,r)=>{let i=e.edges.find(e=>e.session_id===t);if(!i)return;let a=i.parent_session_id;a!==r&&n.mutate({threadId:e.id,sessionId:t,parentSessionId:r},{onSuccess:()=>{Q({message:r?`Re-parented ${t.slice(0,8)} to ${r.slice(0,8)}`:`Promoted ${t.slice(0,8)} to origin`,tone:`success`,duration:9e3,action:{label:`Undo`,onClick:()=>{n.mutate({threadId:e.id,sessionId:t,parentSessionId:a})}}})},onError:e=>{Q({message:`Re-parent failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[e.edges,e.id,n]),ee=(0,W.useCallback)(t=>{let n=e.edges.find(e=>e.session_id===t),i=e.edges.filter(e=>e.parent_session_id===t).length,a=n?.alias??t.slice(0,8),o=i>0?`\n\n${i} child session${i===1?``:`s`} will be re-parented to ${n?.parent_session_id?`its grandparent`:`origin`}.`:``;confirm(`Remove "${a}" from this thread?${o}\n\nThe session itself stays in Recall, only the link to this thread is removed.`)&&r.mutate({threadId:e.id,sessionId:t},{onSuccess:()=>{Q({message:`Removed ${a} from thread`,tone:`success`})},onError:e=>{Q({message:`Remove failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[e.edges,e.id,r]),N=(0,W.useCallback)(t=>{S({sessionId:t,value:e.edges.find(e=>e.session_id===t)?.alias??``}),b(null)},[e.edges]),te=(0,W.useCallback)(()=>S(null),[]),P=(0,W.useCallback)(()=>{if(!x)return;let e=x.value.trim();if(!e){S(null);return}let t=x.sessionId;S(null),i.mutate({sessionId:t,alias:e},{onSuccess:()=>{Q({message:`Renamed session to "${e}"`,tone:`success`})},onError:e=>{Q({message:`Rename failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[x,i]),F=(0,W.useCallback)((e,t)=>{let n=w.current;if(!n)return{x:0,y:0};let r=n.getBoundingClientRect(),i=f.current||1;return{x:(e-r.left+n.scrollLeft)/i,y:(t-r.top+n.scrollTop)/i}},[]),I=(0,W.useCallback)((e,t,n)=>{for(let r of h)if(r.edge.session_id!==n&&e>=r.x&&e<=r.x+Pf&&t>=r.y&&t<=r.y+Ff)return r.edge.session_id;return null},[h]),L=(e,t)=>{if(e.button!==0)return;let n=w.current;if(n)try{n.setPointerCapture(e.pointerId)}catch{}let r=F(e.clientX,e.clientY);E({sessionId:t,pointerX:r.x,pointerY:r.y,startX:r.x,startY:r.y,pointerId:e.pointerId}),A(!1)},R=e=>{if(!T||T.pointerId!==e.pointerId)return;let t=F(e.clientX,e.clientY),n=Math.hypot(t.x-T.startX,t.y-T.startY)>16;n&&!k&&A(!0),E({...T,pointerX:t.x,pointerY:t.y}),O(n?I(t.x,t.y,T.sessionId):null)},z=e=>{let t=w.current;if(t?.hasPointerCapture(e))try{t.releasePointerCapture(e)}catch{}},B=t=>{if(!T||T.pointerId!==t.pointerId)return;z(t.pointerId);let n=F(t.clientX,t.clientY),r=Math.hypot(n.x-T.startX,n.y-T.startY),i=k,a=r>16,o=i&&a?I(n.x,n.y,T.sessionId):null,s=T.sessionId;if(E(null),O(null),A(!1),!i){j(s);return}if(a&&o!==s&&o&&o!==s){if(Wf(s,o,e.edges)){Q({message:`Cannot re-parent: that would create a cycle. A thread is a DAG.`,tone:`error`});return}M(s,o)}},V=e=>{T?.pointerId===e.pointerId&&z(e.pointerId),E(null),O(null),A(!1)},ne=(0,W.useMemo)(()=>{let t=[];for(let n of e.edges){let e=n.parent_session_id;if(!e)continue;let r=g.get(n.session_id),i=g.get(e);if(!r||!i)continue;let a=i.x+Pf/2,o=i.y+Ff,s=r.x+Pf/2,c=r.y;t.push({key:`${e}->${n.session_id}`,x1:a,y1:o,x2:s,y2:c,confidence:n.confidence,source:n.source,midX:(a+s)/2,midY:(o+c)/2,title:Uf(n)})}return t},[e.edges,g]),H=T?g.get(T.sessionId)??null:null;return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{title:`Total sessions pulled into this thread.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.total}),` session`,C.total===1?``:`s`,` linked`]}),(0,G.jsxs)(`span`,{title:`Threads can have multiple origins; these are the seed sessions the thread grew from.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.origins}),` origin`,C.origins===1?``:`s`]}),C.autoPending>0&&(0,G.jsxs)(`span`,{title:`Auto-detected links below full confidence that you have not confirmed yet.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.autoPending}),` `,`auto-suggested`]}),(0,G.jsx)(`span`,{className:`ml-auto italic`,children:`Drag a node onto another to re-parent. Drop on empty canvas to cancel.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:$(`px-2.5 py-1 rounded border transition-colors`,u?`border-accent text-accent bg-accent/10`:`border-line text-fg-muted hover:text-accent hover:border-accent`),title:`Scale the entire tree to fit the canvas without scrolling`,children:u?`↔ Fit-to-view (on)`:`↔ Fit-to-view`}),o.size>0&&(0,G.jsxs)(`button`,{type:`button`,onClick:l,className:`px-2.5 py-1 rounded border border-line text-fg-muted hover:text-accent hover:border-accent transition-colors`,title:`Expand every collapsed branch`,children:[`▾ Expand all (`,o.size,`)`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 px-2 py-1 rounded border border-line text-fg-muted`,title:`Vertical spacing between parent and child rows (saved per browser)`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider`,children:`Spacing`}),(0,G.jsx)(`input`,{type:`range`,min:100,max:900,step:4,value:p,onChange:e=>m(parseInt(e.target.value,10)),className:`accent-accent w-24`,"aria-label":`Vertical spacing between rows`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(168),className:`text-[10px] text-fg-muted/70 hover:text-accent`,title:`Reset to default`,children:`reset`})]}),(0,G.jsx)(`span`,{className:`text-[10px] text-fg-muted ml-auto`,children:`Click ▸ on any parent to fold its branch`})]}),(0,G.jsx)(`div`,{ref:w,className:`relative border border-line rounded bg-bg-elevated overflow-auto`,style:{height:Math.min(v+40,700)},onPointerMove:R,onPointerUp:B,onPointerCancel:V,children:(0,G.jsx)(Xf,{enabled:u,contentWidth:_,contentHeight:v,onScaleChange:e=>{f.current=e},children:(0,G.jsxs)(`div`,{style:{width:_,height:v,position:`relative`},"data-share-capture-content":`thread-graph`,children:[(0,G.jsx)(`svg`,{width:_,height:v,className:`absolute inset-0 pointer-events-none`,children:ne.map(e=>{let t=e.source!==`manual`,n=e.confidence>=1?3:Math.max(1,e.confidence*2.5);return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`path`,{d:`M ${e.x1} ${e.y1} C ${e.x1} ${(e.y1+e.y2)/2}, ${e.x2} ${(e.y1+e.y2)/2}, ${e.x2} ${e.y2}`,fill:`none`,stroke:`currentColor`,strokeOpacity:.6,strokeWidth:n,strokeDasharray:t?`5 4`:void 0,className:`text-fg-muted`,style:{pointerEvents:`stroke`},children:(0,G.jsx)(`title`,{children:e.title})}),t&&(0,G.jsxs)(`g`,{transform:`translate(${e.midX-10} ${e.midY-8})`,style:{pointerEvents:`auto`},children:[(0,G.jsx)(`title`,{children:e.title}),(0,G.jsx)(`rect`,{width:20,height:14,rx:3,className:`fill-bg-elevated`,stroke:`currentColor`,strokeOpacity:.5}),(0,G.jsx)(`text`,{x:10,y:10,textAnchor:`middle`,className:`fill-fg-muted`,style:{fontSize:9,fontWeight:600},children:`AI`})]})]},e.key)})}),h.map(e=>{let t=T?.sessionId===e.edge.session_id,n=D===e.edge.session_id,r=e.edge.role===`origin`,i=x?.sessionId===e.edge.session_id,a=Math.round(e.edge.confidence*100),o=e.edge.source===`manual`?`added manually`:`auto-linked via ${e.edge.source} at ${a}% confidence`,s=`${r?`Origin`:`Child`} session ${e.edge.session_id}, ${o}; click to open, drag to re-parent, right-click to rename.`,l=r?`Origin: one of the seed sessions this thread grew from.`:`Child: a session linked under a parent.`,u=e.edge.source===`manual`?``:`Auto-linked via ${e.edge.source} at ${a}% confidence (${Hf[e.edge.source]}); 100% would mean manually linked.`;return(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onPointerDown:t=>{i||L(t,e.edge.session_id)},onContextMenu:t=>{t.preventDefault(),T&&z(T.pointerId),E(null),O(null),A(!1),b({sessionId:e.edge.session_id,x:t.clientX,y:t.clientY})},onKeyDown:t=>{i||(t.key===`Enter`||t.key===` `?(t.preventDefault(),j(e.edge.session_id)):t.key===`F2`&&(t.preventDefault(),N(e.edge.session_id)))},className:$(`absolute select-none rounded border shadow-sm flex flex-col justify-center px-3 py-2 text-left transition-colors`,`focus:outline-none focus:ring-2 focus:ring-accent/60`,r?`bg-accent/20 border-accent/60 text-fg`:`bg-bg border-line text-fg`,t&&`opacity-50 cursor-grabbing`,n&&`ring-2 ring-accent`,i&&`ring-2 ring-accent cursor-text`,!t&&!i&&`cursor-grab hover:border-accent/60`),style:{left:e.x,top:e.y,width:Pf,height:Ff,touchAction:`none`},title:s,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:$(`text-[9px] uppercase tracking-wider px-1 py-0.5 rounded shrink-0`,r?`bg-accent text-bg`:`bg-bg-hover text-fg-muted`),title:l,children:e.edge.role}),e.edge.source!==`manual`&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider px-1 py-0.5 rounded bg-bg-hover text-fg-muted shrink-0`,title:u,children:`AI`}),e.hasChildren&&(0,G.jsx)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),c(e.edge.session_id)},className:$(`ml-auto text-[10px] leading-none px-1.5 py-0.5 rounded shrink-0 border transition-colors`,e.hiddenCount>0?`border-accent text-accent bg-accent/10 hover:bg-accent/20`:`border-line text-fg-muted hover:text-accent hover:border-accent`),title:e.hiddenCount>0?`${e.hiddenCount} descendant${e.hiddenCount===1?``:`s`} hidden — click to expand`:`Fold this branch`,"aria-label":e.hiddenCount>0?`Expand subtree`:`Collapse subtree`,children:e.hiddenCount>0?`▸ +${e.hiddenCount}`:`▾`})]}),i?(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:x.value,onChange:e=>S({sessionId:x.sessionId,value:e.target.value}),onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),P()):e.key===`Escape`&&(e.preventDefault(),te())},onBlur:P,placeholder:Vf(e.edge),"aria-label":`Rename session`,className:`text-sm bg-bg-elevated border border-accent rounded px-1 py-0.5 mt-0.5 outline-none w-full`}):(0,G.jsx)(`div`,{className:`text-[12.5px] leading-snug mt-0.5 break-words overflow-hidden`,children:Vf(e.edge)})]},e.edge.session_id)}),H&&T&&k&&(0,G.jsx)(`div`,{className:`absolute pointer-events-none rounded border border-accent bg-bg shadow-lg px-3 py-2 opacity-80`,style:{left:T.pointerX-Pf/2,top:T.pointerY-Ff/2,width:Pf,height:Ff},children:(0,G.jsx)(`div`,{className:`text-[12.5px] leading-snug break-words overflow-hidden`,children:Vf(H.edge)})})]})})}),y&&(0,G.jsx)(Yf,{x:y.x,y:y.y,sessionId:y.sessionId,onRename:()=>N(y.sessionId),onRemoveFromThread:()=>ee(y.sessionId),onClose:()=>b(null)})]})}function qf(e){let t=new Map;for(let n of e)t.set(n.session_id,{edge:n,children:[]});let n=[];for(let e of t.values()){let r=e.edge.parent_session_id;r&&t.has(r)&&r!==e.edge.session_id?t.get(r).children.push(e):n.push(e)}return n}function Jf({thread:e}){let t=(0,W.useMemo)(()=>qf(e.edges),[e.edges]),[,n]=Nn(),r=xu();if(t.length===0)return(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic p-3 border border-line rounded`,children:`No sessions yet.`});let i=(t,n)=>{let i=n??t.slice(0,8),a=e.edges.filter(e=>e.parent_session_id===t).length,o=a>0?`\n\n${a} child session${a===1?``:`s`} will be re-parented.`:``;confirm(`Remove "${i}" from this thread?${o}\n\nThe session itself stays in Recall, only the link to this thread is removed.`)&&r.mutate({threadId:e.id,sessionId:t},{onSuccess:()=>{Q({message:`Removed ${i} from thread`,tone:`success`})},onError:e=>{Q({message:`Remove failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},a=(e,t)=>{let r=e.edge.role===`origin`,o=Math.round(e.edge.confidence*100),s=e.edge.source===`manual`?`added manually`:`auto-linked via ${e.edge.source} at ${o}% confidence`,c=`${r?`Origin`:`Child`} session ${e.edge.session_id}, ${s}; click to open.`,l=r?`Origin: one of the seed sessions this thread grew from.`:`Child: a session linked under a parent.`,u=e.edge.project??null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 border-b border-line/50 hover:bg-bg-hover`,style:{paddingLeft:`${12+t*20}px`,paddingRight:`8px`},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n({session:e.edge.session_id,view:null,thread:null,project:u,msg:null,col:null}),className:`flex-1 flex items-center gap-2 py-2 text-sm text-left min-w-0`,title:c,children:[(0,G.jsx)(`span`,{className:$(`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded shrink-0`,r?`bg-accent/20 text-accent`:`bg-bg-hover text-fg-muted`),title:l,children:e.edge.role}),(0,G.jsx)(`span`,{className:`truncate`,children:Vf(e.edge)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.edge.session_id,e.edge.alias??null)},className:`text-[10px] text-fg-muted hover:text-role-user opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,title:`remove from this thread (session itself is preserved)`,"aria-label":`remove from thread`,children:`remove`})]}),e.children.map(e=>a(e,t+1))]},e.edge.session_id)};return(0,G.jsx)(`div`,{className:`border border-line rounded`,children:t.map(e=>a(e,0))})}function Yf({x:e,y:t,sessionId:n,onRename:r,onRemoveFromThread:i,onClose:a}){let o=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a()},t=e=>{e.key===`Escape`&&a()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[a]);let[s,c]=(0,W.useState)(`idle`),l=Math.min(e,window.innerWidth-240-8),u=Math.min(t,window.innerHeight-200-8),d=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}};return(0,G.jsxs)(`div`,{ref:o,role:`menu`,"aria-label":`thread node actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:l,top:u,width:240},children:[(0,G.jsxs)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted`,children:[`session `,n.slice(0,8)]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:async()=>{c(await d(n)?`copied`:`failed`),setTimeout(a,700)},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:s===`copied`?`Copied!`:s===`failed`?`Copy failed — try again`:`Copy session ID`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted font-mono`,children:n})]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),a()},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Rename session`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`set an alias that overrides the auto-title`})]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(),i()},className:`block w-full text-left px-3 py-1.5 hover:bg-role-user/10`,children:[(0,G.jsx)(`div`,{className:`text-role-user`,children:`Remove from thread`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`unlinks this session; the session itself is preserved`})]})]})}function Xf({enabled:e,contentWidth:t,contentHeight:n,children:r,onScaleChange:i}){let a=(0,W.useRef)(null),[o,s]=(0,W.useState)(1);return(0,W.useEffect)(()=>{if(!e){s(1),i?.(1);return}let r=a.current?.parentElement;if(!r)return;let o=()=>{let e=r.clientWidth,a=r.clientHeight;if(e<=0||a<=0||t<=0||n<=0)return;let o=Math.min(e/t,a/n,1);s(o),i?.(o)};o();let c=new ResizeObserver(o);return c.observe(r),()=>c.disconnect()},[e,t,n,i]),e?(0,G.jsx)(`div`,{ref:a,style:{width:t*o,height:n*o,position:`relative`},children:(0,G.jsx)(`div`,{style:{transform:`scale(${o})`,transformOrigin:`top left`,width:t,height:n},children:r})}):(0,G.jsx)(G.Fragment,{children:r})}var Zf=`#f97316`,Qf=`#fb923c`,$f=`#4a4a52`;function ep(){return(0,G.jsx)(`span`,{className:`inline-flex items-center justify-center w-7 h-7 align-[-6px] rounded border-2 text-base font-semibold leading-none`,style:{color:Zf,borderColor:Zf},"aria-label":`sync`,children:`⟳`})}function tp(){return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-0 border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(np,{index:`01`,kicker:`Before`,title:`Chats live in many terminals`,description:`Every Claude conversation in an IDE terminal is its own session. Most users juggle dozens, scattered across repos and windows.`,children:(0,G.jsx)(rp,{})}),(0,G.jsx)(np,{index:`02`,kicker:`Action`,title:`Click ⟳ on the repo`,description:`Sync grabs every session whose terminal is still open in that repo's cwd, then infers parent and child links from time, file overlap, and authorship.`,accent:!0,children:(0,G.jsx)(ip,{})}),(0,G.jsx)(np,{index:`03`,kicker:`After`,title:`One thread, ready to pipe`,description:`The whole bundle becomes a single thread you can hand back to Claude as a context-rich prompt. Re-running adds new actives, never duplicates.`,children:(0,G.jsx)(ap,{})})]})}function np({index:e,kicker:t,title:n,description:r,accent:i,children:a}){return(0,G.jsxs)(`div`,{className:`relative bg-bg-hover/20 p-5 flex flex-col gap-3 border-r border-line last:border-r-0`,style:i?{background:`rgba(249, 115, 22, 0.06)`}:void 0,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums leading-none tracking-tight`,style:{color:i?Zf:$f},children:e}),(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.2em] text-fg-muted`,children:t})]}),(0,G.jsx)(`div`,{className:`aspect-[3/2] w-full rounded border border-line bg-bg-elevated/40 flex items-center justify-center overflow-hidden`,children:a}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg mb-1 leading-snug`,children:n}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:r})]})]})}function rp(){return(0,G.jsx)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`Before: scattered terminals`,children:[[20,30],[110,25],[180,50],[40,90],[130,95],[195,110],[70,130]].map(([e,t],n)=>(0,G.jsxs)(`g`,{transform:`translate(${e},${t})`,children:[(0,G.jsx)(`rect`,{width:`44`,height:`22`,rx:`2`,fill:`none`,stroke:$f,strokeWidth:`1.25`}),(0,G.jsx)(`circle`,{cx:`6`,cy:`6`,r:`1.4`,fill:Qf}),(0,G.jsx)(`line`,{x1:`11`,y1:`13`,x2:`38`,y2:`13`,stroke:$f,strokeWidth:`0.8`}),(0,G.jsx)(`line`,{x1:`11`,y1:`17`,x2:`30`,y2:`17`,stroke:$f,strokeWidth:`0.8`})]},n))})}function ip(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`Action: terminals collapse into a thread`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`arr`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,G.jsx)(`path`,{d:`M0,0 L10,5 L0,10 Z`,fill:Zf})})}),[[20,30],[20,70],[20,110],[20,130]].map(([e,t],n)=>(0,G.jsxs)(`g`,{transform:`translate(${e},${t})`,children:[(0,G.jsx)(`rect`,{width:`44`,height:`20`,rx:`2`,fill:`none`,stroke:$f,strokeWidth:`1.25`}),(0,G.jsx)(`circle`,{cx:`6`,cy:`6`,r:`1.4`,fill:Qf}),(0,G.jsx)(`line`,{x1:`11`,y1:`13`,x2:`38`,y2:`13`,stroke:$f,strokeWidth:`0.8`})]},n)),[40,80,120,140].map((e,t)=>(0,G.jsx)(`line`,{x1:`68`,y1:e,x2:`150`,y2:`80`,stroke:Zf,strokeWidth:`1`,strokeDasharray:`3 3`,markerEnd:`url(#arr)`,opacity:`0.85`},t)),(0,G.jsx)(`circle`,{cx:`170`,cy:`80`,r:`22`,fill:`none`,stroke:Zf,strokeWidth:`2`}),(0,G.jsx)(`text`,{x:`170`,y:`85`,textAnchor:`middle`,fontSize:`20`,fill:Zf,fontFamily:`system-ui`,fontWeight:`600`,children:`⟳`})]})}function ap(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`After: thread tree`,children:[(0,G.jsx)(`circle`,{cx:`120`,cy:`32`,r:`9`,fill:Zf}),[60,120,180].map((e,t)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`line`,{x1:`120`,y1:`40`,x2:e,y2:`80`,stroke:Qf,strokeWidth:`1.5`}),(0,G.jsx)(`circle`,{cx:e,cy:`86`,r:`7`,fill:Qf})]},t)),[[40,60],[80,60],[105,120],[135,120],[165,180],[195,180]].map(([e,t],n)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`line`,{x1:t,y1:`92`,x2:e,y2:`128`,stroke:$f,strokeWidth:`1`}),(0,G.jsx)(`circle`,{cx:e,cy:`132`,r:`5`,fill:`none`,stroke:$f,strokeWidth:`1.25`})]},n))]})}function op({kicker:e,value:t,detail:n}){return(0,G.jsxs)(`div`,{className:`bg-bg p-5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-fg-muted mb-2`,children:e}),(0,G.jsx)(`div`,{className:`text-lg font-semibold text-fg mb-1`,children:t}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:n})]})}var sp=`#fb923c`,cp=`#f97316`;function lp({projectId:e,projectName:t,onClose:n}){let r=K(),[i,a]=(0,W.useState)(`preflighting`),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null);(0,W.useEffect)(()=>{let t=!1;return a(`preflighting`),d(null),(async()=>{try{let n=await Z.syncActivePreflight({project_id:e});if(t)return;s(n.plan),a(`review`)}catch(e){if(t)return;d(e instanceof Error?e.message:String(e)),a(`failed`)}})(),()=>{t=!0}},[e]),(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`applying`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]);async function f(){a(`applying`),d(null);try{let n=await Z.syncActiveApply({project_id:e});s(n.plan),l(n.result),a(`done`),r.invalidateQueries({queryKey:[`threads`]}),r.invalidateQueries({queryKey:[`thread-folders`]}),Q({message:n.result.added>0?`Added ${n.result.added} session${n.result.added===1?``:`s`}, set ${n.result.edges_set} edge${n.result.edges_set===1?``:`s`}.`:`Already up to date in ${t}.`,tone:`success`})}catch(e){d(e instanceof Error?e.message:String(e)),a(`failed`),Q({message:`Sync failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}let p=i===`review`&&o!==null&&o.candidates.length>0;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`applying`&&n()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:cp,boxShadow:`0 0 0 2px ${sp} inset`}}),`Sync active sessions in `,t]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i===`applying`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,children:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(0,G.jsxs)(`details`,{className:`group`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer select-none flex items-center justify-between text-[10px] uppercase tracking-[0.2em] text-fg-muted hover:text-fg py-1`,children:[(0,G.jsx)(`span`,{children:`How this works`}),(0,G.jsx)(`span`,{className:`text-fg-muted group-open:rotate-90 transition-transform inline-block`,children:`›`})]}),(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(tp,{}),(0,G.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-px bg-line border border-line rounded overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Scope`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5 truncate`,title:t,children:t})]}),(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Re-runs`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5`,children:`Same thread`})]}),(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Manual edges`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5`,children:`Preserved`})]})]})]})]}),i===`preflighting`&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30 flex items-center gap-3 text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-t-transparent animate-spin`,style:{borderColor:sp,borderTopColor:`transparent`}}),(0,G.jsxs)(`span`,{children:[`Looking at active sessions in `,t,`…`]})]}),(i===`review`||i===`applying`||i===`done`)&&o&&(0,G.jsx)(up,{plan:o,applying:i===`applying`,done:i===`done`,result:c}),i===`failed`&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-1`,children:`Sync failed`}),(0,G.jsx)(`div`,{children:u??`Unknown error`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[i===`review`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded border border-line hover:bg-bg-hover`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:f,disabled:!p,className:`text-xs px-3 py-1.5 rounded text-bg disabled:opacity-40 disabled:cursor-not-allowed font-medium`,style:{background:cp},children:o&&o.proposed_additions.length>0?`Apply (${o.proposed_additions.length} new session${o.proposed_additions.length===1?``:`s`})`:`Apply`})]}),i===`applying`&&(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-t-transparent animate-spin`,style:{borderColor:sp,borderTopColor:`transparent`}}),(0,G.jsx)(`span`,{children:`Writing thread + edges…`})]}),(i===`done`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded text-bg font-medium`,style:{background:cp},children:`Close`})]})]})})}function up({plan:e,applying:t,done:n,result:r}){return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(fp,{plan:e}),e.warnings.length>0&&(0,G.jsx)(`div`,{className:`p-2 rounded border border-role-tool/40 bg-role-tool/10 text-role-tool`,children:e.warnings.map((e,t)=>(0,G.jsxs)(`div`,{children:[`⚠ `,e]},t))}),e.candidates.length===0?(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`No live Claude sessions touched in `,dp(e),` within the rolling window. Open a terminal in this repo and run`,` `,(0,G.jsx)(`code`,{className:`text-fg bg-bg-elevated px-1 py-0.5 rounded`,children:`claude`}),` `,`to get on the list.`]}):(0,G.jsx)(pp,{plan:e}),e.preserved_manual_edges.length>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[e.preserved_manual_edges.length,` manual edge`,e.preserved_manual_edges.length===1?``:`s`,` will be preserved across this sync.`]}),n&&r&&(0,G.jsxs)(`div`,{className:`p-3 rounded text-fg`,style:{background:`rgba(138, 120, 255, 0.10)`,borderColor:sp,borderWidth:1,borderStyle:`solid`},children:[(0,G.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Applied.`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Added `,r.added,` session`,r.added===1?``:`s`,`, set `,r.edges_set,` parent edge`,r.edges_set===1?``:`s`,`, preserved `,r.preserved_manual,` manual edge`,r.preserved_manual===1?``:`s`,`.`]})]}),t&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Writing the thread, sessions, and inferred parent edges…`})]})}function dp(e){return e.project.name}function fp({plan:e}){return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Thread`}),(0,G.jsx)(`span`,{className:`text-fg font-medium truncate`,children:e.thread.name}),(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider`,style:{background:e.thread.exists?`rgba(138, 120, 255, 0.15)`:`rgba(179, 168, 255, 0.20)`,color:sp},children:e.thread.exists?`reusing`:`new`})]}),e.thread.exists&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] mt-1`,children:[e.thread.existing_session_count,` session`,e.thread.existing_session_count===1?``:`s`,` already in this thread. Re-syncing only adds the ones that are missing.`]})]})}function pp({plan:e}){let t=new Set(e.candidates.map(e=>e.session_id)),n=new Map;for(let t of e.proposed_edges)n.set(t.child_id,t);let r=new Set(e.proposed_additions.map(e=>e.session_id));return(0,G.jsxs)(`div`,{className:`border border-line rounded`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line text-fg-muted text-[11px] uppercase tracking-wider flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:`Candidates`}),(0,G.jsxs)(`span`,{children:[e.candidates.length,` session`,e.candidates.length===1?``:`s`,` ·`,` `,e.proposed_additions.length,` new`]})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-line/60`,children:e.candidates.map(e=>{let i=n.get(e.session_id),a=!!i&&t.has(i.parent_id),o=r.has(e.session_id);return(0,G.jsxs)(`li`,{className:`px-3 py-2 flex flex-col gap-0.5`,style:{paddingLeft:a?28:12,borderLeft:a?`2px solid ${sp}40`:`2px solid transparent`},children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider shrink-0`,style:{background:o?`rgba(179, 168, 255, 0.20)`:`rgba(74, 74, 82, 0.25)`,color:o?sp:`#888`},children:o?`new`:`keep`}),(0,G.jsx)(`span`,{className:`font-mono text-fg-muted shrink-0`,children:e.session_id.slice(0,8)}),(0,G.jsx)(`span`,{className:`truncate text-fg`,children:mp(e)})]}),i&&t.has(i.parent_id)&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] flex items-baseline gap-2 ml-1`,children:[(0,G.jsx)(`span`,{children:`parent`}),(0,G.jsx)(`span`,{className:`font-mono`,children:i.parent_id.slice(0,8)}),(0,G.jsxs)(`span`,{className:`font-mono tabular-nums`,style:{color:sp},children:[`[conf `,i.confidence.toFixed(2),`]`]}),(0,G.jsx)(`span`,{className:`truncate`,children:i.reasons.join(` · `)})]})]},e.session_id)})})]})}function mp(e){return e.alias||e.auto_title||(e.first_user_message?e.first_user_message.replace(/\s+/g,` `).slice(0,80):`(no title)`)}function hp(){let[e,t]=Nn(),n=du(),r=e.thread,i=fu(r),a=mu(),o=hu(),s=n.data?.threads??[],c=i.data?.thread??null,[l,u]=(0,W.useState)(``),d=`(no project yet)`,f=(0,W.useMemo)(()=>{let e=new Map;for(let t of s){let n=t.project??d,r=e.get(n);r||(r=[],e.set(n,r)),r.push(t)}return Array.from(e.entries()).sort(([e],[t])=>e===d?1:t===d?-1:e.localeCompare(t))},[s]),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(null),_=`threads.leftPaneWidth`,[v,y]=(0,W.useState)(()=>{if(typeof window>`u`)return 288;let e=window.localStorage.getItem(_),t=e?Number(e):NaN;return Number.isFinite(t)?Math.min(600,Math.max(200,t)):288}),b=`threads.leftPaneCollapsed`,[x,S]=(0,W.useState)(()=>typeof window>`u`?!1:window.localStorage.getItem(b)===`1`),C=()=>{S(e=>{let t=!e;return typeof window<`u`&&window.localStorage.setItem(b,t?`1`:`0`),t})},w=(0,W.useRef)(null),T=e=>{e.preventDefault(),w.current={startX:e.clientX,startWidth:v},e.currentTarget.setPointerCapture(e.pointerId)},E=e=>{if(!w.current)return;let t=w.current.startWidth+(e.clientX-w.current.startX);y(Math.min(600,Math.max(200,t)))},D=e=>{w.current&&(w.current=null,e.currentTarget.releasePointerCapture(e.pointerId),typeof window<`u`&&window.localStorage.setItem(_,String(v)))},O=()=>{y(288),typeof window<`u`&&window.localStorage.setItem(_,`288`)},k=`threads.expandedFolders`,[A,j]=(0,W.useState)(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(k);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}),M=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),typeof window<`u`&&window.localStorage.setItem(k,JSON.stringify(Array.from(n))),n})},[ee,N]=(0,W.useState)(null),te=q({queryKey:[`projects`],queryFn:()=>Z.projects().then(e=>e.mode===`folder`?e.projects:[]),staleTime:6e4}),P=(0,W.useMemo)(()=>{let e=new Map;for(let t of te.data??[])e.set(t.name,t.id);return e},[te.data]),F=gu(),I=_u(),L=vu(),R=F.data?.folders??[],[z,B]=(0,W.useState)(null),[V,ne]=(0,W.useState)(null),[H,re]=(0,W.useState)(null),[ie,ae]=(0,W.useState)(null),oe=yu(),se=()=>{re(null),ae(null)},ce=(e,t)=>{if(H?.kind!==`folder`||H.parentFolderId!==e.parent_folder_id||H.projectScope!==e.project_scope)return;if(H.id===e.id){se();return}let n=R.filter(t=>t.parent_folder_id===e.parent_folder_id&&t.project_scope===e.project_scope).sort((e,t)=>e.sort_order-t.sort_order||e.name.localeCompare(t.name)).map(e=>e.id).filter(e=>e!==H.id),r=n.indexOf(e.id);if(r<0){se();return}let i=t===`before`?r:r+1,a=[...n.slice(0,i),H.id,...n.slice(i)];se(),oe.mutate({parentFolderId:e.parent_folder_id,projectScope:e.project_scope,orderedIds:a},{onError:e=>Q({message:`Reorder failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},U=e=>{if(H?.kind!==`thread`)return;if(e.project_scope!==null&&H.project!==e.project_scope){se(),Q({message:`Can't move thread: it belongs to ${H.project??`no project`} but folder is in ${e.project_scope}`,tone:`error`});return}let t=H.id;se(),o.mutate({id:t,patch:{folder_id:e.id}},{onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},le=(e,t)=>{let n=t.trim();n&&o.mutate({id:e,patch:{name:n}},{onSuccess:()=>{Q({message:`Renamed thread to "${n}"`,tone:`success`})},onError:e=>{Q({message:`Rename failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})};return(0,G.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[x?(0,G.jsxs)(`aside`,{className:`pane shrink-0 w-10 border-r border-line flex flex-col items-center py-3 gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`Expand threads pane`,title:`Expand threads pane`,className:`w-7 h-7 rounded border border-line text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-semibold leading-none transition-colors`,children:`»`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),"aria-label":`Show threads overview`,title:`Show the threads overview`,className:`w-7 h-7 rounded-full border-2 border-fg-muted text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-bold leading-none transition-colors`,children:`?`}),(0,G.jsx)(`span`,{className:`text-base`,title:`Threads`,style:{writingMode:`vertical-rl`},children:`🧵`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold tabular-nums text-fg-muted`,title:`${s.length} thread${s.length===1?``:`s`}`,children:s.length})]}):(0,G.jsxs)(`aside`,{className:`pane shrink-0`,style:{width:`${v}px`},children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsx)(`span`,{className:`text-base`,children:`🧵 Threads`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),"aria-label":`Show how threads work`,className:`w-8 h-8 rounded-full border-2 border-fg-muted text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-lg font-bold leading-none transition-colors`,title:`Show the threads overview (deselects the current thread)`,children:`?`}),(0,G.jsx)(`span`,{className:`text-base font-semibold tabular-nums`,children:s.length}),(0,G.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`Collapse threads pane`,title:`Collapse threads pane (full-width thread view)`,className:`w-7 h-7 rounded border border-line text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-semibold leading-none transition-colors`,children:`«`})]})]}),(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let n=l.trim();n&&a.mutate({name:n},{onSuccess:e=>{u(``),t({thread:e.thread.id})}})},className:`px-3 pt-2 pb-3 border-b border-line flex gap-2`,children:[(0,G.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`New thread name`,className:`flex-1 px-2 py-1 bg-bg-elevated border border-line rounded text-sm`}),(0,G.jsx)(`button`,{type:`submit`,disabled:a.isPending||!l.trim(),className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Create a new empty thread with this name; add sessions to it afterwards.`,children:`Create`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Loading threads…`}),s.length===0&&!n.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted italic`,children:`No threads yet. A thread is one unit of work spanning many sessions (planning session plus its children). Create one with the form above, then add sessions to it from any session's transcript header.`}),f.map(([e,n])=>{let i=!A.has(e),a=e===d?null:e,s=R.filter(e=>e.project_scope===a&&e.parent_folder_id===null),c=n.filter(e=>!e.folder_id),l=ie&&`project`in ie&&ie.project===e;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:$(`flex items-center border-t border-line first:border-t-0`,l&&`bg-accent/15 ring-1 ring-accent/40`),onDragOver:t=>{H?.kind===`thread`&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,ae({project:e,into:!0}))},onDragLeave:()=>{l&&ae(null)},onDrop:e=>{if(H?.kind!==`thread`)return;e.preventDefault();let t=H.id;se(),o.mutate({id:t,patch:{folder_id:null}},{onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>M(e),className:`flex-1 flex items-center gap-2 px-3 py-2 text-sm font-semibold uppercase tracking-wider text-fg-muted hover:bg-bg-hover`,"aria-expanded":!i,title:`${n.length} thread${n.length===1?``:`s`} in ${e}`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 text-center text-fg-muted`,children:i?`▶`:`▼`}),(0,G.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-fg-muted`,children:n.length})]}),e!==d&&P.has(e)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{let t=P.get(e);t!==void 0&&N({id:t,name:e})},className:`px-2.5 py-1.5 text-xl leading-none hover:bg-bg-hover rounded`,style:{color:`#f97316`},title:`Sync currently active Claude sessions in ${e} into a thread (Captain Code Pattern)`,"aria-label":`Sync active sessions for ${e}`,children:`⟳`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{B(e),i&&M(e)},className:`px-2.5 py-1 text-2xl leading-none text-fg-muted hover:text-accent hover:bg-bg-hover rounded`,title:`Create a new subfolder inside ${e}`,"aria-label":`Add subfolder to ${e}`,children:`+`})]}),z===e&&(0,G.jsx)(Tp,{project:e,onCommit:t=>{B(null);let n=t.trim();n&&I.mutate({name:n,projectScope:e===d?null:e,parentFolderId:null},{onError:e=>Q({message:`Subfolder create failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},onCancel:()=>B(null)}),!i&&(0,G.jsxs)(G.Fragment,{children:[s.map(e=>(0,G.jsx)(wp,{folder:e,depth:1,allSubfolders:R,threadsInProject:n,threadId:r,renamingThreadId:h,onSelectThread:e=>t({thread:e}),onThreadContextMenu:(e,t,n)=>m({threadId:e.id,name:e.name,x:t,y:n}),onCommitRename:(e,t)=>{g(null),t.trim()&&t.trim()!==e.name&&le(e.id,t)},onCancelRename:()=>g(null),onDeleteSubfolder:e=>ne(e),confirmingDeleteId:V,onConfirmDelete:e=>{ne(null),L.mutate(e,{onError:e=>Q({message:`Delete failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},onCancelDelete:()=>ne(null),drag:H,setDrag:re,dropHint:ie,setDropHint:ae,onReorderDrop:ce,onFileThreadIntoFolder:U},e.id)),c.map(e=>(0,G.jsx)(gp,{thread:e,active:e.id===r,renaming:h===e.id,onSelect:()=>t({thread:e.id}),onContextMenu:(t,n)=>m({threadId:e.id,name:e.name,x:t,y:n}),onCommitRename:t=>{g(null),t.trim()&&t.trim()!==e.name&&le(e.id,t)},onCancelRename:()=>g(null),onDragStart:()=>re({kind:`thread`,id:e.id,project:e.project??null}),onDragEnd:se},e.id))]})]},e)})]})]}),!x&&(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize threads list`,title:`Drag to resize · double-click to reset`,onPointerDown:T,onPointerMove:E,onPointerUp:D,onDoubleClick:O,className:`w-1 shrink-0 cursor-col-resize bg-line hover:bg-accent transition-colors`}),(0,G.jsx)(`section`,{className:`flex-1 min-w-0 overflow-y-auto`,children:c?(0,G.jsx)(vp,{thread:c,onPatch:o.mutate}):r&&i.isLoading?(0,G.jsx)(`div`,{className:`p-10 text-sm text-fg-muted`,children:`Loading thread…`}):r&&!i.isLoading?(0,G.jsxs)(`div`,{className:`p-10 text-sm text-fg-muted max-w-2xl space-y-3`,children:[(0,G.jsx)(`div`,{className:`text-fg font-semibold`,children:`That thread isn’t here.`}),(0,G.jsx)(`div`,{children:`It may have been archived or deleted. Pick another from the left, or`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),className:`text-accent hover:underline`,children:`show the threads overview →`})]}):(0,G.jsxs)(`div`,{className:`p-10 max-w-4xl`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.2em] text-fg-muted mb-3`,children:`Threads / The Captain Code Pattern`}),(0,G.jsxs)(`h1`,{className:`text-4xl font-semibold text-fg leading-[1.05] mb-3 tracking-tight`,children:[`Three steps. One thread.`,(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{style:{color:`#f97316`},children:`Every session you have open, in one place.`})]}),(0,G.jsxs)(`p`,{className:`text-base text-fg-muted leading-relaxed max-w-2xl mb-10`,children:[`You probably have 5 to 50 Claude chats running across your IDE windows. Sync turns that mess into a tree you can hand back to Claude. Below is what happens, in order, when you click `,(0,G.jsx)(ep,{}),` on any repo.`]}),(0,G.jsx)(tp,{}),(0,G.jsxs)(`div`,{className:`mt-12 grid grid-cols-3 gap-px bg-line border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(op,{kicker:`Scope`,value:`Per-repo`,detail:`Always cwd-bound. Sync from audio-hooks-studio-F never touches ClaudeRecall.`}),(0,G.jsx)(op,{kicker:`Re-runs`,value:`Same thread`,detail:`No daily rollover. The date in the name is the creation date, not a key.`}),(0,G.jsx)(op,{kicker:`Manual edges`,value:`Preserved`,detail:`Anything you wired by hand survives every sync. Only auto edges recompute.`})]}),(0,G.jsxs)(`div`,{className:`mt-10 flex items-center gap-4 text-xs text-fg-muted`,children:[(0,G.jsx)(`code`,{className:`px-2 py-1 rounded bg-bg-elevated border border-line text-fg`,children:`recall threads sync`}),(0,G.jsx)(`span`,{children:`does the same thing as the button. Add`}),(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-bg-elevated border border-line text-fg`,children:`--preflight`}),(0,G.jsx)(`span`,{children:`to dry-run.`})]})]})}),p&&(()=>{let e=s.find(e=>e.id===p.threadId),t=e?.project??null,n=R.filter(e=>e.project_scope===t||e.project_scope===null);return(0,G.jsx)(bp,{x:p.x,y:p.y,threadName:p.name,movableFolders:n,currentFolderId:e?.folder_id??null,onMoveToFolder:e=>{o.mutate({id:p.threadId,patch:{folder_id:e}},{onSuccess:()=>{let t=e?R.find(t=>t.id===e)?.name??`subfolder`:`project root`;Q({message:`Moved "${p.name}" to ${t}`,tone:`success`})},onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})})},onRename:()=>{g(p.threadId),m(null)},onClose:()=>m(null)})})(),ee&&(0,G.jsx)(lp,{projectId:ee.id,projectName:ee.name,onClose:()=>N(null)})]})}function gp({thread:e,active:t,renaming:n,onSelect:r,onContextMenu:i,onCommitRename:a,onCancelRename:o,onDragStart:s,onDragEnd:c}){let[l,u]=(0,W.useState)(e.name);return(0,W.useEffect)(()=>{n&&u(e.name)},[n,e.name]),n?(0,G.jsxs)(`div`,{className:$(`w-full text-left px-3 py-2 border-b border-line/50`,t&&`bg-accent/10`),children:[(0,G.jsx)(`input`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a(l)):e.key===`Escape`&&(e.preventDefault(),o())},onBlur:()=>a(l),"aria-label":`Rename thread`,className:`w-full px-2 py-1 bg-bg-elevated border border-accent rounded text-sm font-medium outline-none`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:`Enter to save, Esc to cancel`})]}):(0,G.jsxs)(`button`,{type:`button`,onClick:r,draggable:!!s,onDragStart:t=>{s&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-recall-thread`,e.id),s())},onDragEnd:c,onContextMenu:e=>{e.preventDefault(),i(e.clientX,e.clientY)},className:$(`w-full text-left px-3 py-2 border-b border-line/50 hover:bg-bg-hover`,t&&`bg-accent/10`),title:`Open the "${e.name}" thread detail view with its session graph (right-click to rename).`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-medium truncate`,title:e.name,children:e.name}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg-muted shrink-0 tabular-nums`,title:`${e.session_count} session${e.session_count===1?``:`s`} currently linked into this thread.`,children:e.session_count})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,G.jsx)(_p,{thread:e}),(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-muted truncate flex-1 min-w-0`,children:[e.origin_count,` origin`,e.origin_count===1?``:`s`,` ·`,` `,e.closed_at?`closed`:`open`,e.summary?` · ${e.summary}`:``]})]})]})}function _p({thread:e}){return!e.project&&e.session_count===0?(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-fg-muted/70 border border-line`,title:`No sessions yet — add a session from any session header to give this thread a project origin.`,children:`empty`}):e.project_count>1?(0,G.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-accent border border-accent/30 cursor-help shrink-0`,title:`Cross-project thread: spans ${e.project_count} projects (dominant: ${e.project??`unknown`}).`,children:[e.project_count,` repos`]}):e.project?(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-fg-muted border border-line truncate max-w-[120px] shrink-0`,title:`All sessions in this thread are from project "${e.project}".`,children:e.project}):null}function vp({thread:e,onPatch:t}){let[,n]=Nn(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(e.name);(0,W.useEffect)(()=>{r||o(e.name)},[e.name,r]);let s=()=>{let n=a.trim();if(i(!1),!n||n===e.name){o(e.name);return}t({id:e.id,patch:{name:n}}),Q({message:`Renamed thread to "${n}"`,tone:`success`})},c=()=>{i(!1),o(e.name)};return(0,G.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,G.jsxs)(`header`,{className:`space-y-1 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r?(0,G.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},onBlur:s,"aria-label":`Rename thread`,className:`text-2xl font-semibold bg-bg-elevated border border-accent rounded px-2 py-0.5 outline-none flex-1`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold cursor-text`,onDoubleClick:()=>i(!0),title:`Double-click (or use the pencil button) to rename this thread.`,children:e.name}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-xs text-fg-muted hover:text-accent px-1.5 py-0.5 rounded border border-transparent hover:border-line`,title:`Rename this thread`,"aria-label":`Rename thread`,children:`✎`})]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.session_count,` session`,e.session_count===1?``:`s`,` ·`,` `,e.closed_at?`closed`:`open`]})]}),e.summary&&(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.summary}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[e.closed_at?(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,patch:{reopen:!0}}),className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Mark this thread as active again so new sessions can be added.`,children:`Reopen`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,patch:{close:!0}}),className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Mark this thread as finished; sessions stay linked and you can reopen it at any time.`,children:`Close thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Archive "${e.name}"? You can still find it with Show archived.`)&&(t({id:e.id,patch:{archive:!0}}),n({thread:null}))},className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Hide this thread from the main list; it stays in the database and reappears under Show archived.`,children:`Archive`}),(0,G.jsx)(xp,{thread:e})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2 max-w-3xl`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Sessions in this thread`}),(0,G.jsx)(yp,{threadId:e.id,existingIds:new Set(e.edges.map(e=>e.session_id))})]}),e.edges.length===0?(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted p-3 border border-line rounded max-w-3xl space-y-2`,children:[(0,G.jsx)(`div`,{className:`italic`,children:`No sessions in this thread yet. Two ways to add:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-5 space-y-1 not-italic`,children:[(0,G.jsxs)(`li`,{children:[`Use the `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ Add session`}),` `,`button above to search and link any session.`]}),(0,G.jsxs)(`li`,{children:[`Open any session from the sidebar and click`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ Add to thread`}),` in its transcript header.`]})]})]}):(0,G.jsx)(`div`,{"data-share-capture":`thread-graph`,"data-share-capture-thread-id":e.id,children:(0,G.jsx)(Gf,{thread:e})})]}),(0,G.jsxs)(`section`,{className:`rounded border border-line bg-bg-elevated p-3 text-xs text-fg-muted space-y-1 max-w-3xl`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg text-sm`,children:`How Threads work`}),(0,G.jsx)(`p`,{children:`A thread is a DAG (not a tree). It can have multiple origins. A session can belong to multiple threads. Manual edges are always authoritative. Auto-detected edges (v0.7 Pro) will show up with a confidence score and will always be undoable.`}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Tip:`}),` pipe a whole thread back into Claude Code with `,(0,G.jsxs)(`span`,{className:`font-mono`,children:[`recall context thread:`,e.id.slice(0,8)]}),`(CLI command landing in v0.15a.2).`]})]})]})}function yp({threadId:e,existingIds:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(``),o=bu(),s=q({queryKey:[`sessions`,{limit:500}],queryFn:()=>Z.sessions({limit:500}),enabled:n,staleTime:3e4}),c=s.data?.items??[],l=(0,W.useMemo)(()=>{let e=i.trim().toLowerCase(),n=c.filter(e=>!t.has(e.id));return e?n.filter(t=>[t.alias??``,t.first_user_message??``,t.project??``,t.id].join(` `).toLowerCase().includes(e)).slice(0,10):n.slice(0,10)},[c,t,i]);return n?(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,G.jsx)(`input`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:`search sessions by alias, project, or first message`,className:`text-xs bg-bg-elevated border border-line rounded px-2 py-1 w-80`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{r(!1),a(``)},className:`text-xs text-fg-muted hover:text-fg`,title:`Close the search without linking any session.`,children:`cancel`})]}),(0,G.jsxs)(`div`,{className:`absolute right-0 top-8 z-20 w-96 max-h-80 overflow-y-auto bg-bg border border-line rounded shadow-lg`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`Loading sessions...`}),l.length===0&&!s.isLoading&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted italic`,children:i?`no matches`:`all sessions are already in this thread`}),l.map(t=>{let n=t.alias||t.first_user_message?.split(`
|
|
649
|
-
`)[0].slice(0,80)||t.id.slice(0,8);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{o.mutate({threadId:e,sessionId:t.id},{onSuccess:()=>a(``)})},className:`w-full text-left px-3 py-2 border-b border-line/40 hover:bg-accent/10 text-xs`,title:`Link ${t.id}`,children:[(0,G.jsx)(`div`,{className:`font-medium truncate`,children:n}),(0,G.jsxs)(`div`,{className:`text-fg-muted truncate`,children:[t.project||`—`,` · `,t.id.slice(0,8)]})]},t.id)})]})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`text-xs px-2 py-1 rounded bg-accent text-bg font-medium`,title:`Search and link any session into this thread (you can also start from a session's transcript header with + Add to thread).`,children:`+ Add session`})}function bp({x:e,y:t,threadName:n,onRename:r,onClose:i,movableFolders:a,currentFolderId:o,onMoveToFolder:s}){let c=(0,W.useRef)(null),[l,u]=(0,W.useState)(`menu`);(0,W.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&(l===`menu`?i():u(`menu`))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i,l]);let d=l===`move`?220:110;return(0,G.jsxs)(`div`,{ref:c,role:`menu`,"aria-label":`thread actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:Math.min(e,window.innerWidth-240-8),top:Math.min(t,window.innerHeight-d-8),width:240},children:[(0,G.jsx)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted truncate`,children:n}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),l===`menu`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),i()},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Rename thread`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`inline edit, Enter to save`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>u(`move`),className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Move to subfolder…`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`file under a subfolder, or move back to the project root`})]})]}),l===`move`&&(0,G.jsxs)(`div`,{className:`max-h-56 overflow-auto`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(null),i()},className:$(`block w-full text-left px-3 py-1.5 hover:bg-bg-hover italic`,o===null?`text-fg`:`text-fg-muted`),children:[`(project root)`,o===null&&` ✓`]}),a.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-[10px] text-fg-muted italic`,children:`No subfolders for this project yet. Create one with the + button on the project header.`}),a.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.id),i()},className:$(`block w-full text-left px-3 py-1.5 hover:bg-bg-hover truncate`,o===e.id?`text-fg`:`text-fg-muted`),children:[`📁 `,e.name,o===e.id&&` ✓`]},e.id))]})]})}function xp({thread:e}){let{state:t,start:n,cancel:r,reset:i}=Nf(e.id),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{if(t.status!==`done`||!t.summary)return;let{generated:e,skipped:n,failed:r}=t.summary;r.length>0?Q({message:`Generated ${e.length}, skipped ${n.length}, ${r.length} failed`,tone:`error`}):Q({message:`Generated ${e.length} title${e.length===1?``:`s`}, skipped ${n.length}`,tone:`success`})},[t.status,t.summary]),t.status===`running`||t.status===`starting`||t.status===`cancelling`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 px-2 py-1 text-xs rounded border border-accent bg-bg-elevated`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`inline-block animate-spin`,children:`⋮`}),(0,G.jsx)(`span`,{children:t.status===`cancelling`?`Cancelling...`:`Titling ${t.current} of ${t.total||`?`}...`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-fg-muted hover:text-accent underline`,title:`Stop the bulk titler. Already-generated titles stay; the rest are skipped.`,children:`Cancel`})]}):(0,G.jsxs)(`span`,{className:`relative`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(t.status===`running`||t.status===`starting`)){c(!0);try{(await Z.threadTitlesPreflight(e.id)).alreadyTitled===0?await n(!1):o(!0)}catch(e){Q({message:`Could not prepare bulk titler: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{c(!1)}}},disabled:s,className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover disabled:opacity-50`,title:`Generate a coherent title for every session in this thread, walking the DAG so children inherit the parent's naming pattern.`,children:s?`Checking...`:`🪄 Title whole thread`}),a&&(0,G.jsx)(Sp,{thread:e,onPick:e=>{o(!1),n(e)},onClose:()=>o(!1)}),t.status===`done`&&t.summary&&t.summary.failed.length>0&&(0,G.jsx)(Cp,{failures:t.summary.failed,onDismiss:i})]})}function Sp({thread:e,onPick:t,onClose:n}){let r=(0,W.useRef)(null);return(0,W.useEffect)(()=>{function e(e){r.current&&!r.current.contains(e.target)&&n()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,G.jsxs)(`div`,{ref:r,role:`dialog`,"aria-label":`Bulk title confirmation`,className:`absolute right-0 top-full mt-1 z-50 w-72 rounded border border-line bg-bg-elevated p-3 shadow-lg text-xs space-y-2`,children:[(0,G.jsxs)(`p`,{className:`text-fg`,children:[`Some sessions in “`,e.name,`” already have agent titles. Pick what to do:`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!1),className:`px-2 py-1 rounded border border-line hover:bg-bg-hover text-left`,children:[`Skip already-titled`,(0,G.jsx)(`span`,{className:`block text-[10px] text-fg-muted`,children:`Only title the untitled sessions. Recommended.`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`px-2 py-1 rounded border border-line hover:bg-bg-hover text-left`,children:[`Regenerate all`,(0,G.jsx)(`span`,{className:`block text-[10px] text-fg-muted`,children:`Replace every title. Old titles stay in auto_title_history.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`px-2 py-1 rounded border border-transparent hover:bg-bg-hover text-fg-muted text-left`,children:`Cancel`})]})]})}function Cp({failures:e,onDismiss:t}){return(0,G.jsxs)(`div`,{role:`alert`,className:`absolute right-0 top-full mt-1 z-50 w-80 rounded border border-line bg-bg-elevated p-3 shadow-lg text-xs space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Some sessions failed to title`}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-accent`,"aria-label":`Dismiss failure panel`,children:`Dismiss`})]}),(0,G.jsx)(`ul`,{className:`max-h-40 overflow-auto space-y-1`,children:e.map(e=>(0,G.jsxs)(`li`,{className:`font-mono text-[10px] text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:e.sessionId.slice(0,8)}),`: `,e.error]},e.sessionId))})]})}function wp(e){let{folder:t,depth:n,allSubfolders:r,threadsInProject:i,drag:a,dropHint:o,setDropHint:s}=e,[c,l]=(0,W.useState)(!0),u=r.filter(e=>e.parent_folder_id===t.id),d=i.filter(e=>e.folder_id===t.id),f=12+n*14,p=e.confirmingDeleteId===t.id,m=a?.kind===`folder`&&a.id!==t.id&&a.parentFolderId===t.parent_folder_id&&a.projectScope===t.project_scope,h=a?.kind===`thread`&&(t.project_scope===null||a.project===t.project_scope),g=m||h,_=o&&`folderId`in o&&o.folderId===t.id?o.pos:null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:$(`flex items-center hover:bg-bg-hover`,m&&_===`before`&&`border-t-2 border-accent`,m&&_===`after`&&`border-b-2 border-accent`,h&&_!==null&&`bg-accent/15 ring-1 ring-accent/40`),draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`application/x-recall-folder`,t.id),e.setDrag({kind:`folder`,id:t.id,parentFolderId:t.parent_folder_id,projectScope:t.project_scope})},onDragEnd:()=>{e.setDrag(null),e.setDropHint(null)},onDragOver:e=>{if(g)if(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m){let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2;s({folderId:t.id,pos:r?`before`:`after`})}else s({folderId:t.id,pos:`after`})},onDragLeave:()=>{_!==null&&s(null)},onDrop:n=>{if(g)if(n.preventDefault(),m){let r=n.currentTarget.getBoundingClientRect(),i=n.clientY<r.top+r.height/2;e.onReorderDrop(t,i?`before`:`after`)}else h&&e.onFileThreadIntoFolder(t)},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex-1 flex items-center gap-2 py-1 text-xs text-fg-muted text-left truncate`,style:{paddingLeft:`${f}px`,paddingRight:`8px`},title:`Subfolder "${t.name}" — drag to reorder, drop a thread here to file it.`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 text-center`,children:c?`▶`:`▼`}),(0,G.jsxs)(`span`,{className:`flex-1 truncate`,children:[`📁 `,t.name]}),(0,G.jsx)(`span`,{className:`text-fg-muted/60`,children:d.length})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>e.onDeleteSubfolder(t.id),className:`px-2 py-1 text-xs text-fg-muted hover:text-role-user`,title:`Delete subfolder (threads inside pop back to project root)`,"aria-label":`Delete subfolder ${t.name}`,children:`×`})]}),p&&(0,G.jsxs)(`div`,{className:`mx-3 my-1 rounded border border-role-user/40 bg-role-user/5 p-2 text-[11px]`,style:{marginLeft:`${f}px`},children:[(0,G.jsxs)(`div`,{className:`text-fg mb-1.5`,children:[`Delete `,(0,G.jsx)(`span`,{className:`font-semibold`,children:t.name}),`?`]}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-2`,children:`Threads inside pop back to the project root; nested subfolders are deleted too.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e.onCancelDelete,className:`px-2 py-0.5 text-fg-muted hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>e.onConfirmDelete(t.id),className:`px-2 py-0.5 rounded bg-role-user/80 text-bg hover:bg-role-user`,autoFocus:!0,children:`Delete`})]})]}),!c&&(0,G.jsxs)(G.Fragment,{children:[u.map(t=>(0,G.jsx)(wp,{folder:t,depth:n+1,allSubfolders:r,threadsInProject:i,threadId:e.threadId,renamingThreadId:e.renamingThreadId,onSelectThread:e.onSelectThread,onThreadContextMenu:e.onThreadContextMenu,onCommitRename:e.onCommitRename,onCancelRename:e.onCancelRename,onDeleteSubfolder:e.onDeleteSubfolder,confirmingDeleteId:e.confirmingDeleteId,onConfirmDelete:e.onConfirmDelete,onCancelDelete:e.onCancelDelete,drag:e.drag,setDrag:e.setDrag,dropHint:e.dropHint,setDropHint:e.setDropHint,onReorderDrop:e.onReorderDrop,onFileThreadIntoFolder:e.onFileThreadIntoFolder},t.id)),d.map(t=>(0,G.jsx)(gp,{thread:t,active:t.id===e.threadId,renaming:e.renamingThreadId===t.id,onSelect:()=>e.onSelectThread(t.id),onContextMenu:(n,r)=>e.onThreadContextMenu(t,n,r),onCommitRename:n=>e.onCommitRename(t,n),onCancelRename:e.onCancelRename,onDragStart:()=>e.setDrag({kind:`thread`,id:t.id,project:t.project??null}),onDragEnd:()=>{e.setDrag(null),e.setDropHint(null)}},t.id))]})]})}function Tp({project:e,onCommit:t,onCancel:n}){let[r,i]=(0,W.useState)(``);return(0,G.jsxs)(`div`,{className:`px-3 py-2 border-t border-line bg-bg-elevated`,children:[(0,G.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),t(r)):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:()=>t(r),placeholder:`Subfolder name in ${e}`,"aria-label":`New subfolder in ${e}`,className:`w-full px-2 py-1 bg-bg border border-accent rounded text-sm outline-none`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:`Enter to create · Esc to cancel`})]})}var Ep=class extends Map{constructor(e,t=Ap){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Dp(this,e))}has(e){return super.has(Dp(this,e))}set(e,t){return super.set(Op(this,e),t)}delete(e){return super.delete(kp(this,e))}};function Dp({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Op({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function kp({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Ap(e){return typeof e==`object`&&e?e.valueOf():e}function jp(e){return e}function Mp(e,...t){return Np(e,jp,jp,t)}function Np(e,t,n,r){return(function e(i,a){if(a>=r.length)return n(i);let o=new Ep,s=r[a++],c=-1;for(let e of i){let t=s(e,++c,i),n=o.get(t);n?n.push(e):o.set(t,[e])}for(let[t,n]of o)o.set(t,e(n,a));return t(o)})(e,0)}var Pp={value:()=>{}};function Fp(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Ip(n)}function Ip(e){this._=e}function Lp(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Ip.prototype=Fp.prototype={constructor:Ip,on:function(e,t){var n=this._,r=Lp(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Rp(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=zp(n[i],e.name,t);else if(t==null)for(i in n)n[i]=zp(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ip(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Rp(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function zp(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Pp,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bp={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Vp(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Bp.hasOwnProperty(t)?{space:Bp[t],local:e}:e}function Hp(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Up(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Wp(e){var t=Vp(e);return(t.local?Up:Hp)(t)}function Gp(){}function Kp(e){return e==null?Gp:function(){return this.querySelector(e)}}function qp(e){typeof e!=`function`&&(e=Kp(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Fh(r,this._parents)}function Jp(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Yp(){return[]}function Xp(e){return e==null?Yp:function(){return this.querySelectorAll(e)}}function Zp(e){return function(){return Jp(e.apply(this,arguments))}}function Qp(e){e=typeof e==`function`?Zp(e):Xp(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Fh(r,i)}function $p(e){return function(){return this.matches(e)}}function em(e){return function(t){return t.matches(e)}}var tm=Array.prototype.find;function nm(e){return function(){return tm.call(this.children,e)}}function rm(){return this.firstElementChild}function im(e){return this.select(e==null?rm:nm(typeof e==`function`?e:em(e)))}var am=Array.prototype.filter;function om(){return Array.from(this.children)}function sm(e){return function(){return am.call(this.children,e)}}function cm(e){return this.selectAll(e==null?om:sm(typeof e==`function`?e:em(e)))}function lm(e){typeof e!=`function`&&(e=$p(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Fh(r,this._parents)}function um(e){return Array(e.length)}function dm(){return new Fh(this._enter||this._groups.map(um),this._parents)}function fm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}fm.prototype={constructor:fm,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function pm(e){return function(){return e}}function mm(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new fm(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function hm(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new fm(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function gm(e){return e.__data__}function _m(e,t){if(!arguments.length)return Array.from(this,gm);var n=t?hm:mm,r=this._parents,i=this._groups;typeof e!=`function`&&(e=pm(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=vm(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Fh(o,r),o._enter=s,o._exit=c,o}function vm(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ym(){return new Fh(this._exit||this._groups.map(um),this._parents)}function bm(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function xm(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Fh(s,this._parents)}function Sm(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Cm(e){e||=wm;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Fh(i,this._parents).order()}function wm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Tm(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Em(){return Array.from(this)}function Dm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Om(){let e=0;for(let t of this)++e;return e}function km(){return!this.node()}function Am(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function jm(e){return function(){this.removeAttribute(e)}}function Mm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Nm(e,t){return function(){this.setAttribute(e,t)}}function Pm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Fm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Im(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Lm(e,t){var n=Vp(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Mm:jm:typeof t==`function`?n.local?Im:Fm:n.local?Pm:Nm)(n,t))}function Rm(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function zm(e){return function(){this.style.removeProperty(e)}}function Bm(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Vm(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Hm(e,t,n){return arguments.length>1?this.each((t==null?zm:typeof t==`function`?Vm:Bm)(e,t,n??``)):Um(this.node(),e)}function Um(e,t){return e.style.getPropertyValue(t)||Rm(e).getComputedStyle(e,null).getPropertyValue(t)}function Wm(e){return function(){delete this[e]}}function Gm(e,t){return function(){this[e]=t}}function Km(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function qm(e,t){return arguments.length>1?this.each((t==null?Wm:typeof t==`function`?Km:Gm)(e,t)):this.node()[e]}function Jm(e){return e.trim().split(/^|\s+/)}function Ym(e){return e.classList||new Xm(e)}function Xm(e){this._node=e,this._names=Jm(e.getAttribute(`class`)||``)}Xm.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Zm(e,t){for(var n=Ym(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Qm(e,t){for(var n=Ym(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function $m(e){return function(){Zm(this,e)}}function eh(e){return function(){Qm(this,e)}}function th(e,t){return function(){(t.apply(this,arguments)?Zm:Qm)(this,e)}}function nh(e,t){var n=Jm(e+``);if(arguments.length<2){for(var r=Ym(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?th:t?$m:eh)(n,t))}function rh(){this.textContent=``}function ih(e){return function(){this.textContent=e}}function ah(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function oh(e){return arguments.length?this.each(e==null?rh:(typeof e==`function`?ah:ih)(e)):this.node().textContent}function sh(){this.innerHTML=``}function ch(e){return function(){this.innerHTML=e}}function lh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function uh(e){return arguments.length?this.each(e==null?sh:(typeof e==`function`?lh:ch)(e)):this.node().innerHTML}function dh(){this.nextSibling&&this.parentNode.appendChild(this)}function fh(){return this.each(dh)}function ph(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mh(){return this.each(ph)}function hh(e){var t=typeof e==`function`?e:Wp(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function gh(){return null}function _h(e,t){var n=typeof e==`function`?e:Wp(e),r=t==null?gh:typeof t==`function`?t:Kp(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function vh(){var e=this.parentNode;e&&e.removeChild(this)}function yh(){return this.each(vh)}function bh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sh(e){return this.select(e?xh:bh)}function Ch(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function wh(e){return function(t){e.call(this,t,this.__data__)}}function Th(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Eh(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Dh(e,t,n){return function(){var r=this.__on,i,a=wh(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Oh(e,t,n){var r=Th(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Dh:Eh,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function kh(e,t,n){var r=Rm(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Ah(e,t){return function(){return kh(this,e,t)}}function jh(e,t){return function(){return kh(this,e,t.apply(this,arguments))}}function Mh(e,t){return this.each((typeof t==`function`?jh:Ah)(e,t))}function*Nh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Ph=[null];function Fh(e,t){this._groups=e,this._parents=t}function Ih(){return new Fh([[document.documentElement]],Ph)}function Lh(){return this}Fh.prototype=Ih.prototype={constructor:Fh,select:qp,selectAll:Qp,selectChild:im,selectChildren:cm,filter:lm,data:_m,enter:dm,exit:ym,join:bm,merge:xm,selection:Lh,order:Sm,sort:Cm,call:Tm,nodes:Em,node:Dm,size:Om,empty:km,each:Am,attr:Lm,style:Hm,property:qm,classed:nh,text:oh,html:uh,raise:fh,lower:mh,append:hh,insert:_h,remove:yh,clone:Sh,datum:Ch,on:Oh,dispatch:Mh,[Symbol.iterator]:Nh};function Rh(e){return typeof e==`string`?new Fh([[document.querySelector(e)]],[document.documentElement]):new Fh([[e]],Ph)}function zh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Bh(e,t){if(e=zh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Vh={capture:!0,passive:!1};function Hh(e){e.preventDefault(),e.stopImmediatePropagation()}function Uh(e){var t=e.document.documentElement,n=Rh(e).on(`dragstart.drag`,Hh,Vh);`onselectstart`in t?n.on(`selectstart.drag`,Hh,Vh):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function Wh(e,t){var n=e.document.documentElement,r=Rh(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,Hh,Vh),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Gh(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Kh(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function qh(){}var Jh=.7,Yh=1/Jh,Xh=`\\s*([+-]?\\d+)\\s*`,Zh=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Qh=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,$h=/^#([0-9a-f]{3,8})$/,eg=RegExp(`^rgb\\(${Xh},${Xh},${Xh}\\)$`),tg=RegExp(`^rgb\\(${Qh},${Qh},${Qh}\\)$`),ng=RegExp(`^rgba\\(${Xh},${Xh},${Xh},${Zh}\\)$`),rg=RegExp(`^rgba\\(${Qh},${Qh},${Qh},${Zh}\\)$`),ig=RegExp(`^hsl\\(${Zh},${Qh},${Qh}\\)$`),ag=RegExp(`^hsla\\(${Zh},${Qh},${Qh},${Zh}\\)$`),og={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Gh(qh,dg,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sg,formatHex:sg,formatHex8:cg,formatHsl:lg,formatRgb:ug,toString:ug});function sg(){return this.rgb().formatHex()}function cg(){return this.rgb().formatHex8()}function lg(){return wg(this).formatHsl()}function ug(){return this.rgb().formatRgb()}function dg(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=$h.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?fg(t):n===3?new gg(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?pg(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?pg(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=eg.exec(e))?new gg(t[1],t[2],t[3],1):(t=tg.exec(e))?new gg(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ng.exec(e))?pg(t[1],t[2],t[3],t[4]):(t=rg.exec(e))?pg(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ig.exec(e))?Cg(t[1],t[2]/100,t[3]/100,1):(t=ag.exec(e))?Cg(t[1],t[2]/100,t[3]/100,t[4]):og.hasOwnProperty(e)?fg(og[e]):e===`transparent`?new gg(NaN,NaN,NaN,0):null}function fg(e){return new gg(e>>16&255,e>>8&255,e&255,1)}function pg(e,t,n,r){return r<=0&&(e=t=n=NaN),new gg(e,t,n,r)}function mg(e){return e instanceof qh||(e=dg(e)),e?(e=e.rgb(),new gg(e.r,e.g,e.b,e.opacity)):new gg}function hg(e,t,n,r){return arguments.length===1?mg(e):new gg(e,t,n,r??1)}function gg(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Gh(gg,hg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new gg(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new gg(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new gg(xg(this.r),xg(this.g),xg(this.b),bg(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_g,formatHex:_g,formatHex8:vg,formatRgb:yg,toString:yg}));function _g(){return`#${Sg(this.r)}${Sg(this.g)}${Sg(this.b)}`}function vg(){return`#${Sg(this.r)}${Sg(this.g)}${Sg(this.b)}${Sg((isNaN(this.opacity)?1:this.opacity)*255)}`}function yg(){let e=bg(this.opacity);return`${e===1?`rgb(`:`rgba(`}${xg(this.r)}, ${xg(this.g)}, ${xg(this.b)}${e===1?`)`:`, ${e})`}`}function bg(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xg(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sg(e){return e=xg(e),(e<16?`0`:``)+e.toString(16)}function Cg(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Eg(e,t,n,r)}function wg(e){if(e instanceof Eg)return new Eg(e.h,e.s,e.l,e.opacity);if(e instanceof qh||(e=dg(e)),!e)return new Eg;if(e instanceof Eg)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Eg(o,s,c,e.opacity)}function Tg(e,t,n,r){return arguments.length===1?wg(e):new Eg(e,t,n,r??1)}function Eg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gh(Eg,Tg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new Eg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new Eg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new gg(kg(e>=240?e-240:e+120,i,r),kg(e,i,r),kg(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Eg(Dg(this.h),Og(this.s),Og(this.l),bg(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=bg(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Dg(this.h)}, ${Og(this.s)*100}%, ${Og(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Dg(e){return e=(e||0)%360,e<0?e+360:e}function Og(e){return Math.max(0,Math.min(1,e||0))}function kg(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Ag=Math.PI/180,jg=180/Math.PI,Mg=-.14861,Ng=1.78277,Pg=-.29227,Fg=-.90649,Ig=1.97294,Lg=Ig*Fg,Rg=Ig*Ng,zg=Ng*Pg-Fg*Mg;function Bg(e){if(e instanceof Hg)return new Hg(e.h,e.s,e.l,e.opacity);e instanceof gg||(e=mg(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(zg*r+Lg*t-Rg*n)/(zg+Lg-Rg),a=r-i,o=(Ig*(n-i)-Pg*a)/Fg,s=Math.sqrt(o*o+a*a)/(Ig*i*(1-i)),c=s?Math.atan2(o,a)*jg-120:NaN;return new Hg(c<0?c+360:c,s,i,e.opacity)}function Vg(e,t,n,r){return arguments.length===1?Bg(e):new Hg(e,t,n,r??1)}function Hg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gh(Hg,Vg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new Hg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new Hg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*Ag,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new gg(255*(t+n*(Mg*r+Ng*i)),255*(t+n*(Pg*r+Fg*i)),255*(t+Ig*r*n),this.opacity)}}));var Ug=e=>()=>e;function Wg(e,t){return function(n){return e+n*t}}function Gg(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Kg(e,t){var n=t-e;return n?Wg(e,n>180||n<-180?n-360*Math.round(n/360):n):Ug(isNaN(e)?t:e)}function qg(e){return(e=+e)==1?Jg:function(t,n){return n-t?Gg(t,n,e):Ug(isNaN(t)?n:t)}}function Jg(e,t){var n=t-e;return n?Wg(e,n):Ug(isNaN(e)?t:e)}var Yg=(function e(t){var n=qg(t);function r(e,t){var r=n((e=hg(e)).r,(t=hg(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Jg(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Xg(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Zg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qg=new RegExp(Zg.source,`g`);function $g(e){return function(){return e}}function e_(e){return function(t){return e(t)+``}}function t_(e,t){var n=Zg.lastIndex=Qg.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Zg.exec(e))&&(i=Qg.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Xg(r,i)})),n=Qg.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?e_(c[0].x):$g(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var n_=180/Math.PI,r_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function i_(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*n_,skewX:Math.atan(c)*n_,scaleX:o,scaleY:s}}var a_;function o_(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?r_:i_(t.a,t.b,t.c,t.d,t.e,t.f)}function s_(e){return e==null||(a_||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),a_.setAttribute(`transform`,e),!(e=a_.transform.baseVal.consolidate()))?r_:(e=e.matrix,i_(e.a,e.b,e.c,e.d,e.e,e.f))}function c_(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Xg(e,i)},{i:c-2,x:Xg(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Xg(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Xg(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Xg(e,n)},{i:s-2,x:Xg(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var l_=c_(o_,`px, `,`px)`,`deg)`),u_=c_(s_,`, `,`)`,`)`),d_=1e-12;function f_(e){return((e=Math.exp(e))+1/e)/2}function p_(e){return((e=Math.exp(e))-1/e)/2}function m_(e){return((e=Math.exp(2*e))-1)/(e+1)}var h_=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<d_)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=f_(y),c=s/(n*g)*(i*m_(t*r+y)-p_(y));return[a+c*d,o+c*f,s*i/f_(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4);function g_(e){return(function t(n){n=+n;function r(t,r){var i=e((t=Vg(t)).h,(r=Vg(r)).h),a=Jg(t.s,r.s),o=Jg(t.l,r.l),s=Jg(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}g_(Kg);var __=g_(Jg);function v_(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}var y_=0,b_=0,x_=0,S_=1e3,C_,w_,T_=0,E_=0,D_=0,O_=typeof performance==`object`&&performance.now?performance:Date,k_=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function A_(){return E_||=(k_(j_),O_.now()+D_)}function j_(){E_=0}function M_(){this._call=this._time=this._next=null}M_.prototype=N_.prototype={constructor:M_,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?A_():+n)+(t==null?0:+t),!this._next&&w_!==this&&(w_?w_._next=this:C_=this,w_=this),this._call=e,this._time=n,R_()},stop:function(){this._call&&(this._call=null,this._time=1/0,R_())}};function N_(e,t,n){var r=new M_;return r.restart(e,t,n),r}function P_(){A_(),++y_;for(var e=C_,t;e;)(t=E_-e._time)>=0&&e._call.call(void 0,t),e=e._next;--y_}function F_(){E_=(T_=O_.now())+D_,y_=b_=0;try{P_()}finally{y_=0,L_(),E_=0}}function I_(){var e=O_.now(),t=e-T_;t>S_&&(D_-=t,T_=e)}function L_(){for(var e,t=C_,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:C_=n);w_=e,R_(r)}function R_(e){y_||(b_&&=clearTimeout(b_),e-E_>24?(e<1/0&&(b_=setTimeout(F_,e-O_.now()-D_)),x_&&=clearInterval(x_)):(x_||=(T_=O_.now(),setInterval(I_,S_)),y_=1,k_(F_)))}function z_(e,t,n){var r=new M_;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var B_=Fp(`start`,`end`,`cancel`,`interrupt`),V_=[];function H_(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;K_(e,n,{name:t,index:r,group:i,on:B_,tween:V_,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function U_(e,t){var n=G_(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function W_(e,t){var n=G_(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function G_(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function K_(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=N_(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return z_(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(z_(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function q_(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function J_(e){return this.each(function(){q_(this,e)})}function Y_(e,t){var n,r;return function(){var i=W_(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function X_(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=W_(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Z_(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=G_(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Y_:X_)(n,e,t))}function Q_(e,t,n){var r=e._id;return e.each(function(){var e=W_(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return G_(e,r).value[t]}}function $_(e,t){var n;return(typeof t==`number`?Xg:t instanceof dg?Yg:(n=dg(t))?(t=n,Yg):t_)(e,t)}function ev(e){return function(){this.removeAttribute(e)}}function tv(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nv(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function rv(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function iv(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function av(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ov(e,t){var n=Vp(e),r=n===`transform`?u_:$_;return this.attrTween(e,typeof t==`function`?(n.local?av:iv)(n,r,Q_(this,`attr.`+e,t)):t==null?(n.local?tv:ev)(n):(n.local?rv:nv)(n,r,t))}function sv(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cv(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function lv(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&cv(e,i)),n}return i._value=t,i}function uv(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&sv(e,i)),n}return i._value=t,i}function dv(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Vp(e);return this.tween(n,(r.local?lv:uv)(r,t))}function fv(e,t){return function(){U_(this,e).delay=+t.apply(this,arguments)}}function pv(e,t){return t=+t,function(){U_(this,e).delay=t}}function mv(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?fv:pv)(t,e)):G_(this.node(),t).delay}function hv(e,t){return function(){W_(this,e).duration=+t.apply(this,arguments)}}function gv(e,t){return t=+t,function(){W_(this,e).duration=t}}function _v(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?hv:gv)(t,e)):G_(this.node(),t).duration}function vv(e,t){if(typeof t!=`function`)throw Error();return function(){W_(this,e).ease=t}}function yv(e){var t=this._id;return arguments.length?this.each(vv(t,e)):G_(this.node(),t).ease}function bv(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();W_(this,e).ease=n}}function xv(e){if(typeof e!=`function`)throw Error();return this.each(bv(this._id,e))}function Sv(e){typeof e!=`function`&&(e=$p(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Zv(r,this._parents,this._name,this._id)}function Cv(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new Zv(o,this._parents,this._name,this._id)}function wv(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Tv(e,t,n){var r,i,a=wv(t)?U_:W_;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ev(e,t){var n=this._id;return arguments.length<2?G_(this.node(),n).on.on(e):this.each(Tv(n,e,t))}function Dv(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ov(){return this.on(`end.remove`,Dv(this._id))}function kv(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Kp(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,H_(l[f],t,n,f,l,G_(u,n)));return new Zv(a,this._parents,t,n)}function Av(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Xp(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=G_(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&H_(p,t,n,h,f,m);a.push(f),o.push(u)}return new Zv(a,o,t,n)}var jv=Ih.prototype.constructor;function Mv(){return new jv(this._groups,this._parents)}function Nv(e,t){var n,r,i;return function(){var a=Um(this,e),o=(this.style.removeProperty(e),Um(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Pv(e){return function(){this.style.removeProperty(e)}}function Fv(e,t,n){var r,i=n+``,a;return function(){var o=Um(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Iv(e,t,n){var r,i,a;return function(){var o=Um(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Um(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Lv(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=W_(this,e),l=c.on,u=c.value[a]==null?s||=Pv(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Rv(e,t,n){var r=(e+=``)==`transform`?l_:$_;return t==null?this.styleTween(e,Nv(e,r)).on(`end.style.`+e,Pv(e)):typeof t==`function`?this.styleTween(e,Iv(e,r,Q_(this,`style.`+e,t))).each(Lv(this._id,e)):this.styleTween(e,Fv(e,r,t),n).on(`end.style.`+e,null)}function zv(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Bv(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&zv(e,a,n)),r}return a._value=t,a}function Vv(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Bv(e,t,n??``))}function Hv(e){return function(){this.textContent=e}}function Uv(e){return function(){var t=e(this);this.textContent=t??``}}function Wv(e){return this.tween(`text`,typeof e==`function`?Uv(Q_(this,`text`,e)):Hv(e==null?``:e+``))}function Gv(e){return function(t){this.textContent=e.call(this,t)}}function Kv(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Gv(r)),t}return r._value=e,r}function qv(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Kv(e))}function Jv(){for(var e=this._name,t=this._id,n=$v(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=G_(c,t);H_(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Zv(r,this._parents,e,n)}function Yv(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=W_(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Xv=0;function Zv(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Qv(e){return Ih().transition(e)}function $v(){return++Xv}var ey=Ih.prototype;Zv.prototype=Qv.prototype={constructor:Zv,select:kv,selectAll:Av,selectChild:ey.selectChild,selectChildren:ey.selectChildren,filter:Sv,merge:Cv,selection:Mv,transition:Jv,call:ey.call,nodes:ey.nodes,node:ey.node,size:ey.size,empty:ey.empty,each:ey.each,on:Ev,attr:ov,attrTween:dv,style:Rv,styleTween:Vv,text:Wv,textTween:qv,remove:Ov,tween:Z_,delay:mv,duration:_v,ease:yv,easeVarying:xv,end:Yv,[Symbol.iterator]:ey[Symbol.iterator]};function ty(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ny={time:null,delay:0,duration:250,ease:ty};function ry(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function iy(e){var t,n;e instanceof Zv?(t=e._id,e=e._name):(t=$v(),(n=ny).time=A_(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&H_(c,e,t,l,o,n||ry(c,t));return new Zv(r,this._parents,e,t)}Ih.prototype.interrupt=J_,Ih.prototype.transition=iy;var{abs:ay,max:oy,min:sy}=Math;[`w`,`e`].map(cy),[`n`,`s`].map(cy),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(cy);function cy(e){return{type:e}}function ly(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return uy(this.cover(t,n),t,n,e)}function uy(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function dy(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)uy(this,o[n],s[n],e[n]);return this}function fy(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function py(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function my(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function hy(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function gy(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new hy(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a))if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new hy(p[3],g,_,c,l),new hy(p[2],o,_,g,l),new hy(p[1],g,s,c,_),new hy(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}return r}function _y(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function vy(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function yy(){return this._root}function by(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function xy(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new hy(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new hy(i,l,u,s,c)),(i=r[2])&&t.push(new hy(i,a,u,l,c)),(i=r[1])&&t.push(new hy(i,l,o,s,u)),(i=r[0])&&t.push(new hy(i,a,o,l,u))}return this}function Sy(e){var t=[],n=[],r;for(this._root&&t.push(new hy(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new hy(a,o,s,u,d)),(a=i[1])&&t.push(new hy(a,u,s,c,d)),(a=i[2])&&t.push(new hy(a,o,d,u,l)),(a=i[3])&&t.push(new hy(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Cy(e){return e[0]}function wy(e){return arguments.length?(this._x=e,this):this._x}function Ty(e){return e[1]}function Ey(e){return arguments.length?(this._y=e,this):this._y}function Dy(e,t,n){var r=new Oy(t??Cy,n??Ty,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Oy(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function ky(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ay=Dy.prototype=Oy.prototype;Ay.copy=function(){var e=new Oy(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=ky(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=ky(r));return e},Ay.add=ly,Ay.addAll=dy,Ay.cover=fy,Ay.data=py,Ay.extent=my,Ay.find=gy,Ay.remove=_y,Ay.removeAll=vy,Ay.root=yy,Ay.size=by,Ay.visit=xy,Ay.visitAfter=Sy,Ay.x=wy,Ay.y=Ey;function jy(e){return function(){return e}}function My(e){return(e()-.5)*1e-6}function Ny(e){return e.x+e.vx}function Py(e){return e.y+e.vy}function Fy(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=jy(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;m<a;++m)for(c=Dy(t,Ny,Py).visitAfter(s),e=0;e<o;++e)l=t[e],f=n[l.index],p=f*f,u=l.x+l.vx,d=l.y+l.vy,c.visit(h);function h(e,t,n,a,o){var s=e.data,c=e.r,m=f+c;if(s){if(s.index>l.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_<m*m&&(h===0&&(h=My(r),_+=h*h),g===0&&(g=My(r),_+=g*g),_=(m-(_=Math.sqrt(_)))/_*i,l.vx+=(h*=_)*(m=(c*=c)/(p+c)),l.vy+=(g*=_)*m,s.vx-=h*(m=1-m),s.vy-=g*m)}return}return t>u+m||a<u-m||n>d+m||o<d-m}}function s(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r<i;++r)a=t[r],n[a.index]=+e(a,r,t)}}return o.initialize=function(e,n){t=e,r=n,c()},o.iterations=function(e){return arguments.length?(a=+e,o):a},o.strength=function(e){return arguments.length?(i=+e,o):i},o.radius=function(t){return arguments.length?(e=typeof t==`function`?t:jy(+t),c(),o):e},o}var Iy=1664525,Ly=1013904223,Ry=4294967296;function zy(){let e=1;return()=>(e=(Iy*e+Ly)%Ry)/Ry}function By(e){return e.x}function Vy(e){return e.y}var Hy=10,Uy=Math.PI*(3-Math.sqrt(5));function Wy(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=N_(d),l=Fp(`tick`,`end`),u=zy();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=Hy*Math.sqrt(.5+t),a=t*Uy;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function Gy(){var e,t,n,r,i=jy(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=Dy(e,By,Vy).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=My(n),m+=d*d),f===0&&(f=My(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=My(n),m+=d*d),f===0&&(f=My(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:jy(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}function Ky(e,t,n){var r,i=jy(.1),a,o;typeof e!=`function`&&(e=jy(+e)),t??=0,n??=0;function s(e){for(var i=0,s=r.length;i<s;++i){var c=r[i],l=c.x-t||1e-6,u=c.y-n||1e-6,d=Math.sqrt(l*l+u*u),f=(o[i]-d)*a[i]*e/d;c.vx+=l*f,c.vy+=u*f}}function c(){if(r){var t,n=r.length;for(a=Array(n),o=Array(n),t=0;t<n;++t)o[t]=+e(r[t],t,r),a[t]=isNaN(o[t])?0:+i(r[t],t,r)}}return s.initialize=function(e){r=e,c()},s.strength=function(e){return arguments.length?(i=typeof e==`function`?e:jy(+e),c(),s):i},s.radius=function(t){return arguments.length?(e=typeof t==`function`?t:jy(+t),c(),s):e},s.x=function(e){return arguments.length?(t=+e,s):t},s.y=function(e){return arguments.length?(n=+e,s):n},s}function qy(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var Jy=Symbol(`implicit`);function Yy(){var e=new Ep,t=[],n=[],r=Jy;function i(i){let a=e.get(i);if(a===void 0){if(r!==Jy)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Ep;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Yy(t,n).unknown(r)},qy.apply(i,arguments),i}__(Vg(-100,.75,.35),Vg(80,1.5,.8));var Xy=__(Vg(260,.75,.35),Vg(80,1.5,.8));Vg();var Zy=e=>()=>e;function Qy(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function $y(e,t,n){this.k=e,this.x=t,this.y=n}$y.prototype={constructor:$y,scale:function(e){return e===1?this:new $y(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new $y(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var eb=new $y(1,0,0);tb.prototype=$y.prototype;function tb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return eb;return e.__zoom}function nb(e){e.stopImmediatePropagation()}function rb(e){e.preventDefault(),e.stopImmediatePropagation()}function ib(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function ab(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ob(){return this.__zoom||eb}function sb(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cb(){return navigator.maxTouchPoints||`ontouchstart`in this}function lb(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function ub(){var e=ib,t=ab,n=lb,r=sb,i=cb,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=h_,l=Fp(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,ob).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,ob),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(eb.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new $y(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new $y(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new $y(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Rh(this.that).datum();l.call(e,this.that,new Qy(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Bh(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],q_(this),s.start();rb(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Rh(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Bh(t,i),l=t.clientX,u=t.clientY;Uh(t.view),nb(t),a.mouse=[c,this.__zoom.invert(c)],q_(this),a.start();function d(e){if(rb(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Bh(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Wh(e.view,a.moved),rb(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Bh(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);rb(r),s>0?Rh(this).transition().duration(s).call(x,d,c,r):Rh(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(nb(t),s=0;s<i;++s)c=r[s],l=Bh(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),q_(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(rb(e),s=0;s<a;++s)c=i[s],l=Bh(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(nb(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Bh(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Rh(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:Zy(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:Zy(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:Zy(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:Zy([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}function db({projectName:e,onPickProject:t}){let[n,r]=(0,W.useState)(`galaxy`),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),f=q({queryKey:[`cog-graph-projects`],queryFn:()=>Z.projects().then(e=>e.mode===`folder`?e.projects:[])}),p=q({queryKey:[`cog-graph`,e],queryFn:()=>Z.graph(e),enabled:!!e}),m=(0,W.useMemo)(()=>wb(p.data?.sessions??[],p.data?.thread_edges??[]),[p.data]),h=(0,W.useMemo)(()=>{let e=new Map;for(let t of m)t.skill&&e.set(t.skill,(e.get(t.skill)??0)+1);let t=0;for(let n of e.values())t+=Math.max(0,n-1);return t},[m]),g=(0,W.useMemo)(()=>Tb(m),[m]),_=(0,W.useMemo)(()=>c?m.find(e=>e.full_id===c)??null:null,[c,m]);return(0,G.jsxs)(`div`,{className:`flex flex-col h-full bg-bg text-fg`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-4 px-6 py-3 border-b border-line bg-bg-elevated`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-sm`,children:`Cognitive Graph`}),(0,G.jsx)(fb,{current:e,available:f.data??[],onPick:t}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-dim`,children:[m.length,` sessions · `,g.length,` clusters`,p.data?.thread_edges?.length?` · ${p.data.thread_edges.length} thread edges`:``,h>0?` · ${h} skill chains`:` · 0 skill chains`]}),(0,G.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`filter by brand / skill / id…`,className:`ml-auto bg-bg border border-line rounded px-3 py-1 text-xs text-fg placeholder:text-fg-dim focus:outline-none focus:border-accent w-64`}),(0,G.jsx)(pb,{view:n,onChange:r})]}),(0,G.jsxs)(`main`,{className:`flex-1 flex min-h-0`,children:[(0,G.jsxs)(`div`,{className:`flex-1 relative overflow-hidden bg-[radial-gradient(ellipse_at_center,#15151a_0%,#0a0a0c_80%)]`,children:[p.isLoading&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-dim text-xs`,children:`loading project graph…`}),p.error&&(0,G.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-warn text-xs`,children:[`error: `,p.error.message]}),p.data&&m.length>0&&(0,G.jsx)(vb,{projectName:e,sessions:m,brandOrder:g,threadEdges:p.data.thread_edges??[],showSkillChains:u,view:n,focusId:i,search:o,onSelect:e=>{l(e),n===`focus`&&a(e)}}),p.data&&m.length===0&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center px-8 text-fg-dim text-xs`,children:(0,G.jsxs)(`div`,{className:`max-w-md space-y-3 text-center`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg`,children:`Graph is empty for this project.`}),(0,G.jsx)(`p`,{className:`leading-relaxed`,children:`The Cognitive Graph populates after Tier-1 inference runs over your sessions and extracts decisions, skills, and outputs to plot.`}),(0,G.jsxs)(`p`,{className:`leading-relaxed`,children:[`Run`,` `,(0,G.jsx)(`code`,{className:`px-1 py-0.5 bg-bg-elevated border border-line rounded text-fg`,children:`recall semantic on`}),` `,`in your terminal, then come back. Or open this project on a different Recall install where extractions have already landed.`]})]})}),(0,G.jsx)(mb,{showSkillChains:u,onToggleSkillChains:()=>d(e=>!e)})]}),(0,G.jsx)(`aside`,{className:`w-80 border-l border-line bg-bg-elevated p-5 overflow-y-auto text-xs`,children:(0,G.jsx)(hb,{session:_,allSessions:m,onPick:e=>{l(e),n===`focus`&&a(e)}})})]})]})}function fb({current:e,available:t,onPick:n}){return(0,G.jsxs)(`select`,{value:e,onChange:e=>n(e.target.value),className:`bg-bg border border-line rounded px-2 py-1 text-xs text-fg cursor-pointer max-w-[16rem]`,children:[t.length===0&&(0,G.jsx)(`option`,{value:e,children:e}),t.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.session_count,`)`]},e.id))]})}function pb({view:e,onChange:t}){return(0,G.jsx)(`div`,{className:`flex gap-1 bg-bg border border-line rounded p-0.5`,children:[`galaxy`,`focus`].map(n=>(0,G.jsx)(`button`,{onClick:()=>t(n),className:`px-3 py-1 text-xs rounded font-medium ${e===n?`bg-accent text-white`:`text-fg-dim hover:text-fg`}`,children:n===`galaxy`?`Galaxy`:`Focus (INDEX)`},n))})}function mb({showSkillChains:e,onToggleSkillChains:t}){return(0,G.jsxs)(`div`,{className:`absolute bottom-4 left-4 bg-bg/90 backdrop-blur-sm border border-line rounded-md px-4 py-3 text-xs text-fg-dim leading-relaxed max-w-sm shadow-lg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1.5`,children:`Reading the galaxy`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-dim mb-3 italic`,children:`Every circle is one terminal session. Lines show how sessions relate.`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1.5`,children:`Circles`}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-4 rounded-full mr-2 shrink-0`,style:{background:`#8a78ff`,boxShadow:`0 0 0 2px #b3a8ff inset`}}),`the project (this repo) — center hub`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3.5 h-3.5 rounded-full mr-2 shrink-0`,style:{background:`#4f9ec4`,boxShadow:`0 0 0 1.5px #86c4dd inset, 0 0 0 2px #4f9ec4`}}),`thread origin — started a family`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-0.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full mr-2 shrink-0`,style:{background:Xy(.78)}}),`a regular session`]}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-dim/80 mb-3 ml-[26px]`,children:`color tracks which agent ran it; size tracks message count`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1.5`,children:`Lines`}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 h-px mr-2 shrink-0`,style:{background:`#4a4a52`,height:1}}),`belongs to this project`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mr-2 shrink-0`,style:{background:`#4f9ec4`,height:2,opacity:.9}}),`child → parent inside a thread`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 hover:text-fg cursor-pointer select-none`,title:`Toggle shared-skill correlation overlay`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:t,className:`cursor-pointer accent-[#b3a8ff]`}),(0,G.jsx)(`span`,{className:`inline-block w-5 shrink-0`,style:{borderTop:`1.5px dashed #b3a8ff`,opacity:e?.85:.3}}),(0,G.jsx)(`span`,{style:{opacity:e?1:.5},children:`sessions sharing a skill`})]})]})}function hb({session:e,allSessions:t,onPick:n}){if(!e)return(0,G.jsx)(`div`,{className:`text-fg-dim italic`,children:`Click a node to inspect.`});let r=t.filter(t=>t.brandKey===e.brandKey&&t.full_id!==e.full_id),i=t.filter(t=>t.skill&&t.skill===e.skill&&t.brandKey!==e.brandKey).slice(0,8);return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-[10px] uppercase tracking-wider text-fg-dim mb-3`,children:`Detail`}),(0,G.jsx)(gb,{label:`Decimal coordinate`,children:(0,G.jsx)(`span`,{className:`font-mono text-accent text-sm font-semibold`,children:e.decimal})}),(0,G.jsx)(gb,{label:`Title`,children:(0,G.jsx)(`span`,{className:`break-words`,children:e.title})}),e.brand&&(0,G.jsx)(gb,{label:`Brand cluster`,children:e.brand}),e.skill&&(0,G.jsx)(gb,{label:`Skill`,children:e.skill}),e.title_quality&&(0,G.jsx)(gb,{label:`Title quality`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:e.title_quality})}),(0,G.jsx)(gb,{label:`Started`,children:e.started_at?new Date(e.started_at).toLocaleString():`—`}),(0,G.jsx)(gb,{label:`Messages`,children:e.msgs}),(0,G.jsx)(gb,{label:`Session UUID`,children:(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-fg-dim break-all`,children:e.full_id})}),r.length>0&&(0,G.jsx)(_b,{label:`Same-brand siblings (${r.length})`,peers:r.slice(0,8),onPick:n,overflow:r.length>8?r.length-8:0}),i.length>0&&(0,G.jsx)(_b,{label:`Same-skill cousins (other brands)`,peers:i,onPick:n})]})}function gb({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-fg-dim mb-1`,children:e}),(0,G.jsx)(`div`,{className:`text-fg leading-snug`,children:t})]})}function _b({label:e,peers:t,onPick:n,overflow:r}){return(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-line`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-fg-dim mb-1`,children:e}),t.map(e=>(0,G.jsxs)(`button`,{onClick:()=>n(e.full_id),className:`w-full text-left px-2 py-1.5 -mx-2 rounded hover:bg-bg flex items-baseline gap-2 cursor-pointer`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-accent min-w-[3rem]`,children:e.decimal}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg truncate flex-1`,children:e.title})]},e.full_id)),r?(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-dim mt-1 px-2`,children:[`+`,r,` more`]}):null]})}function vb({projectName:e,sessions:t,brandOrder:n,threadEdges:r,showSkillChains:i,view:a,focusId:o,search:s,onSelect:c}){let l=(0,W.useRef)(null),u=(0,W.useRef)(null),[d,f]=(0,W.useState)({w:800,h:600}),p=(0,W.useRef)(eb),m=(0,W.useRef)(a),h=(0,W.useRef)(c);return(0,W.useEffect)(()=>{h.current=c},[c]),(0,W.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(()=>{f({w:e.clientWidth,h:e.clientHeight})});return t.observe(e),f({w:e.clientWidth,h:e.clientHeight}),()=>t.disconnect()},[]),(0,W.useEffect)(()=>{if(!l.current||t.length===0)return;let i=Rh(l.current);i.selectAll(`*`).remove(),m.current!==a&&(p.current=eb,m.current=a);let s=bb(i,d,p),c=e=>h.current(e);a===`galaxy`?Sb(i,s,e,t,n,r,!0,d,c):Cb(i,s,t,n,o,d,c)},[e,t,n,r,a,o,d]),(0,W.useEffect)(()=>{l.current&&Rh(l.current).select(`g.skill-edges`).style(`display`,i?null:`none`)},[i]),(0,W.useEffect)(()=>{if(!l.current)return;let e=Rh(l.current),t=s.trim().toLowerCase();if(!t){e.selectAll(`circle.node`).classed(`dim`,!1),e.selectAll(`line.link`).classed(`dim`,!1);return}e.selectAll(`circle.node`).classed(`dim`,e=>{let n=(e?.title??``).toLowerCase(),r=(e?.brand??``).toLowerCase(),i=(e?.skill??``).toLowerCase(),a=(e?.id??``).toLowerCase();return!(n.includes(t)||r.includes(t)||i.includes(t)||a.includes(t))}),e.selectAll(`line.link`).classed(`dim`,!0)},[s]),(0,G.jsx)(`div`,{ref:u,className:`absolute inset-0`,children:(0,G.jsx)(`svg`,{ref:l,className:`w-full h-full block`})})}var yb=v_(e=>Xy(.55+e*.4),20);function bb(e,t,n){let r=e.append(`g`).attr(`class`,`zoom-root`);r.attr(`transform`,n.current.toString());let i=ub().scaleExtent([.2,8]).translateExtent([[-t.w,-t.h],[t.w*2,t.h*2]]).filter(e=>e.type===`wheel`?!0:e.type===`mousedown`?e.button===0?!e.target?.closest(`circle.node`):!1:(e.type,!0)).on(`zoom`,e=>{n.current=e.transform,r.attr(`transform`,e.transform.toString())});return e.call(i),e.call(i.transform,n.current),e.on(`dblclick.zoom`,null),e.on(`dblclick`,t=>{t.target?.closest(`circle.node`)||e.transition().duration(250).call(i.transform,eb)}),r}function xb(e){return 3+Math.min(8,Math.sqrt(e.msgs)/4)}function Sb(e,t,n,r,i,a,o,s,c){let{w:l,h:u}=s;e.attr(`viewBox`,`0 0 ${l} ${u}`);let d=l/2,f=u/2,p=Math.min(l,u)*.32,m=Yy().domain(i).range(yb),h=new Map;for(let e of r)h.set(e.full_id,e);let g=new Map,_=new Map;for(let e of a)h.has(e.session_id)&&(g.has(e.session_id)||g.set(e.session_id,{threadId:e.thread_id,role:e.role,parent:e.parent_session_id}),_.has(e.thread_id)||_.set(e.thread_id,[]),_.get(e.thread_id).push(e.session_id));let v=Array.from(_.entries()).filter(([,e])=>e.length>=2),y=new Set(v.map(([e])=>e));for(let[e,t]of g.entries())y.has(t.threadId)||g.delete(e);v.sort((e,t)=>t[1].length-e[1].length);let b=new Map;v.forEach(([e],t)=>{let n=t/Math.max(v.length,1)*2*Math.PI-Math.PI/2;b.set(e,{x:d+Math.cos(n)*p,y:f+Math.sin(n)*p})});let x=r.filter(e=>!g.has(e.full_id)),S=new Map,C=new Map;for(let[e,t]of g.entries())t.role===`child`&&t.parent&&(C.has(t.parent)||C.set(t.parent,[]),C.get(t.parent).push(e));for(let[e,t]of _.entries()){if(!y.has(e))continue;let n=b.get(e),r=t.filter(e=>{let t=g.get(e);return!!t&&(t.role===`origin`||!t.parent)});r.forEach((e,t)=>{if(r.length===1)S.set(e,{x:n.x,y:n.y});else{let i=-Math.PI/2+t/r.length*2*Math.PI;S.set(e,{x:n.x+Math.cos(i)*40,y:n.y+Math.sin(i)*40})}})}let w=Array.from(S.keys()),T=0;for(;w.length>0&&T<8;){let e=[];for(let t of w){let n=S.get(t),r=C.get(t)??[];if(r.length===0)continue;let i=180*.75**T,a=Math.atan2(n.y-f,n.x-d),o=r.length,s=o<=1?0:o===2?Math.PI/2:o===3?2*Math.PI/3:o<=5?Math.PI:o<=7?3*Math.PI/2:2*Math.PI,c=s>=2*Math.PI-1e-9;r.forEach((t,r)=>{if(S.has(t))return;let l;l=o===1?a:c?a-s/2+r/o*s:a-s/2+r/(o-1)*s,S.set(t,{x:n.x+Math.cos(l)*i,y:n.y+Math.sin(l)*i}),e.push(t)})}w=e,T++}let E=r.map((e,t)=>{let n=g.get(e.full_id),r=S.get(e.full_id);if(n&&r)return{...e,x:r.x,y:r.y};let i=x.indexOf(e),a=(i>=0?i:t)/Math.max(x.length,1)*2*Math.PI;return{...e,x:d+Math.cos(a)*p,y:f+Math.sin(a)*p}}),D=new Map;E.forEach((e,t)=>D.set(e.full_id,t));let O=[];for(let[e,t]of g.entries()){if(t.role!==`child`||!t.parent)continue;let n=D.get(e),r=D.get(t.parent);n==null||r==null||O.push({source:n,target:r})}let k=E.filter(e=>{let t=g.get(e.full_id);return!t||t.role===`origin`}),A=[];if(o){let e=new Map;for(let t of r)t.skill&&(e.has(t.skill)||e.set(t.skill,[]),e.get(t.skill).push(t));for(let t of e.values()){let e=t.slice().sort((e,t)=>(e.started_at??``).localeCompare(t.started_at??``));for(let t=1;t<e.length;t++){let n=D.get(e[t-1].full_id),r=D.get(e[t].full_id);n==null||r==null||A.push({source:n,target:r})}}}let j=t.append(`g`).attr(`class`,`spokes`),M=t.append(`g`).attr(`class`,`skill-edges`),ee=t.append(`g`).attr(`class`,`family-edges`),N=t.append(`g`).attr(`class`,`origin-halos`),te=t.append(`g`).attr(`class`,`hub`),P=t.append(`g`).attr(`class`,`nodes`),F=j.selectAll(`line`).data(k).enter().append(`line`).attr(`class`,`spoke`).attr(`stroke`,`#4a4a52`).attr(`stroke-opacity`,.1).attr(`stroke-width`,.5),I=M.selectAll(`line`).data(A).enter().append(`line`).attr(`class`,`link skill`).attr(`stroke`,`#b3a8ff`).attr(`stroke-opacity`,1).attr(`stroke-width`,2).attr(`stroke-dasharray`,`8 4`),L=ee.selectAll(`line`).data(O).enter().append(`line`).attr(`class`,`link family`).attr(`stroke`,`#4f9ec4`).attr(`stroke-opacity`,1).attr(`stroke-width`,2.5),R=E.filter(e=>g.get(e.full_id)?.role===`origin`),z=N.selectAll(`circle`).data(R).enter().append(`circle`).attr(`class`,`origin-halo`).attr(`fill`,`none`).attr(`stroke`,`#86c4dd`).attr(`stroke-opacity`,.35).attr(`stroke-width`,1).style(`pointer-events`,`none`);te.append(`circle`).attr(`class`,`node hub`).attr(`cx`,d).attr(`cy`,f).attr(`r`,18).attr(`fill`,`#8a78ff`).attr(`stroke`,`#b3a8ff`).attr(`stroke-width`,3).style(`pointer-events`,`none`),te.append(`text`).attr(`text-anchor`,`middle`).attr(`x`,d).attr(`y`,f+18+18).attr(`fill`,`#e6e6e8`).attr(`font-size`,13).attr(`font-weight`,600).style(`pointer-events`,`none`).text(n.length>38?n.slice(0,36)+`…`:n);let B=P.selectAll(`circle`).data(E).enter().append(`circle`).attr(`class`,e=>`node`+(g.get(e.full_id)?.role===`origin`?` origin`:``)).attr(`r`,e=>{let t=g.get(e.full_id),n=xb(e);return t?.role===`origin`?(C.get(e.full_id)??[]).length>0?14:Math.max(n+4,9):n}).attr(`fill`,e=>g.get(e.full_id)?.role===`origin`?`#4f9ec4`:m(e.brandKey)).attr(`stroke`,e=>g.get(e.full_id)?.role===`origin`?`#86c4dd`:`#0e0e10`).attr(`stroke-width`,e=>g.get(e.full_id)?.role===`origin`?2:1.2).attr(`fill-opacity`,e=>g.has(e.full_id)?1:.35).style(`cursor`,`pointer`).on(`click`,(e,t)=>c(t.full_id));B.append(`title`).text(e=>{let t=g.get(e.full_id);return`${t?`[${t.role}] `:``}${e.decimal} · ${e.title}`});for(let e of E)g.has(e.full_id)&&(e.fx=e.x,e.fy=e.y);let V=new Map,ne=[];for(let[e,t]of g.entries())(t.role===`origin`||!t.parent)&&(V.set(e,0),ne.push(e));for(;ne.length;){let e=ne.shift(),t=V.get(e);for(let n of C.get(e)??[])V.has(n)||(V.set(n,t+1),ne.push(n))}let H=Wy(E).force(`moon`,e=>{let t=.35*e;for(let e of E){let n=g.get(e.full_id);if(!n||n.role!==`child`||!n.parent)continue;let r=D.get(n.parent);if(r==null)continue;let i=E[r],a=(e.x??0)-(i.x??0),o=(e.y??0)-(i.y??0),s=Math.sqrt(a*a+o*o)||.01,c=(180*.75**((V.get(e.full_id)??1)-1)-s)/s;e.vx=(e.vx??0)+a*c*t,e.vy=(e.vy??0)+o*c*t}}).force(`anchor`,e=>{let t=.45*e;for(let e of E){let n=g.get(e.full_id);if(!n||!(n.role===`origin`||!n.parent))continue;let r=b.get(n.threadId);r&&(e.vx=(e.vx??0)+(r.x-(e.x??0))*t,e.vy=(e.vy??0)+(r.y-(e.y??0))*t)}}).force(`radial`,Ky(p,d,f).strength(e=>g.has(e.full_id)?0:.18)).force(`charge`,Gy().strength(e=>g.has(e.full_id)?-40:-220).distanceMax(520)).force(`collide`,Fy().radius(e=>xb(e)+10).strength(.95)).on(`tick`,()=>{F.attr(`x1`,e=>e.x??0).attr(`y1`,e=>e.y??0).attr(`x2`,d).attr(`y2`,f),I.attr(`x1`,e=>E[e.source].x??0).attr(`y1`,e=>E[e.source].y??0).attr(`x2`,e=>E[e.target].x??0).attr(`y2`,e=>E[e.target].y??0),L.attr(`x1`,e=>E[e.source].x??0).attr(`y1`,e=>E[e.source].y??0).attr(`x2`,e=>E[e.target].x??0).attr(`y2`,e=>E[e.target].y??0),B.attr(`cx`,e=>e.x??0).attr(`cy`,e=>e.y??0),z.attr(`cx`,e=>e.x??0).attr(`cy`,e=>e.y??0).attr(`r`,e=>{if((C.get(e.full_id)??[]).length>0)return 28;let t=xb(e);return Math.max(t+5,10)+6})});setTimeout(()=>H.alphaTarget(0).stop(),4e3)}function Cb(e,t,n,r,i,a,o){let{w:s,h:c}=a;e.attr(`viewBox`,`0 0 ${s} ${c}`);let l=n.find(e=>e.full_id===i)??n.find(e=>e.brandKey===r[0])??n[0];if(!l)return;let u=n.filter(e=>e.brandKey===l.brandKey&&e.full_id!==l.full_id).slice(0,24),d=n.filter(e=>e.skill&&e.skill===l.skill&&e.brandKey!==l.brandKey).slice(0,18),f=[l,...u,...d],p=Math.min(s,c)*.18,m=Math.min(s,c)*.34,h=f.map((e,t)=>{if(t===0)return{...e,x:s/2,y:c/2};if(t<=u.length){let n=(t-1)/Math.max(u.length,1)*2*Math.PI;return{...e,x:s/2+Math.cos(n)*p,y:c/2+Math.sin(n)*p}}let n=(t-1-u.length)/Math.max(d.length,1)*2*Math.PI+.18;return{...e,x:s/2+Math.cos(n)*m,y:c/2+Math.sin(n)*m}}),g=[...u.map(e=>({source:0,target:f.indexOf(e),kind:`intra`})),...d.map(e=>({source:0,target:f.indexOf(e),kind:`inter`}))],_=t.append(`g`).attr(`class`,`links`),v=t.append(`g`).attr(`class`,`nodes`),y=t.append(`g`).attr(`class`,`labels`);_.selectAll(`line`).data(g).enter().append(`line`).attr(`class`,`link bright`).attr(`stroke`,`#8a78ff`).attr(`stroke-opacity`,e=>e.kind===`intra`?.9:.45).attr(`stroke-width`,e=>e.kind===`intra`?1.4:.7).attr(`x1`,e=>h[e.source].x).attr(`y1`,e=>h[e.source].y).attr(`x2`,e=>h[e.target].x).attr(`y2`,e=>h[e.target].y);let b=Yy().domain(r).range(yb);v.selectAll(`circle`).data(h).enter().append(`circle`).attr(`class`,(e,t)=>`node`+(t===0?` focused`:``)).attr(`cx`,e=>e.x).attr(`cy`,e=>e.y).attr(`r`,(e,t)=>t===0?14:xb(e)+1).attr(`fill`,(e,t)=>t===0?`#8a78ff`:b(e.brandKey)).attr(`stroke`,(e,t)=>t===0?`#b3a8ff`:`#0e0e10`).attr(`stroke-width`,(e,t)=>t===0?3:1.2).style(`cursor`,`pointer`).on(`click`,(e,t)=>o(t.full_id)).append(`title`).text(e=>`${e.decimal} · ${e.title}`),y.append(`text`).attr(`class`,`focus-label`).attr(`text-anchor`,`middle`).attr(`fill`,`#e6e6e8`).attr(`font-size`,13).attr(`font-weight`,600).style(`pointer-events`,`none`).attr(`x`,s/2).attr(`y`,c/2+32).text(`${l.decimal} · INDEX`)}function wb(e,t){let n=Mp(e.map(e=>({...e,brandKey:e.brand??`Other`})),e=>e.brandKey),r=Array.from(n.keys()).sort((e,t)=>n.get(t).length-n.get(e).length),i=[];for(let e of r){let t=n.get(e).slice().sort((e,t)=>{let n=e.skill??`zzz`,r=t.skill??`zzz`;return n===r?(e.started_at??``).localeCompare(t.started_at??``):n.localeCompare(r)}),a=Array.from(new Set(t.map(e=>e.skill??`(prompt)`))),o=r.indexOf(e)+1,s=new Map;for(let e of t){let t=e.skill??`(prompt)`,n=a.indexOf(t)+1,r=(s.get(t)??0)+1;s.set(t,r),i.push({...e,decimal:`${o}.${n}.${r}`})}}let a=new Map(i.map(e=>[e.full_id,e])),o=new Map;for(let e of t)e.role!==`child`||!e.parent_session_id||!a.has(e.session_id)||!a.has(e.parent_session_id)||(o.has(e.parent_session_id)||o.set(e.parent_session_id,[]),o.get(e.parent_session_id).push(e.session_id));for(let e of o.values())e.sort((e,t)=>{let n=a.get(e)?.started_at??``,r=a.get(t)?.started_at??``;return n.localeCompare(r)});let s=new Set;for(let e of t)e.role===`child`&&e.parent_session_id&&a.has(e.session_id)&&s.add(e.session_id);let c=new Set,l=e=>{if(c.has(e))return;c.add(e);let t=a.get(e);t&&(o.get(e)??[]).forEach((e,n)=>{let r=a.get(e);r&&(r.decimal=`${t.decimal}.${n+1}`,l(e))})};for(let e of a.keys())s.has(e)||l(e);return i}function Tb(e){let t=Mp(e,e=>e.brandKey);return Array.from(t.keys()).sort((e,n)=>t.get(n).length-t.get(e).length)}var Eb=[`citation`,`similar`,`skill_track`,`bug_pattern`,`wiki_link`,`temporal_proximity`],Db=[`L1`,`L2`,`L3`,`L4`,`user`],Ob={status:`pending`,linkType:`all`,inferredBy:`all`,minConfidence:0};function kb(e){return`${Math.round(e*100)}%`}function Ab(e){return e>=.9?`text-green-400`:e>=.7?`text-amber-400`:`text-fg-dim`}function jb(e){return{citation:{label:`citation`,className:`bg-blue-500/20 text-blue-300`},similar:{label:`similar`,className:`bg-purple-500/20 text-purple-300`},skill_track:{label:`skill`,className:`bg-emerald-500/20 text-emerald-300`},bug_pattern:{label:`bug`,className:`bg-red-500/20 text-red-300`},wiki_link:{label:`wiki`,className:`bg-amber-500/20 text-amber-300`},temporal_proximity:{label:`temporal`,className:`bg-slate-500/20 text-slate-300`}}[e]}function Mb(e){return e.slice(0,8)}function Nb(){let e=K(),[t,n]=(0,W.useState)(Ob),[r,i]=(0,W.useState)(null),a=q({queryKey:[`suggestions`,t.status,t.linkType,t.inferredBy],queryFn:()=>Z.listSuggestions({status:t.status,linkType:t.linkType===`all`?void 0:t.linkType,inferredBy:t.inferredBy===`all`?void 0:t.inferredBy,limit:1e3})}),o=a.data?.suggestions??[],s=(0,W.useMemo)(()=>o.filter(e=>e.confidence>=t.minConfidence),[o,t.minConfidence]),c=J({mutationFn:({id:e,status:t})=>Z.decideSuggestion(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`suggestions`]}),Q({message:n.status===`approved`?`Suggestion approved — added to session_links`:`Suggestion rejected — tombstoned`,tone:`success`,duration:2500})},onError:e=>{Q({message:`Decide failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}),l=J({mutationFn:({ids:e,status:t})=>Z.bulkDecideSuggestions(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`suggestions`]}),Q({message:`Bulk ${n.status}: decided=${t.decided} skipped=${t.skipped} errors=${t.errors.length}`,tone:t.errors.length?`error`:`success`,duration:4e3})},onError:e=>{Q({message:`Bulk decide failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}),u=(e,t)=>{c.mutate({id:e,status:t})},d=()=>{let e=s.filter(e=>e.status===`pending`&&e.confidence>=.9).map(e=>e.id);if(e.length===0){Q({message:`No pending suggestions ≥ 90% confidence to approve.`,tone:`info`});return}window.confirm(`Approve ${e.length} suggestion(s) at ≥ 90% confidence?`)&&l.mutate({ids:e,status:`approved`})},f=()=>{let e=s.filter(e=>e.status===`pending`).map(e=>e.id);if(e.length===0){Q({message:`Nothing pending in the current filter.`,tone:`info`});return}window.confirm(`Reject ${e.length} suggestion(s) in the current filter? They'll be tombstoned and won't re-propose.`)&&l.mutate({ids:e,status:`rejected`})},p=()=>{n(e=>({...e,linkType:e.linkType===`citation`?`all`:e.linkType})),Q({message:`Citations hidden in the current view (filter only — nothing modified).`,tone:`info`,duration:2e3})};if(a.isLoading)return(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-dim`,children:`Loading suggestions queue…`});if(a.isError)return(0,G.jsxs)(`div`,{className:`p-6 text-sm text-red-400`,children:[`Failed to load suggestions:`,` `,a.error instanceof Error?a.error.message:`unknown error`]});let m=s.filter(e=>e.status===`pending`).length,h=s.filter(e=>e.status===`approved`).length,g=s.filter(e=>e.status===`rejected`).length;return(0,G.jsxs)(`div`,{className:`flex flex-col h-full bg-bg text-fg`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-3 px-6 py-4 border-b border-line bg-bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,G.jsx)(`h1`,{className:`text-base font-semibold`,children:`📋 Suggestions Queue`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-dim`,children:[s.length,` visible · pending=`,m,t.status!==`pending`&&(0,G.jsxs)(G.Fragment,{children:[` `,`· approved=`,h,` · rejected=`,g]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:d,disabled:l.isPending,className:`text-xs px-3 py-1 rounded border border-green-500/40 text-green-300 hover:bg-green-500/10 disabled:opacity-50`,title:`Approve every pending row at ≥ 90% confidence in the current filter`,children:`✓ Approve ≥ 90%`}),(0,G.jsx)(`button`,{type:`button`,onClick:f,disabled:l.isPending,className:`text-xs px-3 py-1 rounded border border-red-500/40 text-red-300 hover:bg-red-500/10 disabled:opacity-50`,title:`Reject every pending row in the current filter (tombstones them)`,children:`✗ Reject visible`}),(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs px-3 py-1 rounded border border-line text-fg-dim hover:text-fg`,title:`Hide citations from the current filter (defer review; nothing is written)`,children:`⤳ Skip citations`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`status:`}),(0,G.jsxs)(`select`,{value:t.status,onChange:e=>n(t=>({...t,status:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`pending`,children:`pending`}),(0,G.jsx)(`option`,{value:`approved`,children:`approved`}),(0,G.jsx)(`option`,{value:`rejected`,children:`rejected`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`type:`}),(0,G.jsxs)(`select`,{value:t.linkType,onChange:e=>n(t=>({...t,linkType:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),Eb.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`inferred by:`}),(0,G.jsxs)(`select`,{value:t.inferredBy,onChange:e=>n(t=>({...t,inferredBy:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),Db.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`min conf:`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:t.minConfidence,onChange:e=>n(t=>({...t,minConfidence:Number(e.target.value)})),className:`w-32`}),(0,G.jsxs)(`span`,{className:`w-10 tabular-nums text-fg-dim`,children:[Math.round(t.minConfidence*100),`%`]})]}),(t.status!==`pending`||t.linkType!==`all`||t.inferredBy!==`all`||t.minConfidence>0)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(Ob),className:`ml-auto text-fg-dim hover:text-accent underline`,children:`reset`})]})]}),(0,G.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:s.length===0?(0,G.jsxs)(`div`,{className:`p-6 text-sm text-fg-dim`,children:[`No suggestions match the current filter.`,o.length>0&&t.minConfidence>0&&(0,G.jsxs)(G.Fragment,{children:[` `,`(`,o.length,` hidden by min-confidence ≥`,` `,Math.round(t.minConfidence*100),`%)`]})]}):(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`sticky top-0 bg-bg-elevated z-10`,children:(0,G.jsxs)(`tr`,{className:`text-fg-dim border-b border-line`,children:[(0,G.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Source`}),(0,G.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Target`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Type`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Conf`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`By`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Evidence`}),(0,G.jsx)(`th`,{className:`text-right px-4 py-2 font-medium`,children:`Decide`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>(0,G.jsx)(Pb,{row:e,expanded:r===e.id,onToggle:()=>i(t=>t===e.id?null:e.id),onDecide:u,pending:c.isPending&&c.variables?.id===e.id},e.id))})]})})]})}function Pb({row:e,expanded:t,onToggle:n,onDecide:r,pending:i}){let a=jb(e.link_type),o=e.status!==`pending`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`tr`,{className:`border-b border-line/60 hover:bg-bg-elevated/40`,children:[(0,G.jsxs)(`td`,{className:`px-4 py-2 align-top max-w-[260px]`,children:[(0,G.jsx)(`div`,{className:`truncate`,title:e.source_title??e.source_session_id,children:e.source_title??Mb(e.source_session_id)}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] tabular-nums`,children:[Mb(e.source_session_id),e.source_project&&(0,G.jsxs)(`span`,{className:`ml-1 text-fg-dim`,children:[`· `,e.source_project]})]})]}),(0,G.jsxs)(`td`,{className:`px-4 py-2 align-top max-w-[260px]`,children:[(0,G.jsx)(`div`,{className:`truncate`,title:e.target_title??e.target_session_id,children:e.target_title??Mb(e.target_session_id)}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] tabular-nums`,children:[Mb(e.target_session_id),e.target_project&&(0,G.jsxs)(`span`,{className:`ml-1 text-fg-dim`,children:[`· `,e.target_project]})]})]}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top`,children:(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] ${a.className}`,children:a.label})}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top text-right tabular-nums ${Ab(e.confidence)}`,children:kb(e.confidence)}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top text-fg-dim`,children:e.inferred_by}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top`,children:(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-dim hover:text-fg underline decoration-dotted`,children:t?`hide`:`show`})}),(0,G.jsx)(`td`,{className:`px-4 py-2 align-top text-right`,children:o?(0,G.jsxs)(`span`,{className:e.status===`approved`?`text-green-400 text-[10px]`:`text-red-400 text-[10px]`,children:[e.status,e.decided_at&&(0,G.jsx)(`span`,{className:`text-fg-muted ml-1`,children:new Date(e.decided_at).toLocaleDateString()})]}):(0,G.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.id,`approved`),disabled:i,className:`px-2 py-0.5 rounded border border-green-500/40 text-green-300 hover:bg-green-500/10 disabled:opacity-50`,children:`✓`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.id,`rejected`),disabled:i,className:`px-2 py-0.5 rounded border border-red-500/40 text-red-300 hover:bg-red-500/10 disabled:opacity-50`,children:`✗`})]})})]}),t&&(0,G.jsx)(`tr`,{className:`bg-bg-elevated/40`,children:(0,G.jsx)(`td`,{colSpan:7,className:`px-6 py-3`,children:(0,G.jsx)(`pre`,{className:`text-[11px] leading-relaxed text-fg-dim overflow-x-auto whitespace-pre-wrap break-words`,children:JSON.stringify(e.evidence,null,2)})})})]})}var Fb=null,Ib=new Set;function Lb(e){Fb=e;for(let e of Ib)e(Fb)}function Rb(){return Fb}var zb=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,note:`fastest, cheapest. Default.`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,note:`higher quality extraction, ~3x cost.`}];function Bb({initialProject:e,availableProjects:t,onClose:n}){let r=K(),[i,a]=(0,W.useState)(`configure`),[o,s]=(0,W.useState)(e),[c,l]=(0,W.useState)(zb[0].value),[u,d]=(0,W.useState)(50),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(null),S=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=Rb();if(!e||e.kind!==`extract`)return;let t=e.jobId,n=!1;return(async()=>{try{let e=await Z.extractOutputsJobSnapshot(t);if(n)return;e.status===`running`?(y(t),x(e),a(`running`)):Lb(null)}catch{Lb(null)}})(),()=>{n=!0}},[]);let C=q({queryKey:[`launcher-budget`],queryFn:()=>Z.launcherBudget(),refetchInterval:i===`running`?5e3:!1});(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`launching`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]),(0,W.useEffect)(()=>{if(!v)return;let e=new EventSource(mt(`/api/extract-outputs/jobs/${encodeURIComponent(v)}/stream`));return S.current=e,e.addEventListener(`progress`,e=>{try{x(JSON.parse(e.data))}catch{}}),e.addEventListener(`done`,t=>{try{let e=JSON.parse(t.data);x(e),a(e.status===`failed`?`failed`:(e.status,`done`)),e.status===`failed`&&_(e.error)}catch{a(`done`)}e.close(),Lb(null),r.invalidateQueries({queryKey:[`bug-patterns`]}),r.invalidateQueries({queryKey:[`launcher-budget`]})}),e.addEventListener(`error`,()=>{_(`Stream disconnected`),a(`failed`),e.close()}),()=>{e.close(),S.current=null}},[v,r]);async function w(){_(null),h(null),a(`previewing`);try{h(await Z.extractOutputsPreflight({project:o,model:c,limit:u,force:f})),a(`previewed`)}catch(e){_(e instanceof Error?e.message:String(e)),a(`configure`)}}async function T(){if(m?.preflight_token){a(`launching`),_(null);try{let{jobId:e,reused:t}=await Z.extractOutputsRun(m.preflight_token);y(e),Lb({jobId:e,kind:`extract`}),a(`running`),t&&Q({message:`A job for ${o} was already running. Attached to it.`,tone:`info`})}catch(e){_(e instanceof Error?e.message:String(e)),a(`previewed`)}}}async function E(){if(v)try{await Z.extractOutputsCancel(v),Q({message:`Cancellation requested`,tone:`info`})}catch(e){Q({message:`Cancel failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}let D=(0,W.useMemo)(()=>t.filter(e=>e.remaining_sessions>0),[t]),O=i===`configure`||i===`previewed`,k=i===`previewed`&&!!m?.preflight_token;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`launching`&&n()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:`🚀 Run extract-outputs`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i===`launching`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,title:i===`running`?`Close this dialog. Job continues running; track progress via the badge in the top bar.`:`Close`,children:i===`running`?`run in background ↗`:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(i===`configure`||i===`previewing`||i===`previewed`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vb,{value:o,options:D,onChange:e=>{s(e),h(null),a(`configure`)}}),(0,G.jsx)(Hb,{value:c,onChange:e=>{l(e),h(null),a(`configure`)}}),(0,G.jsx)(Ub,{value:u,ceiling:C.data?.session_ceiling??500,onChange:e=>{d(e),h(null),a(`configure`)}}),(0,G.jsx)(Wb,{value:f,onChange:e=>{p(e),h(null),a(`configure`)}}),C.data&&(0,G.jsx)(Gb,{budget:C.data}),i===`previewing`&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Computing preview…`}),m&&(0,G.jsx)(Kb,{preflight:m,project:o}),g&&(0,G.jsx)(`div`,{className:`text-error text-xs whitespace-pre-wrap break-words`,children:g})]}),(i===`launching`||i===`running`||i===`done`||i===`failed`)&&b&&(0,G.jsx)(Jb,{snapshot:b,phase:i}),i===`launching`&&!b&&(0,G.jsx)(Yb,{title:`Starting job…`,subtitle:`Securing preflight token and initializing the sub-agent runner.`}),i===`running`&&!b&&(0,G.jsx)(Yb,{title:`Warming up the first sub-agent…`,subtitle:`Each session spawns a Claude sub-agent. The first one usually takes 15–25 seconds before progress events start streaming. Sit tight — once stats appear, they update live.`}),g&&i===`failed`&&(0,G.jsx)(`div`,{className:`text-error text-xs whitespace-pre-wrap break-words`,children:g})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[(i===`configure`||i===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 text-fg-muted hover:text-fg`,children:`Cancel`}),(i===`configure`||i===`previewing`||i===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:!O||i===`previewing`,className:`text-xs px-3 py-1.5 border border-line rounded-md hover:border-accent disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`previewing`?`Computing…`:`Preview cost`}),i===`previewed`&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:!k,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:m?.eligible_session_count===0?`Nothing to run`:`I understand, run (${m?.eligible_session_count??0} sessions)`}),i===`running`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 text-fg-muted hover:text-fg`,title:`Close this dialog. The job continues running in the background; track progress via the badge in the top bar.`,children:`Run in background ↗`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void E(),className:`text-xs px-3 py-1.5 border border-error/60 text-error rounded-md hover:bg-error/10`,children:`Cancel job`})]}),(i===`done`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90`,children:`Close`})]})]})})}function Vb({value:e,options:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Project`}),(0,G.jsxs)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-xs`,children:[t.length===0&&(0,G.jsxs)(`option`,{value:e,children:[e,` (no remaining sessions)`]}),t.map(e=>(0,G.jsxs)(`option`,{value:e.project,children:[e.project,` (`,e.remaining_sessions,` remaining)`]},e.project))]})]})}function Hb({value:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Model`}),(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-xs`,children:zb.map(e=>(0,G.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.note,`)`]},e.value))})]})}function Ub({value:e,ceiling:t,onChange:n}){let r=Math.min(t,500);return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-1 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:`Session limit`}),(0,G.jsx)(`span`,{className:`text-fg tabular-nums`,children:e})]}),(0,G.jsx)(`input`,{type:`range`,min:1,max:r,step:1,value:Math.min(e,r),onChange:e=>n(Number(e.target.value)),className:`w-full`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:[`Server ceiling: `,t,`. Lower this for a smaller, cheaper test run. The actual count extracted will not exceed this.`]})]})}function Wb({value:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Force re-extract`}),` sessions that are already at the current extractor version. Useful if you upgraded the extractor and want fresh signatures. Doubles spend if you run it twice in a row.`]})]})}function Gb({budget:e}){let t=e.spent_total_tokens_24h,n=e.daily_token_budget,r=n===0?0:Math.min(100,Math.round(t/n*100));return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`24h budget`}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[t.toLocaleString(),` / `,n.toLocaleString(),` tokens (`,r,`%)`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden mt-1`,children:(0,G.jsx)(`div`,{className:r>80?`h-full bg-warning`:`h-full bg-accent`,style:{width:`${r}%`}})})]})}function Kb({preflight:e,project:t}){let n=e.estimated_input_tokens_max+e.estimated_output_tokens_max,r=e.budget.remaining_tokens_24h;return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated/40 p-3 space-y-3`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Preview`}),e.eligible_session_count===0?(0,G.jsx)(`div`,{className:`text-fg-muted`,children:e.message??`No eligible sessions in ${t}. Nothing to run.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`About to extract`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:e.eligible_session_count}),` `,`session`,e.eligible_session_count===1?``:`s`,` from`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:t}),`.`]}),e.plan_window_estimate?(0,G.jsx)(qb,{estimate:e.plan_window_estimate}):(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted italic`,children:[`Plan-window impact unavailable. Restart the daemon (`,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`recall stop && recall start`}),`) to pick up the latest server build.`]}),(0,G.jsxs)(`details`,{className:`text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-fg select-none`,children:`Token estimate (for API-key users)`}),(0,G.jsxs)(`div`,{className:`pt-2 space-y-1`,children:[(0,G.jsxs)(`div`,{children:[`Up to`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_input_tokens_max.toLocaleString()}),` `,`input +`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_output_tokens_max.toLocaleString()}),` `,`output tokens. Actual spend depends on session size.`]}),e.would_exceed_budget&&(0,G.jsxs)(`div`,{className:`text-warning`,children:[`⚠ Projected (`,n.toLocaleString(),`) exceeds remaining 24h budget (`,r.toLocaleString(),`). Lower the limit or raise launcher.dailyTokenBudget in ~/.recall/config.json.`]})]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`Token expires in 60 seconds; click Run before then or click Preview again to refresh.`})]})]})}function qb({estimate:e}){let t={pro:`Pro`,"max-5x":`Max 5x`,"max-20x":`Max 20x`};return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:`Claude Code 5-hour window impact`}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(model multiplier: `,e.model_multiplier,`x)`]})]}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.per_plan.map(e=>{let n=e.would_exhaust_window,r=!n&&e.fraction>.5,i=Math.min(100,e.pct);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted w-20 shrink-0`,children:t[e.plan]}),(0,G.jsx)(`div`,{className:`flex-1 h-2 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:n?`h-full bg-warning`:r?`h-full bg-sky-400`:`h-full bg-sky-500/60`,style:{width:`${i}%`}})}),(0,G.jsxs)(`span`,{className:`tabular-nums w-16 text-right text-xs `+(n?`text-warning font-semibold`:`text-fg`),children:[e.pct>=1e3?`>1000`:e.pct.toFixed(1),`%`]})]},e.plan)})}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:[`ⓘ `,e.caveat]})]})}function Jb({snapshot:e,phase:t}){let n=e.total===0?0:Math.round(e.processed/e.total*100);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[t===`running`&&(0,G.jsxs)(`div`,{className:`rounded-md border border-sky-400/40 bg-sky-400/10 px-3 py-2 text-sm text-fg leading-relaxed`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-0.5`,children:`↗ You can close this dialog at any time`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs`,children:[`The job continues running in the background. Track progress on the pulsing pill in the top bar. Use the`,` `,(0,G.jsx)(`strong`,{className:`text-error`,children:`Cancel job`}),` button below to stop early; closing the dialog never cancels.`]})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:e.project}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`· `,e.model]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[e.processed,` / `,e.total,` sessions`]}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden mt-1`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:`${n}%`}})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`ok:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.ok})]}),(0,G.jsxs)(`div`,{children:[`skipped:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.skipped})]}),(0,G.jsxs)(`div`,{children:[`failed:`,` `,(0,G.jsx)(`strong`,{className:e.failed>0?`text-warning tabular-nums`:`text-fg tabular-nums`,children:e.failed})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`input tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.total_input_tokens.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[`output tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.total_output_tokens.toLocaleString()})]})]}),e.current_session_id&&t===`running`&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] font-mono`,children:[`current: `,e.current_session_id]}),t===`done`&&(0,G.jsxs)(`div`,{className:`text-accent`,children:[`✓ Done. Run`,` `,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`recall infer-bug-patterns`}),` in your terminal to cluster the new signatures, or close this modal and they will surface on the next inference run.`]}),t===`failed`&&(0,G.jsxs)(`div`,{className:`text-error`,children:[`✗ Failed. `,e.error??`See the audit log for details.`]})]})}function Yb({title:e,subtitle:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-4`,children:[(0,G.jsx)(Xb,{}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg font-medium`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:t})]})]})}function Xb(){return(0,G.jsx)(`span`,{className:`inline-block w-5 h-5 border-2 border-line border-t-sky-400 rounded-full animate-spin shrink-0`,role:`status`,"aria-label":`loading`})}function Zb({onClose:e}){let t=K(),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),u=q({queryKey:[`macro-repos`],queryFn:()=>Z.listMacroRepos()}),d=u.data?.macro_repos??[],f=u.data?.orphan_projects??[],p=d.find(e=>e.id===n)??null;(0,W.useEffect)(()=>{p?(a(p.name),s(p.description??``)):(a(``),s(``))},[n,p]),(0,W.useEffect)(()=>{function t(t){t.key===`Escape`&&e()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);function m(e){return t=>{Q({message:`${e}: ${t instanceof Error?t.message:String(t)}`,tone:`error`})}}function h(){t.invalidateQueries({queryKey:[`macro-repos`]}),t.invalidateQueries({queryKey:[`bug-patterns`,`setup-status`]})}let g=J({mutationFn:e=>Z.createMacroRepo(e),onSuccess:({macro_repo:e})=>{Q({message:`Created "${e.name}"`,tone:`success`}),r(e.id),h()},onError:m(`Create failed`)}),_=J({mutationFn:e=>Z.patchMacroRepo(e.id,{name:e.name,description:e.description}),onSuccess:()=>{Q({message:`Saved`,tone:`success`}),h()},onError:m(`Save failed`)}),v=J({mutationFn:e=>Z.deleteMacroRepo(e),onSuccess:()=>{Q({message:`Deleted`,tone:`success`}),r(null),h()},onError:m(`Delete failed`)}),y=J({mutationFn:e=>Z.addMacroRepoMember(e.id,e.projectId),onSuccess:()=>{h()},onError:m(`Add member failed`)}),b=J({mutationFn:e=>Z.removeMacroRepoMember(e.id,e.projectId),onSuccess:()=>{h()},onError:m(`Remove member failed`)});function x(){if(!p)return;let e=i.trim();if(!e){Q({message:`Name is required`,tone:`error`});return}e===p.name&&(o||``)===(p.description??``)||_.mutate({id:p.id,name:e,description:o.trim()||null})}function S(){let e=window.prompt(`Name for the new macro repo (e.g. "Mod Office"):`);!e||!e.trim()||g.mutate({name:e.trim()})}let C=c.trim()?f.filter(e=>e.name.toLowerCase().includes(c.trim().toLowerCase())):f;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl w-full max-w-4xl max-h-[88vh] flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:`📁 Macro Repos`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-0.5`,children:`Group cwd-based projects into the logical repos you actually think in. Membership is explicit; no auto-grouping.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs text-fg-muted hover:text-fg`,children:`close`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 grid grid-cols-1 md:grid-cols-[260px_1fr] gap-0 divide-x divide-line overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-2 border-b border-line flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs uppercase tracking-wider text-fg-muted font-medium`,children:[d.length,` repo`,d.length===1?``:`s`]}),(0,G.jsx)(`button`,{type:`button`,onClick:S,className:`text-xs px-2 py-1 bg-accent text-bg rounded font-semibold hover:opacity-90`,children:`+ New`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,children:[d.length===0&&(0,G.jsxs)(`div`,{className:`p-3 text-xs text-fg-muted leading-relaxed`,children:[`No macro repos yet. Click `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ New`}),` to create one, then add member projects on the right.`]}),d.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`w-full text-left px-3 py-2 hover:bg-bg-elevated/40 `+(n===e.id?`bg-bg-elevated/60 border-l-2 border-accent`:``),children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg truncate`,children:e.name}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.member_project_ids.length,` member`,e.member_project_ids.length===1?``:`s`]})]},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[!p&&(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6`,children:(0,G.jsx)(`div`,{className:`text-center text-sm text-fg-muted max-w-sm`,children:d.length===0?`Create your first macro repo to start grouping projects.`:`Pick a macro repo on the left to manage members.`})}),p&&(0,G.jsx)(Qb,{repo:p,draftName:i,draftDescription:o,onDraftNameChange:a,onDraftDescriptionChange:s,onSaveDraft:x,onDelete:()=>{window.confirm(`Delete macro repo "${p.name}"? Member projects will return to orphan status. This does not delete any session data.`)&&v.mutate(p.id)},onRemoveMember:e=>b.mutate({id:p.id,projectId:e}),orphanFilter:c,onOrphanFilterChange:l,visibleOrphans:C,onAddMember:e=>y.mutate({id:p.id,projectId:e}),isSaving:_.isPending||y.isPending||b.isPending},p.id)]})]})]})})}function Qb({repo:e,draftName:t,draftDescription:n,onDraftNameChange:r,onDraftDescriptionChange:i,onSaveDraft:a,onDelete:o,onRemoveMember:s,orphanFilter:c,onOrphanFilterChange:l,visibleOrphans:u,onAddMember:d,isSaving:f}){let p=t.trim()!==e.name||(n.trim()||null)!==(e.description??null);return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-4 border-b border-line space-y-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted mb-1`,children:`Macro repo name`}),(0,G.jsx)(`input`,{type:`text`,value:t,onChange:e=>r(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent`,placeholder:`e.g. Mod Office`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted mb-1`,children:`Description (optional)`}),(0,G.jsx)(`textarea`,{value:n,onChange:e=>i(e.target.value),rows:2,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent resize-y`,placeholder:`What this macro repo represents.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:a,disabled:!p||f,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:`Save changes`}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs px-3 py-1.5 border border-error/60 text-error rounded hover:bg-error/10`,children:`Delete macro repo`})})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-hidden grid grid-cols-1 md:grid-cols-2 divide-x divide-line`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-3 py-2 border-b border-line`,children:(0,G.jsxs)(`div`,{className:`text-xs font-semibold text-fg uppercase tracking-wider`,children:[`Members (`,e.member_project_ids.length,`)`]})}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.member_project_ids.length===0&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`No member projects yet. Add some from the right.`}),e.member_project_ids.map((t,n)=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-sm border-b border-line/50 hover:bg-bg-elevated/40`,children:[(0,G.jsx)(`span`,{className:`text-fg truncate`,children:e.member_project_names[n]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`text-xs text-fg-muted hover:text-error shrink-0 px-1.5`,title:`Remove from macro repo (project becomes orphan again)`,children:`✕`})]},t))]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line space-y-2`,children:[(0,G.jsxs)(`div`,{className:`text-xs font-semibold text-fg uppercase tracking-wider`,children:[`Add member (`,u.length,` available)`]}),(0,G.jsx)(`input`,{type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:`filter orphan projects…`,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-xs focus:outline-none focus:border-accent`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[u.length===0&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:c?`No orphan projects match your filter.`:`No orphan projects. Every project is already in a macro repo.`}),u.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:`w-full flex items-center justify-between px-3 py-1.5 text-sm border-b border-line/50 hover:bg-bg-elevated/40 text-left`,children:[(0,G.jsx)(`span`,{className:`text-fg truncate`,children:e.name}),(0,G.jsx)(`span`,{className:`text-xs text-accent shrink-0 px-1.5`,children:`+ add`})]},e.id))]})]})]})]})}function $b(e){if(!e)return`never`;try{return new Date(e).toISOString().slice(0,10)}catch{return e}}function ex(e,t){return t===0?0:Math.round(e/t*100)}function tx(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(!1),i=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),a=i.data,o=a?.totals,s=a?.projects??[],[c,l]=(0,W.useState)(!1),u=o&&o.total_sessions>0?ex(o.extracted_sessions,o.total_sessions):0;return(0,G.jsxs)(`div`,{className:`border-b border-line shrink-0 max-h-[70vh] flex flex-col`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`w-full text-left px-4 py-3 hover:bg-bg-elevated/40 transition-colors flex items-center gap-3 shrink-0 group`,children:[(0,G.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 rounded text-fg-muted group-hover:text-fg transition-transform `+(c?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`🐛 Bug Patterns Setup`}),o&&(0,G.jsxs)(`span`,{className:`text-sm text-fg-muted tabular-nums shrink-0`,children:[o.extracted_sessions.toLocaleString(),` of`,` `,o.total_sessions.toLocaleString(),` sessions extracted · `,o.cluster_count,` cluster`,o.cluster_count===1?``:`s`]})]}),o&&(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-1.5 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:`${u}%`}})}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums w-10 text-right`,children:[u,`%`]})]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted shrink-0 hidden sm:inline`,children:c?`hide`:`show details`})]}),c&&(0,G.jsx)(`div`,{className:`px-4 pt-2 flex items-center justify-end gap-2 shrink-0`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`text-xs px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Group cwd-based projects into the logical repos you actually think in (manual, no auto-grouping).`,children:`📁 Manage macro repos`})}),c&&(0,G.jsxs)(`div`,{className:`overflow-y-auto px-4 pb-4 space-y-4 text-sm`,children:[(0,G.jsxs)(`details`,{className:`rounded-lg border border-line bg-bg-elevated/30 group`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-fg-muted hover:text-fg flex items-center gap-2 select-none`,children:[(0,G.jsx)(`span`,{className:`text-fg group-open:rotate-90 transition-transform inline-block w-3`,children:`▸`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`What is this and how does it work?`})]}),(0,G.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-3 leading-relaxed border-t border-line`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Bug Patterns groups past Claude Code sessions that hit the same error so a fix from one can be surfaced when the bug recurs. It does `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`not`}),` scan your repo or source code. It reads bug signatures already extracted from your past session JSONLs.`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2`,children:[(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Step 1`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`extract-outputs`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Sub-agent extracts bug signatures.`,` `,(0,G.jsx)(`span`,{className:`text-warning font-medium`,children:`Costs tokens.`})]})]}),(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Step 2`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`infer-bug-patterns`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Local clustering by fingerprint.`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`No cost.`})]})]}),(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Result`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`bug clusters`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Mark "this fix worked" once. Future occurrences surface the linked fix.`})]})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[`Full explanation lives in the Help section under`,` `,(0,G.jsx)(`strong`,{className:`text-fg-dim`,children:`Bug Patterns`}),` and`,` `,(0,G.jsx)(`strong`,{className:`text-fg-dim`,children:`Security & privacy`}),`.`]})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2`,children:[(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-fg`,children:[`Projects (`,s.length,`)`]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Click 🚀 run to extract from the UI, or copy the CLI command`})]}),i.isLoading&&(0,G.jsx)(`div`,{className:`text-fg-muted py-3`,children:`Loading…`}),i.error&&(0,G.jsxs)(`div`,{className:`text-error py-3`,children:[`Failed to load:`,` `,i.error instanceof Error?i.error.message:String(i.error)]}),a&&s.length===0&&(0,G.jsx)(`div`,{className:`text-fg-muted py-3`,children:`No projects indexed yet.`}),a&&s.length>0&&(0,G.jsx)(`div`,{className:`rounded-lg border border-line bg-bg overflow-hidden`,children:(0,G.jsx)(`div`,{className:`max-h-80 overflow-y-auto overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{className:`text-fg-muted bg-bg-elevated sticky top-0 z-10`,children:(0,G.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Project`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Sessions`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-40`,children:`Progress`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Remaining`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium hidden lg:table-cell`,children:`Last run`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Actions`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>{let n=ex(e.extracted_sessions,e.total_sessions),r=e.remaining_sessions===0;return(0,G.jsxs)(`tr`,{className:`border-b border-line/50 last:border-b-0 hover:bg-bg-elevated/30`,children:[(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg font-medium`,children:e.project}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right text-fg-muted tabular-nums`,children:e.total_sessions.toLocaleString()}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-1.5 bg-line rounded-full overflow-hidden min-w-[60px]`,children:(0,G.jsx)(`div`,{className:r?`h-full bg-accent/60`:`h-full bg-accent`,style:{width:`${n}%`}})}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums w-8 text-right`,children:[n,`%`]})]})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:e.remaining_sessions>0?(0,G.jsx)(`span`,{className:`text-warning`,children:e.remaining_sessions.toLocaleString()}):(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`0`})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg-muted hidden lg:table-cell`,children:$b(e.last_extracted_at)}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,children:r?(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,title:`All sessions in this project are already extracted.`,children:`✓ done`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(e.project),className:`text-xs px-2 py-0.5 bg-accent/15 border border-accent/60 text-accent rounded hover:bg-accent/25 font-medium whitespace-nowrap`,title:`Launch extract-outputs for ${e.project} from the UI (with cost preview).`,children:`🚀 run`}),(0,G.jsx)(nx,{command:`recall extract-outputs --project "${e.project}"`})]})})})]},e.project)})})]})})})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`v0.20 Phase H · The 🚀 run button launches from the UI with a cost preview, origin-locked, CSRF-protected, budget-capped. See Help → Security & privacy.`})]}),e&&(0,G.jsx)(Bb,{initialProject:e,availableProjects:s.map(e=>({project:e.project,remaining_sessions:e.remaining_sessions})),onClose:()=>t(null)}),n&&(0,G.jsx)(Zb,{onClose:()=>r(!1)})]})}function nx({command:e}){let[t,n]=(0,W.useState)(!1);async function r(){try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{n(!1)}}return(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-2 py-0.5 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim whitespace-nowrap`,title:`Copy: ${e}`,children:t?`✓ copied`:`copy CLI`})}function rx(e){try{let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return e;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n} min ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toISOString().slice(0,10)}catch{return e}}function ix({initialProject:e=null}){let[,t]=Nn(),[n,r]=(0,W.useState)(e),[i,a]=(0,W.useState)(!1),o=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),s=q({queryKey:[`bug-signatures`,n],queryFn:()=>Z.bugSignatures(n??void 0,200)}),c=s.data,l=c?.sessions??[],u=i?l:l.filter(e=>e.signature_count>0),d=o.data?.projects??[];function f(e){t({session:e,view:null})}return(0,G.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-line shrink-0 flex-wrap`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim`,children:[`project`,(0,G.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value===``?null:e.target.value),className:`bg-bg-elevated border border-line rounded px-2 py-1 text-sm`,children:[(0,G.jsx)(`option`,{value:``,children:`all projects`}),d.filter(e=>e.extracted_sessions>0).map(e=>(0,G.jsx)(`option`,{value:e.project,children:e.project},e.project))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`show sessions with no findings`]}),(0,G.jsx)(`div`,{className:`ml-auto text-sm text-fg-muted tabular-nums`,children:c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:c.totals.total_findings}),` `,`finding`,c.totals.total_findings===1?``:`s`,` across`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:c.totals.sessions_with_findings}),` `,`session`,c.totals.sessions_with_findings===1?``:`s`,` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,c.totals.sessions_empty,` empty)`]})]}):`Loading…`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-6 text-center text-fg-muted text-sm`,children:`Loading…`}),s.error&&(0,G.jsxs)(`div`,{className:`p-6 text-center text-error text-sm`,children:[`Failed to load:`,` `,s.error instanceof Error?s.error.message:String(s.error)]}),c&&u.length===0&&(0,G.jsxs)(`div`,{className:`p-8 text-center text-fg-muted text-sm space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-base text-fg`,children:`No findings to show.`}),c.totals.sessions_total===0?(0,G.jsxs)(`div`,{children:[`No sessions in this project have been extracted yet. Click`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`🚀 run`}),` in Setup & Status to extract bug signatures.`]}):c.totals.sessions_with_findings===0?(0,G.jsxs)(`div`,{children:[c.totals.sessions_total,` session`,c.totals.sessions_total===1?``:`s`,` extracted, but none returned bug-shaped content. Most extractions come back empty unless the session was about debugging or hit errors.`]}):(0,G.jsx)(`div`,{children:`Toggle "show sessions with no findings" to also see empty extractions.`})]}),c&&u.length>0&&(0,G.jsx)(`div`,{className:`px-4 py-3 space-y-3`,children:u.map(e=>(0,G.jsx)(ax,{session:e,onOpenSession:()=>f(e.session_id)},e.session_id))})]})]})}function ax({session:e,onOpenSession:t}){let n=e.signature_count===0;return(0,G.jsxs)(`div`,{className:`rounded-lg border bg-bg-elevated/30 `+(n?`border-line/50 opacity-70`:`border-line hover:border-accent/40`),children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between px-4 py-2.5 border-b border-line/50 gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm font-semibold text-fg hover:text-accent text-left truncate block max-w-full`,title:e.auto_title??e.session_id,children:e.auto_title??e.session_id.slice(0,8)}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-0.5 flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bg rounded border border-line/50 font-medium`,children:e.project}),(0,G.jsx)(`span`,{className:`font-mono`,children:e.session_id.slice(0,8)}),(0,G.jsxs)(`span`,{children:[`extracted `,rx(e.extracted_at)]})]})]}),(0,G.jsx)(`div`,{className:`shrink-0 text-sm`,children:n?(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`no findings`}):(0,G.jsxs)(`span`,{className:`text-accent font-semibold tabular-nums`,children:[e.signature_count,` finding`,e.signature_count===1?``:`s`]})})]}),!n&&(0,G.jsx)(`div`,{className:`divide-y divide-line/50`,children:e.signatures.map((n,r)=>(0,G.jsx)(ox,{index:r,finding:n,sessionId:e.session_id,onOpenSession:t},r))})]})}function ox({index:e,finding:t,sessionId:n,onOpenSession:r}){let[,i]=Nn(),a=K(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=J({mutationFn:e=>Z.resolveBugSignature(e.hash,{resolved_in_session_id:n,fix_summary:e.summary||void 0}),onSuccess:()=>{Q({message:`Marked as fixed`,tone:`success`}),s(!1),l(``),a.invalidateQueries({queryKey:[`bug-signatures`]})},onError:e=>{Q({message:`Failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),d=J({mutationFn:e=>Z.unresolveBugSignature(e),onSuccess:()=>{Q({message:`Re-opened`,tone:`success`}),a.invalidateQueries({queryKey:[`bug-signatures`]})},onError:e=>{Q({message:`Failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}});function f(e,t){navigator.clipboard.writeText(e).then(()=>Q({message:`Copied ${t}`,tone:`success`})).catch(()=>Q({message:`Copy failed`,tone:`error`}))}function p(){let e=[`Bug finding from a past Claude Code session:`];t.error_type&&t.error_type!==`unknown`&&e.push(`Type: ${t.error_type}`),t.snippet&&e.push(`Description: ${t.snippet}`),t.file&&e.push(`File: ${t.file}`),e.push(`Source session: ${n}`),t.message_hash&&e.push(`Finding ID: ${t.message_hash}`),f(e.join(`
|
|
648
|
+
└── bge-base-en-v1.5/`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-3 leading-relaxed`,children:`Tar this directory to back up everything. Untar on a new machine to restore.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 animate-[fadeInUp_0.5s_ease-out_180ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`🛡️`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Never delete user data`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Every rename archives the prior value. Cleared values stay recoverable from history.`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`💾`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Backup in one command`}),(0,G.jsx)(`code`,{className:`block mt-1 text-[11px] font-mono text-fg-muted bg-bg px-2 py-1 rounded border border-line`,children:`tar czf recall.tgz ~/.recall/`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-xs`,children:[(0,G.jsx)(`div`,{className:`text-2xl mb-2`,children:`🔄`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Reset without data loss`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Drop db.sqlite, then recall start and recall index. Aliases and notes survive via mirrors.`})]})]})]})}function Zd(){return(0,G.jsx)(`div`,{className:`mb-10 space-y-6`,children:(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Four ways to get a session out of Recall`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Qd.map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg border ${e.featured?`border-accent/50 bg-accent/5`:`border-line bg-bg`} p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*80}ms`},children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,G.jsx)(`div`,{className:`text-2xl`,children:e.icon}),e.featured&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-2 py-0.5 rounded bg-accent text-bg`,children:`killer feature`})]}),(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1`,children:e.label}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed mb-2`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line w-fit`,children:e.cmd}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mt-3`,children:`Best for`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-dim leading-relaxed`,children:e.bestFor})]},e.label))})]})})}var Qd=[{icon:`📋`,label:`Copy as context`,body:`Condensed markdown to clipboard. Tool-call JSON and thinking blocks stripped, every prompt and response preserved.`,cmd:`recall context <id> | pbcopy`,bestFor:`Pasting into a new Claude Code conversation so it picks up where you left off.`,featured:!0},{icon:`📄`,label:`Copy as full markdown`,body:`Full transcript including tool-call JSON and tool results. Bigger, more faithful, less Claude-friendly.`,cmd:``,bestFor:`Auditing the exact tool sequence the model executed.`},{icon:`🌐`,label:`Export HTML`,body:`Self-contained dark-mode HTML, all styles inlined. Works offline forever.`,cmd:``,bestFor:`Archiving a session, committing to git, emailing it to a colleague.`},{icon:`🖨️`,label:`Print`,body:`Print-friendly layout. Chrome hidden, light background, page breaks between messages.`,cmd:``,bestFor:`PDF export via the print dialog. Sharing with non-tech reviewers.`}];function $d(){return(0,G.jsx)(`div`,{className:`mb-10 space-y-6`,children:(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Tactics from someone using Recall every day`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:ef.map((e,t)=>(0,G.jsx)(`div`,{className:`rounded-lg border border-line bg-bg p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*60}ms`},children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`text-2xl shrink-0`,children:e.icon}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm`,children:e.title}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed mt-1`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block mt-2 text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line max-w-full overflow-x-auto`,children:e.cmd})]})]})},e.title))})]})})}var ef=[{icon:`🔎`,title:`Search first, never scroll`,body:`A typed word beats your scroll wheel against 150,000+ messages. Build the reflex.`},{icon:`✏️`,title:`Alias the day you finish`,body:`A bare UUID is forgettable in a week. Spend 5 seconds naming the session while context is fresh.`},{icon:`⭐`,title:`Pin canonical decisions`,body:`The ★ floats a session to the top of its project. Pin "the auth decisions" so they are always first.`},{icon:`📝`,title:`Notes as executive summary`,body:`3 bullets after the session: what we decided, what code changed, what is unresolved. Re-read in 30 seconds three months later.`},{icon:`⛓️`,title:`Chain context with --prelude`,body:`The prelude tells Claude what to DO with the context, otherwise it summarizes instead of continuing.`,cmd:`recall context abc12345 --prelude "continue the migration" | claude`},{icon:`📦`,title:`Dotfile your ~/.recall`,body:`Commit aliases.json and notes/ to dotfiles. Your session names and personal notes follow you across machines.`},{icon:`🎯`,title:`Search for decisions, not keywords`,body:`You write phrases like "decided", "final answer", "lets go with" when you commit to something. Searching them surfaces decision moments.`,cmd:`recall search "decided"`}];function tf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Stdio MCP server. Same SQLite, no network ports.`}),(0,G.jsx)(af,{})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 animate-[fadeInUp_0.5s_ease-out_240ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`📖`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Read tools`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-1.5 py-0.5 rounded bg-fg-muted/15 text-fg-dim`,children:`always on`})]}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-1.5 m-0 p-0 list-none`,children:nf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`code`,{className:`text-[11px] font-mono text-fg shrink-0`,children:e.name}),(0,G.jsx)(`span`,{children:e.body})]},e.name))})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`✏️`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Write tools`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-semibold px-1.5 py-0.5 rounded bg-accent/20 text-accent font-mono`,children:`--allow-writes`})]}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-1.5 m-0 p-0 list-none`,children:rf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`code`,{className:`text-[11px] font-mono text-fg shrink-0`,children:e.name}),(0,G.jsx)(`span`,{children:e.body})]},e.name))}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-3 leading-relaxed`,children:`All writes rate-limited (default 60/min), zod-validated, audited to ~/.recall/audit/.`})]})]})]})}var nf=[{name:`list_projects`,body:`every project + counts`},{name:`list_sessions`,body:`recent, filterable`},{name:`search`,body:`BM25 + RRF fusion`},{name:`find_similar_sessions`,body:`cosine semantic (Pro)`},{name:`get_session`,body:`full transcript`},{name:`context_for_session`,body:`condensed markdown`},{name:`recall_neighborhood`,body:`parents/children/citations`},{name:`thread_list / thread_get`,body:`thread browsing`},{name:`list_tags`,body:`every tag + counts`},{name:`apply_tags`,body:`merge-mode tagging`}],rf=[{name:`add_tag / remove_tag`,body:`tag management`},{name:`set_alias`,body:`archive prior values`},{name:`append_note`,body:`add markdown to a note`},{name:`create_collection`,body:`plus add/remove session`},{name:`thread_create`,body:`plus link, set-parent, remove`},{name:`thread_rename / archive`,body:`lifecycle`},{name:`thread_merge / split`,body:`restructuring`},{name:`sync_active_sessions`,body:`capture running terminals`}];function af(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 220`,className:`w-full h-auto`,role:`img`,"aria-label":`MCP architecture: Claude Desktop or Code talks via stdio to the local Recall MCP server, which reads from your SQLite database`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`mcp-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsx)(`rect`,{x:`20`,y:`40`,width:`180`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`34`,y:`64`,className:`fill-fg text-[12px] font-semibold`,children:`Claude Desktop`}),(0,G.jsx)(`text`,{x:`34`,y:`84`,className:`fill-fg-muted text-[10px] font-mono`,children:`claude_desktop_config.json`}),(0,G.jsx)(`rect`,{x:`20`,y:`120`,width:`180`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`34`,y:`144`,className:`fill-fg text-[12px] font-semibold`,children:`Claude Code`}),(0,G.jsx)(`text`,{x:`34`,y:`164`,className:`fill-fg-muted text-[10px] font-mono`,children:`~/.claude.json`}),(0,G.jsx)(`line`,{x1:`200`,y1:`70`,x2:`318`,y2:`105`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`line`,{x1:`200`,y1:`150`,x2:`318`,y2:`125`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`text`,{x:`245`,y:`98`,className:`fill-fg-muted text-[10px] font-semibold`,children:`stdio`}),(0,G.jsx)(`rect`,{x:`320`,y:`80`,width:`180`,height:`60`,rx:`10`,className:`fill-accent/15 stroke-accent`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`410`,y:`104`,textAnchor:`middle`,className:`fill-accent text-[12px] font-semibold`,children:`claude-recall-mcp`}),(0,G.jsx)(`text`,{x:`410`,y:`124`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`no ports · no outbound`}),(0,G.jsx)(`line`,{x1:`500`,y1:`110`,x2:`578`,y2:`110`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#mcp-arrow)`}),(0,G.jsx)(`rect`,{x:`580`,y:`80`,width:`120`,height:`60`,rx:`10`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`640`,y:`104`,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`db.sqlite`}),(0,G.jsx)(`text`,{x:`640`,y:`122`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`~/.recall/`}),(0,G.jsx)(`text`,{x:`360`,y:`200`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`Whatever the web UI shows, the MCP client sees the same.`})]})}function of(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Auto-name Claude Code sessions with the terminal tab name you started them in`}),(0,G.jsx)(cf,{})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 animate-[fadeInUp_0.5s_ease-out_220ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`What it watches`}),(0,G.jsxs)(`ul`,{className:`text-xs text-fg-muted space-y-2 m-0 p-0 list-none`,children:[(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`onDidOpenTerminal, rename, close events`})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`POSTs shell_pid, tab_name, cwd to 127.0.0.1`})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:`Daemon correlates via lsof when JSONL appears`})]})]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`What it never does`}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-2 m-0 p-0 list-none`,children:sf.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0 mt-0.5`,children:`×`}),(0,G.jsx)(`span`,{className:`line-through decoration-fg-muted/60`,children:e})]},e))})]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 animate-[fadeInUp_0.5s_ease-out_360ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:`Status bar (VS Code, Cursor, Windsurf)`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-1 rounded bg-bg border border-line text-xs font-mono text-fg flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-accent`,children:`⟳`}),(0,G.jsx)(`span`,{children:`Recall`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`3`})]}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`number of registered terminals`})]})]})]})}var sf=[`Read terminal buffer or output`,`Touch the clipboard`,`Read editor buffers or files`,`Make any outbound network call (loopback only)`];function cf(){let e=[{x:10,line1:`Terminal`,line2:`opens`,sub:`in VS Code`},{x:155,line1:`Tab name`,line2:`registered`,sub:`POST 127.0.0.1`},{x:300,line1:`Claude writes`,line2:`JSONL`,sub:`~/.claude/projects/`},{x:445,line1:`Daemon`,line2:`correlates`,sub:`lsof + shell PID`},{x:590,line1:`Auto-alias`,line2:`applied`,sub:`session named`,accent:!0}];return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 200`,className:`w-full h-auto`,role:`img`,"aria-label":`Lifecycle: terminal opens, tab name registered, JSONL appears, daemon correlates by lsof, alias applied`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`vscode-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),e.map((t,n)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:t.x,y:`60`,width:`120`,height:`80`,rx:`10`,className:t.accent?`fill-accent/15 stroke-accent`:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:t.x+60,y:`86`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:t.line1}),(0,G.jsx)(`text`,{x:t.x+60,y:`102`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:t.line2}),(0,G.jsx)(`text`,{x:t.x+60,y:`124`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:t.sub}),n<e.length-1&&(0,G.jsx)(`line`,{x1:t.x+122,y1:`100`,x2:e[n+1].x-2,y2:`100`,className:`stroke-accent/50`,strokeWidth:`1.8`,markerEnd:`url(#vscode-arrow)`})]},t.line1))]})}function lf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-3 flex items-center gap-3 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`span`,{className:`text-2xl shrink-0`,children:`💎`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-fg-muted font-bold`,children:`Pricing`}),(0,G.jsx)(`div`,{className:`text-xs text-fg`,children:`$49.69 one-time, lifetime. Lifetime updates included.`})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4 animate-[fadeInUp_0.5s_ease-out_120ms_both]`,children:uf.map(e=>(0,G.jsxs)(`div`,{className:`rounded-xl border p-6 flex flex-col relative ${e.featured?`border-accent bg-accent/5`:`border-line bg-bg-elevated`}`,children:[e.featured&&(0,G.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-1 rounded-full bg-accent text-bg text-[10px] uppercase tracking-widest font-bold whitespace-nowrap`,children:`Most popular`}),(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:e.name}),(0,G.jsx)(`div`,{className:`flex items-baseline gap-1 mb-1`,children:(0,G.jsx)(`span`,{className:`text-3xl font-bold text-fg`,children:e.price})}),e.period&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mb-2`,children:e.period}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mb-4`,children:e.tagline}),(0,G.jsx)(`ul`,{className:`text-xs text-fg-muted space-y-2 mb-6 m-0 p-0 list-none flex-1`,children:e.features.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`text-accent shrink-0 mt-0.5`,children:`✓`}),(0,G.jsx)(`span`,{children:e})]},e))}),e.href?(0,G.jsx)(`a`,{href:e.href,target:e.href.startsWith(`mailto:`)?void 0:`_blank`,rel:e.href.startsWith(`mailto:`)?void 0:`noopener noreferrer`,className:`text-center px-4 py-2 rounded text-xs font-semibold font-mono transition-colors ${e.featured?`bg-accent text-bg hover:bg-accent/90`:`border border-line text-fg-dim hover:border-accent hover:text-accent`}`,children:e.cta}):(0,G.jsx)(`div`,{className:`text-center px-4 py-2 rounded text-xs font-semibold font-mono ${e.featured?`bg-accent text-bg`:`border border-line text-fg-dim`}`,children:e.cta})]},e.name))}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_280ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-3`,children:`Dead-man clause`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,G.jsx)(`span`,{className:`text-3xl shrink-0`,children:`🛡️`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1`,children:`If clauderecall.com ever disappears, every existing license stays valid.`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`Your license validates against our server exactly once at activation. After that Recall works offline forever. We will publish the validation secret if we ever shut down so you are never stranded.`})]})]})]})]})}var uf=[{name:`Free`,price:`$0`,period:``,tagline:`Keep every session you have ever run, browsable forever.`,features:[`Full indexing of every Claude Code session`,`CLI list, show, projects, status`,`Web UI: browse projects, read transcripts`,`Three-layer durability (SQLite + mirrors + source untouched)`,`No time limits, no feature expiry`],cta:`already installed`},{name:`Pro`,price:`$49.69`,period:`one-time, lifetime`,tagline:`Everything in Free, plus the features that make this a daily driver.`,features:[`Full-text BM25 search across every message`,`recall context re-injection (the moat)`,`MCP server for Claude Desktop and Code`,`VS Code, Cursor, Windsurf extension`,`Aliases, tags, notes, pins, cross-session diff`,`Semantic vector search (3-lane RRF fusion)`,`Lifetime updates · Dead-man clause`],cta:`→ get a key · $49.69`,href:`https://clauderecall.com/pricing`,featured:!0},{name:`Enterprise`,price:`custom`,period:`50+ seats`,tagline:`Everything in Pro for every seat, plus the wrapper.`,features:[`Centralized license management`,`SSO / SAML`,`NET 30 invoicing`,`Audit log export`,`Security review docs (SOC 2 readiness)`,`MSA / DPA / NDA support`,`Priority support with SLA`],cta:`hello@clauderecall.com`,href:`mailto:hello@clauderecall.com`}];function df(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`The three questions everyone asks first`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:ff.map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4 animate-[fadeInUp_0.5s_ease-out_both]`,style:{animationDelay:`${100+t*80}ms`},children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-accent font-semibold mb-2`,children:e.tag}),(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-2`,children:e.q}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:e.a})]},e.q))})]}),(0,G.jsx)(mf,{})]})}var ff=[{tag:`Privacy`,q:`Does any of my data leave my machine?`,a:`No. The daemon listens on 127.0.0.1 only. The single outbound call ever made is the one-time license-validation call when you activate Pro.`},{tag:`Pricing`,q:`Is Pro a subscription?`,a:`No. One-time, $49.69. Pay once, own it for life.`},{tag:`Future-proofing`,q:`Will Anthropic just ship this natively?`,a:`Maybe. The moat is recall context, threads, MCP, redaction, cross-AI support, and the dead-man clause. Anthropic is a cloud company — they cannot ship "even if we disappear".`}],pf=[{label:`Privacy & data`,icon:`🔒`,items:[{q:`Can I use this if I am offline?`,a:`Yes. Works on a plane, behind firewalls, on air-gapped machines. The browser talks to http://127.0.0.1, your own laptop.`},{q:`What happens if I delete a JSONL from ~/.claude/projects/?`,a:`The SQLite copy persists. We only add and update — we never delete session rows because the source file disappeared. Your indexed memory outlives the source files.`},{q:`How big does the database get?`,a:`~800 MB for 1,100+ sessions and 150,000 messages in our reference environment. Storage is cheap; this is rarely a problem. Compression is on the roadmap if it ever becomes one.`}]},{label:`Compatibility`,icon:`🧩`,items:[{q:`Cursor / Cline / Windsurf?`,a:`Today: no, because those tools do not write to ~/.claude/projects/. Future: adapters for each (v0.8+).`},{q:`Multiple machines on one index?`,a:`Not yet. Each machine has its own ~/.recall/db.sqlite. Team sync is on the roadmap — opt-in, end-to-end encrypted, still local-first.`}]},{label:`Licensing`,icon:`💎`,items:[{q:`What is the license model?`,a:`Free tier: index, list, show, search, basic browsing. Pro tier (one-time, $49.69): full web UI, context re-injection, MCP, advanced search. License validates once, then offline forever. Dead-man clause: if our servers disappear, existing keys stay valid.`},{q:`Refunds?`,a:`30-day satisfaction guarantee from license activation. Email and we refund. The clock starts when you run recall activate, not when you click Buy.`}]}];function mf(){let[e,t]=(0,W.useState)(null);return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_280ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Everything else, grouped by topic`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:pf.map(n=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:n.icon}),(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-widest text-fg font-semibold`,children:n.label})]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:n.items.map(r=>{let i=`${n.label}-${r.q}`,a=e===i;return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(a?null:i),className:`w-full text-left px-3 py-2 flex items-start gap-2 hover:bg-bg-hover transition-colors`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 mt-1 inline-block w-2 h-2 border-r border-b border-fg-muted transition-transform`,style:{transform:`rotate(${a?`225deg`:`-45deg`})`}}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-fg leading-snug flex-1`,children:r.q})]}),a&&(0,G.jsx)(`div`,{className:`px-3 pb-3 text-[11px] text-fg-muted leading-relaxed`,children:r.a})]},i)})})]},n.label))})]})}function hf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Three search lanes fused with Reciprocal Rank Fusion (k = 60)`}),(0,G.jsx)(gf,{})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_220ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Same query, different lanes`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-1`,children:`Query`}),(0,G.jsx)(`div`,{className:`text-sm font-mono text-fg`,children:`"how do I expire user logins"`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-muted font-semibold mb-2`,children:`Keyword only (Free)`}),(0,G.jsx)(`div`,{className:`text-2xl font-bold text-fg-dim mb-1`,children:`0 hits`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`No session contains the literal phrase "expire user logins".`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent/5 p-4`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-accent font-semibold mb-2`,children:`+ Semantic (Pro)`}),(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent mb-1`,children:`7 hits`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:`Top result: a session about JWT refresh rotation. Zero keyword overlap, semantic match.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-xs animate-[fadeInUp_0.5s_ease-out_360ms_both]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`768`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`vector dimensions`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`~110MB`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`model footprint`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`CPU`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`no GPU required`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-bold text-accent`,children:`$0`}),(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-fg-muted mt-1`,children:`no API fees, ever`})]})]})]})}function gf(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 240`,className:`w-full h-auto`,role:`img`,"aria-label":`Three search lanes fused into ranked results: BM25 over messages, BM25 over summaries, kNN over vector chunks`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`sem-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsx)(`rect`,{x:`10`,y:`100`,width:`100`,height:`40`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`60`,y:`124`,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`query`}),(0,G.jsx)(`rect`,{x:`180`,y:`20`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`42`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`BM25 messages`}),(0,G.jsx)(`text`,{x:`260`,y:`58`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`FTS5`}),(0,G.jsx)(`rect`,{x:`180`,y:`95`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`117`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`BM25 summaries`}),(0,G.jsx)(`text`,{x:`260`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`sessions_fts`}),(0,G.jsx)(`rect`,{x:`180`,y:`170`,width:`160`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`260`,y:`192`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`cosine kNN`}),(0,G.jsx)(`text`,{x:`260`,y:`208`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`sqlite-vec · bge-768`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`45`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`120`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`112`,y1:`120`,x2:`178`,y2:`195`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`45`,x2:`408`,y2:`105`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`120`,x2:`408`,y2:`120`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`line`,{x1:`342`,y1:`195`,x2:`408`,y2:`135`,className:`stroke-accent/40`,strokeWidth:`1.5`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`rect`,{x:`410`,y:`95`,width:`120`,height:`50`,rx:`8`,className:`fill-accent/15 stroke-accent`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`470`,y:`117`,textAnchor:`middle`,className:`fill-accent text-[11px] font-semibold`,children:`RRF fuser`}),(0,G.jsx)(`text`,{x:`470`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-mono`,children:`k = 60`}),(0,G.jsx)(`line`,{x1:`532`,y1:`120`,x2:`598`,y2:`120`,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#sem-arrow)`}),(0,G.jsx)(`rect`,{x:`600`,y:`95`,width:`110`,height:`50`,rx:`8`,className:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:`655`,y:`117`,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:`ranked results`}),(0,G.jsx)(`text`,{x:`655`,y:`133`,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`unified, deduped`})]})}function _f(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Two-step pipeline. Reads past sessions, never your repo.`}),(0,G.jsx)(`div`,{className:`hidden md:block`,children:(0,G.jsx)(vf,{})}),(0,G.jsxs)(`div`,{className:`md:hidden flex items-center justify-between text-[11px] font-semibold text-fg gap-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`📁`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Past sessions`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-muted mt-1`,children:`read-only`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`🤖`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Extract`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-warning mt-1`,children:`tokens`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`⚙`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Cluster`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-fg-muted mt-1`,children:`free`})]}),(0,G.jsx)(`span`,{className:`text-accent text-base shrink-0`,children:`→`}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center flex-1 px-1`,children:[(0,G.jsx)(`span`,{className:`text-xl`,children:`🐛`}),(0,G.jsx)(`span`,{className:`mt-1 text-center`,children:`Patterns`}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider text-accent mt-1`,children:`output`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Step 1: Extract`}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed`,children:[`Per-session Claude sub-agent pulls bug snippets from session JSONLs. `,(0,G.jsx)(`strong`,{className:`text-warning`,children:`Costs tokens.`}),` `,`Idempotent. Default cap 200/run.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Step 2: Infer`}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed`,children:[`Local fingerprinting groups sessions by error shape. `,(0,G.jsx)(`strong`,{children:`No LLM cost.`}),` Add `,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`--semantic`}),` `,`for fuzzy merging via local embeddings.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated p-4`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1`,children:`Output`}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:`Clusters of recurring bugs. Mark "this fix worked" once; future occurrences surface the linked resolution.`})]})]})]})}function vf(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 720 200`,className:`w-full h-auto`,role:`img`,"aria-label":`Pipeline: past sessions, extract (LLM, costs tokens), cluster (local, free), bug-pattern output`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`bug-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent/60`})})}),(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`text`,{x:190,y:42,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-semibold uppercase tracking-wider`,children:`read-only`}),(0,G.jsx)(`text`,{x:370,y:42,textAnchor:`middle`,className:`fill-warning text-[10px] font-semibold uppercase tracking-wider`,children:`costs tokens`}),(0,G.jsx)(`text`,{x:550,y:42,textAnchor:`middle`,className:`fill-fg-muted text-[10px] font-semibold uppercase tracking-wider`,children:`local · free`})]}),[190,370,550].map(e=>(0,G.jsx)(`line`,{x1:e,y1:50,x2:e,y2:102,className:`stroke-line/60`,strokeWidth:`1`,strokeDasharray:`2 3`},`drop-${e}`)),[{x1:158,x2:222},{x1:338,x2:402},{x1:518,x2:582}].map(e=>(0,G.jsx)(`line`,{x1:e.x1,y1:110,x2:e.x2,y2:110,className:`stroke-accent/50`,strokeWidth:`2`,markerEnd:`url(#bug-arrow)`},`arrow-${e.x1}`)),(0,G.jsx)(yf,{x:20,y:75,w:140,h:70,emoji:`📁`,title:`Past sessions`,sub:`~/.claude/projects`}),(0,G.jsx)(yf,{x:222,y:75,w:120,h:70,emoji:`🤖`,title:`Extract`,sub:`LLM sub-agent`}),(0,G.jsx)(yf,{x:400,y:75,w:120,h:70,emoji:`⚙`,title:`Cluster`,sub:`by fingerprint`}),(0,G.jsx)(yf,{x:580,y:75,w:120,h:70,emoji:`🐛`,title:`Patterns`,sub:`fix linked`,accent:!0}),(0,G.jsxs)(`text`,{x:360,y:185,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:[`stored locally in`,` `,(0,G.jsx)(`tspan`,{className:`fill-fg-dim font-mono`,children:`~/.recall/db.sqlite`})]})]})}function yf({x:e,y:t,w:n,h:r,emoji:i,title:a,sub:o,accent:s}){return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:e,y:t,width:n,height:r,rx:10,ry:10,className:s?`fill-accent/15 stroke-accent`:`fill-bg stroke-line`,strokeWidth:`1.5`}),(0,G.jsx)(`text`,{x:e+14,y:t+28,style:{fontSize:18},children:i}),(0,G.jsx)(`text`,{x:e+38,y:t+28,className:`fill-fg text-[12px] font-semibold`,children:a}),(0,G.jsx)(`text`,{x:e+14,y:t+52,className:`fill-fg-muted text-[10px] font-mono`,children:o})]})}function bf(){return(0,G.jsxs)(`div`,{className:`mb-10 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Run the doctor first. Most issues surface as a concrete suggestion.`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4 font-mono text-[11px] leading-relaxed`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-2`,children:[`$ `,(0,G.jsx)(`span`,{className:`text-fg`,children:`recall doctor`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ DB size: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`912 MB`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ WAL size: `,(0,G.jsx)(`span`,{className:`text-warning`,children:`167 MB (large)`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ FTS5 fragmentation: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`low`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ Free disk: `,(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`42 GB`})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[`▸ Integrity check: `,(0,G.jsx)(`span`,{className:`text-accent`,children:`ok`})]}),(0,G.jsxs)(`div`,{className:`text-warning mt-2`,children:[`⚠ WAL is 167 MB. Run `,(0,G.jsx)(`span`,{className:`font-semibold`,children:`recall optimize`}),` to truncate it.`]})]})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated p-6 animate-[fadeInUp_0.5s_ease-out_180ms_both]`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-4`,children:`Common scenarios`}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-xs`,children:xf.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,G.jsx)(`span`,{className:`text-base shrink-0`,children:e.icon}),(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.symptom})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed mb-2`,children:e.body}),e.cmd&&(0,G.jsx)(`code`,{className:`block text-[11px] font-mono text-fg-muted bg-bg-elevated px-2 py-1 rounded border border-line w-fit max-w-full overflow-x-auto`,children:e.cmd})]},e.symptom))})]})]})}var xf=[{icon:`🐢`,symptom:`Feels slow`,body:`Run the doctor for concrete suggestions, then optimize if WAL or FTS5 is fragmented.`,cmd:`recall doctor`},{icon:`⚡`,symptom:`Daemon will not start`,body:`Tail the log. Common cause: leftover sqlite-wal/shm. Safe to delete when stopped.`,cmd:`tail -50 ~/.recall/daemon.log`},{icon:`⬜`,symptom:`Page is blank`,body:`Devtools console first. Then bounce the daemon, then hard-refresh.`,cmd:`recall stop && recall start`},{icon:`🔍`,symptom:`Search misses a known term`,body:`Terms shorter than 2 chars are dropped. FTS5 stems with porter; quoted phrases are exact. Try a forced reindex.`,cmd:`recall index --force`},{icon:`🪶`,symptom:`Empty assistant messages`,body:`Pre-v0.4.0 indexer dropped tool-call markdown. Reindex once.`,cmd:`recall index --force`},{icon:`🧹`,symptom:`Want a fully clean slate`,body:`Wipes aliases, notes, pins, the database. Only when you are sure.`,cmd:`recall stop && rm -rf ~/.recall && recall start`}];function Sf({initialSectionId:e,onClose:t,onSectionChange:n,onReplayOnboarding:r,onReplayThreadsIntro:i}){let a=rd[0].id,[o,s]=(0,W.useState)(()=>e&&rd.some(t=>t.id===e)?e:a),[c,l]=(0,W.useState)(!1),u=(0,W.useRef)(null),d=(0,W.useRef)(n);(0,W.useEffect)(()=>{d.current=n}),(0,W.useEffect)(()=>{e&&rd.some(t=>t.id===e)&&s(e)},[e]),(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){let n=e.target;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;if(c){l(!1);return}t()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,c]),(0,W.useEffect)(()=>{u.current&&(u.current.scrollTop=0),d.current?.(o),l(!1)},[o]);let f=(0,W.useMemo)(()=>{let e={};for(let t of rd)e[t.id]=sd(t.md);return e},[]),p=rd.find(e=>e.id===o);return(0,G.jsxs)(`div`,{className:`absolute inset-0 bg-bg flex flex-col z-20`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 sm:px-5 py-3 border-b border-line bg-bg shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"aria-label":c?`close section nav`:`open section nav`,className:`md:hidden shrink-0 h-9 w-9 rounded-md border border-line bg-bg-elevated hover:bg-bg-hover flex items-center justify-center text-fg-dim`,children:(0,G.jsxs)(`span`,{"aria-hidden":`true`,className:`block w-4 space-y-1`,children:[(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`}),(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`}),(0,G.jsx)(`span`,{className:`block h-0.5 bg-current rounded`})]})}),(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-9 w-9 sm:h-10 sm:w-10 rounded-lg shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`leading-none flex items-center gap-2 sm:gap-2.5 flex-wrap`,children:[(0,G.jsx)(`img`,{src:nd,alt:`Claude Recall`,className:`h-7 sm:h-9 w-auto`}),(0,G.jsx)(`span`,{className:`text-xs sm:text-base font-semibold text-fg-dim hidden sm:inline`,children:`· Command Center`})]}),(0,G.jsx)(`div`,{className:`text-[10px] sm:text-xs text-fg-muted mt-1 sm:mt-2 hidden sm:block`,children:`Everything you need to drive the product like a pro.`})]})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:t,className:`text-[11px] sm:text-xs text-fg-dim hover:text-fg border border-line rounded px-2 sm:px-3 py-1.5 whitespace-nowrap shrink-0`,title:`close command center (Esc)`,children:[(0,G.jsx)(`span`,{className:`sm:hidden`,"aria-hidden":`true`,children:`←`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`← back to sessions`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0 relative`,children:[c&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`close nav`,onClick:()=>l(!1),className:`md:hidden fixed inset-0 bg-bg/80 backdrop-blur-sm z-30`}),(0,G.jsxs)(`aside`,{className:$(`shrink-0 border-r border-line bg-bg-elevated flex flex-col transition-transform duration-200`,`md:static md:translate-x-0 md:w-64`,`absolute inset-y-0 left-0 w-72 z-40`,c?`translate-x-0`:`-translate-x-full md:translate-x-0`),children:[(0,G.jsxs)(`div`,{className:`md:hidden flex items-center justify-between px-4 py-3 border-b border-line`,children:[(0,G.jsx)(`span`,{className:`text-[11px] uppercase tracking-widest text-fg-muted font-semibold`,children:`Sections`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`text-fg-dim hover:text-fg text-xs`,"aria-label":`close nav`,children:`✕`})]}),(0,G.jsx)(`nav`,{className:`py-2 md:py-4 flex-1 overflow-y-auto`,children:rd.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:$(`w-full text-left px-5 py-2.5 text-sm flex items-center gap-2.5 transition-colors`,o===e.id?`bg-bg-active text-fg border-l-2 border-l-accent font-medium`:`text-fg-dim hover:bg-bg-hover hover:text-fg border-l-2 border-l-transparent`),children:[(0,G.jsx)(`span`,{className:`w-4 text-center`,children:e.emoji}),(0,G.jsx)(`span`,{children:e.title})]},e.id))}),(r||i)&&(0,G.jsxs)(`div`,{className:`border-t border-line px-5 py-4 space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-widest text-fg-dim`,children:`Replay tours`}),r&&(0,G.jsxs)(`button`,{type:`button`,onClick:r,className:`w-full text-left text-xs text-fg-muted hover:text-fg flex items-center gap-2`,title:`Play the 3-step first-run tour again`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`↺`}),(0,G.jsx)(`span`,{children:`Replay first-run tour`})]}),i&&(0,G.jsxs)(`button`,{type:`button`,onClick:i,className:`w-full text-left text-xs text-fg-muted hover:text-fg flex items-center gap-2`,title:`Play the 3-step Threads explainer again`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`🧵`}),(0,G.jsx)(`span`,{children:`Replay threads tour`})]})]})]}),(0,G.jsxs)(`main`,{ref:u,className:`flex-1 overflow-y-auto min-w-0`,children:[(0,G.jsxs)(`div`,{className:`md:hidden flex items-center gap-2 px-4 py-2 border-b border-line bg-bg-elevated text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Section`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`font-semibold text-fg flex items-center gap-1.5 hover:text-accent transition-colors`,children:[(0,G.jsx)(`span`,{children:p?.emoji}),(0,G.jsx)(`span`,{children:p?.title}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`▾`})]})]}),(0,G.jsxs)(`div`,{className:`max-w-6xl mx-auto px-5 sm:px-8 lg:px-10 py-6 sm:py-10`,children:[o===`taxonomy`&&(0,G.jsx)(cd,{}),o===`threads`&&(0,G.jsx)(Ed,{}),o===`quickstart`&&(0,G.jsx)(Md,{}),o===`web-ui`&&(0,G.jsx)(Fd,{}),o===`cli`&&(0,G.jsx)(zd,{}),o===`shortcuts`&&(0,G.jsx)(Hd,{}),o===`collections`&&(0,G.jsx)(Wd,{}),o===`data`&&(0,G.jsx)(Xd,{}),o===`export`&&(0,G.jsx)(Zd,{}),o===`security`&&(0,G.jsx)(xd,{}),o===`tips`&&(0,G.jsx)($d,{}),o===`mcp`&&(0,G.jsx)(tf,{}),o===`vscode`&&(0,G.jsx)(of,{}),o===`pricing`&&(0,G.jsx)(lf,{}),o===`faq`&&(0,G.jsx)(df,{}),o===`semantic-vectors`&&(0,G.jsx)(hf,{}),o===`bug-patterns`&&(0,G.jsx)(_f,{}),o===`troubleshoot`&&(0,G.jsx)(bf,{}),(0,G.jsx)(`article`,{className:`prose-message prose-help`,dangerouslySetInnerHTML:{__html:f[o]}}),(0,G.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-line flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`Section`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:rd.findIndex(e=>e.id===o)+1}),` `,`of `,rd.length]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Cf,{active:o,direction:-1,onJump:e=>s(e),label:`← prev`}),(0,G.jsx)(Cf,{active:o,direction:1,onJump:e=>s(e),label:`next →`})]})]})]})]})]})]})}function Cf({active:e,direction:t,onJump:n,label:r}){let i=rd[rd.findIndex(t=>t.id===e)+t];return i?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(i.id),className:`text-fg-dim hover:text-fg`,children:[r,` `,i.title]}):(0,G.jsx)(`span`,{className:`text-fg-muted opacity-30`,children:r})}var wf={"cwd-prefix":`Folder path`,"project-id":`Project`,tag:`Tag`,"plan-file":`Plan file`,"git-branch-prefix":`Git branch`},Tf={"cwd-prefix":`Match sessions whose working directory starts with this path.`,"project-id":`Match every session under a specific Claude Code project (by its internal id).`,tag:`Match sessions that carry this tag.`,"plan-file":`Match sessions that reference this plan/doc filename in their transcript.`,"git-branch-prefix":`Match sessions authored on git branches starting with this prefix.`};function Ef(){let e=ir(),t=ar(),n=fr(),r=e.data?.rules??[],i=t.data?.suggestions??[];return(0,G.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6 space-y-8`,children:[(0,G.jsxs)(`header`,{className:`space-y-2`,children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Auto-collections`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Auto-collections group your Claude Code sessions into folders automatically, based on a rule you accept. One click on a suggestion turns into a live folder in the left sidebar that keeps itself populated forever.`}),(0,G.jsxs)(`div`,{className:`rounded border border-line bg-bg-elevated p-3 text-xs text-fg-muted space-y-2`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg text-sm`,children:`Three common rule shapes`}),(0,G.jsxs)(`ul`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Tag`}),` #bugfix →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "bugfix"`}),` that collects every session you tag #bugfix, forever.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Folder path`}),` /Users/you/code/monorepo/packages/web →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "web"`}),` that collects only the monorepo subfolder sessions, separate from the rest of the repo.`]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`Plan file`}),` ROADMAP.md →`,(0,G.jsx)(`span`,{className:`text-fg`,children:` folder named "ROADMAP.md"`}),`that collects every session whose transcript mentions that file. Lets you thread planning across repos.`]})]}),(0,G.jsx)(`div`,{className:`border-t border-line pt-2`,children:`Manually added sessions are never removed. Deleting a rule only removes the rows the rule itself added.`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Pending suggestions`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(),disabled:n.isPending,className:`text-xs text-accent hover:underline disabled:opacity-50`,title:`Re-scan your sessions right now to surface fresh grouping suggestions.`,children:n.isPending?`scanning…`:`scan now`})]}),i.length===0?(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:`No pending suggestions. New clusters will appear after the next scan.`}):(0,G.jsx)(`ul`,{className:`border border-line rounded divide-y divide-line`,children:i.map(e=>(0,G.jsx)(Df,{suggestion:e},e.id))})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Active rules`}),r.length===0?(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:`No active rules yet. Accept a suggestion above or add one below.`}):(0,G.jsx)(`ul`,{className:`border border-line rounded divide-y divide-line`,children:r.map(e=>(0,G.jsx)(kf,{rule:e},e.id))})]}),(0,G.jsx)(Af,{})]})}function Df({suggestion:e}){let t=ur(),n=dr(),[,r]=Nn(),[i,a]=(0,W.useState)(!1),o=pr(e.id,i),s=e.suggested_name||e.pattern,c=e.session_count,l=`${c} ${c===1?`session`:`sessions`}`,u=e=>r({session:e,view:null,col:null,project:null});return(0,G.jsxs)(`li`,{className:`px-3 py-2 text-sm space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-fg-muted w-20 shrink-0`,title:Tf[e.type],children:wf[e.type]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,title:s,children:s}),(0,G.jsx)(`div`,{className:`truncate text-[11px] text-fg-muted font-mono`,title:e.pattern,children:e.pattern})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted shrink-0`,children:l}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.mutate(e.id),disabled:t.isPending,className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Turn this suggestion into an active rule and create the matching sidebar folder.`,children:`Accept`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n.mutate(e.id),disabled:n.isPending,className:`px-2 py-1 rounded border border-line text-xs hover:bg-bg-hover disabled:opacity-50`,title:`Hide this suggestion so the scanner stops proposing it.`,children:`Dismiss`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted pl-[calc(5rem+0.75rem)]`,children:Of(e)}),(0,G.jsxs)(`div`,{className:`pl-[calc(5rem+0.75rem)]`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`text-[11px] text-accent hover:underline`,"aria-expanded":i,title:`Preview a handful of sessions that this rule would pull in before you accept it.`,children:i?`Hide example sessions`:`See ${Math.min(3,c)} example session${c===1?``:`s`} that will join`}),i&&(0,G.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[o.isLoading&&(0,G.jsx)(`li`,{className:`text-fg-muted italic`,children:`Loading…`}),o.data?.sessions.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:`w-full text-left flex items-center gap-2 px-1 py-0.5 rounded hover:bg-accent/10 hover:text-accent`,title:`Open session: ${e.title}`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0`,children:`→`}),(0,G.jsx)(`span`,{className:`truncate flex-1`,children:e.title}),e.started_at&&(0,G.jsx)(`span`,{className:`text-fg-muted shrink-0`,children:new Date(e.started_at).toLocaleDateString()})]})},e.id)),o.data&&o.data.sessions.length===0&&(0,G.jsx)(`li`,{className:`text-fg-muted italic`,children:`No sessions currently match (may have been dismissed).`})]})]})]})}function Of(e){let t=e.suggested_name||e.pattern,n=e.session_count,r=n===1?`session`:`sessions`;switch(e.type){case`cwd-prefix`:return`Creates a folder "${t}" in the sidebar grouping the ${n} ${r} whose working directory is (or is inside) "${e.pattern}". Every future session recorded under that path joins automatically.`;case`project-id`:return`Creates a folder "${t}" grouping every session from the Claude Code project with id ${e.pattern}. Current match: ${n} ${r}.`;case`tag`:return`Creates a folder "${t}" grouping every session tagged #${e.pattern}. Current match: ${n} ${r}. Any future session tagged the same way joins automatically.`;case`plan-file`:return`Creates a folder "${t}" grouping every session whose transcript references "${e.pattern}". Current match: ${n} ${r}.`;case`git-branch-prefix`:return`Creates a folder "${t}" grouping every session whose git branch starts with "${e.pattern}". Current match: ${n} ${r}.`}}function kf({rule:e}){let t=cr(),n=lr(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(e.pattern),s=()=>{if(a===e.pattern){i(!1);return}t.mutate({id:e.id,patch:{pattern:a}},{onSuccess:()=>i(!1)})};return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2 text-sm`,children:[(0,G.jsx)(`label`,{className:`flex items-center gap-2 shrink-0`,title:`enable / disable`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:n=>t.mutate({id:e.id,patch:{enabled:n.target.checked}})})}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted w-28 shrink-0`,title:Tf[e.type],children:wf[e.type]}),r?(0,G.jsx)(`input`,{className:`min-w-0 flex-1 px-2 py-1 bg-bg-elevated border border-line rounded text-xs font-mono`,value:a,onChange:e=>o(e.target.value),onKeyDown:t=>{t.key===`Enter`&&s(),t.key===`Escape`&&(o(e.pattern),i(!1))},autoFocus:!0}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`min-w-0 flex-1 text-left font-mono text-xs truncate hover:text-accent`,title:`click to edit pattern`,children:e.pattern}),(0,G.jsx)(`span`,{className:$(`text-[10px] uppercase px-1.5 py-0.5 rounded-full shrink-0`,e.created_by===`suggestion-accepted`?`bg-role-tool/15 text-role-tool`:`bg-bg-hover text-fg-muted`),title:e.created_by===`suggestion-accepted`?`This rule started as an auto-detected suggestion that you accepted.`:`This rule was added manually through the form below.`,children:e.created_by===`suggestion-accepted`?`✨`:`⚙`}),r?(0,G.jsx)(`button`,{type:`button`,onClick:s,disabled:t.isPending,className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Save the updated pattern and re-match sessions against it.`,children:`Save`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete rule "${e.name}"? The collection stays; only rule-added rows are removed.`)&&n.mutate(e.id)},disabled:n.isPending,className:`px-2 py-1 rounded border border-line text-xs hover:bg-bg-hover disabled:opacity-50`,title:`Remove this rule; the sidebar folder stays and any sessions you added manually remain.`,children:`Delete`})]})}function Af(){let e=sr(),[t,n]=(0,W.useState)(``),[r,i]=(0,W.useState)(`cwd-prefix`),[a,o]=(0,W.useState)(``);return(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Add rule manually`}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted mt-1`,children:`Use this when no suggestion matches what you want. Pick a rule type, set a name (this becomes the collection name in the sidebar), and enter the pattern to match.`})]}),(0,G.jsxs)(`form`,{onSubmit:i=>{i.preventDefault(),!(!t.trim()||!a.trim())&&e.mutate({name:t.trim(),type:r,pattern:a.trim()},{onSuccess:()=>{n(``),o(``)}})},className:`flex flex-wrap gap-2 items-end`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Collection name`}),(0,G.jsx)(`input`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm`,value:t,onChange:e=>n(e.target.value),placeholder:`e.g. my-repo`,title:`Shown as the collection label in the sidebar.`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Match by`}),(0,G.jsx)(`select`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm`,value:r,onChange:e=>i(e.target.value),title:Tf[r],children:Object.keys(wf).map(e=>(0,G.jsx)(`option`,{value:e,title:Tf[e],children:wf[e]},e))})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs min-w-[16rem] flex-1`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Pattern`}),(0,G.jsx)(`input`,{className:`px-2 py-1 bg-bg-elevated border border-line rounded text-sm font-mono`,value:a,onChange:e=>o(e.target.value),placeholder:jf(r),title:Tf[r]})]}),(0,G.jsx)(`button`,{type:`submit`,disabled:e.isPending||!t.trim()||!a.trim(),className:`px-3 py-1.5 rounded bg-accent text-bg text-sm font-medium disabled:opacity-50`,title:`Create this rule and add the matching sidebar folder; it will keep itself populated going forward.`,children:`Create`})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic`,children:Tf[r]}),e.isError&&(0,G.jsx)(`div`,{className:`text-xs text-role-user`,children:e.error.message})]})}function jf(e){switch(e){case`cwd-prefix`:return`/Users/you/code/my-repo`;case`project-id`:return`42`;case`tag`:return`security`;case`plan-file`:return`ROADMAP.md`;case`git-branch-prefix`:return`feature/`}}var Mf={status:`idle`,jobId:null,current:0,total:0,lastTitled:null,failures:[],summary:null,error:null};function Nf(e){let t=K(),[n,r]=(0,W.useState)(Mf),i=(0,W.useRef)(null),a=(0,W.useCallback)(()=>{i.current&&=(i.current.close(),null)},[]);return(0,W.useEffect)(()=>()=>a(),[a]),{state:n,start:(0,W.useCallback)(async n=>{a(),r({...Mf,status:`starting`});let o;try{o=(await Z.startThreadTitlesJob(e,n)).jobId}catch(e){r({...Mf,status:`error`,error:e instanceof Error?e.message:String(e)});return}r(e=>({...e,status:`running`,jobId:o}));let s=mt(`/api/jobs/${encodeURIComponent(o)}/stream`),c=new EventSource(s);i.current=c,c.addEventListener(`progress`,n=>{let i=JSON.parse(n.data);r(e=>({...e,current:i.current,total:i.total,lastTitled:i})),t.invalidateQueries({queryKey:[`thread`,e]})}),c.addEventListener(`skipped`,()=>{}),c.addEventListener(`error`,e=>{if(typeof e.data==`string`)try{let t=JSON.parse(e.data);r(e=>({...e,failures:[...e.failures,t]}))}catch{}}),c.addEventListener(`done`,n=>{let i=JSON.parse(n.data);r(e=>({...e,status:`done`,summary:i})),a(),t.invalidateQueries({queryKey:[`thread`,e]})})},[a,t,e]),cancel:(0,W.useCallback)(async()=>{if(r(e=>({...e,status:`cancelling`})),n.jobId)try{await Z.cancelJob(n.jobId)}catch{}},[n.jobId]),reset:(0,W.useCallback)(()=>{a(),r(Mf)},[a])}}var Pf=260,Ff=92,If=24,Lf=168,Rf=24,zf=900;function Bf(e,t=new Set,n=Lf){let r=Math.max(If,Math.round(n*If/Lf)),i=new Map;for(let t of e)i.set(t.session_id,t);let a=new Map,o=[];for(let t of e){let e=t.parent_session_id;if(e&&i.has(e)&&e!==t.session_id){let n=a.get(e)??[];n.push(t),a.set(e,n)}else o.push(t)}let s=(e,t)=>{let n=e.role===`origin`?0:1,r=t.role===`origin`?0:1;return n===r?e.added_at.localeCompare(t.added_at):n-r};o.sort(s);for(let e of a.values())e.sort(s);let c=new Map,l=new Set;function u(e){if(c.has(e))return c.get(e);if(l.has(e))return c.set(e,0),0;l.add(e);let t=a.get(e)??[],n=0;for(let e of t)n+=1+u(e.session_id);return l.delete(e),c.set(e,n),n}let d=new Map,f=new Set;function p(e){if(d.has(e))return d.get(e);if(f.has(e))return d.set(e,1),1;f.add(e);let n=t.has(e)?[]:a.get(e)??[],r=0;for(let e of n)r+=p(e.session_id);f.delete(e);let i=Math.max(1,r);return d.set(e,i),i}for(let e of o)p(e.session_id);let m=[],h=new Set,g=0;function _(e,i,o){if(h.has(e.session_id))return;h.add(e.session_id);let s=Rf+(o+(d.get(e.session_id)??1)/2)*(Pf+r)-Pf/2,c=Rf+i*n,l=a.get(e.session_id)??[],f=t.has(e.session_id);if(m.push({edge:e,x:s,y:c,depth:i,hasChildren:l.length>0,hiddenCount:f?u(e.session_id):0}),f)return;let p=o;for(let e of l){let t=d.get(e.session_id)??1;_(e,i+1,p),p+=t}}for(let e of o){let t=d.get(e.session_id)??1;_(e,0,g),g+=t}let v=new Map,y=0,b=0;for(let e of m)v.set(e.edge.session_id,e),e.x+Pf>y&&(y=e.x+Pf),e.y+Ff>b&&(b=e.y+Ff);return{nodes:m,byId:v,width:Math.max(y+Rf,400),height:Math.max(b+Rf,200)}}function Vf(e){return ec({sessionId:e.session_id,alias:e.alias,autoTitle:e.auto_title,firstUserMessage:e.first_user_message,aliasSource:e.alias_source,autoTitleSource:e.auto_title_source})}var Hf={manual:`you linked this session to its parent yourself`,"plan-file":`both sessions reference the same plan or spec file`,"uuid-ref":`one session refers directly to the other by UUID`,"recall-context-ref":`one session was piped into the other via recall context`,semantic:`transcript content overlaps in meaning`,git:`the sessions share a git branch or commit range`,temporal:`the sessions ran close together on related work`};function Uf(e){let t=Math.round(e.confidence*100);return e.source===`manual`?`Manual link (${Hf.manual}).`:`Auto-linked via ${e.source} at ${t}% confidence (${Hf[e.source]}); 100% would mean manually linked.`}function Wf(e,t,n){let r=new Map;for(let e of n)r.set(e.session_id,e);let i=new Set,a=t;for(;a;){if(i.has(a))return!1;i.add(a);let t=r.get(a);if(!t)return!1;if(t.parent_session_id===e)return!0;a=t.parent_session_id}return!1}function Gf({thread:e}){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(1024);return(0,W.useEffect)(()=>{if(!t.current)return;let e=new ResizeObserver(e=>{for(let t of e)r(t.contentRect.width)});return e.observe(t.current),()=>e.disconnect()},[]),(0,G.jsx)(`div`,{ref:t,className:`w-full`,children:n>0&&n<zf?(0,G.jsx)(Jf,{thread:e}):(0,G.jsx)(Kf,{thread:e})})}function Kf({thread:e}){let[,t]=Nn(),n=Su(),r=xu(),i=Kl(),a=`threads.collapsed.${e.id}`,[o,s]=(0,W.useState)(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(a);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}),c=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),typeof window<`u`&&window.localStorage.setItem(a,JSON.stringify(Array.from(n))),n})},l=()=>{s(new Set),typeof window<`u`&&window.localStorage.removeItem(a)},[u,d]=(0,W.useState)(!1),f=(0,W.useRef)(1),[p,m]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`recall.threadVSpacing`),t=e?parseInt(e,10):NaN;if(Number.isFinite(t)&&t>=100&&t<=900)return t}catch{}return 168});(0,W.useEffect)(()=>{try{localStorage.setItem(`recall.threadVSpacing`,String(p))}catch{}},[p]);let{nodes:h,byId:g,width:_,height:v}=(0,W.useMemo)(()=>Bf(e.edges,o,p),[e.edges,o,p]),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(null),C=(0,W.useMemo)(()=>{let t=0,n=0;for(let r of e.edges)r.role===`origin`&&t++,r.source!==`manual`&&r.confidence<1&&n++;return{total:e.edges.length,origins:t,autoPending:n}},[e.edges]),w=(0,W.useRef)(null),[T,E]=(0,W.useState)(null),[D,O]=(0,W.useState)(null),[k,A]=(0,W.useState)(!1);(0,W.useEffect)(()=>{function e(){let e=w.current;if(e&&T&&e.hasPointerCapture(T.pointerId))try{e.releasePointerCapture(T.pointerId)}catch{}E(null),O(null),A(!1)}function t(){document.visibilityState===`hidden`&&e()}return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[T]);let j=(0,W.useCallback)(n=>{t({session:n,view:null,thread:null,project:e.edges.find(e=>e.session_id===n)?.project??null,msg:null,col:null})},[t,e.edges]),M=(0,W.useCallback)((t,r)=>{let i=e.edges.find(e=>e.session_id===t);if(!i)return;let a=i.parent_session_id;a!==r&&n.mutate({threadId:e.id,sessionId:t,parentSessionId:r},{onSuccess:()=>{Q({message:r?`Re-parented ${t.slice(0,8)} to ${r.slice(0,8)}`:`Promoted ${t.slice(0,8)} to origin`,tone:`success`,duration:9e3,action:{label:`Undo`,onClick:()=>{n.mutate({threadId:e.id,sessionId:t,parentSessionId:a})}}})},onError:e=>{Q({message:`Re-parent failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[e.edges,e.id,n]),ee=(0,W.useCallback)(t=>{let n=e.edges.find(e=>e.session_id===t),i=e.edges.filter(e=>e.parent_session_id===t).length,a=n?.alias??t.slice(0,8),o=i>0?`\n\n${i} child session${i===1?``:`s`} will be re-parented to ${n?.parent_session_id?`its grandparent`:`origin`}.`:``;confirm(`Remove "${a}" from this thread?${o}\n\nThe session itself stays in Recall, only the link to this thread is removed.`)&&r.mutate({threadId:e.id,sessionId:t},{onSuccess:()=>{Q({message:`Removed ${a} from thread`,tone:`success`})},onError:e=>{Q({message:`Remove failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[e.edges,e.id,r]),N=(0,W.useCallback)(t=>{S({sessionId:t,value:e.edges.find(e=>e.session_id===t)?.alias??``}),b(null)},[e.edges]),te=(0,W.useCallback)(()=>S(null),[]),P=(0,W.useCallback)(()=>{if(!x)return;let e=x.value.trim();if(!e){S(null);return}let t=x.sessionId;S(null),i.mutate({sessionId:t,alias:e},{onSuccess:()=>{Q({message:`Renamed session to "${e}"`,tone:`success`})},onError:e=>{Q({message:`Rename failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},[x,i]),F=(0,W.useCallback)((e,t)=>{let n=w.current;if(!n)return{x:0,y:0};let r=n.getBoundingClientRect(),i=f.current||1;return{x:(e-r.left+n.scrollLeft)/i,y:(t-r.top+n.scrollTop)/i}},[]),I=(0,W.useCallback)((e,t,n)=>{for(let r of h)if(r.edge.session_id!==n&&e>=r.x&&e<=r.x+Pf&&t>=r.y&&t<=r.y+Ff)return r.edge.session_id;return null},[h]),L=(e,t)=>{if(e.button!==0)return;let n=w.current;if(n)try{n.setPointerCapture(e.pointerId)}catch{}let r=F(e.clientX,e.clientY);E({sessionId:t,pointerX:r.x,pointerY:r.y,startX:r.x,startY:r.y,pointerId:e.pointerId}),A(!1)},R=e=>{if(!T||T.pointerId!==e.pointerId)return;let t=F(e.clientX,e.clientY),n=Math.hypot(t.x-T.startX,t.y-T.startY)>16;n&&!k&&A(!0),E({...T,pointerX:t.x,pointerY:t.y}),O(n?I(t.x,t.y,T.sessionId):null)},z=e=>{let t=w.current;if(t?.hasPointerCapture(e))try{t.releasePointerCapture(e)}catch{}},B=t=>{if(!T||T.pointerId!==t.pointerId)return;z(t.pointerId);let n=F(t.clientX,t.clientY),r=Math.hypot(n.x-T.startX,n.y-T.startY),i=k,a=r>16,o=i&&a?I(n.x,n.y,T.sessionId):null,s=T.sessionId;if(E(null),O(null),A(!1),!i){j(s);return}if(a&&o!==s&&o&&o!==s){if(Wf(s,o,e.edges)){Q({message:`Cannot re-parent: that would create a cycle. A thread is a DAG.`,tone:`error`});return}M(s,o)}},V=e=>{T?.pointerId===e.pointerId&&z(e.pointerId),E(null),O(null),A(!1)},ne=(0,W.useMemo)(()=>{let t=[];for(let n of e.edges){let e=n.parent_session_id;if(!e)continue;let r=g.get(n.session_id),i=g.get(e);if(!r||!i)continue;let a=i.x+Pf/2,o=i.y+Ff,s=r.x+Pf/2,c=r.y;t.push({key:`${e}->${n.session_id}`,x1:a,y1:o,x2:s,y2:c,confidence:n.confidence,source:n.source,midX:(a+s)/2,midY:(o+c)/2,title:Uf(n)})}return t},[e.edges,g]),H=T?g.get(T.sessionId)??null:null;return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{title:`Total sessions pulled into this thread.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.total}),` session`,C.total===1?``:`s`,` linked`]}),(0,G.jsxs)(`span`,{title:`Threads can have multiple origins; these are the seed sessions the thread grew from.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.origins}),` origin`,C.origins===1?``:`s`]}),C.autoPending>0&&(0,G.jsxs)(`span`,{title:`Auto-detected links below full confidence that you have not confirmed yet.`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.autoPending}),` `,`auto-suggested`]}),(0,G.jsx)(`span`,{className:`ml-auto italic`,children:`Drag a node onto another to re-parent. Drop on empty canvas to cancel.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:$(`px-2.5 py-1 rounded border transition-colors`,u?`border-accent text-accent bg-accent/10`:`border-line text-fg-muted hover:text-accent hover:border-accent`),title:`Scale the entire tree to fit the canvas without scrolling`,children:u?`↔ Fit-to-view (on)`:`↔ Fit-to-view`}),o.size>0&&(0,G.jsxs)(`button`,{type:`button`,onClick:l,className:`px-2.5 py-1 rounded border border-line text-fg-muted hover:text-accent hover:border-accent transition-colors`,title:`Expand every collapsed branch`,children:[`▾ Expand all (`,o.size,`)`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 px-2 py-1 rounded border border-line text-fg-muted`,title:`Vertical spacing between parent and child rows (saved per browser)`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider`,children:`Spacing`}),(0,G.jsx)(`input`,{type:`range`,min:100,max:900,step:4,value:p,onChange:e=>m(parseInt(e.target.value,10)),className:`accent-accent w-24`,"aria-label":`Vertical spacing between rows`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>m(168),className:`text-[10px] text-fg-muted/70 hover:text-accent`,title:`Reset to default`,children:`reset`})]}),(0,G.jsx)(`span`,{className:`text-[10px] text-fg-muted ml-auto`,children:`Click ▸ on any parent to fold its branch`})]}),(0,G.jsx)(`div`,{ref:w,className:`relative border border-line rounded bg-bg-elevated overflow-auto`,style:{height:Math.min(v+40,700)},onPointerMove:R,onPointerUp:B,onPointerCancel:V,children:(0,G.jsx)(Xf,{enabled:u,contentWidth:_,contentHeight:v,onScaleChange:e=>{f.current=e},children:(0,G.jsxs)(`div`,{style:{width:_,height:v,position:`relative`},"data-share-capture-content":`thread-graph`,children:[(0,G.jsx)(`svg`,{width:_,height:v,className:`absolute inset-0 pointer-events-none`,children:ne.map(e=>{let t=e.source!==`manual`,n=e.confidence>=1?3:Math.max(1,e.confidence*2.5);return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`path`,{d:`M ${e.x1} ${e.y1} C ${e.x1} ${(e.y1+e.y2)/2}, ${e.x2} ${(e.y1+e.y2)/2}, ${e.x2} ${e.y2}`,fill:`none`,stroke:`currentColor`,strokeOpacity:.6,strokeWidth:n,strokeDasharray:t?`5 4`:void 0,className:`text-fg-muted`,style:{pointerEvents:`stroke`},children:(0,G.jsx)(`title`,{children:e.title})}),t&&(0,G.jsxs)(`g`,{transform:`translate(${e.midX-10} ${e.midY-8})`,style:{pointerEvents:`auto`},children:[(0,G.jsx)(`title`,{children:e.title}),(0,G.jsx)(`rect`,{width:20,height:14,rx:3,className:`fill-bg-elevated`,stroke:`currentColor`,strokeOpacity:.5}),(0,G.jsx)(`text`,{x:10,y:10,textAnchor:`middle`,className:`fill-fg-muted`,style:{fontSize:9,fontWeight:600},children:`AI`})]})]},e.key)})}),h.map(e=>{let t=T?.sessionId===e.edge.session_id,n=D===e.edge.session_id,r=e.edge.role===`origin`,i=x?.sessionId===e.edge.session_id,a=Math.round(e.edge.confidence*100),o=e.edge.source===`manual`?`added manually`:`auto-linked via ${e.edge.source} at ${a}% confidence`,s=`${r?`Origin`:`Child`} session ${e.edge.session_id}, ${o}; click to open, drag to re-parent, right-click to rename.`,l=r?`Origin: one of the seed sessions this thread grew from.`:`Child: a session linked under a parent.`,u=e.edge.source===`manual`?``:`Auto-linked via ${e.edge.source} at ${a}% confidence (${Hf[e.edge.source]}); 100% would mean manually linked.`;return(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,onPointerDown:t=>{i||L(t,e.edge.session_id)},onContextMenu:t=>{t.preventDefault(),T&&z(T.pointerId),E(null),O(null),A(!1),b({sessionId:e.edge.session_id,x:t.clientX,y:t.clientY})},onKeyDown:t=>{i||(t.key===`Enter`||t.key===` `?(t.preventDefault(),j(e.edge.session_id)):t.key===`F2`&&(t.preventDefault(),N(e.edge.session_id)))},className:$(`absolute select-none rounded border shadow-sm flex flex-col justify-center px-3 py-2 text-left transition-colors`,`focus:outline-none focus:ring-2 focus:ring-accent/60`,r?`bg-accent/20 border-accent/60 text-fg`:`bg-bg border-line text-fg`,t&&`opacity-50 cursor-grabbing`,n&&`ring-2 ring-accent`,i&&`ring-2 ring-accent cursor-text`,!t&&!i&&`cursor-grab hover:border-accent/60`),style:{left:e.x,top:e.y,width:Pf,height:Ff,touchAction:`none`},title:s,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:$(`text-[9px] uppercase tracking-wider px-1 py-0.5 rounded shrink-0`,r?`bg-accent text-bg`:`bg-bg-hover text-fg-muted`),title:l,children:e.edge.role}),e.edge.source!==`manual`&&(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider px-1 py-0.5 rounded bg-bg-hover text-fg-muted shrink-0`,title:u,children:`AI`}),e.hasChildren&&(0,G.jsx)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),c(e.edge.session_id)},className:$(`ml-auto text-[10px] leading-none px-1.5 py-0.5 rounded shrink-0 border transition-colors`,e.hiddenCount>0?`border-accent text-accent bg-accent/10 hover:bg-accent/20`:`border-line text-fg-muted hover:text-accent hover:border-accent`),title:e.hiddenCount>0?`${e.hiddenCount} descendant${e.hiddenCount===1?``:`s`} hidden — click to expand`:`Fold this branch`,"aria-label":e.hiddenCount>0?`Expand subtree`:`Collapse subtree`,children:e.hiddenCount>0?`▸ +${e.hiddenCount}`:`▾`})]}),i?(0,G.jsx)(`input`,{autoFocus:!0,type:`text`,value:x.value,onChange:e=>S({sessionId:x.sessionId,value:e.target.value}),onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),P()):e.key===`Escape`&&(e.preventDefault(),te())},onBlur:P,placeholder:Vf(e.edge),"aria-label":`Rename session`,className:`text-sm bg-bg-elevated border border-accent rounded px-1 py-0.5 mt-0.5 outline-none w-full`}):(0,G.jsx)(`div`,{className:`text-[12.5px] leading-snug mt-0.5 break-words overflow-hidden`,children:Vf(e.edge)})]},e.edge.session_id)}),H&&T&&k&&(0,G.jsx)(`div`,{className:`absolute pointer-events-none rounded border border-accent bg-bg shadow-lg px-3 py-2 opacity-80`,style:{left:T.pointerX-Pf/2,top:T.pointerY-Ff/2,width:Pf,height:Ff},children:(0,G.jsx)(`div`,{className:`text-[12.5px] leading-snug break-words overflow-hidden`,children:Vf(H.edge)})})]})})}),y&&(0,G.jsx)(Yf,{x:y.x,y:y.y,sessionId:y.sessionId,onRename:()=>N(y.sessionId),onRemoveFromThread:()=>ee(y.sessionId),onClose:()=>b(null)})]})}function qf(e){let t=new Map;for(let n of e)t.set(n.session_id,{edge:n,children:[]});let n=[];for(let e of t.values()){let r=e.edge.parent_session_id;r&&t.has(r)&&r!==e.edge.session_id?t.get(r).children.push(e):n.push(e)}return n}function Jf({thread:e}){let t=(0,W.useMemo)(()=>qf(e.edges),[e.edges]),[,n]=Nn(),r=xu();if(t.length===0)return(0,G.jsx)(`div`,{className:`text-xs text-fg-muted italic p-3 border border-line rounded`,children:`No sessions yet.`});let i=(t,n)=>{let i=n??t.slice(0,8),a=e.edges.filter(e=>e.parent_session_id===t).length,o=a>0?`\n\n${a} child session${a===1?``:`s`} will be re-parented.`:``;confirm(`Remove "${i}" from this thread?${o}\n\nThe session itself stays in Recall, only the link to this thread is removed.`)&&r.mutate({threadId:e.id,sessionId:t},{onSuccess:()=>{Q({message:`Removed ${i} from thread`,tone:`success`})},onError:e=>{Q({message:`Remove failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})},a=(e,t)=>{let r=e.edge.role===`origin`,o=Math.round(e.edge.confidence*100),s=e.edge.source===`manual`?`added manually`:`auto-linked via ${e.edge.source} at ${o}% confidence`,c=`${r?`Origin`:`Child`} session ${e.edge.session_id}, ${s}; click to open.`,l=r?`Origin: one of the seed sessions this thread grew from.`:`Child: a session linked under a parent.`,u=e.edge.project??null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 border-b border-line/50 hover:bg-bg-hover`,style:{paddingLeft:`${12+t*20}px`,paddingRight:`8px`},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n({session:e.edge.session_id,view:null,thread:null,project:u,msg:null,col:null}),className:`flex-1 flex items-center gap-2 py-2 text-sm text-left min-w-0`,title:c,children:[(0,G.jsx)(`span`,{className:$(`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded shrink-0`,r?`bg-accent/20 text-accent`:`bg-bg-hover text-fg-muted`),title:l,children:e.edge.role}),(0,G.jsx)(`span`,{className:`truncate`,children:Vf(e.edge)})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.edge.session_id,e.edge.alias??null)},className:`text-[10px] text-fg-muted hover:text-role-user opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,title:`remove from this thread (session itself is preserved)`,"aria-label":`remove from thread`,children:`remove`})]}),e.children.map(e=>a(e,t+1))]},e.edge.session_id)};return(0,G.jsx)(`div`,{className:`border border-line rounded`,children:t.map(e=>a(e,0))})}function Yf({x:e,y:t,sessionId:n,onRename:r,onRemoveFromThread:i,onClose:a}){let o=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a()},t=e=>{e.key===`Escape`&&a()};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[a]);let[s,c]=(0,W.useState)(`idle`),l=Math.min(e,window.innerWidth-240-8),u=Math.min(t,window.innerHeight-200-8),d=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}};return(0,G.jsxs)(`div`,{ref:o,role:`menu`,"aria-label":`thread node actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:l,top:u,width:240},children:[(0,G.jsxs)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted`,children:[`session `,n.slice(0,8)]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:async()=>{c(await d(n)?`copied`:`failed`),setTimeout(a,700)},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:s===`copied`?`Copied!`:s===`failed`?`Copy failed — try again`:`Copy session ID`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted font-mono`,children:n})]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),a()},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Rename session`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`set an alias that overrides the auto-title`})]}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(),i()},className:`block w-full text-left px-3 py-1.5 hover:bg-role-user/10`,children:[(0,G.jsx)(`div`,{className:`text-role-user`,children:`Remove from thread`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`unlinks this session; the session itself is preserved`})]})]})}function Xf({enabled:e,contentWidth:t,contentHeight:n,children:r,onScaleChange:i}){let a=(0,W.useRef)(null),[o,s]=(0,W.useState)(1);return(0,W.useEffect)(()=>{if(!e){s(1),i?.(1);return}let r=a.current?.parentElement;if(!r)return;let o=()=>{let e=r.clientWidth,a=r.clientHeight;if(e<=0||a<=0||t<=0||n<=0)return;let o=Math.min(e/t,a/n,1);s(o),i?.(o)};o();let c=new ResizeObserver(o);return c.observe(r),()=>c.disconnect()},[e,t,n,i]),e?(0,G.jsx)(`div`,{ref:a,style:{width:t*o,height:n*o,position:`relative`},children:(0,G.jsx)(`div`,{style:{transform:`scale(${o})`,transformOrigin:`top left`,width:t,height:n},children:r})}):(0,G.jsx)(G.Fragment,{children:r})}var Zf=`#f97316`,Qf=`#fb923c`,$f=`#4a4a52`;function ep(){return(0,G.jsx)(`span`,{className:`inline-flex items-center justify-center w-7 h-7 align-[-6px] rounded border-2 text-base font-semibold leading-none`,style:{color:Zf,borderColor:Zf},"aria-label":`sync`,children:`⟳`})}function tp(){return(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-0 border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(np,{index:`01`,kicker:`Before`,title:`Chats live in many terminals`,description:`Every Claude conversation in an IDE terminal is its own session. Most users juggle dozens, scattered across repos and windows.`,children:(0,G.jsx)(rp,{})}),(0,G.jsx)(np,{index:`02`,kicker:`Action`,title:`Click ⟳ on the repo`,description:`Sync grabs every session whose terminal is still open in that repo's cwd, then infers parent and child links from time, file overlap, and authorship.`,accent:!0,children:(0,G.jsx)(ip,{})}),(0,G.jsx)(np,{index:`03`,kicker:`After`,title:`One thread, ready to pipe`,description:`The whole bundle becomes a single thread you can hand back to Claude as a context-rich prompt. Re-running adds new actives, never duplicates.`,children:(0,G.jsx)(ap,{})})]})}function np({index:e,kicker:t,title:n,description:r,accent:i,children:a}){return(0,G.jsxs)(`div`,{className:`relative bg-bg-hover/20 p-5 flex flex-col gap-3 border-r border-line last:border-r-0`,style:i?{background:`rgba(249, 115, 22, 0.06)`}:void 0,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,G.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums leading-none tracking-tight`,style:{color:i?Zf:$f},children:e}),(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.2em] text-fg-muted`,children:t})]}),(0,G.jsx)(`div`,{className:`aspect-[3/2] w-full rounded border border-line bg-bg-elevated/40 flex items-center justify-center overflow-hidden`,children:a}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg mb-1 leading-snug`,children:n}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:r})]})]})}function rp(){return(0,G.jsx)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`Before: scattered terminals`,children:[[20,30],[110,25],[180,50],[40,90],[130,95],[195,110],[70,130]].map(([e,t],n)=>(0,G.jsxs)(`g`,{transform:`translate(${e},${t})`,children:[(0,G.jsx)(`rect`,{width:`44`,height:`22`,rx:`2`,fill:`none`,stroke:$f,strokeWidth:`1.25`}),(0,G.jsx)(`circle`,{cx:`6`,cy:`6`,r:`1.4`,fill:Qf}),(0,G.jsx)(`line`,{x1:`11`,y1:`13`,x2:`38`,y2:`13`,stroke:$f,strokeWidth:`0.8`}),(0,G.jsx)(`line`,{x1:`11`,y1:`17`,x2:`30`,y2:`17`,stroke:$f,strokeWidth:`0.8`})]},n))})}function ip(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`Action: terminals collapse into a thread`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`arr`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,G.jsx)(`path`,{d:`M0,0 L10,5 L0,10 Z`,fill:Zf})})}),[[20,30],[20,70],[20,110],[20,130]].map(([e,t],n)=>(0,G.jsxs)(`g`,{transform:`translate(${e},${t})`,children:[(0,G.jsx)(`rect`,{width:`44`,height:`20`,rx:`2`,fill:`none`,stroke:$f,strokeWidth:`1.25`}),(0,G.jsx)(`circle`,{cx:`6`,cy:`6`,r:`1.4`,fill:Qf}),(0,G.jsx)(`line`,{x1:`11`,y1:`13`,x2:`38`,y2:`13`,stroke:$f,strokeWidth:`0.8`})]},n)),[40,80,120,140].map((e,t)=>(0,G.jsx)(`line`,{x1:`68`,y1:e,x2:`150`,y2:`80`,stroke:Zf,strokeWidth:`1`,strokeDasharray:`3 3`,markerEnd:`url(#arr)`,opacity:`0.85`},t)),(0,G.jsx)(`circle`,{cx:`170`,cy:`80`,r:`22`,fill:`none`,stroke:Zf,strokeWidth:`2`}),(0,G.jsx)(`text`,{x:`170`,y:`85`,textAnchor:`middle`,fontSize:`20`,fill:Zf,fontFamily:`system-ui`,fontWeight:`600`,children:`⟳`})]})}function ap(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 240 160`,className:`w-full h-full`,role:`img`,"aria-label":`After: thread tree`,children:[(0,G.jsx)(`circle`,{cx:`120`,cy:`32`,r:`9`,fill:Zf}),[60,120,180].map((e,t)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`line`,{x1:`120`,y1:`40`,x2:e,y2:`80`,stroke:Qf,strokeWidth:`1.5`}),(0,G.jsx)(`circle`,{cx:e,cy:`86`,r:`7`,fill:Qf})]},t)),[[40,60],[80,60],[105,120],[135,120],[165,180],[195,180]].map(([e,t],n)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`line`,{x1:t,y1:`92`,x2:e,y2:`128`,stroke:$f,strokeWidth:`1`}),(0,G.jsx)(`circle`,{cx:e,cy:`132`,r:`5`,fill:`none`,stroke:$f,strokeWidth:`1.25`})]},n))]})}function op({kicker:e,value:t,detail:n}){return(0,G.jsxs)(`div`,{className:`bg-bg p-5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.2em] text-fg-muted mb-2`,children:e}),(0,G.jsx)(`div`,{className:`text-lg font-semibold text-fg mb-1`,children:t}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:n})]})}var sp=`#fb923c`,cp=`#f97316`;function lp({projectId:e,projectName:t,onClose:n}){let r=K(),[i,a]=(0,W.useState)(`preflighting`),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null);(0,W.useEffect)(()=>{let t=!1;return a(`preflighting`),d(null),(async()=>{try{let n=await Z.syncActivePreflight({project_id:e});if(t)return;s(n.plan),a(`review`)}catch(e){if(t)return;d(e instanceof Error?e.message:String(e)),a(`failed`)}})(),()=>{t=!0}},[e]),(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`applying`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]);async function f(){a(`applying`),d(null);try{let n=await Z.syncActiveApply({project_id:e});s(n.plan),l(n.result),a(`done`),r.invalidateQueries({queryKey:[`threads`]}),r.invalidateQueries({queryKey:[`thread-folders`]}),Q({message:n.result.added>0?`Added ${n.result.added} session${n.result.added===1?``:`s`}, set ${n.result.edges_set} edge${n.result.edges_set===1?``:`s`}.`:`Already up to date in ${t}.`,tone:`success`})}catch(e){d(e instanceof Error?e.message:String(e)),a(`failed`),Q({message:`Sync failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}let p=i===`review`&&o!==null&&o.candidates.length>0;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`applying`&&n()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full`,style:{background:cp,boxShadow:`0 0 0 2px ${sp} inset`}}),`Sync active sessions in `,t]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i===`applying`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,children:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(0,G.jsxs)(`details`,{className:`group`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer select-none flex items-center justify-between text-[10px] uppercase tracking-[0.2em] text-fg-muted hover:text-fg py-1`,children:[(0,G.jsx)(`span`,{children:`How this works`}),(0,G.jsx)(`span`,{className:`text-fg-muted group-open:rotate-90 transition-transform inline-block`,children:`›`})]}),(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(tp,{}),(0,G.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-px bg-line border border-line rounded overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Scope`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5 truncate`,title:t,children:t})]}),(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Re-runs`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5`,children:`Same thread`})]}),(0,G.jsxs)(`div`,{className:`bg-bg p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.18em] text-fg-muted`,children:`Manual edges`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg font-semibold mt-0.5`,children:`Preserved`})]})]})]})]}),i===`preflighting`&&(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30 flex items-center gap-3 text-fg-muted`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-t-transparent animate-spin`,style:{borderColor:sp,borderTopColor:`transparent`}}),(0,G.jsxs)(`span`,{children:[`Looking at active sessions in `,t,`…`]})]}),(i===`review`||i===`applying`||i===`done`)&&o&&(0,G.jsx)(up,{plan:o,applying:i===`applying`,done:i===`done`,result:c}),i===`failed`&&(0,G.jsxs)(`div`,{className:`p-3 rounded border border-role-user/40 bg-role-user/10 text-role-user`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-1`,children:`Sync failed`}),(0,G.jsx)(`div`,{children:u??`Unknown error`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[i===`review`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded border border-line hover:bg-bg-hover`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:f,disabled:!p,className:`text-xs px-3 py-1.5 rounded text-bg disabled:opacity-40 disabled:cursor-not-allowed font-medium`,style:{background:cp},children:o&&o.proposed_additions.length>0?`Apply (${o.proposed_additions.length} new session${o.proposed_additions.length===1?``:`s`})`:`Apply`})]}),i===`applying`&&(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full border-2 border-t-transparent animate-spin`,style:{borderColor:sp,borderTopColor:`transparent`}}),(0,G.jsx)(`span`,{children:`Writing thread + edges…`})]}),(i===`done`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded text-bg font-medium`,style:{background:cp},children:`Close`})]})]})})}function up({plan:e,applying:t,done:n,result:r}){return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(fp,{plan:e}),e.warnings.length>0&&(0,G.jsx)(`div`,{className:`p-2 rounded border border-role-tool/40 bg-role-tool/10 text-role-tool`,children:e.warnings.map((e,t)=>(0,G.jsxs)(`div`,{children:[`⚠ `,e]},t))}),e.candidates.length===0?(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`No live Claude sessions touched in `,dp(e),` within the rolling window. Open a terminal in this repo and run`,` `,(0,G.jsx)(`code`,{className:`text-fg bg-bg-elevated px-1 py-0.5 rounded`,children:`claude`}),` `,`to get on the list.`]}):(0,G.jsx)(pp,{plan:e}),e.preserved_manual_edges.length>0&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px]`,children:[e.preserved_manual_edges.length,` manual edge`,e.preserved_manual_edges.length===1?``:`s`,` will be preserved across this sync.`]}),n&&r&&(0,G.jsxs)(`div`,{className:`p-3 rounded text-fg`,style:{background:`rgba(138, 120, 255, 0.10)`,borderColor:sp,borderWidth:1,borderStyle:`solid`},children:[(0,G.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Applied.`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Added `,r.added,` session`,r.added===1?``:`s`,`, set `,r.edges_set,` parent edge`,r.edges_set===1?``:`s`,`, preserved `,r.preserved_manual,` manual edge`,r.preserved_manual===1?``:`s`,`.`]})]}),t&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Writing the thread, sessions, and inferred parent edges…`})]})}function dp(e){return e.project.name}function fp({plan:e}){return(0,G.jsxs)(`div`,{className:`border border-line rounded p-3 bg-bg-hover/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Thread`}),(0,G.jsx)(`span`,{className:`text-fg font-medium truncate`,children:e.thread.name}),(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider`,style:{background:e.thread.exists?`rgba(138, 120, 255, 0.15)`:`rgba(179, 168, 255, 0.20)`,color:sp},children:e.thread.exists?`reusing`:`new`})]}),e.thread.exists&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] mt-1`,children:[e.thread.existing_session_count,` session`,e.thread.existing_session_count===1?``:`s`,` already in this thread. Re-syncing only adds the ones that are missing.`]})]})}function pp({plan:e}){let t=new Set(e.candidates.map(e=>e.session_id)),n=new Map;for(let t of e.proposed_edges)n.set(t.child_id,t);let r=new Set(e.proposed_additions.map(e=>e.session_id));return(0,G.jsxs)(`div`,{className:`border border-line rounded`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line text-fg-muted text-[11px] uppercase tracking-wider flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:`Candidates`}),(0,G.jsxs)(`span`,{children:[e.candidates.length,` session`,e.candidates.length===1?``:`s`,` ·`,` `,e.proposed_additions.length,` new`]})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-line/60`,children:e.candidates.map(e=>{let i=n.get(e.session_id),a=!!i&&t.has(i.parent_id),o=r.has(e.session_id);return(0,G.jsxs)(`li`,{className:`px-3 py-2 flex flex-col gap-0.5`,style:{paddingLeft:a?28:12,borderLeft:a?`2px solid ${sp}40`:`2px solid transparent`},children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider shrink-0`,style:{background:o?`rgba(179, 168, 255, 0.20)`:`rgba(74, 74, 82, 0.25)`,color:o?sp:`#888`},children:o?`new`:`keep`}),(0,G.jsx)(`span`,{className:`font-mono text-fg-muted shrink-0`,children:e.session_id.slice(0,8)}),(0,G.jsx)(`span`,{className:`truncate text-fg`,children:mp(e)})]}),i&&t.has(i.parent_id)&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[11px] flex items-baseline gap-2 ml-1`,children:[(0,G.jsx)(`span`,{children:`parent`}),(0,G.jsx)(`span`,{className:`font-mono`,children:i.parent_id.slice(0,8)}),(0,G.jsxs)(`span`,{className:`font-mono tabular-nums`,style:{color:sp},children:[`[conf `,i.confidence.toFixed(2),`]`]}),(0,G.jsx)(`span`,{className:`truncate`,children:i.reasons.join(` · `)})]})]},e.session_id)})})]})}function mp(e){return e.alias||e.auto_title||(e.first_user_message?e.first_user_message.replace(/\s+/g,` `).slice(0,80):`(no title)`)}function hp(){let[e,t]=Nn(),n=du(),r=e.thread,i=fu(r),a=mu(),o=hu(),s=n.data?.threads??[],c=i.data?.thread??null,[l,u]=(0,W.useState)(``),d=`(no project yet)`,f=(0,W.useMemo)(()=>{let e=new Map;for(let t of s){let n=t.project??d,r=e.get(n);r||(r=[],e.set(n,r)),r.push(t)}return Array.from(e.entries()).sort(([e],[t])=>e===d?1:t===d?-1:e.localeCompare(t))},[s]),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(null),_=`threads.leftPaneWidth`,[v,y]=(0,W.useState)(()=>{if(typeof window>`u`)return 288;let e=window.localStorage.getItem(_),t=e?Number(e):NaN;return Number.isFinite(t)?Math.min(600,Math.max(200,t)):288}),b=`threads.leftPaneCollapsed`,[x,S]=(0,W.useState)(()=>typeof window>`u`?!1:window.localStorage.getItem(b)===`1`),C=()=>{S(e=>{let t=!e;return typeof window<`u`&&window.localStorage.setItem(b,t?`1`:`0`),t})},w=(0,W.useRef)(null),T=e=>{e.preventDefault(),w.current={startX:e.clientX,startWidth:v},e.currentTarget.setPointerCapture(e.pointerId)},E=e=>{if(!w.current)return;let t=w.current.startWidth+(e.clientX-w.current.startX);y(Math.min(600,Math.max(200,t)))},D=e=>{w.current&&(w.current=null,e.currentTarget.releasePointerCapture(e.pointerId),typeof window<`u`&&window.localStorage.setItem(_,String(v)))},O=()=>{y(288),typeof window<`u`&&window.localStorage.setItem(_,`288`)},k=`threads.expandedFolders`,[A,j]=(0,W.useState)(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(k);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}),M=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),typeof window<`u`&&window.localStorage.setItem(k,JSON.stringify(Array.from(n))),n})},[ee,N]=(0,W.useState)(null),te=q({queryKey:[`projects`],queryFn:()=>Z.projects().then(e=>e.mode===`folder`?e.projects:[]),staleTime:6e4}),P=(0,W.useMemo)(()=>{let e=new Map;for(let t of te.data??[])e.set(t.name,t.id);return e},[te.data]),F=gu(),I=_u(),L=vu(),R=F.data?.folders??[],[z,B]=(0,W.useState)(null),[V,ne]=(0,W.useState)(null),[H,re]=(0,W.useState)(null),[ie,ae]=(0,W.useState)(null),oe=yu(),se=()=>{re(null),ae(null)},ce=(e,t)=>{if(H?.kind!==`folder`||H.parentFolderId!==e.parent_folder_id||H.projectScope!==e.project_scope)return;if(H.id===e.id){se();return}let n=R.filter(t=>t.parent_folder_id===e.parent_folder_id&&t.project_scope===e.project_scope).sort((e,t)=>e.sort_order-t.sort_order||e.name.localeCompare(t.name)).map(e=>e.id).filter(e=>e!==H.id),r=n.indexOf(e.id);if(r<0){se();return}let i=t===`before`?r:r+1,a=[...n.slice(0,i),H.id,...n.slice(i)];se(),oe.mutate({parentFolderId:e.parent_folder_id,projectScope:e.project_scope,orderedIds:a},{onError:e=>Q({message:`Reorder failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},U=e=>{if(H?.kind!==`thread`)return;if(e.project_scope!==null&&H.project!==e.project_scope){se(),Q({message:`Can't move thread: it belongs to ${H.project??`no project`} but folder is in ${e.project_scope}`,tone:`error`});return}let t=H.id;se(),o.mutate({id:t,patch:{folder_id:e.id}},{onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},le=(e,t)=>{let n=t.trim();n&&o.mutate({id:e,patch:{name:n}},{onSuccess:()=>{Q({message:`Renamed thread to "${n}"`,tone:`success`})},onError:e=>{Q({message:`Rename failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})}})};return(0,G.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[x?(0,G.jsxs)(`aside`,{className:`pane shrink-0 w-10 border-r border-line flex flex-col items-center py-3 gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`Expand threads pane`,title:`Expand threads pane`,className:`w-7 h-7 rounded border border-line text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-semibold leading-none transition-colors`,children:`»`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),"aria-label":`Show threads overview`,title:`Show the threads overview`,className:`w-7 h-7 rounded-full border-2 border-fg-muted text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-bold leading-none transition-colors`,children:`?`}),(0,G.jsx)(`span`,{className:`text-base`,title:`Threads`,style:{writingMode:`vertical-rl`},children:`🧵`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold tabular-nums text-fg-muted`,title:`${s.length} thread${s.length===1?``:`s`}`,children:s.length})]}):(0,G.jsxs)(`aside`,{className:`pane shrink-0`,style:{width:`${v}px`},children:[(0,G.jsxs)(`div`,{className:`pane-header`,children:[(0,G.jsx)(`span`,{className:`text-base`,children:`🧵 Threads`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),"aria-label":`Show how threads work`,className:`w-8 h-8 rounded-full border-2 border-fg-muted text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-lg font-bold leading-none transition-colors`,title:`Show the threads overview (deselects the current thread)`,children:`?`}),(0,G.jsx)(`span`,{className:`text-base font-semibold tabular-nums`,children:s.length}),(0,G.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`Collapse threads pane`,title:`Collapse threads pane (full-width thread view)`,className:`w-7 h-7 rounded border border-line text-fg-muted hover:text-accent hover:border-accent flex items-center justify-center text-sm font-semibold leading-none transition-colors`,children:`«`})]})]}),(0,G.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let n=l.trim();n&&a.mutate({name:n},{onSuccess:e=>{u(``),t({thread:e.thread.id})}})},className:`px-3 pt-2 pb-3 border-b border-line flex gap-2`,children:[(0,G.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`New thread name`,className:`flex-1 px-2 py-1 bg-bg-elevated border border-line rounded text-sm`}),(0,G.jsx)(`button`,{type:`submit`,disabled:a.isPending||!l.trim(),className:`px-2 py-1 rounded bg-accent text-bg text-xs font-medium disabled:opacity-50`,title:`Create a new empty thread with this name; add sessions to it afterwards.`,children:`Create`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted`,children:`Loading threads…`}),s.length===0&&!n.isLoading&&(0,G.jsx)(`div`,{className:`px-4 py-6 text-xs text-fg-muted italic`,children:`No threads yet. A thread is one unit of work spanning many sessions (planning session plus its children). Create one with the form above, then add sessions to it from any session's transcript header.`}),f.map(([e,n])=>{let i=!A.has(e),a=e===d?null:e,s=R.filter(e=>e.project_scope===a&&e.parent_folder_id===null),c=n.filter(e=>!e.folder_id),l=ie&&`project`in ie&&ie.project===e;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:$(`flex items-center border-t border-line first:border-t-0`,l&&`bg-accent/15 ring-1 ring-accent/40`),onDragOver:t=>{H?.kind===`thread`&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,ae({project:e,into:!0}))},onDragLeave:()=>{l&&ae(null)},onDrop:e=>{if(H?.kind!==`thread`)return;e.preventDefault();let t=H.id;se(),o.mutate({id:t,patch:{folder_id:null}},{onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>M(e),className:`flex-1 flex items-center gap-2 px-3 py-2 text-sm font-semibold uppercase tracking-wider text-fg-muted hover:bg-bg-hover`,"aria-expanded":!i,title:`${n.length} thread${n.length===1?``:`s`} in ${e}`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 text-center text-fg-muted`,children:i?`▶`:`▼`}),(0,G.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-fg-muted`,children:n.length})]}),e!==d&&P.has(e)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{let t=P.get(e);t!==void 0&&N({id:t,name:e})},className:`px-2.5 py-1.5 text-xl leading-none hover:bg-bg-hover rounded`,style:{color:`#f97316`},title:`Sync currently active Claude sessions in ${e} into a thread (Captain Code Pattern)`,"aria-label":`Sync active sessions for ${e}`,children:`⟳`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{B(e),i&&M(e)},className:`px-2.5 py-1 text-2xl leading-none text-fg-muted hover:text-accent hover:bg-bg-hover rounded`,title:`Create a new subfolder inside ${e}`,"aria-label":`Add subfolder to ${e}`,children:`+`})]}),z===e&&(0,G.jsx)(Tp,{project:e,onCommit:t=>{B(null);let n=t.trim();n&&I.mutate({name:n,projectScope:e===d?null:e,parentFolderId:null},{onError:e=>Q({message:`Subfolder create failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},onCancel:()=>B(null)}),!i&&(0,G.jsxs)(G.Fragment,{children:[s.map(e=>(0,G.jsx)(wp,{folder:e,depth:1,allSubfolders:R,threadsInProject:n,threadId:r,renamingThreadId:h,onSelectThread:e=>t({thread:e}),onThreadContextMenu:(e,t,n)=>m({threadId:e.id,name:e.name,x:t,y:n}),onCommitRename:(e,t)=>{g(null),t.trim()&&t.trim()!==e.name&&le(e.id,t)},onCancelRename:()=>g(null),onDeleteSubfolder:e=>ne(e),confirmingDeleteId:V,onConfirmDelete:e=>{ne(null),L.mutate(e,{onError:e=>Q({message:`Delete failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})})},onCancelDelete:()=>ne(null),drag:H,setDrag:re,dropHint:ie,setDropHint:ae,onReorderDrop:ce,onFileThreadIntoFolder:U},e.id)),c.map(e=>(0,G.jsx)(gp,{thread:e,active:e.id===r,renaming:h===e.id,onSelect:()=>t({thread:e.id}),onContextMenu:(t,n)=>m({threadId:e.id,name:e.name,x:t,y:n}),onCommitRename:t=>{g(null),t.trim()&&t.trim()!==e.name&&le(e.id,t)},onCancelRename:()=>g(null),onDragStart:()=>re({kind:`thread`,id:e.id,project:e.project??null}),onDragEnd:se},e.id))]})]},e)})]})]}),!x&&(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize threads list`,title:`Drag to resize · double-click to reset`,onPointerDown:T,onPointerMove:E,onPointerUp:D,onDoubleClick:O,className:`w-1 shrink-0 cursor-col-resize bg-line hover:bg-accent transition-colors`}),(0,G.jsx)(`section`,{className:`flex-1 min-w-0 overflow-y-auto`,children:c?(0,G.jsx)(vp,{thread:c,onPatch:o.mutate}):r&&i.isLoading?(0,G.jsx)(`div`,{className:`p-10 text-sm text-fg-muted`,children:`Loading thread…`}):r&&!i.isLoading?(0,G.jsxs)(`div`,{className:`p-10 text-sm text-fg-muted max-w-2xl space-y-3`,children:[(0,G.jsx)(`div`,{className:`text-fg font-semibold`,children:`That thread isn’t here.`}),(0,G.jsx)(`div`,{children:`It may have been archived or deleted. Pick another from the left, or`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({thread:null}),className:`text-accent hover:underline`,children:`show the threads overview →`})]}):(0,G.jsxs)(`div`,{className:`p-10 max-w-4xl`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.2em] text-fg-muted mb-3`,children:`Threads / The Captain Code Pattern`}),(0,G.jsxs)(`h1`,{className:`text-4xl font-semibold text-fg leading-[1.05] mb-3 tracking-tight`,children:[`Three steps. One thread.`,(0,G.jsx)(`br`,{}),(0,G.jsx)(`span`,{style:{color:`#f97316`},children:`Every session you have open, in one place.`})]}),(0,G.jsxs)(`p`,{className:`text-base text-fg-muted leading-relaxed max-w-2xl mb-10`,children:[`You probably have 5 to 50 Claude chats running across your IDE windows. Sync turns that mess into a tree you can hand back to Claude. Below is what happens, in order, when you click `,(0,G.jsx)(ep,{}),` on any repo.`]}),(0,G.jsx)(tp,{}),(0,G.jsxs)(`div`,{className:`mt-12 grid grid-cols-3 gap-px bg-line border border-line rounded-lg overflow-hidden`,children:[(0,G.jsx)(op,{kicker:`Scope`,value:`Per-repo`,detail:`Always cwd-bound. Sync from one repo never touches another.`}),(0,G.jsx)(op,{kicker:`Re-runs`,value:`Same thread`,detail:`No daily rollover. The date in the name is the creation date, not a key.`}),(0,G.jsx)(op,{kicker:`Manual edges`,value:`Preserved`,detail:`Anything you wired by hand survives every sync. Only auto edges recompute.`})]}),(0,G.jsxs)(`div`,{className:`mt-10 flex items-center gap-4 text-xs text-fg-muted`,children:[(0,G.jsx)(`code`,{className:`px-2 py-1 rounded bg-bg-elevated border border-line text-fg`,children:`recall threads sync`}),(0,G.jsx)(`span`,{children:`does the same thing as the button. Add`}),(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-bg-elevated border border-line text-fg`,children:`--preflight`}),(0,G.jsx)(`span`,{children:`to dry-run.`})]})]})}),p&&(()=>{let e=s.find(e=>e.id===p.threadId),t=e?.project??null,n=R.filter(e=>e.project_scope===t||e.project_scope===null);return(0,G.jsx)(bp,{x:p.x,y:p.y,threadName:p.name,movableFolders:n,currentFolderId:e?.folder_id??null,onMoveToFolder:e=>{o.mutate({id:p.threadId,patch:{folder_id:e}},{onSuccess:()=>{let t=e?R.find(t=>t.id===e)?.name??`subfolder`:`project root`;Q({message:`Moved "${p.name}" to ${t}`,tone:`success`})},onError:e=>Q({message:`Move failed: ${e instanceof Error?e.message:`unknown error`}`,tone:`error`})})},onRename:()=>{g(p.threadId),m(null)},onClose:()=>m(null)})})(),ee&&(0,G.jsx)(lp,{projectId:ee.id,projectName:ee.name,onClose:()=>N(null)})]})}function gp({thread:e,active:t,renaming:n,onSelect:r,onContextMenu:i,onCommitRename:a,onCancelRename:o,onDragStart:s,onDragEnd:c}){let[l,u]=(0,W.useState)(e.name);return(0,W.useEffect)(()=>{n&&u(e.name)},[n,e.name]),n?(0,G.jsxs)(`div`,{className:$(`w-full text-left px-3 py-2 border-b border-line/50`,t&&`bg-accent/10`),children:[(0,G.jsx)(`input`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),a(l)):e.key===`Escape`&&(e.preventDefault(),o())},onBlur:()=>a(l),"aria-label":`Rename thread`,className:`w-full px-2 py-1 bg-bg-elevated border border-accent rounded text-sm font-medium outline-none`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:`Enter to save, Esc to cancel`})]}):(0,G.jsxs)(`button`,{type:`button`,onClick:r,draggable:!!s,onDragStart:t=>{s&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-recall-thread`,e.id),s())},onDragEnd:c,onContextMenu:e=>{e.preventDefault(),i(e.clientX,e.clientY)},className:$(`w-full text-left px-3 py-2 border-b border-line/50 hover:bg-bg-hover`,t&&`bg-accent/10`),title:`Open the "${e.name}" thread detail view with its session graph (right-click to rename).`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-medium truncate`,title:e.name,children:e.name}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg-muted shrink-0 tabular-nums`,title:`${e.session_count} session${e.session_count===1?``:`s`} currently linked into this thread.`,children:e.session_count})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,G.jsx)(_p,{thread:e}),(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-muted truncate flex-1 min-w-0`,children:[e.origin_count,` origin`,e.origin_count===1?``:`s`,` ·`,` `,e.closed_at?`closed`:`open`,e.summary?` · ${e.summary}`:``]})]})]})}function _p({thread:e}){return!e.project&&e.session_count===0?(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-fg-muted/70 border border-line`,title:`No sessions yet — add a session from any session header to give this thread a project origin.`,children:`empty`}):e.project_count>1?(0,G.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-accent border border-accent/30 cursor-help shrink-0`,title:`Cross-project thread: spans ${e.project_count} projects (dominant: ${e.project??`unknown`}).`,children:[e.project_count,` repos`]}):e.project?(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-bg-elevated text-fg-muted border border-line truncate max-w-[120px] shrink-0`,title:`All sessions in this thread are from project "${e.project}".`,children:e.project}):null}function vp({thread:e,onPatch:t}){let[,n]=Nn(),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(e.name);(0,W.useEffect)(()=>{r||o(e.name)},[e.name,r]);let s=()=>{let n=a.trim();if(i(!1),!n||n===e.name){o(e.name);return}t({id:e.id,patch:{name:n}}),Q({message:`Renamed thread to "${n}"`,tone:`success`})},c=()=>{i(!1),o(e.name)};return(0,G.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,G.jsxs)(`header`,{className:`space-y-1 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r?(0,G.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},onBlur:s,"aria-label":`Rename thread`,className:`text-2xl font-semibold bg-bg-elevated border border-accent rounded px-2 py-0.5 outline-none flex-1`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold cursor-text`,onDoubleClick:()=>i(!0),title:`Double-click (or use the pencil button) to rename this thread.`,children:e.name}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-xs text-fg-muted hover:text-accent px-1.5 py-0.5 rounded border border-transparent hover:border-line`,title:`Rename this thread`,"aria-label":`Rename thread`,children:`✎`})]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.session_count,` session`,e.session_count===1?``:`s`,` ·`,` `,e.closed_at?`closed`:`open`]})]}),e.summary&&(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.summary}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[e.closed_at?(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,patch:{reopen:!0}}),className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Mark this thread as active again so new sessions can be added.`,children:`Reopen`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,patch:{close:!0}}),className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Mark this thread as finished; sessions stay linked and you can reopen it at any time.`,children:`Close thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Archive "${e.name}"? You can still find it with Show archived.`)&&(t({id:e.id,patch:{archive:!0}}),n({thread:null}))},className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover`,title:`Hide this thread from the main list; it stays in the database and reappears under Show archived.`,children:`Archive`}),(0,G.jsx)(xp,{thread:e})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2 max-w-3xl`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-fg-muted`,children:`Sessions in this thread`}),(0,G.jsx)(yp,{threadId:e.id,existingIds:new Set(e.edges.map(e=>e.session_id))})]}),e.edges.length===0?(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted p-3 border border-line rounded max-w-3xl space-y-2`,children:[(0,G.jsx)(`div`,{className:`italic`,children:`No sessions in this thread yet. Two ways to add:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-5 space-y-1 not-italic`,children:[(0,G.jsxs)(`li`,{children:[`Use the `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ Add session`}),` `,`button above to search and link any session.`]}),(0,G.jsxs)(`li`,{children:[`Open any session from the sidebar and click`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ Add to thread`}),` in its transcript header.`]})]})]}):(0,G.jsx)(`div`,{"data-share-capture":`thread-graph`,"data-share-capture-thread-id":e.id,children:(0,G.jsx)(Gf,{thread:e})})]}),(0,G.jsxs)(`section`,{className:`rounded border border-line bg-bg-elevated p-3 text-xs text-fg-muted space-y-1 max-w-3xl`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg text-sm`,children:`How Threads work`}),(0,G.jsx)(`p`,{children:`A thread is a DAG (not a tree). It can have multiple origins. A session can belong to multiple threads. Manual edges are always authoritative. Auto-detected edges (v0.7 Pro) will show up with a confidence score and will always be undoable.`}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Tip:`}),` pipe a whole thread back into Claude Code with `,(0,G.jsxs)(`span`,{className:`font-mono`,children:[`recall context thread:`,e.id.slice(0,8)]}),`(CLI command landing in v0.15a.2).`]})]})]})}function yp({threadId:e,existingIds:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(``),o=bu(),s=q({queryKey:[`sessions`,{limit:500}],queryFn:()=>Z.sessions({limit:500}),enabled:n,staleTime:3e4}),c=s.data?.items??[],l=(0,W.useMemo)(()=>{let e=i.trim().toLowerCase(),n=c.filter(e=>!t.has(e.id));return e?n.filter(t=>[t.alias??``,t.first_user_message??``,t.project??``,t.id].join(` `).toLowerCase().includes(e)).slice(0,10):n.slice(0,10)},[c,t,i]);return n?(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,G.jsx)(`input`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:`search sessions by alias, project, or first message`,className:`text-xs bg-bg-elevated border border-line rounded px-2 py-1 w-80`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{r(!1),a(``)},className:`text-xs text-fg-muted hover:text-fg`,title:`Close the search without linking any session.`,children:`cancel`})]}),(0,G.jsxs)(`div`,{className:`absolute right-0 top-8 z-20 w-96 max-h-80 overflow-y-auto bg-bg border border-line rounded shadow-lg`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`Loading sessions...`}),l.length===0&&!s.isLoading&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted italic`,children:i?`no matches`:`all sessions are already in this thread`}),l.map(t=>{let n=t.alias||t.first_user_message?.split(`
|
|
649
|
+
`)[0].slice(0,80)||t.id.slice(0,8);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{o.mutate({threadId:e,sessionId:t.id},{onSuccess:()=>a(``)})},className:`w-full text-left px-3 py-2 border-b border-line/40 hover:bg-accent/10 text-xs`,title:`Link ${t.id}`,children:[(0,G.jsx)(`div`,{className:`font-medium truncate`,children:n}),(0,G.jsxs)(`div`,{className:`text-fg-muted truncate`,children:[t.project||`—`,` · `,t.id.slice(0,8)]})]},t.id)})]})]}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`text-xs px-2 py-1 rounded bg-accent text-bg font-medium`,title:`Search and link any session into this thread (you can also start from a session's transcript header with + Add to thread).`,children:`+ Add session`})}function bp({x:e,y:t,threadName:n,onRename:r,onClose:i,movableFolders:a,currentFolderId:o,onMoveToFolder:s}){let c=(0,W.useRef)(null),[l,u]=(0,W.useState)(`menu`);(0,W.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&i()},t=e=>{e.key===`Escape`&&(l===`menu`?i():u(`menu`))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i,l]);let d=l===`move`?220:110;return(0,G.jsxs)(`div`,{ref:c,role:`menu`,"aria-label":`thread actions`,className:`fixed z-50 bg-bg-elevated border border-line rounded-lg shadow-xl py-1 text-xs`,style:{left:Math.min(e,window.innerWidth-240-8),top:Math.min(t,window.innerHeight-d-8),width:240},children:[(0,G.jsx)(`div`,{className:`px-3 pt-1 pb-1 text-[10px] uppercase tracking-wider text-fg-muted truncate`,children:n}),(0,G.jsx)(`div`,{className:`border-t border-line my-1`}),l===`menu`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(),i()},className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Rename thread`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`inline edit, Enter to save`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>u(`move`),className:`block w-full text-left px-3 py-1.5 hover:bg-bg-hover`,children:[(0,G.jsx)(`div`,{className:`text-fg`,children:`Move to subfolder…`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:`file under a subfolder, or move back to the project root`})]})]}),l===`move`&&(0,G.jsxs)(`div`,{className:`max-h-56 overflow-auto`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(null),i()},className:$(`block w-full text-left px-3 py-1.5 hover:bg-bg-hover italic`,o===null?`text-fg`:`text-fg-muted`),children:[`(project root)`,o===null&&` ✓`]}),a.length===0&&(0,G.jsx)(`div`,{className:`px-3 py-2 text-[10px] text-fg-muted italic`,children:`No subfolders for this project yet. Create one with the + button on the project header.`}),a.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.id),i()},className:$(`block w-full text-left px-3 py-1.5 hover:bg-bg-hover truncate`,o===e.id?`text-fg`:`text-fg-muted`),children:[`📁 `,e.name,o===e.id&&` ✓`]},e.id))]})]})}function xp({thread:e}){let{state:t,start:n,cancel:r,reset:i}=Nf(e.id),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{if(t.status!==`done`||!t.summary)return;let{generated:e,skipped:n,failed:r}=t.summary;r.length>0?Q({message:`Generated ${e.length}, skipped ${n.length}, ${r.length} failed`,tone:`error`}):Q({message:`Generated ${e.length} title${e.length===1?``:`s`}, skipped ${n.length}`,tone:`success`})},[t.status,t.summary]),t.status===`running`||t.status===`starting`||t.status===`cancelling`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2 px-2 py-1 text-xs rounded border border-accent bg-bg-elevated`,children:[(0,G.jsx)(`span`,{"aria-hidden":!0,className:`inline-block animate-spin`,children:`⋮`}),(0,G.jsx)(`span`,{children:t.status===`cancelling`?`Cancelling...`:`Titling ${t.current} of ${t.total||`?`}...`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-fg-muted hover:text-accent underline`,title:`Stop the bulk titler. Already-generated titles stay; the rest are skipped.`,children:`Cancel`})]}):(0,G.jsxs)(`span`,{className:`relative`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(t.status===`running`||t.status===`starting`)){c(!0);try{(await Z.threadTitlesPreflight(e.id)).alreadyTitled===0?await n(!1):o(!0)}catch(e){Q({message:`Could not prepare bulk titler: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{c(!1)}}},disabled:s,className:`px-2 py-1 text-xs rounded border border-line hover:bg-bg-hover disabled:opacity-50`,title:`Generate a coherent title for every session in this thread, walking the DAG so children inherit the parent's naming pattern.`,children:s?`Checking...`:`🪄 Title whole thread`}),a&&(0,G.jsx)(Sp,{thread:e,onPick:e=>{o(!1),n(e)},onClose:()=>o(!1)}),t.status===`done`&&t.summary&&t.summary.failed.length>0&&(0,G.jsx)(Cp,{failures:t.summary.failed,onDismiss:i})]})}function Sp({thread:e,onPick:t,onClose:n}){let r=(0,W.useRef)(null);return(0,W.useEffect)(()=>{function e(e){r.current&&!r.current.contains(e.target)&&n()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),(0,G.jsxs)(`div`,{ref:r,role:`dialog`,"aria-label":`Bulk title confirmation`,className:`absolute right-0 top-full mt-1 z-50 w-72 rounded border border-line bg-bg-elevated p-3 shadow-lg text-xs space-y-2`,children:[(0,G.jsxs)(`p`,{className:`text-fg`,children:[`Some sessions in “`,e.name,`” already have agent titles. Pick what to do:`]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!1),className:`px-2 py-1 rounded border border-line hover:bg-bg-hover text-left`,children:[`Skip already-titled`,(0,G.jsx)(`span`,{className:`block text-[10px] text-fg-muted`,children:`Only title the untitled sessions. Recommended.`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`px-2 py-1 rounded border border-line hover:bg-bg-hover text-left`,children:[`Regenerate all`,(0,G.jsx)(`span`,{className:`block text-[10px] text-fg-muted`,children:`Replace every title. Old titles stay in auto_title_history.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`px-2 py-1 rounded border border-transparent hover:bg-bg-hover text-fg-muted text-left`,children:`Cancel`})]})]})}function Cp({failures:e,onDismiss:t}){return(0,G.jsxs)(`div`,{role:`alert`,className:`absolute right-0 top-full mt-1 z-50 w-80 rounded border border-line bg-bg-elevated p-3 shadow-lg text-xs space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Some sessions failed to title`}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-fg-muted hover:text-accent`,"aria-label":`Dismiss failure panel`,children:`Dismiss`})]}),(0,G.jsx)(`ul`,{className:`max-h-40 overflow-auto space-y-1`,children:e.map(e=>(0,G.jsxs)(`li`,{className:`font-mono text-[10px] text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`text-fg`,children:e.sessionId.slice(0,8)}),`: `,e.error]},e.sessionId))})]})}function wp(e){let{folder:t,depth:n,allSubfolders:r,threadsInProject:i,drag:a,dropHint:o,setDropHint:s}=e,[c,l]=(0,W.useState)(!0),u=r.filter(e=>e.parent_folder_id===t.id),d=i.filter(e=>e.folder_id===t.id),f=12+n*14,p=e.confirmingDeleteId===t.id,m=a?.kind===`folder`&&a.id!==t.id&&a.parentFolderId===t.parent_folder_id&&a.projectScope===t.project_scope,h=a?.kind===`thread`&&(t.project_scope===null||a.project===t.project_scope),g=m||h,_=o&&`folderId`in o&&o.folderId===t.id?o.pos:null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:$(`flex items-center hover:bg-bg-hover`,m&&_===`before`&&`border-t-2 border-accent`,m&&_===`after`&&`border-b-2 border-accent`,h&&_!==null&&`bg-accent/15 ring-1 ring-accent/40`),draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`application/x-recall-folder`,t.id),e.setDrag({kind:`folder`,id:t.id,parentFolderId:t.parent_folder_id,projectScope:t.project_scope})},onDragEnd:()=>{e.setDrag(null),e.setDropHint(null)},onDragOver:e=>{if(g)if(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m){let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2;s({folderId:t.id,pos:r?`before`:`after`})}else s({folderId:t.id,pos:`after`})},onDragLeave:()=>{_!==null&&s(null)},onDrop:n=>{if(g)if(n.preventDefault(),m){let r=n.currentTarget.getBoundingClientRect(),i=n.clientY<r.top+r.height/2;e.onReorderDrop(t,i?`before`:`after`)}else h&&e.onFileThreadIntoFolder(t)},children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex-1 flex items-center gap-2 py-1 text-xs text-fg-muted text-left truncate`,style:{paddingLeft:`${f}px`,paddingRight:`8px`},title:`Subfolder "${t.name}" — drag to reorder, drop a thread here to file it.`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 text-center`,children:c?`▶`:`▼`}),(0,G.jsxs)(`span`,{className:`flex-1 truncate`,children:[`📁 `,t.name]}),(0,G.jsx)(`span`,{className:`text-fg-muted/60`,children:d.length})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>e.onDeleteSubfolder(t.id),className:`px-2 py-1 text-xs text-fg-muted hover:text-role-user`,title:`Delete subfolder (threads inside pop back to project root)`,"aria-label":`Delete subfolder ${t.name}`,children:`×`})]}),p&&(0,G.jsxs)(`div`,{className:`mx-3 my-1 rounded border border-role-user/40 bg-role-user/5 p-2 text-[11px]`,style:{marginLeft:`${f}px`},children:[(0,G.jsxs)(`div`,{className:`text-fg mb-1.5`,children:[`Delete `,(0,G.jsx)(`span`,{className:`font-semibold`,children:t.name}),`?`]}),(0,G.jsx)(`div`,{className:`text-fg-muted mb-2`,children:`Threads inside pop back to the project root; nested subfolders are deleted too.`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:e.onCancelDelete,className:`px-2 py-0.5 text-fg-muted hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>e.onConfirmDelete(t.id),className:`px-2 py-0.5 rounded bg-role-user/80 text-bg hover:bg-role-user`,autoFocus:!0,children:`Delete`})]})]}),!c&&(0,G.jsxs)(G.Fragment,{children:[u.map(t=>(0,G.jsx)(wp,{folder:t,depth:n+1,allSubfolders:r,threadsInProject:i,threadId:e.threadId,renamingThreadId:e.renamingThreadId,onSelectThread:e.onSelectThread,onThreadContextMenu:e.onThreadContextMenu,onCommitRename:e.onCommitRename,onCancelRename:e.onCancelRename,onDeleteSubfolder:e.onDeleteSubfolder,confirmingDeleteId:e.confirmingDeleteId,onConfirmDelete:e.onConfirmDelete,onCancelDelete:e.onCancelDelete,drag:e.drag,setDrag:e.setDrag,dropHint:e.dropHint,setDropHint:e.setDropHint,onReorderDrop:e.onReorderDrop,onFileThreadIntoFolder:e.onFileThreadIntoFolder},t.id)),d.map(t=>(0,G.jsx)(gp,{thread:t,active:t.id===e.threadId,renaming:e.renamingThreadId===t.id,onSelect:()=>e.onSelectThread(t.id),onContextMenu:(n,r)=>e.onThreadContextMenu(t,n,r),onCommitRename:n=>e.onCommitRename(t,n),onCancelRename:e.onCancelRename,onDragStart:()=>e.setDrag({kind:`thread`,id:t.id,project:t.project??null}),onDragEnd:()=>{e.setDrag(null),e.setDropHint(null)}},t.id))]})]})}function Tp({project:e,onCommit:t,onCancel:n}){let[r,i]=(0,W.useState)(``);return(0,G.jsxs)(`div`,{className:`px-3 py-2 border-t border-line bg-bg-elevated`,children:[(0,G.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),t(r)):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:()=>t(r),placeholder:`Subfolder name in ${e}`,"aria-label":`New subfolder in ${e}`,className:`w-full px-2 py-1 bg-bg border border-accent rounded text-sm outline-none`}),(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:`Enter to create · Esc to cancel`})]})}var Ep=class extends Map{constructor(e,t=Ap){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Dp(this,e))}has(e){return super.has(Dp(this,e))}set(e,t){return super.set(Op(this,e),t)}delete(e){return super.delete(kp(this,e))}};function Dp({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Op({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function kp({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Ap(e){return typeof e==`object`&&e?e.valueOf():e}function jp(e){return e}function Mp(e,...t){return Np(e,jp,jp,t)}function Np(e,t,n,r){return(function e(i,a){if(a>=r.length)return n(i);let o=new Ep,s=r[a++],c=-1;for(let e of i){let t=s(e,++c,i),n=o.get(t);n?n.push(e):o.set(t,[e])}for(let[t,n]of o)o.set(t,e(n,a));return t(o)})(e,0)}var Pp={value:()=>{}};function Fp(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Ip(n)}function Ip(e){this._=e}function Lp(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Ip.prototype=Fp.prototype={constructor:Ip,on:function(e,t){var n=this._,r=Lp(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Rp(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=zp(n[i],e.name,t);else if(t==null)for(i in n)n[i]=zp(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ip(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Rp(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function zp(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Pp,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bp={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Vp(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Bp.hasOwnProperty(t)?{space:Bp[t],local:e}:e}function Hp(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Up(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Wp(e){var t=Vp(e);return(t.local?Up:Hp)(t)}function Gp(){}function Kp(e){return e==null?Gp:function(){return this.querySelector(e)}}function qp(e){typeof e!=`function`&&(e=Kp(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Fh(r,this._parents)}function Jp(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Yp(){return[]}function Xp(e){return e==null?Yp:function(){return this.querySelectorAll(e)}}function Zp(e){return function(){return Jp(e.apply(this,arguments))}}function Qp(e){e=typeof e==`function`?Zp(e):Xp(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Fh(r,i)}function $p(e){return function(){return this.matches(e)}}function em(e){return function(t){return t.matches(e)}}var tm=Array.prototype.find;function nm(e){return function(){return tm.call(this.children,e)}}function rm(){return this.firstElementChild}function im(e){return this.select(e==null?rm:nm(typeof e==`function`?e:em(e)))}var am=Array.prototype.filter;function om(){return Array.from(this.children)}function sm(e){return function(){return am.call(this.children,e)}}function cm(e){return this.selectAll(e==null?om:sm(typeof e==`function`?e:em(e)))}function lm(e){typeof e!=`function`&&(e=$p(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Fh(r,this._parents)}function um(e){return Array(e.length)}function dm(){return new Fh(this._enter||this._groups.map(um),this._parents)}function fm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}fm.prototype={constructor:fm,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function pm(e){return function(){return e}}function mm(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new fm(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function hm(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new fm(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function gm(e){return e.__data__}function _m(e,t){if(!arguments.length)return Array.from(this,gm);var n=t?hm:mm,r=this._parents,i=this._groups;typeof e!=`function`&&(e=pm(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=vm(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Fh(o,r),o._enter=s,o._exit=c,o}function vm(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ym(){return new Fh(this._exit||this._groups.map(um),this._parents)}function bm(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function xm(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Fh(s,this._parents)}function Sm(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Cm(e){e||=wm;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Fh(i,this._parents).order()}function wm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Tm(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Em(){return Array.from(this)}function Dm(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Om(){let e=0;for(let t of this)++e;return e}function km(){return!this.node()}function Am(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function jm(e){return function(){this.removeAttribute(e)}}function Mm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Nm(e,t){return function(){this.setAttribute(e,t)}}function Pm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Fm(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Im(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Lm(e,t){var n=Vp(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Mm:jm:typeof t==`function`?n.local?Im:Fm:n.local?Pm:Nm)(n,t))}function Rm(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function zm(e){return function(){this.style.removeProperty(e)}}function Bm(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Vm(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Hm(e,t,n){return arguments.length>1?this.each((t==null?zm:typeof t==`function`?Vm:Bm)(e,t,n??``)):Um(this.node(),e)}function Um(e,t){return e.style.getPropertyValue(t)||Rm(e).getComputedStyle(e,null).getPropertyValue(t)}function Wm(e){return function(){delete this[e]}}function Gm(e,t){return function(){this[e]=t}}function Km(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function qm(e,t){return arguments.length>1?this.each((t==null?Wm:typeof t==`function`?Km:Gm)(e,t)):this.node()[e]}function Jm(e){return e.trim().split(/^|\s+/)}function Ym(e){return e.classList||new Xm(e)}function Xm(e){this._node=e,this._names=Jm(e.getAttribute(`class`)||``)}Xm.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Zm(e,t){for(var n=Ym(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Qm(e,t){for(var n=Ym(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function $m(e){return function(){Zm(this,e)}}function eh(e){return function(){Qm(this,e)}}function th(e,t){return function(){(t.apply(this,arguments)?Zm:Qm)(this,e)}}function nh(e,t){var n=Jm(e+``);if(arguments.length<2){for(var r=Ym(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?th:t?$m:eh)(n,t))}function rh(){this.textContent=``}function ih(e){return function(){this.textContent=e}}function ah(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function oh(e){return arguments.length?this.each(e==null?rh:(typeof e==`function`?ah:ih)(e)):this.node().textContent}function sh(){this.innerHTML=``}function ch(e){return function(){this.innerHTML=e}}function lh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function uh(e){return arguments.length?this.each(e==null?sh:(typeof e==`function`?lh:ch)(e)):this.node().innerHTML}function dh(){this.nextSibling&&this.parentNode.appendChild(this)}function fh(){return this.each(dh)}function ph(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mh(){return this.each(ph)}function hh(e){var t=typeof e==`function`?e:Wp(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function gh(){return null}function _h(e,t){var n=typeof e==`function`?e:Wp(e),r=t==null?gh:typeof t==`function`?t:Kp(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function vh(){var e=this.parentNode;e&&e.removeChild(this)}function yh(){return this.each(vh)}function bh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sh(e){return this.select(e?xh:bh)}function Ch(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function wh(e){return function(t){e.call(this,t,this.__data__)}}function Th(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Eh(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Dh(e,t,n){return function(){var r=this.__on,i,a=wh(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Oh(e,t,n){var r=Th(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Dh:Eh,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function kh(e,t,n){var r=Rm(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Ah(e,t){return function(){return kh(this,e,t)}}function jh(e,t){return function(){return kh(this,e,t.apply(this,arguments))}}function Mh(e,t){return this.each((typeof t==`function`?jh:Ah)(e,t))}function*Nh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Ph=[null];function Fh(e,t){this._groups=e,this._parents=t}function Ih(){return new Fh([[document.documentElement]],Ph)}function Lh(){return this}Fh.prototype=Ih.prototype={constructor:Fh,select:qp,selectAll:Qp,selectChild:im,selectChildren:cm,filter:lm,data:_m,enter:dm,exit:ym,join:bm,merge:xm,selection:Lh,order:Sm,sort:Cm,call:Tm,nodes:Em,node:Dm,size:Om,empty:km,each:Am,attr:Lm,style:Hm,property:qm,classed:nh,text:oh,html:uh,raise:fh,lower:mh,append:hh,insert:_h,remove:yh,clone:Sh,datum:Ch,on:Oh,dispatch:Mh,[Symbol.iterator]:Nh};function Rh(e){return typeof e==`string`?new Fh([[document.querySelector(e)]],[document.documentElement]):new Fh([[e]],Ph)}function zh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Bh(e,t){if(e=zh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Vh={capture:!0,passive:!1};function Hh(e){e.preventDefault(),e.stopImmediatePropagation()}function Uh(e){var t=e.document.documentElement,n=Rh(e).on(`dragstart.drag`,Hh,Vh);`onselectstart`in t?n.on(`selectstart.drag`,Hh,Vh):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function Wh(e,t){var n=e.document.documentElement,r=Rh(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,Hh,Vh),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Gh(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Kh(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function qh(){}var Jh=.7,Yh=1/Jh,Xh=`\\s*([+-]?\\d+)\\s*`,Zh=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Qh=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,$h=/^#([0-9a-f]{3,8})$/,eg=RegExp(`^rgb\\(${Xh},${Xh},${Xh}\\)$`),tg=RegExp(`^rgb\\(${Qh},${Qh},${Qh}\\)$`),ng=RegExp(`^rgba\\(${Xh},${Xh},${Xh},${Zh}\\)$`),rg=RegExp(`^rgba\\(${Qh},${Qh},${Qh},${Zh}\\)$`),ig=RegExp(`^hsl\\(${Zh},${Qh},${Qh}\\)$`),ag=RegExp(`^hsla\\(${Zh},${Qh},${Qh},${Zh}\\)$`),og={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Gh(qh,dg,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sg,formatHex:sg,formatHex8:cg,formatHsl:lg,formatRgb:ug,toString:ug});function sg(){return this.rgb().formatHex()}function cg(){return this.rgb().formatHex8()}function lg(){return wg(this).formatHsl()}function ug(){return this.rgb().formatRgb()}function dg(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=$h.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?fg(t):n===3?new gg(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?pg(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?pg(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=eg.exec(e))?new gg(t[1],t[2],t[3],1):(t=tg.exec(e))?new gg(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ng.exec(e))?pg(t[1],t[2],t[3],t[4]):(t=rg.exec(e))?pg(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ig.exec(e))?Cg(t[1],t[2]/100,t[3]/100,1):(t=ag.exec(e))?Cg(t[1],t[2]/100,t[3]/100,t[4]):og.hasOwnProperty(e)?fg(og[e]):e===`transparent`?new gg(NaN,NaN,NaN,0):null}function fg(e){return new gg(e>>16&255,e>>8&255,e&255,1)}function pg(e,t,n,r){return r<=0&&(e=t=n=NaN),new gg(e,t,n,r)}function mg(e){return e instanceof qh||(e=dg(e)),e?(e=e.rgb(),new gg(e.r,e.g,e.b,e.opacity)):new gg}function hg(e,t,n,r){return arguments.length===1?mg(e):new gg(e,t,n,r??1)}function gg(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Gh(gg,hg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new gg(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new gg(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new gg(xg(this.r),xg(this.g),xg(this.b),bg(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_g,formatHex:_g,formatHex8:vg,formatRgb:yg,toString:yg}));function _g(){return`#${Sg(this.r)}${Sg(this.g)}${Sg(this.b)}`}function vg(){return`#${Sg(this.r)}${Sg(this.g)}${Sg(this.b)}${Sg((isNaN(this.opacity)?1:this.opacity)*255)}`}function yg(){let e=bg(this.opacity);return`${e===1?`rgb(`:`rgba(`}${xg(this.r)}, ${xg(this.g)}, ${xg(this.b)}${e===1?`)`:`, ${e})`}`}function bg(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xg(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Sg(e){return e=xg(e),(e<16?`0`:``)+e.toString(16)}function Cg(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Eg(e,t,n,r)}function wg(e){if(e instanceof Eg)return new Eg(e.h,e.s,e.l,e.opacity);if(e instanceof qh||(e=dg(e)),!e)return new Eg;if(e instanceof Eg)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Eg(o,s,c,e.opacity)}function Tg(e,t,n,r){return arguments.length===1?wg(e):new Eg(e,t,n,r??1)}function Eg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gh(Eg,Tg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new Eg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new Eg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new gg(kg(e>=240?e-240:e+120,i,r),kg(e,i,r),kg(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Eg(Dg(this.h),Og(this.s),Og(this.l),bg(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=bg(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Dg(this.h)}, ${Og(this.s)*100}%, ${Og(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Dg(e){return e=(e||0)%360,e<0?e+360:e}function Og(e){return Math.max(0,Math.min(1,e||0))}function kg(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Ag=Math.PI/180,jg=180/Math.PI,Mg=-.14861,Ng=1.78277,Pg=-.29227,Fg=-.90649,Ig=1.97294,Lg=Ig*Fg,Rg=Ig*Ng,zg=Ng*Pg-Fg*Mg;function Bg(e){if(e instanceof Hg)return new Hg(e.h,e.s,e.l,e.opacity);e instanceof gg||(e=mg(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(zg*r+Lg*t-Rg*n)/(zg+Lg-Rg),a=r-i,o=(Ig*(n-i)-Pg*a)/Fg,s=Math.sqrt(o*o+a*a)/(Ig*i*(1-i)),c=s?Math.atan2(o,a)*jg-120:NaN;return new Hg(c<0?c+360:c,s,i,e.opacity)}function Vg(e,t,n,r){return arguments.length===1?Bg(e):new Hg(e,t,n,r??1)}function Hg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gh(Hg,Vg,Kh(qh,{brighter(e){return e=e==null?Yh:Yh**+e,new Hg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jh:Jh**+e,new Hg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*Ag,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new gg(255*(t+n*(Mg*r+Ng*i)),255*(t+n*(Pg*r+Fg*i)),255*(t+Ig*r*n),this.opacity)}}));var Ug=e=>()=>e;function Wg(e,t){return function(n){return e+n*t}}function Gg(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Kg(e,t){var n=t-e;return n?Wg(e,n>180||n<-180?n-360*Math.round(n/360):n):Ug(isNaN(e)?t:e)}function qg(e){return(e=+e)==1?Jg:function(t,n){return n-t?Gg(t,n,e):Ug(isNaN(t)?n:t)}}function Jg(e,t){var n=t-e;return n?Wg(e,n):Ug(isNaN(e)?t:e)}var Yg=(function e(t){var n=qg(t);function r(e,t){var r=n((e=hg(e)).r,(t=hg(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Jg(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Xg(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Zg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qg=new RegExp(Zg.source,`g`);function $g(e){return function(){return e}}function e_(e){return function(t){return e(t)+``}}function t_(e,t){var n=Zg.lastIndex=Qg.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Zg.exec(e))&&(i=Qg.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Xg(r,i)})),n=Qg.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?e_(c[0].x):$g(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var n_=180/Math.PI,r_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function i_(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*n_,skewX:Math.atan(c)*n_,scaleX:o,scaleY:s}}var a_;function o_(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?r_:i_(t.a,t.b,t.c,t.d,t.e,t.f)}function s_(e){return e==null||(a_||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),a_.setAttribute(`transform`,e),!(e=a_.transform.baseVal.consolidate()))?r_:(e=e.matrix,i_(e.a,e.b,e.c,e.d,e.e,e.f))}function c_(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Xg(e,i)},{i:c-2,x:Xg(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Xg(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Xg(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Xg(e,n)},{i:s-2,x:Xg(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var l_=c_(o_,`px, `,`px)`,`deg)`),u_=c_(s_,`, `,`)`,`)`),d_=1e-12;function f_(e){return((e=Math.exp(e))+1/e)/2}function p_(e){return((e=Math.exp(e))-1/e)/2}function m_(e){return((e=Math.exp(2*e))-1)/(e+1)}var h_=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<d_)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=f_(y),c=s/(n*g)*(i*m_(t*r+y)-p_(y));return[a+c*d,o+c*f,s*i/f_(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4);function g_(e){return(function t(n){n=+n;function r(t,r){var i=e((t=Vg(t)).h,(r=Vg(r)).h),a=Jg(t.s,r.s),o=Jg(t.l,r.l),s=Jg(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}g_(Kg);var __=g_(Jg);function v_(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}var y_=0,b_=0,x_=0,S_=1e3,C_,w_,T_=0,E_=0,D_=0,O_=typeof performance==`object`&&performance.now?performance:Date,k_=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function A_(){return E_||=(k_(j_),O_.now()+D_)}function j_(){E_=0}function M_(){this._call=this._time=this._next=null}M_.prototype=N_.prototype={constructor:M_,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?A_():+n)+(t==null?0:+t),!this._next&&w_!==this&&(w_?w_._next=this:C_=this,w_=this),this._call=e,this._time=n,R_()},stop:function(){this._call&&(this._call=null,this._time=1/0,R_())}};function N_(e,t,n){var r=new M_;return r.restart(e,t,n),r}function P_(){A_(),++y_;for(var e=C_,t;e;)(t=E_-e._time)>=0&&e._call.call(void 0,t),e=e._next;--y_}function F_(){E_=(T_=O_.now())+D_,y_=b_=0;try{P_()}finally{y_=0,L_(),E_=0}}function I_(){var e=O_.now(),t=e-T_;t>S_&&(D_-=t,T_=e)}function L_(){for(var e,t=C_,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:C_=n);w_=e,R_(r)}function R_(e){y_||(b_&&=clearTimeout(b_),e-E_>24?(e<1/0&&(b_=setTimeout(F_,e-O_.now()-D_)),x_&&=clearInterval(x_)):(x_||=(T_=O_.now(),setInterval(I_,S_)),y_=1,k_(F_)))}function z_(e,t,n){var r=new M_;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var B_=Fp(`start`,`end`,`cancel`,`interrupt`),V_=[];function H_(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;K_(e,n,{name:t,index:r,group:i,on:B_,tween:V_,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function U_(e,t){var n=G_(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function W_(e,t){var n=G_(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function G_(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function K_(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=N_(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return z_(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(z_(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function q_(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function J_(e){return this.each(function(){q_(this,e)})}function Y_(e,t){var n,r;return function(){var i=W_(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function X_(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=W_(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Z_(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=G_(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Y_:X_)(n,e,t))}function Q_(e,t,n){var r=e._id;return e.each(function(){var e=W_(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return G_(e,r).value[t]}}function $_(e,t){var n;return(typeof t==`number`?Xg:t instanceof dg?Yg:(n=dg(t))?(t=n,Yg):t_)(e,t)}function ev(e){return function(){this.removeAttribute(e)}}function tv(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nv(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function rv(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function iv(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function av(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ov(e,t){var n=Vp(e),r=n===`transform`?u_:$_;return this.attrTween(e,typeof t==`function`?(n.local?av:iv)(n,r,Q_(this,`attr.`+e,t)):t==null?(n.local?tv:ev)(n):(n.local?rv:nv)(n,r,t))}function sv(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cv(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function lv(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&cv(e,i)),n}return i._value=t,i}function uv(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&sv(e,i)),n}return i._value=t,i}function dv(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Vp(e);return this.tween(n,(r.local?lv:uv)(r,t))}function fv(e,t){return function(){U_(this,e).delay=+t.apply(this,arguments)}}function pv(e,t){return t=+t,function(){U_(this,e).delay=t}}function mv(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?fv:pv)(t,e)):G_(this.node(),t).delay}function hv(e,t){return function(){W_(this,e).duration=+t.apply(this,arguments)}}function gv(e,t){return t=+t,function(){W_(this,e).duration=t}}function _v(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?hv:gv)(t,e)):G_(this.node(),t).duration}function vv(e,t){if(typeof t!=`function`)throw Error();return function(){W_(this,e).ease=t}}function yv(e){var t=this._id;return arguments.length?this.each(vv(t,e)):G_(this.node(),t).ease}function bv(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();W_(this,e).ease=n}}function xv(e){if(typeof e!=`function`)throw Error();return this.each(bv(this._id,e))}function Sv(e){typeof e!=`function`&&(e=$p(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Zv(r,this._parents,this._name,this._id)}function Cv(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new Zv(o,this._parents,this._name,this._id)}function wv(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Tv(e,t,n){var r,i,a=wv(t)?U_:W_;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ev(e,t){var n=this._id;return arguments.length<2?G_(this.node(),n).on.on(e):this.each(Tv(n,e,t))}function Dv(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ov(){return this.on(`end.remove`,Dv(this._id))}function kv(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Kp(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,H_(l[f],t,n,f,l,G_(u,n)));return new Zv(a,this._parents,t,n)}function Av(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Xp(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=G_(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&H_(p,t,n,h,f,m);a.push(f),o.push(u)}return new Zv(a,o,t,n)}var jv=Ih.prototype.constructor;function Mv(){return new jv(this._groups,this._parents)}function Nv(e,t){var n,r,i;return function(){var a=Um(this,e),o=(this.style.removeProperty(e),Um(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Pv(e){return function(){this.style.removeProperty(e)}}function Fv(e,t,n){var r,i=n+``,a;return function(){var o=Um(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Iv(e,t,n){var r,i,a;return function(){var o=Um(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Um(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Lv(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=W_(this,e),l=c.on,u=c.value[a]==null?s||=Pv(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Rv(e,t,n){var r=(e+=``)==`transform`?l_:$_;return t==null?this.styleTween(e,Nv(e,r)).on(`end.style.`+e,Pv(e)):typeof t==`function`?this.styleTween(e,Iv(e,r,Q_(this,`style.`+e,t))).each(Lv(this._id,e)):this.styleTween(e,Fv(e,r,t),n).on(`end.style.`+e,null)}function zv(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Bv(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&zv(e,a,n)),r}return a._value=t,a}function Vv(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Bv(e,t,n??``))}function Hv(e){return function(){this.textContent=e}}function Uv(e){return function(){var t=e(this);this.textContent=t??``}}function Wv(e){return this.tween(`text`,typeof e==`function`?Uv(Q_(this,`text`,e)):Hv(e==null?``:e+``))}function Gv(e){return function(t){this.textContent=e.call(this,t)}}function Kv(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Gv(r)),t}return r._value=e,r}function qv(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Kv(e))}function Jv(){for(var e=this._name,t=this._id,n=$v(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=G_(c,t);H_(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Zv(r,this._parents,e,n)}function Yv(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=W_(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Xv=0;function Zv(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Qv(e){return Ih().transition(e)}function $v(){return++Xv}var ey=Ih.prototype;Zv.prototype=Qv.prototype={constructor:Zv,select:kv,selectAll:Av,selectChild:ey.selectChild,selectChildren:ey.selectChildren,filter:Sv,merge:Cv,selection:Mv,transition:Jv,call:ey.call,nodes:ey.nodes,node:ey.node,size:ey.size,empty:ey.empty,each:ey.each,on:Ev,attr:ov,attrTween:dv,style:Rv,styleTween:Vv,text:Wv,textTween:qv,remove:Ov,tween:Z_,delay:mv,duration:_v,ease:yv,easeVarying:xv,end:Yv,[Symbol.iterator]:ey[Symbol.iterator]};function ty(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ny={time:null,delay:0,duration:250,ease:ty};function ry(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function iy(e){var t,n;e instanceof Zv?(t=e._id,e=e._name):(t=$v(),(n=ny).time=A_(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&H_(c,e,t,l,o,n||ry(c,t));return new Zv(r,this._parents,e,t)}Ih.prototype.interrupt=J_,Ih.prototype.transition=iy;var{abs:ay,max:oy,min:sy}=Math;[`w`,`e`].map(cy),[`n`,`s`].map(cy),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(cy);function cy(e){return{type:e}}function ly(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return uy(this.cover(t,n),t,n,e)}function uy(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function dy(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)uy(this,o[n],s[n],e[n]);return this}function fy(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function py(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function my(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function hy(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function gy(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new hy(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a))if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new hy(p[3],g,_,c,l),new hy(p[2],o,_,g,l),new hy(p[1],g,s,c,_),new hy(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}return r}function _y(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function vy(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function yy(){return this._root}function by(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function xy(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new hy(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new hy(i,l,u,s,c)),(i=r[2])&&t.push(new hy(i,a,u,l,c)),(i=r[1])&&t.push(new hy(i,l,o,s,u)),(i=r[0])&&t.push(new hy(i,a,o,l,u))}return this}function Sy(e){var t=[],n=[],r;for(this._root&&t.push(new hy(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new hy(a,o,s,u,d)),(a=i[1])&&t.push(new hy(a,u,s,c,d)),(a=i[2])&&t.push(new hy(a,o,d,u,l)),(a=i[3])&&t.push(new hy(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Cy(e){return e[0]}function wy(e){return arguments.length?(this._x=e,this):this._x}function Ty(e){return e[1]}function Ey(e){return arguments.length?(this._y=e,this):this._y}function Dy(e,t,n){var r=new Oy(t??Cy,n??Ty,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Oy(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function ky(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ay=Dy.prototype=Oy.prototype;Ay.copy=function(){var e=new Oy(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=ky(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=ky(r));return e},Ay.add=ly,Ay.addAll=dy,Ay.cover=fy,Ay.data=py,Ay.extent=my,Ay.find=gy,Ay.remove=_y,Ay.removeAll=vy,Ay.root=yy,Ay.size=by,Ay.visit=xy,Ay.visitAfter=Sy,Ay.x=wy,Ay.y=Ey;function jy(e){return function(){return e}}function My(e){return(e()-.5)*1e-6}function Ny(e){return e.x+e.vx}function Py(e){return e.y+e.vy}function Fy(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=jy(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;m<a;++m)for(c=Dy(t,Ny,Py).visitAfter(s),e=0;e<o;++e)l=t[e],f=n[l.index],p=f*f,u=l.x+l.vx,d=l.y+l.vy,c.visit(h);function h(e,t,n,a,o){var s=e.data,c=e.r,m=f+c;if(s){if(s.index>l.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_<m*m&&(h===0&&(h=My(r),_+=h*h),g===0&&(g=My(r),_+=g*g),_=(m-(_=Math.sqrt(_)))/_*i,l.vx+=(h*=_)*(m=(c*=c)/(p+c)),l.vy+=(g*=_)*m,s.vx-=h*(m=1-m),s.vy-=g*m)}return}return t>u+m||a<u-m||n>d+m||o<d-m}}function s(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r<i;++r)a=t[r],n[a.index]=+e(a,r,t)}}return o.initialize=function(e,n){t=e,r=n,c()},o.iterations=function(e){return arguments.length?(a=+e,o):a},o.strength=function(e){return arguments.length?(i=+e,o):i},o.radius=function(t){return arguments.length?(e=typeof t==`function`?t:jy(+t),c(),o):e},o}var Iy=1664525,Ly=1013904223,Ry=4294967296;function zy(){let e=1;return()=>(e=(Iy*e+Ly)%Ry)/Ry}function By(e){return e.x}function Vy(e){return e.y}var Hy=10,Uy=Math.PI*(3-Math.sqrt(5));function Wy(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=N_(d),l=Fp(`tick`,`end`),u=zy();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=Hy*Math.sqrt(.5+t),a=t*Uy;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function Gy(){var e,t,n,r,i=jy(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=Dy(e,By,Vy).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=My(n),m+=d*d),f===0&&(f=My(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=My(n),m+=d*d),f===0&&(f=My(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:jy(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}function Ky(e,t,n){var r,i=jy(.1),a,o;typeof e!=`function`&&(e=jy(+e)),t??=0,n??=0;function s(e){for(var i=0,s=r.length;i<s;++i){var c=r[i],l=c.x-t||1e-6,u=c.y-n||1e-6,d=Math.sqrt(l*l+u*u),f=(o[i]-d)*a[i]*e/d;c.vx+=l*f,c.vy+=u*f}}function c(){if(r){var t,n=r.length;for(a=Array(n),o=Array(n),t=0;t<n;++t)o[t]=+e(r[t],t,r),a[t]=isNaN(o[t])?0:+i(r[t],t,r)}}return s.initialize=function(e){r=e,c()},s.strength=function(e){return arguments.length?(i=typeof e==`function`?e:jy(+e),c(),s):i},s.radius=function(t){return arguments.length?(e=typeof t==`function`?t:jy(+t),c(),s):e},s.x=function(e){return arguments.length?(t=+e,s):t},s.y=function(e){return arguments.length?(n=+e,s):n},s}function qy(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var Jy=Symbol(`implicit`);function Yy(){var e=new Ep,t=[],n=[],r=Jy;function i(i){let a=e.get(i);if(a===void 0){if(r!==Jy)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Ep;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Yy(t,n).unknown(r)},qy.apply(i,arguments),i}__(Vg(-100,.75,.35),Vg(80,1.5,.8));var Xy=__(Vg(260,.75,.35),Vg(80,1.5,.8));Vg();var Zy=e=>()=>e;function Qy(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function $y(e,t,n){this.k=e,this.x=t,this.y=n}$y.prototype={constructor:$y,scale:function(e){return e===1?this:new $y(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new $y(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var eb=new $y(1,0,0);tb.prototype=$y.prototype;function tb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return eb;return e.__zoom}function nb(e){e.stopImmediatePropagation()}function rb(e){e.preventDefault(),e.stopImmediatePropagation()}function ib(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function ab(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ob(){return this.__zoom||eb}function sb(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cb(){return navigator.maxTouchPoints||`ontouchstart`in this}function lb(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function ub(){var e=ib,t=ab,n=lb,r=sb,i=cb,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=h_,l=Fp(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,ob).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,ob),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(eb.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new $y(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new $y(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new $y(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Rh(this.that).datum();l.call(e,this.that,new Qy(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Bh(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],q_(this),s.start();rb(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Rh(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Bh(t,i),l=t.clientX,u=t.clientY;Uh(t.view),nb(t),a.mouse=[c,this.__zoom.invert(c)],q_(this),a.start();function d(e){if(rb(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Bh(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Wh(e.view,a.moved),rb(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Bh(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);rb(r),s>0?Rh(this).transition().duration(s).call(x,d,c,r):Rh(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(nb(t),s=0;s<i;++s)c=r[s],l=Bh(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),q_(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(rb(e),s=0;s<a;++s)c=i[s],l=Bh(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(nb(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Bh(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Rh(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:Zy(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:Zy(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:Zy(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:Zy([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}function db({projectName:e,onPickProject:t}){let[n,r]=(0,W.useState)(`galaxy`),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),f=q({queryKey:[`cog-graph-projects`],queryFn:()=>Z.projects().then(e=>e.mode===`folder`?e.projects:[])}),p=q({queryKey:[`cog-graph`,e],queryFn:()=>Z.graph(e),enabled:!!e}),m=(0,W.useMemo)(()=>wb(p.data?.sessions??[],p.data?.thread_edges??[]),[p.data]),h=(0,W.useMemo)(()=>{let e=new Map;for(let t of m)t.skill&&e.set(t.skill,(e.get(t.skill)??0)+1);let t=0;for(let n of e.values())t+=Math.max(0,n-1);return t},[m]),g=(0,W.useMemo)(()=>Tb(m),[m]),_=(0,W.useMemo)(()=>c?m.find(e=>e.full_id===c)??null:null,[c,m]);return(0,G.jsxs)(`div`,{className:`flex flex-col h-full bg-bg text-fg`,children:[(0,G.jsxs)(`header`,{className:`flex items-center gap-4 px-6 py-3 border-b border-line bg-bg-elevated`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-sm`,children:`Cognitive Graph`}),(0,G.jsx)(fb,{current:e,available:f.data??[],onPick:t}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-dim`,children:[m.length,` sessions · `,g.length,` clusters`,p.data?.thread_edges?.length?` · ${p.data.thread_edges.length} thread edges`:``,h>0?` · ${h} skill chains`:` · 0 skill chains`]}),(0,G.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`filter by brand / skill / id…`,className:`ml-auto bg-bg border border-line rounded px-3 py-1 text-xs text-fg placeholder:text-fg-dim focus:outline-none focus:border-accent w-64`}),(0,G.jsx)(pb,{view:n,onChange:r})]}),(0,G.jsxs)(`main`,{className:`flex-1 flex min-h-0`,children:[(0,G.jsxs)(`div`,{className:`flex-1 relative overflow-hidden bg-[radial-gradient(ellipse_at_center,#15151a_0%,#0a0a0c_80%)]`,children:[p.isLoading&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-fg-dim text-xs`,children:`loading project graph…`}),p.error&&(0,G.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center text-warn text-xs`,children:[`error: `,p.error.message]}),p.data&&m.length>0&&(0,G.jsx)(vb,{projectName:e,sessions:m,brandOrder:g,threadEdges:p.data.thread_edges??[],showSkillChains:u,view:n,focusId:i,search:o,onSelect:e=>{l(e),n===`focus`&&a(e)}}),p.data&&m.length===0&&(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center px-8 text-fg-dim text-xs`,children:(0,G.jsxs)(`div`,{className:`max-w-md space-y-3 text-center`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg`,children:`Graph is empty for this project.`}),(0,G.jsx)(`p`,{className:`leading-relaxed`,children:`The Cognitive Graph populates after Tier-1 inference runs over your sessions and extracts decisions, skills, and outputs to plot.`}),(0,G.jsxs)(`p`,{className:`leading-relaxed`,children:[`Run`,` `,(0,G.jsx)(`code`,{className:`px-1 py-0.5 bg-bg-elevated border border-line rounded text-fg`,children:`recall semantic on`}),` `,`in your terminal, then come back. Or open this project on a different Recall install where extractions have already landed.`]})]})}),(0,G.jsx)(mb,{showSkillChains:u,onToggleSkillChains:()=>d(e=>!e)})]}),(0,G.jsx)(`aside`,{className:`w-80 border-l border-line bg-bg-elevated p-5 overflow-y-auto text-xs`,children:(0,G.jsx)(hb,{session:_,allSessions:m,onPick:e=>{l(e),n===`focus`&&a(e)}})})]})]})}function fb({current:e,available:t,onPick:n}){return(0,G.jsxs)(`select`,{value:e,onChange:e=>n(e.target.value),className:`bg-bg border border-line rounded px-2 py-1 text-xs text-fg cursor-pointer max-w-[16rem]`,children:[t.length===0&&(0,G.jsx)(`option`,{value:e,children:e}),t.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.session_count,`)`]},e.id))]})}function pb({view:e,onChange:t}){return(0,G.jsx)(`div`,{className:`flex gap-1 bg-bg border border-line rounded p-0.5`,children:[`galaxy`,`focus`].map(n=>(0,G.jsx)(`button`,{onClick:()=>t(n),className:`px-3 py-1 text-xs rounded font-medium ${e===n?`bg-accent text-white`:`text-fg-dim hover:text-fg`}`,children:n===`galaxy`?`Galaxy`:`Focus (INDEX)`},n))})}function mb({showSkillChains:e,onToggleSkillChains:t}){return(0,G.jsxs)(`div`,{className:`absolute bottom-4 left-4 bg-bg/90 backdrop-blur-sm border border-line rounded-md px-4 py-3 text-xs text-fg-dim leading-relaxed max-w-sm shadow-lg`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm mb-1.5`,children:`Reading the galaxy`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-dim mb-3 italic`,children:`Every circle is one terminal session. Lines show how sessions relate.`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1.5`,children:`Circles`}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-4 rounded-full mr-2 shrink-0`,style:{background:`#8a78ff`,boxShadow:`0 0 0 2px #b3a8ff inset`}}),`the project (this repo) — center hub`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3.5 h-3.5 rounded-full mr-2 shrink-0`,style:{background:`#4f9ec4`,boxShadow:`0 0 0 1.5px #86c4dd inset, 0 0 0 2px #4f9ec4`}}),`thread origin — started a family`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-0.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full mr-2 shrink-0`,style:{background:Xy(.78)}}),`a regular session`]}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-dim/80 mb-3 ml-[26px]`,children:`color tracks which agent ran it; size tracks message count`}),(0,G.jsx)(`div`,{className:`font-semibold text-fg mb-1.5`,children:`Lines`}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 h-px mr-2 shrink-0`,style:{background:`#4a4a52`,height:1}}),`belongs to this project`]}),(0,G.jsxs)(`div`,{className:`flex items-center mb-1.5`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mr-2 shrink-0`,style:{background:`#4f9ec4`,height:2,opacity:.9}}),`child → parent inside a thread`]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 hover:text-fg cursor-pointer select-none`,title:`Toggle shared-skill correlation overlay`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:t,className:`cursor-pointer accent-[#b3a8ff]`}),(0,G.jsx)(`span`,{className:`inline-block w-5 shrink-0`,style:{borderTop:`1.5px dashed #b3a8ff`,opacity:e?.85:.3}}),(0,G.jsx)(`span`,{style:{opacity:e?1:.5},children:`sessions sharing a skill`})]})]})}function hb({session:e,allSessions:t,onPick:n}){if(!e)return(0,G.jsx)(`div`,{className:`text-fg-dim italic`,children:`Click a node to inspect.`});let r=t.filter(t=>t.brandKey===e.brandKey&&t.full_id!==e.full_id),i=t.filter(t=>t.skill&&t.skill===e.skill&&t.brandKey!==e.brandKey).slice(0,8);return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-[10px] uppercase tracking-wider text-fg-dim mb-3`,children:`Detail`}),(0,G.jsx)(gb,{label:`Decimal coordinate`,children:(0,G.jsx)(`span`,{className:`font-mono text-accent text-sm font-semibold`,children:e.decimal})}),(0,G.jsx)(gb,{label:`Title`,children:(0,G.jsx)(`span`,{className:`break-words`,children:e.title})}),e.brand&&(0,G.jsx)(gb,{label:`Brand cluster`,children:e.brand}),e.skill&&(0,G.jsx)(gb,{label:`Skill`,children:e.skill}),e.title_quality&&(0,G.jsx)(gb,{label:`Title quality`,children:(0,G.jsx)(`span`,{className:`font-mono`,children:e.title_quality})}),(0,G.jsx)(gb,{label:`Started`,children:e.started_at?new Date(e.started_at).toLocaleString():`—`}),(0,G.jsx)(gb,{label:`Messages`,children:e.msgs}),(0,G.jsx)(gb,{label:`Session UUID`,children:(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-fg-dim break-all`,children:e.full_id})}),r.length>0&&(0,G.jsx)(_b,{label:`Same-brand siblings (${r.length})`,peers:r.slice(0,8),onPick:n,overflow:r.length>8?r.length-8:0}),i.length>0&&(0,G.jsx)(_b,{label:`Same-skill cousins (other brands)`,peers:i,onPick:n})]})}function gb({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-fg-dim mb-1`,children:e}),(0,G.jsx)(`div`,{className:`text-fg leading-snug`,children:t})]})}function _b({label:e,peers:t,onPick:n,overflow:r}){return(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-line`,children:[(0,G.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-fg-dim mb-1`,children:e}),t.map(e=>(0,G.jsxs)(`button`,{onClick:()=>n(e.full_id),className:`w-full text-left px-2 py-1.5 -mx-2 rounded hover:bg-bg flex items-baseline gap-2 cursor-pointer`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-accent min-w-[3rem]`,children:e.decimal}),(0,G.jsx)(`span`,{className:`text-[11px] text-fg truncate flex-1`,children:e.title})]},e.full_id)),r?(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-dim mt-1 px-2`,children:[`+`,r,` more`]}):null]})}function vb({projectName:e,sessions:t,brandOrder:n,threadEdges:r,showSkillChains:i,view:a,focusId:o,search:s,onSelect:c}){let l=(0,W.useRef)(null),u=(0,W.useRef)(null),[d,f]=(0,W.useState)({w:800,h:600}),p=(0,W.useRef)(eb),m=(0,W.useRef)(a),h=(0,W.useRef)(c);return(0,W.useEffect)(()=>{h.current=c},[c]),(0,W.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(()=>{f({w:e.clientWidth,h:e.clientHeight})});return t.observe(e),f({w:e.clientWidth,h:e.clientHeight}),()=>t.disconnect()},[]),(0,W.useEffect)(()=>{if(!l.current||t.length===0)return;let i=Rh(l.current);i.selectAll(`*`).remove(),m.current!==a&&(p.current=eb,m.current=a);let s=bb(i,d,p),c=e=>h.current(e);a===`galaxy`?Sb(i,s,e,t,n,r,!0,d,c):Cb(i,s,t,n,o,d,c)},[e,t,n,r,a,o,d]),(0,W.useEffect)(()=>{l.current&&Rh(l.current).select(`g.skill-edges`).style(`display`,i?null:`none`)},[i]),(0,W.useEffect)(()=>{if(!l.current)return;let e=Rh(l.current),t=s.trim().toLowerCase();if(!t){e.selectAll(`circle.node`).classed(`dim`,!1),e.selectAll(`line.link`).classed(`dim`,!1);return}e.selectAll(`circle.node`).classed(`dim`,e=>{let n=(e?.title??``).toLowerCase(),r=(e?.brand??``).toLowerCase(),i=(e?.skill??``).toLowerCase(),a=(e?.id??``).toLowerCase();return!(n.includes(t)||r.includes(t)||i.includes(t)||a.includes(t))}),e.selectAll(`line.link`).classed(`dim`,!0)},[s]),(0,G.jsx)(`div`,{ref:u,className:`absolute inset-0`,children:(0,G.jsx)(`svg`,{ref:l,className:`w-full h-full block`})})}var yb=v_(e=>Xy(.55+e*.4),20);function bb(e,t,n){let r=e.append(`g`).attr(`class`,`zoom-root`);r.attr(`transform`,n.current.toString());let i=ub().scaleExtent([.2,8]).translateExtent([[-t.w,-t.h],[t.w*2,t.h*2]]).filter(e=>e.type===`wheel`?!0:e.type===`mousedown`?e.button===0?!e.target?.closest(`circle.node`):!1:(e.type,!0)).on(`zoom`,e=>{n.current=e.transform,r.attr(`transform`,e.transform.toString())});return e.call(i),e.call(i.transform,n.current),e.on(`dblclick.zoom`,null),e.on(`dblclick`,t=>{t.target?.closest(`circle.node`)||e.transition().duration(250).call(i.transform,eb)}),r}function xb(e){return 3+Math.min(8,Math.sqrt(e.msgs)/4)}function Sb(e,t,n,r,i,a,o,s,c){let{w:l,h:u}=s;e.attr(`viewBox`,`0 0 ${l} ${u}`);let d=l/2,f=u/2,p=Math.min(l,u)*.32,m=Yy().domain(i).range(yb),h=new Map;for(let e of r)h.set(e.full_id,e);let g=new Map,_=new Map;for(let e of a)h.has(e.session_id)&&(g.has(e.session_id)||g.set(e.session_id,{threadId:e.thread_id,role:e.role,parent:e.parent_session_id}),_.has(e.thread_id)||_.set(e.thread_id,[]),_.get(e.thread_id).push(e.session_id));let v=Array.from(_.entries()).filter(([,e])=>e.length>=2),y=new Set(v.map(([e])=>e));for(let[e,t]of g.entries())y.has(t.threadId)||g.delete(e);v.sort((e,t)=>t[1].length-e[1].length);let b=new Map;v.forEach(([e],t)=>{let n=t/Math.max(v.length,1)*2*Math.PI-Math.PI/2;b.set(e,{x:d+Math.cos(n)*p,y:f+Math.sin(n)*p})});let x=r.filter(e=>!g.has(e.full_id)),S=new Map,C=new Map;for(let[e,t]of g.entries())t.role===`child`&&t.parent&&(C.has(t.parent)||C.set(t.parent,[]),C.get(t.parent).push(e));for(let[e,t]of _.entries()){if(!y.has(e))continue;let n=b.get(e),r=t.filter(e=>{let t=g.get(e);return!!t&&(t.role===`origin`||!t.parent)});r.forEach((e,t)=>{if(r.length===1)S.set(e,{x:n.x,y:n.y});else{let i=-Math.PI/2+t/r.length*2*Math.PI;S.set(e,{x:n.x+Math.cos(i)*40,y:n.y+Math.sin(i)*40})}})}let w=Array.from(S.keys()),T=0;for(;w.length>0&&T<8;){let e=[];for(let t of w){let n=S.get(t),r=C.get(t)??[];if(r.length===0)continue;let i=180*.75**T,a=Math.atan2(n.y-f,n.x-d),o=r.length,s=o<=1?0:o===2?Math.PI/2:o===3?2*Math.PI/3:o<=5?Math.PI:o<=7?3*Math.PI/2:2*Math.PI,c=s>=2*Math.PI-1e-9;r.forEach((t,r)=>{if(S.has(t))return;let l;l=o===1?a:c?a-s/2+r/o*s:a-s/2+r/(o-1)*s,S.set(t,{x:n.x+Math.cos(l)*i,y:n.y+Math.sin(l)*i}),e.push(t)})}w=e,T++}let E=r.map((e,t)=>{let n=g.get(e.full_id),r=S.get(e.full_id);if(n&&r)return{...e,x:r.x,y:r.y};let i=x.indexOf(e),a=(i>=0?i:t)/Math.max(x.length,1)*2*Math.PI;return{...e,x:d+Math.cos(a)*p,y:f+Math.sin(a)*p}}),D=new Map;E.forEach((e,t)=>D.set(e.full_id,t));let O=[];for(let[e,t]of g.entries()){if(t.role!==`child`||!t.parent)continue;let n=D.get(e),r=D.get(t.parent);n==null||r==null||O.push({source:n,target:r})}let k=E.filter(e=>{let t=g.get(e.full_id);return!t||t.role===`origin`}),A=[];if(o){let e=new Map;for(let t of r)t.skill&&(e.has(t.skill)||e.set(t.skill,[]),e.get(t.skill).push(t));for(let t of e.values()){let e=t.slice().sort((e,t)=>(e.started_at??``).localeCompare(t.started_at??``));for(let t=1;t<e.length;t++){let n=D.get(e[t-1].full_id),r=D.get(e[t].full_id);n==null||r==null||A.push({source:n,target:r})}}}let j=t.append(`g`).attr(`class`,`spokes`),M=t.append(`g`).attr(`class`,`skill-edges`),ee=t.append(`g`).attr(`class`,`family-edges`),N=t.append(`g`).attr(`class`,`origin-halos`),te=t.append(`g`).attr(`class`,`hub`),P=t.append(`g`).attr(`class`,`nodes`),F=j.selectAll(`line`).data(k).enter().append(`line`).attr(`class`,`spoke`).attr(`stroke`,`#4a4a52`).attr(`stroke-opacity`,.1).attr(`stroke-width`,.5),I=M.selectAll(`line`).data(A).enter().append(`line`).attr(`class`,`link skill`).attr(`stroke`,`#b3a8ff`).attr(`stroke-opacity`,1).attr(`stroke-width`,2).attr(`stroke-dasharray`,`8 4`),L=ee.selectAll(`line`).data(O).enter().append(`line`).attr(`class`,`link family`).attr(`stroke`,`#4f9ec4`).attr(`stroke-opacity`,1).attr(`stroke-width`,2.5),R=E.filter(e=>g.get(e.full_id)?.role===`origin`),z=N.selectAll(`circle`).data(R).enter().append(`circle`).attr(`class`,`origin-halo`).attr(`fill`,`none`).attr(`stroke`,`#86c4dd`).attr(`stroke-opacity`,.35).attr(`stroke-width`,1).style(`pointer-events`,`none`);te.append(`circle`).attr(`class`,`node hub`).attr(`cx`,d).attr(`cy`,f).attr(`r`,18).attr(`fill`,`#8a78ff`).attr(`stroke`,`#b3a8ff`).attr(`stroke-width`,3).style(`pointer-events`,`none`),te.append(`text`).attr(`text-anchor`,`middle`).attr(`x`,d).attr(`y`,f+18+18).attr(`fill`,`#e6e6e8`).attr(`font-size`,13).attr(`font-weight`,600).style(`pointer-events`,`none`).text(n.length>38?n.slice(0,36)+`…`:n);let B=P.selectAll(`circle`).data(E).enter().append(`circle`).attr(`class`,e=>`node`+(g.get(e.full_id)?.role===`origin`?` origin`:``)).attr(`r`,e=>{let t=g.get(e.full_id),n=xb(e);return t?.role===`origin`?(C.get(e.full_id)??[]).length>0?14:Math.max(n+4,9):n}).attr(`fill`,e=>g.get(e.full_id)?.role===`origin`?`#4f9ec4`:m(e.brandKey)).attr(`stroke`,e=>g.get(e.full_id)?.role===`origin`?`#86c4dd`:`#0e0e10`).attr(`stroke-width`,e=>g.get(e.full_id)?.role===`origin`?2:1.2).attr(`fill-opacity`,e=>g.has(e.full_id)?1:.35).style(`cursor`,`pointer`).on(`click`,(e,t)=>c(t.full_id));B.append(`title`).text(e=>{let t=g.get(e.full_id);return`${t?`[${t.role}] `:``}${e.decimal} · ${e.title}`});for(let e of E)g.has(e.full_id)&&(e.fx=e.x,e.fy=e.y);let V=new Map,ne=[];for(let[e,t]of g.entries())(t.role===`origin`||!t.parent)&&(V.set(e,0),ne.push(e));for(;ne.length;){let e=ne.shift(),t=V.get(e);for(let n of C.get(e)??[])V.has(n)||(V.set(n,t+1),ne.push(n))}let H=Wy(E).force(`moon`,e=>{let t=.35*e;for(let e of E){let n=g.get(e.full_id);if(!n||n.role!==`child`||!n.parent)continue;let r=D.get(n.parent);if(r==null)continue;let i=E[r],a=(e.x??0)-(i.x??0),o=(e.y??0)-(i.y??0),s=Math.sqrt(a*a+o*o)||.01,c=(180*.75**((V.get(e.full_id)??1)-1)-s)/s;e.vx=(e.vx??0)+a*c*t,e.vy=(e.vy??0)+o*c*t}}).force(`anchor`,e=>{let t=.45*e;for(let e of E){let n=g.get(e.full_id);if(!n||!(n.role===`origin`||!n.parent))continue;let r=b.get(n.threadId);r&&(e.vx=(e.vx??0)+(r.x-(e.x??0))*t,e.vy=(e.vy??0)+(r.y-(e.y??0))*t)}}).force(`radial`,Ky(p,d,f).strength(e=>g.has(e.full_id)?0:.18)).force(`charge`,Gy().strength(e=>g.has(e.full_id)?-40:-220).distanceMax(520)).force(`collide`,Fy().radius(e=>xb(e)+10).strength(.95)).on(`tick`,()=>{F.attr(`x1`,e=>e.x??0).attr(`y1`,e=>e.y??0).attr(`x2`,d).attr(`y2`,f),I.attr(`x1`,e=>E[e.source].x??0).attr(`y1`,e=>E[e.source].y??0).attr(`x2`,e=>E[e.target].x??0).attr(`y2`,e=>E[e.target].y??0),L.attr(`x1`,e=>E[e.source].x??0).attr(`y1`,e=>E[e.source].y??0).attr(`x2`,e=>E[e.target].x??0).attr(`y2`,e=>E[e.target].y??0),B.attr(`cx`,e=>e.x??0).attr(`cy`,e=>e.y??0),z.attr(`cx`,e=>e.x??0).attr(`cy`,e=>e.y??0).attr(`r`,e=>{if((C.get(e.full_id)??[]).length>0)return 28;let t=xb(e);return Math.max(t+5,10)+6})});setTimeout(()=>H.alphaTarget(0).stop(),4e3)}function Cb(e,t,n,r,i,a,o){let{w:s,h:c}=a;e.attr(`viewBox`,`0 0 ${s} ${c}`);let l=n.find(e=>e.full_id===i)??n.find(e=>e.brandKey===r[0])??n[0];if(!l)return;let u=n.filter(e=>e.brandKey===l.brandKey&&e.full_id!==l.full_id).slice(0,24),d=n.filter(e=>e.skill&&e.skill===l.skill&&e.brandKey!==l.brandKey).slice(0,18),f=[l,...u,...d],p=Math.min(s,c)*.18,m=Math.min(s,c)*.34,h=f.map((e,t)=>{if(t===0)return{...e,x:s/2,y:c/2};if(t<=u.length){let n=(t-1)/Math.max(u.length,1)*2*Math.PI;return{...e,x:s/2+Math.cos(n)*p,y:c/2+Math.sin(n)*p}}let n=(t-1-u.length)/Math.max(d.length,1)*2*Math.PI+.18;return{...e,x:s/2+Math.cos(n)*m,y:c/2+Math.sin(n)*m}}),g=[...u.map(e=>({source:0,target:f.indexOf(e),kind:`intra`})),...d.map(e=>({source:0,target:f.indexOf(e),kind:`inter`}))],_=t.append(`g`).attr(`class`,`links`),v=t.append(`g`).attr(`class`,`nodes`),y=t.append(`g`).attr(`class`,`labels`);_.selectAll(`line`).data(g).enter().append(`line`).attr(`class`,`link bright`).attr(`stroke`,`#8a78ff`).attr(`stroke-opacity`,e=>e.kind===`intra`?.9:.45).attr(`stroke-width`,e=>e.kind===`intra`?1.4:.7).attr(`x1`,e=>h[e.source].x).attr(`y1`,e=>h[e.source].y).attr(`x2`,e=>h[e.target].x).attr(`y2`,e=>h[e.target].y);let b=Yy().domain(r).range(yb);v.selectAll(`circle`).data(h).enter().append(`circle`).attr(`class`,(e,t)=>`node`+(t===0?` focused`:``)).attr(`cx`,e=>e.x).attr(`cy`,e=>e.y).attr(`r`,(e,t)=>t===0?14:xb(e)+1).attr(`fill`,(e,t)=>t===0?`#8a78ff`:b(e.brandKey)).attr(`stroke`,(e,t)=>t===0?`#b3a8ff`:`#0e0e10`).attr(`stroke-width`,(e,t)=>t===0?3:1.2).style(`cursor`,`pointer`).on(`click`,(e,t)=>o(t.full_id)).append(`title`).text(e=>`${e.decimal} · ${e.title}`),y.append(`text`).attr(`class`,`focus-label`).attr(`text-anchor`,`middle`).attr(`fill`,`#e6e6e8`).attr(`font-size`,13).attr(`font-weight`,600).style(`pointer-events`,`none`).attr(`x`,s/2).attr(`y`,c/2+32).text(`${l.decimal} · INDEX`)}function wb(e,t){let n=Mp(e.map(e=>({...e,brandKey:e.brand??`Other`})),e=>e.brandKey),r=Array.from(n.keys()).sort((e,t)=>n.get(t).length-n.get(e).length),i=[];for(let e of r){let t=n.get(e).slice().sort((e,t)=>{let n=e.skill??`zzz`,r=t.skill??`zzz`;return n===r?(e.started_at??``).localeCompare(t.started_at??``):n.localeCompare(r)}),a=Array.from(new Set(t.map(e=>e.skill??`(prompt)`))),o=r.indexOf(e)+1,s=new Map;for(let e of t){let t=e.skill??`(prompt)`,n=a.indexOf(t)+1,r=(s.get(t)??0)+1;s.set(t,r),i.push({...e,decimal:`${o}.${n}.${r}`})}}let a=new Map(i.map(e=>[e.full_id,e])),o=new Map;for(let e of t)e.role!==`child`||!e.parent_session_id||!a.has(e.session_id)||!a.has(e.parent_session_id)||(o.has(e.parent_session_id)||o.set(e.parent_session_id,[]),o.get(e.parent_session_id).push(e.session_id));for(let e of o.values())e.sort((e,t)=>{let n=a.get(e)?.started_at??``,r=a.get(t)?.started_at??``;return n.localeCompare(r)});let s=new Set;for(let e of t)e.role===`child`&&e.parent_session_id&&a.has(e.session_id)&&s.add(e.session_id);let c=new Set,l=e=>{if(c.has(e))return;c.add(e);let t=a.get(e);t&&(o.get(e)??[]).forEach((e,n)=>{let r=a.get(e);r&&(r.decimal=`${t.decimal}.${n+1}`,l(e))})};for(let e of a.keys())s.has(e)||l(e);return i}function Tb(e){let t=Mp(e,e=>e.brandKey);return Array.from(t.keys()).sort((e,n)=>t.get(n).length-t.get(e).length)}var Eb=[`citation`,`similar`,`skill_track`,`bug_pattern`,`wiki_link`,`temporal_proximity`],Db=[`L1`,`L2`,`L3`,`L4`,`user`],Ob={status:`pending`,linkType:`all`,inferredBy:`all`,minConfidence:0};function kb(e){return`${Math.round(e*100)}%`}function Ab(e){return e>=.9?`text-green-400`:e>=.7?`text-amber-400`:`text-fg-dim`}function jb(e){return{citation:{label:`citation`,className:`bg-blue-500/20 text-blue-300`},similar:{label:`similar`,className:`bg-purple-500/20 text-purple-300`},skill_track:{label:`skill`,className:`bg-emerald-500/20 text-emerald-300`},bug_pattern:{label:`bug`,className:`bg-red-500/20 text-red-300`},wiki_link:{label:`wiki`,className:`bg-amber-500/20 text-amber-300`},temporal_proximity:{label:`temporal`,className:`bg-slate-500/20 text-slate-300`}}[e]}function Mb(e){return e.slice(0,8)}function Nb(){let e=K(),[t,n]=(0,W.useState)(Ob),[r,i]=(0,W.useState)(null),a=q({queryKey:[`suggestions`,t.status,t.linkType,t.inferredBy],queryFn:()=>Z.listSuggestions({status:t.status,linkType:t.linkType===`all`?void 0:t.linkType,inferredBy:t.inferredBy===`all`?void 0:t.inferredBy,limit:1e3})}),o=a.data?.suggestions??[],s=(0,W.useMemo)(()=>o.filter(e=>e.confidence>=t.minConfidence),[o,t.minConfidence]),c=J({mutationFn:({id:e,status:t})=>Z.decideSuggestion(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`suggestions`]}),Q({message:n.status===`approved`?`Suggestion approved — added to session_links`:`Suggestion rejected — tombstoned`,tone:`success`,duration:2500})},onError:e=>{Q({message:`Decide failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}),l=J({mutationFn:({ids:e,status:t})=>Z.bulkDecideSuggestions(e,t),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`suggestions`]}),Q({message:`Bulk ${n.status}: decided=${t.decided} skipped=${t.skipped} errors=${t.errors.length}`,tone:t.errors.length?`error`:`success`,duration:4e3})},onError:e=>{Q({message:`Bulk decide failed: ${e instanceof Error?e.message:`unknown`}`,tone:`error`})}}),u=(e,t)=>{c.mutate({id:e,status:t})},d=()=>{let e=s.filter(e=>e.status===`pending`&&e.confidence>=.9).map(e=>e.id);if(e.length===0){Q({message:`No pending suggestions ≥ 90% confidence to approve.`,tone:`info`});return}window.confirm(`Approve ${e.length} suggestion(s) at ≥ 90% confidence?`)&&l.mutate({ids:e,status:`approved`})},f=()=>{let e=s.filter(e=>e.status===`pending`).map(e=>e.id);if(e.length===0){Q({message:`Nothing pending in the current filter.`,tone:`info`});return}window.confirm(`Reject ${e.length} suggestion(s) in the current filter? They'll be tombstoned and won't re-propose.`)&&l.mutate({ids:e,status:`rejected`})},p=()=>{n(e=>({...e,linkType:e.linkType===`citation`?`all`:e.linkType})),Q({message:`Citations hidden in the current view (filter only — nothing modified).`,tone:`info`,duration:2e3})};if(a.isLoading)return(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-dim`,children:`Loading suggestions queue…`});if(a.isError)return(0,G.jsxs)(`div`,{className:`p-6 text-sm text-red-400`,children:[`Failed to load suggestions:`,` `,a.error instanceof Error?a.error.message:`unknown error`]});let m=s.filter(e=>e.status===`pending`).length,h=s.filter(e=>e.status===`approved`).length,g=s.filter(e=>e.status===`rejected`).length;return(0,G.jsxs)(`div`,{className:`flex flex-col h-full bg-bg text-fg`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-3 px-6 py-4 border-b border-line bg-bg-elevated`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,G.jsx)(`h1`,{className:`text-base font-semibold`,children:`📋 Suggestions Queue`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-dim`,children:[s.length,` visible · pending=`,m,t.status!==`pending`&&(0,G.jsxs)(G.Fragment,{children:[` `,`· approved=`,h,` · rejected=`,g]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:d,disabled:l.isPending,className:`text-xs px-3 py-1 rounded border border-green-500/40 text-green-300 hover:bg-green-500/10 disabled:opacity-50`,title:`Approve every pending row at ≥ 90% confidence in the current filter`,children:`✓ Approve ≥ 90%`}),(0,G.jsx)(`button`,{type:`button`,onClick:f,disabled:l.isPending,className:`text-xs px-3 py-1 rounded border border-red-500/40 text-red-300 hover:bg-red-500/10 disabled:opacity-50`,title:`Reject every pending row in the current filter (tombstones them)`,children:`✗ Reject visible`}),(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`text-xs px-3 py-1 rounded border border-line text-fg-dim hover:text-fg`,title:`Hide citations from the current filter (defer review; nothing is written)`,children:`⤳ Skip citations`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`status:`}),(0,G.jsxs)(`select`,{value:t.status,onChange:e=>n(t=>({...t,status:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`pending`,children:`pending`}),(0,G.jsx)(`option`,{value:`approved`,children:`approved`}),(0,G.jsx)(`option`,{value:`rejected`,children:`rejected`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`type:`}),(0,G.jsxs)(`select`,{value:t.linkType,onChange:e=>n(t=>({...t,linkType:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),Eb.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`inferred by:`}),(0,G.jsxs)(`select`,{value:t.inferredBy,onChange:e=>n(t=>({...t,inferredBy:e.target.value})),className:`px-2 py-1 bg-bg border border-line rounded`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),Db.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-fg-dim`,children:`min conf:`}),(0,G.jsx)(`input`,{type:`range`,min:0,max:1,step:.05,value:t.minConfidence,onChange:e=>n(t=>({...t,minConfidence:Number(e.target.value)})),className:`w-32`}),(0,G.jsxs)(`span`,{className:`w-10 tabular-nums text-fg-dim`,children:[Math.round(t.minConfidence*100),`%`]})]}),(t.status!==`pending`||t.linkType!==`all`||t.inferredBy!==`all`||t.minConfidence>0)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(Ob),className:`ml-auto text-fg-dim hover:text-accent underline`,children:`reset`})]})]}),(0,G.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:s.length===0?(0,G.jsxs)(`div`,{className:`p-6 text-sm text-fg-dim`,children:[`No suggestions match the current filter.`,o.length>0&&t.minConfidence>0&&(0,G.jsxs)(G.Fragment,{children:[` `,`(`,o.length,` hidden by min-confidence ≥`,` `,Math.round(t.minConfidence*100),`%)`]})]}):(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`sticky top-0 bg-bg-elevated z-10`,children:(0,G.jsxs)(`tr`,{className:`text-fg-dim border-b border-line`,children:[(0,G.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Source`}),(0,G.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Target`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Type`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Conf`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`By`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Evidence`}),(0,G.jsx)(`th`,{className:`text-right px-4 py-2 font-medium`,children:`Decide`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>(0,G.jsx)(Pb,{row:e,expanded:r===e.id,onToggle:()=>i(t=>t===e.id?null:e.id),onDecide:u,pending:c.isPending&&c.variables?.id===e.id},e.id))})]})})]})}function Pb({row:e,expanded:t,onToggle:n,onDecide:r,pending:i}){let a=jb(e.link_type),o=e.status!==`pending`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`tr`,{className:`border-b border-line/60 hover:bg-bg-elevated/40`,children:[(0,G.jsxs)(`td`,{className:`px-4 py-2 align-top max-w-[260px]`,children:[(0,G.jsx)(`div`,{className:`truncate`,title:e.source_title??e.source_session_id,children:e.source_title??Mb(e.source_session_id)}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] tabular-nums`,children:[Mb(e.source_session_id),e.source_project&&(0,G.jsxs)(`span`,{className:`ml-1 text-fg-dim`,children:[`· `,e.source_project]})]})]}),(0,G.jsxs)(`td`,{className:`px-4 py-2 align-top max-w-[260px]`,children:[(0,G.jsx)(`div`,{className:`truncate`,title:e.target_title??e.target_session_id,children:e.target_title??Mb(e.target_session_id)}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] tabular-nums`,children:[Mb(e.target_session_id),e.target_project&&(0,G.jsxs)(`span`,{className:`ml-1 text-fg-dim`,children:[`· `,e.target_project]})]})]}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top`,children:(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] ${a.className}`,children:a.label})}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top text-right tabular-nums ${Ab(e.confidence)}`,children:kb(e.confidence)}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top text-fg-dim`,children:e.inferred_by}),(0,G.jsx)(`td`,{className:`px-3 py-2 align-top`,children:(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-dim hover:text-fg underline decoration-dotted`,children:t?`hide`:`show`})}),(0,G.jsx)(`td`,{className:`px-4 py-2 align-top text-right`,children:o?(0,G.jsxs)(`span`,{className:e.status===`approved`?`text-green-400 text-[10px]`:`text-red-400 text-[10px]`,children:[e.status,e.decided_at&&(0,G.jsx)(`span`,{className:`text-fg-muted ml-1`,children:new Date(e.decided_at).toLocaleDateString()})]}):(0,G.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.id,`approved`),disabled:i,className:`px-2 py-0.5 rounded border border-green-500/40 text-green-300 hover:bg-green-500/10 disabled:opacity-50`,children:`✓`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e.id,`rejected`),disabled:i,className:`px-2 py-0.5 rounded border border-red-500/40 text-red-300 hover:bg-red-500/10 disabled:opacity-50`,children:`✗`})]})})]}),t&&(0,G.jsx)(`tr`,{className:`bg-bg-elevated/40`,children:(0,G.jsx)(`td`,{colSpan:7,className:`px-6 py-3`,children:(0,G.jsx)(`pre`,{className:`text-[11px] leading-relaxed text-fg-dim overflow-x-auto whitespace-pre-wrap break-words`,children:JSON.stringify(e.evidence,null,2)})})})]})}var Fb=null,Ib=new Set;function Lb(e){Fb=e;for(let e of Ib)e(Fb)}function Rb(){return Fb}var zb=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,note:`fastest, cheapest. Default.`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,note:`higher quality extraction, ~3x cost.`}];function Bb({initialProject:e,availableProjects:t,onClose:n}){let r=K(),[i,a]=(0,W.useState)(`configure`),[o,s]=(0,W.useState)(e),[c,l]=(0,W.useState)(zb[0].value),[u,d]=(0,W.useState)(50),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(null),S=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=Rb();if(!e||e.kind!==`extract`)return;let t=e.jobId,n=!1;return(async()=>{try{let e=await Z.extractOutputsJobSnapshot(t);if(n)return;e.status===`running`?(y(t),x(e),a(`running`)):Lb(null)}catch{Lb(null)}})(),()=>{n=!0}},[]);let C=q({queryKey:[`launcher-budget`],queryFn:()=>Z.launcherBudget(),refetchInterval:i===`running`?5e3:!1});(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&i!==`launching`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]),(0,W.useEffect)(()=>{if(!v)return;let e=new EventSource(mt(`/api/extract-outputs/jobs/${encodeURIComponent(v)}/stream`));return S.current=e,e.addEventListener(`progress`,e=>{try{x(JSON.parse(e.data))}catch{}}),e.addEventListener(`done`,t=>{try{let e=JSON.parse(t.data);x(e),a(e.status===`failed`?`failed`:(e.status,`done`)),e.status===`failed`&&_(e.error)}catch{a(`done`)}e.close(),Lb(null),r.invalidateQueries({queryKey:[`bug-patterns`]}),r.invalidateQueries({queryKey:[`launcher-budget`]})}),e.addEventListener(`error`,()=>{_(`Stream disconnected`),a(`failed`),e.close()}),()=>{e.close(),S.current=null}},[v,r]);async function w(){_(null),h(null),a(`previewing`);try{h(await Z.extractOutputsPreflight({project:o,model:c,limit:u,force:f})),a(`previewed`)}catch(e){_(e instanceof Error?e.message:String(e)),a(`configure`)}}async function T(){if(m?.preflight_token){a(`launching`),_(null);try{let{jobId:e,reused:t}=await Z.extractOutputsRun(m.preflight_token);y(e),Lb({jobId:e,kind:`extract`}),a(`running`),t&&Q({message:`A job for ${o} was already running. Attached to it.`,tone:`info`})}catch(e){_(e instanceof Error?e.message:String(e)),a(`previewed`)}}}async function E(){if(v)try{await Z.extractOutputsCancel(v),Q({message:`Cancellation requested`,tone:`info`})}catch(e){Q({message:`Cancel failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}let D=(0,W.useMemo)(()=>t.filter(e=>e.remaining_sessions>0),[t]),O=i===`configure`||i===`previewed`,k=i===`previewed`&&!!m?.preflight_token;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&i!==`launching`&&n()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-y-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:`🚀 Run extract-outputs`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,disabled:i===`launching`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,title:i===`running`?`Close this dialog. Job continues running; track progress via the badge in the top bar.`:`Close`,children:i===`running`?`run in background ↗`:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-xs`,children:[(i===`configure`||i===`previewing`||i===`previewed`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vb,{value:o,options:D,onChange:e=>{s(e),h(null),a(`configure`)}}),(0,G.jsx)(Hb,{value:c,onChange:e=>{l(e),h(null),a(`configure`)}}),(0,G.jsx)(Ub,{value:u,ceiling:C.data?.session_ceiling??500,onChange:e=>{d(e),h(null),a(`configure`)}}),(0,G.jsx)(Wb,{value:f,onChange:e=>{p(e),h(null),a(`configure`)}}),C.data&&(0,G.jsx)(Gb,{budget:C.data}),i===`previewing`&&(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Computing preview…`}),m&&(0,G.jsx)(Kb,{preflight:m,project:o}),g&&(0,G.jsx)(`div`,{className:`text-error text-xs whitespace-pre-wrap break-words`,children:g})]}),(i===`launching`||i===`running`||i===`done`||i===`failed`)&&b&&(0,G.jsx)(Jb,{snapshot:b,phase:i}),i===`launching`&&!b&&(0,G.jsx)(Yb,{title:`Starting job…`,subtitle:`Securing preflight token and initializing the sub-agent runner.`}),i===`running`&&!b&&(0,G.jsx)(Yb,{title:`Warming up the first sub-agent…`,subtitle:`Each session spawns a Claude sub-agent. The first one usually takes 15–25 seconds before progress events start streaming. Sit tight — once stats appear, they update live.`}),g&&i===`failed`&&(0,G.jsx)(`div`,{className:`text-error text-xs whitespace-pre-wrap break-words`,children:g})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line`,children:[(i===`configure`||i===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 text-fg-muted hover:text-fg`,children:`Cancel`}),(i===`configure`||i===`previewing`||i===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:!O||i===`previewing`,className:`text-xs px-3 py-1.5 border border-line rounded-md hover:border-accent disabled:opacity-40 disabled:cursor-not-allowed`,children:i===`previewing`?`Computing…`:`Preview cost`}),i===`previewed`&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:!k,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:m?.eligible_session_count===0?`Nothing to run`:`I understand, run (${m?.eligible_session_count??0} sessions)`}),i===`running`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 text-fg-muted hover:text-fg`,title:`Close this dialog. The job continues running in the background; track progress via the badge in the top bar.`,children:`Run in background ↗`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void E(),className:`text-xs px-3 py-1.5 border border-error/60 text-error rounded-md hover:bg-error/10`,children:`Cancel job`})]}),(i===`done`||i===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90`,children:`Close`})]})]})})}function Vb({value:e,options:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Project`}),(0,G.jsxs)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-xs`,children:[t.length===0&&(0,G.jsxs)(`option`,{value:e,children:[e,` (no remaining sessions)`]}),t.map(e=>(0,G.jsxs)(`option`,{value:e.project,children:[e.project,` (`,e.remaining_sessions,` remaining)`]},e.project))]})]})}function Hb({value:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Model`}),(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-xs`,children:zb.map(e=>(0,G.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.note,`)`]},e.value))})]})}function Ub({value:e,ceiling:t,onChange:n}){let r=Math.min(t,500);return(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted mb-1 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:`Session limit`}),(0,G.jsx)(`span`,{className:`text-fg tabular-nums`,children:e})]}),(0,G.jsx)(`input`,{type:`range`,min:1,max:r,step:1,value:Math.min(e,r),onChange:e=>n(Number(e.target.value)),className:`w-full`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted mt-1`,children:[`Server ceiling: `,t,`. Lower this for a smaller, cheaper test run. The actual count extracted will not exceed this.`]})]})}function Wb({value:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Force re-extract`}),` sessions that are already at the current extractor version. Useful if you upgraded the extractor and want fresh signatures. Doubles spend if you run it twice in a row.`]})]})}function Gb({budget:e}){let t=e.spent_total_tokens_24h,n=e.daily_token_budget,r=n===0?0:Math.min(100,Math.round(t/n*100));return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`24h budget`}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[t.toLocaleString(),` / `,n.toLocaleString(),` tokens (`,r,`%)`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden mt-1`,children:(0,G.jsx)(`div`,{className:r>80?`h-full bg-warning`:`h-full bg-accent`,style:{width:`${r}%`}})})]})}function Kb({preflight:e,project:t}){let n=e.estimated_input_tokens_max+e.estimated_output_tokens_max,r=e.budget.remaining_tokens_24h;return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated/40 p-3 space-y-3`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Preview`}),e.eligible_session_count===0?(0,G.jsx)(`div`,{className:`text-fg-muted`,children:e.message??`No eligible sessions in ${t}. Nothing to run.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`About to extract`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:e.eligible_session_count}),` `,`session`,e.eligible_session_count===1?``:`s`,` from`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:t}),`.`]}),e.plan_window_estimate?(0,G.jsx)(qb,{estimate:e.plan_window_estimate}):(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted italic`,children:[`Plan-window impact unavailable. Restart the daemon (`,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`recall stop && recall start`}),`) to pick up the latest server build.`]}),(0,G.jsxs)(`details`,{className:`text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-fg select-none`,children:`Token estimate (for API-key users)`}),(0,G.jsxs)(`div`,{className:`pt-2 space-y-1`,children:[(0,G.jsxs)(`div`,{children:[`Up to`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_input_tokens_max.toLocaleString()}),` `,`input +`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_output_tokens_max.toLocaleString()}),` `,`output tokens. Actual spend depends on session size.`]}),e.would_exceed_budget&&(0,G.jsxs)(`div`,{className:`text-warning`,children:[`⚠ Projected (`,n.toLocaleString(),`) exceeds remaining 24h budget (`,r.toLocaleString(),`). Lower the limit or raise launcher.dailyTokenBudget in ~/.recall/config.json.`]})]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`Token expires in 60 seconds; click Run before then or click Preview again to refresh.`})]})]})}function qb({estimate:e}){let t={pro:`Pro`,"max-5x":`Max 5x`,"max-20x":`Max 20x`};return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:`Claude Code 5-hour window impact`}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(model multiplier: `,e.model_multiplier,`x)`]})]}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.per_plan.map(e=>{let n=e.would_exhaust_window,r=!n&&e.fraction>.5,i=Math.min(100,e.pct);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted w-20 shrink-0`,children:t[e.plan]}),(0,G.jsx)(`div`,{className:`flex-1 h-2 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:n?`h-full bg-warning`:r?`h-full bg-sky-400`:`h-full bg-sky-500/60`,style:{width:`${i}%`}})}),(0,G.jsxs)(`span`,{className:`tabular-nums w-16 text-right text-xs `+(n?`text-warning font-semibold`:`text-fg`),children:[e.pct>=1e3?`>1000`:e.pct.toFixed(1),`%`]})]},e.plan)})}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:[`ⓘ `,e.caveat]})]})}function Jb({snapshot:e,phase:t}){let n=e.total===0?0:Math.round(e.processed/e.total*100);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[t===`running`&&(0,G.jsxs)(`div`,{className:`rounded-md border border-sky-400/40 bg-sky-400/10 px-3 py-2 text-sm text-fg leading-relaxed`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-0.5`,children:`↗ You can close this dialog at any time`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs`,children:[`The job continues running in the background. Track progress on the pulsing pill in the top bar. Use the`,` `,(0,G.jsx)(`strong`,{className:`text-error`,children:`Cancel job`}),` button below to stop early; closing the dialog never cancels.`]})]}),(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:e.project}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`· `,e.model]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-fg-muted`,children:[(0,G.jsxs)(`span`,{children:[e.processed,` / `,e.total,` sessions`]}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[n,`%`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden mt-1`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:`${n}%`}})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`ok:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.ok})]}),(0,G.jsxs)(`div`,{children:[`skipped:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.skipped})]}),(0,G.jsxs)(`div`,{children:[`failed:`,` `,(0,G.jsx)(`strong`,{className:e.failed>0?`text-warning tabular-nums`:`text-fg tabular-nums`,children:e.failed})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-fg-muted`,children:[(0,G.jsxs)(`div`,{children:[`input tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.total_input_tokens.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[`output tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.total_output_tokens.toLocaleString()})]})]}),e.current_session_id&&t===`running`&&(0,G.jsxs)(`div`,{className:`text-fg-muted text-[10px] font-mono`,children:[`current: `,e.current_session_id]}),t===`done`&&(0,G.jsxs)(`div`,{className:`text-accent`,children:[`✓ Done. Run`,` `,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`recall infer-bug-patterns`}),` in your terminal to cluster the new signatures, or close this modal and they will surface on the next inference run.`]}),t===`failed`&&(0,G.jsxs)(`div`,{className:`text-error`,children:[`✗ Failed. `,e.error??`See the audit log for details.`]})]})}function Yb({title:e,subtitle:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-4`,children:[(0,G.jsx)(Xb,{}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg font-medium`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:t})]})]})}function Xb(){return(0,G.jsx)(`span`,{className:`inline-block w-5 h-5 border-2 border-line border-t-sky-400 rounded-full animate-spin shrink-0`,role:`status`,"aria-label":`loading`})}function Zb({onClose:e}){let t=K(),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),u=q({queryKey:[`macro-repos`],queryFn:()=>Z.listMacroRepos()}),d=u.data?.macro_repos??[],f=u.data?.orphan_projects??[],p=d.find(e=>e.id===n)??null;(0,W.useEffect)(()=>{p?(a(p.name),s(p.description??``)):(a(``),s(``))},[n,p]),(0,W.useEffect)(()=>{function t(t){t.key===`Escape`&&e()}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);function m(e){return t=>{Q({message:`${e}: ${t instanceof Error?t.message:String(t)}`,tone:`error`})}}function h(){t.invalidateQueries({queryKey:[`macro-repos`]}),t.invalidateQueries({queryKey:[`bug-patterns`,`setup-status`]})}let g=J({mutationFn:e=>Z.createMacroRepo(e),onSuccess:({macro_repo:e})=>{Q({message:`Created "${e.name}"`,tone:`success`}),r(e.id),h()},onError:m(`Create failed`)}),_=J({mutationFn:e=>Z.patchMacroRepo(e.id,{name:e.name,description:e.description}),onSuccess:()=>{Q({message:`Saved`,tone:`success`}),h()},onError:m(`Save failed`)}),v=J({mutationFn:e=>Z.deleteMacroRepo(e),onSuccess:()=>{Q({message:`Deleted`,tone:`success`}),r(null),h()},onError:m(`Delete failed`)}),y=J({mutationFn:e=>Z.addMacroRepoMember(e.id,e.projectId),onSuccess:()=>{h()},onError:m(`Add member failed`)}),b=J({mutationFn:e=>Z.removeMacroRepoMember(e.id,e.projectId),onSuccess:()=>{h()},onError:m(`Remove member failed`)});function x(){if(!p)return;let e=i.trim();if(!e){Q({message:`Name is required`,tone:`error`});return}e===p.name&&(o||``)===(p.description??``)||_.mutate({id:p.id,name:e,description:o.trim()||null})}function S(){let e=window.prompt(`Name for the new macro repo (e.g. "Frontend"):`);!e||!e.trim()||g.mutate({name:e.trim()})}let C=c.trim()?f.filter(e=>e.name.toLowerCase().includes(c.trim().toLowerCase())):f;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl w-full max-w-4xl max-h-[88vh] flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:`📁 Macro Repos`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-0.5`,children:`Group cwd-based projects into the logical repos you actually think in. Membership is explicit; no auto-grouping.`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs text-fg-muted hover:text-fg`,children:`close`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 grid grid-cols-1 md:grid-cols-[260px_1fr] gap-0 divide-x divide-line overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-2 border-b border-line flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs uppercase tracking-wider text-fg-muted font-medium`,children:[d.length,` repo`,d.length===1?``:`s`]}),(0,G.jsx)(`button`,{type:`button`,onClick:S,className:`text-xs px-2 py-1 bg-accent text-bg rounded font-semibold hover:opacity-90`,children:`+ New`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,children:[d.length===0&&(0,G.jsxs)(`div`,{className:`p-3 text-xs text-fg-muted leading-relaxed`,children:[`No macro repos yet. Click `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`+ New`}),` to create one, then add member projects on the right.`]}),d.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`w-full text-left px-3 py-2 hover:bg-bg-elevated/40 `+(n===e.id?`bg-bg-elevated/60 border-l-2 border-accent`:``),children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg truncate`,children:e.name}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.member_project_ids.length,` member`,e.member_project_ids.length===1?``:`s`]})]},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[!p&&(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6`,children:(0,G.jsx)(`div`,{className:`text-center text-sm text-fg-muted max-w-sm`,children:d.length===0?`Create your first macro repo to start grouping projects.`:`Pick a macro repo on the left to manage members.`})}),p&&(0,G.jsx)(Qb,{repo:p,draftName:i,draftDescription:o,onDraftNameChange:a,onDraftDescriptionChange:s,onSaveDraft:x,onDelete:()=>{window.confirm(`Delete macro repo "${p.name}"? Member projects will return to orphan status. This does not delete any session data.`)&&v.mutate(p.id)},onRemoveMember:e=>b.mutate({id:p.id,projectId:e}),orphanFilter:c,onOrphanFilterChange:l,visibleOrphans:C,onAddMember:e=>y.mutate({id:p.id,projectId:e}),isSaving:_.isPending||y.isPending||b.isPending},p.id)]})]})]})})}function Qb({repo:e,draftName:t,draftDescription:n,onDraftNameChange:r,onDraftDescriptionChange:i,onSaveDraft:a,onDelete:o,onRemoveMember:s,orphanFilter:c,onOrphanFilterChange:l,visibleOrphans:u,onAddMember:d,isSaving:f}){let p=t.trim()!==e.name||(n.trim()||null)!==(e.description??null);return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-4 border-b border-line space-y-3`,children:[(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted mb-1`,children:`Macro repo name`}),(0,G.jsx)(`input`,{type:`text`,value:t,onChange:e=>r(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent`,placeholder:`e.g. Frontend`})]}),(0,G.jsxs)(`label`,{className:`block`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted mb-1`,children:`Description (optional)`}),(0,G.jsx)(`textarea`,{value:n,onChange:e=>i(e.target.value),rows:2,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent resize-y`,placeholder:`What this macro repo represents.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:a,disabled:!p||f,className:`text-xs px-3 py-1.5 bg-accent text-bg rounded font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:`Save changes`}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs px-3 py-1.5 border border-error/60 text-error rounded hover:bg-error/10`,children:`Delete macro repo`})})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-hidden grid grid-cols-1 md:grid-cols-2 divide-x divide-line`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-3 py-2 border-b border-line`,children:(0,G.jsxs)(`div`,{className:`text-xs font-semibold text-fg uppercase tracking-wider`,children:[`Members (`,e.member_project_ids.length,`)`]})}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.member_project_ids.length===0&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`No member projects yet. Add some from the right.`}),e.member_project_ids.map((t,n)=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-sm border-b border-line/50 hover:bg-bg-elevated/40`,children:[(0,G.jsx)(`span`,{className:`text-fg truncate`,children:e.member_project_names[n]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`text-xs text-fg-muted hover:text-error shrink-0 px-1.5`,title:`Remove from macro repo (project becomes orphan again)`,children:`✕`})]},t))]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line space-y-2`,children:[(0,G.jsxs)(`div`,{className:`text-xs font-semibold text-fg uppercase tracking-wider`,children:[`Add member (`,u.length,` available)`]}),(0,G.jsx)(`input`,{type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:`filter orphan projects…`,className:`w-full bg-bg-elevated border border-line rounded px-2 py-1 text-xs focus:outline-none focus:border-accent`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[u.length===0&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:c?`No orphan projects match your filter.`:`No orphan projects. Every project is already in a macro repo.`}),u.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:`w-full flex items-center justify-between px-3 py-1.5 text-sm border-b border-line/50 hover:bg-bg-elevated/40 text-left`,children:[(0,G.jsx)(`span`,{className:`text-fg truncate`,children:e.name}),(0,G.jsx)(`span`,{className:`text-xs text-accent shrink-0 px-1.5`,children:`+ add`})]},e.id))]})]})]})]})}function $b(e){if(!e)return`never`;try{return new Date(e).toISOString().slice(0,10)}catch{return e}}function ex(e,t){return t===0?0:Math.round(e/t*100)}function tx(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(!1),i=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),a=i.data,o=a?.totals,s=a?.projects??[],[c,l]=(0,W.useState)(!1),u=o&&o.total_sessions>0?ex(o.extracted_sessions,o.total_sessions):0;return(0,G.jsxs)(`div`,{className:`border-b border-line shrink-0 max-h-[70vh] flex flex-col`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`w-full text-left px-4 py-3 hover:bg-bg-elevated/40 transition-colors flex items-center gap-3 shrink-0 group`,children:[(0,G.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 rounded text-fg-muted group-hover:text-fg transition-transform `+(c?`rotate-90`:``),"aria-hidden":`true`,children:`▸`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`🐛 Bug Patterns Setup`}),o&&(0,G.jsxs)(`span`,{className:`text-sm text-fg-muted tabular-nums shrink-0`,children:[o.extracted_sessions.toLocaleString(),` of`,` `,o.total_sessions.toLocaleString(),` sessions extracted · `,o.cluster_count,` cluster`,o.cluster_count===1?``:`s`]})]}),o&&(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-1.5 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-all`,style:{width:`${u}%`}})}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums w-10 text-right`,children:[u,`%`]})]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted shrink-0 hidden sm:inline`,children:c?`hide`:`show details`})]}),c&&(0,G.jsx)(`div`,{className:`px-4 pt-2 flex items-center justify-end gap-2 shrink-0`,children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`text-xs px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Group cwd-based projects into the logical repos you actually think in (manual, no auto-grouping).`,children:`📁 Manage macro repos`})}),c&&(0,G.jsxs)(`div`,{className:`overflow-y-auto px-4 pb-4 space-y-4 text-sm`,children:[(0,G.jsxs)(`details`,{className:`rounded-lg border border-line bg-bg-elevated/30 group`,children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-fg-muted hover:text-fg flex items-center gap-2 select-none`,children:[(0,G.jsx)(`span`,{className:`text-fg group-open:rotate-90 transition-transform inline-block w-3`,children:`▸`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`What is this and how does it work?`})]}),(0,G.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-3 leading-relaxed border-t border-line`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Bug Patterns groups past Claude Code sessions that hit the same error so a fix from one can be surfaced when the bug recurs. It does `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`not`}),` scan your repo or source code. It reads bug signatures already extracted from your past session JSONLs.`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2`,children:[(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Step 1`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`extract-outputs`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Sub-agent extracts bug signatures.`,` `,(0,G.jsx)(`span`,{className:`text-warning font-medium`,children:`Costs tokens.`})]})]}),(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Step 2`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`infer-bug-patterns`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Local clustering by fingerprint.`,` `,(0,G.jsx)(`span`,{className:`text-fg font-medium`,children:`No cost.`})]})]}),(0,G.jsxs)(`div`,{className:`rounded border border-line p-2.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-fg-muted mb-1`,children:`Result`}),(0,G.jsx)(`div`,{className:`font-mono text-fg-dim text-xs mb-1`,children:`bug clusters`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Mark "this fix worked" once. Future occurrences surface the linked fix.`})]})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[`Full explanation lives in the Help section under`,` `,(0,G.jsx)(`strong`,{className:`text-fg-dim`,children:`Bug Patterns`}),` and`,` `,(0,G.jsx)(`strong`,{className:`text-fg-dim`,children:`Security & privacy`}),`.`]})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2`,children:[(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-fg`,children:[`Projects (`,s.length,`)`]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Click 🚀 run to extract from the UI, or copy the CLI command`})]}),i.isLoading&&(0,G.jsx)(`div`,{className:`text-fg-muted py-3`,children:`Loading…`}),i.error&&(0,G.jsxs)(`div`,{className:`text-error py-3`,children:[`Failed to load:`,` `,i.error instanceof Error?i.error.message:String(i.error)]}),a&&s.length===0&&(0,G.jsx)(`div`,{className:`text-fg-muted py-3`,children:`No projects indexed yet.`}),a&&s.length>0&&(0,G.jsx)(`div`,{className:`rounded-lg border border-line bg-bg overflow-hidden`,children:(0,G.jsx)(`div`,{className:`max-h-80 overflow-y-auto overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{className:`text-fg-muted bg-bg-elevated sticky top-0 z-10`,children:(0,G.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Project`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Sessions`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-40`,children:`Progress`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Remaining`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium hidden lg:table-cell`,children:`Last run`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Actions`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>{let n=ex(e.extracted_sessions,e.total_sessions),r=e.remaining_sessions===0;return(0,G.jsxs)(`tr`,{className:`border-b border-line/50 last:border-b-0 hover:bg-bg-elevated/30`,children:[(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg font-medium`,children:e.project}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right text-fg-muted tabular-nums`,children:e.total_sessions.toLocaleString()}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`flex-1 h-1.5 bg-line rounded-full overflow-hidden min-w-[60px]`,children:(0,G.jsx)(`div`,{className:r?`h-full bg-accent/60`:`h-full bg-accent`,style:{width:`${n}%`}})}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums w-8 text-right`,children:[n,`%`]})]})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:e.remaining_sessions>0?(0,G.jsx)(`span`,{className:`text-warning`,children:e.remaining_sessions.toLocaleString()}):(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`0`})}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg-muted hidden lg:table-cell`,children:$b(e.last_extracted_at)}),(0,G.jsx)(`td`,{className:`px-3 py-2`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,children:r?(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,title:`All sessions in this project are already extracted.`,children:`✓ done`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(e.project),className:`text-xs px-2 py-0.5 bg-accent/15 border border-accent/60 text-accent rounded hover:bg-accent/25 font-medium whitespace-nowrap`,title:`Launch extract-outputs for ${e.project} from the UI (with cost preview).`,children:`🚀 run`}),(0,G.jsx)(nx,{command:`recall extract-outputs --project "${e.project}"`})]})})})]},e.project)})})]})})})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`v0.20 Phase H · The 🚀 run button launches from the UI with a cost preview, origin-locked, CSRF-protected, budget-capped. See Help → Security & privacy.`})]}),e&&(0,G.jsx)(Bb,{initialProject:e,availableProjects:s.map(e=>({project:e.project,remaining_sessions:e.remaining_sessions})),onClose:()=>t(null)}),n&&(0,G.jsx)(Zb,{onClose:()=>r(!1)})]})}function nx({command:e}){let[t,n]=(0,W.useState)(!1);async function r(){try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{n(!1)}}return(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-2 py-0.5 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim whitespace-nowrap`,title:`Copy: ${e}`,children:t?`✓ copied`:`copy CLI`})}function rx(e){try{let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return e;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n} min ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toISOString().slice(0,10)}catch{return e}}function ix({initialProject:e=null}){let[,t]=Nn(),[n,r]=(0,W.useState)(e),[i,a]=(0,W.useState)(!1),o=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),s=q({queryKey:[`bug-signatures`,n],queryFn:()=>Z.bugSignatures(n??void 0,200)}),c=s.data,l=c?.sessions??[],u=i?l:l.filter(e=>e.signature_count>0),d=o.data?.projects??[];function f(e){t({session:e,view:null})}return(0,G.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-line shrink-0 flex-wrap`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim`,children:[`project`,(0,G.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value===``?null:e.target.value),className:`bg-bg-elevated border border-line rounded px-2 py-1 text-sm`,children:[(0,G.jsx)(`option`,{value:``,children:`all projects`}),d.filter(e=>e.extracted_sessions>0).map(e=>(0,G.jsx)(`option`,{value:e.project,children:e.project},e.project))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`show sessions with no findings`]}),(0,G.jsx)(`div`,{className:`ml-auto text-sm text-fg-muted tabular-nums`,children:c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:c.totals.total_findings}),` `,`finding`,c.totals.total_findings===1?``:`s`,` across`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:c.totals.sessions_with_findings}),` `,`session`,c.totals.sessions_with_findings===1?``:`s`,` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,c.totals.sessions_empty,` empty)`]})]}):`Loading…`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-6 text-center text-fg-muted text-sm`,children:`Loading…`}),s.error&&(0,G.jsxs)(`div`,{className:`p-6 text-center text-error text-sm`,children:[`Failed to load:`,` `,s.error instanceof Error?s.error.message:String(s.error)]}),c&&u.length===0&&(0,G.jsxs)(`div`,{className:`p-8 text-center text-fg-muted text-sm space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-base text-fg`,children:`No findings to show.`}),c.totals.sessions_total===0?(0,G.jsxs)(`div`,{children:[`No sessions in this project have been extracted yet. Click`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`🚀 run`}),` in Setup & Status to extract bug signatures.`]}):c.totals.sessions_with_findings===0?(0,G.jsxs)(`div`,{children:[c.totals.sessions_total,` session`,c.totals.sessions_total===1?``:`s`,` extracted, but none returned bug-shaped content. Most extractions come back empty unless the session was about debugging or hit errors.`]}):(0,G.jsx)(`div`,{children:`Toggle "show sessions with no findings" to also see empty extractions.`})]}),c&&u.length>0&&(0,G.jsx)(`div`,{className:`px-4 py-3 space-y-3`,children:u.map(e=>(0,G.jsx)(ax,{session:e,onOpenSession:()=>f(e.session_id)},e.session_id))})]})]})}function ax({session:e,onOpenSession:t}){let n=e.signature_count===0;return(0,G.jsxs)(`div`,{className:`rounded-lg border bg-bg-elevated/30 `+(n?`border-line/50 opacity-70`:`border-line hover:border-accent/40`),children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between px-4 py-2.5 border-b border-line/50 gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm font-semibold text-fg hover:text-accent text-left truncate block max-w-full`,title:e.auto_title??e.session_id,children:e.auto_title??e.session_id.slice(0,8)}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-0.5 flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bg rounded border border-line/50 font-medium`,children:e.project}),(0,G.jsx)(`span`,{className:`font-mono`,children:e.session_id.slice(0,8)}),(0,G.jsxs)(`span`,{children:[`extracted `,rx(e.extracted_at)]})]})]}),(0,G.jsx)(`div`,{className:`shrink-0 text-sm`,children:n?(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`no findings`}):(0,G.jsxs)(`span`,{className:`text-accent font-semibold tabular-nums`,children:[e.signature_count,` finding`,e.signature_count===1?``:`s`]})})]}),!n&&(0,G.jsx)(`div`,{className:`divide-y divide-line/50`,children:e.signatures.map((n,r)=>(0,G.jsx)(ox,{index:r,finding:n,sessionId:e.session_id,onOpenSession:t},r))})]})}function ox({index:e,finding:t,sessionId:n,onOpenSession:r}){let[,i]=Nn(),a=K(),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=J({mutationFn:e=>Z.resolveBugSignature(e.hash,{resolved_in_session_id:n,fix_summary:e.summary||void 0}),onSuccess:()=>{Q({message:`Marked as fixed`,tone:`success`}),s(!1),l(``),a.invalidateQueries({queryKey:[`bug-signatures`]})},onError:e=>{Q({message:`Failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),d=J({mutationFn:e=>Z.unresolveBugSignature(e),onSuccess:()=>{Q({message:`Re-opened`,tone:`success`}),a.invalidateQueries({queryKey:[`bug-signatures`]})},onError:e=>{Q({message:`Failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}});function f(e,t){navigator.clipboard.writeText(e).then(()=>Q({message:`Copied ${t}`,tone:`success`})).catch(()=>Q({message:`Copy failed`,tone:`error`}))}function p(){let e=[`Bug finding from a past Claude Code session:`];t.error_type&&t.error_type!==`unknown`&&e.push(`Type: ${t.error_type}`),t.snippet&&e.push(`Description: ${t.snippet}`),t.file&&e.push(`File: ${t.file}`),e.push(`Source session: ${n}`),t.message_hash&&e.push(`Finding ID: ${t.message_hash}`),f(e.join(`
|
|
650
650
|
`),`finding as context`)}function m(){t.snippet&&i({q:t.snippet.split(/\s+/).slice(0,8).join(` `),view:null})}let h=!!t.resolved;return(0,G.jsxs)(`div`,{className:`px-4 py-3 text-sm group `+(h?`opacity-60`:``),children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-1.5 flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums w-6 shrink-0`,children:[`#`,e+1]}),h&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 bg-accent/15 text-accent border border-accent/40 rounded font-medium`,children:`✓ fixed`}),t.error_type&&t.error_type!==`unknown`&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 bg-warning/10 text-warning border border-warning/40 rounded font-mono`,children:t.error_type}),t.message_hash&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(`recall://finding/${t.message_hash}`,`finding reference`),title:`Click to copy this finding's reference ID. Use it to track or quote this finding elsewhere.`,className:`text-xs font-mono text-fg-muted hover:text-fg hover:bg-bg-elevated px-1.5 py-0.5 rounded border border-line/50`,children:[`id: `,t.message_hash]})]}),t.snippet&&(0,G.jsx)(`div`,{className:`pl-8 text-fg leading-relaxed `+(h?`line-through decoration-fg-muted/60`:``),children:t.snippet}),h&&t.resolution?.fix_summary&&(0,G.jsxs)(`div`,{className:`pl-8 mt-1.5 text-xs text-accent leading-relaxed border-l-2 border-accent/40 pl-3 ml-8`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Fix:`}),` `,t.resolution.fix_summary]}),t.file&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(t.file,`file path`),title:`Click to copy this file path. Paste into your editor to jump to it.`,className:`pl-8 mt-1.5 text-xs text-fg-muted hover:text-accent font-mono break-all flex items-start gap-1.5 text-left`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:`📄`}),(0,G.jsx)(`span`,{children:t.file})]}),o&&t.message_hash&&(0,G.jsxs)(`div`,{className:`pl-8 mt-2.5 space-y-2`,children:[(0,G.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:`Optional fix summary (e.g. added auth middleware to /api/feature-toggles)`,className:`w-full bg-bg-elevated border border-line rounded p-2 text-sm h-20 focus:outline-none focus:border-accent`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:u.isPending,onClick:()=>{t.message_hash&&u.mutate({hash:t.message_hash,summary:c.trim()})},className:`px-3 py-1 text-xs bg-accent text-bg rounded font-semibold hover:opacity-90 disabled:opacity-40`,children:u.isPending?`Saving…`:`Confirm fix`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),l(``)},className:`px-3 py-1 text-xs text-fg-muted hover:text-fg`,children:`Cancel`})]})]}),!o&&(0,G.jsxs)(`div`,{className:`pl-8 mt-2.5 flex items-center gap-1.5 flex-wrap text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Open the session that surfaced this finding`,children:`↗ open session`}),t.snippet&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(t.snippet,`snippet`),className:`px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Copy the snippet text`,children:`📋 copy snippet`}),t.file&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>f(t.file,`file path`),className:`px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Copy file path to paste into your editor`,children:`📁 copy file path`}),(0,G.jsx)(`button`,{type:`button`,onClick:p,className:`px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Copy this finding as a multi-line block formatted for pasting into a new Claude session`,children:`🤖 copy as context`}),t.snippet&&(0,G.jsx)(`button`,{type:`button`,onClick:m,className:`px-2 py-1 border border-line rounded hover:border-accent hover:text-accent transition-colors text-fg-dim`,title:`Search every session for similar wording (might surface other sessions that hit the same bug)`,children:`🔍 find similar`}),t.message_hash&&(h?(0,G.jsx)(`button`,{type:`button`,disabled:d.isPending,onClick:()=>t.message_hash&&d.mutate(t.message_hash),className:`px-2 py-1 border border-line rounded hover:border-warning hover:text-warning transition-colors text-fg-dim`,title:`Re-open this finding (mark not-fixed)`,children:`↺ re-open`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`px-2 py-1 border border-accent/60 bg-accent/10 text-accent rounded hover:bg-accent/20 font-medium ml-auto`,title:`Mark this finding as fixed. Optional fix summary will be saved with the finding for future reference.`,children:`✓ mark fixed`}))]})]})}var sx=[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,note:`fastest, cheapest. Default.`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,note:`higher quality synthesis, ~3x cost.`}],cx={ALLOWED_TAGS:`p.br.h1.h2.h3.h4.h5.h6.ul.ol.li.strong.em.code.pre.blockquote.table.thead.tbody.tr.th.td.hr.mark.div.span`.split(`.`),ALLOWED_ATTR:[`class`,`title`],FORBID_TAGS:[`style`,`form`,`input`,`button`,`iframe`,`object`,`embed`,`script`],FORBID_ATTR:[`style`,`onerror`,`onload`,`onclick`,`href`,`src`],ALLOW_DATA_ATTR:!1};function lx(e){if(!e)return``;let t=Co.parse(e,{gfm:!0,breaks:!1,async:!1});return Vs.sanitize(t,cx)}var ux={synopsis:`Synopsis`,priorities:`Fix priorities`,root_cause:`Root cause`};function dx({scope:e,targetId:t,mode:n,targetLabel:r,memberSessionIds:i,onClose:a}){let[o,s]=(0,W.useState)(`configure`),[c,l]=(0,W.useState)(sx[0].value),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),v=(0,W.useRef)(null);(0,W.useEffect)(()=>{let r=Rb();if(!r||r.kind!==`synth`)return;let i=!1;return(async()=>{try{let a=await Z.synthesizeJobSnapshot(r.jobId);if(i)return;a.status===`running`&&a.scope===e&&a.target_id===t&&a.mode===n?(h(r.jobId),_(a),s(`running`)):a.status!==`running`&&Lb(null)}catch{Lb(null)}})(),()=>{i=!0}},[e,t,n]);let y=q({queryKey:[`launcher-budget`],queryFn:()=>Z.launcherBudget(),refetchInterval:o===`running`?5e3:!1});(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&o!==`launching`&&a()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,a]),(0,W.useEffect)(()=>{if(!m)return;let e=new EventSource(mt(`/api/bug-patterns/synthesize/jobs/${encodeURIComponent(m)}/stream`));return v.current=e,e.addEventListener(`partial`,e=>{try{_(JSON.parse(e.data))}catch{}}),e.addEventListener(`done`,t=>{try{let e=JSON.parse(t.data);_(e),s(e.status===`failed`?`failed`:`done`),e.status===`failed`&&p(e.error)}catch{s(`done`)}e.close(),Lb(null)}),e.addEventListener(`error`,()=>{p(`Stream disconnected`),s(`failed`),e.close()}),()=>{e.close(),v.current=null}},[m]),(0,W.useEffect)(()=>{(o===`configure`||o===`previewed`)&&b()},[c,e,t,n]);async function b(){p(null),d(null),s(`previewing`);try{d(await Z.synthesizePreflight({scope:e,target_id:t,mode:n,model:c})),s(`previewed`)}catch(e){p(e instanceof Error?e.message:String(e)),s(`configure`)}}async function x(){if(u?.preflight_token){s(`launching`),p(null);try{let{jobId:e,reused:t}=await Z.synthesizeRun(u.preflight_token);h(e),Lb({jobId:e,kind:`synth`}),s(`running`),t&&Q({message:`A synthesis for this target was already running. Attached to it.`,tone:`info`})}catch(e){p(e instanceof Error?e.message:String(e)),s(`previewed`)}}}async function S(){if(m)try{await Z.synthesizeCancel(m),Q({message:`Cancellation requested`,tone:`info`})}catch(e){Q({message:`Cancel failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}let C=(0,W.useMemo)(()=>g?lx(g.output_markdown):``,[g]),w=o===`configure`||o===`previewed`,T=o===`previewed`&&!!u?.preflight_token;return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&o!==`launching`&&a()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl max-w-3xl w-full max-h-[90vh] flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-line shrink-0`,children:[(0,G.jsxs)(`div`,{className:`text-sm font-semibold text-fg`,children:[`🤖 `,ux[n],`: `,r]}),(0,G.jsx)(`button`,{type:`button`,onClick:a,disabled:o===`launching`,className:`text-xs text-fg-muted hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed`,title:o===`running`?`Close this dialog. Job continues running; track progress via the badge in the top bar.`:`Close`,children:o===`running`?`run in background ↗`:`close`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4 text-sm overflow-y-auto flex-1`,children:[(o===`configure`||o===`previewing`||o===`previewed`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fx,{scope:e,mode:n,targetLabel:r}),(0,G.jsx)(px,{value:c,onChange:e=>{l(e),d(null),s(`configure`)}}),y.data&&(0,G.jsx)(mx,{budget:y.data}),o===`previewing`&&(0,G.jsx)(`div`,{className:`text-fg-muted text-sm`,children:`Computing preview…`}),u&&(0,G.jsx)(hx,{preflight:u,scope:e}),f&&(0,G.jsx)(`div`,{className:`text-error text-sm whitespace-pre-wrap break-words`,children:f})]}),(o===`launching`||o===`running`||o===`done`||o===`failed`)&&(0,G.jsxs)(G.Fragment,{children:[o===`running`&&(0,G.jsxs)(`div`,{className:`rounded-md border border-sky-400/40 bg-sky-400/10 px-3 py-2 text-sm text-fg leading-relaxed`,children:[(0,G.jsx)(`div`,{className:`font-semibold mb-0.5`,children:`↗ You can close this dialog at any time`}),(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs`,children:[`The job continues in the background. Track progress on the pulsing pill in the top bar. Use`,` `,(0,G.jsx)(`strong`,{className:`text-error`,children:`Cancel job`}),` below to stop early; closing the dialog never cancels.`]})]}),o===`launching`&&!g&&(0,G.jsx)(yx,{title:`Starting synthesis…`,subtitle:`Securing preflight token and initializing the sub-agent runner.`}),o===`running`&&g&&g.output_markdown.length===0&&(0,G.jsx)(yx,{title:`Warming up the sub-agent…`,subtitle:`The first tokens usually take 10 to 25 seconds before streaming begins.`}),g&&g.output_markdown.length>0&&(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated/40 p-4`,children:(0,G.jsx)(`div`,{className:`prose prose-sm max-w-none synthesis-markdown text-sm text-fg leading-relaxed`,dangerouslySetInnerHTML:{__html:C}})}),g&&(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[`input tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:g.input_tokens.toLocaleString()}),` · `,`output tokens:`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:g.output_tokens.toLocaleString()})]}),o===`done`&&g&&(0,G.jsx)(_x,{snapshot:g,memberSessionIds:i}),o===`failed`&&(0,G.jsx)(`div`,{className:`text-error text-sm whitespace-pre-wrap break-words`,children:f??g?.error??`Synthesis failed.`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-line shrink-0`,children:[(o===`configure`||o===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`text-sm px-3 py-1.5 text-fg-muted hover:text-fg`,children:`Cancel`}),(o===`configure`||o===`previewing`||o===`previewed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:!w||o===`previewing`,className:`text-sm px-3 py-1.5 border border-line rounded-md hover:border-accent disabled:opacity-40 disabled:cursor-not-allowed`,children:o===`previewing`?`Computing…`:`Preview cost`}),o===`previewed`&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:!T,className:`text-sm px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:`I understand, run`}),o===`running`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`text-sm px-3 py-1.5 text-fg-muted hover:text-fg`,children:`Run in background ↗`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void S(),className:`text-sm px-3 py-1.5 border border-error/60 text-error rounded-md hover:bg-error/10`,children:`Cancel job`})]}),(o===`done`||o===`failed`)&&(0,G.jsx)(`button`,{type:`button`,onClick:a,className:`text-sm px-3 py-1.5 bg-accent text-bg rounded-md font-semibold hover:opacity-90`,children:`Close`})]})]})})}function fx({scope:e,mode:t,targetLabel:n}){return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated/40 px-3 py-2 text-sm`,children:[(0,G.jsxs)(`div`,{className:`text-fg-muted text-xs uppercase tracking-wider`,children:[e===`cluster`?`Cluster`:`Project`,` · `,ux[t]]}),(0,G.jsx)(`div`,{className:`text-fg font-medium truncate`,title:n,children:n})]})}function px({value:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`block text-sm`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted mb-1`,children:`Model`}),(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full bg-bg-elevated border border-line rounded px-2 py-1.5 text-sm`,children:sx.map(e=>(0,G.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.note,`)`]},e.value))})]})}function mx({budget:e}){let t=e.spent_total_tokens_24h,n=e.daily_token_budget,r=n===0?0:Math.min(100,Math.round(t/n*100));return(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`24h budget (shared with extract-outputs)`}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[t.toLocaleString(),` / `,n.toLocaleString(),` tokens (`,r,`%)`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 bg-line rounded overflow-hidden mt-1`,children:(0,G.jsx)(`div`,{className:r>80?`h-full bg-warning`:`h-full bg-sky-400`,style:{width:`${r}%`}})})]})}function hx({preflight:e,scope:t}){let n=e.estimated_input_tokens_max+e.estimated_output_tokens_max,r=e.budget.remaining_tokens_24h;return(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated/40 p-3 space-y-3 text-sm`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Preview`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`About to synthesize across`,` `,t===`cluster`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:e.context_summary.session_count}),` `,`session`,e.context_summary.session_count===1?``:`s`,` (`,e.context_summary.findings_count,` finding`,e.context_summary.findings_count===1?``:`s`,`).`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:e.context_summary.cluster_count}),` `,`cluster`,e.context_summary.cluster_count===1?``:`s`,` (`,e.context_summary.findings_count,` finding`,e.context_summary.findings_count===1?``:`s`,`).`]})]}),e.plan_window_estimate&&(0,G.jsx)(gx,{estimate:e.plan_window_estimate}),(0,G.jsxs)(`details`,{className:`text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer hover:text-fg select-none`,children:`Request size estimate (this run, not model capacity)`}),(0,G.jsxs)(`div`,{className:`pt-2 space-y-1`,children:[(0,G.jsxs)(`div`,{children:[`This synthesis call will send up to`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_input_tokens_max.toLocaleString()}),` `,`input tokens and produce up to`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e.estimated_output_tokens_max.toLocaleString()}),` `,`output tokens.`]}),(0,G.jsx)(`div`,{className:`text-xs`,children:`For reference: Haiku 4.5 has a 200K-token context window, so this prompt fits easily. The numbers above are this request's footprint, not the model's capacity.`}),e.would_exceed_budget&&(0,G.jsxs)(`div`,{className:`text-warning`,children:[`⚠ Projected (`,n.toLocaleString(),`) exceeds remaining 24h budget (`,r.toLocaleString(),`). Wait for the rolling window or raise launcher.dailyTokenBudget in ~/.recall/config.json.`]})]})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted`,children:`Token expires in 60 seconds; click Run before then or click Preview again to refresh.`})]})}function gx({estimate:e}){if(!e)return null;let t={pro:`Pro`,"max-5x":`Max 5x`,"max-20x":`Max 20x`};return(0,G.jsxs)(`div`,{className:`space-y-1.5 text-sm`,children:[(0,G.jsxs)(`div`,{className:`text-fg`,children:[(0,G.jsx)(`strong`,{children:`Claude Code 5-hour window impact`}),` `,(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`(model multiplier: `,e.model_multiplier,`x)`]})]}),(0,G.jsx)(`div`,{className:`space-y-1`,children:e.per_plan.map(e=>{let n=e.would_exhaust_window,r=!n&&e.fraction>.5,i=Math.min(100,e.pct);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted w-20 shrink-0 text-xs`,children:t[e.plan]}),(0,G.jsx)(`div`,{className:`flex-1 h-2 bg-line rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:n?`h-full bg-warning`:r?`h-full bg-sky-400`:`h-full bg-sky-500/60`,style:{width:`${i}%`}})}),(0,G.jsxs)(`span`,{className:`tabular-nums w-16 text-right text-xs `+(n?`text-warning font-semibold`:`text-fg`),children:[e.pct>=1e3?`>1000`:e.pct.toFixed(1),`%`]})]},e.plan)})}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:[`ⓘ `,e.caveat]})]})}function _x({snapshot:e,memberSessionIds:t}){function n(e,t){navigator.clipboard.writeText(e).then(()=>Q({message:`Copied ${t}`,tone:`info`})).catch(()=>Q({message:`Failed to copy ${t}`,tone:`error`}))}let r=(0,W.useMemo)(()=>{let t=[];return t.push(`Synthesis result from Claude Recall (${e.scope}/${e.mode}):`),t.push(`Target: ${e.target_id}`),t.push(``),t.push(e.output_markdown),t.join(`
|
|
651
651
|
`)},[e]);return(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-2 border-t border-line`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(e.output_markdown,`as Markdown`),className:`text-xs px-2.5 py-1.5 border border-line rounded-md hover:border-accent text-fg`,children:`📋 Copy as Markdown`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>n(r,`as Claude context`),className:`text-xs px-2.5 py-1.5 border border-line rounded-md hover:border-accent text-fg`,children:`🤖 Copy as Claude context`}),t&&t.length===1&&(0,G.jsx)(vx,{sessionId:t[0],markdown:e.output_markdown}),e.scope===`project`&&(0,G.jsx)(`span`,{className:`text-xs text-fg-muted self-center`,children:`(project synthesis: copy to clipboard, paste where useful)`})]})}function vx({sessionId:e,markdown:t}){let[n,r]=(0,W.useState)(!1);async function i(){r(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e)}/notes`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({body:t})}),Q({message:`Saved as session note`,tone:`info`})}catch(e){Q({message:`Save failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{r(!1)}}return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void i(),disabled:n,className:`text-xs px-2.5 py-1.5 border border-line rounded-md hover:border-accent text-fg disabled:opacity-40`,children:[`💾 `,n?`Saving…`:`Save as note`]})}function yx({title:e,subtitle:t}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 py-4`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 h-5 border-2 border-line border-t-sky-400 rounded-full animate-spin shrink-0`,role:`status`,"aria-label":`loading`}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-sm text-fg font-medium`,children:e}),t&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted leading-relaxed`,children:t})]})]})}function bx(e){try{let t=Date.now()-Date.parse(e);if(!Number.isFinite(t)||t<0)return e;let n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n} min ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:e.slice(0,10)}catch{return e}}var xx={synopsis:`Synopsis`,priorities:`Fix priorities`,root_cause:`Root cause`};function Sx({scope:e,targetId:t,targetLabel:n,onClose:r}){let i=K(),[a,o]=(0,W.useState)(null),s=q({queryKey:[`bug-synthesis`,`list`,e,t],queryFn:()=>Z.listBugSynthesisResults({scope:e,target_id:t,limit:50})}),c=q({queryKey:[`bug-synthesis`,`detail`,a],queryFn:()=>a?Z.getBugSynthesisResult(a):Promise.resolve(null),enabled:!!a}),l=J({mutationFn:e=>Z.deleteBugSynthesisResult(e),onSuccess:()=>{Q({message:`Report deleted`,tone:`success`}),o(null),i.invalidateQueries({queryKey:[`bug-synthesis`]})},onError:e=>{Q({message:`Delete failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),u=s.data?.results??[];(0,W.useEffect)(()=>{a===null&&u.length>0&&o(u[0].id)},[u,a]),(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&r()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let d=(0,W.useMemo)(()=>{let e=c.data?.result?.output_markdown??``;if(!e)return``;let t=Co.parse(e,{gfm:!0,breaks:!1,async:!1});return Vs.sanitize(t)},[c.data]),f=c.data?.result??null;function p(e,t){navigator.clipboard.writeText(e).then(()=>Q({message:`Copied ${t}`,tone:`success`})).catch(()=>Q({message:`Copy failed`,tone:`error`}))}return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-xl shadow-2xl w-full max-w-5xl max-h-[88vh] flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between px-5 py-3 border-b border-line`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:`💾 Saved synthesis reports`}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-0.5`,children:[e===`project`?`Project`:`Cluster`,`:`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:n}),` ·`,` `,u.length,` report`,u.length===1?``:`s`,` saved`]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-fg-muted hover:text-fg`,children:`close`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 grid grid-cols-1 md:grid-cols-[280px_1fr] gap-0 divide-x divide-line overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`flex flex-col overflow-hidden`,children:(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,children:[s.isLoading&&(0,G.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`Loading…`}),!s.isLoading&&u.length===0&&(0,G.jsxs)(`div`,{className:`p-3 text-xs text-fg-muted leading-relaxed`,children:[`No saved reports for this `,e,` yet. Run a synthesis from the right-click menu and the result will save here automatically.`]}),u.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:`w-full text-left px-3 py-2.5 hover:bg-bg-elevated/40 border-b border-line/40 `+(a===e.id?`bg-bg-elevated/60 border-l-2 border-l-accent`:``),children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:xx[e.mode]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-0.5`,children:[bx(e.created_at),` · `,e.model.replace(/^claude-/,``)]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted tabular-nums mt-0.5`,children:[(e.input_tokens+e.output_tokens).toLocaleString(),` tokens`]})]},e.id))]})}),(0,G.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[!f&&u.length>0&&(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6 text-sm text-fg-muted`,children:`Select a report on the left to read it.`}),f&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`px-5 py-3 border-b border-line flex items-center justify-between gap-3 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:xx[f.mode]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[`Generated `,bx(f.created_at),` ·`,` `,f.model,` ·`,` `,(f.input_tokens+f.output_tokens).toLocaleString(),` `,`tokens`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(f.output_markdown,`as Markdown`),className:`text-xs px-2 py-1 border border-line rounded hover:border-accent hover:text-accent text-fg-dim`,children:`📋 Copy`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{window.confirm(`Delete this saved report? You can always re-run synthesis to regenerate.`)&&l.mutate(f.id)},className:`text-xs px-2 py-1 border border-error/60 text-error rounded hover:bg-error/10`,children:`Delete`})]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5`,children:(0,G.jsx)(`article`,{className:`prose-message prose-help max-w-none text-sm leading-relaxed`,dangerouslySetInnerHTML:{__html:d}})})]})]})]})]})})}var Cx=[`#7dd3fc`,`#a5b4fc`,`#c4b5fd`,`#67e8f9`,`#93c5fd`,`#bef264`,`#fda4af`,`#fdba74`];function wx(e,t){return Cx[t.indexOf(e)%Cx.length]??Cx[0]}function Tx(e){return 50+Math.min(20,Math.sqrt(e)*4)}function Ex(e,t){return e?e.length>t?e.slice(0,t-1)+`…`:e:``}function Dx(e){return e.length===0?`(no project)`:e.length===1?e[0]:`${e[0]} +${e.length-1}`}var Ox=5;function kx({initialProject:e=null}){let[,t]=Nn(),[n,r]=(0,W.useState)(e),[i,a]=(0,W.useState)(!0),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(null),_=q({queryKey:[`bug-synthesis`,`counts`,`project`],queryFn:()=>Z.bugSynthesisCounts(`project`)}),v=q({queryKey:[`bug-synthesis`,`counts`,`cluster`],queryFn:()=>Z.bugSynthesisCounts(`cluster`)}),y=(0,W.useMemo)(()=>{let e=new Map;for(let t of _.data?.counts??[])e.set(t.target_id,t.count);return e},[_.data]),b=(0,W.useMemo)(()=>{let e=new Map;for(let t of v.data?.counts??[])e.set(t.target_id,t.count);return e},[v.data]),[x,S]=(0,W.useState)(1),[C,w]=(0,W.useState)({x:0,y:0}),[T,E]=(0,W.useState)(!1),D=(0,W.useRef)(null);function O(e){return Math.max(.25,Math.min(4,e))}function k(){S(1),w({x:0,y:0})}function A(e){S(t=>O(t*e))}let j=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),M=q({queryKey:[`bug-patterns`,`graph`,n,i],queryFn:()=>Z.bugPatternsGraph(n??void 0,i)}),ee=(0,W.useMemo)(()=>M.data?Lx(M.data):null,[M.data]),N=(0,W.useMemo)(()=>M.data?Array.from(new Set(M.data.sessions.map(e=>e.project))).sort():[],[M.data]),te=j.data?.projects??[];if(M.isLoading)return(0,G.jsx)(`div`,{className:`p-8 text-center text-fg-muted text-sm`,children:`Loading galaxy…`});if(M.error)return(0,G.jsxs)(`div`,{className:`p-8 text-center text-error text-sm`,children:[`Failed to load:`,` `,M.error instanceof Error?M.error.message:String(M.error)]});if(!M.data||!ee)return null;let P=M.data,{width:F,height:I,nodes:L,regions:R}=ee,z=P.totals.cluster_count===0,B=o&&P.clusters.find(e=>e.id===o),V=o&&P.sessions.find(e=>e.session_id===o),ne=c&&P.clusters.find(e=>e.id===c);return(0,G.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-line shrink-0 flex-wrap`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim`,children:[`project`,(0,G.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value===``?null:e.target.value),className:`bg-bg-elevated border border-line rounded px-2 py-1 text-sm`,children:[(0,G.jsx)(`option`,{value:``,children:`all projects`}),te.filter(e=>e.extracted_sessions>0).map(e=>(0,G.jsx)(`option`,{value:e.project,children:e.project},e.project))]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm text-fg-dim cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`show resolved clusters`]}),(0,G.jsxs)(`div`,{className:`ml-auto text-sm text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:P.totals.cluster_count}),` `,`cluster`,P.totals.cluster_count===1?``:`s`,` ·`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:P.totals.recurring_count}),` `,`recurring ·`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:P.totals.singleton_count}),` `,`singletons ·`,` `,(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:P.totals.session_count}),` `,`session`,P.totals.session_count===1?``:`s`]})]}),(0,G.jsxs)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden bg-bg`,children:[z?(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,G.jsxs)(`div`,{className:`text-center max-w-md p-6 space-y-3 text-sm`,children:[(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:`Nothing to visualize yet`}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed`,children:[`The galaxy renders extracted bug findings (clusters and singletons). Run extract-outputs on a few projects, then run`,` `,(0,G.jsx)(`code`,{className:`text-fg-dim`,children:`recall infer-bug-patterns`}),` `,`to populate this view.`]})]})}):(0,G.jsxs)(`svg`,{ref:u,viewBox:`0 0 ${F} ${I}`,preserveAspectRatio:`xMidYMid meet`,className:`w-full h-full select-none`,style:{cursor:T?`grabbing`:`grab`},onWheel:e=>{e.preventDefault();let t=Math.min(.05,Math.abs(e.deltaY)*5e-4);A(e.deltaY>0?1-t:1+t)},onMouseDown:e=>{e.button===0&&(D.current={x:e.clientX,y:e.clientY,panX:C.x,panY:C.y,moved:!1},E(!0))},onMouseMove:e=>{if(!D.current||!u.current)return;let t=u.current.getBoundingClientRect(),n=e.clientX-D.current.x,r=e.clientY-D.current.y;!D.current.moved&&(Math.abs(n)>3||Math.abs(r)>3)&&(D.current.moved=!0);let i=n*F/t.width,a=r*I/t.height;w({x:D.current.panX+i/x,y:D.current.panY+a/x})},onMouseUp:()=>{D.current=null,E(!1)},onMouseLeave:()=>{D.current=null,E(!1)},children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`bg-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`5`,markerHeight:`5`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-line`})})}),(0,G.jsxs)(`g`,{transform:`translate(${F/2+C.x*x}, ${I/2+C.y*x}) scale(${x}) translate(${-F/2}, ${-I/2})`,children:[R.map(e=>(0,G.jsxs)(`g`,{onContextMenu:t=>{if(t.preventDefault(),t.stopPropagation(),!u.current)return;let n=u.current.getBoundingClientRect();f({target:{kind:`region`,project:e.project,clusterCount:e.cluster_count},x:t.clientX-n.left,y:t.clientY-n.top})},children:[(0,G.jsx)(`rect`,{x:e.cx-e.w/2,y:e.cy-e.h/2,width:e.w,height:e.h,rx:16,ry:16,fill:`rgba(56, 189, 248, 0.04)`,stroke:`rgba(56, 189, 248, 0.2)`,strokeWidth:1.5,strokeDasharray:`6 6`}),(0,G.jsx)(`text`,{x:e.cx,y:e.cy-e.h/2+28,textAnchor:`middle`,className:`fill-fg text-[16px] font-bold pointer-events-none`,children:e.project}),(0,G.jsxs)(`text`,{x:e.cx,y:e.cy-e.h/2+46,textAnchor:`middle`,className:`fill-fg-muted text-[11px] pointer-events-none`,children:[e.cluster_count,` bug`,e.cluster_count===1?``:`s`]})]},`region-${e.project}`)),P.related_edges.map((e,t)=>{let n=L.get(e.a),r=L.get(e.b);return!n||!r?null:(0,G.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`#94a3b8`,strokeOpacity:.65,strokeWidth:2,strokeDasharray:`6 5`},`rel-${t}`)}),P.member_edges.map((e,t)=>{let n=L.get(e.cluster_id),r=L.get(e.session_id);return!n||!r?null:(0,G.jsx)(`line`,{x1:n.x,y1:n.y,x2:r.x,y2:r.y,stroke:`#38bdf8`,strokeOpacity:.55,strokeWidth:1.75,strokeLinecap:`round`},`mem-${t}`)}),P.sessions.map(e=>{let n=L.get(e.session_id);if(!n)return null;let r=wx(e.project,N),i=o===e.session_id;return(0,G.jsx)(`g`,{onMouseEnter:()=>s(e.session_id),onMouseLeave:()=>s(null),onMouseDown:e=>e.stopPropagation(),onClick:()=>t({session:e.session_id,view:null}),className:`cursor-pointer`,children:(0,G.jsx)(`circle`,{cx:n.x,cy:n.y,r:i?7:Ox,fill:r,fillOpacity:.85,stroke:r,strokeWidth:i?2:1})},e.session_id)}),P.clusters.map(e=>{let t=L.get(e.id);if(!t)return null;let n=o===e.id,r=c===e.id,i=60+Math.min(20,Math.sqrt(e.occurrence_count)*6),a=t.x-180/2,d=t.y-i/2,p=Dx(e.projects),m=Ex(e.snippet,36),h=e.error_type&&e.error_type!==`unknown`?e.error_type:null;return(0,G.jsxs)(`g`,{onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),onMouseDown:e=>e.stopPropagation(),onContextMenu:t=>{if(t.preventDefault(),t.stopPropagation(),!u.current)return;let n=u.current.getBoundingClientRect();f({target:{kind:`cluster`,cluster:e},x:t.clientX-n.left,y:t.clientY-n.top})},onClick:()=>l(r?null:e.id),className:`cursor-pointer`,children:[(0,G.jsx)(`rect`,{x:a,y:d,width:180,height:i,rx:8,ry:8,fill:`#0f172a`}),(0,G.jsx)(`rect`,{x:a,y:d,width:180,height:i,rx:8,ry:8,fill:e.resolved?`rgba(15, 23, 42, 0.0)`:`rgba(56, 189, 248, 0.18)`,stroke:e.resolved?`#475569`:`#38bdf8`,strokeWidth:n||r?2.5:1.5,strokeDasharray:e.resolved?`5 4`:void 0}),(0,G.jsx)(`rect`,{x:a+6,y:d+6,width:e.occurrence_count>=100?36:e.occurrence_count>=10?30:24,height:16,rx:4,fill:e.resolved?`rgba(71, 85, 105, 0.4)`:`#38bdf8`}),(0,G.jsxs)(`text`,{x:a+6+(e.occurrence_count>=100?18:e.occurrence_count>=10?15:12),y:d+17,textAnchor:`middle`,className:`text-[10px] font-bold pointer-events-none `+(e.resolved?`fill-fg-muted`:`fill-bg`),children:[e.occurrence_count,`×`]}),e.resolved?(0,G.jsx)(`text`,{x:a+180-8,y:d+17,textAnchor:`end`,className:`fill-accent text-[10px] font-semibold pointer-events-none`,children:`✓ fixed`}):h?(0,G.jsx)(`text`,{x:a+180-8,y:d+17,textAnchor:`end`,className:`fill-warning text-[10px] font-mono pointer-events-none`,children:Ex(h,16)}):null,(0,G.jsx)(`text`,{x:t.x,y:d+36,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold pointer-events-none`,children:Ex(p,28)}),m&&(0,G.jsx)(`text`,{x:t.x,y:d+50,textAnchor:`middle`,className:`fill-fg-muted text-[10px] pointer-events-none`,children:m})]},e.id)})]})]}),!z&&(0,G.jsxs)(`div`,{className:`absolute bottom-3 right-3 bg-bg/90 border border-line rounded-lg p-1 flex flex-col items-stretch gap-0.5 backdrop-blur shadow-lg`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>A(1.2),title:`Zoom in`,className:`px-2 py-1 text-sm font-bold text-fg-dim hover:text-fg hover:bg-bg-elevated rounded`,children:`+`}),(0,G.jsxs)(`div`,{className:`text-[10px] text-fg-muted tabular-nums text-center px-1`,children:[Math.round(x*100),`%`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>A(.83),title:`Zoom out`,className:`px-2 py-1 text-sm font-bold text-fg-dim hover:text-fg hover:bg-bg-elevated rounded`,children:`−`}),(0,G.jsx)(`button`,{type:`button`,onClick:k,title:`Reset zoom and pan`,className:`px-2 py-1 text-xs text-fg-dim hover:text-fg hover:bg-bg-elevated rounded mt-0.5 border-t border-line/50`,children:`⟲`})]}),(B||ne||V)&&(0,G.jsxs)(`div`,{className:`absolute top-3 right-3 max-w-sm bg-bg border border-line rounded-lg shadow-lg p-4 text-sm space-y-2 pointer-events-none`,children:[(B||ne)&&(0,G.jsx)(Ax,{cluster:B||ne}),V&&!B&&!ne&&(0,G.jsx)(jx,{session:V})]}),(0,G.jsx)(Ix,{}),d&&(0,G.jsx)(Mx,{target:d.target,x:d.x,y:d.y,onClose:()=>f(null),onNavigate:e=>{t({q:``,view:null}),r(e),f(null)},onOpenSession:e=>{t({session:e,view:null}),f(null)},onSynthesize:e=>{m(e),f(null)},onViewSavedReports:e=>{g(e),f(null)},savedCountsByProject:y,savedCountsByCluster:b}),p&&(0,G.jsx)(dx,{scope:p.scope,targetId:p.targetId,mode:p.mode,targetLabel:p.targetLabel,memberSessionIds:p.memberSessionIds,onClose:()=>m(null)}),h&&(0,G.jsx)(Sx,{scope:h.scope,targetId:h.targetId,targetLabel:h.targetLabel,onClose:()=>g(null)})]})]})}function Ax({cluster:e}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`font-semibold text-fg`,children:[e.occurrence_count,`× cluster`]}),e.resolved&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 bg-accent/15 text-accent border border-accent/40 rounded font-medium`,children:`✓ fixed`}),e.error_type&&e.error_type!==`unknown`&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 bg-warning/10 text-warning border border-warning/40 rounded font-mono`,children:e.error_type})]}),e.snippet&&(0,G.jsx)(`div`,{className:`text-fg leading-relaxed`,children:e.snippet}),e.file&&(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted font-mono break-all`,children:[`📄 `,e.file]}),e.fix_summary&&(0,G.jsxs)(`div`,{className:`text-xs text-accent border-l-2 border-accent/40 pl-2`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Fix:`}),` `,e.fix_summary]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted pt-1 border-t border-line`,children:[e.projects.length,` project`,e.projects.length===1?``:`s`,`:`,` `,e.projects.join(`, `)]}),e.message_hash&&(0,G.jsxs)(`div`,{className:`text-xs font-mono text-fg-muted`,children:[`id: `,e.message_hash]})]})}function jx({session:e}){return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.auto_title??e.session_id.slice(0,8)}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bg-elevated rounded border border-line/50 font-medium mr-2`,children:e.project}),(0,G.jsx)(`span`,{className:`font-mono`,children:e.session_id.slice(0,8)})]})]})}function Mx({target:e,x:t,y:n,onClose:r,onNavigate:i,onOpenSession:a,onSynthesize:o,onViewSavedReports:s,savedCountsByProject:c,savedCountsByCluster:l}){(0,W.useEffect)(()=>{function e(e){e.key===`Escape`&&r()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);function u(e,t){navigator.clipboard.writeText(e).then(()=>showToast({message:`Copied ${t}`,tone:`success`})).catch(()=>showToast({message:`Copy failed`,tone:`error`}))}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-40`,onMouseDown:e=>{e.stopPropagation(),r()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),r()}}),(0,G.jsxs)(`div`,{className:`absolute z-50 min-w-[320px] max-w-[440px] bg-bg border border-line rounded-lg shadow-2xl overflow-hidden`,style:{left:t,top:n},onMouseDown:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[e.kind===`region`&&(0,G.jsx)(Nx,{project:e.project,clusterCount:e.clusterCount,onNavigate:i,onCopy:u,onClose:r,onSynthesize:o,savedReportCount:c.get(e.project)??0,onViewSavedReports:()=>s({scope:`project`,targetId:e.project,targetLabel:e.project})}),e.kind===`cluster`&&(0,G.jsx)(Px,{cluster:e.cluster,onOpenSession:a,onCopy:u,onClose:r,onSynthesize:o,savedReportCount:e.cluster.message_hash?l.get(e.cluster.message_hash)??0:0,onViewSavedReports:()=>e.cluster.message_hash&&s({scope:`cluster`,targetId:e.cluster.message_hash,targetLabel:e.cluster.snippet.slice(0,60)||`cluster ${e.cluster.id.slice(0,8)}`})})]})]})}function Nx({project:e,clusterCount:t,onNavigate:n,onCopy:r,onClose:i,onSynthesize:a,savedReportCount:o,onViewSavedReports:s}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line bg-bg-elevated/40`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-fg-muted font-medium`,children:`Project`}),(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg break-words`,children:e}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t,` bug`,t===1?``:`s`]})]}),(0,G.jsxs)(`div`,{className:`py-1 text-sm`,children:[(0,G.jsx)(Fx,{icon:`📋`,label:`View all bugs in this repo`,hint:`Switch to the All Findings tab, filtered to this project`,onClick:()=>n(e)}),(0,G.jsx)(Fx,{icon:`🔗`,label:`Copy project name`,hint:`Useful for piping into a CLI command`,onClick:()=>{r(e,`project name`),i()}}),(0,G.jsx)(Fx,{icon:`⌨`,label:`Copy CLI extract command`,hint:`recall extract-outputs --project "${e}"`,onClick:()=>{r(`recall extract-outputs --project "${e}"`,`CLI command`),i()}})]}),(0,G.jsxs)(`div`,{className:`py-1 border-t border-line text-sm`,children:[(0,G.jsx)(Fx,{icon:`🤖`,label:`Synthesize all bugs in ${e}`,hint:`LLM-powered repo-wide bug synopsis`,onClick:()=>a({scope:`project`,targetId:e,mode:`priorities`,targetLabel:e})}),(0,G.jsx)(Fx,{icon:`🧠`,label:`Suggest fix priorities`,hint:`Rank bugs by severity and recurrence`,onClick:()=>a({scope:`project`,targetId:e,mode:`priorities`,targetLabel:e})}),o>0&&(0,G.jsx)(Fx,{icon:`💾`,label:`View saved reports (${o})`,hint:`Browse past synthesis runs without re-spending tokens`,onClick:s})]})]})}function Px({cluster:e,onOpenSession:t,onCopy:n,onClose:r,onSynthesize:i,savedReportCount:a,onViewSavedReports:o}){let s=e.member_session_ids,c=s.length===1;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 border-b border-line bg-bg-elevated/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs uppercase tracking-wider text-fg-muted font-medium`,children:[e.occurrence_count,`× cluster`]}),e.resolved&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 bg-accent/15 text-accent border border-accent/40 rounded`,children:`✓ fixed`})]}),(0,G.jsx)(`div`,{className:`text-sm font-semibold text-fg line-clamp-2`,children:e.snippet||`(no snippet)`}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted mt-0.5`,children:[e.projects.length,` project`,e.projects.length===1?``:`s`,` ·`,` `,s.length,` session`,s.length===1?``:`s`]})]}),(0,G.jsxs)(`div`,{className:`py-1 text-sm`,children:[s.length>0&&(0,G.jsx)(Fx,{icon:`↗`,label:c?`Open the originating session`:`Open first session (of ${s.length})`,hint:s[0].slice(0,8),onClick:()=>{t(s[0])}}),(0,G.jsx)(Fx,{icon:`📋`,label:`Copy snippet`,hint:`The bug description text`,onClick:()=>{n(e.snippet,`snippet`),r()}}),e.file&&(0,G.jsx)(Fx,{icon:`📁`,label:`Copy file path`,hint:e.file,onClick:()=>{n(e.file,`file path`),r()}}),e.message_hash&&(0,G.jsx)(Fx,{icon:`🔗`,label:`Copy finding reference ID`,hint:`recall://finding/${e.message_hash}`,onClick:()=>{n(`recall://finding/${e.message_hash}`,`reference ID`),r()}}),(0,G.jsx)(Fx,{icon:`🤖`,label:`Copy as Claude context`,hint:`Multi-line block to paste into a new claude session`,onClick:()=>{let t=[`Bug finding from a past Claude Code session:`];e.error_type&&e.error_type!==`unknown`&&t.push(`Type: ${e.error_type}`),e.snippet&&t.push(`Description: ${e.snippet}`),e.file&&t.push(`File: ${e.file}`),t.push(`Occurrences: ${e.occurrence_count} session${e.occurrence_count===1?``:`s`}`),t.push(`Projects: ${e.projects.join(`, `)}`),e.message_hash&&t.push(`Finding ID: ${e.message_hash}`),n(t.join(`
|
|
652
|
-
`),`cluster as context`),r()}})]}),!c&&s.length>1&&(0,G.jsxs)(`div`,{className:`border-t border-line bg-bg-elevated/30 max-h-48 overflow-y-auto`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-xs uppercase tracking-wider text-fg-muted font-medium`,children:`Member sessions`}),s.slice(0,12).map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`w-full text-left px-3 py-1.5 text-xs font-mono text-fg-dim hover:text-accent hover:bg-bg-elevated/60`,children:e.slice(0,8)},e)),s.length>12&&(0,G.jsxs)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:[`… and `,s.length-12,` more`]})]}),(0,G.jsxs)(`div`,{className:`py-1 border-t border-line text-sm`,children:[(0,G.jsx)(Fx,{icon:`🤖`,label:c?`Synthesize this finding`:`Synthesize this bug across ${s.length} sessions`,hint:`LLM-powered cross-session bug analysis`,onClick:()=>i({scope:`cluster`,targetId:e.id,mode:`synopsis`,targetLabel:e.snippet||e.id.slice(0,12),memberSessionIds:e.member_session_ids})}),(0,G.jsx)(Fx,{icon:`🧠`,label:`Suggest the root cause`,hint:`Pattern-aware diagnosis`,onClick:()=>i({scope:`cluster`,targetId:e.id,mode:`root_cause`,targetLabel:e.snippet||e.id.slice(0,12),memberSessionIds:e.member_session_ids})}),a>0&&(0,G.jsx)(Fx,{icon:`💾`,label:`View saved reports (${a})`,hint:`Browse past synthesis runs without re-spending tokens`,onClick:o})]})]})}function Fx({icon:e,label:t,hint:n,onClick:r,disabled:i,comingSoon:a}){return(0,G.jsxs)(`button`,{type:`button`,disabled:i,onClick:r,title:a??n,className:`w-full text-left px-3 py-2 flex items-start gap-3 ${i?`opacity-50 cursor-not-allowed`:`hover:bg-bg-elevated/60 cursor-pointer`}`,children:[(0,G.jsx)(`span`,{className:`text-base shrink-0 mt-0.5`,"aria-hidden":!0,children:e}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`span`,{className:`block text-sm text-fg font-medium leading-snug break-words`,children:t}),n&&(0,G.jsx)(`span`,{className:`block text-xs text-fg-muted truncate`,children:n}),a&&(0,G.jsxs)(`span`,{className:`block text-[10px] text-warning mt-0.5`,children:[`⏳ `,a]})]})]})}function Ix(){let[e,t]=(0,W.useState)(!0);return(0,G.jsxs)(`div`,{className:`absolute bottom-3 left-3 bg-bg/95 border border-line rounded-lg backdrop-blur shadow-lg max-w-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 text-sm font-semibold text-fg hover:bg-bg-elevated/40`,children:[(0,G.jsx)(`span`,{children:`Legend`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:e?`▾`:`▸`})]}),e&&(0,G.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-2.5 text-xs leading-relaxed`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Counts`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`N×`}),` = the bug occurred in N past sessions. `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`1×`}),` means it has only been seen once (a singleton).`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`5×`}),` means five sessions hit the same fingerprint (a real recurring pattern).`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Shapes`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-3 rounded-sm bg-sky-400/30 border border-sky-400 mt-0.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Cluster card`}),`: a unique bug. Project name on top, snippet below.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-3 rounded-sm border border-fg-muted mt-0.5 shrink-0`,style:{borderStyle:`dashed`}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Dashed card`}),`: cluster marked as fixed.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full bg-cyan-300 mt-1 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Session dot`}),`: one Claude Code session that hit this bug. Tinted by its project. Click to open the transcript.`]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Regions`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Each `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`dashed-outline box`}),` `,`groups bugs from one project. Cross-project related-edges span between regions.`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Edges`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mt-2 shrink-0`,style:{borderTop:`2px solid #38bdf8`,opacity:.55}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Cyan line`}),`: cluster ↔ its sessions.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mt-2 shrink-0`,style:{borderTop:`2px dashed #94a3b8`,opacity:.65}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Gray dashed`}),`: clusters that share an error_type or file.`]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Controls`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Scroll to zoom. Drag empty space to pan. Click any card or session for details.`})]})]})]})}function Lx(e){let t=new Map,n=new Map,r=new Map;for(let t of e.clusters){let e=t.projects[0]??`(no project)`,n=r.get(e);n?n.push(t):r.set(e,[t])}let i=Array.from(r.entries()).sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0])),a=i.length,o=Math.max(1,Math.ceil(Math.sqrt(a)));function s(e){let t=Math.max(1,Math.ceil(Math.sqrt(e))),n=Math.max(1,Math.ceil(e/t));return{w:t*200+(t-1)*60+100,h:n*230+(n-1)*80+100+32,subCols:t,subRows:n}}let c=i.map(([e,t])=>({project:e,clusters:t,...s(t.length)})),l=Array(o).fill(0),u=[];c.forEach((e,t)=>{let n=t%o,r=Math.floor(t/o);e.w>l[n]&&(l[n]=e.w),u[r]===void 0&&(u[r]=0),e.h>u[r]&&(u[r]=e.h)});function d(e){let t=80;for(let n=0;n<e;n+=1)t+=l[n]+80;return t}function f(e){let t=80;for(let n=0;n<e;n+=1)t+=u[n]+80;return t}let p=l.reduce((e,t)=>e+t,0)+80*(o+1),m=u.reduce((e,t)=>e+t,0)+80*(u.length+1),h=Math.max(1200,p),g=Math.max(700,m),_=[];c.forEach((e,r)=>{let i=r%o,a=Math.floor(r/o),s=d(i),c=f(a),p=l[i],m=u[a];_.push({project:e.project,cx:s+p/2,cy:c+m/2,w:p,h:m,cluster_count:e.clusters.length});let h=s+50+100,g=c+50+32+45;e.clusters.forEach((r,i)=>{let a=i%e.subCols,o=Math.floor(i/e.subCols),s=h+a*260,c=g+o*310;t.set(r.id,{id:r.id,kind:`cluster`,x:s,y:c,vx:0,vy:0,radius:Tx(r.occurrence_count),fixed:!0}),n.set(r.id,{cluster:r})})});let v=new Map;for(let t of e.member_edges){let e=v.get(t.cluster_id);e?e.push(t.session_id):v.set(t.cluster_id,[t.session_id])}let y=new Set;for(let[r,i]of v){let a=t.get(r);if(!a)continue;let o=i.length;i.forEach((r,i)=>{if(y.has(r))return;y.add(r);let s=Math.PI/2+(i/Math.max(1,o)-.5)*Math.PI*.9,c=e.sessions.find(e=>e.session_id===r);t.set(r,{id:r,kind:`session`,x:a.x+Math.cos(s)*70,y:a.y+Math.sin(s)*70,vx:0,vy:0,radius:Ox}),c&&n.set(r,{session:c})})}for(let r of e.sessions)t.has(r.session_id)||(t.set(r.session_id,{id:r.session_id,kind:`session`,x:h/2,y:g/2,vx:0,vy:0,radius:Ox}),n.set(r.session_id,{session:r}));for(let e=0;e<30;e+=1){let e=Array.from(t.values()).filter(e=>e.kind===`cluster`),n=!1;for(let t=0;t<e.length;t+=1)for(let r=t+1;r<e.length;r+=1){let i=e[t],a=e[r],o=a.x-i.x,s=a.y-i.y,c=216-Math.abs(o),l=106-Math.abs(s);if(c>0&&l>0){if(c<l){let e=c/2*(o>=0?1:-1);i.x-=e,a.x+=e}else{let e=l/2*(s>=0?1:-1);i.y-=e,a.y+=e}n=!0}}if(!n)break}for(let n of e.member_edges){let e=t.get(n.cluster_id),r=t.get(n.session_id);if(!e||!r)continue;let i=r.x-e.x,a=r.y-e.y,o=114+r.radius,s=59+r.radius,c=o-Math.abs(i),l=s-Math.abs(a);c>0&&l>0&&(c<l?r.x=e.x+(i>=0?o:-o):r.y=e.y+(a>=0?s:-s))}return{width:h,height:g,nodes:t,nodeMeta:n,regions:_}}function Rx(e){return e.slice(0,8)}function zx(e){if(!e)return`—`;try{return new Date(e).toISOString().slice(0,10)}catch{return e}}function Bx(){let e=K(),[,t]=Nn(),[n,r]=(0,W.useState)(`clusters`),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.useState)(3),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(new Set),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(null),v=q({queryKey:[`bug-patterns`,i,o],queryFn:()=>Z.listBugPatterns({minCount:o,status:i,limit:200})}),y=q({queryKey:[`bug-patterns`,`detail`,c],queryFn:()=>c?Z.getBugPattern(c):Promise.resolve(null),enabled:!!c}),b=J({mutationFn:e=>Z.resolveBugPattern(e.clusterId,e.sessionId,e.fixSummary),onSuccess:()=>{Q({message:`Cluster marked resolved`,tone:`success`}),p(null),h(``),e.invalidateQueries({queryKey:[`bug-patterns`]})},onError:e=>{Q({message:`Resolve failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),x=J({mutationFn:e=>Z.splitBugPattern(e.clusterId,e.memberSessionIds),onSuccess:()=>{Q({message:`Cluster split`,tone:`success`}),_(null),d(new Set),e.invalidateQueries({queryKey:[`bug-patterns`]})},onError:e=>{Q({message:`Split failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),S=v.data?.clusters??[],C=v.data?.total??0,w=y.data?.cluster??null,T=y.data?.members??[],E=(0,W.useMemo)(()=>{let e=new Set;for(let t of T)t.project&&e.add(t.project);return Array.from(e).sort()},[T]);function D(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function O(e){t({session:e,view:null})}return(0,G.jsxs)(`div`,{className:`h-full flex flex-col text-sm overflow-hidden`,children:[(0,G.jsx)(tx,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-4 pt-2 border-b border-line shrink-0`,children:[(0,G.jsx)(Wx,{active:n===`clusters`,onClick:()=>r(`clusters`),label:`Clusters`,hint:`Recurring bugs across sessions (≥ min-count)`}),(0,G.jsx)(Wx,{active:n===`findings`,onClick:()=>r(`findings`),label:`All findings`,hint:`Every bug signature extracted, including singletons`}),(0,G.jsx)(Wx,{active:n===`galaxy`,onClick:()=>r(`galaxy`),label:`🌌 Galaxy`,hint:`Force-directed visualization of bug clusters and the sessions that hit them`})]}),n===`findings`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(ix,{})}),n===`galaxy`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,"data-share-capture":`patterns-graph`,children:(0,G.jsx)(kx,{})}),n===`clusters`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-line shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-fg-dim`,children:[`status`,(0,G.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`bg-bg-elevated border border-line rounded px-1.5 py-1 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),(0,G.jsx)(`option`,{value:`open`,children:`open`}),(0,G.jsx)(`option`,{value:`resolved`,children:`resolved`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-fg-dim`,children:[`min count`,(0,G.jsx)(`input`,{type:`number`,min:2,value:o,onChange:e=>s(Math.max(2,Math.floor(Number(e.target.value)||3))),className:`bg-bg-elevated border border-line rounded px-1.5 py-1 w-16 text-xs`})]}),(0,G.jsx)(`div`,{className:`ml-auto text-xs text-fg-muted`,children:v.isLoading?`Loading…`:`${S.length} of ${C} cluster${C===1?``:`s`}`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[!v.isLoading&&S.length===0&&(0,G.jsx)(Gx,{minCount:o}),S.map(e=>(0,G.jsx)(Vx,{cluster:e,expanded:c===e.id,onToggle:()=>{l(c===e.id?null:e.id),d(new Set)},children:c===e.id&&(0,G.jsx)(Hx,{cluster:w??e,members:T,loading:y.isLoading,projects:E,selected:u,onToggleSelected:D,onClearSelected:()=>d(new Set),onOpenSession:O,onMarkResolved:(t,n)=>{p({clusterId:e.id,sessionId:t,sessionTitle:n}),h(``)},onSplit:t=>_({clusterId:e.id,memberSessionIds:t})})},e.id))]})]}),f&&(0,G.jsxs)(Ux,{onClose:()=>p(null),children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:`Mark fix as working`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-dim mb-3`,children:[`Attach `,(0,G.jsx)(`span`,{className:`text-accent`,children:f.sessionTitle}),` as the fix that resolved this bug pattern. Future occurrences will surface this session as the recommended remedy.`]}),(0,G.jsx)(`label`,{className:`block text-xs text-fg-dim mb-1`,children:`Fix summary`}),(0,G.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:`e.g. wrapped the optional chain with a typeof check; root cause was an async race`,className:`w-full bg-bg-elevated border border-line rounded p-2 text-xs h-24 mb-3 focus:outline-none focus:border-accent`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(null),className:`text-xs px-3 py-1.5 border border-line rounded text-fg-dim hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,disabled:!m.trim()||b.isPending,onClick:()=>{f&&b.mutate({...f,fixSummary:m})},className:`text-xs px-3 py-1.5 rounded bg-accent text-bg font-medium disabled:opacity-50 disabled:cursor-not-allowed`,children:b.isPending?`Saving…`:`Mark fix worked`})]})]}),g&&(0,G.jsxs)(Ux,{onClose:()=>_(null),children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:`Split cluster`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-dim mb-3`,children:[`Move `,g.memberSessionIds.length,` member`,g.memberSessionIds.length===1?``:`s`,` into a new cluster. The original retains the rest. Both clusters keep the same`,` `,(0,G.jsx)(`code`,{children:`signature_hash`}),` and can be marked resolved independently.`]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>_(null),className:`text-xs px-3 py-1.5 border border-line rounded text-fg-dim hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,disabled:x.isPending,onClick:()=>x.mutate(g),className:`text-xs px-3 py-1.5 rounded bg-accent text-bg font-medium disabled:opacity-50`,children:x.isPending?`Splitting…`:`Split off`})]})]})]})}function Vx({cluster:e,expanded:t,onToggle:n,children:r}){let i=e.resolved_in_session_id?`resolved`:`open`;return(0,G.jsxs)(`div`,{className:`border-b border-line`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`w-full px-4 py-3 flex items-start gap-3 hover:bg-bg-elevated text-left`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5 w-4 shrink-0`,children:t?`▾`:`▸`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded uppercase font-semibold tracking-wide `+(i===`resolved`?`bg-emerald-500/20 text-emerald-300`:`bg-red-500/20 text-red-300`),children:i===`resolved`?`✓ resolved`:`open`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.occurrence_count,` occurrence`,e.occurrence_count===1?``:`s`]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`first `,zx(e.first_seen_at),` →`,` `,zx(e.last_seen_at)]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`·`}),(0,G.jsx)(`code`,{className:`text-[10px] text-fg-muted`,children:e.signature_hash.slice(0,8)})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg leading-snug truncate`,title:e.example_message,children:e.example_message||(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`(no message)`})}),i===`resolved`&&e.fix_summary&&(0,G.jsxs)(`div`,{className:`text-[11px] text-emerald-300/80 mt-1 truncate`,title:e.fix_summary,children:[`fix: `,e.fix_summary]})]})]}),r]})}function Hx({cluster:e,members:t,loading:n,projects:r,selected:i,onToggleSelected:a,onClearSelected:o,onOpenSession:s,onMarkResolved:c,onSplit:l}){let u=!!e.resolved_in_session_id,d=i.size>0&&i.size<t.length;return(0,G.jsxs)(`div`,{className:`px-4 pb-4 pl-11 bg-bg-elevated/40`,children:[r.length>1&&(0,G.jsxs)(`div`,{className:`text-[11px] text-amber-300/80 mb-2`,children:[`🌐 cross-project — appears in `,r.length,` projects:`,` `,r.join(`, `)]}),n&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted py-2`,children:`Loading members…`}),!n&&t.length===0&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted py-2`,children:`No members.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!d,onClick:()=>l(Array.from(i)),className:`text-[11px] px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-accent disabled:opacity-40 disabled:cursor-not-allowed`,title:`Move selected members into a new cluster`,children:i.size>0?`Split off ${i.size} member${i.size===1?``:`s`}`:`Select members to split`}),i.size>0&&(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-[11px] text-fg-muted hover:text-fg`,children:`clear`})]}),(0,G.jsx)(`ul`,{className:`space-y-1`,children:t.map(t=>{let n=e.resolved_in_session_id===t.session_id,r=i.has(t.session_id);return(0,G.jsxs)(`li`,{className:`flex items-start gap-2 py-1 px-2 rounded `+(n?`bg-emerald-500/10`:``),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>a(t.session_id),className:`mt-1 shrink-0`,disabled:u,title:u?`Cannot split resolved cluster`:`Select for split`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(t.session_id),className:`text-xs text-fg hover:text-accent text-left truncate w-full`,title:t.session_id,children:[t.project&&(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`[`,t.project,`] `]}),t.title,(0,G.jsxs)(`span`,{className:`text-fg-muted ml-1`,children:[`(`,Rx(t.session_id),`)`]})]}),t.started_at&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:zx(t.started_at)})]}),n&&(0,G.jsx)(`span`,{className:`text-[10px] text-emerald-300 self-center`,children:`✓ fix`}),!u&&!n&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(t.session_id,t.title),className:`text-[10px] px-1.5 py-0.5 border border-line rounded text-fg-muted hover:text-emerald-300 hover:border-emerald-500/40 self-center shrink-0`,title:`Mark this session's fix as the resolution for this cluster`,children:`Mark fix worked`})]},t.session_id)})})]})}function Ux({onClose:e,children:t}){return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e,children:(0,G.jsx)(`div`,{className:`bg-bg border border-line rounded-lg p-4 max-w-md w-full`,onClick:e=>e.stopPropagation(),children:t})})}function Wx({active:e,onClick:t,label:n,hint:r}){return(0,G.jsx)(`button`,{type:`button`,onClick:t,title:r,className:`px-4 py-2 text-sm font-medium rounded-t-md border-b-2 transition-colors `+(e?`text-fg border-accent bg-bg-elevated/40`:`text-fg-muted hover:text-fg border-transparent hover:bg-bg-elevated/20`),children:n})}function Gx({minCount:e}){let{data:t}=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),n=t?.totals,r=(t?.projects??[]).filter(e=>e.extracted_sessions>0).length,i=n?.extracted_sessions??0;return(0,G.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6 space-y-6`,children:[(0,G.jsx)(Jx,{}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`What is a cluster?`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted leading-relaxed`,children:`A cluster is a group of past Claude Code sessions that all hit the same bug fingerprint. Recall recognizes when the same error shape, snippet, and file pattern shows up across multiple sessions, and groups them so you can deal with them as one unit instead of N separate findings.`})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Why clusters earn their own tab`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm`,children:[(0,G.jsx)(Kx,{icon:`🔁`,title:`Recurrence detection`,body:`Five sessions hit the same NPE? Cluster forms. You see "this is a pattern", not just a bunch of disconnected findings.`}),(0,G.jsx)(Kx,{icon:`🔧`,title:`Linked fix forever`,body:`Mark one member "this fix worked". Every future occurrence of the same fingerprint surfaces the fix automatically.`}),(0,G.jsx)(Kx,{icon:`🌐`,title:`Cross-project visibility`,body:`Same auth bug in three different repos clusters together so you can see it as one concern, not three.`}),(0,G.jsx)(Kx,{icon:`📊`,title:`Top-of-list ranking`,body:`Clusters sort by occurrence count. Your worst-recurring bugs surface first, automatically.`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Why you have zero clusters right now`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated/30 p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Sessions extracted across all projects`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:i})]}),(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Projects with at least one extraction`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:r})]}),(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Current cluster threshold (min-count)`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed border-t border-line pt-2 mt-2`,children:[`For a cluster to form, the `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`same fingerprint`}),` must appear in `,(0,G.jsxs)(`strong`,{className:`text-fg`,children:[`at least `,e,` sessions`]}),`. With`,` `,i===0?`no extractions yet`:`only ${i} session${i===1?``:`s`} extracted`,r<=1?` from a single project`:` across ${r} projects`,`, there is not enough cross-session signal yet to cluster anything. This is mathematically expected, not a bug.`]})]})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`How to get clusters to appear, in order of value`}),(0,G.jsx)(qx,{step:1,title:`Extract more projects`,body:`More extracted sessions = more chances of finding recurring bugs. Pick 2-3 projects you actually mine bugs from. The 🚀 run buttons in Setup & Status above launch each.`}),(0,G.jsx)(qx,{step:2,title:`Run inference with semantic mode`,body:`Fuzzy-merges "same bug, different wording" via local embeddings. No API cost. Run after each extraction batch.`,command:`recall infer-bug-patterns --semantic`}),(0,G.jsx)(qx,{step:3,title:`Lower the threshold (last resort)`,body:`Drop min-count to 2 to surface pairs. Less reliable signal (a pair could be coincidence) but useful for spot-checking before you have lots of data.`,command:`recall infer-bug-patterns --semantic --min-cluster-size 2`})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted text-center pt-2`,children:[`Single findings live on the`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`All findings`}),` tab. Findings only graduate to clusters when their fingerprint repeats.`]})]})}function Kx({icon:e,title:t,body:n}){return(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated/30 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-base`,"aria-hidden":!0,children:e}),(0,G.jsx)(`span`,{className:`font-semibold text-fg`,children:t})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:n})]})}function qx({step:e,title:t,body:n,command:r}){let[i,a]=(0,W.useState)(!1);function o(){r&&navigator.clipboard.writeText(r).then(()=>{a(!0),setTimeout(()=>a(!1),1500)})}return(0,G.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,G.jsx)(`div`,{className:`shrink-0 w-7 h-7 rounded-full bg-accent/15 border border-accent/40 text-accent text-sm font-semibold flex items-center justify-center`,children:e}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm`,children:t}),(0,G.jsx)(`div`,{className:`text-sm text-fg-muted leading-relaxed`,children:n}),r&&(0,G.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-2 text-xs font-mono px-2 py-1 rounded border border-line hover:border-accent text-fg-dim hover:text-accent`,title:`Copy this command`,children:[(0,G.jsx)(`span`,{children:r}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:i?`✓ copied`:`copy`})]})]})]})}function Jx(){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated/30 p-5`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-3 text-center`,children:`How clusters work`}),(0,G.jsxs)(`svg`,{viewBox:`0 0 560 180`,className:`w-full h-auto`,role:`img`,"aria-label":`Three session dots converge into one cluster node with a linked fix badge.`,children:[[{y:40,label:`Session A`},{y:90,label:`Session B`},{y:140,label:`Session C`}].map((e,t)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`circle`,{cx:60,cy:e.y,r:14,className:`fill-bg stroke-line`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:60,y:e.y+4,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`◯`}),(0,G.jsx)(`text`,{x:60,y:e.y+30,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:e.label}),(0,G.jsx)(`line`,{x1:78,y1:e.y,x2:232,y2:90,className:`stroke-sky-500/50`,strokeWidth:1.2,strokeDasharray:`3 3`})]},t)),(0,G.jsx)(`rect`,{x:235,y:60,width:120,height:60,rx:8,className:`fill-sky-500/15 stroke-sky-400`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:295,y:88,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`🐛 Cluster`}),(0,G.jsx)(`text`,{x:295,y:104,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`same bug fingerprint`}),(0,G.jsx)(`line`,{x1:358,y1:90,x2:432,y2:90,className:`stroke-accent`,strokeWidth:1.5,markerEnd:`url(#explainer-arrow)`}),(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`explainer-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent`})})}),(0,G.jsx)(`rect`,{x:435,y:60,width:110,height:60,rx:8,className:`fill-accent/15 stroke-accent`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:490,y:88,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`✓ Linked fix`}),(0,G.jsx)(`text`,{x:490,y:104,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`surfaces next time`})]})]})}var Yx=[`onboarding`];function Xx(){let e=K(),t=q({queryKey:Yx,queryFn:()=>Z.getOnboarding(),staleTime:6e4,refetchOnWindowFocus:!1}),n=J({mutationFn:e=>Z.patchOnboarding(e),onSuccess:t=>{e.setQueryData(Yx,e=>e&&{...e,state:t})}}),r=J({mutationFn:()=>Z.resetOnboarding(),onSuccess:t=>{e.setQueryData(Yx,e=>e&&{...e,state:t})}}),i=!!t.data&&!t.data.state.completed&&!t.data.state.skipped;return{data:t.data,isLoading:t.isLoading,shouldShow:i,patch:e=>n.mutateAsync(e),reset:()=>r.mutateAsync()}}var Zx=[{id:`intro`,title:`Your most recent session`},{id:`resume`,title:`Resume it in Claude Code`},{id:`auto-tag`,title:`Let Recall organize it`}];function Qx({onSelectSession:e,onOpenAutoTagSettings:t,onClose:n}){let r=Xx(),i=r.data?.mostRecentSession??null,[a,o]=(0,W.useState)(0),s=Zx[a].id,c=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:a>=1,staleTime:3e4}),[l,u]=(0,W.useState)(!1);(0,W.useEffect)(()=>{l||s!==`intro`||!i||(e(i.id),u(!0))},[l,s,i,e]),(0,W.useEffect)(()=>{r.patch({completedSteps:[s]})},[s]);let d=(0,W.useCallback)(()=>{n(),r.patch({completed:!0,finishedAt:new Date().toISOString(),completedSteps:Zx.map(e=>e.id)}).catch(()=>{})},[r,n]),f=(0,W.useCallback)(()=>{n(),r.patch({skipped:!0,finishedAt:new Date().toISOString()}).catch(()=>{})},[r,n]);ui(!0,f);let p=(0,W.useCallback)(()=>{a<Zx.length-1?o(e=>e+1):d()},[a,d]),m=(0,W.useCallback)(()=>{a>0&&o(e=>e-1)},[a]);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-end sm:items-center justify-center p-4 sm:p-6`,role:`dialog`,"aria-labelledby":`onboarding-title`,"aria-modal":`true`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[520px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-2xl flex flex-col`,children:[(0,G.jsx)($x,{stepIdx:a,onSkip:()=>void f()}),(0,G.jsxs)(`div`,{className:`flex-1 px-6 py-5`,children:[s===`intro`&&(0,G.jsx)(tS,{session:i,isLoading:r.isLoading,onReveal:()=>{i&&e(i.id)}}),s===`resume`&&(0,G.jsx)(nS,{session:i}),s===`auto-tag`&&(0,G.jsx)(rS,{claudeCliAvailable:!!c.data?.claudeCliAvailable,mcpInstalled:!!c.data?.installed,onOpenSettings:()=>{t(),d()},onFinish:d})]}),(0,G.jsx)(eS,{stepIdx:a,canBack:a>0,onBack:m,onNext:p,onSkip:()=>void f(),isFinalStep:a===Zx.length-1})]})})}function $x({stepIdx:e,onSkip:t}){return(0,G.jsxs)(`div`,{className:`px-6 py-4 border-b border-line flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-7 w-7 rounded-md shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{id:`onboarding-title`,className:`text-sm font-semibold text-fg leading-none`,children:[`Welcome to `,(0,G.jsxs)(`span`,{className:`text-base font-extrabold`,children:[`Claude `,(0,G.jsx)(`span`,{className:`text-accent`,children:`Recall`})]})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1`,children:[`Step `,e+1,` of `,Zx.length,` · `,Zx[e].title]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-fg-muted hover:text-fg whitespace-nowrap`,title:`dismiss the tour (Esc)`,children:`I’ll explore myself →`})]})}function eS({stepIdx:e,canBack:t,onBack:n,onNext:r,onSkip:i,isFinalStep:a}){return(0,G.jsxs)(`div`,{className:`px-6 py-3 border-t border-line flex items-center justify-between gap-2 bg-bg-elevated`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:Zx.map((t,n)=>(0,G.jsx)(`span`,{className:`h-1.5 w-6 rounded-full transition-colors ${n<=e?`bg-accent`:`bg-line`}`},t.id))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Skip`}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg text-xs px-3 py-1 border border-line rounded`,children:`← Back`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`bg-accent text-bg rounded px-4 py-1.5 text-xs font-semibold hover:opacity-90`,children:a?`Finish`:`Next →`})]})]})}function tS({session:e,isLoading:t,onReveal:n}){if(t)return(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Looking for your most recent session…`});if(!e)return(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`p`,{className:`text-fg`,children:[`Claude Recall watches `,(0,G.jsx)(`code`,{className:`font-mono text-xs text-fg-muted`,children:`~/.claude/projects/`}),` `,`and indexes every session Claude Code has written — automatically, in the background, offline.`]}),(0,G.jsx)(`p`,{className:`text-fg-muted`,children:`No sessions are indexed yet. Start a Claude Code conversation anywhere on this machine, then come back — Recall will pick it up within seconds.`})]});let r=e.alias??e.first_user_message??e.id.slice(0,8),i=e.ended_at??e.started_at;return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`Here’s your `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`most recent Claude Code session`}),` — already indexed and searchable. Nothing left the machine; Recall just watches the files Claude Code was already writing.`]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-accent/40 bg-accent/10 px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-accent font-semibold mb-1`,children:`Highlighted behind this dialog`}),(0,G.jsx)(`div`,{className:`text-sm text-fg font-medium truncate`,title:r,children:r}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1 flex flex-wrap gap-x-3 gap-y-0.5`,children:[(0,G.jsx)(`span`,{children:e.project}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[e.message_count,` messages`]}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:iS(i)})]}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,8)})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs text-accent hover:underline`,children:`Re-highlight the transcript behind this dialog →`})]})}function nS({session:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useMemo)(()=>e?`recall context ${e.id.slice(0,8)} | claude`:``,[e]),i=(0,W.useCallback)(async()=>{if(r)try{await navigator.clipboard.writeText(r),n(!0),Q({message:`Command copied. Paste it in a terminal to start a fresh Claude Code session with full context.`,tone:`success`,duration:8e3}),setTimeout(()=>n(!1),2500)}catch(e){Q({message:`Clipboard blocked: ${e instanceof Error?e.message:String(e)}. Copy the command manually.`,tone:`error`})}},[r]);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`This is the feature nobody else has: `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`pipe any past session back into a new Claude Code conversation`}),`. Claude wakes up already knowing everything you discussed before.`]}),e?(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2`,children:(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg break-all`,children:r})}):(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Once you have indexed sessions, this step shows a one-click copy for the most recent one.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void i(),disabled:!r,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:t?`✓ Copied — paste into a terminal`:`📋 Copy resume command to clipboard`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted leading-relaxed`,children:(0,G.jsxs)(`p`,{children:[`Paste the command in any terminal to launch a fresh `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`claude`}),` `,`session with the prior context preinjected. You can also run`,` `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`recall context <id> --full`}),` for the complete transcript or `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`--since 2h`}),` to clip just the last two hours.`]})})]})}function rS({claudeCliAvailable:e,mcpInstalled:t,onOpenSettings:n,onFinish:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(0),f=(0,W.useRef)(null),p=e&&t;(0,W.useEffect)(()=>{if(!i)return;let e=f.current??Date.now();f.current=e,d(Math.floor((Date.now()-e)/1e3));let t=window.setInterval(()=>{d(Math.floor((Date.now()-e)/1e3))},1e3);return()=>window.clearInterval(t)},[i]);let m=(0,W.useCallback)(async()=>{if(!p||i)return;let e=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`scan-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;a(!0),s(null),l(null),f.current=Date.now(),d(0);let t=Z.subscribeToScanProgress(e);t.addEventListener(`progress`,e=>{try{let t=JSON.parse(e.data);l({current:t.current,total:t.total,sessionLabel:t.sessionLabel})}catch{}}),t.addEventListener(`done`,()=>{t.close()}),t.onerror=()=>{t.close()};try{let t=await Z.runClaudeCliScan({untaggedOnly:!0,limit:10},{scanId:e});s({tagsAdded:t.tagsAdded,success:t.success}),t.success?Q({message:`Auto-tag added ${t.tagsAdded} tag${t.tagsAdded===1?``:`s`} across your 10 most recent sessions.`,tone:`success`,duration:8e3}):Q({message:`Auto-tag run finished with exit ${t.exitCode??`?`}. Check the ⚙ button on the top bar for details.`,tone:`error`})}catch(e){Q({message:`Auto-tag failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{t.close(),a(!1),f.current=null}},[p,i]),h=(0,W.useMemo)(()=>{if(!c||c.current<2||c.total<=c.current)return null;let e=u/c.current;return Math.max(1,Math.round(e*(c.total-c.current)))},[c,u]);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`Let Claude Recall `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`auto-tag`}),` your last`,` `,`10 sessions so you can find them by topic later —`,` `,(0,G.jsx)(`code`,{className:`font-mono text-xs`,children:`#auth-fix`}),`,`,` `,(0,G.jsx)(`code`,{className:`font-mono text-xs`,children:`#migration`}),`, and so on. Opt-in, local, reversible.`]}),p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),disabled:i,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90 disabled:opacity-60 disabled:cursor-wait flex items-center justify-center gap-2`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{children:`Tagging via your Claude Code agent…`})]}):(0,G.jsx)(`span`,{children:`🏷 Tag my 10 most recent sessions`})}),i&&(0,G.jsxs)(`div`,{className:`text-xs rounded border border-line bg-bg-elevated px-3 py-2 text-fg-muted`,role:`status`,"aria-live":`polite`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{className:`text-fg`,children:c?`Tagging session ${c.current} of ${c.total}`:`Preparing…`})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-[11px]`,children:[(0,G.jsxs)(`span`,{children:[u,`s elapsed`]}),h!==null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[`~`,h,`s remaining`]})]}),c?.sessionLabel&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`truncate max-w-[24ch]`,title:c.sessionLabel,children:c.sessionLabel})]})]})]}),o&&!i&&(0,G.jsx)(`div`,{className:`text-xs rounded border px-3 py-2 ${o.success?`border-accent/40 bg-accent/10 text-fg`:`border-role-user/40 bg-role-user/10 text-fg`}`,children:o.success?`Added ${o.tagsAdded} tag${o.tagsAdded===1?``:`s`}. You can review or remove them anytime from the session transcript.`:`The agent exited with an error. Open ⚙ on the 🏷 auto-tag button for logs.`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`Uses your existing Claude Code subscription via the Recall MCP server — no extra API cost.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void r(),className:`text-xs text-fg-muted hover:text-fg`,children:`Skip this — I’ll tag sessions myself →`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2.5 text-xs text-fg-muted space-y-1`,children:[(0,G.jsx)(`div`,{children:`One-click auto-tagging needs two things already set up:`}),(0,G.jsxs)(`ul`,{className:`pl-4 list-disc marker:text-fg-muted space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[`Recall’s MCP server installed in Claude Code —`,` `,(0,G.jsx)(`span`,{className:t?`text-accent`:`text-role-user`,children:t?`installed ✓`:`not installed`})]}),(0,G.jsxs)(`li`,{children:[`The `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`claude`}),` CLI on your PATH —`,` `,(0,G.jsx)(`span`,{className:e?`text-accent`:`text-role-user`,children:e?`found ✓`:`not found`})]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90`,children:`Set up auto-tagging →`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`You can also paste an Anthropic API key in the same settings dialog if you prefer an API-backed scan.`})]})]})}function iS(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.round(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.round(r/60);if(i<24)return`${i}h ago`;let a=Math.round(i/24);return a<30?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var aS=[{id:`what`,title:`A thread groups sessions by intent`},{id:`how`,title:`Three ways to add a session to a thread`},{id:`pipe`,title:`Pipe a whole thread back into Claude Code`}];function oS({onClose:e}){let t=Xx(),[n,r]=(0,W.useState)(0),i=aS[n].id,a=(0,W.useCallback)(()=>{e(),t.patch({threadsIntroSeen:!0}).catch(()=>{})},[t,e]);ui(!0,a);let o=(0,W.useCallback)(()=>{n<aS.length-1?r(e=>e+1):a()},[n,a]),s=(0,W.useCallback)(()=>{n>0&&r(e=>e-1)},[n]);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-end sm:items-center justify-center p-4 sm:p-6`,role:`dialog`,"aria-labelledby":`threads-intro-title`,"aria-modal":`true`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[560px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-2xl flex flex-col`,children:[(0,G.jsx)(sS,{stepIdx:n,onSkip:a}),(0,G.jsxs)(`div`,{className:`flex-1 px-6 py-5`,children:[i===`what`&&(0,G.jsx)(lS,{}),i===`how`&&(0,G.jsx)(dS,{}),i===`pipe`&&(0,G.jsx)(fS,{})]}),(0,G.jsx)(cS,{stepIdx:n,canBack:n>0,onBack:s,onNext:o,onSkip:a,isFinalStep:n===aS.length-1})]})})}function sS({stepIdx:e,onSkip:t}){return(0,G.jsxs)(`div`,{className:`px-6 py-4 border-b border-line flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-7 w-7 rounded-md bg-accent flex items-center justify-center text-bg font-bold text-sm shrink-0`,children:`🧵`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{id:`threads-intro-title`,className:`text-sm font-semibold text-fg leading-none`,children:`Welcome to Threads`}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1`,children:[`Step `,e+1,` of `,aS.length,` · `,aS[e].title]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-fg-muted hover:text-fg whitespace-nowrap`,title:`dismiss the tour (Esc)`,children:`I can explore on my own →`})]})}function cS({stepIdx:e,canBack:t,onBack:n,onNext:r,onSkip:i,isFinalStep:a}){return(0,G.jsxs)(`div`,{className:`px-6 py-3 border-t border-line flex items-center justify-between gap-2 bg-bg-elevated`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:aS.map((t,n)=>(0,G.jsx)(`span`,{className:`h-1.5 w-6 rounded-full transition-colors ${n<=e?`bg-accent`:`bg-line`}`},t.id))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Skip`}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg text-xs px-3 py-1 border border-line rounded`,children:`← Back`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`bg-accent text-bg rounded px-4 py-1.5 text-xs font-semibold hover:opacity-90`,children:a?`Done`:`Next →`})]})]})}function lS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`A thread is the unit of work you remember afterwards. It links one planning session to every session that acts on the plan, so you can keep working across days, branches, and machines, and still pull it all back together in one view.`}),(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated p-4 flex justify-center`,children:(0,G.jsx)(uS,{})}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-muted leading-relaxed`,children:`One origin session at the top. Three child sessions below. The thread is the shape, not any single session.`})]})}function uS(){return(0,G.jsx)(`svg`,{viewBox:`0 0 340 200`,width:`100%`,height:`180`,role:`img`,"aria-label":`Sketch of a thread: one origin session with three child sessions branching below it.`,className:`text-fg`,children:(0,G.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,G.jsxs)(`g`,{transform:`translate(170 32) rotate(-0.8)`,children:[(0,G.jsx)(`rect`,{x:`-60`,y:`-18`,width:`120`,height:`36`,rx:`6`,ry:`6`,strokeWidth:`1.75`}),(0,G.jsx)(`text`,{x:`0`,y:`5`,textAnchor:`middle`,fontSize:`12`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Planning session`})]}),(0,G.jsx)(`path`,{d:`M 150 60 C 140 90, 80 90, 70 130`,strokeWidth:`1.4`}),(0,G.jsx)(`path`,{d:`M 170 62 C 170 95, 170 100, 170 130`,strokeWidth:`1.4`}),(0,G.jsx)(`path`,{d:`M 190 60 C 200 90, 260 90, 270 130`,strokeWidth:`1.4`}),(0,G.jsxs)(`g`,{transform:`translate(70 150) rotate(1.1)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 1`})]}),(0,G.jsxs)(`g`,{transform:`translate(170 150) rotate(-0.6)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 2`})]}),(0,G.jsxs)(`g`,{transform:`translate(270 150) rotate(0.9)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 3`})]})]})})}function dS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`You can add a session to a thread from three places. Pick whichever one is closest to where you already are.`}),(0,G.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg`,children:[(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`1`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From a session transcript`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Open any session from the sidebar. In the transcript header, click`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`+ Add to thread`}),` and pick the thread you want.`]})]})]}),(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`2`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From this Threads page`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Select a thread on the left. Click`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`+ Add session`}),` on the top right and search for the session by alias, project, or first message.`]})]})]}),(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`3`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From a terminal`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Run`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`recall thread link <session-id> --thread <thread-id>`}),` `,`in a shell. Works in scripts. Short identifiers are fine as long as they are unambiguous.`]})]})]})]})]})}function fS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`When you start a fresh conversation, you can load every session in a thread as context for Claude Code with one command. It wakes up knowing the plan and every execution session that followed, so you pick up exactly where the thread left off.`}),(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2`,children:(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg break-all`,children:`recall context thread:<id> | claude`})}),(0,G.jsxs)(`ul`,{className:`text-[11px] text-fg-muted leading-relaxed space-y-1 list-disc pl-4 marker:text-fg-muted`,children:[(0,G.jsxs)(`li`,{children:[`Replace`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`<id>`}),` `,`with the thread identifier shown in the list on the left. The first few characters are enough as long as they are unambiguous.`]}),(0,G.jsx)(`li`,{children:`Sessions are concatenated in thread order: origins first, then children in the order they were added.`}),(0,G.jsx)(`li`,{children:`Nothing leaves your machine. The pipe is between two local programs.`})]})]})}function pS(e){let t=e/100;return t===0?`$0.00`:t<.01?`<$0.01`:t<100?`$${t.toFixed(2)}`:t<1e4?`$${t.toFixed(0)}`:`$${(t/1e3).toFixed(1)}k`}function mS(e){let t=e/100;return t===0?`$0.00`:t<1?`$${t.toFixed(4)}`:t<100?`$${t.toFixed(2)}`:`$${t.toLocaleString(void 0,{maximumFractionDigits:2})}`}function hS(e){return!Number.isFinite(e)||e<0?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:e<0xe8d4a51000?`${(e/1e9).toFixed(2)}B`:`${(e/0xe8d4a51000).toFixed(2)}T`}function gS(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function _S(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function vS(e,t){let n=new Map;for(let t of e)n.set(t.day,{tokens:t.tokens,cents:t.cents});if(t===`7d`||t===`30d`){let e=t===`7d`?7:30,r=new Date;r.setHours(0,0,0,0);let i=[];for(let t=e-1;t>=0;t--){let e=new Date(r);e.setDate(e.getDate()-t);let a=gS(e),o=n.get(a);i.push({day:a,tokens:o?.tokens??0,cents:o?.cents??0})}return i}if(e.length===0)return[];let[r,i,a]=[...e].sort((e,t)=>e.day.localeCompare(t.day))[0].day.split(`-`).map(Number),o=new Date(r,i-1,a),s=new Date;s.setHours(0,0,0,0);let c=Math.floor((s.getTime()-o.getTime())/864e5)+1,l=Math.min(90,Math.max(1,c)),u=[];for(let e=l-1;e>=0;e--){let t=new Date(s);t.setDate(t.getDate()-e);let r=gS(t),i=n.get(r);u.push({day:r,tokens:i?.tokens??0,cents:i?.cents??0})}return u}function yS({axis:e,range:t}){let[n,r]=(0,W.useState)(null);if(e.length===0)return(0,G.jsx)(`div`,{className:`text-xs text-fg-muted text-center py-6`,children:`No usage data in this range.`});let i=Math.max(1,...e.map(e=>e.cents)),a=704/e.length,o=Math.max(2,a-2),s=e.length<=7?1:e.length<=14?2:e.length<=30?5:10;return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`svg`,{width:720,height:120,viewBox:`0 0 720 120`,className:`w-full h-auto`,role:`img`,"aria-label":`Daily cost chart`,onMouseLeave:()=>r(null),children:[(0,G.jsx)(`line`,{x1:8,x2:712,y1:102,y2:102,className:`stroke-line`,strokeWidth:1}),e.map((e,t)=>{let s=8+t*a+(a-o)/2,c=e.cents>0?Math.max(2,e.cents/i*98):0,l=102-c,u=n?.i===t,d=e.cents===0;return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:8+t*a,y:0,width:a,height:102,fill:`transparent`,onMouseEnter:()=>r({i:t,day:e.day,tokens:e.tokens,cents:e.cents,x:8+t*a+a/2})}),(0,G.jsx)(`rect`,{x:s,y:d?100:l,width:o,height:d?2:c,rx:1,className:d?`fill-line`:u?`fill-accent`:`fill-accent/70`,pointerEvents:`none`})]},e.day)}),e.map((t,n)=>n%s!==0&&n!==e.length-1?null:(0,G.jsx)(`text`,{x:8+n*a+a/2,y:116,textAnchor:`middle`,className:`fill-fg-muted`,fontSize:9,children:_S(t.day)},`tick-${t.day}`))]}),n&&(0,G.jsxs)(`div`,{className:`absolute pointer-events-none bg-bg-elevated border border-line rounded-lg shadow-xl px-3 py-2 text-xs -translate-x-1/2`,style:{left:`${n.x/720*100}%`,top:4},children:[(0,G.jsx)(`div`,{className:`font-medium text-fg`,children:_S(n.day)}),(0,G.jsx)(`div`,{className:`text-accent font-semibold tabular-nums mt-0.5`,children:mS(n.cents)}),(0,G.jsxs)(`div`,{className:`text-fg-muted tabular-nums`,children:[hS(n.tokens),` tokens`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-fg-muted mt-2`,children:[(0,G.jsxs)(`span`,{children:[t===`7d`?`Last 7 days`:t===`30d`?`Last 30 days`:e.length>=90?`Last 90 days (capped for readability)`:`Last ${e.length} days`,` `,`· local time · hover for detail`]}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[`peak `,mS(i)]})]})]})}function bS({text:e,align:t=`center`}){let[n,r]=(0,W.useState)(!1);return(0,G.jsxs)(`span`,{className:`relative inline-block ml-1 align-middle`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,G.jsx)(`span`,{tabIndex:0,role:`button`,"aria-label":e,onFocus:()=>r(!0),onBlur:()=>r(!1),className:`inline-flex items-center justify-center w-[14px] h-[14px] rounded-full border border-line text-fg-muted text-[9px] font-medium cursor-help hover:text-fg hover:border-fg-dim`,children:`?`}),n&&(0,G.jsx)(`span`,{role:`tooltip`,className:`absolute z-50 top-full mt-2 w-64 px-3 py-2 text-xs leading-relaxed bg-bg-elevated border border-line rounded-lg shadow-xl text-fg-muted pointer-events-none whitespace-normal normal-case tracking-normal font-normal `+(t===`left`?`left-0`:t===`right`?`right-0`:`left-1/2 -translate-x-1/2`),children:e})]})}function xS({input:e,output:t,cacheCreate:n,cacheRead:r}){return e+t+n+r===0?(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-2`,children:`no tokens in range`}):(0,G.jsx)(`div`,{className:`mt-2 space-y-1`,children:[{key:`output`,label:`Output`,sub:`what the model wrote`,value:t,cls:`bg-accent`},{key:`cache-r`,label:`Cache read`,sub:`cached prefix re-read each turn · 10× cheaper`,value:r,cls:`bg-fg-muted`},{key:`cache-w`,label:`Cache write`,sub:`first-time cache fills`,value:n,cls:`bg-role-tool`},{key:`input`,label:`Input`,sub:`fresh text sent to the model`,value:e,cls:`bg-role-user`}].sort((e,t)=>t.value-e.value).map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm shrink-0 `+e.cls}),(0,G.jsx)(`span`,{className:`text-fg w-20 shrink-0`,children:e.label}),(0,G.jsx)(`span`,{className:`text-fg-muted flex-1 truncate`,children:e.sub}),(0,G.jsx)(`span`,{className:`text-fg font-medium tabular-nums`,children:hS(e.value)})]},e.key))})}function SS({onClose:e,onSelectSession:t}){let[n,r]=(0,W.useState)(`30d`),i=K(),[,a]=Nn(),o=q({queryKey:[`statsOverview`,n],queryFn:()=>Z.getOverviewStats(n),refetchInterval:3e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(!1),d=J({mutationFn:()=>Z.triggerStatsBackfill(),onMutate:()=>{c({kind:`info`,text:`Scanning…`})},onSuccess:e=>{i.invalidateQueries({queryKey:[`statsOverview`]}),i.invalidateQueries({queryKey:[`sessionStats`]});let t=e.result??null;if(e.mode===`background`){c({kind:`info`,text:`Large backlog — scanning in background. Refresh in a moment.`});return}t&&t.inserted>0?c({kind:`success`,text:`Recovered ${t.inserted.toLocaleString()} usage rows across ${t.sessionsTouched.toLocaleString()} sessions.`}):t&&c({kind:`noop`,text:`Scanned ${t.scanned.toLocaleString()} message${t.scanned===1?``:`s`} — none carried recoverable usage data. These messages are aborted/cancelled assistant turns or pre-v0.10 Claude Code output and can't be priced.`})},onError:e=>{c({kind:`noop`,text:`Backfill failed: ${e.message}`})}}),f=o.data,p=(0,W.useMemo)(()=>f?vS(f.daily,n):[],[f,n]),[m,h]=(0,W.useState)(()=>Date.now());(0,W.useEffect)(()=>{let e=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let g=o.dataUpdatedAt?Math.max(0,Math.floor((m-o.dataUpdatedAt)/1e3)):null,_=g===null?`—`:g<5?`just now`:g<60?`${g}s ago`:g<3600?`${Math.floor(g/60)}m ago`:`${Math.floor(g/3600)}h ago`;return(0,G.jsx)(`div`,{className:`absolute inset-0 z-30 bg-bg/95 backdrop-blur-sm flex items-start justify-center overflow-y-auto`,children:(0,G.jsxs)(`div`,{className:`w-full max-w-4xl p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Cost & tokens`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:`Local-only — derived from the usage counters Claude Code writes into your session files. No telemetry.`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o.refetch(),disabled:o.isFetching,title:`Refresh now`,className:`mt-1.5 inline-flex items-center gap-1 text-[10px] text-fg-dim hover:text-fg disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`inline-block `+(o.isFetching?`animate-spin`:``),children:`↻`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:o.isFetching?`refreshing…`:`updated ${_}`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(`div`,{className:`flex items-stretch text-xs border border-line rounded-lg overflow-hidden`,children:[`7d`,`30d`,`all`].map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:(t===0?``:`border-l border-line `)+`min-w-[72px] px-3 py-2 text-center transition-colors `+(n===e?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),children:e===`all`?`all-time`:e},e))}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-2.5 py-1.5 text-fg-dim hover:text-fg border border-line rounded-lg`,children:`✕ close`})]})]}),o.isLoading&&(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`loading…`}),o.error&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400`,children:[`failed to load: `,o.error.message]}),f&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 mb-6`,children:[(0,G.jsx)(CS,{label:`Estimated cost`,value:f.display.dollars,accent:!0,info:`Sum of all priced tokens × Anthropic list price for each model. Cache reads are 10× cheaper than fresh input. List-price estimate — actual billing may differ.`}),(0,G.jsx)(CS,{label:`Total tokens`,value:f.display.tokens,hint:`${hS(f.outputTokens)} output · ${hS(f.cacheReadTokens)} cache read`,info:`Sum of all four token buckets Anthropic's API reports: input + output + cache-write + cache-read. The big number is usually dominated by cache-read, which re-counts the entire cached prompt prefix on every turn. Cache-read is priced ~10× cheaper than fresh input — see the composition panel below for the full breakdown.`}),(0,G.jsx)(CS,{label:`Sessions`,value:`${f.sessionsWithUsage.toLocaleString()} / ${f.totalSessions.toLocaleString()}`,hint:`with usage / active`,info:n===`all`?`Sessions Claude Recall has indexed: those with at least one priced message vs the total in the database.`:`Sessions active in this window (any message) and the subset that had at least one priced assistant message.`}),(0,G.jsx)(CS,{label:`Primary model`,value:f.byModel[0]?.modelLabel??`—`,hint:f.byModel.length>1?`+${f.byModel.length-1} more`:void 0,info:`Model that produced the most spend in this range. See the By-model table below for the full split.`,infoAlign:`right`})]}),(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Token composition`}),(0,G.jsx)(bS,{text:`The same total, split by what Anthropic counted. Cache-read dominates because every assistant turn reports the full cached prompt prefix as tokens read — priced 10× cheaper than fresh input.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg p-4`,children:(0,G.jsx)(xS,{input:f.inputTokens,output:f.outputTokens,cacheCreate:f.cacheCreateTokens,cacheRead:f.cacheReadTokens})})]}),(f.backfill.pending>0||s)&&!l&&(0,G.jsxs)(`div`,{className:`mb-6 flex items-start justify-between gap-3 rounded-lg px-4 py-3 border `+(s?.kind===`success`?`bg-green-500/10 border-green-500/40`:`bg-bg-elevated border-line`),children:[(0,G.jsxs)(`div`,{className:`text-xs flex-1`,children:[f.backfill.pending>0&&(0,G.jsxs)(`div`,{className:`text-fg font-medium flex items-center gap-1`,children:[(0,G.jsx)(`span`,{children:(()=>{let e=Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0));return e===0?`${f.backfill.pending.toLocaleString()} message${f.backfill.pending===1?``:`s`} can't be priced — nothing to recover.`:`${e.toLocaleString()} of ${f.backfill.pending.toLocaleString()} assistant message${f.backfill.pending===1?``:`s`} missing usage data.`})()}),(0,G.jsx)(bS,{text:`When Claude Recall first imported your sessions, some assistant messages were stored without their token-count metadata — usually because they came from older Claude Code versions, were cancelled mid-stream, or got partial writes during a crash. Backfill re-reads each message's raw JSON locally and recovers any usage data it finds. Anything still missing after a backfill (the "unrecoverable" count) genuinely never had counts recorded by Anthropic and can't be priced. Runs in chunks, transactional, no network, no reindex.`})]}),(0,G.jsx)(`div`,{className:`text-fg-muted mt-0.5`,children:d.isPending?`Scanning… this may take a few seconds.`:s?.text??(f.backfill.pending>0&&Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0))===0?`These are aborted/cancelled assistant turns or pre-v0.10 Claude Code output — Anthropic never recorded their token counts.`:`Backfill re-parses the messages' raw JSON to recover token counts. Local only — no reindex, no network.`)})]}),Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0))>0?(0,G.jsx)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`text-xs bg-accent text-bg font-medium rounded px-3 py-1.5 disabled:opacity-50 whitespace-nowrap`,children:d.isPending?`scanning…`:`run backfill`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs text-fg-dim hover:text-fg px-2 py-1.5 whitespace-nowrap`,"aria-label":`Dismiss`,children:`✕`})]}),(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Daily spend`}),(0,G.jsx)(bS,{text:`One bar per local-time day. Empty bars = no priced activity that day. Hover any day for the exact dollar amount and token count. Cost = Σ(tokens × model price).`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg p-3`,children:(0,G.jsx)(yS,{axis:p,range:n})})]}),f.byModel.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`By model`}),(0,G.jsx)(bS,{text:`Per-model token counts and cost in this range. cache_w is normally MUCH larger than input — Claude Code re-caches system prompt + tools + conversation history every turn, and Anthropic reports cumulative cache writes per turn. Pricing: cache_w = 1.25× input, cache_r = 0.1× input. Total cost reflects the right weighting.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`bg-bg/60 text-fg-muted`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`model`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Fresh tokens sent to the model`,children:`input`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Tokens generated by the model`,children:`output`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Cache write tokens (cache_creation_input_tokens). Claude Code re-caches the system prompt + tool definitions + conversation history every turn, so this number grows with conversation length and is normally MUCH larger than 'input'. Priced at 1.25× the input rate — Anthropic's published pricing.`,children:`cache w`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Cache read tokens (cache_read_input_tokens). Charged at 0.1× the input rate (10× cheaper). High cache_r is good — it means most of the prompt was served from cache instead of re-billed as input.`,children:`cache r`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`cost`})]})}),(0,G.jsx)(`tbody`,{children:f.byModel.map(e=>(0,G.jsxs)(`tr`,{className:`border-t border-line`,children:[(0,G.jsx)(`td`,{className:`px-3 py-2 font-medium`,children:e.modelLabel}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.inputTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.outputTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.cacheCreateTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.cacheReadTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 font-semibold text-accent`,children:pS(e.cost.cents)})]},e.model??`__unknown__`))})]})})]}),f.topSessions.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Top sessions`}),(0,G.jsx)(bS,{text:`The 10 most expensive sessions in this range, ranked by tokens used inside the window. Click any row to open the transcript.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`bg-bg/60 text-fg-muted`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`session`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`project`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`tokens`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`cost`})]})}),(0,G.jsx)(`tbody`,{children:f.topSessions.map(e=>(0,G.jsxs)(`tr`,{className:`border-t border-line hover:bg-bg-hover cursor-pointer`,onClick:()=>t(e.sessionId),children:[(0,G.jsx)(`td`,{className:`px-3 py-2 font-mono truncate max-w-[200px]`,children:e.alias??e.sessionId.slice(0,12)}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg-muted truncate max-w-[200px]`,children:e.project??`—`}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.totalTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 font-semibold text-accent`,children:pS(e.cost.cents)})]},e.sessionId))})]})}),(0,G.jsx)(`p`,{className:`text-[10px] text-fg-muted mt-2`,children:`Showing the top 10 sessions by tokens. Smaller projects with only a few sessions won't appear here even though they're fully indexed — every project shows up in the per-project view (and in the daily chart total).`})]}),f.topRepos.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Top repos`}),(0,G.jsx)(bS,{text:`Projects ranked by total tokens used inside this range. Click a card to filter the rest of the UI to that project.`})]}),(0,G.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2 -mx-2 px-2 snap-x`,style:{scrollbarWidth:`thin`},children:f.topRepos.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a({project:e.project}),className:`snap-start shrink-0 w-[220px] text-left bg-bg-elevated border border-line rounded-lg px-4 py-3 hover:border-accent hover:bg-bg-hover transition-colors`,title:`Filter to ${e.project}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,t+1]}),(0,G.jsx)(`span`,{className:`truncate`,children:`repo`})]}),(0,G.jsx)(`div`,{className:`mt-1 text-sm font-medium truncate`,title:e.project,children:e.project}),(0,G.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-accent tabular-nums`,children:pS(e.cost.cents)}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted tabular-nums`,children:[hS(e.totalTokens),` tokens · `,e.sessions,` session`,e.sessions===1?``:`s`]})]},e.project+t))}),(0,G.jsxs)(`p`,{className:`text-[10px] text-fg-muted mt-1`,children:[`Top `,Math.min(f.topRepos.length,20),` projects by tokens in this range. Scroll horizontally for more. Click to filter.`]})]})]})]})})}function CS({label:e,value:t,accent:n,hint:r,info:i,infoAlign:a=`left`,extra:o}){return(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e}),i&&(0,G.jsx)(bS,{text:i,align:a})]}),(0,G.jsx)(`div`,{className:`text-lg font-semibold mt-1 `+(n?`text-accent`:`text-fg`),children:t}),r&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-0.5`,children:r}),o]})}var wS=[],TS=[];function ES(e){wS.some(t=>t.id===e.id)||wS.push(e)}function DS(e){TS.push(e)}function OS(e){let t=[];for(let n of TS)try{t.push(...n(e))}catch{}return[...wS,...t]}function kS(e,t){let n=e.trim().toLowerCase();if(!n)return 1;let r=t.title.toLowerCase(),i=(t.subtitle??``).toLowerCase(),a=(t.keywords??[]).join(` `).toLowerCase(),o=t.section.toLowerCase(),s=0;return r===n&&(s=Math.max(s,1e3)),r.startsWith(n)&&(s=Math.max(s,500)),RegExp(`\\b`+jS(n)).test(r)&&(s=Math.max(s,300)),r.includes(n)&&(s=Math.max(s,200)),a.includes(n)&&(s=Math.max(s,150)),i.includes(n)&&(s=Math.max(s,100)),o.includes(n)&&(s=Math.max(s,50)),s===0&&AS(n,r)&&(s=25),s===0&&AS(n,a)&&(s=10),s}function AS(e,t){if(!e)return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function jS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function MS(e,t){let n=OS(t),r=e.trim();return r?n.map(e=>({c:e,s:kS(r,e)})).filter(e=>e.s>0).sort((e,t)=>t.s-e.s).map(e=>e.c):n}function NS(e){let t=[`Jump`,`Search`,`Actions`,`Settings`],n=new Map;for(let e of t)n.set(e,[]);for(let t of e){let e=n.get(t.section)??[];e.push(t),n.set(t.section,e)}return t.map(e=>[e,n.get(e)??[]]).filter(([,e])=>e.length>0)}function PS({ctx:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(0),o=(0,W.useRef)(null),s=(0,W.useRef)(null),c=q({queryKey:[`sessions`,`palette`],queryFn:()=>Z.sessions({limit:60}),staleTime:3e4}),l=(0,W.useMemo)(()=>({...e,sessions:c.data?.items??[],openPalette:()=>{},closePalette:t}),[e,c.data,t]),u=(0,W.useMemo)(()=>MS(n,l),[n,l]),d=(0,W.useMemo)(()=>NS(u),[u]),f=(0,W.useMemo)(()=>d.flatMap(([,e])=>e),[d]);return(0,W.useEffect)(()=>{a(0)},[n,u.length]),(0,W.useEffect)(()=>{requestAnimationFrame(()=>o.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),t();return}if(e.key===`ArrowDown`)e.preventDefault(),a(e=>Math.min(e+1,Math.max(f.length-1,0)));else if(e.key===`ArrowUp`)e.preventDefault(),a(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let n=f[i];n&&IS(n,l,t)}else if(e.key===`Tab`){if(e.preventDefault(),d.length===0)return;let t=f[i],[,n]=d[((t?d.findIndex(([e])=>e===t.section):0)+(e.shiftKey?-1:1)+d.length)%d.length],r=n[0];if(r){let e=f.findIndex(e=>e.id===r.id);e>=0&&a(e)}}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[f,d,i,l,t]),(0,W.useEffect)(()=>{(s.current?.querySelector(`[data-cmd-idx="${i}"]`))?.scrollIntoView({block:`nearest`})},[i]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-start justify-center pt-24 px-6`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-xl shadow-2xl w-full max-w-2xl max-h-[70vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),"data-testid":`command-palette`,children:[(0,G.jsxs)(`div`,{className:`p-4 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-fg-dim mb-2`,children:`Command palette`}),(0,G.jsx)(`input`,{ref:o,type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Type a command or session… ↑↓ navigate · Enter run · Esc close · Tab section`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm focus:outline-none focus:border-accent`,"data-testid":`command-palette-input`,"aria-label":`Command palette search`,autoComplete:`off`,spellCheck:!1})]}),(0,G.jsxs)(`div`,{ref:s,className:`flex-1 overflow-y-auto`,children:[f.length===0&&(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-muted`,children:`No commands match.`}),d.map(([e,n])=>(0,G.jsx)(FS,{section:e,cmds:n,activeIdx:i,flat:f,onRun:e=>IS(e,l,t),onHover:e=>{let t=f.findIndex(t=>t.id===e.id);t>=0&&a(t)}},e))]}),(0,G.jsxs)(`div`,{className:`p-3 border-t border-line text-xs text-fg-muted flex justify-between`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`↑↓`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Enter`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Tab`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Esc`})]}),(0,G.jsxs)(`span`,{children:[f.length,` commands`]})]})]})})}function FS({section:e,cmds:t,activeIdx:n,flat:r,onRun:i,onHover:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[10px] uppercase tracking-widest text-fg-dim`,children:e}),t.map(e=>{let t=r.findIndex(t=>t.id===e.id),o=t===n;return(0,G.jsxs)(`button`,{type:`button`,"data-cmd-idx":t,"data-cmd-id":e.id,onMouseEnter:()=>a(e),onClick:()=>i(e),className:$(`block w-full text-left px-4 py-2 border-b border-line/40 transition-colors`,o?`bg-bg-active`:`hover:bg-bg-hover`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,G.jsx)(`span`,{className:`shrink-0 text-fg-muted w-5 text-center`,children:e.icon}),(0,G.jsx)(`span`,{className:`text-sm text-fg truncate`,children:e.title})]}),e.subtitle&&(0,G.jsx)(`div`,{className:`pl-7 text-xs text-fg-muted truncate`,children:e.subtitle})]},e.id)})]})}async function IS(e,t,n){try{await e.run(t)}finally{n()}}function LS({onExit:e}){return(0,G.jsxs)(`div`,{"data-testid":`compare-banner`,className:`flex items-center justify-between gap-3 px-4 py-2 bg-accent/10 border-b border-accent/30 text-sm normal-case tracking-normal`,children:[(0,G.jsxs)(`span`,{className:`text-fg-dim truncate`,children:[`Compare mode · two sessions open · press`,` `,(0,G.jsx)(`kbd`,{className:`px-1.5 py-0.5 border border-line rounded text-xs font-mono`,children:`Esc`}),` `,`to exit`]}),(0,G.jsx)(`button`,{type:`button`,onClick:e,"data-testid":`compare-banner-exit`,"aria-label":`Exit compare view`,className:`shrink-0 px-3 py-1 bg-accent text-bg rounded text-xs font-semibold hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-accent/60`,children:`Exit compare ⤫`})]})}function RS(e,t=250){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var zS=!1;function BS(){zS||(zS=!0,ES({id:`palette.close`,title:`Close command palette`,section:`Actions`,keywords:[`dismiss`,`escape`],icon:`✕`,run:e=>e.closePalette()}),ES({id:`help.open`,title:`Open Command Center`,subtitle:`Full help & keyboard reference`,section:`Settings`,keywords:[`help`,`?`,`docs`,`shortcuts`,`center`],icon:`?`,run:e=>e.openHelp()}),ES({id:`collections.create`,title:`New collection`,subtitle:`Create a new collection to group sessions`,section:`Actions`,keywords:[`new`,`collection`,`group`,`folder`],icon:`📁`,run:e=>e.openCreateCollection()}),ES({id:`collections.add-current-session`,title:`Add current session to a collection`,section:`Actions`,keywords:[`collection`,`add`,`organize`],icon:`➕`,run:e=>{e.currentSessionId&&e.openAddToCollection()}}),ES({id:`compare.start`,title:`Start compare — pick a second session`,subtitle:`Open side-by-side transcript diff`,section:`Actions`,keywords:[`compare`,`diff`,`side`,`split`],icon:`⇆`,run:e=>e.startCompare()}),ES({id:`compare.exit`,title:`Exit compare view`,section:`Actions`,keywords:[`compare`,`close`,`exit`],icon:`✕`,run:e=>e.exitCompare()}),ES({id:`session.export`,title:`Export current session as context`,subtitle:`Copy condensed markdown to clipboard`,section:`Actions`,keywords:[`export`,`copy`,`context`,`clipboard`,`markdown`],icon:`📋`,run:e=>{e.currentSessionId&&e.exportCurrentSession()}}),ES({id:`semantic.toggle`,title:`Toggle semantic search`,subtitle:`AI-powered search by concept (requires v0.11)`,section:`Settings`,keywords:[`semantic`,`ai`,`search`,`mode`],icon:`✨`,run:e=>e.toggleSemantic()}),ES({id:`threads.intro.replay`,title:`Replay threads tour`,subtitle:`Play the 3-step Threads explainer again`,section:`Settings`,keywords:[`threads`,`intro`,`tour`,`replay`,`onboarding`,`help`],icon:`🧵`,run:e=>e.replayThreadsIntro()}),ES({id:`nav.home`,title:`Go home — clear filters`,subtitle:`Clear project, session, search`,section:`Jump`,keywords:[`home`,`reset`,`clear`],icon:`⌂`,run:e=>e.navigate({project:null,session:null,msg:null,q:``,col:null,view:null})}),DS(e=>e.sessions.slice(0,10).map((e,t)=>{let n=e.alias||(e.first_user_message?e.first_user_message.slice(0,80).replace(/\s+/g,` `).trim():``)||`(no prompt)`;return{id:`jump.session.${e.id}`,title:`Jump to: ${n}`,subtitle:`${e.project} · ${e.message_count} msgs · ${e.id.slice(0,8)}`,section:`Jump`,keywords:[e.id,e.id.slice(0,8),e.project,e.alias??``,...e.tags.map(e=>`#${e}`),`recent${t+1}`].filter(Boolean),icon:`↳`,run:t=>t.navigate({session:e.id,project:e.project,msg:null,view:null})}})))}BS();function VS(){let[e,t]=Nn(),n=RS(e.q,120),[r,i]=(0,W.useState)(`all`),[a,o]=(0,W.useState)(!1),s=!!q({queryKey:[`semanticStatus`],queryFn:()=>Z.getSemanticStatus(),refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}).data?.enabled,c=a&&s,[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),_=Xx(),[v,y]=(0,W.useState)(null),b=_.data?.state.threadsIntroSeen===!0,x=null;h===`show`?x=`onboarding`:v===`show`&&e.view===`threads`?x=`threadsIntro`:h!==`hide`&&_.shouldShow?x=`onboarding`:v!==`hide`&&_.data&&!b&&e.view===`threads`&&(x=`threadsIntro`);let S=x===`onboarding`,C=x===`threadsIntro`,[w,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(!1),[A,j]=(0,W.useState)(!1),[M,ee]=(0,W.useState)(null),[N,te]=(0,W.useState)(null),[P,F]=(0,W.useState)(!1),I=(0,W.useCallback)(()=>{if(!e.thread){Q({message:`Open a thread first to share it.`,tone:`info`});return}ee({threadId:e.thread})},[e.thread]),L=(0,W.useCallback)(async()=>{if(P)return;let t=document.querySelector(`[data-share-capture="patterns-graph"]`);if(!t){Q({message:`Switch to the Galaxy tab on the Patterns page first.`,tone:`info`});return}F(!0);try{let{captureNodeAsDataUrl:n}=await dn(async()=>{let{captureNodeAsDataUrl:e}=await import(`./captureNode-Da1ofkVZ.js`);return{captureNodeAsDataUrl:e}},[],import.meta.url),r=t.getBoundingClientRect(),i=968*2,a=r.height/r.width,o=Math.round(i*a);te({heroImage:await n(t,{width:Math.round(r.width),height:Math.round(r.height),canvasWidth:i,canvasHeight:o,pixelRatio:1}),scopeLabel:e.project?`Project: ${e.project}`:`All projects`})}catch(e){console.error(`[Share] capture failed:`,e),Q({message:`Could not capture the patterns graph. `+(e instanceof Error?e.message:``),tone:`error`})}finally{F(!1)}},[P,e.project]);(0,W.useEffect)(()=>{let n=n=>{let r=n.target,i=!!r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable);if(n.key===`/`&&!i){n.preventDefault();let e=document.querySelector(`input[type="search"]`);e?.focus(),e?.select()}else if(n.key===`?`&&!i)n.preventDefault(),t({view:`help`});else if(n.key===`Escape`&&i&&r?.getAttribute(`type`)===`search`)t({q:``}),r.blur();else if(n.key===`Escape`&&!i&&e.view&&e.view!==null)n.preventDefault(),t({view:null,thread:null,helpSection:null});else if(n.key===`c`&&!i&&!n.metaKey&&!n.ctrlKey)n.preventDefault(),u(!0);else if((n.metaKey||n.ctrlKey)&&n.shiftKey&&(n.key===`A`||n.key===`a`))e.session&&(n.preventDefault(),f(!0));else if((n.metaKey||n.ctrlKey)&&n.shiftKey&&(n.key===`C`||n.key===`c`)){n.preventDefault();let e=document.querySelector(`[data-collections-focus]`);e?.focus(),e?.scrollIntoView({block:`nearest`})}else if((n.metaKey||n.ctrlKey)&&!n.shiftKey&&!n.altKey&&(n.key===`k`||n.key===`K`))n.preventDefault(),T(e=>!e);else if((n.metaKey||n.ctrlKey)&&n.key===`\\`){n.preventDefault();let e=`claude-recall:sessions-pane`,t=`${e}:collapsed`,r=localStorage.getItem(t)===`1`?`0`:`1`;localStorage.setItem(t,r),Rn(e)}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,e.session,e.view]),(0,W.useEffect)(()=>{if(!e.compareWith)return;let n=e=>{if(e.key!==`Escape`)return;let n=e.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||t({compareWith:null})};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e.compareWith,t]);let R=n.trim().length>1,z=r===`project`?e.project:null,B=q({queryKey:[`searchCount`,n,z,c?`semantic`:`fts`],queryFn:()=>Z.search(n,60,z??void 0,c?`semantic`:void 0),enabled:R}),V=(0,W.useMemo)(()=>R?B.data?.hits.length??null:null,[R,B.data]),ne=(0,W.useCallback)(e=>t({q:e}),[t]),H=(0,W.useCallback)(()=>t({view:`help`}),[t]),re=(0,W.useCallback)(()=>t({view:null,helpSection:null}),[t]),ie=(0,W.useCallback)(()=>t({view:`stats`}),[t]),ae=(0,W.useCallback)(()=>t({view:`threads`}),[t]),oe=(0,W.useCallback)(()=>t({view:`graph`}),[t]),se=(0,W.useCallback)(()=>t({view:`suggestions`}),[t]),ce=(0,W.useCallback)(()=>t({view:`patterns`}),[t]),U=(0,W.useCallback)(()=>t({view:null}),[t]),le=(0,W.useCallback)(e=>t({helpSection:e}),[t]),ue=(0,W.useCallback)(e=>t({project:e,session:null,msg:null,col:null}),[t]),de=(0,W.useCallback)((e,n)=>t({session:e,msg:n??null}),[t]),fe=(0,W.useCallback)(async()=>{await _.reset(),g(`show`),t({view:null,helpSection:null})},[_,t]),pe=(0,W.useCallback)(()=>{g(`hide`),y(`hide`)},[]),me=(0,W.useCallback)(async()=>{await _.patch({threadsIntroSeen:!1}),y(`show`),t({view:`threads`,helpSection:null})},[_,t]),he=(0,W.useCallback)(()=>{y(`hide`),g(`hide`)},[]),ge=(0,W.useCallback)(()=>m(!0),[]),_e=(0,W.useCallback)(e=>t({msg:e}),[t]);return(0,G.jsxs)(`div`,{className:`h-full flex flex-col relative`,children:[(0,G.jsx)(Vt,{query:e.q,onQueryChange:ne,matchCount:V,scope:r,onScopeChange:i,canScope:!!e.project,projectName:e.project,onOpenHelp:H,helpActive:e.view===`help`,onOpenStats:ie,statsActive:e.view===`stats`,onOpenThreads:ae,threadsActive:e.view===`threads`,onOpenGraph:oe,graphActive:e.view===`graph`,onOpenSuggestions:se,suggestionsActive:e.view===`suggestions`,onOpenPatterns:ce,patternsActive:e.view===`patterns`,onOpenShare:()=>k(!0),onGoHome:()=>t({view:null,helpSection:null,session:null,msg:null,col:null,project:null,q:``}),semanticAvailable:s,semanticMode:c,onSemanticModeChange:o}),(0,G.jsx)(qt,{}),(0,G.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[(0,G.jsx)(Zr,{selected:e.project,selectedCollection:e.col,onSelect:ue,onCreateCollection:()=>u(!0),onSelectSession:de}),(0,G.jsx)(lc,{projectName:e.project,collectionId:e.col,selectedSessionId:e.session,onSelect:de,searchQuery:n,searchScope:r,semanticMode:c}),(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,"data-compare-wrapper":e.compareWith?`1`:void 0,children:[e.compareWith&&(0,G.jsx)(LS,{onExit:()=>t({compareWith:null})}),(0,G.jsxs)(`div`,{className:`flex-1 flex min-w-0 min-h-0 max-[1100px]:flex-col min-[1101px]:flex-row`,children:[(0,G.jsx)(`div`,{className:`flex-1 flex min-w-0 min-h-0`,children:(0,G.jsx)(ed,{sessionId:e.session,targetMessageUuid:e.msg,onTargetChange:_e,searchQuery:n,isCompareLeft:!!e.compareWith})}),e.compareWith&&(0,G.jsx)(`div`,{className:`flex-1 flex min-w-0 min-h-0 border-t border-line min-[1101px]:border-t-0 min-[1101px]:border-l`,children:(0,G.jsx)(ed,{sessionId:e.compareWith,targetMessageUuid:null,onTargetChange:()=>{},searchQuery:n,isCompareRight:!0,onExitCompare:()=>t({compareWith:null})})})]})]})]}),e.view===`stats`&&(0,G.jsx)(SS,{onClose:U,onSelectSession:e=>de(e)}),e.view===`help`&&(0,G.jsx)(Sf,{initialSectionId:e.helpSection,onClose:re,onSectionChange:le,onReplayOnboarding:fe,onReplayThreadsIntro:()=>void me()}),e.view===`auto-rules`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg overflow-auto`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`Auto-collections`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(Ef,{})]}),e.view===`threads`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-20 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0 share-capture-exclude`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🧵 Threads`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.thread&&(0,G.jsx)(`button`,{type:`button`,onClick:I,className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg-dim hover:text-fg hover:border-accent/60 transition-colors`,title:`Render this thread as a shareable card`,children:`↗ Share thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null,thread:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]})]}),(0,G.jsx)(hp,{})]}),e.view===`graph`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🌌 Cognitive Graph`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(db,{projectName:e.project??`audio-hooks-studio-F`,onPickProject:e=>t({project:e})})})]}),e.view===`suggestions`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`📋 Suggestions Queue`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(Nb,{})})]}),e.view===`patterns`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0 share-capture-exclude`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🐛 Bug Patterns`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void L(),disabled:P,className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg-dim hover:text-fg hover:border-accent/60 transition-colors disabled:opacity-60`,title:`Capture the galaxy view and share it`,children:P?`Capturing…`:`↗ Share patterns`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(Bx,{})})]}),l&&(0,G.jsx)(nr,{mode:`create`,onClose:()=>u(!1),onCreated:e=>{u(!1),t({col:e.id,session:null,msg:null})}}),d&&e.session&&(0,G.jsx)(Bi,{sessionId:e.session,onClose:()=>f(!1),anchor:`center`}),S&&(0,G.jsx)(Qx,{onSelectSession:e=>de(e),onOpenAutoTagSettings:ge,onClose:pe}),C&&(0,G.jsx)(oS,{onClose:he}),(0,G.jsx)(fi,{open:p,onClose:()=>m(!1)}),(0,G.jsx)(zt,{}),w&&(0,G.jsx)(PS,{onClose:()=>T(!1),ctx:{navigate:e=>t(e),openHelp:()=>t({view:`help`}),openCreateCollection:()=>u(!0),openAddToCollection:()=>{e.session&&f(!0)},startCompare:()=>D(!0),exitCompare:()=>t({compareWith:null}),exportCurrentSession:()=>{if(!e.session)return;let t=`recall context ${e.session} | claude`;navigator.clipboard?.writeText(t).catch(()=>void 0)},toggleSemantic:()=>{let e=`claude-recall:semantic-mode`,t=localStorage.getItem(e)===`1`?`0`:`1`;localStorage.setItem(e,t)},replayThreadsIntro:()=>{me()},currentSessionId:e.session,compareSessionId:e.compareWith}}),E&&(0,G.jsx)(Js,{excludeSessionId:e.session,onPick:e=>{D(!1),t({compareWith:e})},onClose:()=>D(!1)}),O&&(0,G.jsx)(Yt,{onClose:()=>k(!1),onPick:n=>{k(!1),n===`stats`?j(!0):n===`thread`?e.view===`threads`&&e.thread?I():(Q({message:`Open the Threads page and pick a thread, then click ↗ Share thread.`,tone:`info`,duration:4e3}),t({view:`threads`})):n===`patterns`?e.view===`patterns`?L():(Q({message:`Open the Patterns page (Galaxy tab), then click ↗ Share patterns.`,tone:`info`,duration:4e3}),t({view:`patterns`})):n===`session`&&(e.session?Q({message:`Click the ↗ Share button on the transcript header to share this session.`,tone:`info`,duration:3e3}):Q({message:`Open a session first, then click the ↗ Share button on its header.`,tone:`info`,duration:3e3}))}}),A&&(0,G.jsx)(_n,{onClose:()=>j(!1)}),M&&(0,G.jsx)(Sn,{threadId:M.threadId,onClose:()=>ee(null)}),N&&(0,G.jsx)(Cn,{heroImage:N.heroImage,scopeLabel:N.scopeLabel,onClose:()=>te(null)})]})}var HS=new We({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}}),US=document.getElementById(`root`);if(!US)throw Error(`root element not found`);ut.createRoot(US).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Je,{client:HS,children:(0,G.jsx)(VS,{})})}));export{u as a,d as i,o as n,c as r,s as t};
|
|
652
|
+
`),`cluster as context`),r()}})]}),!c&&s.length>1&&(0,G.jsxs)(`div`,{className:`border-t border-line bg-bg-elevated/30 max-h-48 overflow-y-auto`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-xs uppercase tracking-wider text-fg-muted font-medium`,children:`Member sessions`}),s.slice(0,12).map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`w-full text-left px-3 py-1.5 text-xs font-mono text-fg-dim hover:text-accent hover:bg-bg-elevated/60`,children:e.slice(0,8)},e)),s.length>12&&(0,G.jsxs)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:[`… and `,s.length-12,` more`]})]}),(0,G.jsxs)(`div`,{className:`py-1 border-t border-line text-sm`,children:[(0,G.jsx)(Fx,{icon:`🤖`,label:c?`Synthesize this finding`:`Synthesize this bug across ${s.length} sessions`,hint:`LLM-powered cross-session bug analysis`,onClick:()=>i({scope:`cluster`,targetId:e.id,mode:`synopsis`,targetLabel:e.snippet||e.id.slice(0,12),memberSessionIds:e.member_session_ids})}),(0,G.jsx)(Fx,{icon:`🧠`,label:`Suggest the root cause`,hint:`Pattern-aware diagnosis`,onClick:()=>i({scope:`cluster`,targetId:e.id,mode:`root_cause`,targetLabel:e.snippet||e.id.slice(0,12),memberSessionIds:e.member_session_ids})}),a>0&&(0,G.jsx)(Fx,{icon:`💾`,label:`View saved reports (${a})`,hint:`Browse past synthesis runs without re-spending tokens`,onClick:o})]})]})}function Fx({icon:e,label:t,hint:n,onClick:r,disabled:i,comingSoon:a}){return(0,G.jsxs)(`button`,{type:`button`,disabled:i,onClick:r,title:a??n,className:`w-full text-left px-3 py-2 flex items-start gap-3 ${i?`opacity-50 cursor-not-allowed`:`hover:bg-bg-elevated/60 cursor-pointer`}`,children:[(0,G.jsx)(`span`,{className:`text-base shrink-0 mt-0.5`,"aria-hidden":!0,children:e}),(0,G.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`span`,{className:`block text-sm text-fg font-medium leading-snug break-words`,children:t}),n&&(0,G.jsx)(`span`,{className:`block text-xs text-fg-muted truncate`,children:n}),a&&(0,G.jsxs)(`span`,{className:`block text-[10px] text-warning mt-0.5`,children:[`⏳ `,a]})]})]})}function Ix(){let[e,t]=(0,W.useState)(!0);return(0,G.jsxs)(`div`,{className:`absolute bottom-3 left-3 bg-bg/95 border border-line rounded-lg backdrop-blur shadow-lg max-w-xs`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e=>!e),className:`w-full flex items-center justify-between px-3 py-2 text-sm font-semibold text-fg hover:bg-bg-elevated/40`,children:[(0,G.jsx)(`span`,{children:`Legend`}),(0,G.jsx)(`span`,{className:`text-fg-muted text-xs`,children:e?`▾`:`▸`})]}),e&&(0,G.jsxs)(`div`,{className:`px-3 pb-3 pt-1 space-y-2.5 text-xs leading-relaxed`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Counts`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`N×`}),` = the bug occurred in N past sessions. `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`1×`}),` means it has only been seen once (a singleton).`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`5×`}),` means five sessions hit the same fingerprint (a real recurring pattern).`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Shapes`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-3 rounded-sm bg-sky-400/30 border border-sky-400 mt-0.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Cluster card`}),`: a unique bug. Project name on top, snippet below.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-4 h-3 rounded-sm border border-fg-muted mt-0.5 shrink-0`,style:{borderStyle:`dashed`}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Dashed card`}),`: cluster marked as fixed.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full bg-cyan-300 mt-1 shrink-0`}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Session dot`}),`: one Claude Code session that hit this bug. Tinted by its project. Click to open the transcript.`]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Regions`}),(0,G.jsxs)(`div`,{className:`text-fg-muted`,children:[`Each `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`dashed-outline box`}),` `,`groups bugs from one project. Cross-project related-edges span between regions.`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Edges`}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mt-2 shrink-0`,style:{borderTop:`2px solid #38bdf8`,opacity:.55}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Cyan line`}),`: cluster ↔ its sessions.`]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block w-5 mt-2 shrink-0`,style:{borderTop:`2px dashed #94a3b8`,opacity:.65}}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:`Gray dashed`}),`: clusters that share an error_type or file.`]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 border-t border-line/50 pt-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:`Controls`}),(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Scroll to zoom. Drag empty space to pan. Click any card or session for details.`})]})]})]})}function Lx(e){let t=new Map,n=new Map,r=new Map;for(let t of e.clusters){let e=t.projects[0]??`(no project)`,n=r.get(e);n?n.push(t):r.set(e,[t])}let i=Array.from(r.entries()).sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0])),a=i.length,o=Math.max(1,Math.ceil(Math.sqrt(a)));function s(e){let t=Math.max(1,Math.ceil(Math.sqrt(e))),n=Math.max(1,Math.ceil(e/t));return{w:t*200+(t-1)*60+100,h:n*230+(n-1)*80+100+32,subCols:t,subRows:n}}let c=i.map(([e,t])=>({project:e,clusters:t,...s(t.length)})),l=Array(o).fill(0),u=[];c.forEach((e,t)=>{let n=t%o,r=Math.floor(t/o);e.w>l[n]&&(l[n]=e.w),u[r]===void 0&&(u[r]=0),e.h>u[r]&&(u[r]=e.h)});function d(e){let t=80;for(let n=0;n<e;n+=1)t+=l[n]+80;return t}function f(e){let t=80;for(let n=0;n<e;n+=1)t+=u[n]+80;return t}let p=l.reduce((e,t)=>e+t,0)+80*(o+1),m=u.reduce((e,t)=>e+t,0)+80*(u.length+1),h=Math.max(1200,p),g=Math.max(700,m),_=[];c.forEach((e,r)=>{let i=r%o,a=Math.floor(r/o),s=d(i),c=f(a),p=l[i],m=u[a];_.push({project:e.project,cx:s+p/2,cy:c+m/2,w:p,h:m,cluster_count:e.clusters.length});let h=s+50+100,g=c+50+32+45;e.clusters.forEach((r,i)=>{let a=i%e.subCols,o=Math.floor(i/e.subCols),s=h+a*260,c=g+o*310;t.set(r.id,{id:r.id,kind:`cluster`,x:s,y:c,vx:0,vy:0,radius:Tx(r.occurrence_count),fixed:!0}),n.set(r.id,{cluster:r})})});let v=new Map;for(let t of e.member_edges){let e=v.get(t.cluster_id);e?e.push(t.session_id):v.set(t.cluster_id,[t.session_id])}let y=new Set;for(let[r,i]of v){let a=t.get(r);if(!a)continue;let o=i.length;i.forEach((r,i)=>{if(y.has(r))return;y.add(r);let s=Math.PI/2+(i/Math.max(1,o)-.5)*Math.PI*.9,c=e.sessions.find(e=>e.session_id===r);t.set(r,{id:r,kind:`session`,x:a.x+Math.cos(s)*70,y:a.y+Math.sin(s)*70,vx:0,vy:0,radius:Ox}),c&&n.set(r,{session:c})})}for(let r of e.sessions)t.has(r.session_id)||(t.set(r.session_id,{id:r.session_id,kind:`session`,x:h/2,y:g/2,vx:0,vy:0,radius:Ox}),n.set(r.session_id,{session:r}));for(let e=0;e<30;e+=1){let e=Array.from(t.values()).filter(e=>e.kind===`cluster`),n=!1;for(let t=0;t<e.length;t+=1)for(let r=t+1;r<e.length;r+=1){let i=e[t],a=e[r],o=a.x-i.x,s=a.y-i.y,c=216-Math.abs(o),l=106-Math.abs(s);if(c>0&&l>0){if(c<l){let e=c/2*(o>=0?1:-1);i.x-=e,a.x+=e}else{let e=l/2*(s>=0?1:-1);i.y-=e,a.y+=e}n=!0}}if(!n)break}for(let n of e.member_edges){let e=t.get(n.cluster_id),r=t.get(n.session_id);if(!e||!r)continue;let i=r.x-e.x,a=r.y-e.y,o=114+r.radius,s=59+r.radius,c=o-Math.abs(i),l=s-Math.abs(a);c>0&&l>0&&(c<l?r.x=e.x+(i>=0?o:-o):r.y=e.y+(a>=0?s:-s))}return{width:h,height:g,nodes:t,nodeMeta:n,regions:_}}function Rx(e){return e.slice(0,8)}function zx(e){if(!e)return`—`;try{return new Date(e).toISOString().slice(0,10)}catch{return e}}function Bx(){let e=K(),[,t]=Nn(),[n,r]=(0,W.useState)(`clusters`),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.useState)(3),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(new Set),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(null),v=q({queryKey:[`bug-patterns`,i,o],queryFn:()=>Z.listBugPatterns({minCount:o,status:i,limit:200})}),y=q({queryKey:[`bug-patterns`,`detail`,c],queryFn:()=>c?Z.getBugPattern(c):Promise.resolve(null),enabled:!!c}),b=J({mutationFn:e=>Z.resolveBugPattern(e.clusterId,e.sessionId,e.fixSummary),onSuccess:()=>{Q({message:`Cluster marked resolved`,tone:`success`}),p(null),h(``),e.invalidateQueries({queryKey:[`bug-patterns`]})},onError:e=>{Q({message:`Resolve failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),x=J({mutationFn:e=>Z.splitBugPattern(e.clusterId,e.memberSessionIds),onSuccess:()=>{Q({message:`Cluster split`,tone:`success`}),_(null),d(new Set),e.invalidateQueries({queryKey:[`bug-patterns`]})},onError:e=>{Q({message:`Split failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}}),S=v.data?.clusters??[],C=v.data?.total??0,w=y.data?.cluster??null,T=y.data?.members??[],E=(0,W.useMemo)(()=>{let e=new Set;for(let t of T)t.project&&e.add(t.project);return Array.from(e).sort()},[T]);function D(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function O(e){t({session:e,view:null})}return(0,G.jsxs)(`div`,{className:`h-full flex flex-col text-sm overflow-hidden`,children:[(0,G.jsx)(tx,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-4 pt-2 border-b border-line shrink-0`,children:[(0,G.jsx)(Wx,{active:n===`clusters`,onClick:()=>r(`clusters`),label:`Clusters`,hint:`Recurring bugs across sessions (≥ min-count)`}),(0,G.jsx)(Wx,{active:n===`findings`,onClick:()=>r(`findings`),label:`All findings`,hint:`Every bug signature extracted, including singletons`}),(0,G.jsx)(Wx,{active:n===`galaxy`,onClick:()=>r(`galaxy`),label:`🌌 Galaxy`,hint:`Force-directed visualization of bug clusters and the sessions that hit them`})]}),n===`findings`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(ix,{})}),n===`galaxy`&&(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,"data-share-capture":`patterns-graph`,children:(0,G.jsx)(kx,{})}),n===`clusters`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b border-line shrink-0`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-fg-dim`,children:[`status`,(0,G.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`bg-bg-elevated border border-line rounded px-1.5 py-1 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:`all`}),(0,G.jsx)(`option`,{value:`open`,children:`open`}),(0,G.jsx)(`option`,{value:`resolved`,children:`resolved`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-fg-dim`,children:[`min count`,(0,G.jsx)(`input`,{type:`number`,min:2,value:o,onChange:e=>s(Math.max(2,Math.floor(Number(e.target.value)||3))),className:`bg-bg-elevated border border-line rounded px-1.5 py-1 w-16 text-xs`})]}),(0,G.jsx)(`div`,{className:`ml-auto text-xs text-fg-muted`,children:v.isLoading?`Loading…`:`${S.length} of ${C} cluster${C===1?``:`s`}`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[!v.isLoading&&S.length===0&&(0,G.jsx)(Gx,{minCount:o}),S.map(e=>(0,G.jsx)(Vx,{cluster:e,expanded:c===e.id,onToggle:()=>{l(c===e.id?null:e.id),d(new Set)},children:c===e.id&&(0,G.jsx)(Hx,{cluster:w??e,members:T,loading:y.isLoading,projects:E,selected:u,onToggleSelected:D,onClearSelected:()=>d(new Set),onOpenSession:O,onMarkResolved:(t,n)=>{p({clusterId:e.id,sessionId:t,sessionTitle:n}),h(``)},onSplit:t=>_({clusterId:e.id,memberSessionIds:t})})},e.id))]})]}),f&&(0,G.jsxs)(Ux,{onClose:()=>p(null),children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:`Mark fix as working`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-dim mb-3`,children:[`Attach `,(0,G.jsx)(`span`,{className:`text-accent`,children:f.sessionTitle}),` as the fix that resolved this bug pattern. Future occurrences will surface this session as the recommended remedy.`]}),(0,G.jsx)(`label`,{className:`block text-xs text-fg-dim mb-1`,children:`Fix summary`}),(0,G.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:`e.g. wrapped the optional chain with a typeof check; root cause was an async race`,className:`w-full bg-bg-elevated border border-line rounded p-2 text-xs h-24 mb-3 focus:outline-none focus:border-accent`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(null),className:`text-xs px-3 py-1.5 border border-line rounded text-fg-dim hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,disabled:!m.trim()||b.isPending,onClick:()=>{f&&b.mutate({...f,fixSummary:m})},className:`text-xs px-3 py-1.5 rounded bg-accent text-bg font-medium disabled:opacity-50 disabled:cursor-not-allowed`,children:b.isPending?`Saving…`:`Mark fix worked`})]})]}),g&&(0,G.jsxs)(Ux,{onClose:()=>_(null),children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:`Split cluster`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-dim mb-3`,children:[`Move `,g.memberSessionIds.length,` member`,g.memberSessionIds.length===1?``:`s`,` into a new cluster. The original retains the rest. Both clusters keep the same`,` `,(0,G.jsx)(`code`,{children:`signature_hash`}),` and can be marked resolved independently.`]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>_(null),className:`text-xs px-3 py-1.5 border border-line rounded text-fg-dim hover:text-fg`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,disabled:x.isPending,onClick:()=>x.mutate(g),className:`text-xs px-3 py-1.5 rounded bg-accent text-bg font-medium disabled:opacity-50`,children:x.isPending?`Splitting…`:`Split off`})]})]})]})}function Vx({cluster:e,expanded:t,onToggle:n,children:r}){let i=e.resolved_in_session_id?`resolved`:`open`;return(0,G.jsxs)(`div`,{className:`border-b border-line`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:n,className:`w-full px-4 py-3 flex items-start gap-3 hover:bg-bg-elevated text-left`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted text-xs mt-0.5 w-4 shrink-0`,children:t?`▾`:`▸`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded uppercase font-semibold tracking-wide `+(i===`resolved`?`bg-emerald-500/20 text-emerald-300`:`bg-red-500/20 text-red-300`),children:i===`resolved`?`✓ resolved`:`open`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.occurrence_count,` occurrence`,e.occurrence_count===1?``:`s`]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`first `,zx(e.first_seen_at),` →`,` `,zx(e.last_seen_at)]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`·`}),(0,G.jsx)(`code`,{className:`text-[10px] text-fg-muted`,children:e.signature_hash.slice(0,8)})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg leading-snug truncate`,title:e.example_message,children:e.example_message||(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`(no message)`})}),i===`resolved`&&e.fix_summary&&(0,G.jsxs)(`div`,{className:`text-[11px] text-emerald-300/80 mt-1 truncate`,title:e.fix_summary,children:[`fix: `,e.fix_summary]})]})]}),r]})}function Hx({cluster:e,members:t,loading:n,projects:r,selected:i,onToggleSelected:a,onClearSelected:o,onOpenSession:s,onMarkResolved:c,onSplit:l}){let u=!!e.resolved_in_session_id,d=i.size>0&&i.size<t.length;return(0,G.jsxs)(`div`,{className:`px-4 pb-4 pl-11 bg-bg-elevated/40`,children:[r.length>1&&(0,G.jsxs)(`div`,{className:`text-[11px] text-amber-300/80 mb-2`,children:[`🌐 cross-project — appears in `,r.length,` projects:`,` `,r.join(`, `)]}),n&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted py-2`,children:`Loading members…`}),!n&&t.length===0&&(0,G.jsx)(`div`,{className:`text-xs text-fg-muted py-2`,children:`No members.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!d,onClick:()=>l(Array.from(i)),className:`text-[11px] px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-accent disabled:opacity-40 disabled:cursor-not-allowed`,title:`Move selected members into a new cluster`,children:i.size>0?`Split off ${i.size} member${i.size===1?``:`s`}`:`Select members to split`}),i.size>0&&(0,G.jsx)(`button`,{type:`button`,onClick:o,className:`text-[11px] text-fg-muted hover:text-fg`,children:`clear`})]}),(0,G.jsx)(`ul`,{className:`space-y-1`,children:t.map(t=>{let n=e.resolved_in_session_id===t.session_id,r=i.has(t.session_id);return(0,G.jsxs)(`li`,{className:`flex items-start gap-2 py-1 px-2 rounded `+(n?`bg-emerald-500/10`:``),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>a(t.session_id),className:`mt-1 shrink-0`,disabled:u,title:u?`Cannot split resolved cluster`:`Select for split`}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(t.session_id),className:`text-xs text-fg hover:text-accent text-left truncate w-full`,title:t.session_id,children:[t.project&&(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[`[`,t.project,`] `]}),t.title,(0,G.jsxs)(`span`,{className:`text-fg-muted ml-1`,children:[`(`,Rx(t.session_id),`)`]})]}),t.started_at&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted`,children:zx(t.started_at)})]}),n&&(0,G.jsx)(`span`,{className:`text-[10px] text-emerald-300 self-center`,children:`✓ fix`}),!u&&!n&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>c(t.session_id,t.title),className:`text-[10px] px-1.5 py-0.5 border border-line rounded text-fg-muted hover:text-emerald-300 hover:border-emerald-500/40 self-center shrink-0`,title:`Mark this session's fix as the resolution for this cluster`,children:`Mark fix worked`})]},t.session_id)})})]})}function Ux({onClose:e,children:t}){return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-center justify-center p-4`,onClick:e,children:(0,G.jsx)(`div`,{className:`bg-bg border border-line rounded-lg p-4 max-w-md w-full`,onClick:e=>e.stopPropagation(),children:t})})}function Wx({active:e,onClick:t,label:n,hint:r}){return(0,G.jsx)(`button`,{type:`button`,onClick:t,title:r,className:`px-4 py-2 text-sm font-medium rounded-t-md border-b-2 transition-colors `+(e?`text-fg border-accent bg-bg-elevated/40`:`text-fg-muted hover:text-fg border-transparent hover:bg-bg-elevated/20`),children:n})}function Gx({minCount:e}){let{data:t}=q({queryKey:[`bug-patterns`,`setup-status`],queryFn:()=>Z.getBugPatternsSetupStatus()}),n=t?.totals,r=(t?.projects??[]).filter(e=>e.extracted_sessions>0).length,i=n?.extracted_sessions??0;return(0,G.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6 space-y-6`,children:[(0,G.jsx)(Jx,{}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`What is a cluster?`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted leading-relaxed`,children:`A cluster is a group of past Claude Code sessions that all hit the same bug fingerprint. Recall recognizes when the same error shape, snippet, and file pattern shows up across multiple sessions, and groups them so you can deal with them as one unit instead of N separate findings.`})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Why clusters earn their own tab`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-sm`,children:[(0,G.jsx)(Kx,{icon:`🔁`,title:`Recurrence detection`,body:`Five sessions hit the same NPE? Cluster forms. You see "this is a pattern", not just a bunch of disconnected findings.`}),(0,G.jsx)(Kx,{icon:`🔧`,title:`Linked fix forever`,body:`Mark one member "this fix worked". Every future occurrence of the same fingerprint surfaces the fix automatically.`}),(0,G.jsx)(Kx,{icon:`🌐`,title:`Cross-project visibility`,body:`Same auth bug in three different repos clusters together so you can see it as one concern, not three.`}),(0,G.jsx)(Kx,{icon:`📊`,title:`Top-of-list ranking`,body:`Clusters sort by occurrence count. Your worst-recurring bugs surface first, automatically.`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Why you have zero clusters right now`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated/30 p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Sessions extracted across all projects`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:i})]}),(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Projects with at least one extraction`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:r})]}),(0,G.jsxs)(`div`,{className:`flex justify-between text-fg-muted`,children:[(0,G.jsx)(`span`,{children:`Current cluster threshold (min-count)`}),(0,G.jsx)(`strong`,{className:`text-fg tabular-nums`,children:e})]}),(0,G.jsxs)(`div`,{className:`text-fg-muted leading-relaxed border-t border-line pt-2 mt-2`,children:[`For a cluster to form, the `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`same fingerprint`}),` must appear in `,(0,G.jsxs)(`strong`,{className:`text-fg`,children:[`at least `,e,` sessions`]}),`. With`,` `,i===0?`no extractions yet`:`only ${i} session${i===1?``:`s`} extracted`,r<=1?` from a single project`:` across ${r} projects`,`, there is not enough cross-session signal yet to cluster anything. This is mathematically expected, not a bug.`]})]})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`How to get clusters to appear, in order of value`}),(0,G.jsx)(qx,{step:1,title:`Extract more projects`,body:`More extracted sessions = more chances of finding recurring bugs. Pick 2-3 projects you actually mine bugs from. The 🚀 run buttons in Setup & Status above launch each.`}),(0,G.jsx)(qx,{step:2,title:`Run inference with semantic mode`,body:`Fuzzy-merges "same bug, different wording" via local embeddings. No API cost. Run after each extraction batch.`,command:`recall infer-bug-patterns --semantic`}),(0,G.jsx)(qx,{step:3,title:`Lower the threshold (last resort)`,body:`Drop min-count to 2 to surface pairs. Less reliable signal (a pair could be coincidence) but useful for spot-checking before you have lots of data.`,command:`recall infer-bug-patterns --semantic --min-cluster-size 2`})]}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted text-center pt-2`,children:[`Single findings live on the`,` `,(0,G.jsx)(`strong`,{className:`text-fg`,children:`All findings`}),` tab. Findings only graduate to clusters when their fingerprint repeats.`]})]})}function Kx({icon:e,title:t,body:n}){return(0,G.jsxs)(`div`,{className:`rounded-lg border border-line bg-bg-elevated/30 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-1`,children:[(0,G.jsx)(`span`,{className:`text-base`,"aria-hidden":!0,children:e}),(0,G.jsx)(`span`,{className:`font-semibold text-fg`,children:t})]}),(0,G.jsx)(`div`,{className:`text-fg-muted leading-relaxed`,children:n})]})}function qx({step:e,title:t,body:n,command:r}){let[i,a]=(0,W.useState)(!1);function o(){r&&navigator.clipboard.writeText(r).then(()=>{a(!0),setTimeout(()=>a(!1),1500)})}return(0,G.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,G.jsx)(`div`,{className:`shrink-0 w-7 h-7 rounded-full bg-accent/15 border border-accent/40 text-accent text-sm font-semibold flex items-center justify-center`,children:e}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg text-sm`,children:t}),(0,G.jsx)(`div`,{className:`text-sm text-fg-muted leading-relaxed`,children:n}),r&&(0,G.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-2 text-xs font-mono px-2 py-1 rounded border border-line hover:border-accent text-fg-dim hover:text-accent`,title:`Copy this command`,children:[(0,G.jsx)(`span`,{children:r}),(0,G.jsx)(`span`,{className:`text-fg-muted`,children:i?`✓ copied`:`copy`})]})]})]})}function Jx(){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-bg-elevated/30 p-5`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-widest text-fg-muted font-semibold mb-3 text-center`,children:`How clusters work`}),(0,G.jsxs)(`svg`,{viewBox:`0 0 560 180`,className:`w-full h-auto`,role:`img`,"aria-label":`Three session dots converge into one cluster node with a linked fix badge.`,children:[[{y:40,label:`Session A`},{y:90,label:`Session B`},{y:140,label:`Session C`}].map((e,t)=>(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`circle`,{cx:60,cy:e.y,r:14,className:`fill-bg stroke-line`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:60,y:e.y+4,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`◯`}),(0,G.jsx)(`text`,{x:60,y:e.y+30,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:e.label}),(0,G.jsx)(`line`,{x1:78,y1:e.y,x2:232,y2:90,className:`stroke-sky-500/50`,strokeWidth:1.2,strokeDasharray:`3 3`})]},t)),(0,G.jsx)(`rect`,{x:235,y:60,width:120,height:60,rx:8,className:`fill-sky-500/15 stroke-sky-400`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:295,y:88,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`🐛 Cluster`}),(0,G.jsx)(`text`,{x:295,y:104,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`same bug fingerprint`}),(0,G.jsx)(`line`,{x1:358,y1:90,x2:432,y2:90,className:`stroke-accent`,strokeWidth:1.5,markerEnd:`url(#explainer-arrow)`}),(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`explainer-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`fill-accent`})})}),(0,G.jsx)(`rect`,{x:435,y:60,width:110,height:60,rx:8,className:`fill-accent/15 stroke-accent`,strokeWidth:1.5}),(0,G.jsx)(`text`,{x:490,y:88,textAnchor:`middle`,className:`fill-fg text-[12px] font-semibold`,children:`✓ Linked fix`}),(0,G.jsx)(`text`,{x:490,y:104,textAnchor:`middle`,className:`fill-fg-muted text-[10px]`,children:`surfaces next time`})]})]})}var Yx=[`onboarding`];function Xx(){let e=K(),t=q({queryKey:Yx,queryFn:()=>Z.getOnboarding(),staleTime:6e4,refetchOnWindowFocus:!1}),n=J({mutationFn:e=>Z.patchOnboarding(e),onSuccess:t=>{e.setQueryData(Yx,e=>e&&{...e,state:t})}}),r=J({mutationFn:()=>Z.resetOnboarding(),onSuccess:t=>{e.setQueryData(Yx,e=>e&&{...e,state:t})}}),i=!!t.data&&!t.data.state.completed&&!t.data.state.skipped;return{data:t.data,isLoading:t.isLoading,shouldShow:i,patch:e=>n.mutateAsync(e),reset:()=>r.mutateAsync()}}var Zx=[{id:`intro`,title:`Your most recent session`},{id:`resume`,title:`Resume it in Claude Code`},{id:`auto-tag`,title:`Let Recall organize it`}];function Qx({onSelectSession:e,onOpenAutoTagSettings:t,onClose:n}){let r=Xx(),i=r.data?.mostRecentSession??null,[a,o]=(0,W.useState)(0),s=Zx[a].id,c=q({queryKey:[`mcp-install-status`],queryFn:()=>Z.getMcpInstallStatus(),enabled:a>=1,staleTime:3e4}),[l,u]=(0,W.useState)(!1);(0,W.useEffect)(()=>{l||s!==`intro`||!i||(e(i.id),u(!0))},[l,s,i,e]),(0,W.useEffect)(()=>{r.patch({completedSteps:[s]})},[s]);let d=(0,W.useCallback)(()=>{n(),r.patch({completed:!0,finishedAt:new Date().toISOString(),completedSteps:Zx.map(e=>e.id)}).catch(()=>{})},[r,n]),f=(0,W.useCallback)(()=>{n(),r.patch({skipped:!0,finishedAt:new Date().toISOString()}).catch(()=>{})},[r,n]);ui(!0,f);let p=(0,W.useCallback)(()=>{a<Zx.length-1?o(e=>e+1):d()},[a,d]),m=(0,W.useCallback)(()=>{a>0&&o(e=>e-1)},[a]);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-end sm:items-center justify-center p-4 sm:p-6`,role:`dialog`,"aria-labelledby":`onboarding-title`,"aria-modal":`true`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[520px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-2xl flex flex-col`,children:[(0,G.jsx)($x,{stepIdx:a,onSkip:()=>void f()}),(0,G.jsxs)(`div`,{className:`flex-1 px-6 py-5`,children:[s===`intro`&&(0,G.jsx)(tS,{session:i,isLoading:r.isLoading,onReveal:()=>{i&&e(i.id)}}),s===`resume`&&(0,G.jsx)(nS,{session:i}),s===`auto-tag`&&(0,G.jsx)(rS,{claudeCliAvailable:!!c.data?.claudeCliAvailable,mcpInstalled:!!c.data?.installed,onOpenSettings:()=>{t(),d()},onFinish:d})]}),(0,G.jsx)(eS,{stepIdx:a,canBack:a>0,onBack:m,onNext:p,onSkip:()=>void f(),isFinalStep:a===Zx.length-1})]})})}function $x({stepIdx:e,onSkip:t}){return(0,G.jsxs)(`div`,{className:`px-6 py-4 border-b border-line flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsx)(`img`,{src:Bt,alt:``,className:`h-7 w-7 rounded-md shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{id:`onboarding-title`,className:`text-sm font-semibold text-fg leading-none`,children:[`Welcome to `,(0,G.jsxs)(`span`,{className:`text-base font-extrabold`,children:[`Claude `,(0,G.jsx)(`span`,{className:`text-accent`,children:`Recall`})]})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1`,children:[`Step `,e+1,` of `,Zx.length,` · `,Zx[e].title]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-fg-muted hover:text-fg whitespace-nowrap`,title:`dismiss the tour (Esc)`,children:`I’ll explore myself →`})]})}function eS({stepIdx:e,canBack:t,onBack:n,onNext:r,onSkip:i,isFinalStep:a}){return(0,G.jsxs)(`div`,{className:`px-6 py-3 border-t border-line flex items-center justify-between gap-2 bg-bg-elevated`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:Zx.map((t,n)=>(0,G.jsx)(`span`,{className:`h-1.5 w-6 rounded-full transition-colors ${n<=e?`bg-accent`:`bg-line`}`},t.id))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Skip`}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg text-xs px-3 py-1 border border-line rounded`,children:`← Back`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`bg-accent text-bg rounded px-4 py-1.5 text-xs font-semibold hover:opacity-90`,children:a?`Finish`:`Next →`})]})]})}function tS({session:e,isLoading:t,onReveal:n}){if(t)return(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Looking for your most recent session…`});if(!e)return(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`p`,{className:`text-fg`,children:[`Claude Recall watches `,(0,G.jsx)(`code`,{className:`font-mono text-xs text-fg-muted`,children:`~/.claude/projects/`}),` `,`and indexes every session Claude Code has written — automatically, in the background, offline.`]}),(0,G.jsx)(`p`,{className:`text-fg-muted`,children:`No sessions are indexed yet. Start a Claude Code conversation anywhere on this machine, then come back — Recall will pick it up within seconds.`})]});let r=e.alias??e.first_user_message??e.id.slice(0,8),i=e.ended_at??e.started_at;return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`Here’s your `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`most recent Claude Code session`}),` — already indexed and searchable. Nothing left the machine; Recall just watches the files Claude Code was already writing.`]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-accent/40 bg-accent/10 px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-accent font-semibold mb-1`,children:`Highlighted behind this dialog`}),(0,G.jsx)(`div`,{className:`text-sm text-fg font-medium truncate`,title:r,children:r}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1 flex flex-wrap gap-x-3 gap-y-0.5`,children:[(0,G.jsx)(`span`,{children:e.project}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[e.message_count,` messages`]}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{children:iS(i)})]}),(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,8)})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs text-accent hover:underline`,children:`Re-highlight the transcript behind this dialog →`})]})}function nS({session:e}){let[t,n]=(0,W.useState)(!1),r=(0,W.useMemo)(()=>e?`recall context ${e.id.slice(0,8)} | claude`:``,[e]),i=(0,W.useCallback)(async()=>{if(r)try{await navigator.clipboard.writeText(r),n(!0),Q({message:`Command copied. Paste it in a terminal to start a fresh Claude Code session with full context.`,tone:`success`,duration:8e3}),setTimeout(()=>n(!1),2500)}catch(e){Q({message:`Clipboard blocked: ${e instanceof Error?e.message:String(e)}. Copy the command manually.`,tone:`error`})}},[r]);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`This is the feature nobody else has: `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`pipe any past session back into a new Claude Code conversation`}),`. Claude wakes up already knowing everything you discussed before.`]}),e?(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2`,children:(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg break-all`,children:r})}):(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Once you have indexed sessions, this step shows a one-click copy for the most recent one.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void i(),disabled:!r,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed`,children:t?`✓ Copied — paste into a terminal`:`📋 Copy resume command to clipboard`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted leading-relaxed`,children:(0,G.jsxs)(`p`,{children:[`Paste the command in any terminal to launch a fresh `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`claude`}),` `,`session with the prior context preinjected. You can also run`,` `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`recall context <id> --full`}),` for the complete transcript or `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`--since 2h`}),` to clip just the last two hours.`]})})]})}function rS({claudeCliAvailable:e,mcpInstalled:t,onOpenSettings:n,onFinish:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(0),f=(0,W.useRef)(null),p=e&&t;(0,W.useEffect)(()=>{if(!i)return;let e=f.current??Date.now();f.current=e,d(Math.floor((Date.now()-e)/1e3));let t=window.setInterval(()=>{d(Math.floor((Date.now()-e)/1e3))},1e3);return()=>window.clearInterval(t)},[i]);let m=(0,W.useCallback)(async()=>{if(!p||i)return;let e=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`scan-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;a(!0),s(null),l(null),f.current=Date.now(),d(0);let t=Z.subscribeToScanProgress(e);t.addEventListener(`progress`,e=>{try{let t=JSON.parse(e.data);l({current:t.current,total:t.total,sessionLabel:t.sessionLabel})}catch{}}),t.addEventListener(`done`,()=>{t.close()}),t.onerror=()=>{t.close()};try{let t=await Z.runClaudeCliScan({untaggedOnly:!0,limit:10},{scanId:e});s({tagsAdded:t.tagsAdded,success:t.success}),t.success?Q({message:`Auto-tag added ${t.tagsAdded} tag${t.tagsAdded===1?``:`s`} across your 10 most recent sessions.`,tone:`success`,duration:8e3}):Q({message:`Auto-tag run finished with exit ${t.exitCode??`?`}. Check the ⚙ button on the top bar for details.`,tone:`error`})}catch(e){Q({message:`Auto-tag failed: ${e instanceof Error?e.message:String(e)}`,tone:`error`})}finally{t.close(),a(!1),f.current=null}},[p,i]),h=(0,W.useMemo)(()=>{if(!c||c.current<2||c.total<=c.current)return null;let e=u/c.current;return Math.max(1,Math.round(e*(c.total-c.current)))},[c,u]);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg leading-relaxed`,children:[`Let Claude Recall `,(0,G.jsx)(`span`,{className:`text-accent font-semibold`,children:`auto-tag`}),` your last`,` `,`10 sessions so you can find them by topic later —`,` `,(0,G.jsx)(`code`,{className:`font-mono text-xs`,children:`#auth-fix`}),`,`,` `,(0,G.jsx)(`code`,{className:`font-mono text-xs`,children:`#migration`}),`, and so on. Opt-in, local, reversible.`]}),p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void m(),disabled:i,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90 disabled:opacity-60 disabled:cursor-wait flex items-center justify-center gap-2`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{children:`Tagging via your Claude Code agent…`})]}):(0,G.jsx)(`span`,{children:`🏷 Tag my 10 most recent sessions`})}),i&&(0,G.jsxs)(`div`,{className:`text-xs rounded border border-line bg-bg-elevated px-3 py-2 text-fg-muted`,role:`status`,"aria-live":`polite`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zu,{size:16}),(0,G.jsx)(`span`,{className:`text-fg`,children:c?`Tagging session ${c.current} of ${c.total}`:`Preparing…`})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-[11px]`,children:[(0,G.jsxs)(`span`,{children:[u,`s elapsed`]}),h!==null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsxs)(`span`,{children:[`~`,h,`s remaining`]})]}),c?.sessionLabel&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`·`}),(0,G.jsx)(`span`,{className:`truncate max-w-[24ch]`,title:c.sessionLabel,children:c.sessionLabel})]})]})]}),o&&!i&&(0,G.jsx)(`div`,{className:`text-xs rounded border px-3 py-2 ${o.success?`border-accent/40 bg-accent/10 text-fg`:`border-role-user/40 bg-role-user/10 text-fg`}`,children:o.success?`Added ${o.tagsAdded} tag${o.tagsAdded===1?``:`s`}. You can review or remove them anytime from the session transcript.`:`The agent exited with an error. Open ⚙ on the 🏷 auto-tag button for logs.`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`Uses your existing Claude Code subscription via the Recall MCP server — no extra API cost.`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void r(),className:`text-xs text-fg-muted hover:text-fg`,children:`Skip this — I’ll tag sessions myself →`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2.5 text-xs text-fg-muted space-y-1`,children:[(0,G.jsx)(`div`,{children:`One-click auto-tagging needs two things already set up:`}),(0,G.jsxs)(`ul`,{className:`pl-4 list-disc marker:text-fg-muted space-y-0.5`,children:[(0,G.jsxs)(`li`,{children:[`Recall’s MCP server installed in Claude Code —`,` `,(0,G.jsx)(`span`,{className:t?`text-accent`:`text-role-user`,children:t?`installed ✓`:`not installed`})]}),(0,G.jsxs)(`li`,{children:[`The `,(0,G.jsx)(`code`,{className:`font-mono text-fg`,children:`claude`}),` CLI on your PATH —`,` `,(0,G.jsx)(`span`,{className:e?`text-accent`:`text-role-user`,children:e?`found ✓`:`not found`})]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`w-full bg-accent text-bg rounded px-4 py-2.5 text-sm font-semibold hover:opacity-90`,children:`Set up auto-tagging →`}),(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,children:`You can also paste an Anthropic API key in the same settings dialog if you prefer an API-backed scan.`})]})]})}function iS(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.round(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.round(r/60);if(i<24)return`${i}h ago`;let a=Math.round(i/24);return a<30?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var aS=[{id:`what`,title:`A thread groups sessions by intent`},{id:`how`,title:`Three ways to add a session to a thread`},{id:`pipe`,title:`Pipe a whole thread back into Claude Code`}];function oS({onClose:e}){let t=Xx(),[n,r]=(0,W.useState)(0),i=aS[n].id,a=(0,W.useCallback)(()=>{e(),t.patch({threadsIntroSeen:!0}).catch(()=>{})},[t,e]);ui(!0,a);let o=(0,W.useCallback)(()=>{n<aS.length-1?r(e=>e+1):a()},[n,a]),s=(0,W.useCallback)(()=>{n>0&&r(e=>e-1)},[n]);return(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/60 flex items-end sm:items-center justify-center p-4 sm:p-6`,role:`dialog`,"aria-labelledby":`threads-intro-title`,"aria-modal":`true`,children:(0,G.jsxs)(`div`,{className:`bg-bg border border-line rounded-lg w-[560px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-4rem)] overflow-y-auto shadow-2xl flex flex-col`,children:[(0,G.jsx)(sS,{stepIdx:n,onSkip:a}),(0,G.jsxs)(`div`,{className:`flex-1 px-6 py-5`,children:[i===`what`&&(0,G.jsx)(lS,{}),i===`how`&&(0,G.jsx)(dS,{}),i===`pipe`&&(0,G.jsx)(fS,{})]}),(0,G.jsx)(cS,{stepIdx:n,canBack:n>0,onBack:s,onNext:o,onSkip:a,isFinalStep:n===aS.length-1})]})})}function sS({stepIdx:e,onSkip:t}){return(0,G.jsxs)(`div`,{className:`px-6 py-4 border-b border-line flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-7 w-7 rounded-md bg-accent flex items-center justify-center text-bg font-bold text-sm shrink-0`,children:`🧵`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{id:`threads-intro-title`,className:`text-sm font-semibold text-fg leading-none`,children:`Welcome to Threads`}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted mt-1`,children:[`Step `,e+1,` of `,aS.length,` · `,aS[e].title]})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-fg-muted hover:text-fg whitespace-nowrap`,title:`dismiss the tour (Esc)`,children:`I can explore on my own →`})]})}function cS({stepIdx:e,canBack:t,onBack:n,onNext:r,onSkip:i,isFinalStep:a}){return(0,G.jsxs)(`div`,{className:`px-6 py-3 border-t border-line flex items-center justify-between gap-2 bg-bg-elevated`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:aS.map((t,n)=>(0,G.jsx)(`span`,{className:`h-1.5 w-6 rounded-full transition-colors ${n<=e?`bg-accent`:`bg-line`}`},t.id))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`text-fg-muted hover:text-fg text-xs px-3 py-1`,children:`Skip`}),t&&(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`text-fg-muted hover:text-fg text-xs px-3 py-1 border border-line rounded`,children:`← Back`}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`bg-accent text-bg rounded px-4 py-1.5 text-xs font-semibold hover:opacity-90`,children:a?`Done`:`Next →`})]})]})}function lS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`A thread is the unit of work you remember afterwards. It links one planning session to every session that acts on the plan, so you can keep working across days, branches, and machines, and still pull it all back together in one view.`}),(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated p-4 flex justify-center`,children:(0,G.jsx)(uS,{})}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-muted leading-relaxed`,children:`One origin session at the top. Three child sessions below. The thread is the shape, not any single session.`})]})}function uS(){return(0,G.jsx)(`svg`,{viewBox:`0 0 340 200`,width:`100%`,height:`180`,role:`img`,"aria-label":`Sketch of a thread: one origin session with three child sessions branching below it.`,className:`text-fg`,children:(0,G.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,G.jsxs)(`g`,{transform:`translate(170 32) rotate(-0.8)`,children:[(0,G.jsx)(`rect`,{x:`-60`,y:`-18`,width:`120`,height:`36`,rx:`6`,ry:`6`,strokeWidth:`1.75`}),(0,G.jsx)(`text`,{x:`0`,y:`5`,textAnchor:`middle`,fontSize:`12`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Planning session`})]}),(0,G.jsx)(`path`,{d:`M 150 60 C 140 90, 80 90, 70 130`,strokeWidth:`1.4`}),(0,G.jsx)(`path`,{d:`M 170 62 C 170 95, 170 100, 170 130`,strokeWidth:`1.4`}),(0,G.jsx)(`path`,{d:`M 190 60 C 200 90, 260 90, 270 130`,strokeWidth:`1.4`}),(0,G.jsxs)(`g`,{transform:`translate(70 150) rotate(1.1)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 1`})]}),(0,G.jsxs)(`g`,{transform:`translate(170 150) rotate(-0.6)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 2`})]}),(0,G.jsxs)(`g`,{transform:`translate(270 150) rotate(0.9)`,children:[(0,G.jsx)(`rect`,{x:`-45`,y:`-16`,width:`90`,height:`32`,rx:`6`,ry:`6`,strokeWidth:`1.6`}),(0,G.jsx)(`text`,{x:`0`,y:`4`,textAnchor:`middle`,fontSize:`11`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fill:`currentColor`,stroke:`none`,children:`Execution 3`})]})]})})}function dS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`You can add a session to a thread from three places. Pick whichever one is closest to where you already are.`}),(0,G.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg`,children:[(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`1`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From a session transcript`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Open any session from the sidebar. In the transcript header, click`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`+ Add to thread`}),` and pick the thread you want.`]})]})]}),(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`2`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From this Threads page`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Select a thread on the left. Click`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`+ Add session`}),` on the top right and search for the session by alias, project, or first message.`]})]})]}),(0,G.jsxs)(`li`,{className:`flex gap-3`,children:[(0,G.jsx)(`span`,{className:`shrink-0 h-6 w-6 rounded-full bg-accent/20 text-accent flex items-center justify-center text-xs font-semibold`,"aria-hidden":`true`,children:`3`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`From a terminal`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 leading-relaxed`,children:[`Run`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`recall thread link <session-id> --thread <thread-id>`}),` `,`in a shell. Works in scripts. Short identifiers are fine as long as they are unambiguous.`]})]})]})]})]})}function fS(){return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg leading-relaxed`,children:`When you start a fresh conversation, you can load every session in a thread as context for Claude Code with one command. It wakes up knowing the plan and every execution session that followed, so you pick up exactly where the thread left off.`}),(0,G.jsx)(`div`,{className:`rounded-md border border-line bg-bg-elevated px-3 py-2`,children:(0,G.jsx)(`div`,{className:`font-mono text-xs text-fg break-all`,children:`recall context thread:<id> | claude`})}),(0,G.jsxs)(`ul`,{className:`text-[11px] text-fg-muted leading-relaxed space-y-1 list-disc pl-4 marker:text-fg-muted`,children:[(0,G.jsxs)(`li`,{children:[`Replace`,` `,(0,G.jsx)(`span`,{className:`font-mono text-fg`,children:`<id>`}),` `,`with the thread identifier shown in the list on the left. The first few characters are enough as long as they are unambiguous.`]}),(0,G.jsx)(`li`,{children:`Sessions are concatenated in thread order: origins first, then children in the order they were added.`}),(0,G.jsx)(`li`,{children:`Nothing leaves your machine. The pipe is between two local programs.`})]})]})}function pS(e){let t=e/100;return t===0?`$0.00`:t<.01?`<$0.01`:t<100?`$${t.toFixed(2)}`:t<1e4?`$${t.toFixed(0)}`:`$${(t/1e3).toFixed(1)}k`}function mS(e){let t=e/100;return t===0?`$0.00`:t<1?`$${t.toFixed(4)}`:t<100?`$${t.toFixed(2)}`:`$${t.toLocaleString(void 0,{maximumFractionDigits:2})}`}function hS(e){return!Number.isFinite(e)||e<0?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:e<0xe8d4a51000?`${(e/1e9).toFixed(2)}B`:`${(e/0xe8d4a51000).toFixed(2)}T`}function gS(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function _S(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function vS(e,t){let n=new Map;for(let t of e)n.set(t.day,{tokens:t.tokens,cents:t.cents});if(t===`7d`||t===`30d`){let e=t===`7d`?7:30,r=new Date;r.setHours(0,0,0,0);let i=[];for(let t=e-1;t>=0;t--){let e=new Date(r);e.setDate(e.getDate()-t);let a=gS(e),o=n.get(a);i.push({day:a,tokens:o?.tokens??0,cents:o?.cents??0})}return i}if(e.length===0)return[];let[r,i,a]=[...e].sort((e,t)=>e.day.localeCompare(t.day))[0].day.split(`-`).map(Number),o=new Date(r,i-1,a),s=new Date;s.setHours(0,0,0,0);let c=Math.floor((s.getTime()-o.getTime())/864e5)+1,l=Math.min(90,Math.max(1,c)),u=[];for(let e=l-1;e>=0;e--){let t=new Date(s);t.setDate(t.getDate()-e);let r=gS(t),i=n.get(r);u.push({day:r,tokens:i?.tokens??0,cents:i?.cents??0})}return u}function yS({axis:e,range:t}){let[n,r]=(0,W.useState)(null);if(e.length===0)return(0,G.jsx)(`div`,{className:`text-xs text-fg-muted text-center py-6`,children:`No usage data in this range.`});let i=Math.max(1,...e.map(e=>e.cents)),a=704/e.length,o=Math.max(2,a-2),s=e.length<=7?1:e.length<=14?2:e.length<=30?5:10;return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`svg`,{width:720,height:120,viewBox:`0 0 720 120`,className:`w-full h-auto`,role:`img`,"aria-label":`Daily cost chart`,onMouseLeave:()=>r(null),children:[(0,G.jsx)(`line`,{x1:8,x2:712,y1:102,y2:102,className:`stroke-line`,strokeWidth:1}),e.map((e,t)=>{let s=8+t*a+(a-o)/2,c=e.cents>0?Math.max(2,e.cents/i*98):0,l=102-c,u=n?.i===t,d=e.cents===0;return(0,G.jsxs)(`g`,{children:[(0,G.jsx)(`rect`,{x:8+t*a,y:0,width:a,height:102,fill:`transparent`,onMouseEnter:()=>r({i:t,day:e.day,tokens:e.tokens,cents:e.cents,x:8+t*a+a/2})}),(0,G.jsx)(`rect`,{x:s,y:d?100:l,width:o,height:d?2:c,rx:1,className:d?`fill-line`:u?`fill-accent`:`fill-accent/70`,pointerEvents:`none`})]},e.day)}),e.map((t,n)=>n%s!==0&&n!==e.length-1?null:(0,G.jsx)(`text`,{x:8+n*a+a/2,y:116,textAnchor:`middle`,className:`fill-fg-muted`,fontSize:9,children:_S(t.day)},`tick-${t.day}`))]}),n&&(0,G.jsxs)(`div`,{className:`absolute pointer-events-none bg-bg-elevated border border-line rounded-lg shadow-xl px-3 py-2 text-xs -translate-x-1/2`,style:{left:`${n.x/720*100}%`,top:4},children:[(0,G.jsx)(`div`,{className:`font-medium text-fg`,children:_S(n.day)}),(0,G.jsx)(`div`,{className:`text-accent font-semibold tabular-nums mt-0.5`,children:mS(n.cents)}),(0,G.jsxs)(`div`,{className:`text-fg-muted tabular-nums`,children:[hS(n.tokens),` tokens`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-fg-muted mt-2`,children:[(0,G.jsxs)(`span`,{children:[t===`7d`?`Last 7 days`:t===`30d`?`Last 30 days`:e.length>=90?`Last 90 days (capped for readability)`:`Last ${e.length} days`,` `,`· local time · hover for detail`]}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[`peak `,mS(i)]})]})]})}function bS({text:e,align:t=`center`}){let[n,r]=(0,W.useState)(!1);return(0,G.jsxs)(`span`,{className:`relative inline-block ml-1 align-middle`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,G.jsx)(`span`,{tabIndex:0,role:`button`,"aria-label":e,onFocus:()=>r(!0),onBlur:()=>r(!1),className:`inline-flex items-center justify-center w-[14px] h-[14px] rounded-full border border-line text-fg-muted text-[9px] font-medium cursor-help hover:text-fg hover:border-fg-dim`,children:`?`}),n&&(0,G.jsx)(`span`,{role:`tooltip`,className:`absolute z-50 top-full mt-2 w-64 px-3 py-2 text-xs leading-relaxed bg-bg-elevated border border-line rounded-lg shadow-xl text-fg-muted pointer-events-none whitespace-normal normal-case tracking-normal font-normal `+(t===`left`?`left-0`:t===`right`?`right-0`:`left-1/2 -translate-x-1/2`),children:e})]})}function xS({input:e,output:t,cacheCreate:n,cacheRead:r}){return e+t+n+r===0?(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-2`,children:`no tokens in range`}):(0,G.jsx)(`div`,{className:`mt-2 space-y-1`,children:[{key:`output`,label:`Output`,sub:`what the model wrote`,value:t,cls:`bg-accent`},{key:`cache-r`,label:`Cache read`,sub:`cached prefix re-read each turn · 10× cheaper`,value:r,cls:`bg-fg-muted`},{key:`cache-w`,label:`Cache write`,sub:`first-time cache fills`,value:n,cls:`bg-role-tool`},{key:`input`,label:`Input`,sub:`fresh text sent to the model`,value:e,cls:`bg-role-user`}].sort((e,t)=>t.value-e.value).map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,G.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm shrink-0 `+e.cls}),(0,G.jsx)(`span`,{className:`text-fg w-20 shrink-0`,children:e.label}),(0,G.jsx)(`span`,{className:`text-fg-muted flex-1 truncate`,children:e.sub}),(0,G.jsx)(`span`,{className:`text-fg font-medium tabular-nums`,children:hS(e.value)})]},e.key))})}function SS({onClose:e,onSelectSession:t}){let[n,r]=(0,W.useState)(`30d`),i=K(),[,a]=Nn(),o=q({queryKey:[`statsOverview`,n],queryFn:()=>Z.getOverviewStats(n),refetchInterval:3e4,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(!1),d=J({mutationFn:()=>Z.triggerStatsBackfill(),onMutate:()=>{c({kind:`info`,text:`Scanning…`})},onSuccess:e=>{i.invalidateQueries({queryKey:[`statsOverview`]}),i.invalidateQueries({queryKey:[`sessionStats`]});let t=e.result??null;if(e.mode===`background`){c({kind:`info`,text:`Large backlog — scanning in background. Refresh in a moment.`});return}t&&t.inserted>0?c({kind:`success`,text:`Recovered ${t.inserted.toLocaleString()} usage rows across ${t.sessionsTouched.toLocaleString()} sessions.`}):t&&c({kind:`noop`,text:`Scanned ${t.scanned.toLocaleString()} message${t.scanned===1?``:`s`} — none carried recoverable usage data. These messages are aborted/cancelled assistant turns or pre-v0.10 Claude Code output and can't be priced.`})},onError:e=>{c({kind:`noop`,text:`Backfill failed: ${e.message}`})}}),f=o.data,p=(0,W.useMemo)(()=>f?vS(f.daily,n):[],[f,n]),[m,h]=(0,W.useState)(()=>Date.now());(0,W.useEffect)(()=>{let e=window.setInterval(()=>h(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let g=o.dataUpdatedAt?Math.max(0,Math.floor((m-o.dataUpdatedAt)/1e3)):null,_=g===null?`—`:g<5?`just now`:g<60?`${g}s ago`:g<3600?`${Math.floor(g/60)}m ago`:`${Math.floor(g/3600)}h ago`;return(0,G.jsx)(`div`,{className:`absolute inset-0 z-30 bg-bg/95 backdrop-blur-sm flex items-start justify-center overflow-y-auto`,children:(0,G.jsxs)(`div`,{className:`w-full max-w-4xl p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Cost & tokens`}),(0,G.jsx)(`div`,{className:`text-xs text-fg-muted mt-1`,children:`Local-only — derived from the usage counters Claude Code writes into your session files. No telemetry.`}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o.refetch(),disabled:o.isFetching,title:`Refresh now`,className:`mt-1.5 inline-flex items-center gap-1 text-[10px] text-fg-dim hover:text-fg disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`inline-block `+(o.isFetching?`animate-spin`:``),children:`↻`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:o.isFetching?`refreshing…`:`updated ${_}`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,G.jsx)(`div`,{className:`flex items-stretch text-xs border border-line rounded-lg overflow-hidden`,children:[`7d`,`30d`,`all`].map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:(t===0?``:`border-l border-line `)+`min-w-[72px] px-3 py-2 text-center transition-colors `+(n===e?`bg-accent text-bg font-medium`:`bg-bg-elevated text-fg-dim hover:text-fg`),children:e===`all`?`all-time`:e},e))}),(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-2.5 py-1.5 text-fg-dim hover:text-fg border border-line rounded-lg`,children:`✕ close`})]})]}),o.isLoading&&(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`loading…`}),o.error&&(0,G.jsxs)(`div`,{className:`text-sm text-red-400`,children:[`failed to load: `,o.error.message]}),f&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 mb-6`,children:[(0,G.jsx)(CS,{label:`Estimated cost`,value:f.display.dollars,accent:!0,info:`Sum of all priced tokens × Anthropic list price for each model. Cache reads are 10× cheaper than fresh input. List-price estimate — actual billing may differ.`}),(0,G.jsx)(CS,{label:`Total tokens`,value:f.display.tokens,hint:`${hS(f.outputTokens)} output · ${hS(f.cacheReadTokens)} cache read`,info:`Sum of all four token buckets Anthropic's API reports: input + output + cache-write + cache-read. The big number is usually dominated by cache-read, which re-counts the entire cached prompt prefix on every turn. Cache-read is priced ~10× cheaper than fresh input — see the composition panel below for the full breakdown.`}),(0,G.jsx)(CS,{label:`Sessions`,value:`${f.sessionsWithUsage.toLocaleString()} / ${f.totalSessions.toLocaleString()}`,hint:`with usage / active`,info:n===`all`?`Sessions Claude Recall has indexed: those with at least one priced message vs the total in the database.`:`Sessions active in this window (any message) and the subset that had at least one priced assistant message.`}),(0,G.jsx)(CS,{label:`Primary model`,value:f.byModel[0]?.modelLabel??`—`,hint:f.byModel.length>1?`+${f.byModel.length-1} more`:void 0,info:`Model that produced the most spend in this range. See the By-model table below for the full split.`,infoAlign:`right`})]}),(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Token composition`}),(0,G.jsx)(bS,{text:`The same total, split by what Anthropic counted. Cache-read dominates because every assistant turn reports the full cached prompt prefix as tokens read — priced 10× cheaper than fresh input.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg p-4`,children:(0,G.jsx)(xS,{input:f.inputTokens,output:f.outputTokens,cacheCreate:f.cacheCreateTokens,cacheRead:f.cacheReadTokens})})]}),(f.backfill.pending>0||s)&&!l&&(0,G.jsxs)(`div`,{className:`mb-6 flex items-start justify-between gap-3 rounded-lg px-4 py-3 border `+(s?.kind===`success`?`bg-green-500/10 border-green-500/40`:`bg-bg-elevated border-line`),children:[(0,G.jsxs)(`div`,{className:`text-xs flex-1`,children:[f.backfill.pending>0&&(0,G.jsxs)(`div`,{className:`text-fg font-medium flex items-center gap-1`,children:[(0,G.jsx)(`span`,{children:(()=>{let e=Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0));return e===0?`${f.backfill.pending.toLocaleString()} message${f.backfill.pending===1?``:`s`} can't be priced — nothing to recover.`:`${e.toLocaleString()} of ${f.backfill.pending.toLocaleString()} assistant message${f.backfill.pending===1?``:`s`} missing usage data.`})()}),(0,G.jsx)(bS,{text:`When Claude Recall first imported your sessions, some assistant messages were stored without their token-count metadata — usually because they came from older Claude Code versions, were cancelled mid-stream, or got partial writes during a crash. Backfill re-reads each message's raw JSON locally and recovers any usage data it finds. Anything still missing after a backfill (the "unrecoverable" count) genuinely never had counts recorded by Anthropic and can't be priced. Runs in chunks, transactional, no network, no reindex.`})]}),(0,G.jsx)(`div`,{className:`text-fg-muted mt-0.5`,children:d.isPending?`Scanning… this may take a few seconds.`:s?.text??(f.backfill.pending>0&&Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0))===0?`These are aborted/cancelled assistant turns or pre-v0.10 Claude Code output — Anthropic never recorded their token counts.`:`Backfill re-parses the messages' raw JSON to recover token counts. Local only — no reindex, no network.`)})]}),Math.max(0,f.backfill.pending-(f.backfill.unrecoverable??0))>0?(0,G.jsx)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`text-xs bg-accent text-bg font-medium rounded px-3 py-1.5 disabled:opacity-50 whitespace-nowrap`,children:d.isPending?`scanning…`:`run backfill`}):(0,G.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs text-fg-dim hover:text-fg px-2 py-1.5 whitespace-nowrap`,"aria-label":`Dismiss`,children:`✕`})]}),(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Daily spend`}),(0,G.jsx)(bS,{text:`One bar per local-time day. Empty bars = no priced activity that day. Hover any day for the exact dollar amount and token count. Cost = Σ(tokens × model price).`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg p-3`,children:(0,G.jsx)(yS,{axis:p,range:n})})]}),f.byModel.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`By model`}),(0,G.jsx)(bS,{text:`Per-model token counts and cost in this range. cache_w is normally MUCH larger than input — Claude Code re-caches system prompt + tools + conversation history every turn, and Anthropic reports cumulative cache writes per turn. Pricing: cache_w = 1.25× input, cache_r = 0.1× input. Total cost reflects the right weighting.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`bg-bg/60 text-fg-muted`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`model`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Fresh tokens sent to the model`,children:`input`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Tokens generated by the model`,children:`output`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Cache write tokens (cache_creation_input_tokens). Claude Code re-caches the system prompt + tool definitions + conversation history every turn, so this number grows with conversation length and is normally MUCH larger than 'input'. Priced at 1.25× the input rate — Anthropic's published pricing.`,children:`cache w`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,title:`Cache read tokens (cache_read_input_tokens). Charged at 0.1× the input rate (10× cheaper). High cache_r is good — it means most of the prompt was served from cache instead of re-billed as input.`,children:`cache r`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`cost`})]})}),(0,G.jsx)(`tbody`,{children:f.byModel.map(e=>(0,G.jsxs)(`tr`,{className:`border-t border-line`,children:[(0,G.jsx)(`td`,{className:`px-3 py-2 font-medium`,children:e.modelLabel}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.inputTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.outputTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.cacheCreateTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.cacheReadTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 font-semibold text-accent`,children:pS(e.cost.cents)})]},e.model??`__unknown__`))})]})})]}),f.topSessions.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Top sessions`}),(0,G.jsx)(bS,{text:`The 10 most expensive sessions in this range, ranked by tokens used inside the window. Click any row to open the transcript.`})]}),(0,G.jsx)(`div`,{className:`bg-bg-elevated border border-line rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`bg-bg/60 text-fg-muted`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`session`}),(0,G.jsx)(`th`,{className:`text-left px-3 py-2`,children:`project`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`tokens`}),(0,G.jsx)(`th`,{className:`text-right px-3 py-2`,children:`cost`})]})}),(0,G.jsx)(`tbody`,{children:f.topSessions.map(e=>(0,G.jsxs)(`tr`,{className:`border-t border-line hover:bg-bg-hover cursor-pointer`,onClick:()=>t(e.sessionId),children:[(0,G.jsx)(`td`,{className:`px-3 py-2 font-mono truncate max-w-[200px]`,children:e.alias??e.sessionId.slice(0,12)}),(0,G.jsx)(`td`,{className:`px-3 py-2 text-fg-muted truncate max-w-[200px]`,children:e.project??`—`}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 tabular-nums`,children:hS(e.totalTokens)}),(0,G.jsx)(`td`,{className:`text-right px-3 py-2 font-semibold text-accent`,children:pS(e.cost.cents)})]},e.sessionId))})]})}),(0,G.jsx)(`p`,{className:`text-[10px] text-fg-muted mt-2`,children:`Showing the top 10 sessions by tokens. Smaller projects with only a few sessions won't appear here even though they're fully indexed — every project shows up in the per-project view (and in the daily chart total).`})]}),f.topRepos.length>0&&(0,G.jsxs)(`section`,{className:`mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-xs uppercase tracking-wider text-fg-dim`,children:`Top repos`}),(0,G.jsx)(bS,{text:`Projects ranked by total tokens used inside this range. Click a card to filter the rest of the UI to that project.`})]}),(0,G.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2 -mx-2 px-2 snap-x`,style:{scrollbarWidth:`thin`},children:f.topRepos.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a({project:e.project}),className:`snap-start shrink-0 w-[220px] text-left bg-bg-elevated border border-line rounded-lg px-4 py-3 hover:border-accent hover:bg-bg-hover transition-colors`,title:`Filter to ${e.project}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[`#`,t+1]}),(0,G.jsx)(`span`,{className:`truncate`,children:`repo`})]}),(0,G.jsx)(`div`,{className:`mt-1 text-sm font-medium truncate`,title:e.project,children:e.project}),(0,G.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-accent tabular-nums`,children:pS(e.cost.cents)}),(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-muted tabular-nums`,children:[hS(e.totalTokens),` tokens · `,e.sessions,` session`,e.sessions===1?``:`s`]})]},e.project+t))}),(0,G.jsxs)(`p`,{className:`text-[10px] text-fg-muted mt-1`,children:[`Top `,Math.min(f.topRepos.length,20),` projects by tokens in this range. Scroll horizontally for more. Click to filter.`]})]})]})]})})}function CS({label:e,value:t,accent:n,hint:r,info:i,infoAlign:a=`left`,extra:o}){return(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-lg px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center text-[10px] uppercase tracking-wider text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e}),i&&(0,G.jsx)(bS,{text:i,align:a})]}),(0,G.jsx)(`div`,{className:`text-lg font-semibold mt-1 `+(n?`text-accent`:`text-fg`),children:t}),r&&(0,G.jsx)(`div`,{className:`text-[10px] text-fg-muted mt-0.5`,children:r}),o]})}var wS=[],TS=[];function ES(e){wS.some(t=>t.id===e.id)||wS.push(e)}function DS(e){TS.push(e)}function OS(e){let t=[];for(let n of TS)try{t.push(...n(e))}catch{}return[...wS,...t]}function kS(e,t){let n=e.trim().toLowerCase();if(!n)return 1;let r=t.title.toLowerCase(),i=(t.subtitle??``).toLowerCase(),a=(t.keywords??[]).join(` `).toLowerCase(),o=t.section.toLowerCase(),s=0;return r===n&&(s=Math.max(s,1e3)),r.startsWith(n)&&(s=Math.max(s,500)),RegExp(`\\b`+jS(n)).test(r)&&(s=Math.max(s,300)),r.includes(n)&&(s=Math.max(s,200)),a.includes(n)&&(s=Math.max(s,150)),i.includes(n)&&(s=Math.max(s,100)),o.includes(n)&&(s=Math.max(s,50)),s===0&&AS(n,r)&&(s=25),s===0&&AS(n,a)&&(s=10),s}function AS(e,t){if(!e)return!0;let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function jS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function MS(e,t){let n=OS(t),r=e.trim();return r?n.map(e=>({c:e,s:kS(r,e)})).filter(e=>e.s>0).sort((e,t)=>t.s-e.s).map(e=>e.c):n}function NS(e){let t=[`Jump`,`Search`,`Actions`,`Settings`],n=new Map;for(let e of t)n.set(e,[]);for(let t of e){let e=n.get(t.section)??[];e.push(t),n.set(t.section,e)}return t.map(e=>[e,n.get(e)??[]]).filter(([,e])=>e.length>0)}function PS({ctx:e,onClose:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(0),o=(0,W.useRef)(null),s=(0,W.useRef)(null),c=q({queryKey:[`sessions`,`palette`],queryFn:()=>Z.sessions({limit:60}),staleTime:3e4}),l=(0,W.useMemo)(()=>({...e,sessions:c.data?.items??[],openPalette:()=>{},closePalette:t}),[e,c.data,t]),u=(0,W.useMemo)(()=>MS(n,l),[n,l]),d=(0,W.useMemo)(()=>NS(u),[u]),f=(0,W.useMemo)(()=>d.flatMap(([,e])=>e),[d]);return(0,W.useEffect)(()=>{a(0)},[n,u.length]),(0,W.useEffect)(()=>{requestAnimationFrame(()=>o.current?.focus())},[]),(0,W.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),t();return}if(e.key===`ArrowDown`)e.preventDefault(),a(e=>Math.min(e+1,Math.max(f.length-1,0)));else if(e.key===`ArrowUp`)e.preventDefault(),a(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let n=f[i];n&&IS(n,l,t)}else if(e.key===`Tab`){if(e.preventDefault(),d.length===0)return;let t=f[i],[,n]=d[((t?d.findIndex(([e])=>e===t.section):0)+(e.shiftKey?-1:1)+d.length)%d.length],r=n[0];if(r){let e=f.findIndex(e=>e.id===r.id);e>=0&&a(e)}}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[f,d,i,l,t]),(0,W.useEffect)(()=>{(s.current?.querySelector(`[data-cmd-idx="${i}"]`))?.scrollIntoView({block:`nearest`})},[i]),(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-start justify-center pt-24 px-6`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,children:(0,G.jsxs)(`div`,{className:`bg-bg-elevated border border-line rounded-xl shadow-2xl w-full max-w-2xl max-h-[70vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),"data-testid":`command-palette`,children:[(0,G.jsxs)(`div`,{className:`p-4 border-b border-line`,children:[(0,G.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-fg-dim mb-2`,children:`Command palette`}),(0,G.jsx)(`input`,{ref:o,type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Type a command or session… ↑↓ navigate · Enter run · Esc close · Tab section`,className:`w-full bg-bg border border-line rounded px-3 py-2 text-sm focus:outline-none focus:border-accent`,"data-testid":`command-palette-input`,"aria-label":`Command palette search`,autoComplete:`off`,spellCheck:!1})]}),(0,G.jsxs)(`div`,{ref:s,className:`flex-1 overflow-y-auto`,children:[f.length===0&&(0,G.jsx)(`div`,{className:`p-6 text-sm text-fg-muted`,children:`No commands match.`}),d.map(([e,n])=>(0,G.jsx)(FS,{section:e,cmds:n,activeIdx:i,flat:f,onRun:e=>IS(e,l,t),onHover:e=>{let t=f.findIndex(t=>t.id===e.id);t>=0&&a(t)}},e))]}),(0,G.jsxs)(`div`,{className:`p-3 border-t border-line text-xs text-fg-muted flex justify-between`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`↑↓`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Enter`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Tab`}),` `,(0,G.jsx)(`kbd`,{className:`font-mono border border-line rounded px-1`,children:`Esc`})]}),(0,G.jsxs)(`span`,{children:[f.length,` commands`]})]})]})})}function FS({section:e,cmds:t,activeIdx:n,flat:r,onRun:i,onHover:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[10px] uppercase tracking-widest text-fg-dim`,children:e}),t.map(e=>{let t=r.findIndex(t=>t.id===e.id),o=t===n;return(0,G.jsxs)(`button`,{type:`button`,"data-cmd-idx":t,"data-cmd-id":e.id,onMouseEnter:()=>a(e),onClick:()=>i(e),className:$(`block w-full text-left px-4 py-2 border-b border-line/40 transition-colors`,o?`bg-bg-active`:`hover:bg-bg-hover`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,G.jsx)(`span`,{className:`shrink-0 text-fg-muted w-5 text-center`,children:e.icon}),(0,G.jsx)(`span`,{className:`text-sm text-fg truncate`,children:e.title})]}),e.subtitle&&(0,G.jsx)(`div`,{className:`pl-7 text-xs text-fg-muted truncate`,children:e.subtitle})]},e.id)})]})}async function IS(e,t,n){try{await e.run(t)}finally{n()}}function LS({onExit:e}){return(0,G.jsxs)(`div`,{"data-testid":`compare-banner`,className:`flex items-center justify-between gap-3 px-4 py-2 bg-accent/10 border-b border-accent/30 text-sm normal-case tracking-normal`,children:[(0,G.jsxs)(`span`,{className:`text-fg-dim truncate`,children:[`Compare mode · two sessions open · press`,` `,(0,G.jsx)(`kbd`,{className:`px-1.5 py-0.5 border border-line rounded text-xs font-mono`,children:`Esc`}),` `,`to exit`]}),(0,G.jsx)(`button`,{type:`button`,onClick:e,"data-testid":`compare-banner-exit`,"aria-label":`Exit compare view`,className:`shrink-0 px-3 py-1 bg-accent text-bg rounded text-xs font-semibold hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-accent/60`,children:`Exit compare ⤫`})]})}function RS(e,t=250){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var zS=!1;function BS(){zS||(zS=!0,ES({id:`palette.close`,title:`Close command palette`,section:`Actions`,keywords:[`dismiss`,`escape`],icon:`✕`,run:e=>e.closePalette()}),ES({id:`help.open`,title:`Open Command Center`,subtitle:`Full help & keyboard reference`,section:`Settings`,keywords:[`help`,`?`,`docs`,`shortcuts`,`center`],icon:`?`,run:e=>e.openHelp()}),ES({id:`collections.create`,title:`New collection`,subtitle:`Create a new collection to group sessions`,section:`Actions`,keywords:[`new`,`collection`,`group`,`folder`],icon:`📁`,run:e=>e.openCreateCollection()}),ES({id:`collections.add-current-session`,title:`Add current session to a collection`,section:`Actions`,keywords:[`collection`,`add`,`organize`],icon:`➕`,run:e=>{e.currentSessionId&&e.openAddToCollection()}}),ES({id:`compare.start`,title:`Start compare — pick a second session`,subtitle:`Open side-by-side transcript diff`,section:`Actions`,keywords:[`compare`,`diff`,`side`,`split`],icon:`⇆`,run:e=>e.startCompare()}),ES({id:`compare.exit`,title:`Exit compare view`,section:`Actions`,keywords:[`compare`,`close`,`exit`],icon:`✕`,run:e=>e.exitCompare()}),ES({id:`session.export`,title:`Export current session as context`,subtitle:`Copy condensed markdown to clipboard`,section:`Actions`,keywords:[`export`,`copy`,`context`,`clipboard`,`markdown`],icon:`📋`,run:e=>{e.currentSessionId&&e.exportCurrentSession()}}),ES({id:`semantic.toggle`,title:`Toggle semantic search`,subtitle:`AI-powered search by concept (requires v0.11)`,section:`Settings`,keywords:[`semantic`,`ai`,`search`,`mode`],icon:`✨`,run:e=>e.toggleSemantic()}),ES({id:`threads.intro.replay`,title:`Replay threads tour`,subtitle:`Play the 3-step Threads explainer again`,section:`Settings`,keywords:[`threads`,`intro`,`tour`,`replay`,`onboarding`,`help`],icon:`🧵`,run:e=>e.replayThreadsIntro()}),ES({id:`nav.home`,title:`Go home — clear filters`,subtitle:`Clear project, session, search`,section:`Jump`,keywords:[`home`,`reset`,`clear`],icon:`⌂`,run:e=>e.navigate({project:null,session:null,msg:null,q:``,col:null,view:null})}),DS(e=>e.sessions.slice(0,10).map((e,t)=>{let n=e.alias||(e.first_user_message?e.first_user_message.slice(0,80).replace(/\s+/g,` `).trim():``)||`(no prompt)`;return{id:`jump.session.${e.id}`,title:`Jump to: ${n}`,subtitle:`${e.project} · ${e.message_count} msgs · ${e.id.slice(0,8)}`,section:`Jump`,keywords:[e.id,e.id.slice(0,8),e.project,e.alias??``,...e.tags.map(e=>`#${e}`),`recent${t+1}`].filter(Boolean),icon:`↳`,run:t=>t.navigate({session:e.id,project:e.project,msg:null,view:null})}})))}BS();function VS(){let[e,t]=Nn(),n=RS(e.q,120),[r,i]=(0,W.useState)(`all`),[a,o]=(0,W.useState)(!1),s=!!q({queryKey:[`semanticStatus`],queryFn:()=>Z.getSemanticStatus(),refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}).data?.enabled,c=a&&s,[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),_=Xx(),[v,y]=(0,W.useState)(null),b=_.data?.state.threadsIntroSeen===!0,x=null;h===`show`?x=`onboarding`:v===`show`&&e.view===`threads`?x=`threadsIntro`:h!==`hide`&&_.shouldShow?x=`onboarding`:v!==`hide`&&_.data&&!b&&e.view===`threads`&&(x=`threadsIntro`);let S=x===`onboarding`,C=x===`threadsIntro`,[w,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(!1),[A,j]=(0,W.useState)(!1),[M,ee]=(0,W.useState)(null),[N,te]=(0,W.useState)(null),[P,F]=(0,W.useState)(!1),I=(0,W.useCallback)(()=>{if(!e.thread){Q({message:`Open a thread first to share it.`,tone:`info`});return}ee({threadId:e.thread})},[e.thread]),L=(0,W.useCallback)(async()=>{if(P)return;let t=document.querySelector(`[data-share-capture="patterns-graph"]`);if(!t){Q({message:`Switch to the Galaxy tab on the Patterns page first.`,tone:`info`});return}F(!0);try{let{captureNodeAsDataUrl:n}=await dn(async()=>{let{captureNodeAsDataUrl:e}=await import(`./captureNode-Da1ofkVZ.js`);return{captureNodeAsDataUrl:e}},[],import.meta.url),r=t.getBoundingClientRect(),i=968*2,a=r.height/r.width,o=Math.round(i*a);te({heroImage:await n(t,{width:Math.round(r.width),height:Math.round(r.height),canvasWidth:i,canvasHeight:o,pixelRatio:1}),scopeLabel:e.project?`Project: ${e.project}`:`All projects`})}catch(e){console.error(`[Share] capture failed:`,e),Q({message:`Could not capture the patterns graph. `+(e instanceof Error?e.message:``),tone:`error`})}finally{F(!1)}},[P,e.project]);(0,W.useEffect)(()=>{let n=n=>{let r=n.target,i=!!r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable);if(n.key===`/`&&!i){n.preventDefault();let e=document.querySelector(`input[type="search"]`);e?.focus(),e?.select()}else if(n.key===`?`&&!i)n.preventDefault(),t({view:`help`});else if(n.key===`Escape`&&i&&r?.getAttribute(`type`)===`search`)t({q:``}),r.blur();else if(n.key===`Escape`&&!i&&e.view&&e.view!==null)n.preventDefault(),t({view:null,thread:null,helpSection:null});else if(n.key===`c`&&!i&&!n.metaKey&&!n.ctrlKey)n.preventDefault(),u(!0);else if((n.metaKey||n.ctrlKey)&&n.shiftKey&&(n.key===`A`||n.key===`a`))e.session&&(n.preventDefault(),f(!0));else if((n.metaKey||n.ctrlKey)&&n.shiftKey&&(n.key===`C`||n.key===`c`)){n.preventDefault();let e=document.querySelector(`[data-collections-focus]`);e?.focus(),e?.scrollIntoView({block:`nearest`})}else if((n.metaKey||n.ctrlKey)&&!n.shiftKey&&!n.altKey&&(n.key===`k`||n.key===`K`))n.preventDefault(),T(e=>!e);else if((n.metaKey||n.ctrlKey)&&n.key===`\\`){n.preventDefault();let e=`claude-recall:sessions-pane`,t=`${e}:collapsed`,r=localStorage.getItem(t)===`1`?`0`:`1`;localStorage.setItem(t,r),Rn(e)}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,e.session,e.view]),(0,W.useEffect)(()=>{if(!e.compareWith)return;let n=e=>{if(e.key!==`Escape`)return;let n=e.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||t({compareWith:null})};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e.compareWith,t]);let R=n.trim().length>1,z=r===`project`?e.project:null,B=q({queryKey:[`searchCount`,n,z,c?`semantic`:`fts`],queryFn:()=>Z.search(n,60,z??void 0,c?`semantic`:void 0),enabled:R}),V=(0,W.useMemo)(()=>R?B.data?.hits.length??null:null,[R,B.data]),ne=(0,W.useCallback)(e=>t({q:e}),[t]),H=(0,W.useCallback)(()=>t({view:`help`}),[t]),re=(0,W.useCallback)(()=>t({view:null,helpSection:null}),[t]),ie=(0,W.useCallback)(()=>t({view:`stats`}),[t]),ae=(0,W.useCallback)(()=>t({view:`threads`}),[t]),oe=(0,W.useCallback)(()=>t({view:`graph`}),[t]),se=(0,W.useCallback)(()=>t({view:`suggestions`}),[t]),ce=(0,W.useCallback)(()=>t({view:`patterns`}),[t]),U=(0,W.useCallback)(()=>t({view:null}),[t]),le=(0,W.useCallback)(e=>t({helpSection:e}),[t]),ue=(0,W.useCallback)(e=>t({project:e,session:null,msg:null,col:null}),[t]),de=(0,W.useCallback)((e,n)=>t({session:e,msg:n??null}),[t]),fe=(0,W.useCallback)(async()=>{await _.reset(),g(`show`),t({view:null,helpSection:null})},[_,t]),pe=(0,W.useCallback)(()=>{g(`hide`),y(`hide`)},[]),me=(0,W.useCallback)(async()=>{await _.patch({threadsIntroSeen:!1}),y(`show`),t({view:`threads`,helpSection:null})},[_,t]),he=(0,W.useCallback)(()=>{y(`hide`),g(`hide`)},[]),ge=(0,W.useCallback)(()=>m(!0),[]),_e=(0,W.useCallback)(e=>t({msg:e}),[t]);return(0,G.jsxs)(`div`,{className:`h-full flex flex-col relative`,children:[(0,G.jsx)(Vt,{query:e.q,onQueryChange:ne,matchCount:V,scope:r,onScopeChange:i,canScope:!!e.project,projectName:e.project,onOpenHelp:H,helpActive:e.view===`help`,onOpenStats:ie,statsActive:e.view===`stats`,onOpenThreads:ae,threadsActive:e.view===`threads`,onOpenGraph:oe,graphActive:e.view===`graph`,onOpenSuggestions:se,suggestionsActive:e.view===`suggestions`,onOpenPatterns:ce,patternsActive:e.view===`patterns`,onOpenShare:()=>k(!0),onGoHome:()=>t({view:null,helpSection:null,session:null,msg:null,col:null,project:null,q:``}),semanticAvailable:s,semanticMode:c,onSemanticModeChange:o}),(0,G.jsx)(qt,{}),(0,G.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[(0,G.jsx)(Zr,{selected:e.project,selectedCollection:e.col,onSelect:ue,onCreateCollection:()=>u(!0),onSelectSession:de}),(0,G.jsx)(lc,{projectName:e.project,collectionId:e.col,selectedSessionId:e.session,onSelect:de,searchQuery:n,searchScope:r,semanticMode:c}),(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,"data-compare-wrapper":e.compareWith?`1`:void 0,children:[e.compareWith&&(0,G.jsx)(LS,{onExit:()=>t({compareWith:null})}),(0,G.jsxs)(`div`,{className:`flex-1 flex min-w-0 min-h-0 max-[1100px]:flex-col min-[1101px]:flex-row`,children:[(0,G.jsx)(`div`,{className:`flex-1 flex min-w-0 min-h-0`,children:(0,G.jsx)(ed,{sessionId:e.session,targetMessageUuid:e.msg,onTargetChange:_e,searchQuery:n,isCompareLeft:!!e.compareWith})}),e.compareWith&&(0,G.jsx)(`div`,{className:`flex-1 flex min-w-0 min-h-0 border-t border-line min-[1101px]:border-t-0 min-[1101px]:border-l`,children:(0,G.jsx)(ed,{sessionId:e.compareWith,targetMessageUuid:null,onTargetChange:()=>{},searchQuery:n,isCompareRight:!0,onExitCompare:()=>t({compareWith:null})})})]})]})]}),e.view===`stats`&&(0,G.jsx)(SS,{onClose:U,onSelectSession:e=>de(e)}),e.view===`help`&&(0,G.jsx)(Sf,{initialSectionId:e.helpSection,onClose:re,onSectionChange:le,onReplayOnboarding:fe,onReplayThreadsIntro:()=>void me()}),e.view===`auto-rules`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg overflow-auto`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`Auto-collections`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(Ef,{})]}),e.view===`threads`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-20 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0 share-capture-exclude`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🧵 Threads`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.thread&&(0,G.jsx)(`button`,{type:`button`,onClick:I,className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg-dim hover:text-fg hover:border-accent/60 transition-colors`,title:`Render this thread as a shareable card`,children:`↗ Share thread`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null,thread:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]})]}),(0,G.jsx)(hp,{})]}),e.view===`graph`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🌌 Cognitive Graph`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(db,{projectName:e.project??``,onPickProject:e=>t({project:e})})})]}),e.view===`suggestions`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`📋 Suggestions Queue`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(Nb,{})})]}),e.view===`patterns`&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-30 bg-bg flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 bg-bg border-b border-line px-4 py-2 flex items-center justify-between shrink-0 share-capture-exclude`,children:[(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:`🐛 Bug Patterns`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void L(),disabled:P,className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg-dim hover:text-fg hover:border-accent/60 transition-colors disabled:opacity-60`,title:`Capture the galaxy view and share it`,children:P?`Capturing…`:`↗ Share patterns`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t({view:null}),className:`text-xs px-3 py-1.5 border border-line rounded-md font-medium text-fg hover:text-bg hover:bg-accent hover:border-accent transition-colors`,title:`Back to home (Esc)`,children:`← Home`})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,G.jsx)(Bx,{})})]}),l&&(0,G.jsx)(nr,{mode:`create`,onClose:()=>u(!1),onCreated:e=>{u(!1),t({col:e.id,session:null,msg:null})}}),d&&e.session&&(0,G.jsx)(Bi,{sessionId:e.session,onClose:()=>f(!1),anchor:`center`}),S&&(0,G.jsx)(Qx,{onSelectSession:e=>de(e),onOpenAutoTagSettings:ge,onClose:pe}),C&&(0,G.jsx)(oS,{onClose:he}),(0,G.jsx)(fi,{open:p,onClose:()=>m(!1)}),(0,G.jsx)(zt,{}),w&&(0,G.jsx)(PS,{onClose:()=>T(!1),ctx:{navigate:e=>t(e),openHelp:()=>t({view:`help`}),openCreateCollection:()=>u(!0),openAddToCollection:()=>{e.session&&f(!0)},startCompare:()=>D(!0),exitCompare:()=>t({compareWith:null}),exportCurrentSession:()=>{if(!e.session)return;let t=`recall context ${e.session} | claude`;navigator.clipboard?.writeText(t).catch(()=>void 0)},toggleSemantic:()=>{let e=`claude-recall:semantic-mode`,t=localStorage.getItem(e)===`1`?`0`:`1`;localStorage.setItem(e,t)},replayThreadsIntro:()=>{me()},currentSessionId:e.session,compareSessionId:e.compareWith}}),E&&(0,G.jsx)(Js,{excludeSessionId:e.session,onPick:e=>{D(!1),t({compareWith:e})},onClose:()=>D(!1)}),O&&(0,G.jsx)(Yt,{onClose:()=>k(!1),onPick:n=>{k(!1),n===`stats`?j(!0):n===`thread`?e.view===`threads`&&e.thread?I():(Q({message:`Open the Threads page and pick a thread, then click ↗ Share thread.`,tone:`info`,duration:4e3}),t({view:`threads`})):n===`patterns`?e.view===`patterns`?L():(Q({message:`Open the Patterns page (Galaxy tab), then click ↗ Share patterns.`,tone:`info`,duration:4e3}),t({view:`patterns`})):n===`session`&&(e.session?Q({message:`Click the ↗ Share button on the transcript header to share this session.`,tone:`info`,duration:3e3}):Q({message:`Open a session first, then click the ↗ Share button on its header.`,tone:`info`,duration:3e3}))}}),A&&(0,G.jsx)(_n,{onClose:()=>j(!1)}),M&&(0,G.jsx)(Sn,{threadId:M.threadId,onClose:()=>ee(null)}),N&&(0,G.jsx)(Cn,{heroImage:N.heroImage,scopeLabel:N.scopeLabel,onClose:()=>te(null)})]})}var HS=new We({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}}),US=document.getElementById(`root`);if(!US)throw Error(`root element not found`);ut.createRoot(US).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Je,{client:HS,children:(0,G.jsx)(VS,{})})}));export{u as a,d as i,o as n,c as r,s as t};
|