@dubusoft/toodo-linux-arm64 1.11.1-dev.191 → 1.11.1-dev.193

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.
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./jsx-runtime-C3cWAN_r.js";import{c as r,g as i,i as a,l as o,o as s,t as c}from"./session-sBDFnC3r.js";import{n as l}from"./event-CSYkpd32.js";var u=e(t(),1),d=u.createContext(!1),f=()=>u.useContext(d);d.Provider;var p=n(),m=u.createContext(void 0),h=e=>{let t=u.useContext(m);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},g=({client:e,children:t})=>(u.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,p.jsx)(m.Provider,{value:e,children:t}));function _(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var v=u.createContext(_()),ee=()=>u.useContext(v),y=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},te=new class extends y{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},ne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},b=new class{#e=ne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function re(e){setTimeout(e,0)}var ie=typeof window>`u`||`Deno`in globalThis;function x(){}function ae(e,t){return typeof e==`function`?e(t):e}function oe(e){return typeof e==`number`&&e>=0&&e!==1/0}function se(e,t){return Math.max(e+(t||0)-Date.now(),0)}function S(e,t){return typeof e==`function`?e(t):e}function ce(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ue(o,t.options))return!1}else if(!w(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function le(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(C(t.options.mutationKey)!==C(a))return!1}else if(!w(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ue(e,t){return(t?.queryKeyHashFn||C)(e)}function C(e){return JSON.stringify(e,(e,t)=>me(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function w(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!w(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!w(e[r],t[r]))return!1;return!0}return!1}var de=Object.prototype.hasOwnProperty;function fe(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=pe(e)&&pe(t);if(!r&&!(me(e)&&me(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:de.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=fe(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function T(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n of Object.keys(e))if(!de.call(t,n)||e[n]!==t[n])return!1;return!0}function pe(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function me(e){if(!he(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!he(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function he(e){return Object.prototype.toString.call(e)===`[object Object]`}function ge(e){return new Promise(t=>{b.setTimeout(t,e)})}function _e(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:fe(e,t)}function ve(e,t,n,r){let i=r?[t,...e]:[...e,t];return n&&i.length>n?r?i.slice(0,n):i.slice(-n):i}var E=Symbol();function ye(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===E?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function D(e,t){return typeof e==`function`?e(...t):!!e}var O=Symbol();function be(e,t,n,r){let i=!1,a;return Object.defineProperties(e,{[O]:{value:r},signal:{enumerable:!0,get:()=>(a??=t(),i||(i=!0,a.aborted?n():a.addEventListener(`abort`,n,{once:!0})),a)}}),e}var xe=()=>ie,k=()=>xe();function Se(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=t,u=e=>{be(e,()=>t.signal,()=>n=!0,l[O])},d=ye(t.options,t.fetchOptions),f=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return u(e),e})(),o=await d(a),{maxPages:s}=t.options;return{pages:ve(e.pages,o,s,i),pageParams:ve(e.pageParams,r,s,i)}};if(i&&a.length){let e=i===`backward`,t=e?Ce:A,n={pages:a,pageParams:o};s=await f(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]===void 0?r.initialPageParam:o[0]:A(r,s);if(c>0&&e==null)break;s=await f(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function A(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ce(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function we(e,t){return t?A(e,t)!=null:!1}function Te(e,t){return!t||!e.getPreviousPageParam?!1:Ce(e,t)!=null}var Ee=re;function De(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Ee,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var j=De(),Oe=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),oe(this.gcTime)&&(this.#e=b.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(k()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(b.clearTimeout(this.#e),this.#e=void 0)}},M=new class extends y{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function ke(e){return Math.min(1e3*2**e,3e4)}function Ae(e){return(e??`online`)!==`online`||M.isOnline()}var N=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function je(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(x);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new N(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>te.isFocused()&&(e.networkMode===`always`||M.isOnline())&&e.canRun(),p=()=>Ae(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(k()?0:3),a=e.retryDelay??ke,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),ge(o).then(()=>c()||f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var Me=class extends Oe{#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){super(),this.#c=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Fe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#s,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Fe(this.options);e.data!==void 0&&(this.setState(Pe(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=_e(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(x).catch(x):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>S(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===E||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.state.data!==void 0&&this.getObserversCount()>0&&this.observers.some(e=>S(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!se(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#c||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a&&this.#o)return this.#a.continueRetry(),this.#o}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperties(e,{[O]:{value:n.signal,enumerable:!0},signal:{enumerable:!0,get:()=>(this.#c=!0,n.signal)}})},i=()=>{let e=ye(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#c=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Se(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=je({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof N&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}),s=(async()=>{try{let e=await o.promise;if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof N){if(e.silent){if(this.#a!==o&&this.#o)return this.#o;throw e}if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0,this.#o=void 0),this.scheduleGc()}})();return this.#o=s,o.start(),s}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Ne(t.data,this.options),fetchMeta:e.meta??null};case`success`:{let n={...t,...Pe(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n}case`error`:{let n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:`idle`,status:`error`,isInvalidated:!0}}case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),j.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ne(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ae(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Pe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Fe(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Ie=class extends y{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#a=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Re(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return P(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return P(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof S(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!T(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ze(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||S(this.options.enabled,this.#t)!==S(t.enabled,this.#t)||S(this.options.staleTime,this.#t)!==S(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||S(this.options.enabled,this.#t)!==S(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return T(this.getCurrentResult(),n)||(this.#r=n,this.#i=e),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch(t).then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(x)),t}#h(e){return!k()&&S(this.options.enabled,this.#t)!==!1&&oe(e)}#g(){this.#b();let e=S(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=se(this.#r.dataUpdatedAt,e)+1;this.#u=b.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return S(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=b.setInterval(()=>{(this.options.refetchIntervalInBackground||te.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(b.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(b.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=e===n?this.#n:e.state,{state:s}=e,c={...s},l=!1,u;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Re(e,t),o=i&&ze(e,n,t,r);(a||o)&&(c={...c,...Ne(s.data,e.options)}),t._optimisticResults===`isRestoring`&&(c.fetchStatus=`idle`)}let{error:d,errorUpdatedAt:f,status:p}=c;u=c.data;let m=!1;if(t.placeholderData!==void 0&&u===void 0&&p===`pending`){let e,n=i?.isPlaceholderData&&t.placeholderData===a?.placeholderData;n?(e=i.data,m=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,(n||e!==void 0)&&(p=`success`,u=_e(t.select&&!m?this.#s:i?.data,e,t),l=!0)}if(t.select&&u!==void 0&&!m){if(u===this.#s&&t.select===this.#o)u=this.#c;else try{this.#o=t.select,this.#s=u,u=t.select(u),u=_e(i?.data,u,t),this.#c=u,this.#a=null}catch(e){this.#a=e}}else u===void 0&&(this.#s=void 0,this.#a=null);this.#a&&(d=this.#a,u=this.#c,f=i?.error===d?i.errorUpdatedAt:Date.now(),p=`error`,l=!1);let h=c.fetchStatus===`fetching`,g=p===`pending`,_=p===`error`,v=g&&h,ee=u!==void 0;return{status:p,fetchStatus:c.fetchStatus,isPending:g,isSuccess:p===`success`,isError:_,isInitialLoading:v,isLoading:v,data:u,dataUpdatedAt:c.dataUpdatedAt,error:d,errorUpdatedAt:f,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:c.dataUpdateCount>o.dataUpdateCount||c.errorUpdateCount>o.errorUpdateCount,isFetching:h,isRefetching:h&&!g,isLoadingError:_&&!ee,isPaused:c.fetchStatus===`paused`,isPlaceholderData:l,isRefetchError:_&&ee,isStale:F(e,t),refetch:this.refetch,isEnabled:S(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.options,this.#t.state.data!==void 0&&(this.#l=this.#t),T(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size||this.options.throwOnError&&this.#r.error!==e.error)return!0;for(let t of n??this.#p)if(this.#r[t]!==e[t])return!0;return!1})();j.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function Le(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||S(t.retryOnMount,e)!==!1)}function Re(e,t){return Le(e,t)||e.state.data!==void 0&&P(e,t,t.refetchOnMount)}function P(e,t,n){if(S(t.enabled,e)!==!1&&S(t.staleTime,e)!==`static`){let r=S(n,e);return r===`always`||r!==!1&&F(e,t)}return!1}function ze(e,t,n,r){return(e!==t||S(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&F(e,n)}function F(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(S(t.staleTime,e))}var Be=class extends Ie{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:we(t,n.data),hasPreviousPage:Te(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},Ve=class extends Oe{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||He(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=je({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}this.state.isPaused&&r.canStart()&&t();let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),j.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function He(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ue=class extends y{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),T(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&C(t.mutationKey)!==C(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??He();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){j.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},We=(e,t,n)=>{let r=n?.state.status===`error`&&typeof e.throwOnError==`function`?D(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Ge=e=>{u.useEffect(()=>{e.clearReset()},[e])},Ke=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||D(n,[e.error,r])),qe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Je=(e,t)=>e?.suspense&&t.isPending,Ye=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Xe(e,t,n){let r=f(),i=ee(),a=h(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,qe(o),We(o,i,s),Ge(i);let[l]=u.useState(()=>new t(a,o)),d=l.getOptimisticResult(o);u.useEffect(()=>{l.setOptions(o)},[o,l]);let p=!r&&c;if(u.useSyncExternalStore(u.useCallback(e=>{let t=p?l.subscribe(j.batchCalls(e)):x;return l.updateResult(),t},[l,p]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Je(o,d))throw Ye(o,l,i);if(Ke({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:l.trackResult(d)}function I(e,t){return Xe(e,Ie,t)}function L(e,t){let n=h(t),[r]=u.useState(()=>new Ue(n,e));u.useEffect(()=>{r.setOptions(e)},[r,e]);let i=u.useSyncExternalStore(u.useCallback(e=>r.subscribe(j.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=u.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(x)},[r]);if(i.error&&D(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Ze(e,t){return Xe(e,Be,t)}var Qe={planned:`Blocked`,ready:`Ready`,waiting:`Planned`,paused:`Paused`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`,not_adopted:`Not adopted`},$e=`Planned on`,et={neutral:`bg-muted text-foreground/70`,info:`bg-sky-100 text-sky-800 dark:bg-sky-950 dark:text-sky-200`,progress:`bg-blue-100 text-blue-800 dark:bg-blue-950 dark:text-blue-200`,review:`bg-violet-100 text-violet-800 dark:bg-violet-950 dark:text-violet-200`,success:`bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200`,attention:`bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-200`,danger:`bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200`},tt={neutral:`text-muted-foreground`,info:`text-sky-700 dark:text-sky-300`,progress:`text-blue-700 dark:text-blue-300`,review:`text-violet-700 dark:text-violet-300`,success:`text-emerald-700 dark:text-emerald-300`,attention:`text-amber-700 dark:text-amber-300`,danger:`text-rose-700 dark:text-rose-300`},nt={neutral:`border-border text-muted-foreground`,info:`border-sky-300 text-sky-700 dark:border-sky-800 dark:text-sky-300`,progress:`border-blue-300 text-blue-700 dark:border-blue-800 dark:text-blue-300`,review:`border-violet-300 text-violet-700 dark:border-violet-800 dark:text-violet-300`,success:`border-emerald-300 text-emerald-700 dark:border-emerald-800 dark:text-emerald-300`,attention:`border-amber-300 text-amber-700 dark:border-amber-800 dark:text-amber-300`,danger:`border-rose-300 text-rose-700 dark:border-rose-800 dark:text-rose-300`},rt={info:`border border-sky-300 bg-sky-50 text-sky-900 dark:border-sky-800 dark:bg-sky-950 dark:text-sky-100`,attention:`border border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100`,danger:`border border-rose-300 bg-rose-50 text-rose-900 dark:border-rose-800 dark:bg-rose-950 dark:text-rose-100`},it={neutral:`bg-neutral-400`,info:`bg-sky-500`,progress:`bg-blue-500`,review:`bg-violet-500`,success:`bg-emerald-500`,attention:`bg-amber-500`,danger:`bg-rose-500`},at={neutral:`border-muted-foreground`,info:`border-sky-500`,progress:`border-blue-500`,review:`border-violet-500`,success:`border-emerald-500`,attention:`border-amber-500`,danger:`border-rose-500 dark:border-rose-400`},ot={done:`border-emerald-500 bg-emerald-100 dark:bg-emerald-950`,ready:`border-amber-500 shadow-none`,blocked:`border-dashed border-muted-foreground shadow-none`,paused:`border-dashed border-muted-foreground bg-muted shadow-none`,behindDue:`border-2 border-rose-500 dark:border-rose-400`},st=`border-foreground/70`,ct=`text-foreground`,lt=[[`plannedAt`,`Planned`],[`startedAt`,`Started`],[`reviewAt`,Qe.in_review],[`completedAt`,`Completed`],[`reopenedAt`,`Reopened`],[`pausedAt`,Qe.paused]];function ut(e){let t=new Date(e*1e3),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}var dt=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`,style:`short`}),ft=604800;function pt(e,t=Date.now()/1e3){let n=e-t,r=Math.abs(n);if(r<60)return`just now`;if(r<ft){let[e,t]=r<3600?[Math.trunc(n/60),`minute`]:r<86400?[Math.trunc(n/3600),`hour`]:[Math.trunc(n/86400),`day`];return dt.format(e,t)}let i=new Date(e*1e3),a=i.getFullYear()===new Date(t*1e3).getFullYear();return i.toLocaleDateString(`en`,{month:`short`,day:`numeric`,...a?{}:{year:`numeric`}})}function mt(e,t=Date.now()/1e3){let n=Math.max(0,Math.floor((e-t)/60));if(n<60)return`${n}m`;if(n<1440)return`${Math.floor(n/30)/2}h`;let r=Math.floor(n/1440);return r<14?`${r}d`:r<60?`${Math.floor(r/7)}w`:r<365?`${Math.floor(r/30)}mo`:`${Math.floor(r/365)}y`}function ht(e){return new Date(e*1e3).toLocaleString(`en`,{dateStyle:`medium`,timeStyle:`short`})}function gt(e){let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&e.end===null&&(e.end=n.at),n.status!==`done`&&(n.status===`planned`?t.length>0&&t.push({state:`paused`,start:n.at,end:null,reason:n.reason}):t.push({state:n.status,start:n.at,end:null,reason:null}))}return t}function _t(e,t){return yt(e,t,e=>e!==`paused`)}function vt(e,t){return yt(e,t,e=>e===`paused`)}function yt(e,t,n){let r=gt(e);return r.length===0?null:r.filter(e=>n(e.state)).reduce((e,n)=>e+Math.max((n.end??t)-n.start,0),0)}function bt(e){return lt.flatMap(([t,n])=>{let r=e[t];return r===null?[]:[{label:n,at:r}]}).sort((e,t)=>e.at-t.at)}function xt({at:e,prefix:t=``,className:n}){return(0,p.jsx)(`time`,{className:n,dateTime:new Date(e*1e3).toISOString(),title:ht(e),children:`${t}${pt(e)}`})}var St=3e4;function Ct(e){return typeof e==`object`&&!!e&&typeof e.kind==`string`&&typeof e.code==`string`&&typeof e.message==`string`}async function R(e,t={}){let n=a();if(n===null)throw Error(`No access token for the Toodo server.`);let c=new AbortController,l=setTimeout(()=>c.abort(),St),u,d;try{if(u=await i(`/api/rpc/${encodeURIComponent(e)}`,{method:`POST`,headers:{...n,"Content-Type":`application/json`},body:JSON.stringify(t),signal:c.signal}),u.status===401)throw await o(u)?(s(),Error(`The Toodo server did not accept the access token.`)):r();d=await u.text()}catch(t){throw c.signal.aborted?Error(`The Toodo server did not answer ${e} within ${St/1e3} s.`):t}finally{clearTimeout(l)}if(u.ok)return d?JSON.parse(d):null;let f=null;try{f=JSON.parse(d)}catch{}throw Ct(f)?f:Error(d||`${u.status} ${u.statusText}`)}var z={appInfo:()=>R(`app_info`),checkUpdate:()=>R(`check_update`),listWorkspaces:()=>V(R(`list_workspaces`)),getWorkspace:e=>V(R(`get_workspace`,{id:e})),createWorkspace:e=>V(R(`create_workspace`,{workspace:e})),updateWorkspace:e=>V(R(`update_workspace`,{workspace:e})),deleteWorkspace:e=>V(R(`delete_workspace`,{id:e})),restoreWorkspace:e=>V(R(`restore_workspace`,{id:e})),purgeWorkspace:e=>V(R(`purge_workspace`,{id:e})),listArchive:()=>V(R(`list_archive`)),listGuidelines:e=>V(R(`list_guidelines`,{workspaceId:e})),addGuideline:e=>V(R(`add_guideline`,{guideline:e})),updateGuideline:e=>V(R(`update_guideline`,{guideline:e})),deleteGuideline:e=>V(R(`delete_guideline`,{id:e})),listTasks:e=>V(R(`list_tasks`,{filter:e})),listTaskRelations:()=>V(R(`list_task_relations`)),addTaskRelation:(e,t)=>V(R(`add_task_relation`,{taskId:e,relatedId:t})),removeTaskRelation:(e,t)=>V(R(`remove_task_relation`,{taskId:e,relatedId:t})),getTask:e=>V(R(`get_task`,{id:e})),createTask:e=>V(R(`create_task`,{task:e})),updateTask:e=>V(R(`update_task`,{task:e})),moveTask:(e,t)=>V(R(`move_task`,{id:e,workspaceId:t})),pauseTask:e=>V(R(`pause_task`,{id:e})),waitTask:(e,t,n)=>V(R(`wait_task`,{id:e,until:t,reason:n})),endWait:e=>V(R(`end_wait`,{id:e})),setCompletionNote:(e,t)=>V(R(`set_completion_note`,{id:e,note:t})),reopenTask:(e,t)=>V(R(`reopen_task`,{id:e,reason:t})),setTaskOutcome:(e,t,n)=>V(R(`set_task_outcome`,{id:e,resolution:t,note:n})),checkCriterion:(e,t,n,r)=>V(R(`check_criterion`,{taskId:e,criterionId:t,met:n,evidence:r})),deleteTask:e=>V(R(`delete_task`,{id:e})),deleteDoneTasks:e=>V(R(`delete_done_tasks`,{workspaceId:e})),restoreTask:e=>V(R(`restore_task`,{id:e})),purgeTask:e=>V(R(`purge_task`,{id:e})),addDependency:(e,t,n)=>V(R(`add_dependency`,{taskId:e,dependsOn:t,confirmPause:n})),removeDependency:(e,t)=>V(R(`remove_dependency`,{taskId:e,dependsOn:t})),startTask:(e,t,n)=>V(R(`start_task`,{id:e,reason:t,refs:n})),completeTask:(e,t,n)=>V(R(`complete_task`,{id:e,note:t,refs:n})),concludeTask:(e,t,n,r)=>V(R(`conclude_task`,{id:e,note:t,outcome:n,shippedWith:r})),linkIssue:(e,t)=>V(R(`link_issue`,{id:e,reference:t})),mcpServerInfo:()=>R(`mcp_server_info`),listConnectedApps:()=>V(R(`list_connected_apps`)),revokeConnectedApp:e=>V(R(`revoke_connected_app`,{grantId:e})),reviewPeriod:(e,t)=>V(R(`review_period`,{from:e,to:t})),reviewReport:e=>V(R(`review_report`,{request:e})),getReviewTimeZone:()=>V(R(`get_review_time_zone`)),setReviewTimeZone:e=>V(R(`set_review_time_zone`,{timeZone:e})),saveReviewSnapshot:e=>V(R(`save_review_snapshot`,{request:e})),listReviewSnapshots:()=>V(R(`list_review_snapshots`)),getReviewSnapshot:e=>V(R(`get_review_snapshot`,{id:e})),deleteReviewSnapshot:e=>V(R(`delete_review_snapshot`,{id:e})),getBackupSettings:()=>R(`get_backup_settings`),getBackupStatus:()=>R(`get_backup_status`),saveBackupSettings:e=>V(R(`save_backup_settings`,{settings:e})),listBackups:()=>V(R(`list_backups`)),restoreBackup:e=>V(R(`restore_backup`,{name:e})),listChat:e=>V(R(`list_chat`,{before:e})),sendChatMessage:(e,t)=>V(R(`send_chat_message`,{body:e,clientId:t}))},B={tasksChanged:H(`tasks-changed`),workspacesChanged:H(`workspaces-changed`),guidelinesChanged:H(`guidelines-changed`),taskStatusChanged:H(`task-status-changed`),taskReady:H(`task-ready`),chatChanged:H(`chat-changed`),chatTyping:H(`chat-typing`)};async function V(e){try{return{status:`ok`,data:await e}}catch(e){if(e instanceof Error)throw e;return{status:`error`,error:e}}}function H(e){return{listen:t=>l(e,t)}}function wt(e){switch(e.code){case`unknownCommand`:case`invalidArguments`:return`This page is out of date with the Toodo server. Reload the page, then try again.`;case`commandPanicked`:return`Something went wrong on the Toodo server. Try again; if it keeps failing, look for "a command panicked" in the toodo-server log.`;case`guidelineNotFound`:return`This guideline no longer exists; it was deleted elsewhere. Reload the page to see the current guidelines, and add your text as a new guideline if it is still needed.`;case`storageFailed`:return`The Toodo server could not use its database (${e.message}). Try again; if it keeps failing, check the toodo-server log.`;default:return e.message}}function Tt(e,t){return/filename="([^"]+)"/.exec(e.headers.get(`Content-Disposition`)??``)?.[1]??t}function Et(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),setTimeout(()=>URL.revokeObjectURL(n),0)}async function Dt(){let e=await c(`/api/backups/export`),t=Tt(e,`toodo-backup.sqlite3`);return Et(t,await e.blob()),t}async function Ot(e){return Et(e,await(await c(`/api/backups/${encodeURIComponent(e)}`)).blob()),e}async function kt(e){return await(await c(`/api/backups/restore`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e})).json()}var At=`toodo-install-dismissed`;function jt(){let{userAgent:e,maxTouchPoints:t}=navigator;return/iPhone|iPad|iPod/.test(e)||e.includes(`Macintosh`)&&t>1}function Mt(){return matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0}var U=null,Nt=!1,W=new Set;function G(){W.forEach(e=>e())}function Pt(e){return W.add(e),()=>W.delete(e)}function Ft(){return Nt||Mt()||localStorage.getItem(At)!==null?`none`:U===null?jt()?`home-screen`:`none`:`prompt`}function It(){localStorage.setItem(At,`1`),G()}async function Lt(){let e=U;if(e===null)return;U=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`dismissed`?It():G()}function Rt(){addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),U=e,G()}),addEventListener(`appinstalled`,()=>{U=null,Nt=!0,G()})}function zt(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:jt()&&!Mt()?`needs-install`:`unsupported`}var K=null,Bt={completion:[`Task awaiting completion`],messages:[]};function Vt(e){return K!==null&&Object.keys(Bt).some(t=>K?.[t]===!0&&Bt[t].includes(e))}function Ht(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Ut(e,t){let n=e.options.applicationServerKey;return n===null||n.byteLength===t.length&&new Uint8Array(n).every((e,n)=>e===t[n])}function Wt(){return navigator.serviceWorker.getRegistration()}async function Gt(e){let t=await(await Wt())?.pushManager.getSubscription()??null;return t===null||Ut(t,e)?t:(await t.unsubscribe(),null)}function q(e){return typeof e==`object`&&!!e}function Kt(e){return q(e)&&typeof e.completion==`boolean`&&typeof e.messages==`boolean`}function qt(e){return q(e)&&typeof e.message==`string`&&typeof e.at==`number`}function Jt(e){return q(e)&&typeof e.endpoint==`string`&&Kt(e.settings)&&(e.lastFailure===null||qt(e.lastFailure))}function Yt(e){return q(e)&&typeof e.publicKey==`string`&&(e.subscription===null||Jt(e.subscription))}async function Xt(e,t,n){let r=await t.text(),i;try{i=JSON.parse(r)}catch{throw Error(`The answer to ${e} is not JSON; a proxy in front of the Toodo server may have answered instead.`)}if(!n(i))throw Error(`The answer to ${e} is not the push data this app expects; the Toodo server may be older or newer than the app. Reload the app.`);return i}async function Zt(e){return Xt(`PUT /api/push/subscription`,await c(`/api/push/subscription`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.toJSON())}),Jt)}async function Qt(){let e=await Xt(`GET /api/push`,await c(`/api/push`),Yt),t=await Gt(Ht(e.publicKey)),n=t===null?null:t.endpoint===e.subscription?.endpoint?e.subscription:await Zt(t);return K=n?.settings??null,{publicKey:e.publicKey,permission:Notification.permission,subscription:n}}var $t=1e4;async function en(){let e,t=new Promise((t,n)=>{e=setTimeout(()=>n(Error(`The service worker did not become active within ${$t/1e3} seconds. Reload the app and try again.`)),$t)});try{return await Promise.race([navigator.serviceWorker.ready,t])}finally{clearTimeout(e)}}async function tn(e,t){if(await e!==`granted`)throw Error(`Notifications were not allowed.`);if(await Wt()===void 0)throw Error(`Notifications need the service worker, which only the built app installs.`);let{pushManager:n}=await en(),r=Ht(t),i=await Gt(r)??await n.subscribe({userVisibleOnly:!0,applicationServerKey:r});try{let e=await Zt(i);return K=e.settings,e}catch(e){throw await i.unsubscribe(),e}}async function nn(){await(await(await Wt())?.pushManager.getSubscription())?.unsubscribe(),K=null,await c(`/api/push/subscription`,{method:`DELETE`})}async function rn(e){let t=await Xt(`PUT /api/push/settings`,await c(`/api/push/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),Jt);return K=t.settings,t}async function an(){await c(`/api/push/test`,{method:`POST`})}var on=`toodo-open-task`,sn=`toodo-open-chat`;function cn(e){if(!(`serviceWorker`in navigator))return()=>{};let t=navigator.serviceWorker,n=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===sn&&e()};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}function ln(e){if(!(`serviceWorker`in navigator))return()=>{};let t=navigator.serviceWorker,n=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===on&&`taskId`in t&&typeof t.taskId==`number`&&e(t.taskId)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}async function un(){return`Notification`in window&&Notification.permission===`granted`}async function dn(){return`Notification`in window?Notification.requestPermission():`denied`}function fn(e){Vt(e.title)||new Notification(e.title,{body:e.body})}var pn={planned:`Planned`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`};function mn(e){return e.status===`done`&&e.resolution===`completed`?`Completed`:e.status===`done`&&e.resolution===`not_adopted`?`Not adopted`:pn[e.status]}function hn(e,t){switch(t.status){case`in_progress`:return`Task started`;case`in_review`:return`Task awaiting completion`;case`done`:return t.resolution===`not_adopted`?`Task concluded without merging`:`Task done`;case`planned`:return e===`in_progress`?`Task paused`:`Task status changed`}}function gn(e,t){let n=new Map(e.map(e=>[e.id,e.status]));return t.flatMap(e=>{let t=n.get(e.id);return t===void 0||t===e.status?[]:[{title:hn(t,e),body:`#${e.id} ${e.title}: ${pn[t]} -> ${mn(e)}`}]})}async function _n(e){if(e.length!==0&&(await un()||await dn()===`granted`))for(let t of e)fn(t)}var vn=class extends Error{kind;code;constructor(e){super(wt(e)),this.name=`CommandFailure`,this.kind=e.kind,this.code=e.code}};async function J(e){let t=await e;if(t.status===`error`)throw new vn(t.error);return t.data}var Y={workspaces:[`workspaces`],guidelines:e=>[`guidelines`,e],tasks:[`task-list`,`pages`],taskRelations:[`tasks`,`relations`],archive:[`tasks`,`archive`],backups:[`backups`],backupSettings:[`backup-settings`],backupStatus:[`backup-status`],mcpServerInfo:[`mcp-server-info`],review:(e,t)=>[`review`,e,t],reviewTimeZone:[`review`,`time-zone`],reviewSnapshots:[`review-snapshots`],reviewSnapshot:e=>[`review-snapshots`,e],chat:[`chat`]};function yn(){return Ze({queryKey:Y.chat,queryFn:({pageParam:e})=>J(z.listChat(e)),initialPageParam:null,getNextPageParam:e=>e.hasEarlier?e.messages[0]?.id??null:null})}function bn(e){return[...e.pages].reverse().flatMap(e=>e.messages)}function xn(){let e=h();return L({mutationFn:({body:e,clientId:t})=>J(z.sendChatMessage(e,t)),onSuccess:()=>e.invalidateQueries({queryKey:Y.chat})})}function Sn(){return I({queryKey:Y.mcpServerInfo,queryFn:()=>z.mcpServerInfo(),refetchInterval:5e3})}function Cn(){return I({queryKey:Y.backups,queryFn:()=>J(z.listBackups())})}function wn(){return I({queryKey:Y.backupSettings,queryFn:()=>z.getBackupSettings()})}function Tn(){return I({queryKey:Y.backupStatus,queryFn:()=>z.getBackupStatus(),refetchInterval:6e4})}function En(){let e=h();return L({mutationFn:e=>J(z.saveBackupSettings(e)),onSuccess:t=>(e.setQueryData(Y.backupSettings,t),Promise.all([e.invalidateQueries({queryKey:Y.backups}),e.invalidateQueries({queryKey:Y.backupStatus})]))})}function Dn(){let e=h();return L({mutationFn:e=>J(z.restoreBackup(e)),onSuccess:()=>e.invalidateQueries()})}function On(){return L({mutationFn:Dt})}function kn(){return L({mutationFn:Ot})}function An(){let e=h();return L({mutationFn:kt,onSuccess:()=>e.invalidateQueries()})}function jn(){return I({queryKey:Y.workspaces,queryFn:()=>J(z.listWorkspaces())})}function Mn(){let e=h();return L({mutationFn:e=>J(z.createWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:Y.workspaces})})}function Nn(){let e=h();return L({mutationFn:e=>J(z.updateWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:Y.workspaces,exact:!0})})}function Pn(){return Z(e=>J(z.deleteWorkspace(e)))}function Fn(){return I({queryKey:Y.archive,queryFn:()=>J(z.listArchive())})}function X(e){return Promise.all([e.invalidateQueries({queryKey:Y.tasks}),e.invalidateQueries({queryKey:[`tasks`]}),e.invalidateQueries({queryKey:[`review`]})])}function Z(e){let t=h();return L({mutationFn:e,onSuccess:()=>Promise.all([X(t),t.invalidateQueries({queryKey:Y.workspaces,exact:!0})])})}function In(){return Z(e=>J(z.restoreWorkspace(e)))}function Ln(){return Z(e=>J(z.purgeWorkspace(e)))}function Rn(){return Z(e=>J(z.restoreTask(e)))}function zn(){return Z(e=>J(z.purgeTask(e)))}function Bn(e){return I({queryKey:Y.guidelines(e),queryFn:()=>J(z.listGuidelines(e))})}function Vn(e){let t=h();return L({mutationFn:e,onSuccess:e=>t.invalidateQueries({queryKey:Y.guidelines(e.workspaceId)})})}function Hn(){return Vn(e=>J(z.addGuideline(e)))}function Un(){return Vn(e=>J(z.updateGuideline(e)))}function Wn(){return Vn(e=>J(z.deleteGuideline(e)))}var Gn=[`planned`,`in_progress`,`in_review`];function Q(e){return J(z.listTasks(e))}async function Kn(e){let t=Q({statuses:[`done`],before:e,limit:100}),n=e=>e.length<100?null:Math.min(...e.map(e=>e.id));if(e!==null){let e=await t;return{tasks:e,olderBefore:n(e)}}let[r,i]=await Promise.all([Q({statuses:Gn}),t]),a=new Set([...r,...i].map(e=>e.id)),o=[...new Set(r.flatMap(e=>e.dependsOn))].filter(e=>!a.has(e)),s=[];for(let e=0;e<o.length;e+=100)s.push(o.slice(e,e+100));let c=await Promise.all(s.map(e=>Q({ids:e})));return{tasks:[...r,...i,...c.flat()],olderBefore:n(i)}}function qn(e){let t=new Map;for(let n of e.pages)for(let e of n.tasks)t.set(e.id,e);return[...t.values()].sort((e,t)=>e.id-t.id)}function Jn(e){let t=e.getQueryData(Y.tasks);return t===void 0?void 0:qn(t)}async function Yn(e){let t=e.getQueryData(Y.tasks);t===void 0||t.pages.length<=1||(await e.cancelQueries({queryKey:Y.tasks,exact:!0}),e.setQueryData(Y.tasks,e=>e===void 0?e:{pages:e.pages.slice(0,1),pageParams:e.pageParams.slice(0,1)}))}function Xn(e){let t=h();(0,u.useEffect)(()=>{if(!e)Yn(t);else return()=>void Yn(t)},[e,t])}function Zn(e=[]){let t=Ze({queryKey:Y.tasks,queryFn:({pageParam:e})=>Kn(e),initialPageParam:null,getNextPageParam:e=>e.olderBefore,select:qn}),n=t.data,r=new Set(n?.map(e=>e.id)),i=[...new Set(e.filter(e=>e!=null&&!r.has(e)))].sort((e,t)=>e-t),a=I({queryKey:[...Y.tasks,`by-id`,i],queryFn:()=>Q({ids:i}),enabled:n!==void 0&&i.length>0}),o=i.length===0?[]:a.data??[];return n===void 0||o.length===0?t:{...t,data:[...n,...o].sort((e,t)=>e.id-t.id)}}function Qn(e,t){return I({queryKey:Y.review(e,t),queryFn:()=>J(z.reviewPeriod(e,t))})}function $n(){return I({queryKey:Y.reviewTimeZone,queryFn:()=>J(z.getReviewTimeZone())})}function er(){let e=h();return L({mutationFn:e=>J(z.setReviewTimeZone(e)),onSuccess:()=>e.invalidateQueries({queryKey:[`review`]})})}function tr(){return I({queryKey:Y.reviewSnapshots,queryFn:()=>J(z.listReviewSnapshots())})}function nr(e){return I({queryKey:Y.reviewSnapshot(e??0),queryFn:()=>J(z.getReviewSnapshot(e??0)),enabled:e!==null,staleTime:1/0})}function rr(){let e=h();return L({mutationFn:e=>J(z.saveReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:Y.reviewSnapshots})})}function ir(){let e=h();return L({mutationFn:e=>J(z.deleteReviewSnapshot(e)),onSuccess:()=>e.invalidateQueries({queryKey:Y.reviewSnapshots})})}function ar(){let e=h();(0,u.useEffect)(()=>{let t=[B.tasksChanged.listen(async()=>{let t=Jn(e);await X(e),t===void 0||document.hasFocus()||_n(gn(t,Jn(e)??[])).catch(e=>console.error(`toodo: failed to show status notifications`,e))}),B.workspacesChanged.listen(()=>e.invalidateQueries({queryKey:Y.workspaces,exact:!0})),B.guidelinesChanged.listen(t=>e.invalidateQueries({queryKey:Y.guidelines(t.payload.workspaceId)})),B.chatChanged.listen(()=>e.invalidateQueries({queryKey:Y.chat}))];return()=>{for(let e of t)e.then(e=>e())}},[e])}function or(){let e=h();return L({mutationFn:e=>J(z.startTask(e,null,null)),onSuccess:()=>X(e)})}function sr(){let e=h();return L({mutationFn:e=>J(z.completeTask(e,null,null)),onSuccess:()=>X(e)})}function cr(){let e=h();return L({mutationFn:({id:e,note:t,shippedWith:n=null})=>J(z.concludeTask(e,t,n===null?`not_adopted`:`shipped_with`,n)),onSuccess:()=>X(e)})}function lr(){let e=h();return L({mutationFn:({id:e,note:t})=>J(z.setCompletionNote(e,t)),onSuccess:()=>X(e)})}function ur(){let e=h();return L({mutationFn:({id:e,reason:t})=>J(z.reopenTask(e,t)),onSuccess:()=>X(e)})}function dr(){let e=h();return L({mutationFn:({id:e,resolution:t,note:n})=>J(z.setTaskOutcome(e,t,n)),onSuccess:()=>X(e)})}function fr(){let e=h();return L({mutationFn:e=>J(z.updateTask(e)),onSuccess:()=>X(e)})}function pr(){let e=h();return L({mutationFn:({id:e,workspaceId:t})=>J(z.moveTask(e,t)),onSuccess:()=>X(e)})}function $(e){let t=h();return L({mutationFn:e,onSuccess:()=>X(t)})}function mr(){return $(e=>J(z.pauseTask(e)))}function hr(){return $(({id:e,until:t,reason:n})=>J(z.waitTask(e,t,n)))}function gr(){return $(e=>J(z.endWait(e)))}function _r(){return $(({taskId:e,criterionId:t,met:n,evidence:r})=>J(z.checkCriterion(e,t,n,r)))}function vr(){return Z(e=>J(z.deleteTask(e)))}function yr(){return Z(e=>J(z.deleteDoneTasks(e)))}function br(e,t){return I({queryKey:[...Y.tasks,`done-count`,e],queryFn:async()=>(await Q({workspaceId:e,statuses:[`done`]})).length,enabled:t})}function xr(){return $(({id:e,dependsOn:t,confirmPause:n})=>J(z.addDependency(e,t,n)))}function Sr(){return $(({id:e,dependsOn:t})=>J(z.removeDependency(e,t)))}function Cr(){return I({queryKey:Y.taskRelations,queryFn:()=>J(z.listTaskRelations())})}function wr(e){let t=h();return L({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:Y.taskRelations})})}function Tr(){return wr(({taskId:e,relatedId:t})=>J(z.addTaskRelation(e,t)))}function Er(){return wr(({taskId:e,relatedId:t})=>J(z.removeTaskRelation(e,t)))}function Dr(){let e=h();return L({mutationFn:e=>J(z.createTask(e)),onSuccess:()=>X(e)})}export{Un as $,w as $t,mr as A,ot as At,nr as B,tt as Bt,kn as C,ut as Ct,Sn as D,bt as Dt,Bn as E,pt as Et,ur as F,et as Ft,xn as G,M as Gt,$n as H,I as Ht,Dn as I,it as It,er as J,C as Jt,ar as K,j as Kt,Rn as L,at as Lt,Ln as M,st as Mt,Sr as N,$e as Nt,pr as O,vt as Ot,Er as P,Qe as Pt,Zn as Q,x as Qt,In as R,nt as Rt,br as S,_t as St,gr as T,mt as Tt,En as U,Ve as Ut,tr as V,L as Vt,rr as W,Me as Wt,or as X,le as Xt,dr as Y,ue as Yt,Cr as Z,ce as Zt,yr as _,Rt as _t,Hn as a,h as an,nn as at,vr as b,B as bt,wn as c,cn as ct,yn as d,rn as dt,S as en,fr as et,_r as f,an as ft,Mn as g,Pt as gt,Dr as h,Ft as ht,xr as i,g as in,jn as it,zn as j,ct as jt,Xn as k,gt as kt,Tn as l,ln as lt,cr as m,Lt as mt,Y as n,te as nn,An as nt,Tr as o,tn as ot,sr as p,It as pt,lr as q,ae as qt,J as r,y as rn,hr as rt,Fn as s,Qt as st,bn as t,E as tn,Nn as tt,Cn as u,zt as ut,Wn as v,Et as vt,On as w,ht as wt,Pn as x,xt,ir as y,z as yt,Qn as z,rt as zt};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./jsx-runtime-C3cWAN_r.js";import{A as r,Bt as i,C as a,D as o,E as s,G as c,J as l,L as u,M as d,N as f,Nt as p,O as m,P as ee,Pt as h,Q as te,Rt as g,S as ne,T as _,X as v,Z as re,_ as ie,b as y,c as ae,ct as oe,d as se,dt as b,f as x,g as S,h as C,j as w,k as ce,l as T,m as E,p as D,s as le,st as ue,u as O,v as k,w as de,x as A,y as j,zt as fe}from"./index-BhedIiZp.js";import{t as M}from"./Selector-DoBdC70u.js";import{n as N,t as P}from"./button-HISRpujD.js";import{B as pe,Bt as F,Ct as I,H as L,It as R,J as z,Ot as B,St as V,V as me,W as he,it as ge,kt as H,r as _e,s as ve,vt as ye,wt as be,xt as U,y as xe,yt as Se,z as Ce}from"./queries-Bcvk9W54.js";import{t as W}from"./opener-DWhHPoCL.js";var G=e(t(),1),K=n(),we={completed:F.success,opened_for_review:F.review,started:F.progress,worked_on:F.progress,planned:F.neutral},q=`live`,J=`all`,Y=`any`,Te=[{kind:`week`,label:`Week`},{kind:`month`,label:`Month`},{kind:`quarter`,label:`Quarter`},{kind:`year`,label:`Year`},{kind:`custom`,label:`Custom`}];function Ee({disabled:e,items:t}){return(0,K.jsx)(c,{items:t,alignment:`end`,menuWidth:192,renderTrigger:t=>(0,K.jsx)(P,{...t,size:`sm`,variant:`primary`,icon:(0,K.jsx)(g,{}),label:`Export`,isDisabled:e})})}function X(e,t){return`${e} ${t}${e===1?``:`s`}`}function De(){let e=L(),t=z(),[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(null),c=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];async function l(e){s(null);try{await t.mutateAsync(e),r(!1)}catch(e){s(e instanceof Error?e.message:String(e))}}if(!e.data)return null;let{timeZone:u,configured:d}=e.data;return n?(0,K.jsxs)(`form`,{"aria-label":`Review time zone`,className:`flex flex-wrap items-center gap-2 print:hidden`,onSubmit:e=>{e.preventDefault(),l(i)},children:[(0,K.jsx)(`label`,{htmlFor:`review-time-zone`,className:`text-xs`,children:`Time zone for every device`}),(0,K.jsx)(`input`,{id:`review-time-zone`,list:`review-time-zones`,required:!0,className:b(v,`w-56`),value:i,onChange:e=>a(e.target.value)}),(0,K.jsx)(`datalist`,{id:`review-time-zones`,children:c.map(e=>(0,K.jsx)(`option`,{value:e},e))}),(0,K.jsx)(P,{size:`sm`,variant:`primary`,type:`submit`,label:`Save`,isDisabled:t.isPending}),d!==null&&(0,K.jsx)(P,{size:`sm`,variant:`secondary`,label:`Use the server's`,onClick:()=>void l(null)}),(0,K.jsx)(P,{size:`sm`,variant:`ghost`,label:`Cancel`,onClick:()=>r(!1)}),o&&(0,K.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o})]}):(0,K.jsxs)(`span`,{children:[`Days are in `,u,d===null&&` (the server's time zone)`,`.`,` `,(0,K.jsx)(P,{size:`sm`,variant:`ghost`,label:`Change time zone`,className:`print:hidden`,onClick:()=>{a(d??u),r(!0)}})]})}function Z({onShowTask:e}){let[t,n]=(0,G.useState)(()=>A(`week`,I(Date.now()/1e3))),[s,c]=(0,G.useState)(null),[f,p]=(0,G.useState)(j),[m,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(null),x=Ce(t.from,t.to),S=me(),C=pe(_),w=he(),T=xe(),E=_!==null,D=E?C:x,O=ge(),k=ve(),F=E?C.data?.workspaces??[]:[...O.data??[],...k.data?.workspaces??[]],L=new Map(F.map(e=>[e.id,e.name])),R=E?C.data&&{period:{kind:C.data.summary.period,from:C.data.summary.from,to:C.data.summary.to},entries:C.data.entries,start:C.data.summary.start,end:C.data.summary.end,timeZone:C.data.summary.timeZone,now:C.data.summary.savedAt}:x.data&&{period:t,entries:x.data.entries,start:x.data.start,end:x.data.end,timeZone:x.data.timeZone,now:Date.now()/1e3},z=R?.period??t,B=R&&se(R.entries,f),V=ce(R?.entries??[]);f.label!==null&&!V.includes(f.label)&&V.push(f.label);let H=[f.workspaceId===null?`across all workspaces`:`in ${L.get(f.workspaceId)??`workspace ${f.workspaceId}`}`,f.label!==null&&`labelled ${f.label}`].filter(Boolean).join(`, `),W=a[z.kind];function Z(e){c(null),n(e)}function Q(e){c(null),g(null),v(e)}async function Ne(){try{let e=await w.mutateAsync({period:t.kind,from:t.from,to:t.kind===`custom`?t.to:null,workspaceId:f.workspaceId,label:f.label,title:null});c(`Saved "${e.title}" with ${X(e.entryCount,`task`)}; reopen it from Saved reviews.`)}catch(e){c(`Could not save the review: ${e instanceof Error?e.message:String(e)}`)}}async function Pe(e){try{await T.mutateAsync(e),Q(null),c(`Deleted the saved review.`)}catch(e){c(`Could not delete the saved review: ${e instanceof Error?e.message:String(e)}`)}}function Fe(e){e!==t.kind&&Z(e===`custom`?{...t,kind:e}:A(e,t.from))}function $(e){return E?C.data?Promise.resolve(e===`csv`?C.data.csv:C.data.markdown):Promise.reject(Error(`the saved review is still loading`)):_e(Se.reviewReport({period:t.kind,date:null,from:t.from,to:t.kind===`custom`?t.to:null,format:e,timeZone:null,workspaceId:f.workspaceId,label:f.label}))}async function Ie(){try{let e=$(`markdown`);if(typeof ClipboardItem>`u`)await navigator.clipboard.writeText((await e).contents);else{let t=e.then(({contents:e})=>new Blob([e],{type:`text/plain`}));await navigator.clipboard.write([new ClipboardItem({"text/plain":t})])}c(`Copied as Markdown.`)}catch(e){c(`Could not copy: ${e instanceof Error?e.message:String(e)}`)}}async function Le(e){try{let t=await $(e);ye(t.fileName,new Blob([t.contents],{type:`${t.mediaType};charset=utf-8`})),c(`Downloaded ${t.fileName}`)}catch(e){c(`Could not export: ${e instanceof Error?e.message:String(e)}`)}}return(0,K.jsxs)(`section`,{"aria-labelledby":`review-heading`,className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h2`,{id:`review-heading`,className:`text-xl font-semibold tracking-tight`,children:E&&C.data?C.data.summary.title:de[z.kind]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Work recorded from `,z.from,` to `,z.to,` `,H,`.`,` `,E?C.data&&(0,K.jsxs)(`span`,{children:[`Saved `,be(C.data.summary.savedAt),`, with days in `,C.data.summary.timeZone,`; it stays as it was when saved.`]}):(0,K.jsx)(De,{})]})]}),(E||(S.data?.length??0)>0)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,K.jsx)(M,{label:`Saved reviews`,isLabelHidden:!0,size:`sm`,options:[{value:q,label:`Live review`},...(S.data??[]).map(e=>({value:String(e.id),label:`${e.title} (saved ${I(e.savedAt)})`}))],value:_===null?q:String(_),onChange:e=>Q(e===q?null:Number(e))}),_!==null&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{size:`sm`,variant:`secondary`,label:`Back to the live review`,onClick:()=>Q(null)}),(0,K.jsx)(P,{size:`sm`,variant:`ghost`,label:`Delete saved review`,isDisabled:T.isPending,onClick:()=>void Pe(_)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2 print:hidden`,children:[!E&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(te,{label:`Review period`,size:`sm`,value:t.kind,onChange:e=>typeof e==`string`&&Fe(e),children:Te.map(({kind:e,label:t})=>(0,K.jsx)(re,{value:e,label:t},e))}),t.kind===`week`&&(0,K.jsx)(u,{label:`Week starting`,size:`sm`,format:`system_date`,value:t.from,onChange:e=>e&&Z(d(e))}),t.kind===`custom`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{label:`From`,size:`sm`,format:`system_date`,max:t.to,value:t.from,onChange:e=>e&&e<=t.to&&Z({...t,from:e})}),(0,K.jsx)(u,{label:`To`,size:`sm`,format:`system_date`,min:t.from,value:t.to,onChange:e=>e&&e>=t.from&&Z({...t,to:e})})]}),t.kind!==`week`&&t.kind!==`custom`&&(0,K.jsx)(`span`,{className:`px-1 text-sm font-medium`,children:ne(t)}),(0,K.jsx)(N,{size:`sm`,variant:`secondary`,icon:(0,K.jsx)(i,{}),label:`Previous ${W}`,tooltip:`Previous ${W}`,onClick:()=>Z(r(t,-1))}),(0,K.jsx)(N,{size:`sm`,variant:`secondary`,icon:(0,K.jsx)(fe,{}),label:`Next ${W}`,tooltip:`Next ${W}`,onClick:()=>Z(r(t,1))}),t.kind!==`custom`&&(0,K.jsx)(P,{size:`sm`,variant:`ghost`,label:`This ${W}`,onClick:()=>Z(A(t.kind,I(Date.now()/1e3)))})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsx)(Ee,{disabled:!B,items:[...E?[]:[{label:`Save as snapshot`,onClick:()=>void Ne()}],{label:`Copy as Markdown`,onClick:()=>void Ie()},{label:`Save as Markdown`,onClick:()=>void Le(`markdown`)},{label:`Save as CSV`,onClick:()=>void Le(`csv`)},{label:`Print or save as PDF`,onClick:()=>window.print()}]})})]}),(0,K.jsxs)(`div`,{role:`group`,"aria-label":`Review filters`,className:`flex flex-wrap items-center gap-2 print:hidden`,children:[(0,K.jsx)(M,{label:`Workspace`,isLabelHidden:!0,size:`sm`,options:[{value:J,label:`All workspaces`},...F.map(e=>({value:String(e.id),label:e.name}))],value:f.workspaceId===null?J:String(f.workspaceId),onChange:e=>p({...f,workspaceId:e===J?null:Number(e)})}),(0,K.jsx)(M,{label:`Label`,isLabelHidden:!0,size:`sm`,options:[{value:Y,label:V.length===0?`No labels in this period`:`Any label`},...V.map(e=>({value:`label:${e}`,label:e}))],value:f.label===null?Y:`label:${f.label}`,onChange:e=>p({...f,label:e===Y?null:e.slice(6)})}),(f.workspaceId!==null||f.label!==null)&&(0,K.jsx)(P,{size:`sm`,variant:`ghost`,label:`Clear filters`,onClick:()=>p(j)})]}),s&&(0,K.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground print:hidden`,children:s}),(0,K.jsx)(`p`,{role:`status`,className:b(`text-sm text-muted-foreground`,!D.isPending&&`sr-only`),children:D.isPending?`Loading the review...`:B?`Showing ${B.length} ${B.length===1?`task`:`tasks`} with activity in this ${W}.`:``}),D.isError&&(0,K.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Failed to load the review: `,D.error.message]}),B?.length===0&&(0,K.jsx)(le,{title:R?.entries.length===0?`No recorded activity in this ${W}.`:`No recorded activity in this ${W} matches the filters.`,hint:E?`This saved review keeps the tasks it had when it was saved.`:R?.entries.length===0?`Toodo records each task as it is planned, started, moved to review, and completed, so reviews fill up as you work.`:`Pick another period or change the filters to look at other work.`,action:E?void 0:(0,K.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2 print:hidden`,children:(0,K.jsx)(P,{size:`sm`,variant:`secondary`,label:`Show the ${W} before`,onClick:()=>Z(r(t,-1))})})}),R&&B&&B.length>0&&(0,K.jsx)(Me,{shown:R,entries:B,workspaces:F}),R&&B&&(0,K.jsx)(je,{shown:R,entries:B,editable:!E}),z.kind===`year`&&B&&(0,K.jsx)(Ae,{entries:B}),B&&ie(B).map(t=>(0,K.jsxs)(`section`,{"aria-label":y[t.outcome],className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`h3`,{className:b(`text-sm font-semibold`,we[t.outcome]),children:[y[t.outcome],` `,(0,K.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`(`,t.entries.length,`)`]})]}),(0,K.jsx)(`ul`,{className:`flex flex-col divide-y rounded-lg border`,children:t.entries.map(({task:t,at:n,commits:r,archived:i,pullRequest:a})=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(l,{type:t.taskType}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[`#`,t.id]}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Open #${t.id} ${t.title}`,title:t.title,onClick:()=>e?.(t.id),className:`min-w-0 flex-1 truncate text-left text-sm font-medium hover:underline max-md:min-h-11`,children:t.title}),t.resolution===`not_adopted`&&(0,K.jsx)(h,{className:`shrink-0`,label:`Not adopted`}),i&&(0,K.jsx)(h,{className:`shrink-0`,label:`Archived`}),t.resolution===`completed`&&(0,K.jsx)(h,{className:`shrink-0`,variant:`green`,label:`Completed`}),o(t)&&(0,K.jsx)(ke,{url:o(t),stats:a}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground max-md:hidden print:inline`,children:[L.get(t.workspaceId)??`Workspace ${t.workspaceId}`,` · `,(0,K.jsx)(U,{at:n})]})]}),(0,K.jsx)(oe,{task:t}),i||E?null:m?.id===t.id?(0,K.jsx)(ee,{task:t,focusPlan:m.field,onDone:()=>g(null)}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground empty:hidden print:hidden`,children:(0,K.jsx)(ue,{task:t,onEdit:e=>g({id:t.id,field:e})})}),t.completionNote&&(0,K.jsx)(`p`,{"aria-label":`Completion note of #${t.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:t.completionNote}),R&&(0,K.jsx)(Oe,{task:t,shown:R}),r.length>0&&(0,K.jsx)(`ul`,{"aria-label":`Commits of #${t.id} this ${W}`,className:`flex flex-col gap-0.5`,children:r.map(e=>(0,K.jsxs)(`li`,{className:`flex gap-2 text-xs`,title:e.author,children:[(0,K.jsx)(`code`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}),(0,K.jsx)(`span`,{className:`truncate`,children:ae(e.message)})]},e.sha))})]},t.id))})]},t.outcome))]})}function Q(e){return e===0?`0h`:E(e)}function Oe({task:e,shown:t}){let{start:n,end:r,now:i}=t,a=V(e.timeline,i),o=B(e.timeline,i);if(a===null||o===null)return null;let s=H(e.timeline).filter(e=>e.state===`paused`&&e.start<r&&(e.end??i)>n);return(0,K.jsxs)(`div`,{"aria-label":`Time of #${e.id}`,className:`flex flex-col gap-0.5 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`p`,{children:[Q(a),` active, `,Q(o),` waiting`]}),s.length>0&&(0,K.jsx)(`ul`,{"aria-label":`Waits of #${e.id}`,className:`flex flex-col gap-0.5`,children:s.map(e=>(0,K.jsxs)(`li`,{className:`break-words-keep`,children:[`Waiting `,Q(Math.max((e.end??i)-e.start,0)),` from `,I(e.start),e.end===null&&`, still waiting`,`: `,e.reason??`no reason recorded`]},e.start))})]})}function ke({url:e,stats:t}){let n=s(e),r=t=>{t.preventDefault(),W(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,K.jsx)(`a`,{href:e,title:t?`${e} \u00b7 ${m(t)}`:e,"aria-label":n?`Pull request #${n}`:`Pull request`,onClick:r,onAuxClick:r,className:`shrink-0 text-xs text-primary underline underline-offset-2 hover:no-underline max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:n?`#${n}`:`PR`})}function Ae({entries:e}){let t=f(e);return t===null?null:(0,K.jsxs)(`section`,{"aria-labelledby":`year-in-review-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(`h3`,{id:`year-in-review-heading`,className:`text-sm font-semibold`,children:`Year in review`}),t.pullRequests&&(0,K.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Merged pull requests`}),(0,K.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.pullRequests})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Lines changed`}),(0,K.jsxs)(`dd`,{className:`text-lg font-semibold`,children:[(0,K.jsxs)(`span`,{children:[`+`,t.pullRequests.additions]}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,K.jsxs)(`span`,{children:[`-`,t.pullRequests.deletions]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Files changed`}),(0,K.jsx)(`dd`,{className:`text-lg font-semibold`,children:t.pullRequests.changedFiles})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Reviews`}),(0,K.jsxs)(`dd`,{className:`text-lg font-semibold`,title:S(t.pullRequests),children:[t.pullRequests.reviews,(0,K.jsxs)(`span`,{className:`ml-1 text-xs font-normal text-muted-foreground`,children:[`on `,t.pullRequests.reviewed,` of `,t.pullRequests.pullRequests]})]})]})]}),t.largest.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest pull requests`}),(0,K.jsx)(`ol`,{"aria-label":`Largest pull requests`,className:`flex flex-col gap-1`,children:t.largest.map(({task:e,pullRequest:t})=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsx)(l,{type:e.taskType}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:m(t)})]},e.id))})]}),t.research.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Research conclusions`}),(0,K.jsx)(`ul`,{"aria-label":`Research conclusions`,className:`flex flex-col divide-y rounded-md border`,children:t.research.map(({task:e,at:t,adopted:n})=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-1 px-2 py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,K.jsx)(h,{className:`shrink-0`,variant:n?`green`:`neutral`,label:n?`Adopted`:`Not adopted`}),(0,K.jsx)(U,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,at:t})]}),(0,K.jsx)(`p`,{"aria-label":`Research conclusion of #${e.id}`,className:`whitespace-pre-line break-words-keep text-xs`,children:e.completionNote??(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`No conclusion written.`})})]},e.id))})]}),t.overruns.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Largest estimate overruns`}),(0,K.jsx)(`ol`,{"aria-label":`Largest estimate overruns`,className:`flex flex-col gap-1`,children:t.overruns.map(({task:e,estimated:t,actual:n})=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsx)(l,{type:e.taskType}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,K.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:[`estimated `,E(t),`, `,E(n),` active`]})]},e.id))})]})]})}function je({shown:e,entries:t,editable:n}){let r=_(e.end,t,e.now),i=n?t.filter(({archived:e})=>!e).map(({task:e})=>p(e)):[],a=i.filter(e=>e.includes(`estimate`)).length,o=i.filter(e=>e.includes(`dueDate`)).length;if(r===null&&a+o===0)return null;let s=(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Missing plan`}),(0,K.jsxs)(`dd`,{children:[[a>0&&`${X(a,`task`)} without an estimate`,o>0&&`${X(o,`task`)} without a due date`].filter(Boolean).join(`, `),`; add them from the marks on the tasks below`]})]});return(0,K.jsxs)(`section`,{"aria-labelledby":`plan-heading`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsx)(`h3`,{id:`plan-heading`,className:`text-sm font-semibold`,children:`Plan vs actual`}),r===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm`,children:`No reviewed task has an estimate or a due date, so there is nothing to compare yet.`}),(0,K.jsx)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:s})]}):(0,K.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Estimate vs active time`}),(0,K.jsx)(`dd`,{children:r.time?C(r.time):`No completed task had an estimate`})]}),(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Due dates met`}),(0,K.jsx)(`dd`,{children:r.dueDates?D(r.dueDates):`No completed task had a due date`})]}),a+o>0&&s]}),r!==null&&r.late.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs text-muted-foreground`,children:`Late tasks`}),(0,K.jsx)(`ul`,{"aria-label":`Late tasks`,className:`flex flex-col gap-1`,children:r.late.map(e=>(0,K.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[(0,K.jsx)(l,{type:e.task.taskType}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:e.task.title})]}),(0,K.jsx)(`span`,{className:b(`ml-auto shrink-0 text-xs`,F.danger),children:k(e)})]},e.task.id))})]})]})}function Me({shown:e,entries:t,workspaces:n}){let r=w(e.period,t,n,e.timeZone),i=Math.max(1,...(r.completedPerMonth??[]).map(({count:e})=>e));return(0,K.jsxs)(`section`,{"aria-label":`Summary`,className:`flex flex-col gap-3 rounded-lg border p-3`,children:[(0,K.jsxs)(`dl`,{className:`flex flex-wrap gap-x-6 gap-y-2`,children:[r.outcomes.map(({outcome:e,count:t})=>(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:y[e]}),(0,K.jsx)(`dd`,{className:`text-lg font-semibold`,children:t})]},e)),r.notAdopted>0&&(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Not adopted`}),(0,K.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.notAdopted})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Commits`}),(0,K.jsx)(`dd`,{className:`text-lg font-semibold`,children:r.commits})]})]}),(0,K.jsxs)(`dl`,{className:`grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[auto_1fr]`,children:[T.map(e=>{let t=r[e];return(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:O[e]}),(0,K.jsx)(`dd`,{children:t===null?`No data`:`${E(t.median)} (${t.tasks} ${t.tasks===1?`task`:`tasks`})`})]},e)}),r.changes&&(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Changes in completed pull requests`}),(0,K.jsx)(`dd`,{children:x(r.changes)})]}),r.completedByType.length>0&&(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by type`}),(0,K.jsx)(`dd`,{children:r.completedByType.map(({taskType:e,count:t})=>`${e} ${t}`).join(`, `)})]}),r.completedByWorkspace.length>0&&(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Completed by workspace`}),(0,K.jsx)(`dd`,{children:r.completedByWorkspace.map(({workspace:e,count:t})=>`${e} ${t}`).join(`, `)})]})]}),r.completedPerMonth&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Completed per month`}),(0,K.jsx)(`ul`,{"aria-label":`Completed per month`,className:`flex flex-col gap-0.5`,children:r.completedPerMonth.map(({month:e,count:t})=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`w-16 shrink-0 font-mono text-muted-foreground`,children:e}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:b(`h-2 rounded-sm`,R.success),style:{width:`${t/i*60}%`,minWidth:t>0?4:0}}),(0,K.jsx)(`span`,{children:t})]},e))})]})]})}export{Z as Review};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./jsx-runtime-C3cWAN_r.js";import{n as r,t as i}from"./button-HISRpujD.js";import{t as a}from"./details-sheet-DZm5HiKY.js";import{F as o,Ft as s,H as c,I as l,It as u,Mt as d,Pt as f,U as p,Vt as m,W as h,at as g,ct as _,dt as v,it as y,lt as b,ot as x,ut as S}from"./index-BhedIiZp.js";import{t as C,u as w}from"./Selector-DoBdC70u.js";import{Bt as T,Dt as E,Et as D,O,P as k,Z as ee,et as A,f as j,it as M,o as N,wt as te,xt as P}from"./queries-Bcvk9W54.js";import{t as ne}from"./opener-DWhHPoCL.js";import{t as F}from"./createLucideIcon-DtNDbJdC.js";var I={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};I.node;var L=F(I),R={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};R.node;var z=F(R),B={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};B.node;var V=F(B),H=e(t(),1),U=n();function W({onClose:e,children:t}){let n=(0,H.useRef)(null),[r,o]=(0,H.useState)(!1);function s(){n.current?.querySelector(`form[data-dirty]`)?o(!0):e()}return(0,H.useEffect)(()=>{function e(e){e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[aria-haspopup='menu'][aria-expanded='true']`)||(r?o(!1):e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select, [role=combobox], [role=listbox]`)||s())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,U.jsx)(a,{ref:n,width:`min(480px, max(360px, 40vw), calc(100vw - 32px))`,onClose:s,banner:r&&(0,U.jsxs)(`div`,{role:`group`,"aria-label":`Unsaved changes`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted px-4 py-2 text-xs`,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Discard your unsaved changes?`}),(0,U.jsx)(i,{size:`sm`,variant:`secondary`,label:`Keep editing`,autoFocus:!0,onClick:()=>o(!1)}),(0,U.jsx)(i,{size:`sm`,variant:`destructive`,label:`Discard changes`,onClick:e})]}),children:t})}function G(e){switch(e.status){case`in_progress`:return`Started`;case`in_review`:return`In review`;case`done`:return`Completed`;case`planned`:return e.reopened?`Reopened`:`Paused`}}function K({task:e}){let t=e.timeline.filter(e=>e.reason!==null);return t.length===0?null:(0,U.jsx)(`ol`,{"aria-label":`Reasons of #${e.id}`,className:`mt-1 flex flex-col gap-0.5`,children:t.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 max-md:flex-wrap max-md:gap-y-0`,children:[(0,U.jsx)(P,{className:`shrink-0 text-muted-foreground`,at:e.at}),(0,U.jsx)(`span`,{className:`shrink-0 font-medium`,children:G(e)}),(0,U.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words-keep max-md:basis-full`,children:e.reason})]},t))})}var q={lane:`Lane`,discord:`Discord`,pr:`PR`};function J({value:e}){if(/^https?:\/\//i.test(e)){let t=t=>{t.preventDefault(),ne(e).catch(t=>console.error(`Failed to open ${e}`,t))};return(0,U.jsx)(`a`,{href:e,onClick:t,onAuxClick:t,className:`min-w-0 break-all text-primary underline underline-offset-2 hover:no-underline`,children:e})}let t=e.indexOf(`:`),n=t>0?q[e.slice(0,t)]:void 0;return n===void 0?(0,U.jsx)(`code`,{className:`min-w-0 break-all`,children:e}):(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n}),(0,U.jsx)(`code`,{className:`min-w-0 break-all`,children:e.slice(t+1)})]})}function Y({task:e}){return e.refs.length===0?null:(0,U.jsx)(y,{label:`Refs`,children:(0,U.jsx)(`ul`,{"aria-label":`Refs of #${e.id}`,className:`flex flex-col gap-0.5`,children:e.refs.map(e=>(0,U.jsx)(`li`,{className:`flex min-w-0`,children:(0,U.jsx)(J,{value:e})},e))})})}function X({task:e,detailed:t}){let n=E(e.milestones);return n.length===0?null:t?(0,U.jsxs)(y,{label:`Timeline`,children:[(0,U.jsx)(`dl`,{"aria-label":`Timeline of #${e.id}`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:n.map(({label:e,at:t})=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(P,{at:t})})]},e))}),(0,U.jsx)(K,{task:e})]}):(0,U.jsx)(`p`,{"aria-label":`Timeline of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:n.map(({label:e,at:t})=>(0,U.jsx)(P,{at:t,prefix:`${e} `},e))})}function re({task:e,tasks:t,context:n,navigation:a}){let o=ee(),s=N(),c=k(),l=(o.data??[]).flatMap(({taskId:t,relatedId:n})=>t===e.id?[n]:n===e.id?[t]:[]).filter(e=>n.byId.has(e)),d=t.filter(t=>t.id!==e.id&&!l.includes(t.id)),f=[...new Set([e.workspaceId,...d.map(e=>e.workspaceId)])].map(e=>({workspaceId:e,tasks:d.filter(t=>t.workspaceId===e)})).filter(e=>e.tasks.length>0),p=S(),m=s.isPending||c.isPending||p,h=s.error??c.error;if(l.length===0&&f.length===0)return null;let g=f.length>0&&(0,U.jsx)(C,{label:`Add related task to #${e.id}`,isLabelHidden:!0,size:`sm`,width:192,placeholder:`Add related task...`,value:``,isDisabled:m,options:f.map(e=>({type:`section`,title:n.workspaceName(e.workspaceId),options:e.tasks.map(e=>({value:String(e.id),label:`#${e.id} ${e.title}`}))})),onChange:t=>{t&&s.mutate({taskId:e.id,relatedId:Number(t)})}}),_=h&&(0,U.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:h.message});return l.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs`,children:[g,_]}):(0,U.jsxs)(y,{label:`Related`,children:[(0,U.jsxs)(`ul`,{"aria-label":`Related tasks of #${e.id}`,className:`flex flex-wrap items-center gap-1 max-md:gap-2`,children:[l.map(t=>{let o=n.byId.get(t),s=b(t,e.workspaceId,n);return(0,U.jsxs)(`li`,{className:`inline-flex min-w-0 items-center max-md:gap-2`,children:[(0,U.jsx)(i,{size:`sm`,variant:`secondary`,label:o===void 0?s:`${s} ${o.title}`,"aria-label":`Open related task ${s}`,tooltip:o?.title,className:`min-w-0 max-w-56 tabular-nums`,isDisabled:a===void 0||!a.canOpen(t),onClick:()=>a?.open(t)}),(0,U.jsx)(r,{size:`sm`,variant:`ghost`,label:`Remove related task #${t} from #${e.id}`,tooltip:`Remove related task`,icon:(0,U.jsx)(u,{}),isDisabled:m,onClick:()=>c.mutate({taskId:e.id,relatedId:t})})]},t)}),g]}),_]})}function ie({task:e}){let t=A();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i,{size:`sm`,variant:e.autopilot?`primary`:`secondary`,changesData:!0,"aria-pressed":e.autopilot,"aria-label":`Autopilot of #${e.id}`,label:e.autopilot?`Autopilot on`:`Autopilot off`,icon:(0,U.jsx)(m,{"aria-hidden":!0}),tooltip:e.autopilot?`Marked for autopilot: an executor may take it up on its own once it is ready. Click to clear.`:`Not marked for autopilot. Click to let an executor take it up on its own once it is ready.`,isDisabled:t.isPending,onClick:()=>t.mutate({status:null,id:e.id,taskType:e.taskType,title:e.title,description:e.description,estimate:e.estimate,dueDate:e.dueDate,autopilot:!e.autopilot,criteria:null}),className:`shrink-0`}),t.error&&(0,U.jsx)(`span`,{role:`alert`,className:`text-xs text-destructive`,children:t.error.message})]})}function ae({task:e}){let t=M(),n=O(),r=S(),i=t.data??[];return i.length<2?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`inline-flex`,title:`Move the task to another workspace; its history, notes, criteria, refs, and links stay`,children:(0,U.jsx)(C,{label:`Workspace of #${e.id}`,isLabelHidden:!0,size:`sm`,width:160,value:String(e.workspaceId),isDisabled:n.isPending||r,options:i.map(e=>({value:String(e.id),label:e.name})),onChange:t=>n.mutate({id:e.id,workspaceId:Number(t)})})}),n.error&&(0,U.jsx)(`span`,{role:`alert`,className:`text-xs text-destructive`,children:n.error.message})]})}function oe({task:e}){return(0,U.jsxs)(U.Fragment,{children:[(e.estimate!==null||e.dueDate!==null)&&(0,U.jsxs)(`p`,{"aria-label":`Plan of #${e.id}`,className:`flex flex-wrap gap-x-2 text-xs text-muted-foreground`,children:[e.estimate!==null&&(0,U.jsxs)(`span`,{children:[`Estimate `,d(e.estimate)]}),e.dueDate!==null&&(0,U.jsx)(g,{task:e})]}),(0,U.jsx)(_,{task:e}),(0,U.jsx)(Y,{task:e})]})}var se={progress:`Progress`,blocker:`Blocker`,decision:`Decision`},ce={progress:`neutral`,blocker:`warning`,decision:`info`};function Z({kind:e}){return(0,U.jsx)(f,{"data-note-kind":e,className:`shrink-0`,variant:ce[e],label:se[e]})}function le({task:e,detailed:t}){let n=e.notes;if(n.length===0)return null;if(!t){let t=n[n.length-1];return(0,U.jsxs)(`p`,{"aria-label":`Latest note of #${e.id}`,className:`flex min-w-0 items-center gap-1.5 text-xs`,title:te(t.at),children:[(0,U.jsx)(Z,{kind:t.kind}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:h(t.body)}),n.length>1&&(0,U.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`+${n.length-1} more`})]})}return(0,U.jsx)(y,{label:`Notes (${n.length})`,children:(0,U.jsx)(`ol`,{"aria-label":`Notes of #${e.id}`,className:`flex flex-col gap-2`,children:n.map((e,t)=>(0,U.jsxs)(`li`,{className:`flex flex-col gap-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(Z,{kind:e.kind}),(0,U.jsx)(P,{className:`text-muted-foreground`,at:e.at})]}),(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`p`,{className:`whitespace-pre-line break-words-keep`,children:e.body}),children:(0,U.jsx)(x,{source:e.body})})]},t))})})}var ue={pending:`Pending`,met:`Met`,failed:`Failed`},de={pending:T.neutral,met:T.success,failed:T.danger},Q={user:`you`,agent:`an agent`,toodo:`Toodo`};function $({state:e}){let t=e===`met`?L:e===`failed`?z:V;return(0,U.jsx)(`span`,{role:`img`,"aria-label":ue[e],className:v(`flex size-4 shrink-0 items-center justify-center`,de[e]),children:(0,U.jsx)(t,{"aria-hidden":!0,className:`size-3.5`})})}function fe(e){if(e.checkedBy===null)return null;let t=e.checkedAt===null?``:` ${D(e.checkedAt)}`;return`Checked by ${Q[e.checkedBy]}${t}`}function pe({task:e,detailed:t}){let n=e.criteria;if(n.length===0)return null;let r=(0,U.jsx)(`ul`,{"aria-label":`Criteria of #${e.id}`,className:`flex flex-col gap-0.5`,children:n.map(n=>(0,U.jsx)(me,{task:e,criterion:n,detailed:t},n.id))});if(!t)return r;let i=n.filter(e=>e.state===`met`).length;return(0,U.jsx)(y,{label:`Criteria (${i} of ${n.length} met)`,children:r})}function me({task:e,criterion:t,detailed:n}){let r=j(),a=S(),[u,d]=(0,H.useState)(!1),[m,h]=(0,H.useState)(``),g=t.kind===`manual`&&e.status!==`done`,_=fe(t),y=l(t.kind)?t.target:null;function b(){d(!1),h(``)}let x=p(m.trim()!==``,b,r.isPending);function C(n){u?b():n?(r.reset(),d(!0)):r.mutate({taskId:e.id,criterionId:t.id,met:!1,evidence:null})}function E(n){n.preventDefault(),r.mutate({taskId:e.id,criterionId:t.id,met:!0,evidence:m.trim()||null},{onSuccess:b})}return(0,U.jsxs)(`li`,{"data-criterion-state":t.state,className:`flex min-w-0 flex-col gap-0.5 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,title:n?void 0:[_,t.evidence,y].filter(Boolean).join(`
2
- `)||void 0,children:[g?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(s,{size:`sm`,className:`shrink-0`,label:`Check criterion ${t.id} of #${e.id}`,isLabelHidden:!0,value:t.state===`met`||u,isDisabled:r.isPending||a,onChange:C}),t.state===`failed`&&(0,U.jsx)($,{state:`failed`})]}):(0,U.jsx)($,{state:t.state}),(0,U.jsx)(`span`,{className:v(`min-w-0`,n?`break-words-keep`:`truncate`,t.state===`failed`&&T.danger),children:t.text}),t.kind!==`manual`&&(0,U.jsx)(f,{className:`shrink-0`,label:o[t.kind]}),!n&&t.evidence&&(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.evidence})]}),n&&y&&(0,U.jsx)(`code`,{className:`ml-5.5 break-all text-muted-foreground`,children:y}),n&&(t.evidence||_)&&(0,U.jsxs)(`p`,{className:`ml-5.5 whitespace-pre-line break-words-keep text-muted-foreground`,children:[t.evidence,t.evidence&&_&&` · `,t.checkedBy!==null&&(0,U.jsxs)(U.Fragment,{children:[`Checked by `,Q[t.checkedBy],t.checkedAt!==null&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsx)(P,{at:t.checkedAt})]})]})]}),u&&(0,U.jsxs)(`form`,{onSubmit:E,className:`ml-5.5 flex flex-wrap items-center gap-1`,onKeyDown:x.onKeyDown,children:[(0,U.jsx)(w,{size:`sm`,containerClassName:`flex-1 basis-48`,label:`Evidence for criterion ${t.id}`,isLabelHidden:!0,placeholder:`Evidence (optional), e.g. a link or what you checked`,value:m,onChange:h,hasAutoFocus:!0}),x.asking?(0,U.jsx)(c,{label:`Discard evidence for criterion ${t.id}`,question:`Discard the evidence?`,onKeep:x.keep,onDiscard:x.discard}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(i,{type:`submit`,size:`sm`,variant:`primary`,label:r.isPending?`Saving...`:`Save`,isDisabled:r.isPending}),(0,U.jsx)(i,{type:`button`,size:`sm`,variant:`ghost`,label:`Cancel`,onClick:x.request})]})]}),r.isError&&(0,U.jsx)(`p`,{role:`alert`,className:`ml-5.5 text-destructive`,children:r.error.message})]})}export{ie as AutopilotToggle,re as RelatedTasks,pe as TaskCriteria,W as TaskDetailsSheet,le as TaskNotes,oe as TaskPlan,X as TaskTimeline,ae as TaskWorkspace};