@dubusoft/toodo-linux-x64 1.3.3-dev.14 → 1.3.3-dev.16

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{i as e,n as t,r as n,s as r,t as i}from"./dist-ZmB2kPfR.js";import{t as a}from"./button-Dghi8qWf.js";import{a as o,n as s,o as c,s as l}from"./connection-BFaD-ecb.js";import{i as u,n as d,o as f,r as p,s as m}from"./event-BTxkSTih.js";var h=r(e(),1),g=n(),_=h.createContext(void 0),v=e=>{let t=h.useContext(_);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},y=({client:e,children:t})=>(h.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,g.jsx)(_.Provider,{value:e,children:t})),b={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},x=new class{#e=b;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 S(e){setTimeout(e,0)}var C=typeof window>`u`||`Deno`in globalThis;function w(){}function T(e,t){return typeof e==`function`?e(t):e}function E(e){return typeof e==`number`&&e>=0&&e!==1/0}function D(e,t){return Math.max(e+(t||0)-Date.now(),0)}function O(e,t){return typeof e==`function`?e(t):e}function ee(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==A(o,t.options))return!1}else if(!M(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 k(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(j(t.options.mutationKey)!==j(a))return!1}else if(!M(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function A(e,t){return(t?.queryKeyHashFn||j)(e)}function j(e){return JSON.stringify(e,(e,t)=>F(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function M(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)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!M(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!M(e[r],t[r]))return!1;return!0}return!1}var te=Object.prototype.hasOwnProperty;function ne(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=P(e)&&P(t);if(!r&&!(F(e)&&F(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:te.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ne(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function N(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function P(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function F(e){if(!I(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!(!I(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function I(e){return Object.prototype.toString.call(e)===`[object Object]`}function re(e){return new Promise(t=>{x.setTimeout(t,e)})}function ie(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ne(e,t)}function ae(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function oe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var se=Symbol();function ce(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===se?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function le(e,t){return typeof e==`function`?e(...t):!!e}function ue(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var de=()=>C,fe=()=>de(),L=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(){}},pe=new class extends L{#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`}},me=S;function he(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=me,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 R=he(),ge=new class extends L{#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 _e(e){return Math.min(1e3*2**e,3e4)}function ve(e){return(e??`online`)!==`online`||ge.isOnline()}var ye=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function be(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(w);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new ye(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>pe.isFocused()&&(e.networkMode===`always`||ge.isOnline())&&e.canRun(),p=()=>ve(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??(fe()?0:3),a=e.retryDelay??_e,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),re(o).then(()=>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 xe=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),E(this.gcTime)&&(this.#e=x.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(fe()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(x.clearTimeout(this.#e),this.#e=void 0)}};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=e=>{ue(e,()=>t.signal,()=>n=!0)},u=ce(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?oe:ae;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?we:Ce,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ce(r,s);if(c>0&&e==null)break;s=await d(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 Ce(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 we(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Te=class extends xe{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Oe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Oe(this.options);e.data!==void 0&&(this.setState(De(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=ie(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(w).catch(w):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=>O(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===se||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>O(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:!D(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.#s||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.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ce(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?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.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=be({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ye&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ye){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({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.scheduleGc()}}#c(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,...Ee(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...De(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),R.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Ee(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ve(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function De(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Oe(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 ke=class extends L{#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.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),je(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Me(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Me(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 O(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&&!N(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ne(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||O(this.options.enabled,this.#t)!==O(t.enabled,this.#t)||O(this.options.staleTime,this.#t)!==O(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||O(this.options.enabled,this.#t)!==O(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 N(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),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().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(w)),t}#h(e){return!fe()&&O(this.options.enabled,this.#t)!==!1&&E(e)}#g(){this.#b();let e=O(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=D(this.#r.dataUpdatedAt,e)+1;this.#u=x.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return O(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=x.setInterval(()=>{(this.options.refetchIntervalInBackground||pe.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(x.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(x.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&je(e,t),o=i&&Ne(e,n,t,r);(a||o)&&(l={...l,...Ee(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=ie(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=ie(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Pe(e,t),refetch:this.refetch,isEnabled:O(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),N(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)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();R.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 Ae(e,t){return O(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||O(t.retryOnMount,e)!==!1)}function je(e,t){return Ae(e,t)||e.state.data!==void 0&&Me(e,t,t.refetchOnMount)}function Me(e,t,n){if(O(t.enabled,e)!==!1&&O(t.staleTime,e)!==`static`){let r=O(n,e);return r===`always`||r!==!1&&Pe(e,t)}return!1}function Ne(e,t,n,r){return(e!==t||O(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Pe(e,n)}function Pe(e,t){return O(t.enabled,e)!==!1&&e.isStaleByTime(O(t.staleTime,e))}var Fe=class extends xe{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ie(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.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=be({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})}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),R.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ie(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Le=class extends L{#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),N(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&j(t.mutationKey)!==j(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??Ie();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){R.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)})})}},Re=h.createContext(!1),ze=()=>h.useContext(Re);Re.Provider;function Be(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ve=h.createContext(Be()),He=()=>h.useContext(Ve),Ue=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?le(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},We=e=>{h.useEffect(()=>{e.clearReset()},[e])},Ge=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||le(n,[e.error,r])),Ke=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))}},qe=(e,t)=>e?.suspense&&t.isPending,Je=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ye(e,t,n){let r=ze(),i=He(),a=v(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Ke(o),Ue(o,i,s),We(i);let[l]=h.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(h.useSyncExternalStore(h.useCallback(e=>{let t=d?l.subscribe(R.batchCalls(e)):w;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),h.useEffect(()=>{l.setOptions(o)},[o,l]),qe(o,u))throw Je(o,l,i);if(Ge({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function z(e,t){return Ye(e,ke,t)}function B(e,t){let n=v(t),[r]=h.useState(()=>new Le(n,e));h.useEffect(()=>{r.setOptions(e)},[r,e]);let i=h.useSyncExternalStore(h.useCallback(e=>r.subscribe(R.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=h.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(w)},[r]);if(i.error&&le(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Xe={name:`ban`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]};Xe.node;var Ze=t(Xe),Qe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Qe.node;var $e=t(Qe),et={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};et.node;var tt=t(et),nt={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};nt.node;var rt=t(nt),it={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};it.node;var at=t(it),ot={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};ot.node;var st=t(ot),ct={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};ct.node;var lt=t(ct),ut={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};ut.node;var dt=t(ut);function ft(e){return typeof e==`object`&&!!e&&typeof e.kind==`string`&&typeof e.message==`string`}async function V(e,t={}){let n=m();if(n===null)throw Error(`No access token for the Toodo server.`);let r=await o(`/api/rpc/${encodeURIComponent(e)}`,{method:`POST`,headers:{...u(n),"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.status===401)throw f(),Error(`The Toodo server did not accept the access token.`);let i=await r.text();if(r.ok)return i?JSON.parse(i):null;let a=null;try{a=JSON.parse(i)}catch{}throw ft(a)?a:Error(i||`${r.status} ${r.statusText}`)}var H={appInfo:()=>V(`app_info`),listWorkspaces:()=>W(V(`list_workspaces`)),getWorkspace:e=>W(V(`get_workspace`,{id:e})),createWorkspace:e=>W(V(`create_workspace`,{workspace:e})),updateWorkspace:e=>W(V(`update_workspace`,{workspace:e})),moveWorkspace:(e,t)=>W(V(`move_workspace`,{id:e,location:t})),listWorkspaceBranches:e=>W(V(`list_workspace_branches`,{id:e})),createWorkspaceBaseBranch:(e,t,n)=>W(V(`create_workspace_base_branch`,{id:e,name:t,from:n})),deleteWorkspace:e=>W(V(`delete_workspace`,{id:e})),getMachineSettings:e=>W(V(`get_machine_settings`,{machine:e})),saveMachineSettings:e=>W(V(`save_machine_settings`,{settings:e})),listHerdrMachines:()=>W(V(`list_herdr_machines`)),listSshHosts:()=>W(V(`list_ssh_hosts`)),addSshHost:e=>W(V(`add_ssh_host`,{host:e})),listRemoteDirectories:(e,t)=>W(V(`list_remote_directories`,{machine:e,path:t})),listDirectories:(e,t)=>W(V(`list_directories`,{machine:e,path:t})),listTasks:()=>W(V(`list_tasks`)),listTaskRelations:()=>W(V(`list_task_relations`)),addTaskRelation:(e,t)=>W(V(`add_task_relation`,{taskId:e,relatedId:t})),removeTaskRelation:(e,t)=>W(V(`remove_task_relation`,{taskId:e,relatedId:t})),getTask:e=>W(V(`get_task`,{id:e})),createTask:e=>W(V(`create_task`,{task:e})),updateTask:e=>W(V(`update_task`,{task:e})),pauseTask:e=>W(V(`pause_task`,{id:e})),setCompletionNote:(e,t)=>W(V(`set_completion_note`,{id:e,note:t})),reopenTask:(e,t)=>W(V(`reopen_task`,{id:e,reason:t})),setTaskOutcome:(e,t,n)=>W(V(`set_task_outcome`,{id:e,resolution:t,note:n})),checkCriterion:(e,t,n,r)=>W(V(`check_criterion`,{taskId:e,criterionId:t,met:n,evidence:r})),deleteTask:(e,t)=>W(V(`delete_task`,{id:e,force:t})),addDependency:(e,t,n)=>W(V(`add_dependency`,{taskId:e,dependsOn:t,confirmPause:n})),removeDependency:(e,t)=>W(V(`remove_dependency`,{taskId:e,dependsOn:t})),listCommitRecords:e=>W(V(`list_commit_records`,{taskId:e})),listTaskActivity:e=>W(V(`list_task_activity`,{taskId:e})),herdrStatus:()=>W(V(`herdr_status`)),startTask:e=>W(V(`start_task`,{id:e})),ensureTaskWorkspace:e=>W(V(`ensure_task_workspace`,{id:e})),openTaskInHerdr:e=>W(V(`open_task_in_herdr`,{id:e})),focusAgentPane:e=>W(V(`focus_agent_pane`,{id:e})),restoreTaskWorktree:e=>W(V(`restore_task_worktree`,{id:e})),closeTaskWorkspace:e=>W(V(`close_task_workspace`,{id:e})),refreshCommitRecords:e=>W(V(`refresh_commit_records`,{taskId:e})),openPullRequest:e=>W(V(`open_pull_request`,{id:e})),completeTask:e=>W(V(`complete_task`,{id:e})),concludeTask:(e,t)=>W(V(`conclude_task`,{id:e,note:t})),completeTaskMergedWith:(e,t,n)=>W(V(`complete_task_merged_with`,{id:e,mergedWithTask:t,pullRequestUrl:n})),branchFreshness:e=>W(V(`branch_freshness`,{id:e})),listPullRequestStatuses:()=>V(`list_pull_request_statuses`),linkIssue:(e,t)=>W(V(`link_issue`,{id:e,number:t})),createIssue:e=>W(V(`create_issue`,{id:e})),listAgentStatuses:()=>V(`list_agent_statuses`),mcpServerInfo:()=>V(`mcp_server_info`),listMcpTunnels:()=>V(`list_mcp_tunnels`),listConnectedApps:()=>W(V(`list_connected_apps`)),revokeConnectedApp:e=>W(V(`revoke_connected_app`,{grantId:e})),reviewPeriod:(e,t)=>W(V(`review_period`,{start:e,end:t})),getBackupSettings:()=>V(`get_backup_settings`),saveBackupSettings:e=>W(V(`save_backup_settings`,{settings:e})),listBackups:()=>W(V(`list_backups`)),restoreBackup:e=>W(V(`restore_backup`,{name:e}))},U={tasksChanged:G(`tasks-changed`),workspacesChanged:G(`workspaces-changed`),agentStatusesChanged:G(`agent-statuses-changed`),pullRequestStatusesChanged:G(`pull-request-statuses-changed`)};async function W(e){try{return{status:`ok`,data:await e}}catch(e){if(e instanceof Error)throw e;return{status:`error`,error:e}}}function G(e){return{listen:t=>d(e,t)}}function pt(e,t){return/filename="([^"]+)"/.exec(e.headers.get(`Content-Disposition`)??``)?.[1]??t}function mt(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),URL.revokeObjectURL(n)}async function ht(){let e=await p(`/api/backups/export`),t=pt(e,`toodo-backup.sqlite3`);return mt(t,await e.blob()),t}async function gt(e){return mt(e,await(await p(`/api/backups/${encodeURIComponent(e)}`)).blob()),e}async function _t(e){return await(await p(`/api/backups/restore`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e})).json()}var vt=`toodo-install-dismissed`;function yt(){let{userAgent:e,maxTouchPoints:t}=navigator;return/iPhone|iPad|iPod/.test(e)||e.includes(`Macintosh`)&&t>1}function bt(){return matchMedia(`(display-mode: standalone)`).matches||`standalone`in navigator&&navigator.standalone===!0}var K=null,xt=!1,St=new Set;function q(){St.forEach(e=>e())}function Ct(e){return St.add(e),()=>St.delete(e)}function wt(){return xt||bt()||localStorage.getItem(vt)!==null?`none`:K===null?yt()?`home-screen`:`none`:`prompt`}function Tt(){localStorage.setItem(vt,`1`),q()}async function Et(){let e=K;if(e===null)return;K=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`dismissed`?Tt():q()}function Dt(){addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),K=e,q()}),addEventListener(`appinstalled`,()=>{K=null,xt=!0,q()})}function Ot(){return`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window?`supported`:yt()&&!bt()?`needs-install`:`unsupported`}var J=null,kt={agent:[`Agent needs input`,`Agent finished`],pullRequests:[`CI failed`,`CI passed`,`Changes requested`,`Pull request approved`],completion:[`Task awaiting completion`]};function At(e){return J!==null&&Object.keys(kt).some(t=>J?.[t]===!0&&kt[t].includes(e))}function jt(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 Mt(e,t){let n=e.options.applicationServerKey;return n===null||n.byteLength===t.length&&new Uint8Array(n).every((e,n)=>e===t[n])}function Nt(){return navigator.serviceWorker.getRegistration()}async function Pt(e){let t=await(await Nt())?.pushManager.getSubscription()??null;return t===null||Mt(t,e)?t:(await t.unsubscribe(),null)}async function Ft(e){return await(await p(`/api/push/subscription`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e.toJSON())})).json()}async function It(){let e=await(await p(`/api/push`)).json(),t=await Pt(jt(e.publicKey)),n=t===null?null:t.endpoint===e.subscription?.endpoint?e.subscription:await Ft(t);return J=n?.settings??null,{publicKey:e.publicKey,permission:Notification.permission,subscription:n}}async function Lt(e,t){if(await e!==`granted`)throw Error(`Notifications were not allowed.`);if(await Nt()===void 0)throw Error(`Notifications need the service worker, which only the built app installs.`);let{pushManager:n}=await navigator.serviceWorker.ready,r=jt(t),i=await Pt(r)??await n.subscribe({userVisibleOnly:!0,applicationServerKey:r});try{let e=await Ft(i);return J=e.settings,e}catch(e){throw await i.unsubscribe(),e}}async function Rt(){await(await(await Nt())?.pushManager.getSubscription())?.unsubscribe(),J=null,await p(`/api/push/subscription`,{method:`DELETE`})}async function zt(e){let t=await(await p(`/api/push/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();return J=t.settings,t}async function Bt(){await p(`/api/push/test`,{method:`POST`})}var Vt=`toodo-open-task`;function Ht(e){let t=new URL(location.href),n=t.searchParams.get(`task`);if(n!==null&&(t.searchParams.delete(`task`),history.replaceState(history.state,``,t),/^\d+$/.test(n)&&e(Number(n))),!(`serviceWorker`in navigator))return()=>{};let r=navigator.serviceWorker,i=({data:t})=>{typeof t==`object`&&t&&`type`in t&&t.type===Vt&&`taskId`in t&&typeof t.taskId==`number`&&e(t.taskId)};return r.addEventListener(`message`,i),()=>r.removeEventListener(`message`,i)}async function Ut(){return`Notification`in window&&Notification.permission===`granted`}async function Wt(){return`Notification`in window?Notification.requestPermission():`denied`}function Gt(e){At(e.title)||new Notification(e.title,{body:e.body})}var Kt={planned:`Planned`,in_progress:`In progress`,in_review:`Awaiting completion`,done:`Done`};function qt(e){return e.status===`done`&&e.resolution===`completed`?`Completed`:e.status===`done`&&e.resolution===`not_adopted`?`Not adopted`:Kt[e.status]}function Jt(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 Yt(e,t){let n=new Map(e.map(e=>[e.id,e.status])),r=new Map(t.map(e=>[e.id,e]));return t.flatMap(e=>{let t=n.get(e.id);if(t===void 0||t===e.status)return[];let i=e.dependsOn.some(e=>r.get(e)?.status!==`done`);return t===`in_progress`&&e.status===`planned`&&i&&e.herdrWorkspaceId!==null?[{title:`Task paused by a new prerequisite`,body:`#${e.id} ${e.title}: close its herdr workspace?`}]:[{title:Jt(t,e),body:`#${e.id} ${e.title}: ${Kt[t]} -> ${qt(e)}`}]})}function Xt(e,t,n){let r=new Map(e.map(e=>[e.taskId,e.status]));return t.flatMap(({taskId:e,status:t})=>{let i=r.get(e);if(i===void 0||i===t||t!==`blocked`)return[];let a=n.find(t=>t.id===e);return[{title:`Agent needs input`,body:a?`#${e} ${a.title}`:`#${e}`}]})}function Zt(e,t,n){let r=new Map(e.map(e=>[e.taskId,e]));return t.flatMap(({taskId:e,checks:t,review:i})=>{let a=r.get(e);if(a===void 0)return[];let o=n.find(t=>t.id===e),s=o?`#${e} ${o.title}`:`#${e}`,c=[];return t===`failing`&&a.checks!==`failing`&&c.push({title:`CI failed`,body:s}),i===`changes_requested`&&a.review!==`changes_requested`&&c.push({title:`Changes requested`,body:s}),c})}async function Qt(e){if(e.length!==0&&(await Ut()||await Wt()===`granted`))for(let t of e)Gt(t)}var $t=class extends Error{kind;constructor(e){super(e.message),this.name=`CommandFailure`,this.kind=e.kind}};async function Y(e){let t=await e;if(t.status===`error`)throw new $t(t.error);return t.data}var X={workspaces:[`workspaces`],tasks:[`task-list`],taskRelations:[`tasks`,`relations`],herdrStatus:[`herdr-status`],agentStatuses:[`agent-statuses`],pullRequestStatuses:[`pull-request-statuses`],machineSettings:e=>[`machine-settings`,e],branches:e=>[`branches`,e],commitRecords:e=>[`tasks`,e,`commit-records`],taskActivity:e=>[`tasks`,e,`activity`],branchFreshness:e=>[`tasks`,e,`branch-freshness`],herdrMachines:[`herdr-machines`],backups:[`backups`],backupSettings:[`backup-settings`],mcpServerInfo:[`mcp-server-info`],mcpTunnels:[`mcp-tunnels`],review:(e,t)=>[`review`,e,t],directories:(e,t)=>[`directories`,e,t]};function en(){return z({queryKey:X.mcpServerInfo,queryFn:()=>H.mcpServerInfo(),refetchInterval:5e3})}function tn(){return z({queryKey:X.mcpTunnels,queryFn:()=>H.listMcpTunnels(),refetchInterval:3e3})}function nn(){return z({queryKey:X.backups,queryFn:()=>Y(H.listBackups())})}function rn(){return z({queryKey:X.backupSettings,queryFn:()=>H.getBackupSettings()})}function an(){let e=v();return B({mutationFn:e=>Y(H.saveBackupSettings(e)),onSuccess:t=>(e.setQueryData(X.backupSettings,t),e.invalidateQueries({queryKey:X.backups}))})}function on(){let e=v();return B({mutationFn:e=>Y(H.restoreBackup(e)),onSuccess:()=>e.invalidateQueries()})}function sn(){return B({mutationFn:ht})}function cn(){return B({mutationFn:gt})}function ln(){let e=v();return B({mutationFn:_t,onSuccess:()=>e.invalidateQueries()})}function un(){return z({queryKey:X.herdrMachines,queryFn:()=>Y(H.listHerdrMachines())})}function dn(e,t){return z({queryKey:X.directories(e,t),queryFn:()=>Y(H.listDirectories(e,t)),enabled:t!==null,retry:!1})}function fn(e){return z({queryKey:[`home-directory`,e],queryFn:async()=>(await Y(H.listDirectories(e,null))).path,staleTime:1/0,retry:!1})}function pn(e){return e.kind===`local`?{kind:`local`}:{kind:`ssh`,label:e.machine}}function mn(){return z({queryKey:X.workspaces,queryFn:()=>Y(H.listWorkspaces())})}function hn(){let e=v();return B({mutationFn:e=>Y(H.createWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces})})}function gn(){let e=v();return B({mutationFn:e=>Y(H.updateWorkspace(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0})})}function _n(){let e=v();return B({mutationFn:({id:e,location:t})=>Y(H.moveWorkspace(e,t)),onSuccess:()=>{e.invalidateQueries()}})}function vn(e,t){return z({queryKey:X.branches(e),queryFn:()=>Y(H.listWorkspaceBranches(e)),enabled:t,staleTime:0})}function yn(e,t){return z({queryKey:X.branchFreshness(e),queryFn:()=>Y(H.branchFreshness(e)),enabled:t,staleTime:6e4,refetchInterval:3e5,retry:!1})}function bn(){let e=v();return B({mutationFn:({workspace:e,name:t,from:n})=>Y(H.createWorkspaceBaseBranch(e,t,n)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:X.workspaces,exact:!0}),e.invalidateQueries({queryKey:X.branches(t.id)})])})}function xn(){let e=v();return B({mutationFn:e=>Y(H.deleteWorkspace(e)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:X.workspaces,exact:!0})])})}function Sn(){return z({queryKey:X.tasks,queryFn:()=>Y(H.listTasks())})}function Cn(e,t){return z({queryKey:X.review(e,t),queryFn:()=>Y(H.reviewPeriod(e,t))})}function wn(){return z({queryKey:X.herdrStatus,queryFn:()=>Y(H.herdrStatus())})}function Tn(){return z({queryKey:X.agentStatuses,queryFn:()=>H.listAgentStatuses()})}function En(){return z({queryKey:X.pullRequestStatuses,queryFn:()=>H.listPullRequestStatuses()})}function Dn(){let e=v();(0,h.useEffect)(()=>{function t(t,n,r){let i=e.getQueryData(t);e.setQueryData(t,n),!(i===void 0||document.hasFocus())&&Qt(r(i,n,e.getQueryData(X.tasks)??[])).catch(e=>console.error(`toodo: failed to show notifications`,e))}let n=[U.tasksChanged.listen(async()=>{let t=e.getQueryData(X.tasks);await Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`tasks`]})]),!(t===void 0||document.hasFocus())&&Qt(Yt(t,e.getQueryData(X.tasks)??[])).catch(e=>console.error(`toodo: failed to show status notifications`,e))}),U.workspacesChanged.listen(()=>e.invalidateQueries({queryKey:X.workspaces,exact:!0})),U.agentStatusesChanged.listen(({payload:e})=>t(X.agentStatuses,e.statuses,Xt)),U.pullRequestStatusesChanged.listen(({payload:e})=>t(X.pullRequestStatuses,e.statuses,Zt))];return()=>{for(let e of n)e.then(e=>e())}},[e])}function On(e){return z({queryKey:X.machineSettings(e),queryFn:()=>Y(H.getMachineSettings(e))})}function kn(){let e=v();return B({mutationFn:e=>Y(H.saveMachineSettings(e)),onSuccess:t=>e.setQueryData(X.machineSettings(t.machine),t)})}function An(){let e=v();return B({mutationFn:e=>Y(H.startTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}function jn(){return B({mutationFn:e=>Y(H.openTaskInHerdr(e))})}function Mn(){return B({mutationFn:e=>Y(H.focusAgentPane(e))})}function Nn(e,t){return z({queryKey:X.commitRecords(e),queryFn:()=>Y(H.listCommitRecords(e)),enabled:t})}function Pn(e,t){return z({queryKey:X.taskActivity(e),queryFn:()=>Y(H.listTaskActivity(e)),enabled:t})}function Fn(){let e=v();return B({mutationFn:e=>Y(H.refreshCommitRecords(e)),onSuccess:(t,n)=>e.setQueryData(X.commitRecords(n),t)})}function In(){let e=v();return B({mutationFn:e=>Y(H.openPullRequest(e)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:X.commitRecords(t.id)})])})}function Ln(){let e=v();return B({mutationFn:e=>Y(H.completeTask(e)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:X.commitRecords(t.id)}),e.invalidateQueries({queryKey:X.taskActivity(t.id)})])})}function Rn(){let e=v();return B({mutationFn:({id:e,note:t})=>Y(H.concludeTask(e,t)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:X.commitRecords(t.id)}),e.invalidateQueries({queryKey:[`review`]})])})}function zn(){let e=v();return B({mutationFn:({id:e,note:t})=>Y(H.setCompletionNote(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Bn(){let e=v();return B({mutationFn:({id:e,reason:t})=>Y(H.reopenTask(e,t)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Vn(){let e=v();return B({mutationFn:({id:e,resolution:t,note:n})=>Y(H.setTaskOutcome(e,t,n)),onSuccess:()=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:[`review`]})])})}function Hn(){let e=v();return B({mutationFn:({id:e,mergedWithTask:t,pullRequestUrl:n})=>Y(H.completeTaskMergedWith(e,t,n)),onSuccess:t=>Promise.all([e.invalidateQueries({queryKey:X.tasks}),e.invalidateQueries({queryKey:X.commitRecords(t.id)}),e.invalidateQueries({queryKey:[`review`]})])})}function Un(){let e=v();return B({mutationFn:e=>Y(H.restoreTaskWorktree(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}function Wn(){let e=v();return B({mutationFn:e=>Y(H.updateTask(e)),onSuccess:()=>e.invalidateQueries({queryKey:X.tasks})})}function Z(e){let t=v();return B({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.tasks})})}function Gn(){return Z(e=>Y(H.pauseTask(e)))}function Kn(){return Z(e=>Y(H.closeTaskWorkspace(e)))}function qn(){return Z(({taskId:e,criterionId:t,met:n,evidence:r})=>Y(H.checkCriterion(e,t,n,r)))}function Jn(){return Z(({id:e,force:t})=>Y(H.deleteTask(e,t)))}function Yn(){return Z(({id:e,dependsOn:t,confirmPause:n})=>Y(H.addDependency(e,t,n)))}function Xn(){return Z(({id:e,dependsOn:t})=>Y(H.removeDependency(e,t)))}function Zn(){return z({queryKey:X.taskRelations,queryFn:()=>Y(H.listTaskRelations())})}function Qn(e){let t=v();return B({mutationFn:e,onSuccess:()=>t.invalidateQueries({queryKey:X.taskRelations})})}function $n(){return Qn(({taskId:e,relatedId:t})=>Y(H.addTaskRelation(e,t)))}function er(){return Qn(({taskId:e,relatedId:t})=>Y(H.removeTaskRelation(e,t)))}function tr(){return Z(({id:e,number:t})=>Y(H.linkIssue(e,t)))}function nr(){return Z(e=>Y(H.createIssue(e)))}var rr=class extends Error{constructor(e,t,n){super(`Task #${e} was added, but issue #${t} could not be linked: ${n}`),this.name=`IssueLinkFailure`}};function ir(){let e=v();return B({mutationFn:async({issue:e,...t})=>{let n=await Y(H.createTask(t));if(e===null)return n;try{return await Y(H.linkIssue(n.id,e))}catch(t){throw new rr(n.id,e,t instanceof Error?t.message:String(t))}},onSettled:()=>e.invalidateQueries({queryKey:X.tasks})})}var ar=200;function or(e){return/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)}function sr(e,t){let n=or(e)?`\\`:`/`;return/[\\/]$/.test(e)?`${e}${t}`:`${e}${n}${t}`}function cr(e){return e.replace(/(?<=[^\\/:])[\\/]+$/,``)}function lr(e,t){let[n,r]=(0,h.useState)(e);return(0,h.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function ur({id:e,machine:t,value:n,onChange:r,describedBy:a,required:o,autoFocus:s,className:c}){let[l,u]=(0,h.useState)(!1),[d,f]=(0,h.useState)(-1),p=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),m=p<0?null:n.slice(0,p+1),_=n.slice(p+1).toLowerCase(),v=lr(m,ar),y=dn(t,l?v:null),b=l&&m!==null&&v===m,x=b&&y.data?y.data.directories.filter(e=>e.toLowerCase().startsWith(_)):[],S=x.length>0,C=`${e}-folders`,w=t.kind===`local`?`the server`:t.label;function T(e){r(e),f(-1),u(!0)}function E(e){m!==null&&T(`${sr(m,e)}${or(m)?`\\`:`/`}`)}function D(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!S){u(!0);return}let t=x.length,n=e.key===`ArrowDown`;f(e=>e<0?n?0:t-1:(e+(n?1:t-1))%t)}else if(e.key===`Enter`){if(!S||d<0)return;e.preventDefault(),E(x[d])}else if(e.key===`Tab`){if(!S||e.shiftKey||d<0&&_===``)return;e.preventDefault(),e.stopPropagation(),E(x[Math.max(d,0)])}else if(e.key===`Escape`){if(!S)return;e.preventDefault(),e.stopPropagation(),u(!1)}}return(0,g.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,g.jsx)(`input`,{id:e,role:`combobox`,"aria-expanded":S,"aria-controls":C,"aria-autocomplete":`list`,"aria-activedescendant":S&&d>=0?`${C}-${d}`:void 0,"aria-describedby":a,autoComplete:`off`,spellCheck:!1,className:c,value:n,onChange:e=>T(e.target.value),onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:D,required:o,autoFocus:s}),S&&(0,g.jsx)(`ul`,{id:C,role:`listbox`,"aria-label":`Folders in ${m}`,className:`absolute top-full right-0 left-0 z-10 mt-1 flex max-h-56 flex-col overflow-y-auto rounded-lg border bg-popover p-1 font-mono text-xs text-popover-foreground shadow-md`,children:x.map((e,t)=>(0,g.jsxs)(`li`,{id:`${C}-${t}`,role:`option`,"aria-selected":t===d,onMouseDown:e=>e.preventDefault(),onClick:()=>E(e),className:i(`cursor-pointer truncate rounded px-1.5 py-1 hover:bg-muted max-md:py-2`,t===d&&`bg-secondary hover:bg-secondary`),children:[e,or(m??``)?`\\`:`/`]},e))}),b&&y.isError&&(0,g.jsxs)(`p`,{role:`status`,className:`mt-1 text-xs break-words text-muted-foreground`,children:[`No suggestions: `,y.error.message,`. Type the path of a folder that exists on `,w,`, ending in a separator, to see its subfolders.`]})]})}function dr(e,t){if(e===null)return;let n=[...e.querySelectorAll(`a[href], button, input, select, textarea, summary, [tabindex]`)].filter(e=>!e.matches(`:disabled, [tabindex='-1']`)&&e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement,o=a instanceof Node&&e.contains(a);(t.shiftKey?!o||a===r:!o||a===i)&&(t.preventDefault(),(t.shiftKey?i:r).focus())}function fr(e){let t=/^[a-zA-Z]:/.test(e)||e.startsWith(`\\\\`)||e.includes(`\\`)&&!e.includes(`/`),n=t?`\\`:`/`,r=``,i=e,a=t?/^[\\/]{2}[^\\/]+[\\/]+[^\\/]+/.exec(e):null,o=t?/^[a-zA-Z]:([\\/]?)/.exec(e):null;a?(r=`${a[0].replace(/[\\/]+/g,`\\`).replace(/^\\/,`\\\\`)}\\`,i=e.slice(a[0].length)):o?(r=o[0].slice(0,2)+(o[1]?n:``),i=e.slice(o[0].length)):/^[\\/]/.test(e)&&(r=n,i=e.replace(/^[\\/]+/,``));let s=[];for(let e of i.split(t?/[\\/]+/:/\/+/))e!==``&&e!==`.`&&(e===`..`?s.length>0&&s[s.length-1]!==`..`?s.pop():r===``&&s.push(e):s.push(e));return{root:r,separator:n,segments:s}}function pr(e){let{root:t,separator:n,segments:r}=fr(e),i=t+r.join(n);return i===``?`.`:i}function mr(e,t=2){let{separator:n,segments:r}=fr(e);return r.length<=t?pr(e):`…${n}${r.slice(-t).join(n)}`}var hr=[`none`,`local_git`,`github`],gr=[`manual`,`local_merge`,`pr_merge`],_r=[`herdr`,`none`],vr=[`open`,`init`,`clone`],yr={none:`Plain folder`,local_git:`Local git`,github:`GitHub`},br={manual:`Manual`,local_merge:`Local merge`,pr_merge:`PR merge`},xr={none:`No runner`,herdr:`herdr`},Sr={open:`Open existing`,init:`New repository`,clone:`Clone URL`};function Cr(e){return e===`none`?`manual`:e===`local_git`?`local_merge`:`pr_merge`}function wr(e){return e===`none`?`none`:`herdr`}function Tr(e){return e===`none`?null:`open`}function Er(e,t){switch(t){case`manual`:return null;case`local_merge`:return e===`local_git`?null:e===`none`?`Needs a git repository; choose source Local git`:`GitHub tasks merge through pull requests; choose source Local git`;case`pr_merge`:return e===`github`?null:e===`none`?`Needs a git repository; choose source GitHub`:`Needs a GitHub origin remote; choose source GitHub`}}function Dr(e,t,n){return n===`herdr`&&e===`none`?`Needs a git repository for task worktrees; choose source Local git or GitHub`:n===`none`&&t!==`manual`?`${br[t]} needs the task branch that herdr creates; choose completion Manual`:null}function Or(e,t){return e===`none`?`A plain folder has no repository; choose source Local git or GitHub`:e===`github`&&t===`init`?`A new repository has no GitHub origin; choose source Local git`:null}function kr(e){let{source:t}=e,n=e.repository!==null&&Or(t,e.repository)===null?e.repository:Tr(t),r=e.completion!==null&&Er(t,e.completion)===null?e.completion:Cr(t);return{source:t,repository:n,completion:r,runner:e.runner!==null&&Dr(t,r,e.runner)===null?e.runner:wr(t)}}function Ar(e,t){let n={...e,...t},r=kr(n);return{source:n.source,repository:n.repository===r.repository?n.repository:null,completion:n.completion===r.completion?n.completion:null,runner:n.runner===r.runner?n.runner:null}}var jr=`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,Mr=`h-6 rounded-md border border-input bg-background px-1.5 text-xs outline-none max-md:h-11 max-md:px-2.5 max-md:text-sm focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50`;function Nr(e){let t=pr(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}function Pr(e){let t=mr(e.path);return e.kind===`local`?t:`${e.machine}:${t}`}var Fr={foreign:`Windows path, not on this server`,missing:`Folder not found on the server`};function Ir({problem:e,className:t}){return(0,g.jsxs)(`span`,{className:i(`flex min-w-0 items-start gap-1 text-xs text-destructive`,t),title:`Toodo cannot run git in this repository until its path is corrected`,children:[(0,g.jsx)(lt,{"aria-hidden":`true`,className:`mt-0.5 size-3 shrink-0`}),(0,g.jsx)(`span`,{children:Fr[e]})]})}function Lr({workspace:e}){let t=yr[e.source],n=br[e.completion],r=xr[e.runner];return(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,title:`Source ${t}, completion ${n}, runner ${r}; set when the workspace was added`,children:[(0,g.jsx)(`span`,{className:`whitespace-nowrap`,children:t}),` · `,(0,g.jsx)(`span`,{className:`whitespace-nowrap`,children:n}),` `,`· `,(0,g.jsx)(`span`,{className:`whitespace-nowrap`,children:r})]})}function Rr(e){return e.kind===`local`?null:e.machine}function zr(e,t){let n=t.filter(t=>t.target===e);return n.length===0?`Not saved in herdr`:n.some(e=>e.enabled)?null:`Disabled in herdr`}function Br(e){return/[\\/]$/.test(e)?e:sr(e,``)}function Q({label:e,help:t,children:n}){let r=(0,h.useId)(),i=`${r}-help`;return(0,g.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,g.jsx)(`label`,{htmlFor:r,className:`text-xs text-muted-foreground`,children:e}),n({id:r,describedBy:t?i:void 0}),t&&(0,g.jsx)(`p`,{id:i,className:`text-xs text-muted-foreground`,children:t})]})}function Vr(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``}function Hr(e){return Vr(e.trim().replace(/\.git$/,``)).split(`:`).pop()??``}function Ur({selectedId:e,onSelect:t}){let n=mn(),r=(0,h.useSyncExternalStore)(c,s),i=r===`unreachable`||r===`retrying`,o=un(),[u,d]=(0,h.useState)(null),f=(0,h.useRef)(null),p=()=>{d(null),f.current?.focus()},[m,_]=(0,h.useState)(!1),v=o.data??[],y=[null,...new Set([...v.map(e=>e.target),...(n.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])];return(0,g.jsxs)(`section`,{"aria-labelledby":`workspaces-heading`,className:`flex shrink-0 flex-col gap-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`h2`,{id:`workspaces-heading`,className:`text-xs font-medium uppercase text-muted-foreground`,children:`Workspaces`}),(0,g.jsxs)(a,{variant:`ghost`,size:`xs`,onClick:()=>_(e=>!e),children:[!m&&(0,g.jsx)(at,{}),m?`Cancel`:`Add machine`]})]}),m&&(0,g.jsx)(Jr,{onClose:()=>_(!1)}),o.isError&&(0,g.jsxs)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:[`Failed to list herdr machines: `,o.error.message]}),n.isPending&&!i&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspaces...`}),(n.isError||n.isPending&&i)&&(0,g.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-sm text-destructive`,children:[(0,g.jsxs)(`p`,{children:[`Failed to load workspaces:`,` `,n.error?.message??(l()||`The Toodo server does not answer.`)]}),(0,g.jsx)(a,{size:`xs`,variant:`outline`,onClick:()=>void n.refetch(),children:`Retry now`})]}),n.data?.length===0&&u===null&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No workspaces yet.`}),(0,g.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.data&&y.map(r=>{let i=r??`Local`,s=n.data.filter(e=>Rr(e.location)===r),c=r!==null&&o.isSuccess?zr(r,v):null;return(0,g.jsxs)(`section`,{"aria-label":`Machine ${i}`,className:`flex flex-col gap-1`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsxs)(`h3`,{className:`flex min-w-0 flex-1 items-center gap-1.5 px-1 text-xs font-semibold`,children:[r===null?(0,g.jsx)(rt,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}):(0,g.jsx)(st,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,g.jsx)(`span`,{className:`truncate`,children:i}),c&&(0,g.jsx)(`span`,{className:`ml-1.5 font-normal text-destructive`,children:c})]}),(0,g.jsxs)(a,{size:`xs`,variant:`outline`,"aria-label":`Add workspace on ${i}`,title:`Add a workspace on this machine`,"aria-haspopup":`dialog`,"aria-expanded":u!==null&&u.machine===r,onClick:e=>{f.current=e.currentTarget,d({machine:r})},children:[(0,g.jsx)(at,{}),`Add`]})]}),s.length>0&&(0,g.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(n=>(0,g.jsx)(Wr,{workspace:n,selected:n.id===e,onSelect:t},n.id))})]},i)})}),u&&(0,g.jsx)(ti,{machine:u.machine,onCreated:e=>{p(),t(e.id)},onClose:p})]})}function Wr({workspace:e,selected:t,onSelect:n}){let r=xn(),[o,s]=(0,h.useState)(!1);return(0,g.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,g.jsxs)(`div`,{className:i(`group flex items-center rounded-lg hover:bg-sidebar-accent`,t&&`bg-sidebar-accent`),children:[(0,g.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:`flex min-w-0 flex-1 flex-col px-2.5 py-1.5 text-left`,children:[(0,g.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,g.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,title:Nr(e.location),children:mr(e.location.path)}),(0,g.jsx)(Lr,{workspace:e}),e.pathProblem&&(0,g.jsx)(Ir,{problem:e.pathProblem})]}),!o&&(0,g.jsx)(a,{size:`icon-xs`,variant:`ghost`,"aria-label":`Remove ${e.name}`,title:`Remove the workspace and its tasks from Toodo`,className:`mr-1 shrink-0 opacity-0 group-hover:opacity-100 hover:text-destructive focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,onClick:()=>{r.reset(),s(!0)},children:(0,g.jsx)(dt,{})})]}),o&&(0,g.jsxs)(`div`,{role:`group`,"aria-label":`Remove ${e.name}`,className:`flex flex-col gap-1.5 rounded-lg border p-2`,onKeyDown:e=>{e.key===`Escape`&&!r.isPending&&(e.preventDefault(),s(!1))},children:[(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Remove `,e.name,` and its tasks from Toodo? The repository, worktrees, and herdr workspaces are kept.`]}),r.isError&&(0,g.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:r.error.message}),(0,g.jsxs)(`div`,{className:`flex gap-1`,children:[(0,g.jsx)(a,{changesData:!0,size:`xs`,variant:`destructive`,"aria-label":`Confirm remove ${e.name}`,disabled:r.isPending,onClick:()=>r.mutate(e.id),children:r.isPending?`Removing...`:`Remove`}),(0,g.jsx)(a,{size:`xs`,variant:`ghost`,autoFocus:!0,onClick:()=>s(!1),children:`Back`})]})]})]})}function Gr(e,t=!1){return n=>{n.key===`Escape`&&!t&&!n.defaultPrevented&&(n.preventDefault(),e())}}function Kr({workspace:e,onClose:t}){let n=_n(),r=un(),i=mn(),[o,s]=(0,h.useState)(Rr(e.location)),[c,l]=(0,h.useState)(e.location.path),u=[...new Set([...(r.data??[]).map(e=>e.target),...(i.data??[]).flatMap(e=>e.location.kind===`ssh`?[e.location.machine]:[])])],d=cr(c.trim());function f(r){r.preventDefault();let i=o===null?{kind:`local`,path:d}:{kind:`ssh`,machine:o,path:d};n.mutate({id:e.id,location:i},{onSuccess:t})}return(0,g.jsxs)(`form`,{onSubmit:f,"aria-label":`Move ${e.name}`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Gr(t,n.isPending),children:[(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Point the workspace at the same repository on another machine or in another folder. Its tasks stay. A repository on a Windows host takes a Windows path such as D:\\dev\\repo.`}),(0,g.jsx)(Q,{label:`Machine`,children:({id:e})=>(0,g.jsxs)(`select`,{id:e,className:jr,value:o??``,onChange:e=>s(e.target.value===``?null:e.target.value),autoFocus:!0,children:[(0,g.jsx)(`option`,{value:``,children:`Local (this server)`}),u.map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]})}),(0,g.jsx)(Q,{label:`Folder`,help:`The repository's own folder on that machine.`,children:({id:e,describedBy:t})=>(0,g.jsx)(ur,{id:e,machine:o===null?{kind:`local`}:{kind:`ssh`,label:o},className:jr,describedBy:t,value:c,onChange:l,required:!0})}),n.isError&&(0,g.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:n.error.message}),(0,g.jsxs)(`div`,{className:`flex gap-1`,children:[(0,g.jsx)(a,{type:`submit`,size:`sm`,disabled:n.isPending||d===``,children:n.isPending?`Moving...`:`Move workspace`}),(0,g.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:t,children:`Cancel`})]})]})}var qr=`herdr machine add <host>`;function Jr({onClose:e}){let[t,n]=(0,h.useState)(null);async function r(){try{await navigator.clipboard.writeText(qr),n(`Copied the command.`)}catch(e){n(`Could not copy: ${String(e)}`)}}return(0,g.jsxs)(`section`,{"aria-label":`Add machine`,className:`flex flex-col gap-2 rounded-lg border p-2`,onKeyDown:Gr(e),children:[(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`herdr asks questions in a terminal, which the Toodo server cannot open. Run this command in a terminal on the server, replacing `,(0,g.jsx)(`code`,{children:`<host>`}),` with an SSH host from its ~/.ssh/config, then reload the machine list here.`]}),(0,g.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,g.jsx)(`code`,{className:`max-w-full rounded bg-muted px-1.5 py-1 text-xs`,"aria-label":`Add machine command`,children:qr}),(0,g.jsx)(a,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void r(),children:`Copy command`})]}),t&&(0,g.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t})]})}var Yr=[`Source`,`Completion`,`Runner`,`Details`],Xr={none:`A folder without git. Tasks get no branch, worktree, or pull request.`,local_git:`A git repository without GitHub. Task branches merge locally.`,github:`A git repository with a GitHub origin. Tasks ship as pull requests.`},Zr={open:`The folder already holds the repository.`,init:`Make a folder a new git repository without a remote.`,clone:`Clone a repository URL into a new folder.`},Qr={manual:`When its criteria are met; nothing is merged.`,local_merge:`Once its branch is merged into the base branch locally.`,pr_merge:`Once its pull request is merged into the base branch.`},$r={herdr:`Opens agents in herdr on a worktree and branch of the task.`,none:`Only marks the task in progress.`},ei={clone:{submit:`Clone workspace`,pending:`Cloning...`},open:{submit:`Open workspace`,pending:`Opening...`},init:{submit:`Init workspace`,pending:`Initializing...`},none:{submit:`Add workspace`,pending:`Adding...`}};function $({legend:e,value:t,choices:n,onChange:r,autoFocus:a=!1}){let o=(0,h.useId)();return(0,g.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,g.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium`,children:e}),n.map(e=>{let n=e.value===t,s=e.problem!==null,c=`${o}-${e.value}`;return(0,g.jsxs)(`label`,{className:i(`flex items-start gap-2.5 rounded-lg border px-3 py-2 transition-colors has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50`,s?`cursor-not-allowed border-dashed`:`cursor-pointer hover:bg-muted`,n&&`border-ring bg-secondary hover:bg-secondary`),children:[(0,g.jsx)(`input`,{type:`radio`,name:o,value:e.value,checked:n,disabled:s,autoFocus:a&&n,"aria-labelledby":c,"aria-describedby":`${c}-about`,onChange:()=>r(e.value),className:`mt-0.5 size-4 shrink-0 accent-primary`}),(0,g.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,g.jsx)(`span`,{id:c,className:i(`text-sm font-medium`,s&&`text-muted-foreground`),children:e.label}),(0,g.jsxs)(`span`,{id:`${c}-about`,className:`flex items-start gap-1 text-xs text-muted-foreground`,children:[s&&(0,g.jsx)(Ze,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}),e.problem??e.description]})]})]},e.value)})]})}function ti({machine:e,onCreated:t,onClose:n}){let r=hn(),o=(0,h.useRef)(null),s=(0,h.useId)(),[c,l]=(0,h.useState)(0),[u,d]=(0,h.useState)({source:`github`,repository:null,completion:null,runner:null}),[f,p]=(0,h.useState)(``),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(``),S=e??`Local`,C=e===null?{kind:`local`}:{kind:`ssh`,label:e},w=kr(u),T=w.repository===`clone`,E=fn(C).data,D=E===void 0?``:T?E:Br(E),O=m??D,ee=!T&&m===null,k=v??(T?Hr(f):ee?``:Vr(O)),A=T&&O.trim()&&k.trim()?sr(O.trim(),k.trim()):cr(O.trim()),j=c===Yr.length-1,M=r.isPending,te=ei[w.repository??`none`],ne=[yr[w.source],br[w.completion],xr[w.runner],S],N=T?void 0:w.source===`none`?`The folder the tasks are about. Toodo runs no git or herdr there.`:`The repository's own folder.`;function P(e){let t=Ar(u,e);kr(t).repository===`clone`!==T&&_(null),d(t)}function F(e){l(e)}function I(){M||n()}function re(n){if(n.preventDefault(),!j){F(c+1);return}let i={name:k,location:e===null?{kind:`local`,path:A}:{kind:`ssh`,machine:e,path:A},repository:w.repository===null?null:w.repository===`clone`?{kind:`clone`,url:f}:{kind:w.repository},source:w.source,completion:w.completion,runner:w.runner,defaultBaseBranch:w.source===`none`?null:b.trim()||null};r.mutate(i,{onSuccess:t})}return(0,g.jsxs)(`div`,{className:`fixed inset-0 z-50`,children:[(0,g.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-0 bg-black/40 max-md:hidden`,onClick:I}),(0,g.jsx)(`div`,{ref:o,role:`dialog`,"aria-modal":!0,"aria-labelledby":s,onKeyDown:e=>{e.key===`Tab`?dr(o.current,e.nativeEvent):Gr(n,M)(e)},className:i(`relative flex flex-col overflow-hidden bg-background text-foreground`,`max-md:h-full max-md:pt-[env(safe-area-inset-top)] max-md:pb-[env(safe-area-inset-bottom)]`,`md:absolute md:top-1/2 md:left-1/2 md:h-[min(40rem,calc(100dvh-4rem))] md:w-[min(36rem,calc(100vw-4rem))] md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-2xl md:border md:shadow-xl`),children:(0,g.jsxs)(`form`,{onSubmit:re,className:`flex min-h-0 flex-1 flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-4 pt-3 pb-2 md:px-6 md:pt-4`,children:[(0,g.jsxs)(`h2`,{id:s,className:`min-w-0 flex-1 truncate text-base font-semibold`,children:[`New workspace on `,S]}),(0,g.jsx)(a,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close new workspace`,title:`Close (Esc)`,disabled:M,onClick:I,children:(0,g.jsx)(dt,{})})]}),(0,g.jsx)(`ol`,{"aria-label":`Steps`,className:`grid shrink-0 grid-cols-2 gap-1 px-4 pb-3 md:grid-cols-4 md:px-6`,children:Yr.map((e,t)=>{let n=t===c;return(0,g.jsx)(`li`,{className:`min-w-0`,children:(0,g.jsxs)(`button`,{type:`button`,"aria-current":n?`step`:void 0,disabled:M,onClick:()=>F(t),className:i(`flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none`,n&&`bg-secondary hover:bg-secondary`),children:[(0,g.jsx)(`span`,{"aria-hidden":!0,className:i(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs font-medium`,n?`border-primary bg-primary text-primary-foreground`:`text-muted-foreground`),children:t+1}),(0,g.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,g.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,g.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:ne[t]})]})]})},e)})}),(0,g.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain border-t px-4 py-4 md:px-6`,children:[c===0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)($,{legend:`What does the workspace folder hold?`,value:w.source,autoFocus:!0,choices:hr.map(e=>({value:e,label:yr[e],description:Xr[e],problem:null})),onChange:e=>P({source:e})}),w.source!==`none`&&(0,g.jsx)($,{legend:`How does the repository get there?`,value:w.repository,choices:vr.map(e=>({value:e,label:Sr[e],description:Zr[e],problem:Or(w.source,e)})),onChange:e=>P({repository:e})})]}),c===1&&(0,g.jsx)($,{legend:`When is a task done?`,value:w.completion,autoFocus:!0,choices:gr.map(e=>({value:e,label:br[e],description:Qr[e],problem:Er(w.source,e)})),onChange:e=>P({completion:e})}),c===2&&(0,g.jsx)($,{legend:`What does starting a task do?`,value:w.runner,autoFocus:!0,choices:_r.map(e=>({value:e,label:xr[e],description:$r[e],problem:Dr(w.source,w.completion,e)})),onChange:e=>P({runner:e})}),j&&(0,g.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[T&&(0,g.jsx)(Q,{label:`Repository URL`,children:({id:e})=>(0,g.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:f,onChange:e=>p(e.target.value),required:!0,autoFocus:!0})}),(0,g.jsx)(Q,{label:T?`Parent folder`:`Folder`,help:N,children:({id:e,describedBy:t})=>(0,g.jsx)(ur,{id:e,machine:C,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,describedBy:t,value:O,onChange:_,required:!0,autoFocus:!T})}),(0,g.jsx)(Q,{label:`Name`,children:({id:e})=>(0,g.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,value:k,onChange:e=>y(e.target.value),required:!0})}),T&&O.trim()&&k.trim()&&(0,g.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,title:A,children:[`Clones into `,A]}),w.repository===`init`&&(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder is created if it does not exist and becomes a git repository without a remote.`}),w.source!==`none`&&(0,g.jsx)(Q,{label:`Base branch`,help:w.repository===`init`?`Uses main if empty.`:`Detected from the repository if empty.`,children:({id:e,describedBy:t})=>(0,g.jsx)(`input`,{id:e,className:`h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 text-sm outline-none max-md:h-11 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,"aria-describedby":t,value:b,onChange:e=>x(e.target.value)})}),r.isError&&(0,g.jsx)(`p`,{role:`alert`,className:`text-xs break-words text-destructive`,children:r.error.message})]})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t px-4 py-3 md:px-6`,children:[c===0?(0,g.jsx)(a,{type:`button`,variant:`ghost`,disabled:M,onClick:I,children:`Cancel`}):(0,g.jsxs)(a,{type:`button`,variant:`ghost`,disabled:M,onClick:()=>F(c-1),children:[(0,g.jsx)(tt,{"data-icon":`inline-start`}),`Back`]}),(0,g.jsx)(a,{type:`submit`,className:`ml-auto`,changesData:j,disabled:M||j&&ee,children:j?M?te.pending:te.submit:(0,g.jsxs)(g.Fragment,{children:[`Next`,(0,g.jsx)($e,{"data-icon":`inline-end`})]})})]})]})})]})}export{kn as $,ir as A,z as At,tn as B,k as Bt,Kn as C,H as Ct,Rn as D,tt as Dt,Hn as E,at as Et,Dn as F,pe as Ft,Fn as G,se as Gt,jn as H,w as Ht,wn as I,L as It,Bn as J,Xn as K,y as Kt,tr as L,T as Lt,cn as M,Te as Mt,sn as N,ge as Nt,bn as O,$e as Ot,Mn as P,R as Pt,an as Q,On as R,j as Rt,qn as S,Dt as St,Ln as T,lt as Tt,Gn as U,M as Ut,In as V,ee as Vt,En as W,O as Wt,Un as X,on as Y,Cn as Z,$n as _,Bt as _t,Nr as a,Sn as at,nn as b,wt as bt,Pr as c,ln as ct,dr as d,Rt as dt,zn as et,$t as f,Lt as ft,Yn as g,zt as gt,Y as h,Ot as ht,Mr as i,Zn as it,Jn as j,Fe as jt,nr as k,B as kt,pr as l,vn as lt,pn as m,Ht as mt,Ir as n,An as nt,Gr as o,Wn as ot,rr as p,It as pt,er as q,v as qt,Ur as r,Pn as rt,jr as s,gn as st,Kr as t,Vn as tt,mr as u,mn as ut,Tn as v,Tt as vt,Nn as w,dt as wt,yn as x,Ct as xt,rn as y,Et as yt,en as z,A as zt};