@moberg_hr/work-tree 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/{chunk-YLG6DO5Y.js → chunk-BR6OPEE4.js} +2 -2
- package/dist/{chunk-7H4BJ2YA.js → chunk-C7W5TMFB.js} +8 -8
- package/dist/{chunk-KA4JVX5U.js → chunk-CVAVYDXO.js} +2 -2
- package/dist/{chunk-PZ4RG6EW.js → chunk-FPKERDK7.js} +12 -2
- package/dist/chunk-FPKERDK7.js.map +1 -0
- package/dist/{chunk-CXEC5W5V.js → chunk-HIZBWYPL.js} +2 -2
- package/dist/chunk-LMIEEDDC.js +9 -0
- package/dist/{cleanup-X45MA74G.js → cleanup-LDBGWEKZ.js} +5 -5
- package/dist/{cli-52VWEHIQ.js → cli-UATB4RM2.js} +3 -3
- package/dist/{pr-YU3NOW6G.js → pr-527S5HXB.js} +8 -4
- package/dist/pr-527S5HXB.js.map +1 -0
- package/dist/{prune-26FYYFTO.js → prune-AIS5YEXP.js} +4 -4
- package/dist/{remove-2UHJQ4DY.js → remove-YGUTSKZP.js} +3 -3
- package/dist/{sync-3CTAXM6J.js → sync-ITK5UYGM.js} +4 -4
- package/dist/wd-bin.js +2 -2
- package/dist/web/assets/{PtyView-M4b0GFVs.js → PtyView-DYvawzWb.js} +2 -2
- package/dist/web/assets/{PtyView-M4b0GFVs.js.map → PtyView-DYvawzWb.js.map} +1 -1
- package/dist/web/assets/{index-5hi1kMKy.js → index-C5lJhIwK.js} +4 -4
- package/dist/web/assets/{index-5hi1kMKy.js.map → index-C5lJhIwK.js.map} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/{web-BI3MRQEM.js → web-IC3P7EHZ.js} +35 -8
- package/dist/web-IC3P7EHZ.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/chunk-MAGGGRSB.js +0 -9
- package/dist/chunk-PZ4RG6EW.js.map +0 -1
- package/dist/pr-YU3NOW6G.js.map +0 -1
- package/dist/web-BI3MRQEM.js.map +0 -1
- /package/dist/{chunk-YLG6DO5Y.js.map → chunk-BR6OPEE4.js.map} +0 -0
- /package/dist/{chunk-7H4BJ2YA.js.map → chunk-C7W5TMFB.js.map} +0 -0
- /package/dist/{chunk-KA4JVX5U.js.map → chunk-CVAVYDXO.js.map} +0 -0
- /package/dist/{chunk-CXEC5W5V.js.map → chunk-HIZBWYPL.js.map} +0 -0
- /package/dist/{chunk-MAGGGRSB.js.map → chunk-LMIEEDDC.js.map} +0 -0
- /package/dist/{cleanup-X45MA74G.js.map → cleanup-LDBGWEKZ.js.map} +0 -0
- /package/dist/{cli-52VWEHIQ.js.map → cli-UATB4RM2.js.map} +0 -0
- /package/dist/{prune-26FYYFTO.js.map → prune-AIS5YEXP.js.map} +0 -0
- /package/dist/{remove-2UHJQ4DY.js.map → remove-YGUTSKZP.js.map} +0 -0
- /package/dist/{sync-3CTAXM6J.js.map → sync-ITK5UYGM.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PtyView-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PtyView-DYvawzWb.js","assets/PtyView-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(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},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((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.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.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`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(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 P(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,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(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 F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ee=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)};function te(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ee)}catch(e){ee(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ne(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else te(ne.bind(null,e))}var L={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ne,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=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.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 D(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)E.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 D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=te,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),u=o(((e,t)=>{t.exports=l()})),d=o((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}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();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`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(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.browser=function(e){return{$$typeof:o,_reason:e}},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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.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=d(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=d(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,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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=d(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=d(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,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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 l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),m=o(((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=p()})),h=o((e=>{var t=f(),n=u(),r=m();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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e: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 d(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 p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),I=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.legacy_hidden`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.for(`react.view_transition`),se=Symbol.for(`react.recoverable`),ce=Symbol.iterator;function le(e){return typeof e!=`object`||!e?null:(e=ce&&e[ce]||e[`@@iterator`],typeof e==`function`?e:null)}var ue=Symbol.for(`react.client.reference`);function de(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case re:return`Activity`;case oe:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case I:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?de(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return de(e(t))}catch{}}return null}var R=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},pe=[],me=-1;function he(e){return{current:e}}function V(e){0>me||(e.current=pe[me],pe[me]=null,me--)}function ge(e,t){me++,pe[me]=e.current,e.current=t}var _e=he(null),ve=he(null),ye=he(null),be=he(null);function xe(e,t){switch(ge(ye,t),ge(ve,e),ge(_e,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}V(_e),ge(_e,e)}function Se(){V(_e),V(ve),V(ye)}function Ce(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,ge(be,e)),t=_e.current;var n=dp(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function we(e){ve.current===e&&(V(_e),V(ve)),be.current===e&&(V(be),sh._currentValue=fe)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Te+e+Ee}var Oe=!1;function ke(e,t){if(!e||Oe)return``;Oe=!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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}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(`
|
|
@@ -88,7 +88,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
88
88
|
`)+`
|
|
89
89
|
|
|
90
90
|
These will conflict when both merge.`}function ic({session:e,compact:t,quiet:n=!1}){let r=e.agents??e.claudes;if(!r||n&&!r.duplicate&&!r.inTerminal)return null;let i=dt(e),a=[r.inTerminal?`${r.inTerminal>1?`${r.inTerminal}× `:``}terminal`:``,r.inApp?`${r.inApp>1?`${r.inApp}× `:``}app`:``].filter(Boolean).join(` + `),o=r.duplicate?`More than one ${i} is running on this conversation. They would both write to it: close all but one (/exit in its terminal tab).`:`${i} is running (${r.busy?`busy`:`at its prompt`}) in ${a}.`;return r.duplicate?(0,H.jsxs)(`span`,{className:`wd-claudes wd-claudes-dup`,title:o,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),` `,t?`2× ${i}`:`Two of ${i} on one conversation (${a})`]}):(0,H.jsx)(`span`,{className:`wd-claudes`+(r.busy?` wd-claudes-busy`:``),title:o,children:t?r.inTerminal?`▣ terminal`:`▣ app`:`Running in ${a}`})}function ac({session:e,onOpen:t}){let n=e.stackedOn,r=e.stackedChildren??0;return!n&&!r?null:(0,H.jsxs)(`span`,{className:`wd-stack`,title:`Stacked sessions: one made from another session's branch builds on it, and takes in its new commits (when idle and clean).`,children:[n&&(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⤷`}),` on`,` `,t?(0,H.jsx)(`button`,{type:`button`,className:`wd-overlap-link`,onClick:()=>t(n.id),children:n.title??n.branch}):(0,H.jsx)(`span`,{className:`wd-overlap-name`,children:n.title??n.branch})]}),n&&r>0&&` · `,r>0&&(0,H.jsxs)(`span`,{children:[r,` stacked on this`]})]})}function oc({session:e,onOpen:t}){let n=e.overlaps??[];if(n.length===0)return null;let r=n.reduce((e,t)=>e+t.count,0);return(0,H.jsxs)(`span`,{className:`wd-overlap`,title:rc(e),children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),` Same files as`,` `,n.slice(0,2).map((e,n)=>(0,H.jsxs)(`span`,{children:[n>0&&`, `,t?(0,H.jsx)(`button`,{type:`button`,className:`wd-overlap-link`,onClick:()=>t(e.sessionId),children:e.branch}):(0,H.jsx)(`span`,{className:`wd-overlap-name`,children:e.branch})]},e.sessionId)),n.length>2&&` +${n.length-2}`,(0,H.jsxs)(`span`,{className:`wd-overlap-count`,children:[` `,`(`,r,` file`,r===1?``:`s`,`)`]})]})}function sc({session:e}){let t=Ye(e),n=e.attention,r=J(n?n.since:Je(e));return(0,H.jsxs)(`span`,{className:`wd-status-line wd-status-line-${t}`,title:rt(t),children:[(0,H.jsx)(Dt,{kind:t}),(0,H.jsx)(`span`,{className:`wd-status-label`,children:Xe[t]}),r&&(0,H.jsxs)(`span`,{className:`wd-status-since`,children:[` · `,r]}),n?.stale&&(0,H.jsxs)(`span`,{className:`wd-status-since`,title:`No activity for 15 minutes`,children:[` `,`(quiet)`]}),n?.summary&&(0,H.jsxs)(`span`,{className:`wd-status-summary`,children:[` — `,n.summary]})]})}function cc(e){let t=e.onOtherBranch??[];if(t.length===0)return null;let n=e=>e??`a detached HEAD`;return e.isGroup?t.map(e=>`${e.repo} on ${n(e.branch)}`).join(`, `):`on ${n(t[0].branch)}`}function lc({session:e}){let t=cc(e);return t?(0,H.jsx)(`span`,{className:`wd-other-branch`,title:`Started on ${e.branch}; its worktree is ${t} now. Ship, CI and the diffs use the branch that's checked out.`,children:t}):null}function uc(){let[e,t]=(0,_.useState)(null),n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!e)return;let r=e=>e.key===`Escape`&&t(null),i=e=>{n.current&&!n.current.contains(e.target)&&t(null)};return window.addEventListener(`keydown`,r),window.addEventListener(`mousedown`,i),()=>{window.removeEventListener(`keydown`,r),window.removeEventListener(`mousedown`,i)}},[e]),(0,H.jsxs)(`div`,{className:`wd-legend`,ref:n,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-dash-rail-new wd-legend-toggle`,"aria-expanded":!!e,"aria-controls":`wd-legend-panel`,title:`What the icons mean`,"aria-label":`What the icons mean`,onClick:n=>{if(e)return t(null);let r=n.currentTarget.getBoundingClientRect();t({top:r.bottom+6,left:Math.max(8,r.left-8)})},children:`?`}),e&&(0,H.jsxs)(`div`,{id:`wd-legend-panel`,className:`wd-legend-panel`,role:`dialog`,"data-popover":!0,"aria-label":`What the icons mean`,style:{top:e.top,left:e.left},children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`What the icons mean`}),(0,H.jsx)(`ul`,{className:`wd-legend-list`,children:Qe.map(e=>(0,H.jsxs)(`li`,{className:`wd-legend-row`,children:[(0,H.jsx)(Dt,{kind:e}),(0,H.jsx)(`span`,{className:`wd-legend-name`,children:Xe[e]}),(0,H.jsx)(`span`,{className:`wd-legend-meaning`,children:Ze[e]})]},e))}),(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`On a row`}),(0,H.jsxs)(`ul`,{className:`wd-legend-list wd-legend-marks`,children:[(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`b`,{children:`Bold`}),` — it wants you (needs input, done, review comments, its pull request). The Inbox lists these in order;`,` `,(0,H.jsx)(`kbd`,{children:`n`}),` jumps to the next.`]}),(0,H.jsxs)(`li`,{children:[`On the right: `,(0,H.jsx)(`span`,{className:`wd-rail-slot-needs`,children:`4m`}),` waiting that long for you ·`,` `,(0,H.jsx)(`span`,{className:`wd-rail-slot-done`,children:`4m`}),` finished that long ago · `,(0,H.jsx)(`span`,{className:`wd-rail-slot-review`,children:`2`}),` `,`unresolved review comments · `,(0,H.jsx)(`span`,{className:`wd-rail-slot-review`,children:`merge`}),` its PR is ready to merge`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`wd-pr-chip`,children:`#212`}),` an open pull request (click to open it)`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`wd-legend-overlap`,children:`⚠`}),` another session changes the same files`]})]}),(0,H.jsxs)(`p`,{className:`wd-legend-keys`,children:[(0,H.jsx)(`kbd`,{children:`?`}),` lists every keyboard shortcut.`]})]})]})}function dc(e,t=new Date){let n=e.agents??e.claudes,r=[e.snoozed?`snoozed ${Oo(e.snoozed,t)}`:``,e.blockedBy?.length?`waits on ${e.blockedBy.map(e=>e.label).join(`, `)}`:``,e.prStage?.text??``,e.pendingForClaudeCount?`${e.pendingForClaudeCount} waiting for Claude`:``,e.hasNote?`has notes`:``,n?.duplicate?`two Claudes on one conversation`:n?.inTerminal?`running in a terminal`:``].filter(Boolean);return r.length?`\n${r.join(` · `)}`:``}function fc(e,t){let n=e.attention?.since??e.lastAccessedAt;return e.snoozed?{text:`snoozed`,cls:`wd-rail-slot-snoozed`}:t===`needs_input`?{text:J(n),cls:`wd-rail-slot-needs`}:t===`done`?{text:J(n),cls:`wd-rail-slot-done`}:t===`working`?{text:J(n),cls:`wd-rail-slot-working`}:t===`review`?{text:String(e.openReviewThreads),cls:`wd-rail-slot-review`}:t===`pr`?{text:e.prStage.kind===`ready`?`merge`:e.prStage.kind===`conflict`?`conflict`:`CI`,cls:`wd-rail-slot-review`}:{text:J(Je(e)),cls:``}}function pc({sessions:e,activeSessionId:t,onSelect:n,onNewWorktree:r,prsFor:i,order:a,onReorder:o,onRename:s,menuFor:c,layout:l=ot,onPlace:u,onSections:d,onShownChange:f}){let[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useRef)(null),y=(0,_.useRef)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(hc),P=h.trim()!==``,F=(0,_.useMemo)(()=>gt(e,Date.now(),[]),[e]),I=F.current.length+F.older.length>0,{groups:ee,hidden:te}=(0,_.useMemo)(()=>{if(P){let{current:t,older:n}=gt(e,Date.now(),a??[]);return{groups:[{key:`search`,title:null,sessions:[...t,...n].filter(e=>vt(e,h))}],hidden:0}}return _t(e,{order:a,layout:l,activeId:t,showOlder:p})},[e,a,l,t,p,P,h]),ne=e=>M.has(e.key)?e.sessions.filter(e=>e.id===t):e.sessions,L=ee.flatMap(ne),re=new Map(ee.flatMap(e=>e.sessions.map(t=>[t.id,e]))),ie=!!o&&!P,ae=!!u&&!P,oe=e=>N(t=>{let n=new Set(t);return n.delete(e)||n.add(e),gc(n),n});(0,_.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey)return;let t=document.activeElement;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(jt()||document.querySelector(`[role="menu"]`)||(e.preventDefault(),v.current?.focus()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let se=(0,_.useRef)(L);se.current=L,(0,_.useEffect)(()=>{let e=e=>{if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=/^Digit([1-9])$/.exec(e.code)?.[1];if(!t)return;let r=document.activeElement,i=!!r?.classList.contains(`xterm-helper-textarea`);if(r&&!i&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable)||jt()||document.querySelector(`[role="menu"]`))return;let a=se.current[Number(t)-1];a&&(e.preventDefault(),e.stopPropagation(),n(a.id))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]),(0,_.useEffect)(()=>{if(!s||!t)return;let e=e=>{if(e.key!==`F2`||e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented)return;let n=document.activeElement;(!n||n.tagName!==`INPUT`&&n.tagName!==`TEXTAREA`&&!n.isContentEditable)&&(jt()||document.querySelector(`[role="menu"]`)||(e.preventDefault(),T(t)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,t]);let ce=L.map(e=>e.id),le=ce.join(`,`);(0,_.useEffect)(()=>{f?.(le?le.split(`,`):[])},[le,f]);let ue=(e,t)=>{ie&&o?.(at(ce,e,t,a??[]))},de=(e,t)=>{ae&&t&&re.get(e)?.key!==t.key&&u?.(e,ct(t))},R=()=>{x(null),C(null)},z=async e=>{let t=A;if(!t||!d||!e)return;if(t.kind===`rename`)return d({op:`rename`,id:t.sectionId,name:e});let n=lt();await d({op:`add`,id:n,name:e}),t.sessionId&&u?.(t.sessionId,{pinned:!1,section:n})},B=(e,t)=>void d?.({op:`move`,id:e,by:t}).catch(()=>{}),fe=(e,r)=>{let a=Ye(e),o=e.id===t,l=e.titleIsYours&&!!e.title,d=l?e.title:e.branch||e.target,f=cc(e),p=Ws(e),m=fc(e,a),h=i?.(e)??[],g=e.attention?.summary;if(s&&w===e.id)return(0,H.jsx)(`li`,{children:(0,H.jsx)(vc,{session:e,dot:(0,H.jsx)(Dt,{kind:a}),onDone:()=>T(null),onSave:t=>s(e.id,t)})},e.id);let _=S&&`id`in S&&S.id===e.id&&b!==e.id?S:null;return(0,H.jsx)(`li`,{draggable:ie||ae,className:(b===e.id?`wd-dash-rail-dragging`:``)+(_?_.before?` wd-dash-rail-drop-before`:` wd-dash-rail-drop-after`:``),onDragStart:t=>{x(e.id),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)},onDragOver:t=>{if(!b)return;t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY<n.top+n.height/2;(!_||_.before!==r)&&C({id:e.id,before:r})},onDrop:e=>{if(e.preventDefault(),b&&S&&`id`in S){de(b,re.get(S.id));let e=ce.indexOf(S.id);ue(b,S.before?S.id:ce[e+1]??null)}R()},onDragEnd:R,children:(0,H.jsxs)(`button`,{type:`button`,className:`wd-dash-rail-item`+(o?` wd-dash-rail-item-active`:``)+((a===`needs_input`||a===`done`||a===`review`)&&!e.snoozed?` wd-dash-rail-item-unseen`:``),onClick:()=>n(e.id),onContextMenu:t=>{(s||c||u)&&(t.preventDefault(),D({id:e.id,x:t.clientX,y:t.clientY}))},onKeyDown:t=>{if(s&&t.key===`F2`){t.preventDefault(),T(e.id);return}if(!ie||!t.altKey||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=ce.indexOf(e.id);t.key===`ArrowUp`&&n>0&&ue(e.id,ce[n-1]),t.key===`ArrowDown`&&n<ce.length-1&&ue(e.id,ce[n+2]??null)},title:`${e.target} · ${e.branch}${f?` (${f})`:``}${e.stackedOn?` · stacked on ${e.stackedOn.branch}`:``}${p?` · ${p}`:``}${e.title?`\n${e.title}`:``}\n${Xe[a]}`+(g?` — ${g}`:``)+dc(e)+(r<9?`\nAlt+${r+1}`:``),children:[(0,H.jsx)(Dt,{kind:a,labelled:!0,muted:!!e.snoozed}),(0,H.jsxs)(`span`,{className:`wd-dash-rail-lines`,children:[(0,H.jsxs)(`span`,{className:`wd-dash-rail-line`,children:[(0,H.jsx)(`span`,{className:`wd-dash-rail-name`,children:d}),(0,H.jsx)(`span`,{className:`wd-dash-rail-slot `+m.cls,children:m.text})]}),(0,H.jsxs)(`span`,{className:`wd-dash-rail-line wd-dash-rail-sub`,children:[(0,H.jsxs)(`span`,{className:`wd-dash-rail-summary`,children:[e.target,l?` · ${e.branch}`:``]}),(0,H.jsx)($s,{session:e,prs:h})]})]})]})},e.id)},pe=0;return(0,H.jsxs)(`aside`,{className:`wd-dash-rail`,role:`navigation`,"aria-label":`Sessions`,children:[(0,H.jsxs)(`header`,{className:`wd-dash-rail-header`,children:[I&&(0,H.jsx)(`input`,{ref:v,className:`wd-dash-rail-search`,type:`search`,placeholder:`Search sessions /`,title:`Filter this list (/). Ctrl+P jumps to any session from anywhere, a terminal included; Alt+1…9 opens the first nine rows.`,"aria-label":`Search sessions`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(g(``),e.currentTarget.blur()):e.key===`Enter`&&L[0]?n(L[0].id):e.key===`ArrowDown`&&(e.preventDefault(),y.current?.querySelector(`.wd-dash-rail-item`)?.focus())}}),(0,H.jsx)(uc,{}),(0,H.jsx)(`button`,{type:`button`,className:`wd-dash-rail-new`,onClick:r,title:`New worktree`,"aria-label":`New worktree`,children:`+`})]}),P&&L.length===0&&(0,H.jsxs)(`p`,{className:`wd-dash-rail-empty`,children:[`No session matches “`,h.trim(),`”.`]}),I?(0,H.jsxs)(`ul`,{className:`wd-dash-rail-list`,ref:y,children:[A?.kind===`new`&&(0,H.jsx)(`li`,{children:(0,H.jsx)(_c,{initial:``,placeholder:`New section name`,onSave:z,onDone:()=>j(null)})}),ee.map(e=>{let t=M.has(e.key),n=ne(e),r=S&&`group`in S&&S.group===e.key;return[e.title!==null&&(A?.kind===`rename`&&A.sectionId===e.sectionId?(0,H.jsx)(`li`,{children:(0,H.jsx)(_c,{initial:e.title,placeholder:`Section name`,onSave:z,onDone:()=>j(null)})},`h:${e.key}`):(0,H.jsx)(`li`,{className:`wd-dash-rail-group`+(r?` wd-dash-rail-group-drop`:``),onDragOver:t=>{b&&ae&&(t.preventDefault(),r||C({group:e.key}))},onDrop:t=>{t.preventDefault(),b&&de(b,e),R()},children:(0,H.jsxs)(`button`,{type:`button`,className:`wd-dash-rail-group-toggle`,"aria-expanded":!t,onClick:()=>oe(e.key),onContextMenu:t=>{e.sectionId&&d&&(t.preventDefault(),k({id:e.sectionId,x:t.clientX,y:t.clientY}))},title:e.sectionId?`Fold or unfold; right-click to rename, move or remove it`:`Fold or unfold`,children:[(0,H.jsx)(`span`,{className:`wd-dash-rail-group-caret`,"aria-hidden":`true`,children:t?`▸`:`▾`}),(0,H.jsx)(`span`,{className:`wd-dash-rail-group-name`,children:e.title}),(0,H.jsx)(`span`,{className:`wd-dash-rail-group-count`,children:e.sessions.length})]})},`h:${e.key}`)),...n.map(e=>fe(e,pe++)),!t&&e.sessions.length===0&&(0,H.jsx)(`li`,{className:`wd-dash-rail-group-empty`,children:e.sectionId?`Drag a session here, or right-click one → Move to “${e.title}”.`:`Drag a session here to unpin it or take it out of its section.`},`e:${e.key}`)]}),te>0&&(0,H.jsx)(`li`,{className:`wd-dash-rail-overflow`,children:(0,H.jsxs)(`button`,{type:`button`,className:`wd-dash-rail-older`,onClick:()=>m(!0),title:`Sessions not entered in the last 14 days and not running`,children:[`+`,te,` older`]})}),p&&!P&&F.older.length>0&&(0,H.jsx)(`li`,{className:`wd-dash-rail-overflow`,children:(0,H.jsx)(`button`,{type:`button`,className:`wd-dash-rail-older`,onClick:()=>m(!1),children:`Hide older`})})]}):(0,H.jsx)(`p`,{className:`wd-dash-rail-empty`,children:`No worktrees yet. Click + to create one.`}),E&&(0,H.jsx)(Qa,{x:E.x,y:E.y,onClose:()=>D(null),items:(()=>{let t=e.find(e=>e.id===E.id);if(!t)return[];let n=s?[{label:`Rename`,hint:`F2`,run:()=>T(E.id)}]:[],r=u?Ys(t,l,{place:(e,t)=>u(e.id,t),newSection:e=>j({kind:`new`,sessionId:e.id})}):[],i=c?c(t).map((e,t)=>t===0?{...e,separated:!0}:e):[];return[...n,...r,...i]})()}),O&&(0,H.jsx)(Qa,{x:O.x,y:O.y,onClose:()=>k(null),items:[{label:`Rename section`,run:()=>j({kind:`rename`,sectionId:O.id})},{label:`Move up`,run:()=>B(O.id,-1)},{label:`Move down`,run:()=>B(O.id,1)},{label:`New section…`,run:()=>j({kind:`new`,sessionId:null}),separated:!0},{label:`Remove section`,hint:`its sessions stay`,danger:!0,separated:!0,run:()=>void d?.({op:`remove`,id:O.id}).catch(()=>{})}]})]})}var mc=`work-web:rail-collapsed`;function hc(){try{let e=JSON.parse(localStorage.getItem(mc)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function gc(e){try{localStorage.setItem(mc,JSON.stringify([...e]))}catch{}}function _c({initial:e,placeholder:t,onSave:n,onDone:r}){let[i,a]=(0,_.useState)(e),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=()=>{let e=i.trim();if(!e)return r();s(!0),Promise.resolve(n(e)).then(r,e=>{s(!1),l(e.message)})};return(0,H.jsxs)(`div`,{className:`wd-dash-rail-group wd-dash-rail-group-naming`,children:[(0,H.jsx)(`input`,{className:`wd-dash-rail-rename`,autoFocus:!0,value:i,disabled:o,maxLength:40,placeholder:t,"aria-label":t,title:c??`Enter to save, Esc to cancel`,onChange:e=>a(e.target.value),onBlur:()=>!o&&r(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),u()):e.key===`Escape`&&(e.preventDefault(),r())}}),c&&(0,H.jsxs)(`span`,{className:`wd-dash-rail-group-error`,children:[`⚠ `,c]})]})}function vc({session:e,dot:t,onSave:n,onDone:r}){let[i,a]=(0,_.useState)(e.titleIsYours?e.title??``:``),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=()=>{s(!0),l(null),n(i.trim()).then(r,e=>{s(!1),l(e.message)})};return(0,H.jsxs)(`div`,{className:`wd-dash-rail-item wd-dash-rail-item-renaming`,children:[t,(0,H.jsxs)(`span`,{className:`wd-dash-rail-lines`,children:[(0,H.jsx)(`input`,{className:`wd-dash-rail-rename`,autoFocus:!0,value:i,disabled:o,placeholder:e.title??`Name this session`,"aria-label":`Name for ${e.branch||e.target}`,title:c??`Enter to save, Esc to cancel; empty goes back to the automatic name`,onChange:e=>a(e.target.value),onBlur:()=>!o&&r(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),u()):e.key===`Escape`&&(e.preventDefault(),r())}}),(0,H.jsx)(`span`,{className:`wd-dash-rail-line wd-dash-rail-sub`,children:(0,H.jsx)(`span`,{className:`wd-dash-rail-summary`,children:c?`⚠ ${c}`:`${e.target} · ${e.branch}`})})]})]})}var yc={storageKey:`work-web:sidebar-width`,cssVar:`--sidebar-width`,defaultPx:320,min:200,max:720,axis:`x`,label:`Resize sidebar`},bc={storageKey:`work-web:rail-width`,cssVar:`--rail-width`,defaultPx:248,min:160,max:480,axis:`x`,label:`Resize session list`},xc={storageKey:`work-web:comments-height`,cssVar:`--comments-height`,defaultPx:220,min:60,max:900,axis:`y`,invert:!0,label:`Resize comments panel`};function Sc(e,t){return Math.max(e.min,Math.min(e.max,t))}function Cc(e){try{let t=localStorage.getItem(e.storageKey),n=t?Number(t):NaN;if(Number.isFinite(n)&&n>=e.min&&n<=e.max)return n}catch{}return e.defaultPx}function wc(e){let[t,n]=(0,_.useState)(()=>Cc(e));return{size:t,setSize:(0,_.useCallback)(t=>{let r=Sc(e,t);n(r);try{localStorage.setItem(e.storageKey,String(r))}catch{}},[e])}}function Tc(){let{size:e,setSize:t}=wc(yc);return{width:e,setWidth:t}}function Ec({layoutRef:e,size:t,onCommit:n,spec:r=yc}){let i=(0,_.useRef)(null),a=(0,_.useRef)(t),[o,s]=(0,_.useState)(!1);function c(t){let n=Sc(r,t);a.current=n,e.current?.style.setProperty(r.cssVar,`${n}px`)}let l=e=>r.axis===`x`?e.clientX:e.clientY;function u(e){e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),i.current={pos:l(e),w:t},a.current=t,s(!0)}function d(e){if(!i.current)return;let t=l(e)-i.current.pos;c(i.current.w+(r.invert?-t:t))}function f(){i.current&&(i.current=null,s(!1),n(a.current))}return(0,_.useEffect)(()=>{if(!o)return;let e=document.body.style.userSelect,t=document.body.style.cursor;return document.body.style.userSelect=`none`,document.body.style.cursor=r.axis===`x`?`col-resize`:`row-resize`,()=>{document.body.style.userSelect=e,document.body.style.cursor=t}},[o,r.axis]),(0,H.jsx)(`div`,{className:`wd-resize-divider`+(r.axis===`y`?` wd-resize-divider-y`:``)+(o?` wd-resize-dragging`:``),role:`separator`,"aria-orientation":r.axis===`x`?`vertical`:`horizontal`,"aria-label":r.label,onPointerDown:u,onPointerMove:d,onPointerUp:f,onPointerCancel:f,onDoubleClick:()=>n(r.defaultPx),title:`Drag to resize, double-click to reset`})}function Dc({route:e,sessions:t,onSelectTab:n,onSelectSession:r,onHome:i,onNewWorktree:a,inboxCount:o,prsFor:s,onAssistant:c,assistantOpen:l,activity:u,help:d,tasks:f,sessionOrder:p,onReorderSessions:m,sessionMenu:h,railLayout:g,onPlaceSession:v,onRailSections:y,onRailShownChange:b,children:x}){let[S,C]=(0,_.useState)(!1);(0,_.useEffect)(()=>{C(!1)},[e.tab,e.sessionId,e.sessionSubTab]),(0,_.useEffect)(()=>{if(!S)return;let e=e=>{e.key===`Escape`&&C(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[S]);let{size:w,setSize:T}=wc(bc),E=(0,_.useRef)(null);return(0,H.jsxs)(`div`,{className:`wd-dash-layout`,children:[(0,H.jsx)(Us,{active:e.tab,onSelect:n,onHome:i,inboxCount:o,onToggleRail:()=>C(e=>!e),railOpen:S,onAssistant:c,assistantOpen:l,activity:u,help:d,tasks:f}),(0,H.jsxs)(`div`,{ref:E,className:`wd-dash-body`+(S?` wd-dash-rail-open`:``),style:{[bc.cssVar]:`${w}px`},children:[S&&(0,H.jsx)(`div`,{className:`wd-dash-rail-backdrop`,onClick:()=>C(!1),"aria-hidden":!0}),(0,H.jsx)(pc,{sessions:t,activeSessionId:e.sessionId,onSelect:e=>{C(!1),r(e)},onNewWorktree:()=>{C(!1),a()},prsFor:s,onRename:ve,menuFor:h,layout:g,onPlace:v,onSections:y,onShownChange:b,order:p,onReorder:m}),(0,H.jsx)(Ec,{layoutRef:E,size:w,onCommit:T,spec:bc}),(0,H.jsx)(`main`,{className:`wd-dash-main`,children:x})]})]})}function Oc(e,t){if(!e)return null;let n=e.schedules.find(e=>e.pausedUntil&&Date.parse(e.pausedUntil)>t);if(n)return`${n.label} is resting${n.pausedWhy?`: ${n.pausedWhy}`:``}`;let r=new Set;for(let t of e.recent){if(r.has(t.kind)||t.status===`skipped`)continue;r.add(t.kind);let n=!!e.lastOk?.[t.kind]||e.recent.some(e=>e.kind===t.kind&&e.status===`done`);if(t.status===`failed`&&n)return`${t.label} failed${t.summary?`: ${t.summary}`:``}`}return null}function kc(e){let t=e?.running[0];if(!t)return`all quiet`;let n=t.progress&&t.progress.total>0?` ${t.progress.done}/${t.progress.total}`:``,r=(e?.running.length??0)>1?` (+${e.running.length-1} more)`:``;return`${t.label}${n}${r}`}var Ac=e=>e.notes.some(e=>e.level!==`info`);function jc(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.kind===n.kind&&e.status===n.status&&!Ac(e)&&!Ac(n)){t[t.length-1]={...e,repeats:(e.repeats??0)+(n.repeats??0)+1};continue}t.push(n)}return t}function Mc(e,t){let n=Math.round((Date.parse(e)-t)/1e3);if(n<=0)return`now`;let r=Math.floor(n/60);return r>=60?`in ${Math.round(r/60)} h`:`in ${r}:${String(n%60).padStart(2,`0`)}`}var Nc=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Pc=e=>e>=6e4?`every ${Math.round(e/6e4)} min`:`every ${Math.round(e/1e3)} s`;function Fc({onOpenSession:e,load:t=P}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(()=>Date.now()),c=(0,_.useRef)(null),l=(0,_.useCallback)(()=>{t().then(r,()=>{})},[t]);(0,_.useEffect)(l,[l]),Xa(`/events`,{events:{"activity-changed":l},onOpen:l}),(0,_.useEffect)(()=>{if(!i)return;s(Date.now());let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[i]),(0,_.useEffect)(()=>{if(!i)return;let e=e=>e.key===`Escape`&&a(!1),t=e=>{c.current&&!c.current.contains(e.target)&&a(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,t)}},[i]);let u=n?.running??[],d=Oc(n,Date.now()),f=d??kc(n);return(0,H.jsxs)(`div`,{className:`wd-activity`,ref:c,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-activity-dot-btn`+(d?` wd-activity-attention`:``),"aria-expanded":i,"aria-label":`Background jobs: ${f}`,title:`Background jobs: ${f}
|
|
91
|
-
Click for what work does in the background, and what it decided`,onClick:()=>a(e=>!e),children:(0,H.jsx)(`span`,{className:`wd-activity-dot`+(u.length?` wd-activity-dot-busy`:``),"aria-hidden":!0})}),i&&(0,H.jsxs)(`div`,{className:`wd-activity-panel`,role:`dialog`,"data-popover":!0,"aria-label":`Background activity`,children:[(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Now`}),u.length===0?(0,H.jsx)(`p`,{className:`wd-activity-empty`,children:`Nothing running.`}):u.map(t=>(0,H.jsx)(zc,{run:t,onOpenSession:e},t.id))]}),(n?.schedules.length??0)>0&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Coming up`}),(0,H.jsx)(`ul`,{className:`wd-activity-list`,children:n.schedules.map(e=>(0,H.jsx)(Ic,{s:e,now:o},e.kind))})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Recent`}),(n?.recent.length??0)===0?(0,H.jsx)(`p`,{className:`wd-activity-empty`,children:`Nothing yet.`}):jc(n.recent).map(t=>(0,H.jsx)(zc,{run:t,onOpenSession:e},t.id))]})]})]})}function Ic({s:e,now:t}){let n=e.pausedUntil&&Date.parse(e.pausedUntil)>t;return(0,H.jsxs)(`li`,{className:`wd-activity-schedule`,children:[(0,H.jsx)(`span`,{className:`wd-activity-name`,children:e.label}),` `,(0,H.jsx)(`span`,{className:`wd-activity-muted`,children:n?(0,H.jsxs)(`span`,{className:`wd-activity-warn`,children:[`resting until `,Nc(e.pausedUntil),`: `,e.pausedWhy]}):(0,H.jsxs)(H.Fragment,{children:[Pc(e.everyMs),e.nextAt?` · next ${Mc(e.nextAt,t)}`:``]})})]})}var Lc={running:``,done:`✓`,failed:`✗`,skipped:`⏸`},Rc=4;function zc({run:e,onOpenSession:t}){let[n,r]=(0,_.useState)(!1),i=n?e.notes:e.notes.slice(0,Rc);return(0,H.jsxs)(`div`,{className:`wd-activity-run wd-activity-run-${e.status}`,children:[(0,H.jsxs)(`div`,{className:`wd-activity-head`,children:[e.status===`running`?(0,H.jsx)(`span`,{className:`wd-activity-spinner`,"aria-hidden":!0}):(0,H.jsx)(`span`,{className:`wd-activity-mark`,children:Lc[e.status]}),(0,H.jsx)(`span`,{className:`wd-activity-name`,children:e.label}),e.status===`running`&&e.progress&&e.progress.total>0&&(0,H.jsx)(`progress`,{className:`wd-activity-progress`,max:e.progress.total,value:e.progress.done,"aria-label":`${e.progress.done} of ${e.progress.total}`}),(0,H.jsxs)(`span`,{className:`wd-activity-muted wd-activity-when`,children:[e.status===`running`?`started ${J(e.startedAt)}`:J(e.endedAt??e.startedAt),e.repeats?` · ×${e.repeats+1}`:``]})]}),e.summary&&(0,H.jsx)(`div`,{className:`wd-activity-summary`,children:e.summary}),i.length>0&&(0,H.jsxs)(`ul`,{className:`wd-activity-notes`,children:[i.map((e,n)=>(0,H.jsx)(`li`,{className:`wd-activity-note wd-activity-note-${e.level}`,children:e.sessionId?(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(e.sessionId),title:`Open this session`,children:e.text}):e.text},n)),e.notes.length>Rc&&(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button wd-activity-more`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`Show all ${e.notes.length}`})})]})]})}var Bc=`2.0.0`;function Vc(e){let t=e?.available;if(t)return t.how===`restart`?`${t.version} is ready to install`:t.how===`downloading`?`downloading ${t.version}`:`${t.version} is out`;let n=e?.desktop;return n?.state===`failed`?`couldn't update: ${n.error??`unknown`}`:null}function Hc({updates:e,onCheck:t,checking:n,note:r,onWhatsNew:i,onShortcuts:a,onRestart:o}){let[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!s)return;let e=e=>e.key===`Escape`&&c(!1),t=e=>{l.current&&!l.current.contains(e.target)&&c(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,t)}},[s]);let u=e?.running??`2.0.0`,d=Vc(e),f=e?.available?.how===`restart`&&!!o,p=e=>()=>{c(!1),e?.()};return(0,H.jsxs)(`div`,{className:`wd-help`,ref:l,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-help-btn`+(e?.available?` wd-help-btn-update`:``),"aria-expanded":s,"aria-label":`Help: work v${u}${d?`, ${d}`:``}`,title:`work v${u}${d?` · ${d}`:``}\nHelp: updates, what's new, keyboard shortcuts`,onClick:()=>c(e=>!e),children:[`v`,u]}),s&&(0,H.jsxs)(`div`,{className:`wd-help-panel`,role:`dialog`,"data-popover":!0,"aria-label":`Help`,children:[(0,H.jsxs)(`p`,{className:`wd-help-version`,children:[`work v`,u,d&&(0,H.jsxs)(`span`,{className:`wd-help-status`,children:[` · `,d]})]}),f&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item wd-help-restart`,onClick:p(o),children:`Restart to update`}),t&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item`,disabled:n,onClick:t,children:n?`Checking…`:`Check for updates`}),r&&(0,H.jsx)(`p`,{className:`wd-help-note`,children:r}),i&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item`,onClick:p(i),children:`What's new`}),a&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-row-menu-item`,onClick:p(a),children:[`Keyboard shortcuts `,(0,H.jsx)(`kbd`,{children:`?`})]})]})]})}function Uc({selected:e,hidden:t=0,actions:n,onRun:r,onClear:i,busy:a,sections:o=[]}){let[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.filter(e=>!e.archivedAt),y=e.filter(e=>!!e.archivedAt);return(0,H.jsxs)(`div`,{className:`wd-bulk-bar`,role:`toolbar`,"aria-label":`Act on the ticked sessions`,children:[(0,H.jsxs)(`span`,{className:`wd-bulk-count`,children:[e.length,` selected`]}),t>0&&(0,H.jsxs)(`span`,{className:`wd-bulk-hidden`,title:`Ticked, but hidden by the filter or search: the bar leaves them out`,children:[`(+`,t,` hidden, not included)`]}),a?(0,H.jsx)(`span`,{className:`wd-bulk-busy`,children:a}):s===`send`?(0,H.jsxs)(`form`,{className:`wd-bulk-send`,onSubmit:e=>{e.preventDefault(),l.trim()&&(r(`Sent to`,e=>n.send(e,l.trim()),v),u(``),c(null))},children:[(0,H.jsx)(`textarea`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`What to tell ${v.length===1?`its Claude`:`their ${v.length} Claudes`} (delivered like a review comment: now in a terminal the dashboard owns, else on its next turn)`,rows:2,"aria-label":`Prompt to send`}),(0,H.jsxs)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!l.trim()||v.length===0,children:[`Send to `,v.length]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(null),children:`Cancel`})]}):s===`delete`?(0,H.jsxs)(`span`,{className:`wd-bulk-confirm`,role:`alert`,children:[`Delete `,e.length,` session`,e.length===1?``:`s`,`? A worktree goes only where nothing would be lost; the others are refused and listed.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-danger`,onClick:()=>{c(null),r(`Deleted`,e=>n.remove(e),e)},children:`Delete`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(null),children:`Cancel`})]}):(0,H.jsxs)(H.Fragment,{children:[v.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>r(`Archived`,e=>n.archive(e),v),children:[`Archive `,v.length]}),y.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>r(`Restored`,e=>n.restore(e),y),children:[`Restore `,y.length]}),v.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();f({x:t.left,y:t.bottom+2})},children:[`Snooze `,v.length,` ▾`]}),v.length>0&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(`send`),children:`Send a prompt…`}),v.length>0&&n.place&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();g({x:t.left,y:t.bottom+2})},title:`Pin them, or put them under one of the rail's sections`,children:`Rail ▾`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-bulk-delete`,onClick:()=>c(`delete`),children:`Delete…`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:i,children:`Clear`})]}),d&&(0,H.jsx)(Qa,{x:d.x,y:d.y,onClose:()=>f(null),items:[[`2 hours`,`2h`],[`Until tomorrow 9:00`,`tomorrow`],[`Until it changes`,`change`]].map(([e,t])=>({label:e,run:()=>r(`Snoozed`,e=>n.snooze(e,t),v)})).concat([{label:`Until…`,run:()=>m(!0)}])}),h&&n.place&&(0,H.jsx)(Qa,{x:h.x,y:h.y,onClose:()=>g(null),items:[{label:`Pin ${v.length}`,run:()=>r(`Pinned`,e=>n.place(e,{pinned:!0}),v)},{label:`Unpin ${v.length}`,run:()=>r(`Unpinned`,e=>n.place(e,{pinned:!1}),v)},...o.map((e,t)=>({label:`Move to “${e.name}”`,run:()=>r(`Moved to “${e.name}”`,t=>n.place(t,{pinned:!1,section:e.id}),v),...t===0?{separated:!0}:{}})),...o.length?[{label:`Out of their section`,run:()=>r(`Took out of their section`,e=>n.place(e,{section:null}),v)}]:[]]}),p&&(0,H.jsx)(Ao,{count:v.length,onClose:()=>m(!1),onPick:e=>{m(!1),r(`Snoozed`,t=>n.snooze(t,{until:e}),v)}})]})}async function Wc(e,t,n={}){let r=Array(e.length),i=0,a=0;return await Promise.all(Array.from({length:Math.min(n.concurrency??3,e.length)},async()=>{for(let o=i++;o<e.length;o=i++){try{await t(e[o]),r[o]={id:e[o],ok:!0}}catch(t){r[o]={id:e[o],ok:!1,error:t.message}}n.onProgress?.(++a,e.length)}})),r}function Gc(e,t,n){let r=t.filter(e=>e.ok).length,i=t.filter(e=>!e.ok);if(i.length===0)return`${e} ${r}.`;let a=i.slice(0,3).map(e=>`${n(e.id)} — ${e.error??`refused`}`).join(`; `);return`${e} ${r}; ${i.length} refused: ${a}${i.length>3?` (and ${i.length-3} more)`:``}`}function Kc(e,t=!1){let n=new Map;for(let t of e){let e=n.get(t.target);e||(e={key:t.target,isGroup:t.isGroup,repos:[],sessions:[]},n.set(t.target,e)),e.sessions.push(t);for(let n of qc(t))e.repos.includes(n)||e.repos.push(n)}let r=[...n.values()];return t&&r.sort((e,t)=>e.key.toLowerCase().localeCompare(t.key.toLowerCase())),r}function qc(e){return!e.isGroup||e.paths.length<2?[]:e.paths.map(e=>{let t=e.split(/[\\/]+/).filter(Boolean);return t[t.length-1]??e})}var Jc={archive:e=>T(e.id,!0,()=>!1),restore:e=>T(e.id,!1,()=>!1),snooze:(e,t)=>B(e,t),send:(e,t)=>pe(e.id,t),remove:e=>cn(e.id,{}),place:(e,t)=>Pe(e.id,t)},Yc=`work-web:sessions-grouping`,Xc=`work-web:sessions-show-archived`;function Zc(e,t){try{return localStorage.getItem(e)===t}catch{return!1}}function Qc(e,t){try{localStorage.setItem(e,t)}catch{}}var $c={all:`all`,needs:`needs you`,working:`working`,idle:`idle`,stale:`stale`};function el({layout:e,sessions:t,onOpenSession:n,onNewWorktree:r,onDeleteSession:i,menuFor:a,onCleanUp:o,bulk:s=Jc,viewToggle:c,onShowArchived:l}){let[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(()=>new Set),m=e=>{d(e),e||p(new Set)},[h,g]=(0,_.useState)(null),v=e=>a?a(e):[pt(e)?{label:`Restore`,run:()=>void T(e.id,!1).catch(()=>{})}:{label:`Archive`,run:()=>void T(e.id,!0).catch(()=>{})},{label:`Delete…`,run:()=>i(e),danger:!0,separated:!0}],[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),C=(e,t)=>p(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),w=t.filter(e=>f.has(e.id)),E=(e,t,n)=>{let r=new Map(n.map(e=>[e.id,e]));S(null),b(`${e} 0/${n.length}…`),Wc([...r.keys()],e=>t(r.get(e)),{onProgress:(t,n)=>b(`${e} ${t}/${n}…`)}).then(t=>{b(null),S(Gc(e,t,e=>r.get(e)?.branch??e)),p(new Set(t.filter(e=>!e.ok).map(e=>e.id)))})},[D,O]=(0,_.useState)(`recent`),[k,A]=(0,_.useState)(`all`),[j,M]=(0,_.useState)(`any`),N=e??ot,P=(0,_.useMemo)(()=>{let e=new Map;for(let n of st(t.filter(e=>!pt(e)),N))for(let t of n.sessions)e.set(t.id,n);return e},[t,N]),F=(0,_.useCallback)(e=>{if(j===`any`)return!0;let t=P.get(e.id);return j===`pinned`?t?.key===`pinned`:j===`none`?!t||t.key===`rest`:t?.key===j},[j,P]),[I,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(()=>{try{let e=localStorage.getItem(Yc);return e===`project`||e===`none`||e===`section`?e:`age`}catch{return`age`}}),[L,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(()=>Zc(Xc,`1`)),oe=e=>{ne(e),Qc(Yc,e)},se=e=>{ae(e),Qc(Xc,e?`1`:`0`)};(0,_.useEffect)(()=>(l?.(ie),()=>l?.(!1)),[ie]);let ce=(0,_.useMemo)(()=>t.filter(e=>!pt(e)),[t]),le=t.length-ce.length,ue=(0,_.useMemo)(()=>{let e={now:0,week:0,older:0};for(let t of ce)e[et(t)]++;return e},[ce]),de=(0,_.useMemo)(()=>[...(ie?t:ce).filter(e=>(k===`all`||tt(Ye(e))===k)&&F(e)&&vt(e,I))].sort((e,t)=>{if(D===`name`){let n=(e.branch||e.target).toLowerCase(),r=(t.branch||t.target).toLowerCase();return n.localeCompare(r)}return Je(t).localeCompare(Je(e))}),[t,ce,ie,D,k,I,F]),R=de.filter(e=>f.has(e.id)),z=w.length-R.length;(0,_.useEffect)(()=>{let e=new Set(t.map(e=>e.id));p(t=>[...t].every(t=>e.has(t))?t:new Set([...t].filter(t=>e.has(t))))},[t]);let B=(0,_.useMemo)(()=>te===`project`?Kc(de,D===`name`):null,[de,te,D]),fe=(0,_.useMemo)(()=>{if(te!==`section`)return null;let e=st(de.filter(e=>!pt(e)),N).filter(e=>e.sessions.length>0),t=de.filter(e=>pt(e));return t.length?[...e,{key:`archived`,title:`Archived`,sessions:t}]:e},[de,te,N]),pe=(0,_.useMemo)(()=>{if(te!==`age`)return null;let e={now:[],week:[],older:[]};for(let t of de)e[et(t)].push(t);return Object.keys(e).map(t=>({key:t,sessions:e[t]})).filter(e=>e.sessions.length>0)},[de,te]),me=e=>{let t=P.get(e.id);return t?.key===`pinned`?`📌`:t?.sectionId?t.title:null},he=e=>(0,H.jsxs)(`table`,{className:`wd-session-table`+(u?` wd-session-table-selecting`:``),children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[u&&(0,H.jsx)(`th`,{className:`wd-st-col-pick`,children:(0,H.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all shown`,checked:e.length>0&&e.every(e=>f.has(e.id)),onChange:t=>{let n=t.target.checked;p(t=>{let r=new Set(t);for(let t of e)n?r.add(t.id):r.delete(t.id);return r})}})}),(0,H.jsx)(`th`,{className:`wd-st-col-status`,children:`Status`}),(0,H.jsx)(`th`,{children:`Session`}),(0,H.jsx)(`th`,{className:`wd-st-col-summary`,children:`Summary`}),(0,H.jsx)(`th`,{className:`wd-st-col-changes`,children:`Changes`}),(0,H.jsx)(`th`,{className:`wd-st-col-when`,children:`Active`}),(0,H.jsx)(`th`,{className:`wd-st-col-more`,children:(0,H.jsx)(`span`,{className:`wd-visually-hidden`,children:`Actions`})})]})}),(0,H.jsx)(`tbody`,{children:e.map(e=>(0,H.jsx)(il,{session:e,onOpen:()=>n(e.id,ut(e)),onMenu:(t,n)=>g({s:e,x:t,y:n}),selecting:u,picked:f.has(e.id),onPick:t=>C(e.id,t),railTag:me(e)},e.id))})]});return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-sessions`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsxs)(`h1`,{children:[`Sessions `,c,` `,(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:[ue.now?`${ue.now} now`:``,ue.week?`${ue.week} this week`:``,ue.older?`${ue.older} older`:``].filter(Boolean).join(` · `)})]}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[(0,H.jsx)(`input`,{className:`wd-tab-search`,type:`search`,placeholder:`Search branch, repo, words…`,"aria-label":`Search sessions`,value:I,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Escape`&&ee(``)}}),(0,H.jsxs)(nl,{children:[(0,H.jsxs)(`label`,{children:[`Show`,(0,H.jsx)(`select`,{value:k,onChange:e=>A(e.target.value),"aria-label":`Status filter`,children:Object.keys($c).map(e=>(0,H.jsx)(`option`,{value:e,children:$c[e]},e))})]}),(N.sections.length>0||Object.keys(N.places).length>0)&&(0,H.jsxs)(`label`,{children:[`Rail`,(0,H.jsxs)(`select`,{value:j,onChange:e=>M(e.target.value),"aria-label":`Rail filter`,children:[(0,H.jsx)(`option`,{value:`any`,children:`any`}),(0,H.jsx)(`option`,{value:`pinned`,children:`pinned`}),N.sections.map(e=>(0,H.jsx)(`option`,{value:`section:${e.id}`,children:e.name},e.id)),(0,H.jsx)(`option`,{value:`none`,children:`in no section`})]})]}),(0,H.jsxs)(`label`,{children:[`Group`,(0,H.jsxs)(`select`,{value:te,onChange:e=>oe(e.target.value),"aria-label":`Group by`,children:[(0,H.jsx)(`option`,{value:`age`,children:`age`}),(0,H.jsx)(`option`,{value:`project`,children:`project`}),(0,H.jsx)(`option`,{value:`section`,children:`rail section`}),(0,H.jsx)(`option`,{value:`none`,children:`none`})]})]}),(0,H.jsxs)(`label`,{children:[`Sort`,(0,H.jsxs)(`select`,{value:D,onChange:e=>O(e.target.value),"aria-label":`Sort by`,children:[(0,H.jsx)(`option`,{value:`recent`,children:`recent`}),(0,H.jsx)(`option`,{value:`name`,children:`name`})]})]}),(0,H.jsxs)(`label`,{className:`wd-tab-check`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:ie,onChange:e=>se(e.target.checked)}),` Show archived`,le>0?` (${le})`:``]}),(0,H.jsxs)(`label`,{className:`wd-tab-check`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>m(e.target.checked)}),` Select several`]})]}),o&&(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:o,title:`Find worktrees that are safe to remove`,children:`Clean up`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:r,children:`New`})]})]}),(R.length>0||y)&&(0,H.jsx)(Uc,{selected:R,hidden:z,actions:s,onRun:E,onClear:()=>p(new Set),busy:y,sections:N.sections}),x&&(0,H.jsxs)(`p`,{className:`wd-bulk-outcome`,role:`status`,children:[x,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>S(null),children:`OK`})]}),de.length===0?(0,H.jsx)(`div`,{className:`wd-tab-empty`,children:t.length===0?'No worktrees yet. Run `work tree <target> <branch>` in any terminal, or click "New worktree" above.':`No sessions match the current filter.`}):fe?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:fe.map(e=>(0,H.jsxs)(`section`,{className:`wd-session-group`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:e.title??`Not in a section`}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]})]}),he(e.sessions)]},e.key))}):pe?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:pe.map((e,t,n)=>{let r=e=>e.key===`older`&&!L&&I.trim()===``;return r(e)?(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-session-older`,onClick:()=>re(!0),children:[`Show `,e.sessions.length,` older`]},e.key):(0,H.jsxs)(`section`,{className:`wd-session-group wd-session-age wd-session-age-${e.key}`,children:[n.filter(e=>!r(e)).length>1&&(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:$e[e.key]}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]}),e.key===`older`&&I.trim()===``&&(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button wd-session-age-toggle`,onClick:()=>re(!1),children:`Hide`})]}),he(e.sessions)]},e.key)})}):B?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:B.map(e=>(0,H.jsxs)(`section`,{className:`wd-session-group`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:e.key}),e.isGroup&&(0,H.jsx)(`span`,{className:`wd-session-group-kind`,title:`Multi-repo group`,children:`group`}),e.repos.length>0&&(0,H.jsx)(`ul`,{className:`wd-session-group-repos`,"aria-label":`Repos in this group`,children:e.repos.map(e=>(0,H.jsx)(`li`,{children:e},e))}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]})]}),he(e.sessions)]},e.key))}):(0,H.jsx)(`div`,{className:`wd-session-table-wrap`,children:he(de)}),(0,H.jsx)(tl,{query:I,onOpen:e=>n(e,`diff`)}),h&&(0,H.jsx)(Qa,{x:h.x,y:h.y,items:v(h.s),onClose:()=>g(null)})]})}function tl({query:e,onOpen:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let t=e.trim();if(t.length<2){r([]);return}let n=!0,i=setTimeout(()=>{ye(t).then(e=>n&&r(e),()=>n&&r([]))},300);return()=>{n=!1,clearTimeout(i)}},[e]),n.length===0?null:(0,H.jsxs)(`section`,{className:`wd-session-group wd-archive-hits`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-title`,children:[`In conversations (`,n.length,`)`]}),(0,H.jsx)(`ul`,{className:`wd-archive-hit-list`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`wd-archive-hit`,children:[(0,H.jsxs)(`div`,{className:`wd-archive-hit-head`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(e.sessionId),children:[e.target,` · `,e.branch]}),(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:e.archived&&e.archivedAt?` archived ${J(e.archivedAt)}${e.worktreeRemoved?` · folder removed`:``}`:e.lastAt?` ${J(e.lastAt)}`:``}),e.archived&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-action`,disabled:i!==null,title:e.worktreeRemoved?`Recreate its worktree from the branch and continue the conversation`:`Bring it back`,onClick:()=>{a(e.sessionId),T(e.sessionId,!1).finally(()=>a(null))},children:i===e.sessionId?`Restoring…`:`Restore`})]}),e.snippets.map((e,t)=>(0,H.jsxs)(`p`,{className:`wd-archive-hit-snippet`,children:[(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[e.role===`you`?`You`:e.role===`summary`?`Summary`:`Claude`,`:`]}),` `,e.text]},t))]},e.sessionId))})]})}function nl({children:e}){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!t)return;let e=e=>e.key===`Escape`&&n(!1),i=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,i)}},[t]),(0,H.jsxs)(`div`,{className:`wd-view-menu`,ref:r,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,"aria-expanded":t,"aria-haspopup":`true`,onClick:()=>n(e=>!e),children:`View ▾`}),t&&(0,H.jsx)(`div`,{className:`wd-view-menu-panel`,role:`group`,"aria-label":`View`,children:e})]})}function rl(e){let t=e.context;if(!t||t.window<=0)return null;let n=Math.min(1,t.used/t.window);return n>=.7?`${Math.round(n*100)}% full`:null}function il({session:e,onOpen:t,onMenu:n,selecting:r,picked:i,onPick:a,railTag:o}){let s=Ye(e),c=pt(e),l=qc(e),u=S(e.id),d=rl(e),f=e.titleIsYours&&!!e.title;return(0,H.jsxs)(`tr`,{className:`wd-session-row`+(c?` wd-session-row-archived`:``)+(s===`needs_input`||s===`done`?` wd-session-row-unseen`:``),onClick:t,onContextMenu:e=>{e.preventDefault(),n(e.clientX,e.clientY)},tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[r&&(0,H.jsx)(`td`,{className:`wd-st-col-pick`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),"aria-label":`Select ${e.target} ${e.branch}`})}),(0,H.jsx)(`td`,{className:`wd-st-col-status`,children:(0,H.jsxs)(`span`,{className:`wd-st-status`,title:rt(s),children:[(0,H.jsx)(Dt,{kind:s,muted:!!e.snoozed}),(0,H.jsx)(`span`,{className:`wd-st-label`,children:Xe[s]})]})}),(0,H.jsxs)(`td`,{className:`wd-st-session`,children:[(0,H.jsx)(`span`,{className:`wd-st-branch`,title:f?`${e.title} (${e.branch})`:e.branch,children:f?e.title:e.branch||`(base)`}),` `,(0,H.jsx)(`span`,{className:`wd-st-target`,children:e.target}),e.isGroup&&(0,H.jsx)(`span`,{className:`wd-session-group-kind wd-session-group-kind-hint`,title:l.length?`Multi-repo group: ${l.join(`, `)}`:`Multi-repo group`,children:`group`}),o&&(0,H.jsx)(`span`,{className:`wd-st-rail`+(o===`📌`?` wd-st-rail-pin`:``),title:o===`📌`?`Pinned in the rail`:`In the rail's “${o}” section`,children:o}),d&&(0,H.jsx)(`span`,{className:`wd-st-full`,title:`The conversation is ${d}: start fresh for the next task (work tree … --fresh, or /clear)`,children:d}),c&&(0,H.jsx)(`span`,{className:`wd-archived-pill`,title:e.archive?e.archive.worktreeRemoved?`Worktree removed; its branch and the conversation are kept${e.archive.savedUncommitted?`, and ${e.archive.savedUncommitted} uncommitted file${e.archive.savedUncommitted===1?``:`s`}`:``}. Restore recreates it${e.archive.savedUncommitted?` and puts them back`:``}.${e.archive.kept?` Also kept: ${e.archive.kept}.`:``}`:`Worktree kept: ${e.archive.keptBecause??`it has work in it`}${e.archive.kept?`. Also kept: ${e.archive.kept}.`:``}`:`Archived`,children:e.archive?.worktreeRemoved?`archived · folder removed${e.archive.savedUncommitted?` · ${e.archive.savedUncommitted} changes saved`:``}`:`archived`})]}),(0,H.jsx)(`td`,{className:`wd-st-col-summary`,children:(()=>{let t=e.attention?.summary??(c?e.archive?.written??e.archive?.lastSummary??e.archive?.prompts[0]:void 0)??``;return(0,H.jsx)(`span`,{className:`wd-st-summary`,title:t,children:t})})()}),(0,H.jsxs)(`td`,{className:`wd-st-col-changes`,children:[(0,H.jsx)(tc,{session:e}),e.overlaps?.length?(0,H.jsx)(`span`,{className:`wd-st-overlap`,title:rc(e),"aria-label":`Changes the same files as another session`,children:`⚠`}):null]}),(0,H.jsx)(`td`,{className:`wd-st-col-when`,children:u===void 0?J(Je(e)):u?`archiving…`:`restoring…`}),(0,H.jsx)(`td`,{className:`wd-st-col-more`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(`button`,{type:`button`,className:`wd-st-more`,"aria-label":`Actions for ${e.target} ${e.branch}`,title:`Archive, snooze, open in a terminal, delete…`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();n(t.left,t.bottom+4)},children:`⋯`})})]})}function al(e){return e.isDraft?{text:`Draft`,tone:`muted`}:e.conflicting?{text:`Merge conflict`,tone:`bad`}:e.checksStatus===`FAILURE`?{text:`Checks failing`,tone:`bad`}:e.reviewDecision===`CHANGES_REQUESTED`?{text:`Changes requested`,tone:`bad`}:e.reviewDecision===`APPROVED`?{text:`Approved`,tone:`good`}:e.checksStatus===`PENDING`?{text:`Checks running`,tone:`muted`}:e.reviewDecision===`REVIEW_REQUIRED`?{text:`Review needed`,tone:`muted`}:{text:`Open`,tone:`muted`}}function ol(e,t,n){return t.find(t=>!pt(t)&&yt(t,[e],n).length>0)}function sl(e){return!e.isMine&&!!e.reviewRequested&&e.myReview===`NONE`}function cl({sessions:e,onNewWorktree:t,onPickPr:n,onOpenSession:r,onManageRepos:i,prs:a,prsNote:o=null,membersOf:s}){let c=(a??[]).filter(e=>e.isMine),l=(a??[]).filter(sl),u=e=>e?(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-start-existing`,onClick:()=>r(e.id),title:`Open the session on it`,children:[e.titleIsYours&&e.title?e.title:e.branch,` →`]}):null;return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-start`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsx)(`h1`,{children:`Start work`}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[i&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:i,children:`Repos & groups`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:t,children:`New worktree`})]})]}),(0,H.jsxs)(`section`,{className:`wd-start-section`,"aria-label":`Your pull requests`,children:[(0,H.jsx)(`h2`,{className:`wd-start-title`,children:`Your pull requests · GitHub`}),o&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:o}),!o&&a===null&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:`Loading…`}),!o&&a!==null&&c.length===0&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:`No open pull requests of yours.`}),(0,H.jsx)(ll,{prs:c,sessions:e,onPick:n,existing:u,membersOf:s})]}),l.length>0&&(0,H.jsxs)(`section`,{className:`wd-start-section`,"aria-label":`Waiting for your review`,children:[(0,H.jsx)(`h2`,{className:`wd-start-title`,children:`Waiting for your review · GitHub`}),(0,H.jsx)(ll,{prs:l,sessions:e,onPick:n,existing:u,membersOf:s})]})]})}function ll({prs:e,sessions:t,onPick:n,existing:r,membersOf:i}){return(0,H.jsx)(`ul`,{className:`wd-start-list`,children:e.map(e=>{let a=al(e);return(0,H.jsxs)(`li`,{className:`wd-start-row`,children:[(0,H.jsxs)(`a`,{className:`wd-start-key wd-start-key-pr`,href:e.url,target:`_blank`,rel:`noreferrer`,title:`Open on GitHub`,children:[`#`,e.number]}),(0,H.jsxs)(`span`,{className:`wd-start-what`,title:e.title,children:[e.title,` `,(0,H.jsx)(`span`,{className:`wd-start-repo`,children:e.repoAlias})]}),(0,H.jsx)(`span`,{className:`wd-start-state wd-start-state-${a.tone}`,children:a.text}),(0,H.jsx)(`span`,{className:`wd-start-action`,children:r(ol(e,t,i))??(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>n(e),title:e.isMine?`Continue on it in a worktree`:`Have Claude review it in a worktree (it changes nothing, posts nothing)`,children:e.isMine?`Start`:`Review`})})]},`${e.repoAlias}#${e.number}`)})})}function ul(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)||`task`}function dl({onPick:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null);function d(){nn().then(e=>n(e.tasks),()=>{})}(0,_.useEffect)(d,[]),Xa(`/events`,{events:{"tasks-changed":d}});async function f(e){e.preventDefault();let t=a.trim();if(t)try{let e=await rn(t);n(e.tasks),o(``)}catch{}}async function p(e){try{let t=await an(e.id,{done:!e.done});n(t.tasks)}catch{}}async function m(e,t){let r=t.trim();if(r&&r!==e.text)try{let t=await an(e.id,{text:r});n(t.tasks)}catch{}}async function h(e){try{let t=await on(e);n(t.tasks)}catch{}}let g=(0,_.useMemo)(()=>r?t:t.filter(e=>!e.done),[t,r]),v=(0,_.useMemo)(()=>{let e=t.filter(e=>!e.done).length;return{open:e,done:t.length-e}},[t]);return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-tasks`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsxs)(`h1`,{children:[`Tasks`,` `,(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,v.open,` open · `,v.done,` done)`]})]}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),` show done`]}),(0,H.jsxs)(`form`,{className:`wd-task-add`,onSubmit:f,children:[(0,H.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`+ Add task…`}),(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!a.trim(),children:`Add`})]})]})]}),g.length===0?(0,H.jsx)(`div`,{className:`wd-tab-empty`,children:t.length===0?"No tasks yet. Add one above, or `work todo add <text>` from a terminal.":`No open tasks — toggle "show done" to see completed ones.`}):(0,H.jsx)(`ul`,{className:`wd-task-list`,children:g.map(t=>(0,H.jsxs)(`li`,{className:`wd-task-row`+(t.done?` wd-task-row-done`:``),onContextMenu:e=>{e.preventDefault(),u({id:t.id,x:e.clientX,y:e.clientY})},children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t.done,onChange:()=>p(t),"aria-label":t.done?`Mark not done`:`Mark done`}),(0,H.jsx)(fl,{task:t,editing:s===t.id,onEdit:()=>c(t.id),onDone:()=>c(null),onSave:e=>m(t,e)}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-task-action`,onClick:()=>e(t),title:`Create worktree (todo/<slug>)`,children:`→ worktree`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-task-action wd-task-remove`,onClick:()=>h(t.id),title:`Delete task`,"aria-label":`Delete task`,children:`×`})]},t.id))}),l&&(0,H.jsx)(Qa,{x:l.x,y:l.y,onClose:()=>u(null),items:[{label:`Edit`,hint:`F2`,run:()=>c(l.id)}]})]})}function fl({task:e,editing:t,onEdit:n,onDone:r,onSave:i}){let[a,o]=(0,_.useState)(e.text);if((0,_.useEffect)(()=>{t&&o(e.text)},[t,e.text]),t){let e=e=>{r(),e&&i(a)};return(0,H.jsx)(`input`,{className:`wd-task-edit`,"aria-label":`Task text`,value:a,autoFocus:!0,onChange:e=>o(e.target.value),onBlur:()=>e(!0),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e(!0)):t.key===`Escape`&&(t.preventDefault(),e(!1))}})}let s=n;return(0,H.jsx)(`span`,{className:`wd-task-text`,role:`button`,tabIndex:0,onClick:s,onKeyDown:e=>{(e.key===`F2`||e.key===`Enter`)&&(e.preventDefault(),s())},title:`Click to edit`,children:e.text})}function pl({open:e,onOpenChange:t,onPick:n}){let r=(0,_.useRef)(null),i=(0,_.useRef)(t);return i.current=t,(0,_.useEffect)(()=>{if(!e)return;let t=()=>i.current(!1),n=e=>{e.key===`Escape`&&!document.querySelector(`.wd-row-menu`)&&!e.target.closest?.(`input`)&&t()},a=e=>{let n=e.target;r.current?.contains(n)||n.closest?.(`.wd-row-menu`)||t()};return window.addEventListener(`keydown`,n),window.addEventListener(`mousedown`,a),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`mousedown`,a)}},[e]),(0,H.jsxs)(`div`,{className:`wd-tasks-popover`,ref:r,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-topnav-btn`+(e?` wd-topnav-btn-on`:``),"aria-expanded":e,"aria-haspopup":`dialog`,title:`Your tasks (g t)`,onClick:()=>t(!e),children:`Tasks`}),e&&(0,H.jsx)(`div`,{className:`wd-tasks-panel`,role:`dialog`,"aria-label":`Tasks`,"data-popover":!0,children:(0,H.jsx)(dl,{onPick:e=>{t(!1),n(e)}})})]})}function ml({value:e,onChange:t}){return(0,H.jsx)(`span`,{className:`wd-segmented`,role:`group`,"aria-label":`Sessions view`,children:[`now`,`today`].map(n=>(0,H.jsx)(`button`,{type:`button`,className:`wd-segmented-btn`+(e===n?` wd-segmented-btn-on`:``),"aria-pressed":e===n,title:n===`now`?`Every session as it stands (g s)`:`What each session did today (g d)`,onClick:()=>t(n),children:n===`now`?`Now`:`Today`},n))})}var hl={created:`✦`,prompt:`›`,turn:`✓`,commit:`●`,"pr-opened":`⇡`,"pr-merged":`⇣`,"pr-closed":`✕`,archived:`▣`},gl={created:`Started`,prompt:`You`,turn:`Turn`,commit:`Commit`,"pr-opened":`PR`,"pr-merged":`Merged`,"pr-closed":`Closed`,archived:`Archived`};function _l(e){let t=[];for(let n of e){let e=new Date(n.at).toLocaleDateString([],{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`}),r=t[t.length-1];r?.day===e?r.events.push(n):t.push({day:e,events:[n]})}return t}function vl({session:e,onOpenTurn:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let t=!0;return r(null),a(null),Ce(e.id).then(e=>t&&r(e),e=>t&&a(e.message)),()=>{t=!1}},[e.id,e.lastActivity]),i?(0,H.jsx)(`div`,{className:`wd-tab-empty wd-tab-error`,children:i}):n?(0,H.jsx)(`div`,{className:`wd-timeline`,children:_l(n).map(n=>(0,H.jsxs)(`section`,{className:`wd-timeline-day`,children:[(0,H.jsx)(`h3`,{className:`wd-timeline-day-title`,children:n.day}),(0,H.jsx)(`ol`,{className:`wd-timeline-list`,children:n.events.map((n,r)=>(0,H.jsxs)(`li`,{className:`wd-timeline-event wd-timeline-${n.kind}`,children:[(0,H.jsx)(`span`,{className:`wd-timeline-time`,children:new Date(n.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),(0,H.jsx)(`span`,{className:`wd-timeline-icon`,"aria-hidden":!0,children:hl[n.kind]}),(0,H.jsx)(`span`,{className:`wd-timeline-kind`,children:gl[n.kind]}),(0,H.jsxs)(`span`,{className:`wd-timeline-text`,children:[n.kind===`turn`&&n.checkpoint&&t?(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(n.checkpoint),title:`Open what this turn changed`,children:n.text}):n.ref?.startsWith(`https://`)?(0,H.jsx)(`a`,{href:n.ref,target:`_blank`,rel:`noreferrer`,children:n.text}):n.text,n.repo&&e.isGroup&&(0,H.jsxs)(`span`,{className:`wd-timeline-repo`,children:[` · `,n.repo]}),n.kind===`commit`&&n.ref&&(0,H.jsx)(`code`,{className:`wd-timeline-sha`,children:n.ref.slice(0,7)})]})]},`${n.at}-${n.kind}-${r}`))})]},n.day))}):(0,H.jsxs)(`div`,{className:`wd-tab-empty`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-spinner`,"aria-hidden":!0}),` Reading its history…`]})}function yl(e){let t=/^https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/.exec(e.trim());return t?{url:`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`,label:`${t[2]}#${t[3]}`}:null}function bl({session:e,onOpen:t}){let[n,r]=(0,_.useState)(null),i=e.blockedBy??[];if(i.length===0)return null;let a=t=>{r(null),Te(e.id,t).catch(e=>r(e.message))};return(0,H.jsxs)(`span`,{className:`wd-blocked`,title:`Out of the Inbox until these are done (merged, closed or archived); its Claude is told then`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⛔`}),` Waiting on`,` `,i.map((e,n)=>(0,H.jsxs)(`span`,{className:`wd-blocked-item`,children:[n>0&&`, `,e.kind===`session`&&t&&e.sessionId?(0,H.jsx)(`button`,{type:`button`,className:`wd-overlap-link`,onClick:()=>t(e.sessionId),children:e.label}):e.url?(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`wd-overlap-link`,children:e.label}):(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`button`,{type:`button`,className:`wd-blocked-drop`,onClick:()=>a(e.key),"aria-label":`Stop waiting on ${e.label}`,title:`Stop waiting on it`,children:`×`})]},e.key)),n&&(0,H.jsxs)(`span`,{className:`wd-tab-error`,children:[` ⚠ `,n]})]})}function xl({session:e,sessions:t,onDone:n,onClose:r}){let i=t.filter(t=>t.id!==e.id&&!t.archivedAt&&!(e.blockedBy??[]).some(e=>e.sessionId===t.id)),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>p.current?.focus(),[]);let m=s.trim()?yl(s):null,h=!!a||!!m,g=async()=>{if(h&&!l){u(!0),f(null);try{a&&await we(e.id,{kind:`session`,id:a}),m&&await we(e.id,{kind:`pr`,url:m.url}),n([a?t.find(e=>e.id===a)?.branch:null,m?.label].filter(Boolean).join(` and `))}catch(e){f(e.message),u(!1)}}};return(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":`Blocked by`,onClick:e=>e.target===e.currentTarget&&!l&&r(),children:(0,H.jsxs)(`form`,{className:`wd-modal`,onSubmit:e=>{e.preventDefault(),g()},onKeyDown:e=>e.key===`Escape`&&!l&&r(),children:[(0,H.jsxs)(`header`,{className:`wd-modal-header`,children:[(0,H.jsxs)(`h2`,{children:[e.title&&e.titleIsYours?e.title:e.branch,` is waiting on…`]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-modal-close`,onClick:r,"aria-label":`Close`,disabled:l,children:`×`})]}),(0,H.jsxs)(`div`,{className:`wd-modal-body`,children:[(0,H.jsx)(`p`,{className:`wd-fork-note`,children:`It leaves the Inbox until that is done — the session archived (merged), the PR merged or closed — and then you and its Claude are told. A question from its Claude still shows.`}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Another session`}),(0,H.jsxs)(`select`,{ref:p,value:a,onChange:e=>o(e.target.value),disabled:l,children:[(0,H.jsx)(`option`,{value:``,children:`—`}),i.map(e=>(0,H.jsxs)(`option`,{value:e.id,children:[e.target,` · `,e.title&&e.titleIsYours?`${e.title} (${e.branch})`:e.branch]},e.id))]})]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`…or a pull request`}),(0,H.jsx)(`input`,{type:`url`,value:s,onChange:e=>c(e.target.value),placeholder:`https://github.com/org/repo/pull/12`,disabled:l})]}),s.trim()&&!m&&(0,H.jsx)(`p`,{className:`wd-modal-error`,children:`Not a GitHub pull request URL.`}),d&&(0,H.jsx)(`p`,{className:`wd-modal-error`,role:`alert`,children:d})]}),(0,H.jsxs)(`footer`,{className:`wd-modal-footer`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:r,disabled:l,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!h||l,children:l?`Saving…`:`Wait on it`})]})]})})}var Sl=700;function Cl({session:e,open:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,className:`wd-notes-chip`+(t?` wd-notes-chip-open`:``),"aria-expanded":t,onClick:n,title:e.hasNote?`Your notes on this session`:`Notes: yours, not part of the conversation`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`📝`}),` Notes`,e.hasNote?` •`:``]})}function wl({session:e,onClose:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(`idle`),o=(0,_.useRef)(null),s=(0,_.useRef)(``);(0,_.useEffect)(()=>{let t=!0;return r(null),Ee(e.id).then(e=>t&&r(e?.text??``),e=>t&&(r(``),a({error:e.message}))),()=>{t=!1}},[e.id]),(0,_.useEffect)(()=>()=>{o.current&&(clearTimeout(o.current),De(e.id,s.current).catch(()=>{}))},[e.id]);let c=t=>{a(`saving`),De(e.id,t).then(()=>a(`saved`),e=>a({error:e.message}))},l=e=>{r(e),s.current=e,a(`saving`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,c(e)},Sl)},u=()=>{n?.trim()&&(a(`saving`),pe(e.id,`A note from me on this session:\n\n${n.trim()}`).then(()=>a(`sent`),e=>a({error:e.message})))},d=typeof i==`object`?`⚠ ${i.error}`:i===`saving`?`Saving…`:i===`saved`?`Saved`:i===`sent`?`Sent to its Claude`:``;return(0,H.jsxs)(`section`,{className:`wd-notes`,"aria-label":`Your notes on this session`,children:[(0,H.jsx)(`textarea`,{className:`wd-notes-text`,value:n??``,disabled:n===null,placeholder:n===null?`Loading…`:`Your notes: what you decided, what to tell the reviewer, what is next. Saved as you type; only yours until you send them.`,onChange:e=>l(e.target.value),rows:5,"aria-label":`Notes`}),(0,H.jsxs)(`div`,{className:`wd-notes-bar`,children:[(0,H.jsx)(`span`,{className:`wd-notes-status`+(typeof i==`object`?` wd-tab-error`:``),role:`status`,children:d}),(0,H.jsx)(`button`,{type:`button`,className:`wd-session-detail-btn`,onClick:u,disabled:!n?.trim(),title:`Hand the notes to its Claude as a message`,children:`Send to Claude`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:t,children:`Close`})]})]})}var Tl=6e4;function El(e,t){let n=t.byDay[0];return n?{text:`${e.jiraKey?`${e.jiraKey} `:``}${Io(n.ms)} — ${e.title||e.branch}`,day:n.day}:null}function Dl(e,t){if(e===Lo(t))return`Today`;if(e===Lo(t-864e5))return`Yesterday`;let[n,r,i]=e.split(`-`).map(Number);return new Date(n,r-1,i).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})}function Ol({session:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(0),c=e.lastActivity;if((0,_.useEffect)(()=>{let t=Date.now();if(a.current?.id===e.id&&t-a.current.at<Tl){let e=setTimeout(()=>s(e=>e+1),Tl-(t-a.current.at));return()=>clearTimeout(e)}a.current?.id!==e.id&&n(null),a.current={id:e.id,at:t};let r=!0;return Oe(e.id).then(e=>r&&n(e),()=>{}),()=>{r=!1}},[e.id,c,o]),!t||t.workedMs<6e4)return null;let l=Date.now(),u=El(e,t),d=t.byDay.slice(0,7).map(e=>`${Dl(e.day,l)} ${Fo(e.ms)}`).join(` · `),f=e=>{i(e),setTimeout(()=>i(null),2e3)};return(0,H.jsxs)(`span`,{className:`wd-work-time-wrap`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-work-time`,onClick:()=>{u&&Promise.resolve().then(()=>navigator.clipboard.writeText(u.text)).then(()=>f(`ok`),()=>f(`failed`))},disabled:!u,title:`Its Claude worked about ${Fo(t.workedMs)} over ${t.prompts} prompt${t.prompts===1?``:`s`} (the time between its steps, at most 15 minutes each — your reading and typing time is not counted).`+(d?`\n${d}`:``)+(u?`\nClick to copy ${Dl(u.day,l)===`Today`?`today's`:`${Dl(u.day,l)}'s`} worklog: ${u.text}`:`
|
|
91
|
+
Click for what work does in the background, and what it decided`,onClick:()=>a(e=>!e),children:(0,H.jsx)(`span`,{className:`wd-activity-dot`+(u.length?` wd-activity-dot-busy`:``),"aria-hidden":!0})}),i&&(0,H.jsxs)(`div`,{className:`wd-activity-panel`,role:`dialog`,"data-popover":!0,"aria-label":`Background activity`,children:[(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Now`}),u.length===0?(0,H.jsx)(`p`,{className:`wd-activity-empty`,children:`Nothing running.`}):u.map(t=>(0,H.jsx)(zc,{run:t,onOpenSession:e},t.id))]}),(n?.schedules.length??0)>0&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Coming up`}),(0,H.jsx)(`ul`,{className:`wd-activity-list`,children:n.schedules.map(e=>(0,H.jsx)(Ic,{s:e,now:o},e.kind))})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`wd-legend-title`,children:`Recent`}),(n?.recent.length??0)===0?(0,H.jsx)(`p`,{className:`wd-activity-empty`,children:`Nothing yet.`}):jc(n.recent).map(t=>(0,H.jsx)(zc,{run:t,onOpenSession:e},t.id))]})]})]})}function Ic({s:e,now:t}){let n=e.pausedUntil&&Date.parse(e.pausedUntil)>t;return(0,H.jsxs)(`li`,{className:`wd-activity-schedule`,children:[(0,H.jsx)(`span`,{className:`wd-activity-name`,children:e.label}),` `,(0,H.jsx)(`span`,{className:`wd-activity-muted`,children:n?(0,H.jsxs)(`span`,{className:`wd-activity-warn`,children:[`resting until `,Nc(e.pausedUntil),`: `,e.pausedWhy]}):(0,H.jsxs)(H.Fragment,{children:[Pc(e.everyMs),e.nextAt?` · next ${Mc(e.nextAt,t)}`:``]})})]})}var Lc={running:``,done:`✓`,failed:`✗`,skipped:`⏸`},Rc=4;function zc({run:e,onOpenSession:t}){let[n,r]=(0,_.useState)(!1),i=n?e.notes:e.notes.slice(0,Rc);return(0,H.jsxs)(`div`,{className:`wd-activity-run wd-activity-run-${e.status}`,children:[(0,H.jsxs)(`div`,{className:`wd-activity-head`,children:[e.status===`running`?(0,H.jsx)(`span`,{className:`wd-activity-spinner`,"aria-hidden":!0}):(0,H.jsx)(`span`,{className:`wd-activity-mark`,children:Lc[e.status]}),(0,H.jsx)(`span`,{className:`wd-activity-name`,children:e.label}),e.status===`running`&&e.progress&&e.progress.total>0&&(0,H.jsx)(`progress`,{className:`wd-activity-progress`,max:e.progress.total,value:e.progress.done,"aria-label":`${e.progress.done} of ${e.progress.total}`}),(0,H.jsxs)(`span`,{className:`wd-activity-muted wd-activity-when`,children:[e.status===`running`?`started ${J(e.startedAt)}`:J(e.endedAt??e.startedAt),e.repeats?` · ×${e.repeats+1}`:``]})]}),e.summary&&(0,H.jsx)(`div`,{className:`wd-activity-summary`,children:e.summary}),i.length>0&&(0,H.jsxs)(`ul`,{className:`wd-activity-notes`,children:[i.map((e,n)=>(0,H.jsx)(`li`,{className:`wd-activity-note wd-activity-note-${e.level}`,children:e.sessionId?(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(e.sessionId),title:`Open this session`,children:e.text}):e.text},n)),e.notes.length>Rc&&(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button wd-activity-more`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`Show all ${e.notes.length}`})})]})]})}var Bc=`2.0.1`;function Vc(e){let t=e?.available;if(t)return t.how===`restart`?`${t.version} is ready to install`:t.how===`downloading`?`downloading ${t.version}`:`${t.version} is out`;let n=e?.desktop;return n?.state===`failed`?`couldn't update: ${n.error??`unknown`}`:null}function Hc({updates:e,onCheck:t,checking:n,note:r,onWhatsNew:i,onShortcuts:a,onRestart:o}){let[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!s)return;let e=e=>e.key===`Escape`&&c(!1),t=e=>{l.current&&!l.current.contains(e.target)&&c(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,t)}},[s]);let u=e?.running??`2.0.1`,d=Vc(e),f=e?.available?.how===`restart`&&!!o,p=e=>()=>{c(!1),e?.()};return(0,H.jsxs)(`div`,{className:`wd-help`,ref:l,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-help-btn`+(e?.available?` wd-help-btn-update`:``),"aria-expanded":s,"aria-label":`Help: work v${u}${d?`, ${d}`:``}`,title:`work v${u}${d?` · ${d}`:``}\nHelp: updates, what's new, keyboard shortcuts`,onClick:()=>c(e=>!e),children:[`v`,u]}),s&&(0,H.jsxs)(`div`,{className:`wd-help-panel`,role:`dialog`,"data-popover":!0,"aria-label":`Help`,children:[(0,H.jsxs)(`p`,{className:`wd-help-version`,children:[`work v`,u,d&&(0,H.jsxs)(`span`,{className:`wd-help-status`,children:[` · `,d]})]}),f&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item wd-help-restart`,onClick:p(o),children:`Restart to update`}),t&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item`,disabled:n,onClick:t,children:n?`Checking…`:`Check for updates`}),r&&(0,H.jsx)(`p`,{className:`wd-help-note`,children:r}),i&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-menu-item`,onClick:p(i),children:`What's new`}),a&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-row-menu-item`,onClick:p(a),children:[`Keyboard shortcuts `,(0,H.jsx)(`kbd`,{children:`?`})]})]})]})}function Uc({selected:e,hidden:t=0,actions:n,onRun:r,onClear:i,busy:a,sections:o=[]}){let[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.filter(e=>!e.archivedAt),y=e.filter(e=>!!e.archivedAt);return(0,H.jsxs)(`div`,{className:`wd-bulk-bar`,role:`toolbar`,"aria-label":`Act on the ticked sessions`,children:[(0,H.jsxs)(`span`,{className:`wd-bulk-count`,children:[e.length,` selected`]}),t>0&&(0,H.jsxs)(`span`,{className:`wd-bulk-hidden`,title:`Ticked, but hidden by the filter or search: the bar leaves them out`,children:[`(+`,t,` hidden, not included)`]}),a?(0,H.jsx)(`span`,{className:`wd-bulk-busy`,children:a}):s===`send`?(0,H.jsxs)(`form`,{className:`wd-bulk-send`,onSubmit:e=>{e.preventDefault(),l.trim()&&(r(`Sent to`,e=>n.send(e,l.trim()),v),u(``),c(null))},children:[(0,H.jsx)(`textarea`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`What to tell ${v.length===1?`its Claude`:`their ${v.length} Claudes`} (delivered like a review comment: now in a terminal the dashboard owns, else on its next turn)`,rows:2,"aria-label":`Prompt to send`}),(0,H.jsxs)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!l.trim()||v.length===0,children:[`Send to `,v.length]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(null),children:`Cancel`})]}):s===`delete`?(0,H.jsxs)(`span`,{className:`wd-bulk-confirm`,role:`alert`,children:[`Delete `,e.length,` session`,e.length===1?``:`s`,`? A worktree goes only where nothing would be lost; the others are refused and listed.`,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-danger`,onClick:()=>{c(null),r(`Deleted`,e=>n.remove(e),e)},children:`Delete`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(null),children:`Cancel`})]}):(0,H.jsxs)(H.Fragment,{children:[v.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>r(`Archived`,e=>n.archive(e),v),children:[`Archive `,v.length]}),y.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>r(`Restored`,e=>n.restore(e),y),children:[`Restore `,y.length]}),v.length>0&&(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();f({x:t.left,y:t.bottom+2})},children:[`Snooze `,v.length,` ▾`]}),v.length>0&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>c(`send`),children:`Send a prompt…`}),v.length>0&&n.place&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();g({x:t.left,y:t.bottom+2})},title:`Pin them, or put them under one of the rail's sections`,children:`Rail ▾`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-bulk-delete`,onClick:()=>c(`delete`),children:`Delete…`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:i,children:`Clear`})]}),d&&(0,H.jsx)(Qa,{x:d.x,y:d.y,onClose:()=>f(null),items:[[`2 hours`,`2h`],[`Until tomorrow 9:00`,`tomorrow`],[`Until it changes`,`change`]].map(([e,t])=>({label:e,run:()=>r(`Snoozed`,e=>n.snooze(e,t),v)})).concat([{label:`Until…`,run:()=>m(!0)}])}),h&&n.place&&(0,H.jsx)(Qa,{x:h.x,y:h.y,onClose:()=>g(null),items:[{label:`Pin ${v.length}`,run:()=>r(`Pinned`,e=>n.place(e,{pinned:!0}),v)},{label:`Unpin ${v.length}`,run:()=>r(`Unpinned`,e=>n.place(e,{pinned:!1}),v)},...o.map((e,t)=>({label:`Move to “${e.name}”`,run:()=>r(`Moved to “${e.name}”`,t=>n.place(t,{pinned:!1,section:e.id}),v),...t===0?{separated:!0}:{}})),...o.length?[{label:`Out of their section`,run:()=>r(`Took out of their section`,e=>n.place(e,{section:null}),v)}]:[]]}),p&&(0,H.jsx)(Ao,{count:v.length,onClose:()=>m(!1),onPick:e=>{m(!1),r(`Snoozed`,t=>n.snooze(t,{until:e}),v)}})]})}async function Wc(e,t,n={}){let r=Array(e.length),i=0,a=0;return await Promise.all(Array.from({length:Math.min(n.concurrency??3,e.length)},async()=>{for(let o=i++;o<e.length;o=i++){try{await t(e[o]),r[o]={id:e[o],ok:!0}}catch(t){r[o]={id:e[o],ok:!1,error:t.message}}n.onProgress?.(++a,e.length)}})),r}function Gc(e,t,n){let r=t.filter(e=>e.ok).length,i=t.filter(e=>!e.ok);if(i.length===0)return`${e} ${r}.`;let a=i.slice(0,3).map(e=>`${n(e.id)} — ${e.error??`refused`}`).join(`; `);return`${e} ${r}; ${i.length} refused: ${a}${i.length>3?` (and ${i.length-3} more)`:``}`}function Kc(e,t=!1){let n=new Map;for(let t of e){let e=n.get(t.target);e||(e={key:t.target,isGroup:t.isGroup,repos:[],sessions:[]},n.set(t.target,e)),e.sessions.push(t);for(let n of qc(t))e.repos.includes(n)||e.repos.push(n)}let r=[...n.values()];return t&&r.sort((e,t)=>e.key.toLowerCase().localeCompare(t.key.toLowerCase())),r}function qc(e){return!e.isGroup||e.paths.length<2?[]:e.paths.map(e=>{let t=e.split(/[\\/]+/).filter(Boolean);return t[t.length-1]??e})}var Jc={archive:e=>T(e.id,!0,()=>!1),restore:e=>T(e.id,!1,()=>!1),snooze:(e,t)=>B(e,t),send:(e,t)=>pe(e.id,t),remove:e=>cn(e.id,{}),place:(e,t)=>Pe(e.id,t)},Yc=`work-web:sessions-grouping`,Xc=`work-web:sessions-show-archived`;function Zc(e,t){try{return localStorage.getItem(e)===t}catch{return!1}}function Qc(e,t){try{localStorage.setItem(e,t)}catch{}}var $c={all:`all`,needs:`needs you`,working:`working`,idle:`idle`,stale:`stale`};function el({layout:e,sessions:t,onOpenSession:n,onNewWorktree:r,onDeleteSession:i,menuFor:a,onCleanUp:o,bulk:s=Jc,viewToggle:c,onShowArchived:l}){let[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(()=>new Set),m=e=>{d(e),e||p(new Set)},[h,g]=(0,_.useState)(null),v=e=>a?a(e):[pt(e)?{label:`Restore`,run:()=>void T(e.id,!1).catch(()=>{})}:{label:`Archive`,run:()=>void T(e.id,!0).catch(()=>{})},{label:`Delete…`,run:()=>i(e),danger:!0,separated:!0}],[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),C=(e,t)=>p(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),w=t.filter(e=>f.has(e.id)),E=(e,t,n)=>{let r=new Map(n.map(e=>[e.id,e]));S(null),b(`${e} 0/${n.length}…`),Wc([...r.keys()],e=>t(r.get(e)),{onProgress:(t,n)=>b(`${e} ${t}/${n}…`)}).then(t=>{b(null),S(Gc(e,t,e=>r.get(e)?.branch??e)),p(new Set(t.filter(e=>!e.ok).map(e=>e.id)))})},[D,O]=(0,_.useState)(`recent`),[k,A]=(0,_.useState)(`all`),[j,M]=(0,_.useState)(`any`),N=e??ot,P=(0,_.useMemo)(()=>{let e=new Map;for(let n of st(t.filter(e=>!pt(e)),N))for(let t of n.sessions)e.set(t.id,n);return e},[t,N]),F=(0,_.useCallback)(e=>{if(j===`any`)return!0;let t=P.get(e.id);return j===`pinned`?t?.key===`pinned`:j===`none`?!t||t.key===`rest`:t?.key===j},[j,P]),[I,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(()=>{try{let e=localStorage.getItem(Yc);return e===`project`||e===`none`||e===`section`?e:`age`}catch{return`age`}}),[L,re]=(0,_.useState)(!1),[ie,ae]=(0,_.useState)(()=>Zc(Xc,`1`)),oe=e=>{ne(e),Qc(Yc,e)},se=e=>{ae(e),Qc(Xc,e?`1`:`0`)};(0,_.useEffect)(()=>(l?.(ie),()=>l?.(!1)),[ie]);let ce=(0,_.useMemo)(()=>t.filter(e=>!pt(e)),[t]),le=t.length-ce.length,ue=(0,_.useMemo)(()=>{let e={now:0,week:0,older:0};for(let t of ce)e[et(t)]++;return e},[ce]),de=(0,_.useMemo)(()=>[...(ie?t:ce).filter(e=>(k===`all`||tt(Ye(e))===k)&&F(e)&&vt(e,I))].sort((e,t)=>{if(D===`name`){let n=(e.branch||e.target).toLowerCase(),r=(t.branch||t.target).toLowerCase();return n.localeCompare(r)}return Je(t).localeCompare(Je(e))}),[t,ce,ie,D,k,I,F]),R=de.filter(e=>f.has(e.id)),z=w.length-R.length;(0,_.useEffect)(()=>{let e=new Set(t.map(e=>e.id));p(t=>[...t].every(t=>e.has(t))?t:new Set([...t].filter(t=>e.has(t))))},[t]);let B=(0,_.useMemo)(()=>te===`project`?Kc(de,D===`name`):null,[de,te,D]),fe=(0,_.useMemo)(()=>{if(te!==`section`)return null;let e=st(de.filter(e=>!pt(e)),N).filter(e=>e.sessions.length>0),t=de.filter(e=>pt(e));return t.length?[...e,{key:`archived`,title:`Archived`,sessions:t}]:e},[de,te,N]),pe=(0,_.useMemo)(()=>{if(te!==`age`)return null;let e={now:[],week:[],older:[]};for(let t of de)e[et(t)].push(t);return Object.keys(e).map(t=>({key:t,sessions:e[t]})).filter(e=>e.sessions.length>0)},[de,te]),me=e=>{let t=P.get(e.id);return t?.key===`pinned`?`📌`:t?.sectionId?t.title:null},he=e=>(0,H.jsxs)(`table`,{className:`wd-session-table`+(u?` wd-session-table-selecting`:``),children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[u&&(0,H.jsx)(`th`,{className:`wd-st-col-pick`,children:(0,H.jsx)(`input`,{type:`checkbox`,"aria-label":`Select all shown`,checked:e.length>0&&e.every(e=>f.has(e.id)),onChange:t=>{let n=t.target.checked;p(t=>{let r=new Set(t);for(let t of e)n?r.add(t.id):r.delete(t.id);return r})}})}),(0,H.jsx)(`th`,{className:`wd-st-col-status`,children:`Status`}),(0,H.jsx)(`th`,{children:`Session`}),(0,H.jsx)(`th`,{className:`wd-st-col-summary`,children:`Summary`}),(0,H.jsx)(`th`,{className:`wd-st-col-changes`,children:`Changes`}),(0,H.jsx)(`th`,{className:`wd-st-col-when`,children:`Active`}),(0,H.jsx)(`th`,{className:`wd-st-col-more`,children:(0,H.jsx)(`span`,{className:`wd-visually-hidden`,children:`Actions`})})]})}),(0,H.jsx)(`tbody`,{children:e.map(e=>(0,H.jsx)(il,{session:e,onOpen:()=>n(e.id,ut(e)),onMenu:(t,n)=>g({s:e,x:t,y:n}),selecting:u,picked:f.has(e.id),onPick:t=>C(e.id,t),railTag:me(e)},e.id))})]});return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-sessions`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsxs)(`h1`,{children:[`Sessions `,c,` `,(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:[ue.now?`${ue.now} now`:``,ue.week?`${ue.week} this week`:``,ue.older?`${ue.older} older`:``].filter(Boolean).join(` · `)})]}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[(0,H.jsx)(`input`,{className:`wd-tab-search`,type:`search`,placeholder:`Search branch, repo, words…`,"aria-label":`Search sessions`,value:I,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Escape`&&ee(``)}}),(0,H.jsxs)(nl,{children:[(0,H.jsxs)(`label`,{children:[`Show`,(0,H.jsx)(`select`,{value:k,onChange:e=>A(e.target.value),"aria-label":`Status filter`,children:Object.keys($c).map(e=>(0,H.jsx)(`option`,{value:e,children:$c[e]},e))})]}),(N.sections.length>0||Object.keys(N.places).length>0)&&(0,H.jsxs)(`label`,{children:[`Rail`,(0,H.jsxs)(`select`,{value:j,onChange:e=>M(e.target.value),"aria-label":`Rail filter`,children:[(0,H.jsx)(`option`,{value:`any`,children:`any`}),(0,H.jsx)(`option`,{value:`pinned`,children:`pinned`}),N.sections.map(e=>(0,H.jsx)(`option`,{value:`section:${e.id}`,children:e.name},e.id)),(0,H.jsx)(`option`,{value:`none`,children:`in no section`})]})]}),(0,H.jsxs)(`label`,{children:[`Group`,(0,H.jsxs)(`select`,{value:te,onChange:e=>oe(e.target.value),"aria-label":`Group by`,children:[(0,H.jsx)(`option`,{value:`age`,children:`age`}),(0,H.jsx)(`option`,{value:`project`,children:`project`}),(0,H.jsx)(`option`,{value:`section`,children:`rail section`}),(0,H.jsx)(`option`,{value:`none`,children:`none`})]})]}),(0,H.jsxs)(`label`,{children:[`Sort`,(0,H.jsxs)(`select`,{value:D,onChange:e=>O(e.target.value),"aria-label":`Sort by`,children:[(0,H.jsx)(`option`,{value:`recent`,children:`recent`}),(0,H.jsx)(`option`,{value:`name`,children:`name`})]})]}),(0,H.jsxs)(`label`,{className:`wd-tab-check`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:ie,onChange:e=>se(e.target.checked)}),` Show archived`,le>0?` (${le})`:``]}),(0,H.jsxs)(`label`,{className:`wd-tab-check`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>m(e.target.checked)}),` Select several`]})]}),o&&(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:o,title:`Find worktrees that are safe to remove`,children:`Clean up`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:r,children:`New`})]})]}),(R.length>0||y)&&(0,H.jsx)(Uc,{selected:R,hidden:z,actions:s,onRun:E,onClear:()=>p(new Set),busy:y,sections:N.sections}),x&&(0,H.jsxs)(`p`,{className:`wd-bulk-outcome`,role:`status`,children:[x,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>S(null),children:`OK`})]}),de.length===0?(0,H.jsx)(`div`,{className:`wd-tab-empty`,children:t.length===0?'No worktrees yet. Run `work tree <target> <branch>` in any terminal, or click "New worktree" above.':`No sessions match the current filter.`}):fe?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:fe.map(e=>(0,H.jsxs)(`section`,{className:`wd-session-group`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:e.title??`Not in a section`}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]})]}),he(e.sessions)]},e.key))}):pe?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:pe.map((e,t,n)=>{let r=e=>e.key===`older`&&!L&&I.trim()===``;return r(e)?(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-session-older`,onClick:()=>re(!0),children:[`Show `,e.sessions.length,` older`]},e.key):(0,H.jsxs)(`section`,{className:`wd-session-group wd-session-age wd-session-age-${e.key}`,children:[n.filter(e=>!r(e)).length>1&&(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:$e[e.key]}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]}),e.key===`older`&&I.trim()===``&&(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button wd-session-age-toggle`,onClick:()=>re(!1),children:`Hide`})]}),he(e.sessions)]},e.key)})}):B?(0,H.jsx)(`div`,{className:`wd-session-groups`,children:B.map(e=>(0,H.jsxs)(`section`,{className:`wd-session-group`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-header`,children:[(0,H.jsx)(`span`,{className:`wd-session-group-name`,children:e.key}),e.isGroup&&(0,H.jsx)(`span`,{className:`wd-session-group-kind`,title:`Multi-repo group`,children:`group`}),e.repos.length>0&&(0,H.jsx)(`ul`,{className:`wd-session-group-repos`,"aria-label":`Repos in this group`,children:e.repos.map(e=>(0,H.jsx)(`li`,{children:e},e))}),(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,e.sessions.length,`)`]})]}),he(e.sessions)]},e.key))}):(0,H.jsx)(`div`,{className:`wd-session-table-wrap`,children:he(de)}),(0,H.jsx)(tl,{query:I,onOpen:e=>n(e,`diff`)}),h&&(0,H.jsx)(Qa,{x:h.x,y:h.y,items:v(h.s),onClose:()=>g(null)})]})}function tl({query:e,onOpen:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let t=e.trim();if(t.length<2){r([]);return}let n=!0,i=setTimeout(()=>{ye(t).then(e=>n&&r(e),()=>n&&r([]))},300);return()=>{n=!1,clearTimeout(i)}},[e]),n.length===0?null:(0,H.jsxs)(`section`,{className:`wd-session-group wd-archive-hits`,children:[(0,H.jsxs)(`h2`,{className:`wd-session-group-title`,children:[`In conversations (`,n.length,`)`]}),(0,H.jsx)(`ul`,{className:`wd-archive-hit-list`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`wd-archive-hit`,children:[(0,H.jsxs)(`div`,{className:`wd-archive-hit-head`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(e.sessionId),children:[e.target,` · `,e.branch]}),(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:e.archived&&e.archivedAt?` archived ${J(e.archivedAt)}${e.worktreeRemoved?` · folder removed`:``}`:e.lastAt?` ${J(e.lastAt)}`:``}),e.archived&&(0,H.jsx)(`button`,{type:`button`,className:`wd-row-action`,disabled:i!==null,title:e.worktreeRemoved?`Recreate its worktree from the branch and continue the conversation`:`Bring it back`,onClick:()=>{a(e.sessionId),T(e.sessionId,!1).finally(()=>a(null))},children:i===e.sessionId?`Restoring…`:`Restore`})]}),e.snippets.map((e,t)=>(0,H.jsxs)(`p`,{className:`wd-archive-hit-snippet`,children:[(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[e.role===`you`?`You`:e.role===`summary`?`Summary`:`Claude`,`:`]}),` `,e.text]},t))]},e.sessionId))})]})}function nl({children:e}){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!t)return;let e=e=>e.key===`Escape`&&n(!1),i=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,i)}},[t]),(0,H.jsxs)(`div`,{className:`wd-view-menu`,ref:r,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,"aria-expanded":t,"aria-haspopup":`true`,onClick:()=>n(e=>!e),children:`View ▾`}),t&&(0,H.jsx)(`div`,{className:`wd-view-menu-panel`,role:`group`,"aria-label":`View`,children:e})]})}function rl(e){let t=e.context;if(!t||t.window<=0)return null;let n=Math.min(1,t.used/t.window);return n>=.7?`${Math.round(n*100)}% full`:null}function il({session:e,onOpen:t,onMenu:n,selecting:r,picked:i,onPick:a,railTag:o}){let s=Ye(e),c=pt(e),l=qc(e),u=S(e.id),d=rl(e),f=e.titleIsYours&&!!e.title;return(0,H.jsxs)(`tr`,{className:`wd-session-row`+(c?` wd-session-row-archived`:``)+(s===`needs_input`||s===`done`?` wd-session-row-unseen`:``),onClick:t,onContextMenu:e=>{e.preventDefault(),n(e.clientX,e.clientY)},tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[r&&(0,H.jsx)(`td`,{className:`wd-st-col-pick`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),"aria-label":`Select ${e.target} ${e.branch}`})}),(0,H.jsx)(`td`,{className:`wd-st-col-status`,children:(0,H.jsxs)(`span`,{className:`wd-st-status`,title:rt(s),children:[(0,H.jsx)(Dt,{kind:s,muted:!!e.snoozed}),(0,H.jsx)(`span`,{className:`wd-st-label`,children:Xe[s]})]})}),(0,H.jsxs)(`td`,{className:`wd-st-session`,children:[(0,H.jsx)(`span`,{className:`wd-st-branch`,title:f?`${e.title} (${e.branch})`:e.branch,children:f?e.title:e.branch||`(base)`}),` `,(0,H.jsx)(`span`,{className:`wd-st-target`,children:e.target}),e.isGroup&&(0,H.jsx)(`span`,{className:`wd-session-group-kind wd-session-group-kind-hint`,title:l.length?`Multi-repo group: ${l.join(`, `)}`:`Multi-repo group`,children:`group`}),o&&(0,H.jsx)(`span`,{className:`wd-st-rail`+(o===`📌`?` wd-st-rail-pin`:``),title:o===`📌`?`Pinned in the rail`:`In the rail's “${o}” section`,children:o}),d&&(0,H.jsx)(`span`,{className:`wd-st-full`,title:`The conversation is ${d}: start fresh for the next task (work tree … --fresh, or /clear)`,children:d}),c&&(0,H.jsx)(`span`,{className:`wd-archived-pill`,title:e.archive?e.archive.worktreeRemoved?`Worktree removed; its branch and the conversation are kept${e.archive.savedUncommitted?`, and ${e.archive.savedUncommitted} uncommitted file${e.archive.savedUncommitted===1?``:`s`}`:``}. Restore recreates it${e.archive.savedUncommitted?` and puts them back`:``}.${e.archive.kept?` Also kept: ${e.archive.kept}.`:``}`:`Worktree kept: ${e.archive.keptBecause??`it has work in it`}${e.archive.kept?`. Also kept: ${e.archive.kept}.`:``}`:`Archived`,children:e.archive?.worktreeRemoved?`archived · folder removed${e.archive.savedUncommitted?` · ${e.archive.savedUncommitted} changes saved`:``}`:`archived`})]}),(0,H.jsx)(`td`,{className:`wd-st-col-summary`,children:(()=>{let t=e.attention?.summary??(c?e.archive?.written??e.archive?.lastSummary??e.archive?.prompts[0]:void 0)??``;return(0,H.jsx)(`span`,{className:`wd-st-summary`,title:t,children:t})})()}),(0,H.jsxs)(`td`,{className:`wd-st-col-changes`,children:[(0,H.jsx)(tc,{session:e}),e.overlaps?.length?(0,H.jsx)(`span`,{className:`wd-st-overlap`,title:rc(e),"aria-label":`Changes the same files as another session`,children:`⚠`}):null]}),(0,H.jsx)(`td`,{className:`wd-st-col-when`,children:u===void 0?J(Je(e)):u?`archiving…`:`restoring…`}),(0,H.jsx)(`td`,{className:`wd-st-col-more`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(`button`,{type:`button`,className:`wd-st-more`,"aria-label":`Actions for ${e.target} ${e.branch}`,title:`Archive, snooze, open in a terminal, delete…`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();n(t.left,t.bottom+4)},children:`⋯`})})]})}function al(e){return e.isDraft?{text:`Draft`,tone:`muted`}:e.conflicting?{text:`Merge conflict`,tone:`bad`}:e.checksStatus===`FAILURE`?{text:`Checks failing`,tone:`bad`}:e.reviewDecision===`CHANGES_REQUESTED`?{text:`Changes requested`,tone:`bad`}:e.reviewDecision===`APPROVED`?{text:`Approved`,tone:`good`}:e.checksStatus===`PENDING`?{text:`Checks running`,tone:`muted`}:e.reviewDecision===`REVIEW_REQUIRED`?{text:`Review needed`,tone:`muted`}:{text:`Open`,tone:`muted`}}function ol(e,t,n){return t.find(t=>!pt(t)&&yt(t,[e],n).length>0)}function sl(e){return!e.isMine&&!!e.reviewRequested&&e.myReview===`NONE`}function cl({sessions:e,onNewWorktree:t,onPickPr:n,onOpenSession:r,onManageRepos:i,prs:a,prsNote:o=null,membersOf:s}){let c=(a??[]).filter(e=>e.isMine),l=(a??[]).filter(sl),u=e=>e?(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-start-existing`,onClick:()=>r(e.id),title:`Open the session on it`,children:[e.titleIsYours&&e.title?e.title:e.branch,` →`]}):null;return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-start`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsx)(`h1`,{children:`Start work`}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[i&&(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:i,children:`Repos & groups`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:t,children:`New worktree`})]})]}),(0,H.jsxs)(`section`,{className:`wd-start-section`,"aria-label":`Your pull requests`,children:[(0,H.jsx)(`h2`,{className:`wd-start-title`,children:`Your pull requests · GitHub`}),o&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:o}),!o&&a===null&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:`Loading…`}),!o&&a!==null&&c.length===0&&(0,H.jsx)(`p`,{className:`wd-start-note`,children:`No open pull requests of yours.`}),(0,H.jsx)(ll,{prs:c,sessions:e,onPick:n,existing:u,membersOf:s})]}),l.length>0&&(0,H.jsxs)(`section`,{className:`wd-start-section`,"aria-label":`Waiting for your review`,children:[(0,H.jsx)(`h2`,{className:`wd-start-title`,children:`Waiting for your review · GitHub`}),(0,H.jsx)(ll,{prs:l,sessions:e,onPick:n,existing:u,membersOf:s})]})]})}function ll({prs:e,sessions:t,onPick:n,existing:r,membersOf:i}){return(0,H.jsx)(`ul`,{className:`wd-start-list`,children:e.map(e=>{let a=al(e);return(0,H.jsxs)(`li`,{className:`wd-start-row`,children:[(0,H.jsxs)(`a`,{className:`wd-start-key wd-start-key-pr`,href:e.url,target:`_blank`,rel:`noreferrer`,title:`Open on GitHub`,children:[`#`,e.number]}),(0,H.jsxs)(`span`,{className:`wd-start-what`,title:e.title,children:[e.title,` `,(0,H.jsx)(`span`,{className:`wd-start-repo`,children:e.repoAlias})]}),(0,H.jsx)(`span`,{className:`wd-start-state wd-start-state-${a.tone}`,children:a.text}),(0,H.jsx)(`span`,{className:`wd-start-action`,children:r(ol(e,t,i))??(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>n(e),title:e.isMine?`Continue on it in a worktree`:`Have Claude review it in a worktree (it changes nothing, posts nothing)`,children:e.isMine?`Start`:`Review`})})]},`${e.repoAlias}#${e.number}`)})})}function ul(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)||`task`}function dl({onPick:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null);function d(){nn().then(e=>n(e.tasks),()=>{})}(0,_.useEffect)(d,[]),Xa(`/events`,{events:{"tasks-changed":d}});async function f(e){e.preventDefault();let t=a.trim();if(t)try{let e=await rn(t);n(e.tasks),o(``)}catch{}}async function p(e){try{let t=await an(e.id,{done:!e.done});n(t.tasks)}catch{}}async function m(e,t){let r=t.trim();if(r&&r!==e.text)try{let t=await an(e.id,{text:r});n(t.tasks)}catch{}}async function h(e){try{let t=await on(e);n(t.tasks)}catch{}}let g=(0,_.useMemo)(()=>r?t:t.filter(e=>!e.done),[t,r]),v=(0,_.useMemo)(()=>{let e=t.filter(e=>!e.done).length;return{open:e,done:t.length-e}},[t]);return(0,H.jsxs)(`div`,{className:`wd-dash-tab-pane wd-tab-tasks`,children:[(0,H.jsxs)(`header`,{className:`wd-tab-header`,children:[(0,H.jsxs)(`h1`,{children:[`Tasks`,` `,(0,H.jsxs)(`span`,{className:`wd-tab-header-muted`,children:[`(`,v.open,` open · `,v.done,` done)`]})]}),(0,H.jsxs)(`div`,{className:`wd-tab-controls`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),` show done`]}),(0,H.jsxs)(`form`,{className:`wd-task-add`,onSubmit:f,children:[(0,H.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`+ Add task…`}),(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!a.trim(),children:`Add`})]})]})]}),g.length===0?(0,H.jsx)(`div`,{className:`wd-tab-empty`,children:t.length===0?"No tasks yet. Add one above, or `work todo add <text>` from a terminal.":`No open tasks — toggle "show done" to see completed ones.`}):(0,H.jsx)(`ul`,{className:`wd-task-list`,children:g.map(t=>(0,H.jsxs)(`li`,{className:`wd-task-row`+(t.done?` wd-task-row-done`:``),onContextMenu:e=>{e.preventDefault(),u({id:t.id,x:e.clientX,y:e.clientY})},children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t.done,onChange:()=>p(t),"aria-label":t.done?`Mark not done`:`Mark done`}),(0,H.jsx)(fl,{task:t,editing:s===t.id,onEdit:()=>c(t.id),onDone:()=>c(null),onSave:e=>m(t,e)}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-task-action`,onClick:()=>e(t),title:`Create worktree (todo/<slug>)`,children:`→ worktree`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-task-action wd-task-remove`,onClick:()=>h(t.id),title:`Delete task`,"aria-label":`Delete task`,children:`×`})]},t.id))}),l&&(0,H.jsx)(Qa,{x:l.x,y:l.y,onClose:()=>u(null),items:[{label:`Edit`,hint:`F2`,run:()=>c(l.id)}]})]})}function fl({task:e,editing:t,onEdit:n,onDone:r,onSave:i}){let[a,o]=(0,_.useState)(e.text);if((0,_.useEffect)(()=>{t&&o(e.text)},[t,e.text]),t){let e=e=>{r(),e&&i(a)};return(0,H.jsx)(`input`,{className:`wd-task-edit`,"aria-label":`Task text`,value:a,autoFocus:!0,onChange:e=>o(e.target.value),onBlur:()=>e(!0),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e(!0)):t.key===`Escape`&&(t.preventDefault(),e(!1))}})}let s=n;return(0,H.jsx)(`span`,{className:`wd-task-text`,role:`button`,tabIndex:0,onClick:s,onKeyDown:e=>{(e.key===`F2`||e.key===`Enter`)&&(e.preventDefault(),s())},title:`Click to edit`,children:e.text})}function pl({open:e,onOpenChange:t,onPick:n}){let r=(0,_.useRef)(null),i=(0,_.useRef)(t);return i.current=t,(0,_.useEffect)(()=>{if(!e)return;let t=()=>i.current(!1),n=e=>{e.key===`Escape`&&!document.querySelector(`.wd-row-menu`)&&!e.target.closest?.(`input`)&&t()},a=e=>{let n=e.target;r.current?.contains(n)||n.closest?.(`.wd-row-menu`)||t()};return window.addEventListener(`keydown`,n),window.addEventListener(`mousedown`,a),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`mousedown`,a)}},[e]),(0,H.jsxs)(`div`,{className:`wd-tasks-popover`,ref:r,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-topnav-btn`+(e?` wd-topnav-btn-on`:``),"aria-expanded":e,"aria-haspopup":`dialog`,title:`Your tasks (g t)`,onClick:()=>t(!e),children:`Tasks`}),e&&(0,H.jsx)(`div`,{className:`wd-tasks-panel`,role:`dialog`,"aria-label":`Tasks`,"data-popover":!0,children:(0,H.jsx)(dl,{onPick:e=>{t(!1),n(e)}})})]})}function ml({value:e,onChange:t}){return(0,H.jsx)(`span`,{className:`wd-segmented`,role:`group`,"aria-label":`Sessions view`,children:[`now`,`today`].map(n=>(0,H.jsx)(`button`,{type:`button`,className:`wd-segmented-btn`+(e===n?` wd-segmented-btn-on`:``),"aria-pressed":e===n,title:n===`now`?`Every session as it stands (g s)`:`What each session did today (g d)`,onClick:()=>t(n),children:n===`now`?`Now`:`Today`},n))})}var hl={created:`✦`,prompt:`›`,turn:`✓`,commit:`●`,"pr-opened":`⇡`,"pr-merged":`⇣`,"pr-closed":`✕`,archived:`▣`},gl={created:`Started`,prompt:`You`,turn:`Turn`,commit:`Commit`,"pr-opened":`PR`,"pr-merged":`Merged`,"pr-closed":`Closed`,archived:`Archived`};function _l(e){let t=[];for(let n of e){let e=new Date(n.at).toLocaleDateString([],{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`}),r=t[t.length-1];r?.day===e?r.events.push(n):t.push({day:e,events:[n]})}return t}function vl({session:e,onOpenTurn:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let t=!0;return r(null),a(null),Ce(e.id).then(e=>t&&r(e),e=>t&&a(e.message)),()=>{t=!1}},[e.id,e.lastActivity]),i?(0,H.jsx)(`div`,{className:`wd-tab-empty wd-tab-error`,children:i}):n?(0,H.jsx)(`div`,{className:`wd-timeline`,children:_l(n).map(n=>(0,H.jsxs)(`section`,{className:`wd-timeline-day`,children:[(0,H.jsx)(`h3`,{className:`wd-timeline-day-title`,children:n.day}),(0,H.jsx)(`ol`,{className:`wd-timeline-list`,children:n.events.map((n,r)=>(0,H.jsxs)(`li`,{className:`wd-timeline-event wd-timeline-${n.kind}`,children:[(0,H.jsx)(`span`,{className:`wd-timeline-time`,children:new Date(n.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),(0,H.jsx)(`span`,{className:`wd-timeline-icon`,"aria-hidden":!0,children:hl[n.kind]}),(0,H.jsx)(`span`,{className:`wd-timeline-kind`,children:gl[n.kind]}),(0,H.jsxs)(`span`,{className:`wd-timeline-text`,children:[n.kind===`turn`&&n.checkpoint&&t?(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>t(n.checkpoint),title:`Open what this turn changed`,children:n.text}):n.ref?.startsWith(`https://`)?(0,H.jsx)(`a`,{href:n.ref,target:`_blank`,rel:`noreferrer`,children:n.text}):n.text,n.repo&&e.isGroup&&(0,H.jsxs)(`span`,{className:`wd-timeline-repo`,children:[` · `,n.repo]}),n.kind===`commit`&&n.ref&&(0,H.jsx)(`code`,{className:`wd-timeline-sha`,children:n.ref.slice(0,7)})]})]},`${n.at}-${n.kind}-${r}`))})]},n.day))}):(0,H.jsxs)(`div`,{className:`wd-tab-empty`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-spinner`,"aria-hidden":!0}),` Reading its history…`]})}function yl(e){let t=/^https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/.exec(e.trim());return t?{url:`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`,label:`${t[2]}#${t[3]}`}:null}function bl({session:e,onOpen:t}){let[n,r]=(0,_.useState)(null),i=e.blockedBy??[];if(i.length===0)return null;let a=t=>{r(null),Te(e.id,t).catch(e=>r(e.message))};return(0,H.jsxs)(`span`,{className:`wd-blocked`,title:`Out of the Inbox until these are done (merged, closed or archived); its Claude is told then`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⛔`}),` Waiting on`,` `,i.map((e,n)=>(0,H.jsxs)(`span`,{className:`wd-blocked-item`,children:[n>0&&`, `,e.kind===`session`&&t&&e.sessionId?(0,H.jsx)(`button`,{type:`button`,className:`wd-overlap-link`,onClick:()=>t(e.sessionId),children:e.label}):e.url?(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`wd-overlap-link`,children:e.label}):(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`button`,{type:`button`,className:`wd-blocked-drop`,onClick:()=>a(e.key),"aria-label":`Stop waiting on ${e.label}`,title:`Stop waiting on it`,children:`×`})]},e.key)),n&&(0,H.jsxs)(`span`,{className:`wd-tab-error`,children:[` ⚠ `,n]})]})}function xl({session:e,sessions:t,onDone:n,onClose:r}){let i=t.filter(t=>t.id!==e.id&&!t.archivedAt&&!(e.blockedBy??[]).some(e=>e.sessionId===t.id)),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>p.current?.focus(),[]);let m=s.trim()?yl(s):null,h=!!a||!!m,g=async()=>{if(h&&!l){u(!0),f(null);try{a&&await we(e.id,{kind:`session`,id:a}),m&&await we(e.id,{kind:`pr`,url:m.url}),n([a?t.find(e=>e.id===a)?.branch:null,m?.label].filter(Boolean).join(` and `))}catch(e){f(e.message),u(!1)}}};return(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":`Blocked by`,onClick:e=>e.target===e.currentTarget&&!l&&r(),children:(0,H.jsxs)(`form`,{className:`wd-modal`,onSubmit:e=>{e.preventDefault(),g()},onKeyDown:e=>e.key===`Escape`&&!l&&r(),children:[(0,H.jsxs)(`header`,{className:`wd-modal-header`,children:[(0,H.jsxs)(`h2`,{children:[e.title&&e.titleIsYours?e.title:e.branch,` is waiting on…`]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-modal-close`,onClick:r,"aria-label":`Close`,disabled:l,children:`×`})]}),(0,H.jsxs)(`div`,{className:`wd-modal-body`,children:[(0,H.jsx)(`p`,{className:`wd-fork-note`,children:`It leaves the Inbox until that is done — the session archived (merged), the PR merged or closed — and then you and its Claude are told. A question from its Claude still shows.`}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Another session`}),(0,H.jsxs)(`select`,{ref:p,value:a,onChange:e=>o(e.target.value),disabled:l,children:[(0,H.jsx)(`option`,{value:``,children:`—`}),i.map(e=>(0,H.jsxs)(`option`,{value:e.id,children:[e.target,` · `,e.title&&e.titleIsYours?`${e.title} (${e.branch})`:e.branch]},e.id))]})]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`…or a pull request`}),(0,H.jsx)(`input`,{type:`url`,value:s,onChange:e=>c(e.target.value),placeholder:`https://github.com/org/repo/pull/12`,disabled:l})]}),s.trim()&&!m&&(0,H.jsx)(`p`,{className:`wd-modal-error`,children:`Not a GitHub pull request URL.`}),d&&(0,H.jsx)(`p`,{className:`wd-modal-error`,role:`alert`,children:d})]}),(0,H.jsxs)(`footer`,{className:`wd-modal-footer`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:r,disabled:l,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:!h||l,children:l?`Saving…`:`Wait on it`})]})]})})}var Sl=700;function Cl({session:e,open:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,className:`wd-notes-chip`+(t?` wd-notes-chip-open`:``),"aria-expanded":t,onClick:n,title:e.hasNote?`Your notes on this session`:`Notes: yours, not part of the conversation`,children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`📝`}),` Notes`,e.hasNote?` •`:``]})}function wl({session:e,onClose:t}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(`idle`),o=(0,_.useRef)(null),s=(0,_.useRef)(``);(0,_.useEffect)(()=>{let t=!0;return r(null),Ee(e.id).then(e=>t&&r(e?.text??``),e=>t&&(r(``),a({error:e.message}))),()=>{t=!1}},[e.id]),(0,_.useEffect)(()=>()=>{o.current&&(clearTimeout(o.current),De(e.id,s.current).catch(()=>{}))},[e.id]);let c=t=>{a(`saving`),De(e.id,t).then(()=>a(`saved`),e=>a({error:e.message}))},l=e=>{r(e),s.current=e,a(`saving`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,c(e)},Sl)},u=()=>{n?.trim()&&(a(`saving`),pe(e.id,`A note from me on this session:\n\n${n.trim()}`).then(()=>a(`sent`),e=>a({error:e.message})))},d=typeof i==`object`?`⚠ ${i.error}`:i===`saving`?`Saving…`:i===`saved`?`Saved`:i===`sent`?`Sent to its Claude`:``;return(0,H.jsxs)(`section`,{className:`wd-notes`,"aria-label":`Your notes on this session`,children:[(0,H.jsx)(`textarea`,{className:`wd-notes-text`,value:n??``,disabled:n===null,placeholder:n===null?`Loading…`:`Your notes: what you decided, what to tell the reviewer, what is next. Saved as you type; only yours until you send them.`,onChange:e=>l(e.target.value),rows:5,"aria-label":`Notes`}),(0,H.jsxs)(`div`,{className:`wd-notes-bar`,children:[(0,H.jsx)(`span`,{className:`wd-notes-status`+(typeof i==`object`?` wd-tab-error`:``),role:`status`,children:d}),(0,H.jsx)(`button`,{type:`button`,className:`wd-session-detail-btn`,onClick:u,disabled:!n?.trim(),title:`Hand the notes to its Claude as a message`,children:`Send to Claude`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:t,children:`Close`})]})]})}var Tl=6e4;function El(e,t){let n=t.byDay[0];return n?{text:`${e.jiraKey?`${e.jiraKey} `:``}${Io(n.ms)} — ${e.title||e.branch}`,day:n.day}:null}function Dl(e,t){if(e===Lo(t))return`Today`;if(e===Lo(t-864e5))return`Yesterday`;let[n,r,i]=e.split(`-`).map(Number);return new Date(n,r-1,i).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})}function Ol({session:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(0),c=e.lastActivity;if((0,_.useEffect)(()=>{let t=Date.now();if(a.current?.id===e.id&&t-a.current.at<Tl){let e=setTimeout(()=>s(e=>e+1),Tl-(t-a.current.at));return()=>clearTimeout(e)}a.current?.id!==e.id&&n(null),a.current={id:e.id,at:t};let r=!0;return Oe(e.id).then(e=>r&&n(e),()=>{}),()=>{r=!1}},[e.id,c,o]),!t||t.workedMs<6e4)return null;let l=Date.now(),u=El(e,t),d=t.byDay.slice(0,7).map(e=>`${Dl(e.day,l)} ${Fo(e.ms)}`).join(` · `),f=e=>{i(e),setTimeout(()=>i(null),2e3)};return(0,H.jsxs)(`span`,{className:`wd-work-time-wrap`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-work-time`,onClick:()=>{u&&Promise.resolve().then(()=>navigator.clipboard.writeText(u.text)).then(()=>f(`ok`),()=>f(`failed`))},disabled:!u,title:`Its Claude worked about ${Fo(t.workedMs)} over ${t.prompts} prompt${t.prompts===1?``:`s`} (the time between its steps, at most 15 minutes each — your reading and typing time is not counted).`+(d?`\n${d}`:``)+(u?`\nClick to copy ${Dl(u.day,l)===`Today`?`today's`:`${Dl(u.day,l)}'s`} worklog: ${u.text}`:`
|
|
92
92
|
No work in the last two weeks to log.`),children:[(0,H.jsx)(`span`,{"aria-hidden":!0,children:`⏱`}),` `,r===`ok`?`Copied`:r===`failed`?`Couldn't copy`:Fo(t.workedMs)]}),u&&e.jiraKey&&(0,H.jsx)(kl,{sessionId:e.id,day:u.day,jiraKey:e.jiraKey})]})}function kl({sessionId:e,day:t,jiraKey:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let n=!0;return ke(e).then(e=>n&&i({configured:e.configured,logged:e.logged[t]??0}),()=>n&&i(null)),()=>{n=!1}},[e,t]),r?.configured?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-work-time-jira`,disabled:a,onClick:()=>{o(!0),c(null),Ae(e,t).then(e=>{o(!1),i({configured:!0,logged:e.total}),c({text:e.text})},e=>{o(!1),c({text:e.message,error:!0})})},title:`Write ${Dl(t,Date.now())===`Today`?`today's`:`${t}'s`} work to ${n} as a worklog${r.logged?` (${Io(r.logged*1e3)} logged already: only what was added since)`:``}`,children:a?`Logging…`:r.logged?`→ ${n} ✓`:`→ ${n}`}),s&&(0,H.jsx)(`span`,{className:`wd-work-time-result`+(s.error?` wd-tab-error`:``),role:`status`,children:s.text})]}):null}function Al(e){let[t,n]=(0,_.useState)({busy:!1,open:!1});return{state:t,run:(0,_.useCallback)(()=>{n(e=>({...e,busy:!0,error:void 0,open:!0})),V(e).then(e=>n({busy:!1,text:e.text,at:e.at,open:!0}),e=>n({busy:!1,error:e.message,open:!0}))},[e]),close:(0,_.useCallback)(()=>n(e=>({...e,open:!1})),[])}}function jl(e,t){return t-Date.parse(Je(e))>=1728e5?J(Je(e),t):null}function Ml({session:e,catchUp:t,now:n=Date.now()}){let r=jl(e,n);return!r||t.state.open?null:(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-catch-up-away`,onClick:t.run,disabled:t.state.busy,title:`A few sentences on where it stands, what's left, and whether anything waits on you (from its last week of conversation)`,children:[`Away `,r,` · Catch me up`]})}function Nl({catchUp:e,now:t=Date.now()}){let{state:n,run:r,close:i}=e;return n.open?(0,H.jsxs)(`div`,{className:`wd-catch-up`,role:`status`,"aria-live":`polite`,children:[n.busy&&!n.text?(0,H.jsx)(`p`,{className:`wd-catch-up-text wd-tab-header-muted`,children:`Reading its conversation…`}):n.error?(0,H.jsx)(`p`,{className:`wd-catch-up-text wd-tab-error`,children:n.error}):(0,H.jsx)(`p`,{className:`wd-catch-up-text`,children:n.text}),(0,H.jsxs)(`span`,{className:`wd-catch-up-meta`,children:[n.at&&`written ${J(n.at,t)}${J(n.at,t)===`just now`?``:` ago`} · `,(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:r,disabled:n.busy,children:`Refresh`}),` · `,(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:i,children:`Close`})]})]}):null}function Pl(e){let t=e instanceof Error?e.message:String(e);try{let e=JSON.parse(t);if(typeof e.error==`string`)return e.error}catch{}return t}var Fl={push:`Pushing…`,"create-pr":`Creating PR…`,merge:`Merging…`};function Il(e){return!e.done&&e.pr?.state===`OPEN`&&e.mergeBlockers.length===0}function Ll(e){let t=e.repos.filter(e=>!e.done),n=t.filter(e=>e.dirtyFiles>0),r=t.filter(e=>e.commitsVsBase!==0||e.pr),i=r.filter(e=>!e.hasUpstream||(e.ahead??0)>0||!e.tracksRemote),a=r.filter(e=>!e.pr||e.pr.state!==`OPEN`),o=t.filter(Il),s=n.length===0;return{dirty:n,active:t,mergeable:o,canPush:s&&i.length>0,canCreatePr:s&&a.length>0&&r.every(e=>!e.ghError),allDone:e.repos.length>0&&t.length===0}}function Rl({session:e,onClose:t,onMerged:n}){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!0),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(`squash`),[b,x]=(0,_.useState)(!1),[S,T]=(0,_.useState)(new Set),E=(0,_.useRef)(null),D=(0,_.useCallback)(()=>{c(!0),o(null),C(e.id).then(e=>{i(e),T(new Set(e.repos.filter(Il).map(e=>e.name))),x(!1),c(!1)},e=>{o(Pl(e)),c(!1)})},[e.id]);(0,_.useEffect)(D,[D]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!l&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l,t]),(0,_.useEffect)(()=>E.current?.focus(),[]);let O=r?Ll(r):null,k=O?O.mergeable.filter(e=>S.has(e.name)):[],A=!!O&&k.length>0&&k.length===O.active.length,j=t=>{u(t),m(null),f(null);let r=t===`merge`?{action:t,method:v,repos:k.map(e=>({name:e.name,headSha:e.pr.headSha}))}:{action:t,...t===`create-pr`?{draft:h}:{}};w(e.id,r).then(e=>{if(u(null),x(!1),f(e.results),e.archived){n();return}D()},e=>{u(null),x(!1),m(Pl(e))})},M=e=>{x(!1),T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},N=l!==null||s,P=(r?.repos.length??0)>1;return(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,onClick:e=>{e.target===e.currentTarget&&!l&&t()},children:(0,H.jsxs)(`div`,{className:`wd-modal wd-ship-panel`,role:`dialog`,"aria-label":`Ship session`,"aria-busy":s||l!==null,children:[(0,H.jsxs)(`div`,{className:`wd-modal-header`,children:[(0,H.jsxs)(`h2`,{children:[`Ship `,e.target,` · `,e.branch]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-modal-close`,onClick:t,disabled:!!l,"aria-label":`Close`,children:`×`})]}),(0,H.jsxs)(`div`,{className:`wd-modal-body`+(l||s?` wd-ship-dim`:``),children:[s&&!r&&(0,H.jsxs)(`p`,{className:`wd-ship-progress`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-spinner`,"aria-hidden":!0}),` Checking branch, upstream and PR…`]}),a&&(0,H.jsx)(`p`,{className:`wd-modal-error`,role:`alert`,children:a}),r?.repos.map(e=>(0,H.jsx)(zl,{repo:e,selectable:P&&Il(e),selected:S.has(e.name),onToggle:()=>M(e.name),disabled:N},e.path)),O?.allDone&&(0,H.jsx)(`p`,{className:`wd-ship-ok`,role:`status`,children:`Every repository is merged or untouched — nothing left to ship.`}),l&&(0,H.jsxs)(`p`,{className:`wd-ship-progress`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-spinner`,"aria-hidden":!0}),` `,Fl[l]]}),p&&(0,H.jsx)(`p`,{className:`wd-modal-error`,role:`alert`,children:p}),d&&(0,H.jsx)(`ul`,{className:`wd-ship-results`,children:d.map(e=>(0,H.jsxs)(`li`,{className:e.ok?`wd-ship-ok`:`wd-ship-fail`,children:[e.ok?`✓`:`✗`,` `,(0,H.jsx)(`strong`,{children:e.repo}),` — `,e.message,e.url&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:`open`})]})]},e.repo))}),O?.dirty.length?(0,H.jsxs)(`p`,{className:`wd-modal-error`,role:`alert`,children:[`Uncommitted changes in `,O.dirty.map(e=>e.name).join(`, `),` — commit or stash first.`]}):null,b&&k.length>0&&(0,H.jsxs)(`div`,{className:`wd-ship-confirm`,role:`alertdialog`,"aria-label":`Confirm merge`,children:[(0,H.jsxs)(`p`,{children:[`Merge `,k.map(e=>`${e.name} #${e.pr.number} (${e.pr.headSha.slice(0,7)})`).join(`, `),` with`,` `,(0,H.jsx)(`strong`,{children:v}),`? This can’t be undone from here.`,` `,A?`Every repository is then done, so the session is archived.`:`${O.active.length-k.length} other repositor${O.active.length-k.length===1?`y stays`:`ies stay`} open — the session stays until everything is done.`]}),(0,H.jsxs)(`div`,{className:`wd-ship-confirm-actions`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>x(!1),disabled:N,children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-danger`,onClick:()=>j(`merge`),disabled:N,children:`Confirm merge`})]})]})]}),(0,H.jsxs)(`div`,{className:`wd-modal-footer wd-ship-footer`,children:[(0,H.jsx)(`button`,{type:`button`,ref:E,className:`wd-btn-secondary`,onClick:t,disabled:!!l,children:`Close`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:N||!O?.canPush,onClick:()=>j(`push`),title:`Publish the branch (git push, setting upstream if needed)`,children:`Push`}),(0,H.jsxs)(`span`,{className:`wd-ship-group`,children:[(0,H.jsxs)(`label`,{className:`wd-ship-inline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:N}),` draft`]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:N||!O?.canCreatePr,onClick:()=>j(`create-pr`),title:`Push if needed, then open a pull request`,children:`Create PR`})]}),(0,H.jsxs)(`span`,{className:`wd-ship-group`,children:[(0,H.jsxs)(`select`,{"aria-label":`Merge method`,value:v,onChange:e=>y(e.target.value),disabled:N||k.length===0,children:[(0,H.jsx)(`option`,{value:`squash`,children:`squash`}),(0,H.jsx)(`option`,{value:`merge`,children:`merge commit`}),(0,H.jsx)(`option`,{value:`rebase`,children:`rebase`})]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,disabled:N||k.length===0||b,onClick:()=>x(!0),title:P?`Merge the selected repositories — asks for confirmation`:`Merge the open PR — asks for confirmation`,children:P&&k.length>0?`Merge ${k.length}…`:`Merge…`})]})]})]})})}function zl({repo:e,selectable:t,selected:n,onToggle:r,disabled:i}){let a=e.hasUpstream?e.ahead||e.behind?[e.ahead?`${e.ahead} ahead`:``,e.behind?`${e.behind} behind`:``].filter(Boolean).join(`, `):`up to date`:`not pushed`;return(0,H.jsxs)(`section`,{className:`wd-ship-repo`+(e.done?` wd-ship-repo-done`:``),children:[(0,H.jsxs)(`header`,{children:[t&&(0,H.jsx)(`input`,{type:`checkbox`,checked:n,onChange:r,disabled:i,"aria-label":`Merge ${e.name}`}),` `,(0,H.jsx)(`strong`,{children:e.name}),` `,(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:e.branch}),e.done&&(0,H.jsxs)(`span`,{className:`wd-ship-done`,children:[` `,e.doneReason===`merged`?`✓ merged`:`— untouched, nothing to ship`]})]}),!e.done&&(0,H.jsxs)(`ul`,{className:`wd-ship-facts`,children:[(0,H.jsx)(`li`,{className:e.dirtyFiles>0?`wd-ship-bad`:``,children:e.dirtyFiles>0?`${e.dirtyFiles} uncommitted file${e.dirtyFiles===1?``:`s`}`:`working tree clean`}),(0,H.jsx)(`li`,{children:a}),(0,H.jsx)(`li`,{children:e.pr?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`a`,{href:e.pr.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.pr.number]}),` `,e.pr.state.toLowerCase(),e.pr.isDraft?` · draft`:``,` · checks `,e.pr.checks,` · `,e.pr.mergeStateStatus.toLowerCase()]}):`no PR yet`}),e.ghError&&(0,H.jsx)(`li`,{className:`wd-ship-bad`,children:e.ghError})]}),e.mergeBlockers.length>0&&(0,H.jsx)(`ul`,{className:`wd-ship-blockers`,"aria-label":`Why ${e.name} can't merge`,children:e.mergeBlockers.map(e=>(0,H.jsx)(`li`,{children:e},e))})]})}function Bl(e,t,n=[]){let r=new Set([t,...n]);return e.filter(e=>!e.repos||e.repos.some(e=>r.has(e)))}async function Vl(){let e=await fetch(`/api/prompts`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(`prompts: ${e.status}`);return e.json()}var Hl=pe;function Ul({session:e,loadPrompts:t=Vl,send:n=Hl,open:r,onOpenChange:i}){let a=i,[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=(0,_.useRef)(null);(0,_.useEffect)(()=>{r&&!o&&t().then(e=>s(e.prompts),()=>s([]))},[r,o,t]),(0,_.useEffect)(()=>{if(!r)return;let e=e=>{u.current&&!u.current.contains(e.target)&&a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r,a]),(0,_.useEffect)(()=>{l(null)},[e.id]);let d=e.isGroup?e.paths.map(e=>e.split(/[\\/]/).pop()??``):[],f=o?Bl(o,e.target,d):null,p=f?.length??0;(0,_.useEffect)(()=>{r&&p>0&&u.current?.querySelector(`.wd-prompts-item`)?.focus()},[r,p]);let m=t=>e.attention?.state===`working`?`"${t}" queued: Claude gets it when this turn ends`:e.ptyStatus===`running`?`"${t}" sent to Claude`:`"${t}" queued for its next turn (its Claude isn't running in the dashboard)`,h=t=>{a(!1),l({kind:`sending`,text:`Sending "${t.label}"…`});let r=e.id;n(r,t.prompt).then(()=>l({kind:`sent`,text:m(t.label)}),e=>l({kind:`error`,text:e instanceof Error?e.message:String(e)}))};return(0,H.jsxs)(`div`,{className:`wd-prompts`,ref:u,children:[r&&(0,H.jsx)(`ul`,{className:`wd-prompts-menu`,role:`menu`,children:f===null?(0,H.jsx)(`li`,{className:`wd-prompts-empty`,children:`Loading…`}):f.length===0?(0,H.jsx)(`li`,{className:`wd-prompts-empty`,children:`No prompts for this repo. Add some under "prompts" in ~/.work/config.json.`}):f.map(e=>(0,H.jsx)(`li`,{role:`none`,children:(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wd-prompts-item`,onClick:()=>h(e),title:e.prompt,children:e.label})},e.label))}),c&&(0,H.jsx)(`span`,{className:`wd-prompts-state wd-prompts-state-${c.kind}`,role:`status`,children:c.text})]})}var Wl=5e3;function Gl(e){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),s=(0,_.useCallback)(()=>{Ie(e).then(e=>n(t=>t&&JSON.stringify(t)===JSON.stringify(e)?t:e),()=>{})},[e]);return(0,_.useEffect)(()=>{n(null),o(null),s();let e=setInterval(s,Wl);return()=>clearInterval(e)},[s]),Xa(`/events`,{events:{"dev-changed":t=>{t?.sessionId===e&&s()}}}),{sessionId:e,state:t,busy:r,error:a,act:(0,_.useCallback)(t=>{i(t),o(null),Le(e,t).catch(e=>o(e.message)).finally(()=>{i(null),s()})},[e,s])}}function Kl({dev:e}){let{sessionId:t,state:n,busy:r,error:i,act:a}=e;if(!n||n.port===null)return null;let o=!!n.running||n.listening||r===`start`;if(!o&&!i)return null;let s=(!!n.running||r===`start`)&&!n.listening,c=`/api/sessions/${encodeURIComponent(t)}/dev/log`;return(0,H.jsxs)(`span`,{className:`wd-dev-chip`+(n.listening?` wd-dev-live`:``),children:[o&&(0,H.jsxs)(`span`,{className:`wd-dev-port`,title:n.listening?`Something is serving on port ${n.port} ($PORT)`:`Nothing is listening on port ${n.port} ($PORT)`,children:[(0,H.jsx)(`span`,{className:`wd-dev-dot`,"aria-hidden":`true`,children:n.listening?`●`:`○`}),` `,`:`,n.port]}),n.listening&&n.url&&(0,H.jsx)(`a`,{className:`wd-dev-preview`,href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:`Preview ↗`}),s&&(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:`starting…`}),n.running&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-dev-btn`,disabled:r!==null,onClick:()=>a(`stop`),title:`Stop the dev server`,children:r===`stop`?`Stopping…`:`■ Stop`}),(0,H.jsx)(`a`,{className:`wd-dev-log`,href:c,target:`_blank`,rel:`noopener noreferrer`,children:`Log`})]}),i&&(0,H.jsx)(`span`,{className:`wd-dev-error`,role:`alert`,children:i})]})}var ql=6e4,Jl=(e,t)=>`#${e.pr.number}${t?` ${e.name}`:``}`;function Yl(e,t){let n=(e?.repos??[]).filter(e=>e.pr?.state===`OPEN`&&e.pr.checks===`fail`);return n.length?`CI failing on ${n.map(e=>Jl(e,t)).join(`, `)}`:null}function Xl({sessionId:e,isGroup:t,onNeeds:n,hidden:r=!1}){let[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),f=(0,_.useCallback)(()=>{Re(e).then(a,()=>{})},[e]);(0,_.useEffect)(()=>{a(null),l(!1),d(null),f();let e=setInterval(f,ql);return()=>clearInterval(e)},[f]),Xa(`/events`,{events:{"ci-changed":t=>{t?.sessionId===e&&f()}}});let p=Yl(i,t);(0,_.useEffect)(()=>n?.(p),[p,n]);let m=(i?.repos??[]).filter(e=>e.pr?.state===`OPEN`),h=m.filter(e=>e.pr.checks===`fail`),g=m.filter(e=>e.pr.checks===`pending`),v=m.filter(e=>(e.openThreads??0)>0);if(!h.length&&!g.length&&!v.length)return null;let y=e=>Jl(e,t);return(0,H.jsxs)(`div`,{className:`wd-ci-strip`+(h.length?` wd-ci-fail`:` wd-ci-running`),role:`status`,hidden:r,children:[v.map(e=>(0,H.jsxs)(`span`,{className:`wd-ci-item`,title:`Unresolved review threads waiting on you or Claude — new ones are handed to Claude automatically`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`💬`}),` `,(0,H.jsxs)(`a`,{href:`${e.pr.url}/files`,target:`_blank`,rel:`noopener noreferrer`,children:[e.openThreads,` open review thread`,e.openThreads===1?``:`s`]}),` `,`on `,y(e)]},`rv-${e.name}`)),h.map(e=>(0,H.jsxs)(`span`,{className:`wd-ci-item`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`✗`}),` CI failing on`,` `,(0,H.jsx)(`a`,{href:e.pr.url,target:`_blank`,rel:`noopener noreferrer`,children:y(e)}),e.pr.failing?.length?`: `:``,e.pr.failing?.map((e,t)=>(0,H.jsxs)(`span`,{children:[t>0&&`, `,e.url?(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:e.name}):e.name]},e.name+t))]},e.name)),g.map(e=>(0,H.jsxs)(`span`,{className:`wd-ci-item wd-tab-header-muted`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`●`}),` checks running on `,y(e)]},e.name)),h.length>0&&(c?(0,H.jsx)(`span`,{className:`wd-tab-header-muted`,children:`Sent to Claude ✓`}):(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-ci-fix`,disabled:o,onClick:async()=>{s(!0),d(null);try{await ze(e),l(!0)}catch(e){d(e.message)}finally{s(!1)}},children:o?`Sending…`:`Ask Claude to fix`})),u&&(0,H.jsx)(`span`,{className:`wd-dev-error`,role:`alert`,children:u})]})}var Zl={list:O,edit:j,discard:M,post:N,ask:pe};function Ql(e){return[`Review thread [thread ${e.threadId}] on PR #${e.prNumber}${e.where?` (${e.where})`:``}, from @${e.reviewer}, has no reply yet:`,``,`> ${e.excerpt.replace(/\n/g,` `)}`,``,`Fix it if it's right, then draft an answer with \`work pr reply ${e.threadId} "…"\` and show it to me. Don't post it.`].join(`
|
|
93
93
|
`)}function $l(e,t){let n=[e?`${e} ${e===1?`reply`:`replies`} to post`:``,t?`${t} thread${t===1?``:`s`} with no reply`:``].filter(Boolean);return n.length?n.join(` · `):null}function eu({sessionId:e,api:t=Zl,onNeeds:n,hidden:r=!1}){let[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),c=(0,_.useCallback)(()=>{t.list(e).then(e=>{a(e.replies),s(e.waiting)},()=>{})},[t,e]);(0,_.useEffect)(()=>{a([]),s([]),c()},[c]),Xa(`/events`,{events:{"replies-changed":t=>{t?.sessionId===e&&c()}}});let l=i.filter(e=>e.status===`draft`),u=$l(l.length,o.length);return(0,_.useEffect)(()=>n?.(u),[u,n]),l.length===0&&o.length===0?null:(0,H.jsxs)(`section`,{className:`wd-replies`,"aria-label":`Replies to review threads`,hidden:r,children:[l.length>0&&(0,H.jsxs)(`h3`,{className:`wd-replies-title`,children:[`✍ `,l.length,` `,l.length===1?`reply`:`replies`,` to post`]}),l.map(n=>(0,H.jsx)(nu,{reply:n,sessionId:e,api:t,onDone:c},n.threadId)),o.length>0&&(0,H.jsxs)(`h3`,{className:`wd-replies-title`,children:[`💬 `,o.length,` unresolved review thread`,o.length===1?``:`s`,` with no reply yet`]}),o.map(n=>(0,H.jsx)(tu,{thread:n,sessionId:e,api:t,handed:i.some(e=>e.threadId===n.threadId&&e.status===`sent`)},n.threadId))]})}function tu({thread:e,sessionId:t,api:n,handed:r}){let[i,a]=(0,_.useState)(`idle`),[o,s]=(0,_.useState)(null);return(0,H.jsxs)(`article`,{className:`wd-reply`,children:[(0,H.jsxs)(`div`,{className:`wd-reply-head`,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`wd-reply-where`,title:`Open the thread on GitHub`,children:[`PR #`,e.prNumber,e.where?` · ${e.where}`:``]}),(0,H.jsxs)(`span`,{className:`wd-replies-muted`,children:[` @`,e.reviewer]}),r&&(0,H.jsx)(`span`,{className:`wd-replies-muted`,children:` · handed to Claude, no draft yet`})]}),(0,H.jsx)(`blockquote`,{className:`wd-reply-quote`,children:e.excerpt}),o&&(0,H.jsx)(`div`,{className:`wd-tab-error`,role:`alert`,children:o}),(0,H.jsxs)(`div`,{className:`wd-reply-actions`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:i!==`idle`,onClick:()=>{a(`asking`),s(null),n.ask(t,Ql(e)).then(()=>a(`asked`),e=>{s(e.message),a(`idle`)})},title:`Send its Claude a note to fix it if needed and draft a reply (it posts nothing)`,children:i===`asking`?`Asking…`:i===`asked`?`Asked — the draft will show here`:`Ask Claude to reply`}),(0,H.jsx)(`a`,{className:`wd-link-button`,href:e.url,target:`_blank`,rel:`noreferrer`,children:`Answer on GitHub ↗`})]})]})}function nu({reply:e,sessionId:t,api:n,onDone:r}){let[i,a]=(0,_.useState)(e.draft??``),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null);(0,_.useEffect)(()=>a(e.draft??``),[e.draft]);let u=a=>{s(a),l(null),(a===`discard`?n.discard(t,e.threadId):(i===e.draft?Promise.resolve():n.edit(t,e.threadId,i)).then(()=>n.post(t,e.threadId,i,a===`resolve`))).then(r,e=>l(e.message)).finally(()=>s(null))};return(0,H.jsxs)(`article`,{className:`wd-reply`,children:[(0,H.jsxs)(`div`,{className:`wd-reply-head`,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`wd-reply-where`,title:`Open the thread on GitHub`,children:[`PR #`,e.prNumber,e.where?` · ${e.where}`:``]}),(0,H.jsxs)(`span`,{className:`wd-replies-muted`,children:[` @`,e.reviewer]})]}),(0,H.jsx)(`blockquote`,{className:`wd-reply-quote`,children:e.excerpt}),(0,H.jsx)(`textarea`,{className:`wd-reply-text`,value:i,onChange:e=>a(e.target.value),rows:Math.min(8,Math.max(2,i.split(`
|
|
94
94
|
`).length+1)),"aria-label":`Reply to ${e.reviewer}`}),c&&(0,H.jsx)(`div`,{className:`wd-tab-error`,role:`alert`,children:c}),(0,H.jsxs)(`div`,{className:`wd-reply-actions`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,disabled:!!o||!i.trim(),onClick:()=>u(`resolve`),title:`Post from your GitHub account, then resolve the thread`,children:o===`resolve`?`Posting…`:`Post & resolve`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:!!o||!i.trim(),onClick:()=>u(`post`),title:`Post from your GitHub account; leave the thread open`,children:o===`post`?`Posting…`:`Post`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,disabled:!!o,onClick:()=>u(`discard`),title:`Drop the draft; nothing is posted`,children:o===`discard`?`Discarding…`:`Discard`})]})]})}function ru(e){let t=e.filter(e=>!!e);return t.length?t.join(` · `):null}function iu({text:e,open:t,onToggle:n}){return(0,H.jsxs)(`div`,{className:`wd-needs-you`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-needs-you-label`,children:`Needs you`}),(0,H.jsx)(`span`,{className:`wd-needs-you-text`,children:e}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary wd-needs-you-btn`,"aria-expanded":t,onClick:n,children:t?`Hide`:`Review`})]})}async function au(e){let t=await fetch(e,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`${t.status} ${t.statusText} for ${e}`);return t.json()}async function ou(e,t,n=`POST`){let r=await fetch(e,{method:n,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!r.ok)throw Error(`${r.status} ${r.statusText} for ${e}`);return r.json()}function su(){return{fetch:()=>au(`/api/comments`).then(e=>e.comments),post:e=>ou(`/api/comments`,e),delete:async e=>{let t=await fetch(`/api/comments/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()},resolve:(e,t)=>ou(`/api/comments/${encodeURIComponent(e)}/resolve`,{resolved:t}),submit:e=>ou(`/api/submit-review`,{summary:e}),discard:()=>ou(`/api/discard-review`,{}),done:async()=>{await ou(`/api/done`,{})},ssePath:`/events`}}function cu(e){let t=`/api/scopes/${encodeURIComponent(e)}`;return{fetch:()=>au(`${t}/comments`).then(e=>e.comments),post:e=>ou(`${t}/comments`,e),delete:async e=>{let n=await fetch(`${t}/comments/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok)throw Error(`${n.status} ${n.statusText}`);return n.json()},resolve:(e,n)=>ou(`${t}/comments/${encodeURIComponent(e)}/resolve`,{resolved:n}),submit:e=>ou(`${t}/submit-review`,{summary:e}),discard:()=>ou(`${t}/discard-review`,{}),done:async()=>{await ou(`${t}/done`,{})},ssePath:`${t}/events`,matchesEvent:t=>!t||typeof t!=`object`?!1:t.scopeHash===e}}function lu(e){let t=`/api/sessions/${encodeURIComponent(e)}`;return{fetch:()=>au(`${t}/comments`).then(e=>e.comments),post:e=>ou(`${t}/comments`,e),delete:async e=>{let n=await fetch(`${t}/comments/${encodeURIComponent(e)}`,{method:`DELETE`});if(!n.ok)throw Error(`${n.status} ${n.statusText}`);return n.json()},resolve:(e,n)=>ou(`${t}/comments/${encodeURIComponent(e)}/resolve`,{resolved:n}),submit:e=>ou(`${t}/submit-review`,{summary:e}),discard:()=>ou(`${t}/discard-review`,{}),done:async()=>{},ssePath:`/events?session=${encodeURIComponent(e)}`,matchesEvent:t=>{if(!t||typeof t!=`object`)return!0;let n=t;return!n.sessionId||n.sessionId===e}}}function uu(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function du(e,t,n=120){let[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(0),[h,g]=(0,_.useState)(null),v=JSON.stringify(t),y=(0,_.useRef)(v);y.current=v;let b=(0,_.useRef)(0),x=(0,_.useRef)(e),S=(0,_.useRef)(null),C=(0,_.useRef)(0),w=(0,_.useRef)(0),T=(0,_.useRef)(null);x.current=e;let E=(0,_.useCallback)((e,t)=>{S.current=e,i(e),g(t)},[]),D=(0,_.useCallback)(e=>{T.current=e,f(e)},[]);(0,_.useEffect)(()=>{let e=++b.current,t=++C.current,r=y.current;o(null),D(null);let i=setTimeout(()=>{e===b.current&&c(!0)},n);return x.current().then(n=>{clearTimeout(i),e===b.current&&t===C.current&&(E(n,r),c(!1))},n=>{clearTimeout(i),e===b.current&&t===C.current&&(o(n.message),c(!1))}),()=>clearTimeout(i)},[...t,p]);let O=(0,_.useCallback)(()=>m(e=>e+1),[]),k=(0,_.useCallback)(()=>{let e=C.current,t=y.current,r=++w.current,i=setTimeout(()=>{r===w.current&&u(!0)},n);x.current().then(n=>{if(clearTimeout(i),r===w.current&&(u(!1),e===C.current)){if(S.current===null){o(null),E(n,t);return}D(uu(n,S.current)?null:n)}},()=>{clearTimeout(i),r===w.current&&u(!1)})},[E,D,n]),A=(0,_.useCallback)(()=>{let e=T.current;e!==null&&(D(null),E(e,y.current))},[E,D]);return{data:r,error:a,loading:s,checking:l,pending:d,stale:r!==null&&h!==v,applyPending:A,reload:O,checkForUpdates:k}}var fu=(0,_.createContext)(null);function pu({children:e,api:t}){let n=(0,_.useMemo)(()=>t??su(),[t]),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(0,_.useRef)(0),f=(0,_.useCallback)(()=>{let e=++d.current;n.fetch().then(t=>{e===d.current&&(i(t),o(null))},t=>{e===d.current&&o(t.message)})},[n]);(0,_.useEffect)(()=>f(),[f]),Xa(n.ssePath,{events:{"comments-changed":e=>{(!n.matchesEvent||n.matchesEvent(e))&&f()}}});let p=(0,_.useCallback)(async e=>{let t=await n.post(e);++d.current,i(t.comments)},[n]),m=(0,_.useCallback)(async e=>{let t=await n.delete(e);++d.current,i(t.comments)},[n]),h=(0,_.useCallback)(async(e,t)=>{let r=await n.resolve(e,t);++d.current,i(r.comments)},[n]),g=(0,_.useCallback)(async e=>{let t=await n.submit(e);++d.current,i(t.comments)},[n]),v=(0,_.useCallback)(async()=>{let e=await n.discard();++d.current,i(e.comments)},[n]),y=(0,_.useCallback)(async()=>{await n.done()},[n]),b=(0,_.useMemo)(()=>({comments:r,error:a,openComposer:s,openReplyTo:l,postComment:p,deleteComment:m,resolveComment:h,submitReview:g,discardReview:v,done:y,openComposerAt:e=>{c(e),u(null)},closeComposer:()=>c(null),openReplyAt:e=>{u(e),c(null)},closeReply:()=>u(null)}),[r,a,s,l,p,m,h,g,v,y]);return(0,H.jsx)(fu.Provider,{value:b,children:e})}function mu(){let e=(0,_.useContext)(fu);if(!e)throw Error(`useReview must be used inside ReviewProvider`);return e}function hu(){return(0,_.useContext)(fu)}function gu(e){return e.filter(e=>e.status===`draft`)}function _u(e){return e.reduce((e,t)=>t.status===`published`&&t.author===`user`?e+1:e,0)}function vu(e){return e.some(e=>e.status===`draft`)}function yu(e,t,n,r,i){return e.filter(e=>!e.parentId&&e.side===i&&e.repo===t&&e.file===n&&e.line===r)}function bu(e,t){return e.filter(e=>e.parentId===t).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}var xu=(0,_.createContext)(null);function Su(){return(0,_.useContext)(xu)}function Cu(e,t=0){let n=e.length===0?[]:`file`in e[0]?e:e.map((e,n)=>({file:e,index:t+n})),r={children:new Map,files:[]};for(let e of n){let t=e.file.path.split(`/`).filter(Boolean).slice(0,-1),n=r;for(let e of t){let t=n.children.get(e);t||(t={children:new Map,files:[]},n.children.set(e,t)),n=t}n.files.push(e)}function i(e){let t=[];for(let[n,r]of e.children)t.push({kind:`dir`,name:n,children:i(r)});for(let n of e.files){let e=n.file.path.split(`/`).pop()??n.file.path;t.push({kind:`file`,name:e,file:n.file,index:n.index})}return t.sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),t}return i(r)}function wu(e){let t=[];function n(e){for(let r of e)r.kind===`file`?t.push(r):n(r.children)}return n(e),t}var X=c(o(((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=new RegExp(y(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([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]===`(`||/^\(\?[<']/.test(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},N={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},P={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},F={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/},I=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},ee=I(`//`,`$`),te=I(`/\\*`,`\\*/`),ne=I(`#`,`$`),L=Object.freeze({__proto__:null,APOS_STRING_MODE:N,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:I,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:ee,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:ne,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:F,QUOTE_STRING_MODE:P,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 re(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ie(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function ae(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=re,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function oe(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function se(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 ce(e,t){e.relevance===void 0&&(e.relevance=1)}var le=(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},ue=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],de=`keyword`;function R(e,t,n=de){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,R(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,z(n[0],n[1])]})}}function z(e,t){return t?Number(t):+!B(e)}function B(e){return ue.includes(e.toLowerCase())}var fe={},pe=e=>{console.error(e)},me=(e,...t)=>{console.log(`WARN: ${e}`,...t)},he=(e,t)=>{fe[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),fe[`${e}/${t}`]=!0)},V=Error();function ge(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 _e(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw pe(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),V;if(typeof e.beginScope!=`object`||e.beginScope===null)throw pe(`beginScope must be object`),V;ge(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function ve(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw pe(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),V;if(typeof e.endScope!=`object`||e.endScope===null)throw pe(`endScope must be object`),V;ge(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function ye(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function be(e){ye(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),_e(e),ve(e)}function xe(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;[ie,se,be,le].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[ae,oe,ce].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&&=R(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 Ce(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 Se(e){return e?e.endsWithParent||Se(e.starts):!1}function Ce(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:Se(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var we=`11.12.0`,Te=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},Ee=i,De=a,Oe=Symbol(`nomatch`),ke=7,Ae=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=N(n[1]);return t||(me(s.replace(`{}`,n[1])),me(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||N(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(he(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),he(`10.7.0`,`Please use highlight(code, options) instead.
|
|
@@ -108,9 +108,9 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
108
108
|
This discards the uncommitted change; Claude is told not to reintroduce it.`)){a(!0),s(null);try{await r.revert(e,t,n)}catch(e){s(e.message)}finally{a(!1)}}},children:i?`Reverting…`:n?`↶ Revert`:`↶ Revert file`}),o&&(0,H.jsx)(`span`,{className:`wd-revert-error`,role:`alert`,children:o})]})}function mp(e,t){if(!t)return null;let n=[],r=[];for(let t of e.lines)(t.kind===`context`||t.kind===`delete`)&&t.oldNum!==null&&n.push({num:t.oldNum,content:t.content}),(t.kind===`context`||t.kind===`add`)&&t.newNum!==null&&r.push({num:t.newNum,content:t.content});let i=e=>{let n=wf(e.map(e=>e.content),t),r=new Map;return e.forEach((e,t)=>{let i=n[t];i&&r.set(e.num,i)}),r};return{old:i(n),new:i(r)}}function hp({hunk:e,review:t=!1,repo:n,file:r,lang:i,reviewed:a,onToggleReviewed:o,showHeading:s=!0}){let c=ap(),l=(0,_.useMemo)(()=>Qf(e),[e]),u=(0,_.useMemo)(()=>c===`unified`?$f(e):[],[e,c]),d=(0,_.useMemo)(()=>mp(e,i),[e,i]),f=c===`unified`?3:4,p=t&&!!r&&!!o,m=p&&!!a,h=s,g=!!Su()&&!!n&&!!r;return(0,H.jsxs)(H.Fragment,{children:[(h||p||g)&&(0,H.jsx)(`tr`,{className:`wd-hunk-row`+(m?` wd-hunk-reviewed`:``),children:(0,H.jsxs)(`td`,{colSpan:f,className:`wd-hunk-context`,children:[p&&(0,H.jsx)(`label`,{className:`wd-hunk-checkbox`,title:`Mark this hunk as reviewed`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:!!a,"aria-label":`Mark hunk reviewed: ${r} lines ${e.newStart}–${e.newStart+e.newLines-1}`,onChange:e=>o(e.target.checked)})}),h&&fp(e),g&&(0,H.jsx)(pp,{repo:n,path:r,lines:{start:e.newStart,end:e.newStart+Math.max(e.newLines,1)-1}})]})}),c===`unified`?u.map((e,i)=>(0,H.jsxs)(_.Fragment,{children:[(0,H.jsx)(_p,{row:e,review:t,repo:n,file:r,lineHtml:d}),t&&n&&r&&(0,H.jsx)(gp,{row:e,repo:n,file:r})]},`${e.kind}-${e.oldNum??`x`}-${e.newNum??`x`}-${i}`)):l.map(e=>(0,H.jsxs)(_.Fragment,{children:[(0,H.jsx)(vp,{row:e,review:t,repo:n,file:r,lineHtml:d}),t&&n&&r&&(0,H.jsx)(lp,{repo:n,file:r,oldLine:e.oldNum,oldContent:e.oldContent,newLine:e.newNum,newContent:e.newContent})]},`${e.oldNum??`x`}-${e.newNum??`x`}`))]})}function gp({row:e,repo:t,file:n}){let r=e.kind===`delete`?`left`:`right`,i=r===`left`?e.oldNum:e.newNum;return i===null?null:(0,H.jsx)(up,{repo:t,file:n,line:i,side:r,content:e.content})}function _p({row:e,review:t,repo:n,file:r,lineHtml:i}){let a=hu(),o=t&&!!n&&!!r&&!!a,s=e.kind===`delete`?`left`:`right`,c=s===`left`?e.oldNum:e.newNum,l=o&&c!==null;function u(){o&&a&&n&&r&&c!==null&&a.openComposerAt({repo:n,file:r,line:c,side:s,lineContent:e.content})}let d=s===`left`?e.oldNum===null?null:i?.old.get(e.oldNum)??null:e.newNum===null?null:i?.new.get(e.newNum)??null,f=e.kind===`add`?`wd-add`:e.kind===`delete`?`wd-delete`:`wd-context`;return(0,H.jsxs)(`tr`,{className:`wd-row`,children:[(0,H.jsx)(yp,{num:e.oldNum,side:`old`,kindClass:f,clickable:l&&s===`left`,onClick:u}),(0,H.jsx)(yp,{num:e.newNum,side:`new`,kindClass:f,clickable:l&&s===`right`,onClick:u}),(0,H.jsx)(bp,{className:`wd-content ${f}`,text:e.content,spans:e.spans,kind:e.kind,html:d})]})}function vp({row:e,review:t,repo:n,file:r,lineHtml:i}){let a=hu(),o=t&&!!n&&!!r&&!!a;function s(t){if(!o||!a||!n||!r)return;let i=t===`left`?e.oldNum:e.newNum;i!==null&&a.openComposerAt({repo:n,file:r,line:i,side:t,lineContent:t===`left`?e.oldContent:e.newContent})}return(0,H.jsxs)(`tr`,{className:`wd-row`,children:[(0,H.jsx)(yp,{num:e.oldNum,side:`old`,kindClass:`wd-${e.oldKind}`,clickable:o&&e.oldNum!==null,onClick:()=>s(`left`)}),(0,H.jsx)(bp,{className:`wd-content wd-${e.oldKind}`,text:e.oldContent,spans:e.oldSpans,kind:`delete`,html:e.oldNum===null?null:i?.old.get(e.oldNum)??null}),(0,H.jsx)(yp,{num:e.newNum,side:`new`,kindClass:`wd-${e.newKind}`,clickable:o&&e.newNum!==null,onClick:()=>s(`right`)}),(0,H.jsx)(bp,{className:`wd-content wd-${e.newKind}`,text:e.newContent,spans:e.newSpans,kind:`add`,html:e.newNum===null?null:i?.new.get(e.newNum)??null})]})}function yp({num:e,side:t,kindClass:n,clickable:r,onClick:i}){return(0,H.jsx)(`td`,{className:`wd-ln wd-ln-${t} ${n}`+(r?` wd-ln-clickable`:``),onClick:r?i:void 0,children:e??``})}function bp({className:e,text:t,spans:n,kind:r,html:i}){return n?(0,H.jsx)(`td`,{className:e,children:n.map((e,t)=>e.changed?(0,H.jsx)(`span`,{className:`wd-intra-${r===`add`?`add`:`del`}`,children:e.text},t):(0,H.jsx)(`span`,{children:e.text},t))}):i===null?(0,H.jsx)(`td`,{className:e,children:t||` `}):(0,H.jsx)(`td`,{className:e,dangerouslySetInnerHTML:{__html:i}})}var xp=(0,_.createContext)(null);function Sp({children:e,scopeHash:t}){let n=(0,_.useMemo)(()=>({loadLines:(e,n,r,i)=>ie(t,e,n,r,i),fileHref:(e,n)=>{let r=new URLSearchParams({repo:e,path:n});return`${t?`/file/${encodeURIComponent(t)}`:`/file`}?${r.toString()}`}}),[t]);return(0,H.jsx)(xp.Provider,{value:n,children:e})}function Cp(){return(0,_.useContext)(xp)}function wp(e){return{newNum:e.newStart+e.newLines-1,oldNum:e.oldStart+e.oldLines-1}}function Tp(e){return{newNum:e.newStart,oldNum:e.oldStart}}function Ep(e){if(e.length===0)return[];let t=[],n=e[0];n.newStart>1&&t.push({key:`head`,top:null,bottom:Tp(n)});for(let n=0;n<e.length-1;n++){let r=wp(e[n]),i=Tp(e[n+1]);i.newNum-r.newNum>1&&t.push({key:`mid-${n}`,top:r,bottom:i})}let r=e[e.length-1];return t.push({key:`tail`,top:wp(r),bottom:null}),t}function Dp(e){return e.top?e.top.oldNum-e.top.newNum:e.bottom?e.bottom.oldNum-e.bottom.newNum:0}function Op(e,t,n){let r=(e.top?e.top.newNum:0)+t+1,i=e.bottom?e.bottom.newNum-1-n:1/0,a=Math.min(r+20-1,i);return a<r?null:{start:r,end:a}}function kp(e,t,n){if(!e.bottom)return null;let r=e.bottom.newNum-1-n,i=(e.top?e.top.newNum:0)+t+1,a=Math.max(i,r-20+1);return r<a?null:{start:a,end:r}}function Ap(e,t,n){if(!e.bottom)return null;let r=e.bottom.newNum-1-(e.top?e.top.newNum:0);return Math.max(0,r-t-n)}function jp({repo:e,file:t,gap:n,lang:r,onClosedChange:i,belowHeading:a}){let o=Cp(),s=ap(),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),y=Ap(n,c.length,u.length),b=n.bottom!==null&&y===0;(0,_.useEffect)(()=>{i?.(b)},[b,i]);let x=(0,_.useMemo)(()=>{if(!r)return null;let e=new Map,t=t=>{let n=wf(t.map(e=>e.content),r);t.forEach((t,r)=>{let i=n[r];i&&e.set(t,i)})};return t(c),t(u),e},[r,c,u]);if(!o)return null;let S=Dp(n),C=(e,t)=>t.map((t,n)=>{let r=e+n;return{newNum:r,oldNum:r+S,content:t}});function w(){let r=Op(n,c.length,u.length);r&&!m&&(h(!0),v(null),o.loadLines(e,t,r.start,r.end).then(e=>{l(t=>[...t,...C(r.start,e.lines)]),n.bottom===null&&e.eof&&p(!0)}).catch(e=>v(e.message)).finally(()=>h(!1)))}function T(){let r=kp(n,c.length,u.length);r&&!m&&(h(!0),v(null),o.loadLines(e,t,r.start,r.end).then(e=>{d(t=>[...C(r.start,e.lines),...t])}).catch(e=>v(e.message)).finally(()=>h(!1)))}let E=Op(n,c.length,u.length)!==null,D=kp(n,c.length,u.length)!==null,O=(n.bottom!==null||!f&&!!E)&&(D||E),k=y;return(0,H.jsxs)(H.Fragment,{children:[c.map(e=>(0,H.jsx)(Mp,{line:e,html:x?.get(e)??null,unified:s===`unified`},`t-${e.newNum}`)),O&&(0,H.jsx)(`tr`,{className:`wd-row wd-expander-row`,children:(0,H.jsx)(`td`,{className:`wd-expander-cell`,colSpan:s===`unified`?3:4,children:(0,H.jsxs)(`div`,{className:`wd-expander`,children:[(0,H.jsxs)(`div`,{className:`wd-expander-arrows`,children:[E&&(0,H.jsx)(`button`,{type:`button`,className:`wd-expander-btn`,title:`Expand down`,"aria-label":`Expand lines below the section above`,disabled:m,onClick:w,children:`↓`}),D&&(0,H.jsx)(`button`,{type:`button`,className:`wd-expander-btn`,title:`Expand up`,"aria-label":`Expand lines above the section below`,disabled:m,onClick:T,children:`↑`})]}),(0,H.jsxs)(`div`,{className:`wd-expander-text`,children:[(0,H.jsx)(`span`,{className:`wd-expander-label`,children:g?`Couldn't expand: ${g}`:k===null?`Expand`:`${k} hidden line${k===1?``:`s`}`}),a&&(0,H.jsx)(`span`,{className:`wd-hunk-fn wd-expander-heading`,children:a})]})]})})}),u.map(e=>(0,H.jsx)(Mp,{line:e,html:x?.get(e)??null,unified:s===`unified`},`b-${e.newNum}`))]})}function Mp({line:e,html:t,unified:n}){return n?(0,H.jsxs)(`tr`,{className:`wd-row wd-row-context`,children:[(0,H.jsx)(`td`,{className:`wd-ln wd-ln-old wd-context`,children:e.oldNum}),(0,H.jsx)(`td`,{className:`wd-ln wd-ln-new wd-context`,children:e.newNum}),(0,H.jsx)(Np,{content:e.content,html:t})]}):(0,H.jsxs)(`tr`,{className:`wd-row wd-row-context`,children:[(0,H.jsx)(`td`,{className:`wd-ln wd-ln-old wd-context`,children:e.oldNum}),(0,H.jsx)(Np,{content:e.content,html:t}),(0,H.jsx)(`td`,{className:`wd-ln wd-ln-new wd-context`,children:e.newNum}),(0,H.jsx)(Np,{content:e.content,html:t})]})}function Np({content:e,html:t}){return t===null?(0,H.jsx)(`td`,{className:`wd-content wd-context`,children:e||` `}):(0,H.jsx)(`td`,{className:`wd-content wd-context`,dangerouslySetInnerHTML:{__html:t}})}function Pp({file:e,lang:t,review:n=!1,repo:r}){let i=(0,_.useMemo)(()=>ep(e.hunks),[e.hunks]),a=(0,_.useMemo)(()=>t?wf(i.map(e=>e.content),t):null,[i,t]);return(0,H.jsxs)(`table`,{className:`wd-diff-table wd-newfile`,children:[(0,H.jsxs)(`colgroup`,{children:[(0,H.jsx)(`col`,{className:`wd-col-ln`}),(0,H.jsx)(`col`,{})]}),(0,H.jsx)(`tbody`,{children:i.map((t,i)=>(0,H.jsxs)(_.Fragment,{children:[(0,H.jsx)(Fp,{line:t.newNum,content:t.content,html:a?.[i]??null,review:n,repo:r,file:e.path}),n&&r&&(0,H.jsx)(Ip,{repo:r,file:e.path,line:t.newNum,content:t.content})]},t.newNum))})]})}function Fp({line:e,content:t,html:n,review:r,repo:i,file:a}){let o=hu(),s=r&&!!i&&!!o;function c(){s&&o&&i&&o.openComposerAt({repo:i,file:a,line:e,side:`right`,lineContent:t})}return(0,H.jsxs)(`tr`,{className:`wd-row`,children:[(0,H.jsx)(`td`,{className:`wd-ln wd-ln-new wd-add`+(s?` wd-ln-clickable`:``),onClick:s?c:void 0,children:e}),n===null?(0,H.jsx)(`td`,{className:`wd-content wd-add`,children:t||` `}):(0,H.jsx)(`td`,{className:`wd-content wd-add`,dangerouslySetInnerHTML:{__html:n}})]})}function Ip({repo:e,file:t,line:n,content:r}){let i=hu();if(!i)return null;let a={comments:yu(i.comments,e,t,n,`right`),composerOpen:i.openComposer!==null&&i.openComposer.repo===e&&i.openComposer.file===t&&i.openComposer.line===n&&i.openComposer.side===`right`,lineContent:r,line:n,side:`right`};return a.comments.length===0&&!a.composerOpen?null:(0,H.jsx)(`tr`,{className:`wd-comment-row`,children:(0,H.jsx)(`td`,{colSpan:2,className:`wd-comment-side`,children:(0,H.jsx)(dp,{repo:e,file:t,side:a})})})}function Lp(e){function t(){try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return n&&typeof n==`object`?n:{}}catch{return{}}}function n(t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}return{has(e,n){return!!t()[e]?.[n]},set(e,r,i){let a=t();a[e]||(a[e]={}),i?a[e][r]=!0:delete a[e][r],Object.keys(a[e]).length===0&&delete a[e],n(a)},readScope(e){return new Set(Object.keys(t()[e]??{}))}}}var Rp=Lp(`work-web:reviewed-hunks`);function zp(e,t,n){Rp.set(e,t,n)}function Bp(e){return Rp.readScope(e)}function Vp(e){let[t,n]=(0,_.useState)(()=>Bp(e));return(0,_.useEffect)(()=>{n(Bp(e))},[e]),{reviewedHunkKeys:t,toggle:(0,_.useCallback)((t,r)=>{zp(e,t,r),n(e=>{let n=new Set(e);return r?n.add(t):n.delete(t),n})},[e])}}function Hp(e,t){let n=`@@`+t.context+`
|
|
109
109
|
`;for(let e of t.lines)n+=e.kind+` `+e.content+`
|
|
110
110
|
`;return`${e}@${Up(n)}`}function Up(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}var Wp=500;function Gp({file:e,anchor:t,review:n,repo:r,viewed:i,onToggleViewed:a,hunkScopeKey:o}){let{reviewedHunkKeys:s,toggle:c}=Vp(o??``),l=ap(),u=hu(),d=!!n&&!!u&&!!r,f=Cp(),p=!!f,m=f&&r&&!e.isBinary&&e.status!==`deleted`?f.fileHref(r,e.path):null,h=(0,_.useMemo)(()=>e.isBinary?null:Cf(e.path),[e.isBinary,e.path]),g=e.added+e.deleted,[v,y]=(0,_.useState)(!(g>=Wp)),b=e.status===`renamed`&&e.hunks.length===0,x=!!i||e.status===`deleted`||b,[S,C]=(0,_.useState)(x);(0,_.useEffect)(()=>{C(x)},[x]);let w=(0,_.useRef)(null),T=(0,_.useCallback)(e=>{a?.(e),e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{w.current?.scrollIntoView({block:`start`})}))},[a]),E=e.mdContent,D=!!E&&!E.tooLarge&&(E.before!==void 0||E.after!==void 0),O=!!E&&!E.tooLarge&&E.before!==void 0&&E.after!==void 0,[k,A]=(0,_.useState)(`diff`);(0,_.useEffect)(()=>{S&&A(`diff`)},[S]);let j=(0,_.useMemo)(()=>{let t=new Map;for(let n of Ep(e.hunks))t.set(n.key,n);return t},[e.hunks]),[M,N]=(0,_.useState)(()=>new Set),P=(0,_.useCallback)((e,t)=>{N(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),F=(0,_.useMemo)(()=>{let e=new Map;for(let t of j.keys())e.set(t,e=>P(t,e));return e},[j,P]),I=e.status===`renamed`&&e.oldPath!==e.newPath?(0,H.jsxs)(`span`,{className:`wd-rename`,children:[e.oldPath,` → `,e.newPath]}):null;return(0,H.jsxs)(`article`,{ref:w,className:`wd-file`+(i?` wd-file-viewed`:``)+(S?` wd-file-collapsed`:``),id:t,"data-status":e.status,"data-path":e.path,children:[(0,H.jsxs)(`header`,{className:`wd-file-header`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-file-collapse`,"aria-expanded":!S,"aria-label":S?`Expand file`:`Collapse file`,title:S?`Expand file`:`Collapse file`,onClick:()=>C(e=>!e),children:(0,H.jsx)(`span`,{className:`wd-chevron`,"aria-hidden":`true`,children:`▸`})}),(0,H.jsx)(`span`,{className:`wd-file-badge wd-status-${e.status}`,children:Ef[e.status]}),(0,H.jsx)(`span`,{className:`wd-file-path`,children:I??e.path}),(e.added||e.deleted)&&(0,H.jsxs)(`span`,{className:`wd-file-stats`,children:[(0,H.jsxs)(`span`,{className:`wd-add`,children:[`+`,e.added]}),` `,(0,H.jsxs)(`span`,{className:`wd-del`,children:[`-`,e.deleted]})]}),D&&!S&&(0,H.jsxs)(`div`,{className:`wd-view-mode`,role:`tablist`,"aria-label":`File view mode`,children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`diff`,className:`wd-view-mode-btn`+(k===`diff`?` wd-view-mode-btn-active`:``),onClick:()=>A(`diff`),children:`Diff`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`preview`,className:`wd-view-mode-btn`+(k===`preview`?` wd-view-mode-btn-active`:``),onClick:()=>A(`preview`),children:`Preview`}),O&&(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":k===`split`,className:`wd-view-mode-btn`+(k===`split`?` wd-view-mode-btn-active`:``),onClick:()=>A(`split`),children:`Split`})]}),r&&(0,H.jsx)(pp,{repo:r,path:e.path}),m&&(0,H.jsx)(`a`,{className:`wd-file-openfile`,href:m,target:`_blank`,rel:`noopener noreferrer`,title:`Open the whole file in a new tab`,children:`Open file ↗`}),d&&(0,H.jsx)(`button`,{type:`button`,className:`wd-file-comment-btn`,title:`Comment on the whole file`,onClick:()=>u.openComposerAt({repo:r,file:e.path,line:0,side:`file`,lineContent:``}),children:`💬 Comment on file`}),a&&(0,H.jsxs)(`label`,{className:`wd-viewed-label`,title:`Mark this file as reviewed and collapse it`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`wd-viewed-checkbox`,checked:!!i,onChange:e=>T(e.target.checked)}),`Viewed`]})]}),d&&(0,H.jsx)(Kp,{repo:r,file:e.path}),!S&&(D&&k!==`diff`?(0,H.jsx)(qp,{file:e,mode:k}):e.isBinary?(0,H.jsx)(`div`,{className:`wd-binary`,children:`Binary file`}):e.hunks.length===0?(0,H.jsx)(`div`,{className:`wd-binary`,children:b?`File renamed without changes`:`No content changes`}):v?e.status===`added`?(0,H.jsx)(Pp,{file:e,lang:h,review:n,repo:r}):(0,H.jsxs)(`table`,{className:`wd-diff-table `+(l===`unified`?`wd-unified`:`wd-side`),children:[(0,H.jsx)(`colgroup`,{children:l===`unified`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`col`,{className:`wd-col-ln`}),(0,H.jsx)(`col`,{className:`wd-col-ln`}),(0,H.jsx)(`col`,{})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`col`,{className:`wd-col-ln`}),(0,H.jsx)(`col`,{className:`wd-col-content`}),(0,H.jsx)(`col`,{className:`wd-col-ln`}),(0,H.jsx)(`col`,{className:`wd-col-content`})]})}),(0,H.jsxs)(`tbody`,{children:[r&&j.has(`head`)&&(0,H.jsx)(jp,{repo:r,file:e.path,gap:j.get(`head`),lang:h,onClosedChange:F.get(`head`),belowHeading:e.hunks[0]?fp(e.hunks[0]):void 0}),e.hunks.map((t,i)=>{let a=Hp(e.path,t),l=j.get(`mid-${i}`),u=i===0?`head`:`mid-${i-1}`,d=j.has(u),f=M.has(u),m=!(p&&d&&!f)&&!(f||!d&&i>0);return(0,H.jsxs)(_.Fragment,{children:[(0,H.jsx)(hp,{hunk:t,review:n,repo:r,file:e.path,lang:h,reviewed:s.has(a),onToggleReviewed:o?e=>c(a,e):void 0,showHeading:m}),r&&l&&(0,H.jsx)(jp,{repo:r,file:e.path,gap:l,lang:h,onClosedChange:F.get(`mid-${i}`),belowHeading:e.hunks[i+1]?fp(e.hunks[i+1]):void 0})]},`${a}#${i}`)}),r&&j.has(`tail`)&&(0,H.jsx)(jp,{repo:r,file:e.path,gap:j.get(`tail`),lang:h})]})]}):(0,H.jsxs)(`div`,{className:`wd-binary wd-large-file`,children:[(0,H.jsxs)(`p`,{children:[`Large file — `,g.toLocaleString(),` line`,g===1?``:`s`,` changed. Not rendered by default.`]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:()=>y(!0),children:`Load diff`})]}))]})}function Kp({repo:e,file:t}){let n=mu(),r=n.comments.filter(n=>n.side===`file`&&!n.parentId&&n.repo===e&&n.file===t),i=n.openComposer!==null&&n.openComposer.side===`file`&&n.openComposer.repo===e&&n.openComposer.file===t;return r.length===0&&!i?null:(0,H.jsxs)(`div`,{className:`wd-file-comments`,children:[r.map(e=>(0,H.jsx)(cp,{comment:e,currentLineContent:null},e.id)),i&&(0,H.jsx)(sp,{context:`${e}/${t} · whole file`,onSubmit:async(r,i)=>{await n.postComment({repo:e,file:t,line:0,side:`file`,body:r,status:i}),n.closeComposer()},onCancel:()=>n.closeComposer()})]})}function qp({file:e,mode:t}){let n=e.mdContent;if(t===`split`&&n.before!==void 0&&n.after!==void 0)return(0,H.jsxs)(`div`,{className:`wd-md-split`,children:[(0,H.jsxs)(`div`,{className:`wd-md-split-side wd-md-split-before`,children:[(0,H.jsx)(`header`,{className:`wd-md-split-label`,children:`Before`}),(0,H.jsx)(Wa,{source:n.before,block:!0,className:`wd-md-preview`})]}),(0,H.jsxs)(`div`,{className:`wd-md-split-side wd-md-split-after`,children:[(0,H.jsx)(`header`,{className:`wd-md-split-label`,children:`After`}),(0,H.jsx)(Wa,{source:n.after,block:!0,className:`wd-md-preview`})]})]});let r=n.after??n.before??``;return(0,H.jsx)(Wa,{source:r,block:!0,className:`wd-md-preview`})}function Jp({repo:e,startIndex:t,review:n,viewedPaths:r,onToggleViewed:i,hunkScopeKey:a}){let o=(0,_.useMemo)(()=>wu(Cu(e.files,t)),[e.files,t]);return e.files.length===0?(0,H.jsxs)(`div`,{className:`wd-web-empty`,children:[`No changes in `,(0,H.jsx)(`code`,{children:e.name}),`.`]}):(0,H.jsx)(`div`,{className:`wd-repo-files`,children:o.map(t=>(0,H.jsx)(Gp,{file:t.file,anchor:`wd-file-${t.index}`,review:n,repo:e.name,viewed:r?.has(t.file.path),onToggleViewed:i?e=>i(t.file.path,e):void 0,hunkScopeKey:a},t.file.path))})}function Yp({label:e}){return(0,H.jsxs)(`span`,{className:`wd-diff-checking`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-diff-checking-dot`,"aria-hidden":`true`}),e]})}function Xp({filesChanged:e,onShow:t,onReload:n,onShowNewOnly:r}){let i=typeof e==`number`&&e>0?`${e} file${e===1?``:`s`}`:null;return(0,H.jsxs)(`span`,{className:`wd-diff-update`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-diff-update-dot`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`wd-diff-update-text`,children:[`New changes`,i&&(0,H.jsxs)(`span`,{className:`wd-web-muted`,children:[` · `,i]})]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-diff-update-btn wd-diff-update-btn-primary`,onClick:t,title:`Load the new diff here, keeping your scroll position`,children:`Show`}),r&&(0,H.jsx)(`button`,{type:`button`,className:`wd-diff-update-btn`,onClick:r,title:`Show only what changed since the last checkpoint in the diff you are looking at`,children:`Only new`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-diff-update-btn`,onClick:n,title:`Fetch the latest from the server and jump to the top`,children:`Reload`})]})}function Zp(){let e=op();if(!e)return null;let{mode:t,setMode:n}=e;return(0,H.jsxs)(`div`,{className:`wd-diff-mode`,role:`group`,"aria-label":`Diff layout`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-pressed":t===`split`,className:`wd-diff-mode-btn`+(t===`split`?` wd-diff-mode-btn-active`:``),onClick:()=>n(`split`),title:`Side-by-side layout`,children:`Split`}),(0,H.jsx)(`button`,{type:`button`,"aria-pressed":t===`unified`,className:`wd-diff-mode-btn`+(t===`unified`?` wd-diff-mode-btn-active`:``),onClick:()=>n(`unified`),title:`Unified (inline) layout`,children:`Unified`})]})}function Qp(e){let t=`${Math.round(e.coverage??0)}% line coverage`;return typeof e.coverageMtimeMs==`number`&&(t+=` (measured ${new Date(e.coverageMtimeMs).toLocaleString()})`),e.coverageStale&&(t+=` — STALE: source edited since coverage was recorded`),t}function $p({files:e,startIndex:t,selectedAnchor:n,viewedAnchors:r}){let[i,a]=(0,_.useState)(``),o=i.trim().toLowerCase(),s=(0,_.useMemo)(()=>{if(!o)return Cu(e,t);let n=e.map((e,n)=>({file:e,index:t+n})).filter(e=>e.file.path.toLowerCase().includes(o));return n.length===0?[]:Cu(n)},[e,t,o]);return(0,H.jsxs)(`div`,{className:`wd-tree-pane`,children:[(0,H.jsx)(`input`,{className:`wd-web-filter`,type:`search`,placeholder:`Filter files…`,value:i,onChange:e=>a(e.target.value)}),s.length===0?(0,H.jsx)(`p`,{className:`wd-web-empty-list`,children:`No matches.`}):(0,H.jsx)(`ul`,{className:`wd-tree-root`,children:s.map((e,t)=>(0,H.jsx)(em,{node:e,selectedAnchor:n??null,viewedAnchors:r},t))})]})}function em({node:e,selectedAnchor:t,viewedAnchors:n}){if(e.kind===`dir`)return(0,H.jsx)(`li`,{className:`wd-tree-dir`,children:(0,H.jsxs)(`details`,{open:!0,children:[(0,H.jsxs)(`summary`,{children:[(0,H.jsx)(`span`,{className:`wd-tree-caret`}),e.name]}),(0,H.jsx)(`ul`,{children:e.children.map((e,r)=>(0,H.jsx)(em,{node:e,selectedAnchor:t,viewedAnchors:n},r))})]})});let r=`wd-file-${e.index}`,i=r===t,a=n?.has(r)??!1,o=e.file.added||e.file.deleted?(0,H.jsxs)(`span`,{className:`wd-tree-stats`,children:[(0,H.jsxs)(`span`,{className:`wd-add`,children:[`+`,e.file.added]}),` `,(0,H.jsxs)(`span`,{className:`wd-del`,children:[`-`,e.file.deleted]})]}):null;return(0,H.jsx)(`li`,{className:`wd-tree-file`+(i?` wd-tree-file-active`:``)+(a?` wd-tree-file-viewed`:``),children:(0,H.jsxs)(`a`,{href:`#${r}`,onClick:e=>{e.preventDefault();let t=document.getElementById(r);t&&(history.replaceState(null,``,`#${r}`),t.scrollIntoView({block:`start`}))},title:e.file.path,children:[(0,H.jsx)(`span`,{className:`wd-tree-status wd-status-${e.file.status}`,children:Ef[e.file.status]}),(0,H.jsx)(`span`,{className:`wd-tree-name`,children:e.name}),o,typeof e.file.coverage==`number`&&(0,H.jsxs)(`span`,{className:`wd-coverage-badge wd-coverage-${e.file.coverage>=80?`good`:e.file.coverage>=50?`fair`:`poor`}${e.file.coverageStale?` wd-coverage-stale`:``}`,title:Qp(e.file),children:[Math.round(e.file.coverage),`%`,e.file.coverageStale?` ?`:``]})]})})}function tm({repoName:e,onOpenRepo:t}){let n=mu().comments.filter(e=>!e.parentId);return(0,H.jsxs)(`div`,{className:`wd-comments-panel`,children:[(0,H.jsxs)(`h3`,{className:`wd-comments-panel-title`,children:[`Comments `,(0,H.jsxs)(`span`,{className:`wd-comments-panel-count`,children:[`(`,n.length,`)`]})]}),n.length===0?(0,H.jsx)(`p`,{className:`wd-comments-panel-empty`,children:`No comments yet.`}):(0,H.jsx)(`ul`,{className:`wd-comments-panel-list`,children:n.map(n=>(0,H.jsx)(nm,{comment:n,repoName:e,onOpenRepo:t},n.id))})]})}function nm({comment:e,repoName:t,onOpenRepo:n}){let r=e.side!==`general`&&!!e.repo&&e.repo!==t;function i(){if(r){n?.(e.repo),setTimeout(()=>rm(e),60);return}rm(e)}let a=e.side===`general`?`General`:e.side===`file`?`${e.file} · whole file`:`${e.file}:${e.line}`;return(0,H.jsxs)(`li`,{className:`wd-comments-panel-row`+(e.resolved?` wd-comments-panel-row-resolved`:``),onClick:i,children:[(0,H.jsxs)(`div`,{className:`wd-comments-panel-loc`,children:[e.resolved&&(0,H.jsxs)(`span`,{className:`wd-resolved-check`,"aria-hidden":`true`,children:[`✓`,` `]}),r&&(0,H.jsxs)(`span`,{className:`wd-comments-panel-repo`,children:[e.repo,` · `]}),a]}),(0,H.jsx)(`div`,{className:`wd-comments-panel-body`,children:e.body.split(`
|
|
111
|
-
`)[0]})]})}function rm(e){if(e.side===`general`){let e=document.querySelector(`.wd-general-pane`),t=e?.querySelector(`details`);t&&!t.open&&(t.open=!0),e?.scrollIntoView({behavior:`smooth`,block:`start`});return}let t=document.querySelector(`article.wd-file[data-path="${am(e.file)}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),e.side!==`file`&&im(t,e.line,e.side))}function im(e,t,n){let r=e.querySelectorAll(n===`right`?`.wd-ln-new`:`.wd-ln-old`);for(let e of r)if(e.textContent?.trim()===String(t)){let t=e.closest(`tr`);if(t){t.classList.add(`wd-row-flash`),setTimeout(()=>t.classList.remove(`wd-row-flash`),1200);let e=t.nextElementSibling;e?.classList.contains(`wd-comment-row`)&&e.scrollIntoView({behavior:`smooth`,block:`center`})}break}}function am(e){return e.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,`\\$&`)}function om(){let e=mu(),[t,n]=(0,_.useState)(``),r=e.comments.filter(e=>e.side===`general`&&!e.parentId);async function i(r){let i=t.trim();i&&(await e.postComment({side:`general`,body:i,status:r}),n(``))}return(0,H.jsx)(`section`,{className:`wd-general-pane`,children:(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:`General review note (not tied to any line)`}),(0,H.jsx)(`textarea`,{className:`wd-general-input`,placeholder:`A high-level comment for Claude…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),i(`published`))}}),(0,H.jsxs)(`div`,{className:`wd-general-pane-actions`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:!t.trim(),onClick:()=>i(`draft`),children:e.comments.some(e=>e.status===`draft`)?`Add to review`:`Start review`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,disabled:!t.trim(),onClick:()=>i(`published`),children:`Comment (Ctrl+Enter)`})]}),r.length>0&&(0,H.jsx)(`div`,{className:`wd-general-pane-list`,children:r.map(e=>(0,H.jsx)(cp,{comment:e,currentLineContent:null},e.id))})]})})}function sm({title:e,children:t,actions:n,onClose:r,primaryRef:i}){let a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,_.useEffect)(()=>{if(i?.current){i.current.focus();return}(a.current?.querySelector(`.wd-btn-primary`))?.focus()},[i]),(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,ref:a,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,H.jsxs)(`div`,{className:`wd-modal`,children:[(0,H.jsx)(`h2`,{children:e}),t,(0,H.jsx)(`div`,{className:`wd-modal-actions`,children:n})]})})}function cm(){let e=mu(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(``),a=gu(e.comments);return a.length===0?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-pending-pill wd-visible`,onClick:()=>{i(``),n(!0)},children:[`Pending review `,(0,H.jsxs)(`span`,{className:`wd-pending-count`,children:[`(`,a.length,`)`]})]}),t&&(0,H.jsxs)(sm,{title:`Submit your review`,onClose:()=>n(!1),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:async()=>{confirm(`Discard all ${a.length} pending comment(s)?`)&&(await e.discardReview(),n(!1))},children:`Discard drafts`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:async()=>{try{await e.submitReview(r),n(!1)}catch{}},children:`Submit review`})]}),children:[(0,H.jsxs)(`p`,{children:[`Sending `,a.length,` pending comment`,a.length===1?``:`s`,`. Add a summary if you like, then click Submit to send everything to Claude.`]}),(0,H.jsx)(`textarea`,{className:`wd-submit-summary`,placeholder:`Optional summary…`,value:r,onChange:e=>i(e.target.value)})]})]})}var lm=Lp(`work-web:viewed-files`);function um(e,t,n){lm.set(e,t,n)}function dm(e){return lm.readScope(e)}function fm(e,t){let n=new Set;for(let r of e){let e=r.lastIndexOf(`#`);if(e<0){n.add(r);continue}let i=r.slice(0,e);(!t||t.get(i)===r.slice(e+1))&&n.add(i)}return n}function pm(e,t,n){let[r,i]=(0,_.useState)(()=>dm(e));(0,_.useEffect)(()=>{i(dm(e))},[e]);let a=(0,_.useMemo)(()=>fm(r,n),[r,n]),o=(0,_.useCallback)((t,r)=>{for(let n of dm(e))(n===t||n.startsWith(`${t}#`))&&um(e,n,!1);let a=n?.get(t);r&&um(e,a?`${t}#${a}`:t,!0),i(dm(e))},[e,n]),s=new Set;for(let e of a){let n=t.get(e);n&&s.add(n)}return{viewedPaths:a,viewedAnchors:s,toggle:o}}var mm=`.wd-comment-row`;function hm(e){let t=(0,_.useRef)(null);(0,_.useEffect)(()=>{let n=n=>{if(n.key!==`]`&&n.key!==`[`||n.metaKey||n.ctrlKey||n.altKey)return;let r=document.activeElement;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.tagName===`SELECT`||r.isContentEditable))return;let i=e.current;if(!i)return;let a=[...i.querySelectorAll(mm)];if(a.length===0)return;n.preventDefault();let o=t.current?a.indexOf(t.current):-1,s=n.key===`]`?a[o<0?0:(o+1)%a.length]:a[o<0?a.length-1:(o-1+a.length)%a.length];t.current=s,s.scrollIntoView?.({behavior:`smooth`,block:`center`}),s.classList.add(`wd-row-flash`),setTimeout(()=>s.classList.remove(`wd-row-flash`),1200)};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e])}function gm(e,t,n,r){let i=e+t;return e<r?e-r:i>n-r?i-(n-r):0}function _m(e,t,n){(0,_.useEffect)(()=>{if(!n||!t)return;let r=e.current;if(!r)return;let i=r.querySelector(`.wd-tree-file-active`);if(!i)return;let a=i.getBoundingClientRect().top-r.getBoundingClientRect().top;r.scrollTop+=gm(a,i.offsetHeight,r.clientHeight,24)},[t,n])}function vm(e){let[t,n]=(0,_.useState)(null);return(0,_.useEffect)(()=>{function e(){let e=Array.from(document.querySelectorAll(`article.wd-file`)).filter(e=>e.isConnected);if(e.length===0){n(null);return}let t=null;for(let n of e)if(n.getBoundingClientRect().top<=80)t=n;else break;n((t??e[0]).id)}let t=!1;function r(){t||(t=!0,requestAnimationFrame(()=>{t=!1,e()}))}e(),window.addEventListener(`scroll`,r,{passive:!0,capture:!0}),window.addEventListener(`resize`,r);let i=typeof MutationObserver>`u`?null:new MutationObserver(r),a=document.querySelector(`.wd-web-review-main`)??document.body;return i?.observe(a,{childList:!0,subtree:!0}),()=>{window.removeEventListener(`scroll`,r,{capture:!0}),window.removeEventListener(`resize`,r),i?.disconnect()}},[e]),t}var ym=()=>document.visibilityState===`visible`&&document.hasFocus();function bm(e,t,n,r=1e3){let i=(0,_.useRef)(n);i.current=n,(0,_.useEffect)(()=>{if(e===null)return;let n=0,a=setInterval(()=>{ym()&&(n+=r,n>=t&&(clearInterval(a),i.current()))},r);return()=>clearInterval(a)},[e,t,r])}function xm(e){return e.length?Math.max(...e.map(e=>e.id)):null}function Sm(e,t){let n=xm(t);return!!e&&n!==null&&n>e.checkpointId}function Cm(e){let t=5381;for(let n of e.hunks)for(let e of n.lines){let n=`${e.kind}${e.content}`;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0}return`${e.added}.${e.deleted}.${(t>>>0).toString(36)}`}var wm=5e3;function Tm({session:e,startOnLastTurn:t=!1}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(`uncommitted`),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)([]),u=(0,_.useMemo)(()=>R(c),[c]),d=o===null?null:u.find(e=>e.to===o)??null,f=(0,_.useRef)(e.id);f.current=e.id;let p=()=>{let t=e.id,n=e=>{f.current===t&&l(e)};de(t).then(n,()=>n([]))},[m,h]=(0,_.useState)(void 0),[g,v]=(0,_.useState)(!1);(0,_.useEffect)(()=>{s(null),l([]),h(void 0),v(!1),p();let t=e.id;ce(t).then(e=>f.current===t&&h(e),()=>f.current===t&&h(null))},[e.id]);let y=xm(c),b=Sm(m,c),x=(0,_.useRef)(null);(0,_.useEffect)(()=>{t||m===void 0||c.length===0||x.current===e.id||(x.current=e.id,b&&v(!0))},[t,m,c.length,b,e.id]),bm(y===null?null:`${e.id}:${y}`,wm,()=>{y!==null&&le(e.id,y).catch(()=>{})});let S=(0,_.useRef)(null);(0,_.useEffect)(()=>{t&&S.current!==e.id&&u.length!==0&&(S.current=e.id,s(u[0].to))},[t,e.id,u]);let{data:C,error:w,loading:T,checking:E,pending:D,stale:O,applyPending:k,reload:A,checkForUpdates:j}=du(()=>g&&m?ue(e.id,`uncommitted`,{from:m.checkpointId,to:`working`}):d?ue(e.id,`uncommitted`,{from:d.from,to:d.to}):ue(e.id,i),[e.id,i,d?.from,d?.to,g,m?.checkpointId]);Xa(`/events?session=${encodeURIComponent(e.id)}`,{events:{"diff-changed":()=>j(),"checkpoints-changed":()=>p()}});let M=(0,_.useMemo)(()=>lu(e.id),[e.id]);(0,_.useEffect)(()=>{C&&C.repos.length!==0&&(C.repos.some(e=>e.name===n)||r(C.repos[0].name))},[C,n]);let N=(0,_.useMemo)(()=>{let e=new Map,t=0;if(C)for(let n of C.repos)e.set(n.name,t),t+=n.files.length;return e},[C]),P=(0,_.useMemo)(()=>!C||C.repos.length===0?null:C.repos.find(e=>e.name===n)??C.repos[0],[C,n]),F=P?N.get(P.name)??0:0,I=(0,_.useMemo)(()=>{let e=new Map;return P&&P.files.forEach((t,n)=>{e.set(t.path,`wd-file-${F+n}`)}),e},[P,F]),ee=P?`session:${e.id}:${P.name}`:`session:${e.id}:_pending`,te=P?`session:${e.id}:${P.name}:hunks`:``,{viewedPaths:ne,viewedAnchors:L,toggle:re}=pm(ee,I,(0,_.useMemo)(()=>new Map((P?.files??[]).map(e=>[e.path,Cm(e)])),[P])),ie=vm(`${e.id}:${P?.name??`_pending`}`),{width:ae,setWidth:oe}=Tc(),{size:se,setSize:z}=wc(xc),B=(0,_.useRef)(null),fe=(0,_.useRef)(null),pe=(0,_.useRef)(null);hm(pe);let me=()=>{A(),pe.current?.scrollTo({top:0})},he=(0,_.useRef)(null);_m(he,ie,!0);let V=!g&&!d&&i===`uncommitted`,ge=(0,_.useMemo)(()=>V?{revert:async(t,n,r)=>{await Fe(e.id,{repo:t,path:n,lines:r}),A()}}:null,[V,e.id,A]);if(w)return(0,H.jsx)(`div`,{className:`wd-web-error`,children:w});if(!C)return(0,H.jsx)(`div`,{className:`wd-web-empty`,children:`Loading diff…`});let _e=C.repos.reduce((e,t)=>e+t.files.length,0),ve=D?D.repos.reduce((e,t)=>e+t.files.length,0):null,ye=_e===0||!P,be=C.repos.length>1,xe;return xe=g?`Nothing changed since you last looked.`:d?`This turn changed no files.`:i===`uncommitted`?`No uncommitted changes.`:!C.resolvedBase||C.resolvedBase===`HEAD`?"Couldn't auto-detect this branch's parent. Tried main, master, dev, develop (and their origin/* mirrors). Record an explicit base via `work tree --base <ref>` to fix.":`No commits since \`${C.resolvedBase}\` — this branch is up to date or already merged.`,(0,H.jsx)(pu,{api:M,children:(0,H.jsx)(xu.Provider,{value:ge,children:(0,H.jsxs)(`div`,{ref:B,className:`wd-web-review-layout`,style:{"--sidebar-width":`${ae}px`},children:[(0,H.jsxs)(`aside`,{ref:fe,className:`wd-web-review-sidebar wd-web-review-sidebar-split`,style:{[xc.cssVar]:`${se}px`},children:[(0,H.jsxs)(`header`,{className:`wd-web-review-sidebar-header`,children:[(0,H.jsxs)(`h1`,{children:[e.target,(0,H.jsxs)(`span`,{className:`wd-web-branch`,children:[` · `,e.branch]})]}),(0,H.jsxs)(`p`,{children:[O?(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`loading…`}):ye?(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`no changes`}):(0,H.jsxs)(H.Fragment,{children:[_e,` file`,_e===1?``:`s`,` changed`,be?` across ${C.repos.length} repos`:``]}),C.base===`branch`&&C.resolvedBase&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsxs)(`span`,{className:`wd-web-muted`,children:[`vs `,C.resolvedBase]})]})]}),(0,H.jsxs)(`div`,{className:`wd-web-diff-scope`,role:`tablist`,"aria-label":`Diff scope`,children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!d&&i===`uncommitted`,className:`wd-web-diff-scope-btn`+(!g&&!d&&i===`uncommitted`?` wd-web-diff-scope-btn-active`:``),onClick:()=>{v(!1),s(null),a(`uncommitted`)},title:`git diff HEAD — only the working-tree deltas`,children:`Uncommitted`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!d&&i===`branch`,className:`wd-web-diff-scope-btn`+(!g&&!d&&i===`branch`?` wd-web-diff-scope-btn-active`:``),onClick:()=>{v(!1),s(null),a(`branch`)},title:e.baseBranch?`git diff ${e.baseBranch} — everything since this branch was created`:`Everything since this worktree's parent branch — auto-detected`,children:`Since branch`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!!d,className:`wd-web-diff-scope-btn`+(!g&&d?` wd-web-diff-scope-btn-active`:``),disabled:u.length===0,onClick:()=>{v(!1),s(u[0]?.to??null)},title:u.length?`Only what Claude's last instruction changed`:`No finished turn yet — appears after Claude finishes one`,children:`Last turn`}),(b||g)&&m&&(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g,className:`wd-web-diff-scope-btn`+(g?` wd-web-diff-scope-btn-active`:``),onClick:()=>v(!0),title:`Everything that changed after you last looked at this diff (${J(m.at)}${J(m.at)===`just now`?``:` ago`}), over every turn since`,children:`Since you looked`})]}),!g&&d&&u.length>1&&(0,H.jsxs)(`label`,{className:`wd-web-turn-pick`,children:[(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`Turn`}),` `,(0,H.jsx)(`select`,{value:d.to,onChange:e=>s(Number(e.target.value)),"aria-label":`Which turn`,children:u.map(e=>(0,H.jsxs)(`option`,{value:e.to,children:[e.n,e.label?` · ${e.label}`:``]},e.to))})]}),!g&&d&&u.length===1&&d.label&&(0,H.jsx)(`p`,{className:`wd-web-turn-label wd-web-muted`,children:d.label}),(0,H.jsx)(Zp,{}),D&&(0,H.jsx)(Xp,{filesChanged:ve,onShow:k,onReload:me}),(O||T||E&&!D)&&(0,H.jsx)(Yp,{label:O||T?`loading…`:`checking…`})]}),!ye&&P?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:he,className:`wd-sidebar-split-top`+(O?` wd-diff-stale`:``),inert:O,children:(0,H.jsx)($p,{files:P.files,startIndex:F,selectedAnchor:ie,viewedAnchors:L})}),(0,H.jsx)(Ec,{layoutRef:fe,size:se,onCommit:z,spec:xc}),(0,H.jsx)(`div`,{className:`wd-sidebar-split-bottom`,children:(0,H.jsx)(tm,{repoName:P.name,onOpenRepo:r})})]}):(0,H.jsx)(`div`,{className:`wd-sidebar-split-bottom wd-sidebar-comments-only`,children:(0,H.jsx)(tm,{})})]}),(0,H.jsx)(Ec,{layoutRef:B,size:ae,onCommit:oe}),(0,H.jsx)(`main`,{ref:pe,className:`wd-web-review-main`+(O?` wd-diff-stale`:``),"aria-busy":T||O,inert:O,style:{"--tabs-offset":be?`36px`:`0px`},children:ye||!P?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(om,{}),(0,H.jsxs)(`div`,{className:`wd-web-empty wd-web-empty-diff`,children:[(0,H.jsx)(`p`,{children:xe}),!d&&i===`uncommitted`&&(0,H.jsxs)(`p`,{className:`wd-web-empty-hint`,children:[`Try`,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-web-link-btn`,onClick:()=>a(`branch`),children:`Since branch`}),` `,`to see everything in this worktree.`]})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(om,{}),be&&(0,H.jsx)(`nav`,{className:`wd-web-repo-tabs`,children:C.repos.map(e=>{let t=e.files.reduce((e,t)=>e+t.added,0),n=e.files.reduce((e,t)=>e+t.deleted,0);return(0,H.jsxs)(`button`,{type:`button`,className:`wd-web-repo-tab`+(e.name===P.name?` wd-web-repo-tab-active`:``),onClick:()=>r(e.name),children:[e.name,` `,(0,H.jsxs)(`span`,{className:`wd-web-tab-count`,children:[`(`,e.files.length,`)`]}),` `,(0,H.jsxs)(`span`,{className:`wd-tab-stats`,children:[(0,H.jsxs)(`span`,{className:`wd-add`,children:[`+`,t]}),` `,(0,H.jsxs)(`span`,{className:`wd-del`,children:[`-`,n]})]})]},e.name)})}),(0,H.jsx)(Jp,{repo:P,startIndex:F,review:!0,viewedPaths:ne,onToggleViewed:re,hunkScopeKey:te})]})}),!ye&&(0,H.jsx)(cm,{})]})})})}var Em=`modulepreload`,Dm=function(e){return`/`+e},Om={},km=function(e){return e.pathname.endsWith(`.css`)},Am=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,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}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Dm(t,n);let r=s(t);if(r.href in Om)return;Om[r.href]=!0;let i=km(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Em,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}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)})},jm=()=>Am(()=>import(`./PtyView-M4b0GFVs.js`),__vite__mapDeps([0,1])),Mm=(0,_.lazy)(()=>jm().then(e=>({default:e.PtyView})));function Nm(){jm().catch(()=>{})}function Pm(e){return(0,H.jsx)(_.Suspense,{fallback:(0,H.jsx)(`div`,{className:`wd-term-loading`,"aria-busy":`true`}),children:(0,H.jsx)(Mm,{...e})})}function Fm(e,t,n){let r=!!e.archivedAt,i=r?[]:[{label:`Open in terminal`,hint:Lt(`terminal`),run:n.openTerminal},{label:`Ship (push, PR, merge)…`,hint:Lt(`ship`),run:n.ship}],a=r||!t||t.port===null||!t.command&&!t.running?[]:[t.running?{label:`Stop dev server`,hint:`:${t.port} · ${Lt(`dev`)}`,run:n.devStop}:{label:`Start dev server`,hint:`:${t.port} · ${Lt(`dev`)}`,run:n.devStart}];return[...i,{label:`Catch me up`,hint:Lt(`catchup`),run:n.catchUp},...r?[]:[{label:`Send a prompt…`,hint:Lt(`prompt`),run:n.sendPrompt}],{label:e.hasNote?`Notes •`:`Notes`,hint:Lt(`notes`),run:n.notes},...a,{label:`Rename`,hint:`F2`,run:n.rename,separated:!0},{label:`Delete…`,hint:Lt(`delete`),run:n.remove,danger:!0}]}function Im(e){let t=e.context;if(!(!t||t.window<=0))return`Context ${Math.round(Math.min(1,t.used/t.window)*100)}% · ${Xs(t.used)} of ${Xs(t.window)} tokens`}function Lm({session:e,subTab:t,onSelectSubTab:n,onDelete:r,prs:i=[],onShipped:a,startOnLastTurn:o=!1,onOpenSession:s,onTermSlot:c}){let l=e.diffStat?.files??0;return(0,H.jsxs)(`div`,{className:`wd-session-detail`,children:[(0,H.jsx)(Rm,{session:e,prs:i,onDelete:r,onShipped:a,onOpenSession:s},e.id),(0,H.jsxs)(`nav`,{className:`wd-session-subtabs`,role:`tablist`,children:[(0,H.jsx)(Vm,{label:`Terminal`,active:t===`term`,onClick:()=>n(`term`)}),(0,H.jsx)(Vm,{label:`Diff`,meta:l?`${l} file${l===1?``:`s`}`:void 0,active:t===`diff`,badge:e.commentCount,onClick:()=>n(`diff`)}),(0,H.jsx)(Vm,{label:`Timeline`,active:t===`timeline`,onClick:()=>n(`timeline`)})]}),(0,H.jsxs)(`div`,{className:`wd-session-subtab-body`,children:[t===`diff`&&(0,H.jsx)(Tm,{session:e,startOnLastTurn:o}),t===`term`&&(c?(0,H.jsx)(`div`,{className:`wd-term-slot`,ref:c}):(0,H.jsx)(Pm,{sessionId:e.id,target:e.target,branch:e.branch})),t===`timeline`&&(0,H.jsxs)(`div`,{className:`wd-timeline-tab`,children:[(0,H.jsx)(`div`,{className:`wd-timeline-head`,children:(0,H.jsx)(Ol,{session:e})}),(0,H.jsx)(vl,{session:e})]})]})]})}function Rm({session:e,prs:t,onDelete:n,onShipped:r,onOpenSession:i}){let a=pt(e),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(0),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useCallback)(e=>b(e),[]),E=(0,_.useCallback)(e=>S(e),[]),D=Gl(e.id),O=Al(e.id),k=ru([y,x]),A=k!==null&&!C,j=()=>{v({text:`Opening in a terminal…`}),ln(e.id).then(()=>v(null),e=>v({text:e.message,error:!0}))},M=(0,_.useRef)(null),N=(0,_.useRef)(()=>{});N.current=e=>{let t=!a;if(e===`menu`){let e=M.current?.getBoundingClientRect();e&&s({x:e.right,y:e.bottom+4})}else e===`prompt`&&t?p(!0):e===`catchup`?O.run():e===`notes`?d(e=>!e):e===`ship`&&t?l(!0):e===`terminal`&&t?j():e===`dev`&&t&&D.state?.port!=null&&(D.state.command||D.state.running)&&D.act(D.state.running?`stop`:`start`)},(0,_.useEffect)(()=>{let t=t=>{let n=t.detail;n?.id===e.id&&N.current(n.action)};return window.addEventListener(zt,t),()=>window.removeEventListener(zt,t)},[e.id]);let P=Fm(e,D.state,{openTerminal:j,ship:()=>l(!0),catchUp:O.run,sendPrompt:()=>p(!0),notes:()=>d(e=>!e),devStart:()=>D.act(`start`),devStop:()=>D.act(`stop`),rename:()=>h(e=>e+1),remove:n});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`header`,{className:`wd-session-detail-header`,children:[(0,H.jsxs)(`h1`,{children:[(0,H.jsx)(`span`,{className:`wd-session-detail-target`,children:e.target}),(0,H.jsx)(`span`,{className:`wd-session-detail-sep`,children:`/`}),(0,H.jsx)(`span`,{className:`wd-session-detail-branch`,children:e.branch}),(0,H.jsx)(lc,{session:e}),(0,H.jsx)(zm,{session:e,autoEdit:m>0},m)]}),a&&(0,H.jsx)(`span`,{className:`wd-archived-pill`,children:`archived`}),(0,H.jsxs)(`div`,{className:`wd-session-actions`,children:[g&&(0,H.jsx)(`span`,{className:`wd-session-action-note`+(g.error?` wd-session-action-note-error`:``),role:g.error?`alert`:`status`,children:g.text}),(0,H.jsx)(Ul,{session:e,open:f,onOpenChange:p}),(0,H.jsx)(Bm,{sessionId:e.id,archived:a}),(0,H.jsx)(`button`,{ref:M,type:`button`,className:`wd-session-more`,"aria-label":`More actions`,"aria-haspopup":`menu`,"aria-expanded":o!==null,title:`More actions`,onMouseDown:e=>{o&&e.stopPropagation()},onClick:e=>{if(o)return s(null);let t=e.currentTarget.getBoundingClientRect();s({x:t.right,y:t.bottom+4})},children:`⋯`})]})]}),o&&(0,H.jsx)(Qa,{x:o.x,y:o.y,anchor:`right`,items:P,footer:Im(e),onClose:()=>s(null)}),(0,H.jsxs)(`div`,{className:`wd-session-strip`,children:[(0,H.jsx)(sc,{session:e}),(0,H.jsx)(Ml,{session:e,catchUp:O}),(0,H.jsx)(Ks,{session:e}),(0,H.jsx)(Js,{session:e}),(0,H.jsx)(ac,{session:e,onOpen:i}),(0,H.jsx)(bl,{session:e,onOpen:i}),(0,H.jsx)(oc,{session:e,onOpen:i}),(0,H.jsx)(ic,{session:e,quiet:!0}),(0,H.jsx)(nc,{session:e,quiet:!0}),e.prStage?(0,H.jsx)(Qs,{session:e,prs:t}):(0,H.jsx)(ec,{prs:t,link:!0}),(0,H.jsx)(Kl,{dev:D}),(e.hasNote||u)&&(0,H.jsx)(Cl,{session:e,open:u,onToggle:()=>d(e=>!e)})]}),(0,H.jsx)(Nl,{catchUp:O}),u&&(0,H.jsx)(wl,{session:e,onClose:()=>d(!1)}),k&&(0,H.jsx)(iu,{text:k,open:C,onToggle:()=>w(e=>!e)}),(0,H.jsx)(eu,{sessionId:e.id,onNeeds:T,hidden:A}),(0,H.jsx)(Xl,{sessionId:e.id,isGroup:e.isGroup,onNeeds:E,hidden:A}),c&&(0,H.jsx)(Rl,{session:e,onClose:()=>l(!1),onMerged:()=>{l(!1),r?.()}})]})}function zm({session:e,autoEdit:t=!1}){let[n,r]=(0,_.useState)(t),[i,a]=(0,_.useState)(()=>t&&e.titleIsYours?e.title??``:``),[o,s]=(0,_.useState)(!1),c=()=>{a(e.titleIsYours?e.title??``:``),r(!0)},l=async()=>{s(!0);try{await ve(e.id,i),r(!1)}finally{s(!1)}};return n?(0,H.jsx)(`input`,{className:`wd-session-title-input`,autoFocus:!0,value:i,disabled:o,placeholder:e.title??`Name this session`,"aria-label":`Session name`,onChange:e=>a(e.target.value),onBlur:()=>r(!1),onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&r(!1)}}):!e.titleIsYours||!e.title?null:(0,H.jsx)(`button`,{type:`button`,className:`wd-session-title`,title:`Your name for it — click to rename`,onClick:c,children:e.title})}function Bm({sessionId:e,archived:t}){let n=S(e),r=n!==void 0,[i,a]=(0,_.useState)(null);return(0,H.jsx)(`button`,{type:`button`,className:`wd-session-archive`,onClick:()=>{a(null),T(e,!t).catch(e=>a(e.message))},disabled:r,title:i??(t?`Bring it back to the rail and inbox`:`Stop its Claude and hide it; worktree, branch and conversation are kept`),children:r?n?`Archiving…`:`Restoring…`:t?`Restore`:i?`Archive ⚠`:`Archive`})}function Vm({label:e,active:t,onClick:n,meta:r,badge:i}){return(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`wd-session-subtab`+(t?` wd-session-subtab-active`:``),onClick:n,children:[e,r&&(0,H.jsxs)(`span`,{className:`wd-session-subtab-meta`,children:[`· `,r]}),i?(0,H.jsx)(`span`,{className:`wd-session-subtab-badge`,title:`${i} comment${i===1?``:`s`}`,children:i}):null]})}function Hm(e){return Ts(e)}function Um(e){if(!e.isMine)return[`Review PR #${e.number}: ${e.title}`,e.url,``,`It isn't mine: read what it changes (gh pr diff ${e.number}), run what's useful to check it, and tell me what you'd comment and why.`,`Don't commit, push or post anything on GitHub.`].join(`
|
|
111
|
+
`)[0]})]})}function rm(e){if(e.side===`general`){let e=document.querySelector(`.wd-general-pane`),t=e?.querySelector(`details`);t&&!t.open&&(t.open=!0),e?.scrollIntoView({behavior:`smooth`,block:`start`});return}let t=document.querySelector(`article.wd-file[data-path="${am(e.file)}"]`);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),e.side!==`file`&&im(t,e.line,e.side))}function im(e,t,n){let r=e.querySelectorAll(n===`right`?`.wd-ln-new`:`.wd-ln-old`);for(let e of r)if(e.textContent?.trim()===String(t)){let t=e.closest(`tr`);if(t){t.classList.add(`wd-row-flash`),setTimeout(()=>t.classList.remove(`wd-row-flash`),1200);let e=t.nextElementSibling;e?.classList.contains(`wd-comment-row`)&&e.scrollIntoView({behavior:`smooth`,block:`center`})}break}}function am(e){return e.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,`\\$&`)}function om(){let e=mu(),[t,n]=(0,_.useState)(``),r=e.comments.filter(e=>e.side===`general`&&!e.parentId);async function i(r){let i=t.trim();i&&(await e.postComment({side:`general`,body:i,status:r}),n(``))}return(0,H.jsx)(`section`,{className:`wd-general-pane`,children:(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:`General review note (not tied to any line)`}),(0,H.jsx)(`textarea`,{className:`wd-general-input`,placeholder:`A high-level comment for Claude…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),i(`published`))}}),(0,H.jsxs)(`div`,{className:`wd-general-pane-actions`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,disabled:!t.trim(),onClick:()=>i(`draft`),children:e.comments.some(e=>e.status===`draft`)?`Add to review`:`Start review`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,disabled:!t.trim(),onClick:()=>i(`published`),children:`Comment (Ctrl+Enter)`})]}),r.length>0&&(0,H.jsx)(`div`,{className:`wd-general-pane-list`,children:r.map(e=>(0,H.jsx)(cp,{comment:e,currentLineContent:null},e.id))})]})})}function sm({title:e,children:t,actions:n,onClose:r,primaryRef:i}){let a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,_.useEffect)(()=>{if(i?.current){i.current.focus();return}(a.current?.querySelector(`.wd-btn-primary`))?.focus()},[i]),(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,ref:a,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,H.jsxs)(`div`,{className:`wd-modal`,children:[(0,H.jsx)(`h2`,{children:e}),t,(0,H.jsx)(`div`,{className:`wd-modal-actions`,children:n})]})})}function cm(){let e=mu(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(``),a=gu(e.comments);return a.length===0?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-pending-pill wd-visible`,onClick:()=>{i(``),n(!0)},children:[`Pending review `,(0,H.jsxs)(`span`,{className:`wd-pending-count`,children:[`(`,a.length,`)`]})]}),t&&(0,H.jsxs)(sm,{title:`Submit your review`,onClose:()=>n(!1),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:async()=>{confirm(`Discard all ${a.length} pending comment(s)?`)&&(await e.discardReview(),n(!1))},children:`Discard drafts`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:async()=>{try{await e.submitReview(r),n(!1)}catch{}},children:`Submit review`})]}),children:[(0,H.jsxs)(`p`,{children:[`Sending `,a.length,` pending comment`,a.length===1?``:`s`,`. Add a summary if you like, then click Submit to send everything to Claude.`]}),(0,H.jsx)(`textarea`,{className:`wd-submit-summary`,placeholder:`Optional summary…`,value:r,onChange:e=>i(e.target.value)})]})]})}var lm=Lp(`work-web:viewed-files`);function um(e,t,n){lm.set(e,t,n)}function dm(e){return lm.readScope(e)}function fm(e,t){let n=new Set;for(let r of e){let e=r.lastIndexOf(`#`);if(e<0){n.add(r);continue}let i=r.slice(0,e);(!t||t.get(i)===r.slice(e+1))&&n.add(i)}return n}function pm(e,t,n){let[r,i]=(0,_.useState)(()=>dm(e));(0,_.useEffect)(()=>{i(dm(e))},[e]);let a=(0,_.useMemo)(()=>fm(r,n),[r,n]),o=(0,_.useCallback)((t,r)=>{for(let n of dm(e))(n===t||n.startsWith(`${t}#`))&&um(e,n,!1);let a=n?.get(t);r&&um(e,a?`${t}#${a}`:t,!0),i(dm(e))},[e,n]),s=new Set;for(let e of a){let n=t.get(e);n&&s.add(n)}return{viewedPaths:a,viewedAnchors:s,toggle:o}}var mm=`.wd-comment-row`;function hm(e){let t=(0,_.useRef)(null);(0,_.useEffect)(()=>{let n=n=>{if(n.key!==`]`&&n.key!==`[`||n.metaKey||n.ctrlKey||n.altKey)return;let r=document.activeElement;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.tagName===`SELECT`||r.isContentEditable))return;let i=e.current;if(!i)return;let a=[...i.querySelectorAll(mm)];if(a.length===0)return;n.preventDefault();let o=t.current?a.indexOf(t.current):-1,s=n.key===`]`?a[o<0?0:(o+1)%a.length]:a[o<0?a.length-1:(o-1+a.length)%a.length];t.current=s,s.scrollIntoView?.({behavior:`smooth`,block:`center`}),s.classList.add(`wd-row-flash`),setTimeout(()=>s.classList.remove(`wd-row-flash`),1200)};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e])}function gm(e,t,n,r){let i=e+t;return e<r?e-r:i>n-r?i-(n-r):0}function _m(e,t,n){(0,_.useEffect)(()=>{if(!n||!t)return;let r=e.current;if(!r)return;let i=r.querySelector(`.wd-tree-file-active`);if(!i)return;let a=i.getBoundingClientRect().top-r.getBoundingClientRect().top;r.scrollTop+=gm(a,i.offsetHeight,r.clientHeight,24)},[t,n])}function vm(e){let[t,n]=(0,_.useState)(null);return(0,_.useEffect)(()=>{function e(){let e=Array.from(document.querySelectorAll(`article.wd-file`)).filter(e=>e.isConnected);if(e.length===0){n(null);return}let t=null;for(let n of e)if(n.getBoundingClientRect().top<=80)t=n;else break;n((t??e[0]).id)}let t=!1;function r(){t||(t=!0,requestAnimationFrame(()=>{t=!1,e()}))}e(),window.addEventListener(`scroll`,r,{passive:!0,capture:!0}),window.addEventListener(`resize`,r);let i=typeof MutationObserver>`u`?null:new MutationObserver(r),a=document.querySelector(`.wd-web-review-main`)??document.body;return i?.observe(a,{childList:!0,subtree:!0}),()=>{window.removeEventListener(`scroll`,r,{capture:!0}),window.removeEventListener(`resize`,r),i?.disconnect()}},[e]),t}var ym=()=>document.visibilityState===`visible`&&document.hasFocus();function bm(e,t,n,r=1e3){let i=(0,_.useRef)(n);i.current=n,(0,_.useEffect)(()=>{if(e===null)return;let n=0,a=setInterval(()=>{ym()&&(n+=r,n>=t&&(clearInterval(a),i.current()))},r);return()=>clearInterval(a)},[e,t,r])}function xm(e){return e.length?Math.max(...e.map(e=>e.id)):null}function Sm(e,t){let n=xm(t);return!!e&&n!==null&&n>e.checkpointId}function Cm(e){let t=5381;for(let n of e.hunks)for(let e of n.lines){let n=`${e.kind}${e.content}`;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e)|0}return`${e.added}.${e.deleted}.${(t>>>0).toString(36)}`}var wm=5e3;function Tm({session:e,startOnLastTurn:t=!1}){let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(`uncommitted`),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)([]),u=(0,_.useMemo)(()=>R(c),[c]),d=o===null?null:u.find(e=>e.to===o)??null,f=(0,_.useRef)(e.id);f.current=e.id;let p=()=>{let t=e.id,n=e=>{f.current===t&&l(e)};de(t).then(n,()=>n([]))},[m,h]=(0,_.useState)(void 0),[g,v]=(0,_.useState)(!1);(0,_.useEffect)(()=>{s(null),l([]),h(void 0),v(!1),p();let t=e.id;ce(t).then(e=>f.current===t&&h(e),()=>f.current===t&&h(null))},[e.id]);let y=xm(c),b=Sm(m,c),x=(0,_.useRef)(null);(0,_.useEffect)(()=>{t||m===void 0||c.length===0||x.current===e.id||(x.current=e.id,b&&v(!0))},[t,m,c.length,b,e.id]),bm(y===null?null:`${e.id}:${y}`,wm,()=>{y!==null&&le(e.id,y).catch(()=>{})});let S=(0,_.useRef)(null);(0,_.useEffect)(()=>{t&&S.current!==e.id&&u.length!==0&&(S.current=e.id,s(u[0].to))},[t,e.id,u]);let{data:C,error:w,loading:T,checking:E,pending:D,stale:O,applyPending:k,reload:A,checkForUpdates:j}=du(()=>g&&m?ue(e.id,`uncommitted`,{from:m.checkpointId,to:`working`}):d?ue(e.id,`uncommitted`,{from:d.from,to:d.to}):ue(e.id,i),[e.id,i,d?.from,d?.to,g,m?.checkpointId]);Xa(`/events?session=${encodeURIComponent(e.id)}`,{events:{"diff-changed":()=>j(),"checkpoints-changed":()=>p()}});let M=(0,_.useMemo)(()=>lu(e.id),[e.id]);(0,_.useEffect)(()=>{C&&C.repos.length!==0&&(C.repos.some(e=>e.name===n)||r(C.repos[0].name))},[C,n]);let N=(0,_.useMemo)(()=>{let e=new Map,t=0;if(C)for(let n of C.repos)e.set(n.name,t),t+=n.files.length;return e},[C]),P=(0,_.useMemo)(()=>!C||C.repos.length===0?null:C.repos.find(e=>e.name===n)??C.repos[0],[C,n]),F=P?N.get(P.name)??0:0,I=(0,_.useMemo)(()=>{let e=new Map;return P&&P.files.forEach((t,n)=>{e.set(t.path,`wd-file-${F+n}`)}),e},[P,F]),ee=P?`session:${e.id}:${P.name}`:`session:${e.id}:_pending`,te=P?`session:${e.id}:${P.name}:hunks`:``,{viewedPaths:ne,viewedAnchors:L,toggle:re}=pm(ee,I,(0,_.useMemo)(()=>new Map((P?.files??[]).map(e=>[e.path,Cm(e)])),[P])),ie=vm(`${e.id}:${P?.name??`_pending`}`),{width:ae,setWidth:oe}=Tc(),{size:se,setSize:z}=wc(xc),B=(0,_.useRef)(null),fe=(0,_.useRef)(null),pe=(0,_.useRef)(null);hm(pe);let me=()=>{A(),pe.current?.scrollTo({top:0})},he=(0,_.useRef)(null);_m(he,ie,!0);let V=!g&&!d&&i===`uncommitted`,ge=(0,_.useMemo)(()=>V?{revert:async(t,n,r)=>{await Fe(e.id,{repo:t,path:n,lines:r}),A()}}:null,[V,e.id,A]);if(w)return(0,H.jsx)(`div`,{className:`wd-web-error`,children:w});if(!C)return(0,H.jsx)(`div`,{className:`wd-web-empty`,children:`Loading diff…`});let _e=C.repos.reduce((e,t)=>e+t.files.length,0),ve=D?D.repos.reduce((e,t)=>e+t.files.length,0):null,ye=_e===0||!P,be=C.repos.length>1,xe;return xe=g?`Nothing changed since you last looked.`:d?`This turn changed no files.`:i===`uncommitted`?`No uncommitted changes.`:!C.resolvedBase||C.resolvedBase===`HEAD`?"Couldn't auto-detect this branch's parent. Tried main, master, dev, develop (and their origin/* mirrors). Record an explicit base via `work tree --base <ref>` to fix.":`No commits since \`${C.resolvedBase}\` — this branch is up to date or already merged.`,(0,H.jsx)(pu,{api:M,children:(0,H.jsx)(xu.Provider,{value:ge,children:(0,H.jsxs)(`div`,{ref:B,className:`wd-web-review-layout`,style:{"--sidebar-width":`${ae}px`},children:[(0,H.jsxs)(`aside`,{ref:fe,className:`wd-web-review-sidebar wd-web-review-sidebar-split`,style:{[xc.cssVar]:`${se}px`},children:[(0,H.jsxs)(`header`,{className:`wd-web-review-sidebar-header`,children:[(0,H.jsxs)(`h1`,{children:[e.target,(0,H.jsxs)(`span`,{className:`wd-web-branch`,children:[` · `,e.branch]})]}),(0,H.jsxs)(`p`,{children:[O?(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`loading…`}):ye?(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`no changes`}):(0,H.jsxs)(H.Fragment,{children:[_e,` file`,_e===1?``:`s`,` changed`,be?` across ${C.repos.length} repos`:``]}),C.base===`branch`&&C.resolvedBase&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsxs)(`span`,{className:`wd-web-muted`,children:[`vs `,C.resolvedBase]})]})]}),(0,H.jsxs)(`div`,{className:`wd-web-diff-scope`,role:`tablist`,"aria-label":`Diff scope`,children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!d&&i===`uncommitted`,className:`wd-web-diff-scope-btn`+(!g&&!d&&i===`uncommitted`?` wd-web-diff-scope-btn-active`:``),onClick:()=>{v(!1),s(null),a(`uncommitted`)},title:`git diff HEAD — only the working-tree deltas`,children:`Uncommitted`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!d&&i===`branch`,className:`wd-web-diff-scope-btn`+(!g&&!d&&i===`branch`?` wd-web-diff-scope-btn-active`:``),onClick:()=>{v(!1),s(null),a(`branch`)},title:e.baseBranch?`git diff ${e.baseBranch} — everything since this branch was created`:`Everything since this worktree's parent branch — auto-detected`,children:`Since branch`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!g&&!!d,className:`wd-web-diff-scope-btn`+(!g&&d?` wd-web-diff-scope-btn-active`:``),disabled:u.length===0,onClick:()=>{v(!1),s(u[0]?.to??null)},title:u.length?`Only what Claude's last instruction changed`:`No finished turn yet — appears after Claude finishes one`,children:`Last turn`}),(b||g)&&m&&(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g,className:`wd-web-diff-scope-btn`+(g?` wd-web-diff-scope-btn-active`:``),onClick:()=>v(!0),title:`Everything that changed after you last looked at this diff (${J(m.at)}${J(m.at)===`just now`?``:` ago`}), over every turn since`,children:`Since you looked`})]}),!g&&d&&u.length>1&&(0,H.jsxs)(`label`,{className:`wd-web-turn-pick`,children:[(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`Turn`}),` `,(0,H.jsx)(`select`,{value:d.to,onChange:e=>s(Number(e.target.value)),"aria-label":`Which turn`,children:u.map(e=>(0,H.jsxs)(`option`,{value:e.to,children:[e.n,e.label?` · ${e.label}`:``]},e.to))})]}),!g&&d&&u.length===1&&d.label&&(0,H.jsx)(`p`,{className:`wd-web-turn-label wd-web-muted`,children:d.label}),(0,H.jsx)(Zp,{}),D&&(0,H.jsx)(Xp,{filesChanged:ve,onShow:k,onReload:me}),(O||T||E&&!D)&&(0,H.jsx)(Yp,{label:O||T?`loading…`:`checking…`})]}),!ye&&P?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:he,className:`wd-sidebar-split-top`+(O?` wd-diff-stale`:``),inert:O,children:(0,H.jsx)($p,{files:P.files,startIndex:F,selectedAnchor:ie,viewedAnchors:L})}),(0,H.jsx)(Ec,{layoutRef:fe,size:se,onCommit:z,spec:xc}),(0,H.jsx)(`div`,{className:`wd-sidebar-split-bottom`,children:(0,H.jsx)(tm,{repoName:P.name,onOpenRepo:r})})]}):(0,H.jsx)(`div`,{className:`wd-sidebar-split-bottom wd-sidebar-comments-only`,children:(0,H.jsx)(tm,{})})]}),(0,H.jsx)(Ec,{layoutRef:B,size:ae,onCommit:oe}),(0,H.jsx)(`main`,{ref:pe,className:`wd-web-review-main`+(O?` wd-diff-stale`:``),"aria-busy":T||O,inert:O,style:{"--tabs-offset":be?`36px`:`0px`},children:ye||!P?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(om,{}),(0,H.jsxs)(`div`,{className:`wd-web-empty wd-web-empty-diff`,children:[(0,H.jsx)(`p`,{children:xe}),!d&&i===`uncommitted`&&(0,H.jsxs)(`p`,{className:`wd-web-empty-hint`,children:[`Try`,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-web-link-btn`,onClick:()=>a(`branch`),children:`Since branch`}),` `,`to see everything in this worktree.`]})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(om,{}),be&&(0,H.jsx)(`nav`,{className:`wd-web-repo-tabs`,children:C.repos.map(e=>{let t=e.files.reduce((e,t)=>e+t.added,0),n=e.files.reduce((e,t)=>e+t.deleted,0);return(0,H.jsxs)(`button`,{type:`button`,className:`wd-web-repo-tab`+(e.name===P.name?` wd-web-repo-tab-active`:``),onClick:()=>r(e.name),children:[e.name,` `,(0,H.jsxs)(`span`,{className:`wd-web-tab-count`,children:[`(`,e.files.length,`)`]}),` `,(0,H.jsxs)(`span`,{className:`wd-tab-stats`,children:[(0,H.jsxs)(`span`,{className:`wd-add`,children:[`+`,t]}),` `,(0,H.jsxs)(`span`,{className:`wd-del`,children:[`-`,n]})]})]},e.name)})}),(0,H.jsx)(Jp,{repo:P,startIndex:F,review:!0,viewedPaths:ne,onToggleViewed:re,hunkScopeKey:te})]})}),!ye&&(0,H.jsx)(cm,{})]})})})}var Em=`modulepreload`,Dm=function(e){return`/`+e},Om={},km=function(e){return e.pathname.endsWith(`.css`)},Am=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,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}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Dm(t,n);let r=s(t);if(r.href in Om)return;Om[r.href]=!0;let i=km(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:Em,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}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)})},jm=()=>Am(()=>import(`./PtyView-DYvawzWb.js`),__vite__mapDeps([0,1])),Mm=(0,_.lazy)(()=>jm().then(e=>({default:e.PtyView})));function Nm(){jm().catch(()=>{})}function Pm(e){return(0,H.jsx)(_.Suspense,{fallback:(0,H.jsx)(`div`,{className:`wd-term-loading`,"aria-busy":`true`}),children:(0,H.jsx)(Mm,{...e})})}function Fm(e,t,n){let r=!!e.archivedAt,i=r?[]:[{label:`Open in terminal`,hint:Lt(`terminal`),run:n.openTerminal},{label:`Ship (push, PR, merge)…`,hint:Lt(`ship`),run:n.ship}],a=r||!t||t.port===null||!t.command&&!t.running?[]:[t.running?{label:`Stop dev server`,hint:`:${t.port} · ${Lt(`dev`)}`,run:n.devStop}:{label:`Start dev server`,hint:`:${t.port} · ${Lt(`dev`)}`,run:n.devStart}];return[...i,{label:`Catch me up`,hint:Lt(`catchup`),run:n.catchUp},...r?[]:[{label:`Send a prompt…`,hint:Lt(`prompt`),run:n.sendPrompt}],{label:e.hasNote?`Notes •`:`Notes`,hint:Lt(`notes`),run:n.notes},...a,{label:`Rename`,hint:`F2`,run:n.rename,separated:!0},{label:`Delete…`,hint:Lt(`delete`),run:n.remove,danger:!0}]}function Im(e){let t=e.context;if(!(!t||t.window<=0))return`Context ${Math.round(Math.min(1,t.used/t.window)*100)}% · ${Xs(t.used)} of ${Xs(t.window)} tokens`}function Lm({session:e,subTab:t,onSelectSubTab:n,onDelete:r,prs:i=[],onShipped:a,startOnLastTurn:o=!1,onOpenSession:s,onTermSlot:c}){let l=e.diffStat?.files??0;return(0,H.jsxs)(`div`,{className:`wd-session-detail`,children:[(0,H.jsx)(Rm,{session:e,prs:i,onDelete:r,onShipped:a,onOpenSession:s},e.id),(0,H.jsxs)(`nav`,{className:`wd-session-subtabs`,role:`tablist`,children:[(0,H.jsx)(Vm,{label:`Terminal`,active:t===`term`,onClick:()=>n(`term`)}),(0,H.jsx)(Vm,{label:`Diff`,meta:l?`${l} file${l===1?``:`s`}`:void 0,active:t===`diff`,badge:e.commentCount,onClick:()=>n(`diff`)}),(0,H.jsx)(Vm,{label:`Timeline`,active:t===`timeline`,onClick:()=>n(`timeline`)})]}),(0,H.jsxs)(`div`,{className:`wd-session-subtab-body`,children:[t===`diff`&&(0,H.jsx)(Tm,{session:e,startOnLastTurn:o}),t===`term`&&(c?(0,H.jsx)(`div`,{className:`wd-term-slot`,ref:c}):(0,H.jsx)(Pm,{sessionId:e.id,target:e.target,branch:e.branch})),t===`timeline`&&(0,H.jsxs)(`div`,{className:`wd-timeline-tab`,children:[(0,H.jsx)(`div`,{className:`wd-timeline-head`,children:(0,H.jsx)(Ol,{session:e})}),(0,H.jsx)(vl,{session:e})]})]})]})}function Rm({session:e,prs:t,onDelete:n,onShipped:r,onOpenSession:i}){let a=pt(e),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(0),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useCallback)(e=>b(e),[]),E=(0,_.useCallback)(e=>S(e),[]),D=Gl(e.id),O=Al(e.id),k=ru([y,x]),A=k!==null&&!C,j=()=>{v({text:`Opening in a terminal…`}),ln(e.id).then(()=>v(null),e=>v({text:e.message,error:!0}))},M=(0,_.useRef)(null),N=(0,_.useRef)(()=>{});N.current=e=>{let t=!a;if(e===`menu`){let e=M.current?.getBoundingClientRect();e&&s({x:e.right,y:e.bottom+4})}else e===`prompt`&&t?p(!0):e===`catchup`?O.run():e===`notes`?d(e=>!e):e===`ship`&&t?l(!0):e===`terminal`&&t?j():e===`dev`&&t&&D.state?.port!=null&&(D.state.command||D.state.running)&&D.act(D.state.running?`stop`:`start`)},(0,_.useEffect)(()=>{let t=t=>{let n=t.detail;n?.id===e.id&&N.current(n.action)};return window.addEventListener(zt,t),()=>window.removeEventListener(zt,t)},[e.id]);let P=Fm(e,D.state,{openTerminal:j,ship:()=>l(!0),catchUp:O.run,sendPrompt:()=>p(!0),notes:()=>d(e=>!e),devStart:()=>D.act(`start`),devStop:()=>D.act(`stop`),rename:()=>h(e=>e+1),remove:n});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`header`,{className:`wd-session-detail-header`,children:[(0,H.jsxs)(`h1`,{children:[(0,H.jsx)(`span`,{className:`wd-session-detail-target`,children:e.target}),(0,H.jsx)(`span`,{className:`wd-session-detail-sep`,children:`/`}),(0,H.jsx)(`span`,{className:`wd-session-detail-branch`,children:e.branch}),(0,H.jsx)(lc,{session:e}),(0,H.jsx)(zm,{session:e,autoEdit:m>0},m)]}),a&&(0,H.jsx)(`span`,{className:`wd-archived-pill`,children:`archived`}),(0,H.jsxs)(`div`,{className:`wd-session-actions`,children:[g&&(0,H.jsx)(`span`,{className:`wd-session-action-note`+(g.error?` wd-session-action-note-error`:``),role:g.error?`alert`:`status`,children:g.text}),(0,H.jsx)(Ul,{session:e,open:f,onOpenChange:p}),(0,H.jsx)(Bm,{sessionId:e.id,archived:a}),(0,H.jsx)(`button`,{ref:M,type:`button`,className:`wd-session-more`,"aria-label":`More actions`,"aria-haspopup":`menu`,"aria-expanded":o!==null,title:`More actions`,onMouseDown:e=>{o&&e.stopPropagation()},onClick:e=>{if(o)return s(null);let t=e.currentTarget.getBoundingClientRect();s({x:t.right,y:t.bottom+4})},children:`⋯`})]})]}),o&&(0,H.jsx)(Qa,{x:o.x,y:o.y,anchor:`right`,items:P,footer:Im(e),onClose:()=>s(null)}),(0,H.jsxs)(`div`,{className:`wd-session-strip`,children:[(0,H.jsx)(sc,{session:e}),(0,H.jsx)(Ml,{session:e,catchUp:O}),(0,H.jsx)(Ks,{session:e}),(0,H.jsx)(Js,{session:e}),(0,H.jsx)(ac,{session:e,onOpen:i}),(0,H.jsx)(bl,{session:e,onOpen:i}),(0,H.jsx)(oc,{session:e,onOpen:i}),(0,H.jsx)(ic,{session:e,quiet:!0}),(0,H.jsx)(nc,{session:e,quiet:!0}),e.prStage?(0,H.jsx)(Qs,{session:e,prs:t}):(0,H.jsx)(ec,{prs:t,link:!0}),(0,H.jsx)(Kl,{dev:D}),(e.hasNote||u)&&(0,H.jsx)(Cl,{session:e,open:u,onToggle:()=>d(e=>!e)})]}),(0,H.jsx)(Nl,{catchUp:O}),u&&(0,H.jsx)(wl,{session:e,onClose:()=>d(!1)}),k&&(0,H.jsx)(iu,{text:k,open:C,onToggle:()=>w(e=>!e)}),(0,H.jsx)(eu,{sessionId:e.id,onNeeds:T,hidden:A}),(0,H.jsx)(Xl,{sessionId:e.id,isGroup:e.isGroup,onNeeds:E,hidden:A}),c&&(0,H.jsx)(Rl,{session:e,onClose:()=>l(!1),onMerged:()=>{l(!1),r?.()}})]})}function zm({session:e,autoEdit:t=!1}){let[n,r]=(0,_.useState)(t),[i,a]=(0,_.useState)(()=>t&&e.titleIsYours?e.title??``:``),[o,s]=(0,_.useState)(!1),c=()=>{a(e.titleIsYours?e.title??``:``),r(!0)},l=async()=>{s(!0);try{await ve(e.id,i),r(!1)}finally{s(!1)}};return n?(0,H.jsx)(`input`,{className:`wd-session-title-input`,autoFocus:!0,value:i,disabled:o,placeholder:e.title??`Name this session`,"aria-label":`Session name`,onChange:e=>a(e.target.value),onBlur:()=>r(!1),onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&r(!1)}}):!e.titleIsYours||!e.title?null:(0,H.jsx)(`button`,{type:`button`,className:`wd-session-title`,title:`Your name for it — click to rename`,onClick:c,children:e.title})}function Bm({sessionId:e,archived:t}){let n=S(e),r=n!==void 0,[i,a]=(0,_.useState)(null);return(0,H.jsx)(`button`,{type:`button`,className:`wd-session-archive`,onClick:()=>{a(null),T(e,!t).catch(e=>a(e.message))},disabled:r,title:i??(t?`Bring it back to the rail and inbox`:`Stop its Claude and hide it; worktree, branch and conversation are kept`),children:r?n?`Archiving…`:`Restoring…`:t?`Restore`:i?`Archive ⚠`:`Archive`})}function Vm({label:e,active:t,onClick:n,meta:r,badge:i}){return(0,H.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`wd-session-subtab`+(t?` wd-session-subtab-active`:``),onClick:n,children:[e,r&&(0,H.jsxs)(`span`,{className:`wd-session-subtab-meta`,children:[`· `,r]}),i?(0,H.jsx)(`span`,{className:`wd-session-subtab-badge`,title:`${i} comment${i===1?``:`s`}`,children:i}):null]})}function Hm(e){return Ts(e)}function Um(e){if(!e.isMine)return[`Review PR #${e.number}: ${e.title}`,e.url,``,`It isn't mine: read what it changes (gh pr diff ${e.number}), run what's useful to check it, and tell me what you'd comment and why.`,`Don't commit, push or post anything on GitHub.`].join(`
|
|
112
112
|
`);let t=[`Continue on PR #${e.number}: ${e.title}`,e.url,``];return e.conflicting&&t.push(`It conflicts with its base branch. Bring the base in (git fetch, then merge it), resolve the conflicts, and run the tests.`),e.checksStatus===`FAILURE`&&t.push(`Its checks are failing. Find out why (gh pr checks, then the failing job logs) and fix them.`),e.reviewDecision===`CHANGES_REQUESTED`&&t.push(`Review asked for changes. Address the review comments (gh pr view ${e.number} --comments). Don't reply on GitHub.`),t.length===3&&t.push(`Get up to speed on what it changes (gh pr diff) and tell me where it stands.`),t.join(`
|
|
113
113
|
`)}function Wm({position:e,total:t,onNext:n,onStop:r}){return(0,H.jsxs)(`div`,{className:`wd-review-queue-bar`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-review-queue-title`,children:`Reviewing finished work`}),(0,H.jsxs)(`span`,{className:`wd-review-queue-pos`,children:[e,` of `,t]}),(0,H.jsx)(`span`,{className:`wd-review-queue-hint`,children:`Showing what the last instruction changed`}),(0,H.jsxs)(`span`,{className:`wd-review-queue-actions`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-primary wd-review-queue-next`,onClick:n,title:`Next in the queue (n)`,children:[e>=t?`Done`:`Next`,` `,(0,H.jsx)(`kbd`,{children:`n`})]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-row-action`,onClick:r,title:`Leave the queue; stay on this session`,children:`Stop`})]})]})}var Gm=`assistant`;function Km({open:e,onClose:t,seeing:n}){return(0,H.jsxs)(`aside`,{className:`wd-assistant`+(e?` wd-assistant-open`:``),"aria-label":`Assistant`,"aria-hidden":!e,children:[(0,H.jsxs)(`header`,{className:`wd-assistant-header`,children:[(0,H.jsx)(`span`,{className:`wd-assistant-title`,children:`Assistant`}),(0,H.jsxs)(`span`,{className:`wd-assistant-seeing`,title:`Each message you send includes this`,children:[`sees: `,n]}),(0,H.jsxs)(`span`,{className:`wd-assistant-keys`,children:[(0,H.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,H.jsx)(`kbd`,{children:`K`})]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-assistant-close`,onClick:t,"aria-label":`Close the assistant`,children:`×`})]}),(0,H.jsx)(`div`,{className:`wd-assistant-body`,children:(0,H.jsx)(Pm,{sessionId:Gm})})]})}function qm(e,t,n,r=5){let i=e.filter(e=>n.has(e)&&e!==t);return(t&&n.has(t)?[t,...i]:i).slice(0,r)}var Jm=6e5;function Ym(e,t,n,r,i=Jm){return e.filter(e=>e===t||r-(n.get(e)??r)<i)}function Xm({activeId:e,slot:t,sessions:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{let t=new Set(n.filter(e=>!e.archivedAt).map(e=>e.id));i(n=>{let r=qm(n,e,t);return r.length===n.length&&r.every((e,t)=>e===n[t])?n:r})},[e,n]);let s=(0,_.useRef)(new Map),c=t?e:null;if((0,_.useEffect)(()=>{let e=Date.now();for(let t of r)t===c?s.current.delete(t):s.current.has(t)||s.current.set(t,e);for(let e of[...s.current.keys()])r.includes(e)||s.current.delete(e)},[r,c]),(0,_.useEffect)(()=>{let e=setInterval(()=>{i(e=>{let t=Ym(e,c,s.current,Date.now());return t.length===e.length?e:t})},6e4);return()=>clearInterval(e)},[c]),(0,_.useLayoutEffect)(()=>{if(!t)return;let e=()=>{let e=t.getBoundingClientRect();o(t=>t&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.height===e.height?t:{top:e.top,left:e.left,width:e.width,height:e.height})};e();let n=typeof ResizeObserver<`u`?new ResizeObserver(e):null;return n?.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{n?.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[t]),r.length===0||!a)return null;let l=!!t&&!!e,u=new Map(n.map(e=>[e.id,e]));return(0,H.jsx)(`div`,{className:`wd-term-deck`,style:{top:a.top,left:a.left,width:a.width,height:a.height,visibility:l?`visible`:`hidden`},children:r.map(t=>{let n=l&&t===e,r=u.get(t);return(0,H.jsx)(`div`,{className:`wd-term-deck-item`,style:{visibility:n?`visible`:`hidden`},"aria-hidden":!n,children:(0,H.jsx)(Pm,{sessionId:t,target:r?.target,branch:r?.branch,active:n})},t)})})}function Zm(e){return!pt(e)&&e.attention?.state===`idle`&&!e.attention.seen}function Qm(e){let t=e.filter(Zm).sort((e,t)=>yo(e.attention,t.attention)).map(e=>e.id);return t.length?{ids:t}:null}function $m(e,t){let n=t?e.ids.indexOf(t):-1;return n<0?null:n+1}function eh(e,t,n){let r=new Set(n.filter(e=>!pt(e)).map(e=>e.id)),i=t?e.ids.indexOf(t):-1;for(let t=i+1;t<e.ids.length;t++)if(r.has(e.ids[t]))return e.ids[t];return null}function th(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>{let t=[e.name,...e.members??[],e.path??``].join(` `).toLowerCase();return n.every(e=>t.includes(e))})}function nh({projects:e,value:t,onChange:n,disabled:r,inputRef:i}){let a=(0,_.useId)(),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(0),f=(0,_.useMemo)(()=>th(e,o??``),[e,o]),p=e=>e.kind===`group`?`${e.name} (group)`:e.name,m=e.find(e=>e.name===t),h=e=>{e&&n(e.name),s(null),l(!1)};return(0,H.jsxs)(`div`,{className:`wd-project-picker`,children:[(0,H.jsx)(`input`,{ref:i,type:`text`,role:`combobox`,"aria-expanded":c,"aria-controls":a,"aria-autocomplete":`list`,"aria-activedescendant":c&&f[u]?`${a}-${u}`:void 0,value:o??(m?p(m):t),placeholder:e.length?`Type to find a project…`:`(loading…)`,disabled:r,onFocus:e=>{e.target.select(),l(!0)},onChange:e=>{s(e.target.value),d(0),l(!0)},onBlur:()=>{s(null),l(!1)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),l(!0),d(e=>Math.min(e+1,f.length-1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(e-1,0))):e.key===`Enter`&&c?(e.preventDefault(),h(f[u])):e.key===`Escape`&&c&&(e.preventDefault(),e.stopPropagation(),s(null),l(!1))}}),c&&(0,H.jsxs)(`ul`,{id:a,className:`wd-project-picker-list`,role:`listbox`,children:[f.length===0&&(0,H.jsxs)(`li`,{className:`wd-project-picker-empty`,children:[`No project matches “`,o,`”`]}),f.map((e,t)=>(0,H.jsxs)(`li`,{id:`${a}-${t}`,role:`option`,"aria-selected":t===u,className:`wd-project-picker-option`+(t===u?` wd-project-picker-option-active`:``),onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>d(t),children:[(0,H.jsx)(`span`,{children:p(e)}),e.kind===`group`&&e.members?.length?(0,H.jsx)(`span`,{className:`wd-project-picker-hint`,children:e.members.join(`, `)}):null]},`${e.kind}:${e.name}`))]})]})}var rh=[[/^(fix|fixes|fixed|repair|resolve|correct|bug)$/,`fix`],[/^(update|upgrade|bump|clean|cleanup|tidy|chore|rename|move|remove|delete|drop)$/,`chore`],[/^(document|docs|doc|readme)$/,`docs`],[/^(refactor|simplify|restructure|extract|split)$/,`refactor`],[/^(test|tests)$/,`test`]],ih=new Set([`add`,`adds`,`implement`,`create`,`make`,`build`,`support`,`introduce`,`please`,`let`,`lets`,`can`,`could`,`you`,`we`,`should`,`i`,`want`,`need`,`to`,`go`,`ahead`,`and`]),ah=new Set(`a.an.the.to.of.for.in.on.at.and.or.with.by.from.into.that.this.it.its.is.are.be.so.when.our.my.your.all.some.new`.split(`.`)),oh={đ:`d`,ð:`d`,ß:`ss`,æ:`ae`,œ:`oe`,ø:`o`,ł:`l`,þ:`th`,ı:`i`},sh=3,ch=40,lh=e=>String(e).padStart(2,`0`);function uh(e,t=new Date){let n=e.split(`
|
|
114
114
|
`).find(e=>e.trim())??``;if(!n)return``;let r=n.toLowerCase().replace(/[đðßæœøłþı]/g,e=>oh[e]??e).normalize(`NFD`).replace(/\p{M}/gu,``).replace(/[^a-z0-9\s'-]/g,` `).split(/\s+/).map(e=>e.replace(/'/g,``).replace(/^-+|-+$/g,``)).filter(Boolean),i=0;for(;i<r.length&&ih.has(r[i]);)i++;let a=`feat`,o=i<r.length?rh.find(([e])=>e.test(r[i])):void 0;o&&(a=o[1],i++);let s=r.slice(i).filter(e=>!ah.has(e)).slice(0,sh).join(`-`).slice(0,ch).replace(/-+$/,``);return s?`${a}/${s}`:`${a}/work-${lh(t.getMonth()+1)}${lh(t.getDate())}-${lh(t.getHours())}${lh(t.getMinutes())}`}function dh(e,t){return e.valid?t?e.free&&e.free!==e.branch?{text:`${e.branch} is taken, so a new one: ${e.free}.`}:e.free?null:{text:`${e.branch} and its -2 … -9 are all taken: Edit to name the branch.`,blocks:!0}:e.session?.archived?{text:`${e.branch} is an archived session: Create restores it and gives it the prompt.`}:e.session?{text:`${e.branch} already has a session: Create opens it and gives it the prompt.`}:e.exists?{text:`${e.branch} exists: Create checks it out, with the commits it has.`}:null:{text:`${e.branch} isn't a branch name git takes.`,blocks:!0}}function fh(e,t){let n=[e.trim()?`name “${e.trim()}”`:``,t.trim()?`base ${t.trim()}`:``].filter(Boolean);return n.length?`More options: ${n.join(` · `)}`:`More options: name, base branch`}function ph({initial:e,title:t=`New worktree`,onCreated:n,onClose:r,onManageRepos:i,checkBranch:a=qt}){let[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(e?.target??``),[u,d]=(0,_.useState)(e?.branch??null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(e?.base??``),[g,v]=(0,_.useState)(e?.prompt??``),[y,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(!!e?.base),C=uh(g),w=u===null,T=u??C,[E,D]=(0,_.useState)(null),O=E&&E.target===c.trim()&&E.branch===T.trim()?E:null,k=w&&O?.free?O.free:T,A=O?dh(O,w):null,j=e=>d(e),M=(0,_.useRef)(a);M.current=a,(0,_.useEffect)(()=>{let e=c.trim(),t=T.trim();if(!e||!t)return;let n=!0,r=setTimeout(()=>{M.current(e,t).then(t=>n&&D({...t,target:e}),()=>{})},250);return()=>{n=!1,clearTimeout(r)}},[c,T]);let N=(0,_.useRef)(null),[P,F]=(0,_.useState)(null),[I,ee]=(0,_.useState)(!1),[te,ne]=(0,_.useState)(null),L=(0,_.useRef)(null);(0,_.useEffect)(()=>{Jt().then(e=>{s(e),e.singles[0]&&l(t=>t||e.singles[0].name)},()=>s({singles:[],groups:[]}))},[]),(0,_.useEffect)(()=>{o&&L.current?.focus()},[o]);let re=(0,_.useMemo)(()=>o?[...o.groups,...o.singles]:[],[o]),ie=!!o?.groups.some(e=>e.name===c);async function ae(t){if(t.preventDefault(),I)return;if(!c.trim()){ne(`Pick a project.`);return}if(!k.trim()&&ie){p(!0),ne(`${c} is a group: give it a branch (a group has no one checkout to open).`);return}if(!k.trim()&&m.trim()){p(!0),S(!0),ne(`A base needs a branch to fork. Leave both empty to open the project as it is.`);return}if(A?.blocks){p(!0),ne(A.text);return}ee(!0),ne(null);let r=k.trim();if(w&&r&&!O){let e=await a(c.trim(),r).catch(()=>null);e?.free&&(r=e.free)}try{let t=await sn({target:c.trim(),branch:r,base:m.trim()||void 0,jiraKey:e?.jiraKey,prompt:g.trim()||void 0,name:y.trim()||void 0});if(t.startError){F({id:t.sessionId,reason:t.startError}),ee(!1);return}n(t.sessionId,{started:t.started})}catch(e){ne(e.message),ee(!1)}}function oe(e){e.target===e.currentTarget&&r()}return(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,role:`dialog`,"aria-modal":`true`,onClick:oe,onKeyDown:e=>{e.key===`Escape`&&r()},children:(0,H.jsxs)(`form`,{className:`wd-modal`,onSubmit:ae,ref:N,children:[(0,H.jsxs)(`header`,{className:`wd-modal-header`,children:[(0,H.jsx)(`h2`,{children:t}),(0,H.jsx)(`button`,{type:`button`,className:`wd-modal-close`,onClick:r,"aria-label":`Close`,children:`×`})]}),(0,H.jsxs)(`div`,{className:`wd-modal-body`,children:[(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Project`}),(0,H.jsx)(nh,{projects:re,value:c,onChange:l,disabled:I,inputRef:t=>{e?.target||(L.current=t)}})]}),i&&(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button wd-modal-aside`,onClick:i,children:`Not in the list? Repos & groups…`}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`What should Claude do?`}),(0,H.jsx)(`textarea`,{ref:t=>{e?.target&&(L.current=t)},value:g,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),N.current?.requestSubmit())},placeholder:`Add CSV export to the invoices endpoint`,rows:g.split(`
|
|
115
115
|
`).length>3?8:4,disabled:I}),(0,H.jsx)(`span`,{className:`wd-modal-hint`,children:`Leave it empty to just make the worktree. Ctrl+Enter creates.`})]}),f?(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsxs)(`span`,{children:[`Branch `,ie?``:`(empty: the project as it is)`]}),(0,H.jsx)(`input`,{autoFocus:!0,type:`text`,value:k,onChange:e=>j(e.target.value),placeholder:ie?`feat/whatever`:`feat/whatever, or empty: its current branch`,disabled:I,required:ie})]}):(0,H.jsxs)(`div`,{className:`wd-modal-branch`,children:[`Branch`,` `,k?(0,H.jsx)(`code`,{children:k}):(0,H.jsx)(`span`,{className:`wd-modal-hint`,children:ie?`needed for a group`:`none: the project as it is, on its own checkout`}),` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-link-button`,onClick:()=>p(!0),disabled:I,children:`Edit`})]}),A&&(0,H.jsx)(`p`,{className:`wd-modal-branch-note`+(A.blocks?` wd-modal-branch-note-bad`:``),role:`status`,children:A.text}),(0,H.jsxs)(`button`,{type:`button`,className:`wd-link-button wd-modal-more`,"aria-expanded":x,onClick:()=>S(e=>!e),children:[x?`▾`:`▸`,` `,x?`More options: name, base branch`:fh(y,m)]}),x&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Name (optional)`}),(0,H.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`shown instead of the branch, e.g. PDF generation speed`,maxLength:120,disabled:I})]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Base branch (optional)`}),(0,H.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`leave blank to use the default`,disabled:I})]})]}),te&&(0,H.jsx)(`p`,{className:`wd-modal-error`,children:te}),P&&(0,H.jsxs)(`p`,{className:`wd-modal-error`,role:`alert`,children:[`The worktree was created, but Claude didn't start: `,P.reason,`. Open the session and start it from its Terminal tab.`]})]}),(0,H.jsxs)(`footer`,{className:`wd-modal-footer`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:r,disabled:I,children:`Cancel`}),P?(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:()=>n(P.id),children:`Open session`}):(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:I||!c.trim()||!!A?.blocks,children:I?`Creating…`:g.trim()?`Create and start`:`Create`})]})]})})}function mh(e){let t=e instanceof Error?e.message:String(e);try{let e=JSON.parse(t);if(typeof e.error==`string`)return e.error}catch{}return t}function hh({session:e,onDeleted:t,onClose:n}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),l=(0,_.useRef)(null);async function u(n){if(!a){o(!0),c(null);try{await cn(e.id,n),t(e.id)}catch(e){c(mh(e)),o(!1)}}}return(0,H.jsxs)(sm,{title:`Delete session`,onClose:a?()=>{}:n,primaryRef:l,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,ref:l,onClick:n,disabled:a,children:`Cancel`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>u({sessionOnly:!0}),disabled:a,title:`Remove from the dashboard and history; leave the files on disk`,children:`Forget session only`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-danger`,onClick:()=>u({force:r}),disabled:a,children:a?`Deleting…`:`Delete worktree`})]}),children:[(0,H.jsxs)(`p`,{children:[`Remove the worktree for`,` `,(0,H.jsxs)(`code`,{children:[e.target,`/`,e.branch]}),` `,`and forget the session. The branch itself is kept. Any Claude terminal `,(0,H.jsx)(`code`,{children:`work web`}),` opened for it is stopped.`]}),e.paths.length>0&&(0,H.jsx)(`ul`,{className:`wd-delete-paths`,children:e.paths.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}),(0,H.jsxs)(`label`,{className:`wd-delete-force`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),disabled:a}),` Force — discard uncommitted changes and unpushed commits, and stop its Claude even mid-turn (replies to post and undelivered notes go too)`]}),s&&(0,H.jsx)(`p`,{className:`wd-delete-error`,role:`alert`,children:s})]})}function gh(e,t){let n=e.replace(/-\d+$/,``);for(let e=2;e<100;e++)if(!t.has(`${n}-${e}`))return`${n}-${e}`;return`${n}-fork`}function _h({session:e,sessions:t,onForked:n,onClose:r}){let[i,a]=(0,_.useState)(()=>gh(e.branch,new Set(t.filter(t=>t.target===e.target).map(e=>e.branch)))),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),m=(0,_.useRef)(null);(0,_.useEffect)(()=>{m.current?.focus(),m.current?.select()},[]);let h=()=>!u&&r(),g=e.diffStat?.files??0;async function v(t){if(t.preventDefault(),!u&&i.trim()){d(!0),p(null);try{let t=await je(e.id,{branch:i.trim(),prompt:c.trim()||void 0,name:o.trim()||void 0});n(t.sessionId,{summarized:t.summarized,...t.startError?{startError:t.startError}:{}})}catch(e){p(e.message),d(!1)}}}return(0,H.jsx)(`div`,{className:`wd-modal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":`Fork ${e.branch}`,onClick:e=>e.target===e.currentTarget&&h(),onKeyDown:e=>e.key===`Escape`&&h(),children:(0,H.jsxs)(`form`,{className:`wd-modal`,onSubmit:v,children:[(0,H.jsxs)(`header`,{className:`wd-modal-header`,children:[(0,H.jsxs)(`h2`,{children:[`Fork `,e.title&&e.titleIsYours?e.title:e.branch]}),(0,H.jsx)(`button`,{type:`button`,className:`wd-modal-close`,onClick:h,"aria-label":`Close`,disabled:u,children:`×`})]}),(0,H.jsxs)(`div`,{className:`wd-modal-body`,children:[(0,H.jsxs)(`p`,{className:`wd-fork-note`,children:[`A new worktree from `,(0,H.jsx)(`code`,{children:e.branch}),`'s last commit`,e.isGroup?`, in each repo`:``,g?` — its ${g} uncommitted file${g===1?``:`s`} stay here`:``,`. Its Claude starts with a summary of this conversation; this session carries on as it is. The fork is stacked on this one: this branch's new commits are brought into it (when it's idle and clean).`]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`New branch`}),(0,H.jsx)(`input`,{ref:m,type:`text`,value:i,onChange:e=>a(e.target.value),disabled:u,required:!0})]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`Name (optional)`}),(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`shown instead of the branch, e.g. Try the queue approach`,maxLength:120,disabled:u})]}),(0,H.jsxs)(`label`,{className:`wd-modal-row`,children:[(0,H.jsx)(`span`,{children:`What to try (optional)`}),(0,H.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:`Empty: it reads the summary and waits for you`,rows:c?5:2,disabled:u})]}),u&&(0,H.jsxs)(`p`,{className:`wd-fork-busy`,role:`status`,children:[(0,H.jsx)(`span`,{className:`wd-spinner`,"aria-hidden":`true`}),` Creating the worktree and writing a summary of the conversation…`]}),f&&(0,H.jsx)(`p`,{className:`wd-modal-error`,role:`alert`,children:f})]}),(0,H.jsxs)(`footer`,{className:`wd-modal-footer`,children:[(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:h,disabled:u,children:`Cancel`}),(0,H.jsx)(`button`,{type:`submit`,className:`wd-btn-primary`,disabled:u||!i.trim(),children:u?`Forking…`:`Fork`})]})]})})}var vh={tasks:`sessions`,prs:`start`},yh={comments:`diff`,chat:`term`},bh={tab:`sessions`,sessionId:null,sessionSubTab:`term`},xh=/^#\/(inbox|today|sessions|cleanup|start|repos|welcome|prs|jira|tasks)\/?$/,Sh=/^#\/s\/([^/]+)(?:\/(chat|diff|term|comments|timeline))?\/?$/;function Ch(e){if(!e||e===`#`||e===`#/`)return bh;let t=e.match(Sh);if(t){let e=t[2]?yh[t[2]]??t[2]:`term`;return{tab:`sessions`,sessionId:decodeURIComponent(t[1]),sessionSubTab:e}}let n=e.match(xh);return n?{tab:vh[n[1]]??n[1],sessionId:null,sessionSubTab:`term`}:bh}function wh(e){return e.sessionId?`#/s/${encodeURIComponent(e.sessionId)}/${e.sessionSubTab}`:`#/${e.tab}`}var Th=`work-web:last-route`;function Eh(e,t){if(e&&e!==`#`&&e!==`#/`)return e;let n;try{n=t?.getItem(`work-web:last-route`)??null}catch{return e}return!n||Ch(n)===bh?e:n}function Dh(e,t){try{t?.setItem(Th,wh(e))}catch{}}var Oh={inbox:`Inbox`,today:`Today`,cleanup:`Clean up`,sessions:`Sessions`,start:`Start`,jira:`Jira`,repos:`Repos`,welcome:`Welcome`},kh=12e4,Ah=6e4;function jh(){try{return window.localStorage}catch{return null}}function Mh(){let[e,t]=(0,_.useState)(()=>{let e=Eh(window.location.hash,jh());return e!==window.location.hash&&window.history.replaceState(null,``,e),Ch(e)});(0,_.useEffect)(()=>Dh(e,jh()),[e]);let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(new Set),u=(0,_.useCallback)((e,t)=>l(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),[]),d=c.size>0,f=(0,_.useRef)(d);f.current=d;let[p,m]=(0,_.useState)(!1),h=(0,_.useCallback)(()=>{let e=f.current;return F(e).then(t=>{r(t),m(e)})},[]),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(!1),A=(0,_.useCallback)(()=>{k(!0),w(e=>!e)},[]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),e.stopPropagation(),A())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[A]);let{open:j,close:M}=Nt(),[N,P]=(0,_.useState)(null),[I,ee]=(0,_.useState)(null),[te,ne]=(0,_.useState)(null),[L,re]=(0,_.useState)(null),{toast:ie,show:ae,hide:oe}=$a(),[se,ce]=(0,_.useState)(!1),le=Za(),[ue,de]=(0,_.useState)(null),R=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=le.updates?.whatsNew;e&&R.current!==e&&(R.current=e,de({focus:e}))},[le.updates?.whatsNew]);let pe=()=>{le.updates?.whatsNew&&le.seen(le.updates.whatsNew),de(null)},[me,he]=(0,_.useState)(null),V=(0,_.useMemo)(()=>({setArchived:(e,t)=>void T(e.id,t).then(()=>ae({text:`${t?`Archived`:`Restored`} ${e.title??e.branch}`}),e=>ae({text:e.message,kind:`error`})),openTerminal:e=>void ln(e.id).catch(e=>ae({text:`Couldn't open a terminal: ${e.message}`,kind:`error`})),openEditor:e=>void un(e.id).catch(e=>ae({text:`Couldn't open the editor: ${e.message}`,kind:`error`})),copyBranch:e=>void navigator.clipboard.writeText(e.branch).then(()=>ae({text:`Copied ${e.branch}`}),()=>ae({text:`Couldn't copy to the clipboard`,kind:`error`})),remove:e=>P(e),fork:e=>ee(e),snooze:(e,t)=>void B(e,t).then(()=>ae({text:`Snoozed ${e.title??e.branch}`}),e=>ae({text:e.message,kind:`error`})),unsnooze:e=>void fe(e.id).catch(e=>ae({text:e.message,kind:`error`})),snoozeUntil:e=>ne(e),blockBy:e=>re(e)}),[ae]),_e=(0,_.useCallback)(e=>to(e,V),[V]);(0,_.useEffect)(()=>{let e=()=>t(Ch(window.location.hash));return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let ve=(0,_.useCallback)(e=>{let n=wh(e);window.location.hash!==n&&(window.location.hash=n,t(e))},[]),ye=(0,_.useMemo)(()=>_o(()=>h().then(()=>a(null),e=>a(e.message)),400),[h]);(0,_.useEffect)(()=>()=>ye.cancel(),[ye]);let Ce=(0,_.useRef)(!0);(0,_.useEffect)(()=>{if(Ce.current){Ce.current=!1,h().catch(e=>a(e.message)),setTimeout(Nm,0);return}ye.trigger()},[o,ye,h]),mo(e.sessionId);let we=(0,_.useRef)({sessionId:e.sessionId,open:(e,t)=>{}});Xa(`/events`,{onOpen:()=>s(e=>e+1),events:{"session-order-changed":()=>void be().then(Je,()=>{}),"rail-changed":()=>void Me().then(tt,()=>{}),"host-health":e=>$e(e),"sessions-changed":()=>s(e=>e+1),"comments-changed":()=>s(e=>e+1),notify:e=>ho(e,we.current.sessionId,(e,t)=>we.current.open(e,t===`needs_input`?`term`:`diff`))}});let[Te,Ee]=(0,_.useState)([]),[De,Oe]=(0,_.useState)(!1),[ke,Ae]=(0,_.useState)(null),[je,Fe]=(0,_.useState)(0),Ie=(0,_.useCallback)(e=>{Ee(e.prs??[]),Oe(!0),Ae(e.available===!1?`gh isn’t installed or logged in (gh auth login).`:e.error??null)},[]),Le=(0,_.useCallback)(e=>{Oe(!0),Ae(e.message)},[]),[Re,ze]=(0,_.useState)(()=>new Map);(0,_.useEffect)(()=>{Jt().then(e=>ze(new Map(e.groups.map(e=>[e.name,e.members??[]]))),()=>{})},[]);let Be=(0,_.useCallback)(e=>Re.get(e),[Re]);(0,_.useEffect)(()=>{let e=!1,t=()=>{Fe(Date.now()),Yt().then(t=>{e||Ie(t)},t=>{e||Le(t)})};t();let n=setInterval(t,kh);return()=>{e=!0,clearInterval(n)}},[Ie,Le]),(0,_.useEffect)(()=>{o===0||Date.now()-je<Ah||(Fe(Date.now()),Yt().then(Ie,Le))},[o]);let Ve=(0,_.useCallback)(e=>yt(e,Te,Be),[Te,Be]),He=(0,_.useCallback)(e=>{ve({tab:e,sessionId:null,sessionSubTab:`term`})},[ve]),Ue=(0,_.useRef)(e);(0,_.useEffect)(()=>{Ue.current.sessionId||bn().then(e=>{As(e)&&He(`welcome`)}).catch(()=>{})},[He]);let[We,Ge]=(0,_.useState)(null),Ke=(0,_.useCallback)((t,n=`term`,r={})=>{Ge(r.lastTurn?t:null),ve({tab:e.tab,sessionId:t,sessionSubTab:n})},[ve,e.tab]),[qe,Je]=(0,_.useState)([]);(0,_.useEffect)(()=>{be().then(Je,()=>{})},[]);let Ye=(0,_.useCallback)(e=>{Je(e),xe(e).catch(()=>void be().then(Je,()=>{}))},[]),Xe=(0,_.useRef)([]),Ze=(0,_.useCallback)(e=>{Xe.current=e},[]),[Qe,$e]=(0,_.useState)(null);(0,_.useEffect)(()=>{Se().then($e,()=>{})},[]);let[et,tt]=(0,_.useState)(ot);(0,_.useEffect)(()=>{Me().then(tt,()=>{})},[]);let nt=(0,_.useCallback)((e,t)=>void Pe(e,t).then(tt,e=>ae({text:e.message,kind:`error`})),[ae]),rt=(0,_.useCallback)(e=>Ne(e).then(tt,e=>{throw ae({text:e.message,kind:`error`}),e}),[ae]),it=(0,_.useCallback)(t=>Ke(t,e.sessionId?e.sessionSubTab:`term`),[Ke,e.sessionId,e.sessionSubTab]),[at,st]=(0,_.useState)(null),ct=(0,_.useCallback)(()=>{let e=Qm(n);e&&(st(e),Ke(e.ids[0],`diff`,{lastTurn:!0}))},[n,Ke]),lt=(0,_.useCallback)(()=>{if(!at)return;let t=eh(at,e.sessionId,n);t?Ke(t,`diff`,{lastTurn:!0}):(st(null),ve({...bh,tab:`inbox`}))},[at,e.sessionId,n,Ke,ve]),dt=(0,_.useRef)(lt);dt.current=lt,we.current={sessionId:e.sessionId,open:Ke};let ft=(0,_.useCallback)(t=>{e.sessionId&&ve({...e,sessionSubTab:t})},[ve,e]),mt=(0,_.useCallback)(()=>{ve({tab:e.tab,sessionId:null,sessionSubTab:`term`})},[ve,e.tab]),ht=(0,_.useCallback)(()=>He(`sessions`),[He]),gt=(0,_.useCallback)(e=>He(e===`now`?`sessions`:`today`),[He]),vt=(0,_.useCallback)((e=null)=>{b(e),v(!0)},[]),bt=(0,_.useCallback)(t=>{P(null),r(e=>e.filter(e=>e.id!==t)),s(e=>e+1),e.sessionId===t&&ve({tab:e.tab,sessionId:null,sessionSubTab:`term`})},[ve,e.sessionId,e.tab]),xt=g||N!==null||I!==null||te!==null||L!==null;(0,_.useEffect)(()=>{let t=!1,r=null,i=()=>{let e=document.activeElement;return!!e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable)},a=a=>{if(a.metaKey||a.ctrlKey||a.altKey||i()||jt()||xt)return;if(t){t=!1,r&&clearTimeout(r);let e={i:`inbox`,d:`today`,s:`sessions`,w:`start`,r:`repos`,c:`cleanup`,j:`jira`,p:`start`};if(a.key===`t`){a.preventDefault(),D(e=>!e);return}if(e[a.key]){a.preventDefault(),He(e[a.key]);return}}if(a.key===`?`){a.preventDefault(),ce(e=>!e);return}if(a.key===`c`){a.preventDefault(),vt(null);return}if(a.key===`g`){t=!0,r=setTimeout(()=>{t=!1},750);return}if(a.key===`n`){if(at&&$m(at,e.sessionId)!==null){a.preventDefault(),dt.current();return}let t=n.filter(e=>!pt(e)&&To(e)).sort(wo),r=t.find(t=>t.id!==e.sessionId)??t[0];r&&(a.preventDefault(),Ke(r.id,ut(r)));return}if(a.key===`j`||a.key===`k`){let t=new Map(n.map(e=>[e.id,e])),r=Xe.current.map(e=>t.get(e)).filter(e=>!!e),i=r.length?r:_t(n,{order:qe,layout:et,activeId:e.sessionId}).groups.flatMap(e=>e.sessions);if(i.length===0)return;let o=e.sessionId?i.findIndex(t=>t.id===e.sessionId):-1,s=a.key===`j`?1:-1,c=i[Math.max(0,Math.min(i.length-1,o+s))];c&&(a.preventDefault(),it(c.id));return}let o=e.sessionId?n.find(t=>t.id===e.sessionId):void 0,s=o?Ft(a):null;if(!o||!s)return;a.preventDefault();let c=()=>{let e=document.querySelector(`.wd-session-more`)?.getBoundingClientRect();return e?{x:e.right,y:e.bottom+4}:{x:window.innerWidth-16,y:64}};Bt(s,{archived:pt(o)},{tab:ft,setArchived:e=>V.setArchived(o,e),snoozeMenu:()=>{let e=_e(o).filter(e=>/^(Snooze|Unsnooze)/.test(e.label));he({items:e.map(e=>({...e,separated:!1})),...c()})},blockBy:()=>V.blockBy(o),openEditor:()=>V.openEditor(o),copyBranch:()=>V.copyBranch(o),fork:()=>V.fork(o),remove:()=>V.remove(o),header:e=>window.dispatchEvent(new CustomEvent(zt,{detail:{id:o.id,action:e}}))})};return window.addEventListener(`keydown`,a),()=>{window.removeEventListener(`keydown`,a),r&&clearTimeout(r)}},[He,Ke,it,e.sessionId,n,qe,et,xt,at,vt,ft,V,_e]),(0,_.useEffect)(()=>u(`switcher`,j),[j,u]);let St=!!e.sessionId&&!n.some(t=>t.id===e.sessionId&&!pt(t));(0,_.useEffect)(()=>u(`session-page`,St),[St,u]);let Ct=(0,_.useRef)(!0);(0,_.useEffect)(()=>{if(Ct.current){Ct.current=!1;return}h().catch(e=>a(e.message))},[d,h]);let wt=e.sessionId?n.find(t=>t.id===e.sessionId)??null:null,Tt=wt?`${wt.target} · ${wt.branch} (${e.sessionSubTab})`:`the ${Oh[e.tab]} tab`;(0,_.useEffect)(()=>{C&&z(e.sessionId?{tab:`session`,sub:e.sessionSubTab,sessionId:e.sessionId}:{tab:e.tab}).catch(()=>{})},[C,e.tab,e.sessionId,e.sessionSubTab]);let Et=Nh(),Dt=!!wt&&bo(wt.attention)&&wt.attention.state===`idle`,Ot=!!wt&&So(wt),kt=wt&&(Dt||Ot)?`${wt.id}@${Dt?wt.attention.since:``}@${Ot?wt.prStage.key:``}`:null,At=Ot?wt?.prStage??null:null;(0,_.useEffect)(()=>{kt&&Et&&ge(kt.slice(0,kt.indexOf(`@`)),At).catch(()=>{})},[kt,Et]);let Pt=(0,_.useMemo)(()=>n.filter(e=>!pt(e)&&To(e)).length,[n]);(0,_.useEffect)(()=>{document.title=Pt>0?`(${Pt}) work`:`work`},[Pt]);let It;if(i&&n.length===0)It=(0,H.jsx)(`div`,{className:`wd-tab-error`,children:i});else if(wt){let t=at?$m(at,wt.id):null;It=(0,H.jsxs)(H.Fragment,{children:[at&&t!==null&&(0,H.jsx)(Wm,{position:t,total:at.ids.length,onNext:lt,onStop:()=>st(null)}),(0,H.jsx)(Lm,{startOnLastTurn:We===wt.id,onTermSlot:S,onOpenSession:e=>Ke(e),session:wt,subTab:e.sessionSubTab,onSelectSubTab:ft,onDelete:()=>P(wt),prs:Ve(wt),onShipped:mt})]})}else if(e.sessionId&&!p)It=(0,H.jsx)(`div`,{className:`wd-tab-empty`,children:`Loading…`});else if(e.sessionId)It=(0,H.jsxs)(`div`,{className:`wd-tab-empty`,children:[`Session not found. It may have been removed.`,(0,H.jsx)(`br`,{}),(0,H.jsxs)(`button`,{type:`button`,className:`wd-btn-secondary`,onClick:mt,children:[`Back to `,Oh[e.tab]]})]});else switch(e.tab){case`inbox`:It=(0,H.jsx)(Y,{sessions:n,onOpenSession:Ke,onReviewAll:ct});break;case`today`:It=(0,H.jsx)(Jo,{onOpenSession:Ke,viewToggle:(0,H.jsx)(ml,{value:`today`,onChange:gt})});break;case`cleanup`:It=(0,H.jsx)(ls,{onOpenSession:e=>Ke(e)});break;case`sessions`:It=(0,H.jsx)(el,{sessions:n,onShowArchived:e=>u(`sessions-table`,e),onOpenSession:Ke,onNewWorktree:()=>vt(null),onDeleteSession:P,onCleanUp:()=>He(`cleanup`),menuFor:_e,layout:et,viewToggle:(0,H.jsx)(ml,{value:`now`,onChange:gt})});break;case`start`:It=(0,H.jsx)(cl,{sessions:n,prs:De?Te:null,prsNote:ke,membersOf:Be,onNewWorktree:()=>vt(null),onPickPr:e=>vt({target:e.repoAlias,branch:e.branch,prompt:Um(e)}),onOpenSession:e=>Ke(e),onManageRepos:()=>He(`repos`)});break;case`jira`:It=(0,H.jsx)(Ds,{sessions:n,onPickIssue:e=>vt({branch:`feat/${e.key}`,jiraKey:e.key,prompt:Hm(e)}),onOpenSession:e=>Ke(e)});break;case`repos`:It=(0,H.jsx)(vs,{onBack:()=>He(`start`)});break;case`welcome`:It=(0,H.jsx)(Ms,{onNewWorktree:()=>vt(null),onDone:()=>He(`start`)})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Dc,{route:e,sessions:n,onSelectTab:He,onSelectSession:it,sessionOrder:qe,onReorderSessions:Ye,sessionMenu:_e,railLayout:et,onPlaceSession:nt,onRailSections:rt,onRailShownChange:Ze,onHome:ht,onNewWorktree:()=>vt(null),inboxCount:Pt,prsFor:Ve,onAssistant:A,activity:(0,H.jsx)(Fc,{onOpenSession:e=>Ke(e)}),help:(0,H.jsx)(Hc,{updates:le.updates,onCheck:le.check,checking:le.checking,note:le.note,onWhatsNew:()=>de({focus:null}),onShortcuts:()=>ce(!0),onRestart:le.restart}),tasks:(0,H.jsx)(pl,{open:E,onOpenChange:D,onPick:e=>vt({branch:`todo/`+ul(e.text)})}),assistantOpen:C,children:It}),(0,H.jsx)(Xm,{activeId:wt&&e.sessionSubTab===`term`?wt.id:null,slot:x,sessions:n}),O&&(0,H.jsx)(Km,{open:C,onClose:()=>w(!1),seeing:Tt}),g&&(0,H.jsx)(ph,{initial:y??void 0,onCreated:(e,t)=>{v(!1),b(null),Ke(e,`term`)},onClose:()=>{v(!1),b(null)},onManageRepos:()=>{v(!1),b(null),He(`repos`)}}),(0,H.jsx)(ro,{health:Qe}),(0,H.jsx)(eo,{toast:ie,onClose:oe}),j&&(0,H.jsx)(Mt,{sessions:n,onOpen:e=>Ke(e),onClose:M}),se&&(0,H.jsx)(Vt,{onClose:()=>ce(!1)}),(0,H.jsx)(Wt,{updates:le.updates,onRestart:le.restart,onWhatsNew:()=>de({focus:le.updates?.available?.version??null})}),ue&&(0,H.jsx)(Ka,{focus:ue.focus,onClose:pe}),me&&(0,H.jsx)(Qa,{x:me.x,y:me.y,anchor:`right`,items:me.items,onClose:()=>he(null)}),L&&(0,H.jsx)(xl,{session:L,sessions:n,onClose:()=>re(null),onDone:e=>{let t=L;re(null),ae({text:`${t.title??t.branch} waits on ${e}`})}}),te&&(0,H.jsx)(Ao,{onClose:()=>ne(null),onPick:e=>{let t=te;ne(null),B(t,{until:e}).then(()=>ae({text:`Snoozed ${t.title??t.branch}`}),e=>ae({text:e.message,kind:`error`}))}}),I&&(0,H.jsx)(_h,{session:I,sessions:n,onClose:()=>ee(null),onForked:(e,t)=>{let n=I.title??I.branch;ee(null),ye.trigger(),Ke(e,`term`),ae(t.startError?{text:`Forked ${n}, but its Claude didn't start: ${t.startError}`,kind:`error`}:{text:`Forked ${n}${t.summarized?`, with a summary of the conversation`:``}`})}}),N&&(0,H.jsx)(hh,{session:N,onDeleted:bt,onClose:()=>P(null)})]})}function Nh(){let e=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(`focus`,t),window.addEventListener(`blur`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),window.removeEventListener(`blur`,t),document.removeEventListener(`visibilitychange`,t)}},[]),t}function Ph(e,t,n){if(e.length<=1)return{kind:`legacy`};let r=e[0].id;if(!t||!n)return{kind:`range`,range:{from:r,to:`working`}};let i=e.some(e=>e.id===n.from),a=n.to===`working`||e.some(e=>e.id===n.to);return!i||!a?{kind:`range`,range:{from:r,to:`working`},resetUserPicked:!0}:{kind:`range`,range:n}}function Fh(e,t){let n=null;for(let r of e){let e=Date.parse(r.ts);Number.isFinite(e)&&e<=t&&(n=r.id)}return n}function Ih(e){return e===`working`?`working tree`:e===0?`Initial`:`checkpoint #${e}`}function Lh(e,t){let n=Ih(e.from);return e.to===`working`&&t!==void 0&&e.from===t?`${n} is the most recent snapshot — it already matches your working tree, so there's nothing to show. Pick an earlier checkpoint to see recent changes.`:`No changes between ${n} and ${Ih(e.to)}. Pick a different range from the strip above.`}function Rh(e){return e.label&&e.label.trim()?e.label:`#${e.id}`}function zh(e,t){let n=new Date(e).getTime();if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);return a<24?`${a}h ago`:`${Math.round(a/24)}d ago`}function Bh({entries:e,fromId:t,toId:n,onChangeFrom:r,onChangeTo:i,onPickSingle:a,active:o,busy:s}){let[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!c)return;let e=e=>{u.current?.contains(e.target)||l(!1)},t=e=>{e.key===`Escape`&&l(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[c]),e.length===0)return null;let d=n===`working`?1/0:n,f=e=>e>=t&&e<=d,p=Date.now(),m=t=>{if(t===`working`)return`Working`;let n=e.find(e=>e.id===t);return n?Rh(n):`#${t}`},h=(e,t)=>{e.shiftKey?t!==`working`&&r(t):a(t)};return(0,H.jsxs)(`nav`,{ref:u,className:`wd-checkpoint-range`+(o?``:` wd-checkpoint-range-inactive`),"aria-label":`Checkpoint range`,"aria-busy":s,children:[(0,H.jsx)(`div`,{className:`wd-checkpoint-range-row`,children:(0,H.jsxs)(`button`,{type:`button`,className:`wd-checkpoint-range-btn`,"aria-haspopup":`listbox`,"aria-expanded":c,onClick:()=>l(e=>!e),title:`Pick the range of checkpoints to diff`,children:[(0,H.jsx)(`span`,{className:`wd-checkpoint-btn-tag`,children:`Range:`}),` `,(0,H.jsxs)(`span`,{className:`wd-checkpoint-btn-range`,children:[m(t),` `,(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),` `,m(n)]}),(0,H.jsx)(`span`,{className:`wd-checkpoint-caret`,"aria-hidden":`true`,children:`▾`})]})}),c&&(0,H.jsxs)(`div`,{className:`wd-checkpoint-pop`,role:`listbox`,"aria-label":`Checkpoints`,children:[(0,H.jsxs)(`div`,{className:`wd-checkpoint-pop-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-checkpoint-pop-preset`+(t===0&&n===`working`?` wd-checkpoint-pop-preset-active`:``),onClick:()=>{r(0),i(`working`)},children:[(0,H.jsx)(`span`,{className:`wd-checkpoint-pop-dot`,"aria-hidden":`true`,children:t===0&&n===`working`?`●`:``}),`All changes `,(0,H.jsx)(`span`,{className:`wd-checkpoint-pop-sub`,children:`Initial → Working`})]}),(0,H.jsx)(`div`,{className:`wd-checkpoint-pop-hint`,children:`Click = just this checkpoint · Shift+click = widen start`})]}),e.map(e=>{let r=e.id===t,i=n!==`working`&&e.id===n,a=`wd-checkpoint-pop-row`+(r?` wd-checkpoint-pop-from`:``)+(i?` wd-checkpoint-pop-to`:``)+(!r&&!i&&f(e.id)?` wd-checkpoint-pop-in-range`:``);return(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r||i,className:a,onClick:t=>h(t,e.id),children:[(0,H.jsx)(`span`,{className:`wd-checkpoint-pop-dot`,"aria-hidden":`true`,children:r||i?`●`:f(e.id)?`▪`:``}),(0,H.jsx)(`span`,{className:`wd-checkpoint-pop-label`,children:Rh(e)}),(0,H.jsx)(`span`,{className:`wd-checkpoint-pop-time`,children:zh(e.ts,p)})]},e.id)})]})]})}function Vh(){let e=mu(),[t,n]=(0,_.useState)(!1),[r,i]=(0,_.useState)(`idle`),a=gu(e.comments).length,o=_u(e.comments),s=()=>{n(!1),i(`ended`)};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{type:`button`,className:`wd-done-bar`,onClick:()=>n(!0),disabled:r!==`idle`,children:[r===`idle`?`End review `:r===`submitting`?`Submitting… `:r===`ending`?`Closing… `:`Review ended `,(0,H.jsx)(`span`,{className:`wd-done-count`,children:o})]}),t&&(0,H.jsx)(sm,{title:`End review?`,onClose:()=>n(!1),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),a>0&&(0,H.jsx)(`button`,{type:`button`,onClick:async()=>{i(`submitting`);try{await e.submitReview(``),i(`ending`),await e.done(),s()}catch{i(`idle`)}},children:`Submit pending then end`}),(0,H.jsx)(`button`,{type:`button`,className:`wd-btn-primary`,onClick:async()=>{i(`ending`);try{await e.done(),s()}catch{i(`idle`)}},children:a>0?`End anyway (discard drafts)`:`End review`})]}),children:a>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{children:[(0,H.jsxs)(`strong`,{style:{color:`var(--status-modified-fg)`},children:[`You have `,a,` pending comment`,a===1?``:`s`,`.`]}),` `,`They have not been sent yet and will be lost if you end the review now.`]}),o>0&&(0,H.jsxs)(`p`,{style:{color:`var(--muted)`,fontSize:12},children:[o,` comment`,o===1?` was`:`s were`,` already delivered.`]})]}):o===0?(0,H.jsx)(`p`,{children:`You have left no comments. Closing the session will exit wd with no further action.`}):(0,H.jsxs)(`p`,{children:[`Your `,o,` comment`,o===1?``:`s`,` `,o===1?`has`:`have`,` already been delivered. Closing the session will exit wd. You can then close the tab.`]})})]})}function Hh(e,t){return e>t}function Uh(e,t){let[n,r]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>r(Hh(t.scrollHeight,window.innerHeight));n();let i=typeof ResizeObserver<`u`?new ResizeObserver(n):null;return i?.observe(t),window.addEventListener(`resize`,n),()=>{i?.disconnect(),window.removeEventListener(`resize`,n)}},t),n}function Wh({context:e,scopeHash:t}){let[n,r]=(0,_.useState)(null),i=!!e.readOnly,[a,o]=(0,_.useState)(!1),s=(0,_.useMemo)(()=>t?cu(t):void 0,[t]),c=(0,_.useMemo)(()=>s&&a?{...s,ssePath:``}:s,[s,a]),[l,u]=(0,_.useState)(e.initialBase??`uncommitted`),d=!e.staticMode||L(),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)(null),g=(0,_.useRef)(!1),[v,y]=(0,_.useState)(!1),b=(0,_.useCallback)(()=>{t&&ae(t).then(e=>{p(e),h(t=>{let n=Ph(e,g.current,t);if(n.resetUserPicked&&(g.current=!1),n.kind===`legacy`)return null;let r=n.range;return t&&t.from===r.from&&t.to===r.to?t:r})},()=>{})},[t]);(0,_.useEffect)(()=>{b()},[b]);let x=(0,_.useRef)(new WeakMap),{data:S,error:C,loading:w,checking:T,pending:E,applyPending:D,reload:O,checkForUpdates:k}=du(()=>{let e=Date.now();return(t?re(t,l,v?m??void 0:void 0):ne(l)).then(t=>(x.current.set(t,e),t))},[l,t,m,v]),A=S?.repos??null,j=S?.resolvedBase,M=e.headBranch??S?.headBranch;(0,_.useEffect)(()=>{let t=M??`HEAD`,n;n=v&&m?`${m.from===0?`Initial`:`#${m.from}`} → ${m.to===`working`?`working`:`#${m.to}`}`:l===`branch`&&j?`${t} vs ${j}`:`${t} · uncommitted`,document.title=`${n} — ${e.scopeLabel}`},[M,e.scopeLabel,l,j,v,m]),Xa(a?null:t?`/api/scopes/${encodeURIComponent(t)}/events`:`/events`,{events:{"diff-changed":()=>k(),"checkpoints-changed":()=>b(),"review-done":()=>o(!0)}});let N=()=>{O(),window.scrollTo({top:0})},P=(e,t)=>t===`working`?{from:e,to:t}:e>t?{from:t,to:e}:{from:e,to:t},F=e=>{y(!1),u(e)},I=e=>{g.current=!0,y(!0),h(t=>P(e,t?.to??`working`))},ee=e=>{g.current=!0,y(!0),h(t=>P(t?.from??0,e))},te=()=>{ce!==null&&(g.current=!0,y(!0),h({from:ce,to:`working`}))},ie=e=>{if(g.current=!0,y(!0),e===`working`){let e=f.length?f[f.length-1].id:0;h({from:e,to:`working`});return}if(e===0){h({from:0,to:`working`});return}let t=f.findIndex(t=>t.id===e),n=t>0?f[t-1].id:0;h({from:n,to:e})};(0,_.useEffect)(()=>{A&&A.length!==0&&(A.some(e=>e.name===n)||r(A[0].name))},[A,n]),(0,_.useEffect)(()=>{if(!t||!v||!m||m.to===`working`||m.to===0)return;let e=m.to,n=f.find(t=>t.id===e);if(!n||n.label&&n.label.trim())return;let r=!1;return oe(t,e).then(({label:t})=>{r||t&&t.trim()&&p(n=>n.map(n=>n.id===e?{...n,label:t}:n))},()=>{}),()=>{r=!0}},[t,v,m,f]),(0,_.useEffect)(()=>{if(!t||f.length===0)return;let e=f[f.length-1];if(e.id===0||e.label&&e.label.trim())return;let n=setTimeout(()=>{oe(t,e.id).then(({label:t})=>{t&&t.trim()&&p(n=>n.map(n=>n.id===e.id?{...n,label:t}:n))},()=>{})},2500);return()=>clearTimeout(n)},[t,f]);let se=S?x.current.get(S):void 0,ce=se===void 0?null:Fh(f,se),le=(0,_.useMemo)(()=>{let e=new Map,t=0;if(A)for(let n of A)e.set(n.name,t),t+=n.files.length;return e},[A]),ue=(0,_.useMemo)(()=>!A||A.length===0?null:A.find(e=>e.name===n)??A[0],[A,n]),de=ue?le.get(ue.name)??0:0,R=(0,_.useMemo)(()=>{let e=new Map;return ue&&ue.files.forEach((t,n)=>{e.set(t.path,`wd-file-${de+n}`)}),e},[ue,de]),z=ue?`scope:${e.scopeLabel}:${ue.name}`:`scope:${e.scopeLabel}:_pending`,B=ue?`scope:${e.scopeLabel}:${ue.name}:hunks`:``,{viewedPaths:fe,viewedAnchors:pe,toggle:me}=pm(z,R),he=vm(ue?.name??`_pending`),{width:V,setWidth:ge}=Tc(),_e=(0,_.useRef)(null),ve=(0,_.useRef)(null),ye=Uh(ve,[ue?.name,A?.length]);if(_m(ve,he,ye),C)return(0,H.jsx)(`div`,{className:`wd-web-error`,children:C});if(!A)return(0,H.jsx)(`div`,{className:`wd-web-empty`,children:`Loading diff…`});let be=A.reduce((e,t)=>e+t.files.length,0),xe=E?E.repos.reduce((e,t)=>e+t.files.length,0):null,Se=be===0||!ue,Ce=A.length>1,we;we=v&&m?Lh(m,f.length?f[f.length-1].id:void 0):l===`uncommitted`?`No uncommitted changes.`:!j||j===`HEAD`?`Couldn't auto-detect this branch's parent. Tried main, master, dev, develop (and their origin/* mirrors).`:`No commits since \`${j}\` — branch is up to date or already merged.`;let Te=v&&m?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`strong`,{children:m.from===0?`Initial`:`#${m.from}`}),(0,H.jsx)(`span`,{className:`wd-web-muted`,children:` → `}),(0,H.jsx)(`strong`,{children:m.to===`working`?`working`:`#${m.to}`})]}):l===`branch`&&j?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`strong`,{children:M??`HEAD`}),(0,H.jsx)(`span`,{className:`wd-web-muted`,children:` vs `}),(0,H.jsx)(`strong`,{children:j})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`uncommitted on `}),(0,H.jsx)(`strong`,{children:M??`working tree`})]}),Ee=(0,H.jsxs)(`div`,{className:`wd-web-difftoolbar`,children:[(0,H.jsxs)(`div`,{className:`wd-web-difftoolbar-info`,children:[(0,H.jsx)(`span`,{className:`wd-web-difftoolbar-title`,title:e.scopeLabel,children:e.scopeLabel}),(0,H.jsx)(`span`,{className:`wd-web-difftoolbar-count`,children:Se?(0,H.jsx)(`span`,{className:`wd-web-muted`,children:`no changes`}):(0,H.jsxs)(H.Fragment,{children:[be,` file`,be===1?``:`s`,` changed`,Ce?` · ${A.length} repos`:``]})}),(0,H.jsx)(`span`,{className:`wd-web-difftoolbar-compare`,children:Te}),E&&(0,H.jsx)(Xp,{filesChanged:xe,onShow:D,onReload:N,onShowNewOnly:ce===null?void 0:te}),(w||T&&!E)&&(0,H.jsx)(Yp,{label:w?`loading…`:`checking…`})]}),(0,H.jsxs)(`div`,{className:`wd-web-difftoolbar-controls`,children:[(0,H.jsxs)(`span`,{className:`wd-web-version`,title:`work-tree v${Bc}`,children:[`v`,Bc]}),(0,H.jsx)(Bs,{}),(0,H.jsx)(Zp,{}),d&&(0,H.jsxs)(`div`,{className:`wd-web-diff-scope`,role:`tablist`,"aria-label":`Diff scope`,children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!v&&l===`uncommitted`,className:`wd-web-diff-scope-btn`+(!v&&l===`uncommitted`?` wd-web-diff-scope-btn-active`:``),onClick:()=>F(`uncommitted`),children:`Uncommitted`}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":!v&&l===`branch`,className:`wd-web-diff-scope-btn`+(!v&&l===`branch`?` wd-web-diff-scope-btn-active`:``),onClick:()=>F(`branch`),children:`Since branch`})]}),t&&f.length>1&&m&&(0,H.jsx)(Bh,{entries:f,fromId:m.from,toId:m.to,active:v,onChangeFrom:I,onChangeTo:ee,onPickSingle:ie,busy:w})]})]}),De=(0,H.jsxs)(`div`,{ref:_e,className:`wd-web-review-page`,style:{"--sidebar-width":`${V}px`,"--topbar-h":`40px`,"--tabs-offset":Ce?`36px`:`0px`},children:[Ee,(0,H.jsxs)(`div`,{className:`wd-web-review-layout wd-web-review-layout--page`,children:[(0,H.jsx)(`aside`,{ref:ve,className:`wd-web-review-sidebar`+(ye?` wd-sidebar-scrolls`:``),children:!Se&&ue&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($p,{files:ue.files,startIndex:de,selectedAnchor:he,viewedAnchors:pe}),!i&&(0,H.jsx)(tm,{repoName:ue.name,onOpenRepo:r})]})}),(0,H.jsx)(Ec,{layoutRef:_e,size:V,onCommit:ge}),(0,H.jsx)(`main`,{className:`wd-web-review-main`,"aria-busy":w,children:Se||!ue?(0,H.jsxs)(`div`,{className:`wd-web-empty wd-web-empty-diff`,children:[(0,H.jsx)(`p`,{children:we}),l===`uncommitted`&&d&&(0,H.jsxs)(`p`,{className:`wd-web-empty-hint`,children:[`Try`,` `,(0,H.jsx)(`button`,{type:`button`,className:`wd-web-link-btn`,onClick:()=>F(`branch`),children:`Since branch`}),` `,`to see everything in this worktree.`]})]}):(0,H.jsxs)(H.Fragment,{children:[!i&&(0,H.jsx)(om,{}),Ce&&(0,H.jsx)(`nav`,{className:`wd-web-repo-tabs`,children:A.map(e=>{let t=e.files.reduce((e,t)=>e+t.added,0),n=e.files.reduce((e,t)=>e+t.deleted,0);return(0,H.jsxs)(`button`,{type:`button`,className:`wd-web-repo-tab`+(e.name===ue.name?` wd-web-repo-tab-active`:``),onClick:()=>r(e.name),children:[e.name,` `,(0,H.jsxs)(`span`,{className:`wd-web-tab-count`,children:[`(`,e.files.length,`)`]}),` `,(0,H.jsxs)(`span`,{className:`wd-tab-stats`,children:[(0,H.jsxs)(`span`,{className:`wd-add`,children:[`+`,t]}),` `,(0,H.jsxs)(`span`,{className:`wd-del`,children:[`-`,n]})]})]},e.name)})}),(0,H.jsx)(Jp,{repo:ue,startIndex:de,review:!i,viewedPaths:fe,onToggleViewed:me,hunkScopeKey:B})]})}),!i&&!Se&&(0,H.jsx)(cm,{}),!i&&!Se&&(0,H.jsx)(Vh,{})]})]});return(n=>e.staticMode?n:(0,H.jsx)(Sp,{scopeHash:t,children:n}))(i?De:(0,H.jsx)(pu,{api:c,children:De}))}function Gh({hash:e}){let t=new URLSearchParams(window.location.search),n=t.get(`repo`)??``,r=t.get(`path`)??``,i=t.get(`ref`)??void 0,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!r){c(`No file path given.`);return}let t=!1;return ie(e,n,r,1,2**53-1,i).then(e=>{t||o(e.lines)},e=>{t||c(e.message)}),()=>{t=!0}},[e,n,r,i]),(0,_.useEffect)(()=>{document.title=r?`${r} — file`:`file`},[r]);let l=(0,_.useMemo)(()=>{let e=Cf(r);return!e||!a?null:wf(a,e)},[r,a]);return s?(0,H.jsx)(`div`,{className:`wd-web-error`,children:s}):a?(0,H.jsxs)(`div`,{className:`wd-fileview`,children:[(0,H.jsxs)(`header`,{className:`wd-fileview-header`,children:[(0,H.jsx)(`span`,{className:`wd-fileview-path`,children:r}),(0,H.jsxs)(`span`,{className:`wd-fileview-meta`,children:[a.length,` line`,a.length===1?``:`s`]})]}),(0,H.jsx)(`table`,{className:`wd-fileview-table`,children:(0,H.jsx)(`tbody`,{children:a.map((e,t)=>{let n=l?.[t]??null;return(0,H.jsxs)(`tr`,{className:`wd-fileview-row`,children:[(0,H.jsx)(`td`,{className:`wd-fileview-ln`,children:t+1}),n===null?(0,H.jsx)(`td`,{className:`wd-fileview-content`,children:e||` `}):(0,H.jsx)(`td`,{className:`wd-fileview-content`,dangerouslySetInnerHTML:{__html:n}})]},t)})})})]}):(0,H.jsxs)(`div`,{className:`wd-web-empty`,children:[`Loading `,r,`…`]})}function Kh(){return(0,H.jsx)(Rs,{children:(0,H.jsx)(ip,{children:(0,H.jsx)(qh,{})})})}function qh(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),i=Yh(window.location.pathname),a=i?null:Jh(window.location.pathname);return(0,_.useEffect)(()=>{if(i)return;if(a){t({mode:`review`,scopeLabel:a.hash,repos:[],readOnly:a.kind===`diff`});return}let e=!1;return te().then(n=>{e||t(n)},t=>{e||r(t.message)}),()=>{e=!0}},[]),i?(0,H.jsx)(Gh,{hash:i.hash}):n?(0,H.jsx)(`div`,{className:`wd-web-error`,children:n}):e?a?(0,H.jsx)(Wh,{context:e,scopeHash:a.hash}):e.mode===`review`?(0,H.jsx)(Wh,{context:e}):(0,H.jsx)(Mh,{}):(0,H.jsx)(`div`,{className:`wd-web-empty`,children:`Connecting…`})}function Jh(e){let t=e.match(/^\/(diff|review)\/([a-zA-Z0-9_-]+)\/?$/);return t?{kind:t[1],hash:t[2]}:null}function Yh(e){let t=e.match(/^\/file(?:\/([a-zA-Z0-9_-]+))?\/?$/);return t?{hash:t[1]}:null}var Xh=document.getElementById(`root`);if(!Xh)throw Error(`No #root element found`);(0,g.createRoot)(Xh).render((0,H.jsx)(_.StrictMode,{children:(0,H.jsx)(Kh,{})}));export{u as n,c as r,Et as t};
|
|
116
|
-
//# sourceMappingURL=index-
|
|
116
|
+
//# sourceMappingURL=index-C5lJhIwK.js.map
|