@puddle-code/cli 0.3.14 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/README.md +31 -19
  3. package/dist/host-control.mjs +1980 -133
  4. package/dist/index.js +4341 -970
  5. package/dist/install.sh +401 -40
  6. package/dist/public/assets/App-CB0Bm55u.js +9 -0
  7. package/dist/public/assets/{CompilationCommandForm-8ipw9M-Z.js → CompilationCommandForm-vv5bglnl.js} +1 -1
  8. package/dist/public/assets/Dashboard-BQd42kix.js +1 -0
  9. package/dist/public/assets/{EditorTabClose-o1L4BgTN.js → EditorTabClose-D3LwFFHd.js} +1 -1
  10. package/dist/public/assets/{LazyTerminal-Crwcrh-K.js → LazyTerminal-CfuC3bjp.js} +2 -2
  11. package/dist/public/assets/{ModelRefcount-0o8MEOUT.js → ModelRefcount-DtJdNeW7.js} +1 -1
  12. package/dist/public/assets/NewProjectDialog-DYn30yon.js +1 -0
  13. package/dist/public/assets/{NotebookWidget-Ci7TAuWd.js → NotebookWidget-BntkgqbM.js} +1 -1
  14. package/dist/public/assets/PaneEditorBody-ChNwAz96.js +284 -0
  15. package/dist/public/assets/{PdfViewer-BoFsXAue.js → PdfViewer-DYmz05py.js} +1 -1
  16. package/dist/public/assets/ReleaseNotesDialog-D2kA6oIr.js +1 -0
  17. package/dist/public/assets/SettingsDialog-BWWWn7I0.js +8 -0
  18. package/dist/public/assets/{Terminal-B3Iw783s.js → Terminal-BQHSZc8Q.js} +5 -5
  19. package/dist/public/assets/Workspace-DVTqrQNf.js +20 -0
  20. package/dist/public/assets/api-BOuyloUi.js +1 -0
  21. package/dist/public/assets/auth-olLlgxc3.js +64 -0
  22. package/dist/public/assets/{buffer-store-B2nYD11t.js → buffer-store-BWLcD39y.js} +1 -1
  23. package/dist/public/assets/{context-CwZ4epwz.js → context-C3-WejyN.js} +1 -1
  24. package/dist/public/assets/{forward-link-C-8Xn8gf.js → forward-link-DMvLf0Xw.js} +1 -1
  25. package/dist/public/assets/{hotkeys-DOpJ1a7g.js → hotkeys-Cu0t6sbz.js} +1 -1
  26. package/dist/public/assets/index--5A6_BeN.css +2 -0
  27. package/dist/public/assets/{index-B9DFgBft.js → index-BUAoYe1o.js} +3 -3
  28. package/dist/public/assets/markdown-CMSzQtLp.js +8 -0
  29. package/dist/public/assets/markdown-it-CWoG9_Dn.js +13 -0
  30. package/dist/public/assets/{markdown-mermaid-CZnHoKN5.js → markdown-mermaid-BCXEEB98.js} +1 -1
  31. package/dist/public/assets/media-refresh-store-BplHZVs4.js +1 -0
  32. package/dist/public/assets/notification-delivery-CDWhS_kj.js +1 -0
  33. package/dist/public/assets/protocol-support-CsLR9u7d.js +1 -0
  34. package/dist/public/assets/queue-BlrQxHDl.js +3 -0
  35. package/dist/public/assets/{scroll-restoration-gKZDDamc.js → scroll-restoration-CwXbvZvT.js} +1 -1
  36. package/dist/public/assets/selection-actions-B2XIuCoH.js +1 -0
  37. package/dist/public/assets/{session-order-SN_zG4Us.js → session-order-unCbOqgk.js} +1 -1
  38. package/dist/public/assets/{switch-iVuj74VW.js → switch-DVo2TkMf.js} +1 -1
  39. package/dist/public/assets/{use-ui-state-CQp93ZE4.js → use-ui-state-i7N5-9dI.js} +1 -1
  40. package/dist/public/assets/{view-state-store-CVAUWqnG.js → view-state-store-Cy9sQJoZ.js} +1 -1
  41. package/dist/public/assets/ws-BX1iQbeP.js +1 -0
  42. package/dist/public/index.html +3 -3
  43. package/dist/pudl.js +1996 -183
  44. package/package.json +1 -1
  45. package/dist/public/assets/App-5QiKmUI_.js +0 -2
  46. package/dist/public/assets/Dashboard-B9v8mQKk.js +0 -1
  47. package/dist/public/assets/NewProjectDialog-qFDLTphH.js +0 -1
  48. package/dist/public/assets/PaneEditorBody-C8uTV9yU.js +0 -303
  49. package/dist/public/assets/SettingsDialog-tW18Y_Wr.js +0 -8
  50. package/dist/public/assets/Workspace-D2IYXJV2.js +0 -20
  51. package/dist/public/assets/api-CfmzEbQ_.js +0 -1
  52. package/dist/public/assets/auth-CIb9G2C5.js +0 -64
  53. package/dist/public/assets/errors-DTaodZDR.js +0 -1
  54. package/dist/public/assets/index-DwtrJj9v.css +0 -2
  55. package/dist/public/assets/media-refresh-store-DDvrEM5K.js +0 -1
  56. package/dist/public/assets/notification-delivery-DdTD40aA.js +0 -1
  57. package/dist/public/assets/protocol-support-BGk73LFk.js +0 -1
  58. package/dist/public/assets/selection-actions-BjVj7hXw.js +0 -1
  59. package/dist/public/assets/ws-CspBmo8M.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{n as r}from"./api-CfmzEbQ_.js";var i=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(){}},a=new class extends i{#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`}},o={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},s=new class{#e=o;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 c(e){setTimeout(e,0)}var l=typeof window>`u`||`Deno`in globalThis;function u(){}function d(e,t){return typeof e==`function`?e(t):e}function f(e){return typeof e==`number`&&e>=0&&e!==1/0}function p(e,t){return Math.max(e+(t||0)-Date.now(),0)}function m(e,t){return typeof e==`function`?e(t):e}function h(e,t){return typeof e==`function`?e(t):e}function g(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==v(o,t.options))return!1}else if(!b(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 _(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(y(t.options.mutationKey)!==y(a))return!1}else if(!b(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function v(e,t){return(t?.queryKeyHashFn||y)(e)}function y(e){return JSON.stringify(e,(e,t)=>T(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function b(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>b(e[n],t[n])):!1}var x=Object.prototype.hasOwnProperty;function S(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=w(e)&&w(t);if(!r&&!(T(e)&&T(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:x.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=S(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function C(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 w(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T(e){if(!ee(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ee(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ee(e){return Object.prototype.toString.call(e)===`[object Object]`}function te(e){return new Promise(t=>{s.setTimeout(t,e)})}function E(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:S(e,t)}function ne(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function re(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var D=Symbol();function ie(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===D?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function O(e,t){return typeof e==`function`?e(...t):!!e}function ae(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var k=(()=>{let e=()=>l;return{isServer(){return e()},setIsServer(t){e=t}}})();function A(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var oe=c;function se(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=oe,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=se(),M=new class extends i{#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 ce(e){return Math.min(1e3*2**e,3e4)}function N(e){return(e??`online`)!==`online`||M.isOnline()}var P=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function F(e){let t=!1,n=0,r,i=A(),o=()=>i.status!==`pending`,s=t=>{if(!o()){let n=new P(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>a.isFocused()&&(e.networkMode===`always`||M.isOnline())&&e.canRun(),d=()=>N(e.networkMode)&&e.canRun(),f=e=>{o()||(r?.(),i.resolve(e))},p=e=>{o()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),h=()=>{if(o())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(f).catch(r=>{if(o())return;let i=e.retry??(k.isServer()?0:3),a=e.retryDelay??ce,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),te(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?h():m().then(h),i)}}var I=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),f(this.gcTime)&&(this.#e=s.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(k.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(s.clearTimeout(this.#e),this.#e=void 0)}};function le(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=>{ae(e,()=>t.signal,()=>n=!0)},u=ie(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?re:ne;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?R:L,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:L(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function L(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 R(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function ue(e,t){return t?L(e,t)!=null:!1}function de(e,t){return!t||!e.getPreviousPageParam?!1:R(e,t)!=null}var fe=class extends I{#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=V(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=V(this.options);e.data!==void 0&&(this.setState(B(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(u).catch(u):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=>h(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===D||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>m(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:!p(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ie(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`?le(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=F({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof P&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof P){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...z(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...B(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),j.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function z(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:N(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function B(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function V(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 H=class extends i{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=A(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),U(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return W(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return W(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 h(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&&!C(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&me(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||h(this.options.enabled,this.#t)!==h(t.enabled,this.#t)||m(this.options.staleTime,this.#t)!==m(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||h(this.options.enabled,this.#t)!==h(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return he(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(u)),t}#g(){this.#b();let e=m(this.options.staleTime,this.#t);if(k.isServer()||this.#r.isStale||!f(e))return;let t=p(this.#r.dataUpdatedAt,e)+1;this.#d=s.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(k.isServer()||h(this.options.enabled,this.#t)===!1||!f(this.#p)||this.#p===0)&&(this.#f=s.setInterval(()=>{(this.options.refetchIntervalInBackground||a.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(s.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(s.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&U(e,t),o=i&&me(e,n,t,r);(a||o)&&(l={...l,...z(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=E(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=E(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let _=l.fetchStatus===`fetching`,v=m===`pending`,y=m===`error`,b=v&&_,x=d!==void 0,S={status:m,fetchStatus:l.fetchStatus,isPending:v,isSuccess:m===`success`,isError:y,isInitialLoading:b,isLoading:b,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:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:G(e,t),refetch:this.refetch,promise:this.#o,isEnabled:h(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{let e=this.#o=S.promise=A();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!C(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){j.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function pe(e,t){return h(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&h(t.retryOnMount,e)===!1)}function U(e,t){return pe(e,t)||e.state.data!==void 0&&W(e,t,t.refetchOnMount)}function W(e,t,n){if(h(t.enabled,e)!==!1&&m(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&G(e,t)}return!1}function me(e,t,n,r){return(e!==t||h(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&G(e,n)}function G(e,t){return h(t.enabled,e)!==!1&&e.isStaleByTime(m(t.staleTime,e))}function he(e,t){return!C(e.getCurrentResult(),t)}var ge=class extends I{#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||_e(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=F({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),j.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function _e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ve=class extends i{#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),C(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&y(t.mutationKey)!==y(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??_e();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(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},K=e(t(),1),ye=n(),be=K.createContext(void 0),q=e=>{let t=K.useContext(be);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},xe=({client:e,children:t})=>(K.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,ye.jsx)(be.Provider,{value:e,children:t})),Se=K.createContext(!1),Ce=()=>K.useContext(Se);Se.Provider;function we(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Te=K.createContext(we()),Ee=()=>K.useContext(Te),De=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?O(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Oe=e=>{K.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||O(n,[e.error,r])),Ae=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.isLoading&&e.isFetching&&!t,Me=(e,t)=>e?.suspense&&t.isPending,Ne=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Pe(e,t,n){let r=Ce(),i=Ee(),a=q(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Ae(o),De(o,i,s),Oe(i);let l=!a.getQueryCache().get(o.queryHash),[d]=K.useState(()=>new t(a,o)),f=d.getOptimisticResult(o),p=!r&&c;if(K.useSyncExternalStore(K.useCallback(e=>{let t=p?d.subscribe(j.batchCalls(e)):u;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),K.useEffect(()=>{d.setOptions(o)},[o,d]),Me(o,f))throw Ne(o,d,i);if(ke({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw f.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,f),o.experimental_prefetchInRender&&!k.isServer()&&je(f,r)&&(l?Ne(o,d,i):s?.promise)?.catch(u).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?f:d.trackResult(f)}function J(e,t){return Pe(e,H,t)}function Y(e,t){let n=q(t),[r]=K.useState(()=>new ve(n,e));K.useEffect(()=>{r.setOptions(e)},[r,e]);let i=K.useSyncExternalStore(K.useCallback(e=>r.subscribe(j.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=K.useCallback((e,t)=>{r.mutate(e,t).catch(u)},[r]);if(i.error&&O(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Fe=12,X=typeof document<`u`?document.hasFocus():!0;typeof window<`u`&&(window.addEventListener(`focus`,()=>{X=!0}),window.addEventListener(`blur`,()=>{X=!1}),a.setEventListener(e=>{let t=()=>e(void 0);return window.addEventListener(`visibilitychange`,t,!1),window.addEventListener(`focus`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t),window.removeEventListener(`focus`,t)}}));function Z(e){return()=>X?e:e*Fe}function Ie(){return J({queryKey:[`profiles`],queryFn:()=>r(`GET`,`/api/profiles`)})}function Le(e){return J({queryKey:[`profile-settings`,e],queryFn:()=>r(`GET`,`/api/profiles/${e}/settings`),enabled:e!==void 0})}function Re(e){return J({queryKey:[`accounts`,e],queryFn:()=>r(`GET`,`/api/accounts?profile=${e}`),enabled:e!==void 0})}function ze(e){return J({queryKey:[`account-usage`,e],queryFn:()=>r(`GET`,`/api/accounts/${e}/usage`),enabled:e!==void 0,staleTime:15e3})}function Be(){return J({queryKey:[`repos`],queryFn:()=>r(`GET`,`/api/repos`)})}function Ve(e,t=!0){return J({queryKey:[`projects`,e??`all`],queryFn:()=>r(`GET`,e===void 0?`/api/projects`:`/api/projects?profile=${e}`),enabled:t})}function He(e){return J({queryKey:[`project`,e],queryFn:()=>r(`GET`,`/api/projects/${e}`),enabled:e!==void 0,placeholderData:e=>e})}function Ue(e){return r(`POST`,`/api/projects/${e}/conversations/refresh`)}function We(e){return J({queryKey:[`sessions`,e],queryFn:()=>r(`GET`,`/api/sessions?project=${e}`),enabled:e!==void 0})}var Ge={queryKey:[`sessions`,`all`],queryFn:()=>r(`GET`,`/api/sessions`)};function Ke(e=!0){return J({...Ge,enabled:e})}function qe(e){return e.fetchQuery(Ge)}function Je(){return J({queryKey:[`config`],queryFn:()=>r(`GET`,`/api/config`)})}function Ye(e){return J({queryKey:[`repo-branches`,e],queryFn:()=>r(`GET`,`/api/repos/${e}/branches`),enabled:e!==void 0,staleTime:3e4})}function Xe(e,t=1e4){return J({queryKey:[`repo-worktrees`,e],queryFn:()=>r(`GET`,`/api/repos/${e}/worktrees`),enabled:e!==void 0,staleTime:t})}function Ze(e,t){let n=q();return Y({mutationFn:t=>r(`DELETE`,`/api/repos/${e}/worktrees?path=${encodeURIComponent(t)}`),onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function Qe(e,t){let n=q();return Y({mutationFn:({name:t,confirm:n})=>{let i=new URLSearchParams({name:t});return n&&i.set(`confirm`,`1`),r(`DELETE`,`/api/repos/${e}/branches?${i.toString()}`)},onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function $e(e){return J({queryKey:[`fs-dirs`,e],queryFn:()=>r(`GET`,`/api/fs/dirs?prefix=${encodeURIComponent(e)}`),enabled:e.startsWith(`/`)||e.startsWith(`~`),placeholderData:e=>e,staleTime:1e4})}function et(){return J({queryKey:[`version`],queryFn:()=>r(`GET`,`/api/version`),staleTime:1/0})}function tt(){return J({queryKey:[`host`],queryFn:()=>r(`GET`,`/api/host`),staleTime:1/0})}function nt(e){return e?e.displayName||e.hostname:void 0}function rt(){return J({queryKey:[`agents`],queryFn:()=>r(`GET`,`/api/agents`),staleTime:3e4,refetchOnWindowFocus:!0})}function it(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/profiles`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function at(e){let t=q();return Y({mutationFn:t=>r(`PATCH`,`/api/profiles/${e}/settings`,t),onSuccess:n=>t.setQueryData([`profile-settings`,e],n)})}function ot(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/profiles/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function st(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/accounts/${e}`,t),onSuccess:t=>{e.invalidateQueries({queryKey:[`accounts`,t.profile_id]}),e.invalidateQueries({queryKey:[`account-usage`,t.id]})}})}function ct(){let e=q();return Y({mutationFn:e=>r(`DELETE`,`/api/profiles/${e}`),onSuccess:()=>e.clear()})}function lt(){let e=q();return Y({mutationFn:e=>r(`DELETE`,`/api/accounts/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`accounts`]})})}function ut(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/accounts`,e),onSuccess:t=>void e.invalidateQueries({queryKey:[`accounts`,t.profile_id]})})}function dt(){return Y({mutationFn:e=>r(`POST`,`/api/accounts/${e}/login`)})}function ft(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/repos`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function pt(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/repos/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function mt(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/repos/${e}/fetch`),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function ht(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/projects`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function gt(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/projects/${e}`,t),onSuccess:t=>{e.setQueryData([`project`,t.id],e=>e&&{...e,project:t}),e.invalidateQueries({queryKey:[`projects`]})}})}function _t(e,t){return J({queryKey:[`scratchpad`,e,t??`none`],queryFn:()=>r(`GET`,`/api/scratchpad?profile=${e}${t?`&project=${t}`:``}`),enabled:e!==void 0})}function vt(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/scratchpad`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function yt(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/scratchpad/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function bt(){let e=q();return Y({mutationFn:e=>r(`DELETE`,`/api/scratchpad/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function xt(e,t){return J({queryKey:[`layouts`,e,t??`none`],queryFn:()=>r(`GET`,`/api/layouts?profile=${e}${t?`&project=${t}`:``}`),enabled:e!==void 0})}function St(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/layouts`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`layouts`]})})}function Ct(){let e=q();return Y({mutationFn:({id:e,...t})=>r(`PATCH`,`/api/layouts/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`layouts`]})})}function wt(){let e=q();return Y({mutationFn:e=>r(`DELETE`,`/api/layouts/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`layouts`]})})}function Q(e,t){e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`project`,t.project_id]})}function Tt(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/sessions`,e),onSuccess:t=>Q(e,t)})}function Et(e){let t=q();return Y({mutationFn:t=>r(`POST`,`/api/sessions/${t}/${e}`),onSuccess:e=>Q(t,e)})}function Dt(){let e=q();return Y({mutationFn:({sessionId:e,accountId:t})=>r(`POST`,`/api/sessions/${e}/migrate`,{account_id:t}),onSuccess:t=>Q(e,t)})}function Ot(){let e=q();return Y({mutationFn:({sessionId:e,accountId:t})=>r(`POST`,`/api/sessions/${e}/handoff`,{account_id:t}),onSuccess:(t,{sessionId:n})=>{Q(e,t),e.invalidateQueries({queryKey:[`session`,n]})}})}function kt(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/sessions/${e}/archive`),onSuccess:t=>Q(e,t)})}function At(){let e=q();return Y({mutationFn:e=>r(`POST`,`/api/sessions/${e}/unarchive`),onSuccess:t=>Q(e,t)})}function jt(){let e=q();return Y({mutationFn:({sessionId:e,title:t})=>r(`PATCH`,`/api/sessions/${e}`,{title:t}),onSuccess:t=>Q(e,t)})}function Mt(){let e=q();return Y({mutationFn:e=>r(`PATCH`,`/api/config`,e),onSuccess:(t,n)=>{e.setQueryData([`config`],t),`displayName`in n&&e.invalidateQueries({queryKey:[`host`]})}})}async function Nt(e){try{return await r(`GET`,`/api/profiles/${e}/state`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`no_state`)return null;throw e}}function Pt(e,t){return r(`PUT`,`/api/profiles/${e}/state`,{ui_state:t})}function Ft(e,t){return J({queryKey:[`ports`,e],queryFn:()=>r(`GET`,`/api/sessions/${e}/ports`),enabled:e!==void 0&&t,refetchInterval:Z(5e3),refetchIntervalInBackground:!1})}function It(e,t){return J({queryKey:[`session-env`,e],queryFn:()=>r(`GET`,`/api/sessions/${e}/env`),enabled:e!==void 0&&t,refetchInterval:Z(5e3),refetchIntervalInBackground:!1})}function Lt(){let e=q();return Y({mutationFn:e=>r(`DELETE`,`/api/sessions/${e}/env`),onSuccess:(t,n)=>{e.setQueryData([`session-env`,n],{vars:[]})}})}function $(e,t,n){return!e||e.major>t||e.major===t&&e.minor>=n}var Rt=e=>e!==void 0&&$(e,21,3),zt=e=>e!==void 0&&$(e,24,5);function Bt(e){return $(e,17,1)}function Vt(e){return $(e,17,3)}var Ht=e=>e!==void 0&&$(e,24,4),Ut=e=>$(e,10,3),Wt=e=>$(e,12,3),Gt=e=>$(e,12,4),Kt=e=>$(e,15,3),qt=e=>e!==void 0&&$(e,16,3),Jt=e=>$(e,16,4),Yt=e=>$(e,14,1),Xt=e=>e!==void 0&&$(e,24,6),Zt=e=>e!==void 0&&$(e,25,1),Qt=e=>e!==void 0&&$(e,25,2),$t=e=>e!==void 0&&$(e,25,3),en=e=>e!==void 0&&$(e,25,4);export{ot as $,ut as A,M as At,wt as B,D as Bt,ze as C,xe as Ct,kt as D,fe as Dt,Ke as E,H as Et,vt as F,_ as Ft,Ot as G,bt as H,i as Ht,Tt as I,g as It,dt as J,tt as K,et as L,u as Lt,it as M,d as Mt,ht as N,y as Nt,Lt as O,ue as Ot,ft as P,v as Pt,Ct as Q,lt as R,b as Rt,Ue as S,Pe as St,rt as T,ge as Tt,$e as U,ct as V,a as Vt,mt as W,st as X,Dt as Y,Mt as Z,Ut as _,We as _t,qt as a,Ie as at,nt as b,Y as bt,Rt as c,Ze as ct,Qt as d,Xe as dt,at as et,$t as f,Be as ft,Kt as g,Ft as gt,zt as h,It as ht,Bt as i,Le as it,St as j,j as jt,Je as k,de as kt,Jt as l,jt as lt,en as m,Et as mt,Ht as n,pt as nt,Yt as o,He as ot,Xt as p,_t as pt,xt as q,Vt as r,yt as rt,Gt as s,Ve as st,Wt as t,gt as tt,Zt as u,Ye as ut,qe as v,At as vt,Re as w,q as wt,Pt as x,J as xt,Nt as y,Z as yt,Qe as z,m as zt};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{D as n,E as r,G as i,V as a,_ as o,a as s,d as c,o as l,u}from"./auth-CIb9G2C5.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{d as f}from"./index-B9DFgBft.js";import{n as p}from"./api-CfmzEbQ_.js";import{n as m}from"./dist-BOS6OKSE.js";import{t as h}from"./x-DCpy1q13.js";import{t as g}from"./button-9AVMLaMQ.js";import{t as _}from"./createLucideIcon-DyMAgLa3.js";import{t as v}from"./copy-CGsu8426.js";import{t as y}from"./ws-CspBmo8M.js";var b=_(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),x=_(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function ee(){return f.get()}var S=32,C=2048;function w(e,t,n){let r=e.getLine(t);if(!r)return null;let i=e.getNullCell(),a=``,o=[];for(let s=0;s<Math.min(n,r.length);s++){if(!r.getCell(s,i)||i.getWidth()===0)continue;if(s===n-1&&i.getChars()===``){let n=e.getLine(t+1);if(n?.isWrapped&&n.getCell(0)?.getWidth()===2)continue}let c=i.getChars()||` `;a+=c;for(let e=0;e<c.length;e++)o.push({row:t,col:s})}return{text:a,cells:o,isWrapped:r.isWrapped}}function te(e,t,n){return{...e,text:e.text.slice(t,n),cells:e.cells.slice(t,n)}}function T(e,t,n,r,i){if(t<0||n<1)return[];let a=Math.max(0,t-S+1),o=new Map;for(let r=a;r<t+S;r++){let t=w(e,r,n);if(!t)break;o.set(r,t)}let s=new Set,c=[];for(let l of[!0,!1])for(let u=a;u<=t;u++){if(o.get(u)?.isWrapped&&u>a)continue;let d=``,f=[];for(let a=u;a<u+S;a++){let p=o.get(a);if(!p)break;let m=o.get(a-1);if(a>u&&!p.isWrapped&&!(l&&m&&i(m,p,n,d)))break;let h=o.get(a+1),g=te(p,a>u&&!p.isWrapped?p.text.length-p.text.trimStart().length:0,h?.isWrapped?p.text.length:p.text.trimEnd().length);if(d.length+g.text.length>C)break;if(d+=g.text,f.push(...g.cells),!(a<t))for(let n of r(d)){let r=f[n.start],i=f[n.end-1];if(!r||!i||r.row>t||i.row<t)continue;let a=`${d.slice(n.start,n.end)}\0${r.row}:${r.col}-${i.row}:${i.col}`;if(s.has(a))continue;s.add(a);let o=e.getLine(i.row)?.getCell(i.col)?.getWidth()??1;c.push({candidate:n,start:r,end:{row:i.row,col:i.col+Math.max(1,o)-1},text:d.slice(n.start,n.end)})}}}return c.sort((e,t)=>t.text.length-e.text.length)}var ne=r.options.join(`,`),E=u.imageBytes,re=20*1024*1024;async function ie(e,t,n){n?.throwIfAborted();let i=r.safeParse(e.type);if(!i.success)throw Error(`Choose a PNG, JPEG, GIF or WebP image.`);if(e.size===0)throw Error(`This image is empty.`);if(e.size>re)throw Error(`Choose an image smaller than 20 MiB.`);if(!t||e.size<=E)return{blob:e,mime:i.data,resized:!1};if(i.data===`image/gif`)throw Error(`Choose a GIF no larger than 4 MiB for remote access.`);let a=await createImageBitmap(e);try{n?.throwIfAborted();let e=document.createElement(`canvas`),t=e.getContext(`2d`);if(!t)throw Error(`Could not prepare this image.`);let o=i.data===`image/jpeg`?`image/jpeg`:`image/webp`,s=Math.min(1,2048/Math.max(a.width,a.height));for(let i=0;i<8;i++){e.width=Math.max(1,Math.round(a.width*s)),e.height=Math.max(1,Math.round(a.height*s)),t.drawImage(a,0,0,e.width,e.height);for(let t of[.85,.7,.55]){let i=await new Promise(n=>e.toBlob(n,o,t));if(n?.throwIfAborted(),i&&i.size<=E)return{blob:i,mime:r.parse(i.type),resized:!0}}s*=.75}throw Error(`This image is too large to attach remotely. Choose a smaller image.`)}finally{a.close()}}var D=new WeakSet,ae=Math.floor((o.requestBytes-1024)*3/4);async function oe(e,t,r,o,s,l,d){let f=e.generation,p=()=>{if(l?.throwIfAborted(),s(),e.generation!==f)throw Error(`The connection changed; the image upload was interrupted.`)};if(p(),!r.size||r.size>u.imageBytes)throw Error(`The prepared image must be no larger than 4 MiB.`);if(D.has(e))throw Error(`An image upload is already in progress.`);D.add(e);let m=crypto.randomUUID(),h=`/api/worktrees/${t}/paste-upload`,g=!1,_=!1,v=async(t,n,r)=>{p();let a=await e.request(t,n,r,l),o=await a.json();if(p(),!a.ok){let e=i.safeParse(o);throw Error(e.success?e.data.error.message:`The image upload failed.`)}return o},y=e=>v(`POST`,h,e),b=async e=>{let t=new Uint8Array(await e.arrayBuffer());return p(),btoa(Array.from(t,e=>String.fromCharCode(e)).join(``))};try{let e=a.parse(await v(`GET`,`/api/version`));if(d?.(0,r.size),!e.remote_image_uploads){if(r.size>ae)throw Error(`Update the host connector to upload images larger than 191 KiB.`);let e=await b(r),i=n.parse(await v(`POST`,`/api/worktrees/${t}/paste`,{mime:o,data:e}));return d?.(r.size,r.size),i}if(g=!0,c.parse(await y({action:`start`,upload:m,mime:o,size:r.size})).received!==0)throw Error(`Invalid image upload acknowledgement.`);for(let e=0;e<r.size;e+=u.chunkBytes){let t=r.slice(e,e+u.chunkBytes),n=await b(t),i=c.parse(await y({action:`chunk`,upload:m,offset:e,data:n}));if(i.received!==e+t.size)throw Error(`Invalid image upload acknowledgement.`);d?.(i.received,r.size)}let i=n.parse(await y({action:`finish`,upload:m}));return _=!0,i}finally{if(g&&!_&&e.generation===f)try{s(),e.request(`POST`,h,{action:`cancel`,upload:m}).catch(()=>{})}catch{}D.delete(e)}}function O(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let r=Array.from(e.clipboardData?.items??[]);if(r.some(e=>e.type===`text/plain`))return!1;let i=r.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!i)return!1;let a=i.getAsFile();return a?(k(a,t,n).then(({resized:e})=>{e&&m(`Image resized for remote access`)}).catch(e=>{m.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}),!0):!1}async function k(e,t,r,i={}){if(t.startsWith(`login-`)||t===`home`)throw Error(`Open a project terminal to attach an image.`);let a=l(),o=a?.generation,s=()=>{if(l()!==a||a?.generation!==o||!y.isConnected())throw Error(`The terminal connection changed; the image was not inserted.`)};i.signal?.throwIfAborted(),s(),i.onProgress?.({stage:`preparing`});let{blob:c,mime:u,resized:d}=await ie(e,a!==null,i.signal);s();let f=a?await oe(a,t,c,u,s,i.signal,(e,t)=>i.onProgress?.(e===t?{stage:`saving`}:{stage:`uploading`,received:e,total:t})):await(async()=>{let e=await se(c);return s(),i.signal?.throwIfAborted(),n.parse(await p(`POST`,`/api/worktrees/${t}/paste`,{mime:u,data:e}))})();return i.signal?.throwIfAborted(),s(),i.onProgress?.({stage:`inserting`}),i.insert?i.insert(`${f.path} `):a?await a.input(t,r,`${f.path} `):y.write(t,r,`${f.path} `),{resized:d}}function se(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var A=/(?:^|[\s"'`([<])((?:(?:\/|\.{1,2}\/|~\/)(?:[\w.+@~-]+\/)*[\w.+@~-]+|(?:[\w.+@~-]+\/)+[\w.+@~-]*|[\w.+@~-]+\.[A-Za-z]\w{0,11}))(?::(\d{1,6})(?::(\d{1,6}))?)?/dg,ce=new Set([`.`,`,`,`;`,`:`,`)`,`]`,`'`,`"`]);function j(e){let t=[],n=new RegExp(A.source,A.flags),r;for(;r=n.exec(e);){let e=r.indices,n=r[1];if(!e?.[1]||n===void 0)continue;let i=e[1][0],a=e[1][1],o=n;for(o.startsWith(`@`)&&(o=o.slice(1),i++);o.length>0&&ce.has(o[o.length-1]);)o=o.slice(0,-1),a--;if(o.length===0)continue;let s=r[2]===void 0?void 0:Number.parseInt(r[2],10),c=r[3]===void 0?void 0:Number.parseInt(r[3],10),l=c!==void 0&&e[3]?e[3][1]:s!==void 0&&e[2]?e[2][1]:a;t.push({path:o,line:s,column:c,start:i,end:l})}return t}function le(e,t,n){let r=e.text.trimEnd(),i=t.text.trimStart();if(!/[\w.+@~/:-]$/.test(r)||!/^[\w.+@~:-]/.test(i)||/^(?:~\/|\.{1,2}\/)/.test(i))return!1;let a=e.cells[r.length-1];return r.endsWith(`/`)||a!==void 0&&a.col>=n-9}function ue(e,t,n){return T(e,t,n,j,le)}function de(e,t){return e.kind===`file`&&e.root!==void 0&&e.root!==t?e.root:null}var fe=class{fetcher;now;positiveTtlMs;negativeTtlMs;maxEntries;maxConcurrent;entries=new Map;inflight=new Map;inUse=0;waiters=[];constructor(e){this.fetcher=e.fetcher,this.now=e.now??Date.now,this.positiveTtlMs=e.positiveTtlMs??15e3,this.negativeTtlMs=e.negativeTtlMs??5e3,this.maxEntries=e.maxEntries??500,this.maxConcurrent=e.maxConcurrent??4}resolve(e,t,n){let r=`${e}\0${t}`,i=this.entries.get(r);if(i){if(this.now()<i.expiresAt)return Promise.resolve(i.value);this.entries.delete(r)}let a=this.inflight.get(r);if(a)return a;let o=this.withSlot(()=>this.fetcher(e,t,n)).then(e=>(this.store(r,e),e)).finally(()=>{this.inflight.delete(r)});return this.inflight.set(r,o),o}store(e,t){let n=t?this.positiveTtlMs:this.negativeTtlMs;for(this.entries.set(e,{value:t,expiresAt:this.now()+n});this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.entries.delete(e)}}async withSlot(e){this.inUse>=this.maxConcurrent&&await new Promise(e=>this.waiters.push(e)),this.inUse++;try{return await e()}finally{this.inUse--,this.waiters.shift()?.()}}};async function M(e,t,n,r){let i=new URLSearchParams({path:t});return n!==void 0&&i.set(`line`,String(n)),r!==void 0&&i.set(`root`,r),p(`GET`,`/api/worktrees/${e}/resolve?${i}`)}function N(e,t,n){let r=e.kind??`file`;return{kind:r,path:e.path,...e.root===void 0?{}:{root:e.root},...e.relative_path===void 0?{}:{relativePath:e.relative_path},...r===`file`&&t!==void 0?{line:Math.max(1,t)}:{},...r===`file`&&n!==void 0?{column:n}:{}}}async function pe(e,t,n){return N(await M(e,t,n?.line,n?.root),n?.line,n?.column)}async function P(e,t,n){try{return await M(e,t,n)}catch{return null}}function F(e,t,n){let r=new fe({fetcher:P});return e.registerLinkProvider({provideLinks(i,a){let o=e.buffer.active,s=ue(o,i-1,e.cols);if(s.length===0){a(void 0);return}Promise.all(s.map(async({candidate:e,start:i,end:a,text:o})=>{let s=await r.resolve(t,e.path,e.line);return s?{range:{start:{x:i.col+1,y:i.row+1},end:{x:a.col+1,y:a.row+1}},text:o,decorations:{underline:!0,pointerCursor:!0},activate:t=>{!t.metaKey&&!t.ctrlKey||n(N(s,e.line,e.column))}}:null})).then(e=>{let t=e.filter(e=>e!==null);a(t.length>0?t:void 0)})}})}var I=e(t(),1),L={ctrl:1,alt:2,shift:4},R=/^(?:\[[ABCD]|O[ABCD]|\[1;([2-8])[ABCD])$/,z=e=>e.startsWith(`\x1B`)?R.exec(e.slice(1)):null;function B(e){return!e.startsWith(`\x1B`)||e===`\x1B`||z(e)!==null||e===`\x1B[Z`}function me(e,t){if(!t)return e;let n=(t&L.ctrl)!==0,r=(t&L.alt)!==0,i=(t&L.shift)!==0,a=!!i|(r?2:0)|(n?4:0),o=z(e);if(o)return`\x1b[1;${1+(a|(o[1]?Number(o[1])-1:0))}${e.slice(-1)}`;if(!B(e))return e;if(e===` `||e===`\x1B[Z`)return i||e===`\x1B[Z`?`\x1B[Z`:` `;if(e===`\r`&&i)return`\x1b[13;${1+a}u`;if(i&&e.length===1){let t="`1234567890-=[]\\;',./".indexOf(e);t===-1?/[a-z]/.test(e)&&(e=e.toUpperCase()):e=`~!@#$%^&*()_+{}|:"<>?`[t]}if(n&&e.length===1){let t=e.toUpperCase().charCodeAt(0);t>=64&&t<=95?e=String.fromCharCode(t-64):e===` `?e=`\0`:e===`?`&&(e=``)}return r?`\x1b${e}`:e}function he(e){return e.length===3&&(e.startsWith(`\x1B[`)||e.startsWith(`\x1BO`))&&`ABCD`.includes(e[2])}var V=new Map,H=new Map,U=new Map,W=new Map,G=new Set,K=e=>(G.add(e),()=>{G.delete(e)}),q=()=>{for(let e of G)e()},J=(e,t)=>s(JSON.stringify([e,t]));function ge(e,t){return(0,I.useSyncExternalStore)(K,()=>V.has(J(e,t)))}function _e(e,t,n,r,i){let a=J(e,t);return V.set(a,n),r&&H.set(a,r),i?U.set(a,i):U.delete(a),q(),()=>{V.get(a)===n&&(V.delete(a),H.delete(a),U.delete(a),W.delete(a),q())}}function Y(e,t){H.get(J(e,t))?.()}function ve(e,t){return(0,I.useSyncExternalStore)(K,()=>W.get(J(e,t))??0)}function X(e,t,n){let r=J(e,t);W.set(r,(W.get(r)??0)^n),q()}function Z(e,t,n){let r=J(e,t),i=W.get(r)??0;return!i||!B(n)?n:(W.delete(r),q(),me(n,i))}async function ye(e,t,n,r=!1){let i=J(e,t),a=V.get(i);if(!a)throw Error(`Wait for the terminal to attach; nothing was sent`);let o=r?`${a(n)}\r`:Z(e,t,n);!r&&he(o)&&U.get(i)?.()&&(o=`\x1bO${o.slice(-1)}`),await Q(e,t,o)}async function be(e,t,n){let r=J(e,t),i=V.get(r),a=l(),o=a?.generation;if(!i||!n()||!y.isConnected())throw Error(`Wait for the terminal to attach; nothing was pasted.`);let s;try{let n=navigator.clipboard.readText();Y(e,t),s=await n}catch{throw Error(`Could not read the clipboard. Allow clipboard access or use your keyboard’s Paste action.`)}if(!n()||V.get(r)!==i||l()!==a||a?.generation!==o||!y.isConnected())throw Error(`The terminal changed; nothing was pasted. Try again in the active terminal.`);s&&await Q(e,t,i(s))}async function Q(e,t,n){let r=l();if(r)await r.input(e,t,n);else{if(!y.isConnected())throw Error(`Terminal is disconnected; nothing was sent`);y.write(e,t,n)}}var $=d();function xe({text:e,label:t,clear:n,paste:r}){let[i,a]=(0,I.useState)(!1);return(0,$.jsxs)(`div`,{role:`toolbar`,"aria-label":t,onPointerDown:e=>e.preventDefault(),className:`absolute right-2 top-2 z-20 flex gap-1 rounded-md bg-elevated p-1 shadow-lg`,children:[(0,$.jsxs)(g,{variant:`ghost`,size:`sm`,disabled:!e||i,onClick:async()=>{try{await navigator.clipboard.writeText(e),n()}catch{m.error(`Could not copy the selection. Try again.`)}},children:[(0,$.jsx)(v,{}),` Copy`]}),r&&(0,$.jsxs)(g,{variant:`ghost`,size:`sm`,disabled:i,onClick:async()=>{if(!i){a(!0);try{await r(),n()}catch(e){m.error(e instanceof Error?e.message:`Could not paste. Try again.`)}finally{a(!1)}}},children:[(0,$.jsx)(b,{}),` Paste`]}),(0,$.jsx)(g,{variant:`ghost`,size:`icon`,"aria-label":`Clear selection`,disabled:i,onClick:n,children:(0,$.jsx)(h,{})})]})}export{T as _,_e as a,x as b,ge as c,de as d,F as f,ne as g,k as h,be as i,ve as l,O as m,Z as n,ye as o,pe as p,Y as r,X as s,xe as t,L as u,w as v,ee as y};
@@ -1 +0,0 @@
1
- import{n as e,o as t,r as n}from"./auth-CIb9G2C5.js";import{n as r}from"./dist-BOS6OKSE.js";var i=500,a=1e4;function o(e,t){return`${e} ${t}`}var s=new class{ws=null;open=!1;backoff=i;reconnectTimer=null;theme=null;terminals=new Map;notificationListeners=new Set;statusListeners=new Set;renameListeners=new Set;accountListeners=new Set;switchListeners=new Set;sessionsChangedListeners=new Set;connectionListeners=new Set;shellWaiters=new Map;attach(e,t,n,r,i){let a={session:e,term:t,cols:n,rows:r,handlers:i};return this.terminals.set(o(e,t),a),this.ensureConnected(),this.open&&this.send({t:`attach`,session:e,term:t,cols:n,rows:r}),()=>this.detach(e,t)}detach(e,t){this.terminals.delete(o(e,t))&&this.open&&this.send({t:`detach`,session:e,term:t})}write(e,t,n){this.open&&this.send({t:`stdin`,session:e,term:t,data:n})}resize(e,t,n,r){let i=this.terminals.get(o(e,t));i&&(i.cols=n,i.rows=r),this.open&&this.send({t:`resize`,session:e,term:t,cols:n,rows:r})}spawnShell(e){return this.ensureConnected(),this.open?new Promise((t,n)=>{let r=this.shellWaiters.get(e)??[];r.push({resolve:t,reject:n}),this.shellWaiters.set(e,r),this.open&&this.send({t:`spawn-shell`,session:e})}):Promise.reject(Error(`Connection is unavailable`))}killShell(e,t){this.open&&this.send({t:`kill-shell`,session:e,term:t})}onStatus(e){return this.statusListeners.add(e),this.ensureConnected(),()=>this.statusListeners.delete(e)}onAgentNotification(e){return this.notificationListeners.add(e),this.ensureConnected(),()=>this.notificationListeners.delete(e)}onRenamed(e){return this.renameListeners.add(e),this.ensureConnected(),()=>this.renameListeners.delete(e)}onAccount(e){return this.accountListeners.add(e),this.ensureConnected(),()=>this.accountListeners.delete(e)}onSessionSwitched(e){return this.switchListeners.add(e),this.ensureConnected(),()=>this.switchListeners.delete(e)}onSessionsChanged(e){return this.sessionsChangedListeners.add(e),this.ensureConnected(),()=>this.sessionsChangedListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),()=>this.connectionListeners.delete(e)}isConnected(){return this.open}reportTheme(e,t){this.theme&&this.theme.fg===e&&this.theme.bg===t||(this.theme={fg:e,bg:t},this.open&&this.send({t:`theme`,fg:e,bg:t}))}reset(){this.ws?.close()}switchHost(){let e=this.ws;this.ws=null,this.open=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.terminals.clear();for(let e of this.shellWaiters.values())for(let t of e)t.reject(Error(`Host changed`));this.shellWaiters.clear(),e?.close();for(let e of this.connectionListeners)e(!1)}ensureConnected(){this.ws||this.reconnectTimer||this.connect()}connect(){let r=n.get(),a=t();if(!r&&!a)return;let o=window.location.protocol===`https:`?`wss`:`ws`,s=a?a.socket():new WebSocket(`${o}://${window.location.host}/ws`);this.ws=s,s.addEventListener(`open`,()=>{if(this.ws!==s){s.close();return}a||s.send(JSON.stringify({t:`auth`,token:r}))}),s.addEventListener(`message`,e=>{if(this.ws!==s)return;let t;try{t=JSON.parse(String(e.data))}catch{return}if(t.t===`authenticated`){if(this.open)return;this.open=!0,this.backoff=i,this.send({t:`subscribe-status`}),this.theme&&this.send({t:`theme`,...this.theme});for(let{session:e,term:t,cols:n,rows:r}of this.terminals.values())this.send({t:`attach`,session:e,term:t,cols:n,rows:r});for(let e of this.connectionListeners)e(!0)}else this.open&&this.handle(t)}),s.addEventListener(`close`,t=>{if(this.ws!==s)return;let n=this.open;this.open=!1,this.ws=null;for(let e of this.shellWaiters.values())for(let t of e)t.reject(Error(`Connection lost; operation outcome is unknown`));if(this.shellWaiters.clear(),n)for(let e of this.connectionListeners)e(!1);if(t.code===4401&&t.reason===`browser_rejected`){e();return}this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer||this.terminals.size===0&&this.statusListeners.size===0&&this.notificationListeners.size===0&&this.renameListeners.size===0&&this.accountListeners.size===0&&this.switchListeners.size===0&&this.sessionsChangedListeners.size===0||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.backoff),this.backoff=Math.min(this.backoff*2,a))}send(e){this.open&&this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}handle(e){switch(e.t){case`agent-notification`:for(let t of this.notificationListeners)t(e);break;case`replay`:case`output`:this.terminals.get(o(e.session,e.term))?.handlers.onData(e.data,e.t);break;case`exit`:this.terminals.get(o(e.session,e.term))?.handlers.onExit?.(e.code);break;case`status`:for(let t of this.statusListeners)t({session:e.session,status:e.status,last_activity_at:e.last_activity_at});break;case`renamed`:for(let t of this.renameListeners)t({session:e.session,title:e.title,agent_title:e.agent_title,osc_title:e.osc_title});break;case`account`:for(let t of this.accountListeners)t({account_id:e.account_id,profile_id:e.profile_id,logged_in:e.logged_in});break;case`session-switched`:for(let t of this.switchListeners)t(e);break;case`sessions-changed`:for(let t of this.sessionsChangedListeners)t(e);break;case`shell-spawned`:{let t=this.shellWaiters.get(e.session)?.shift();t&&t.resolve(e.term);break}case`notice`:(e.level===`warning`?r.warning:r.error)(e.title,{...e.detail===void 0?{}:{description:e.detail},duration:12e3});break;case`error`:r.error(`Connection error`,{description:e.message});break}}};export{s as t};