moi-computer 0.13.1-next.2 → 0.13.1-next.3

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 (54) hide show
  1. package/client/features/chat/sessions/use-selected-session.ts +0 -13
  2. package/client/features/views/api.ts +33 -8
  3. package/client/features/views/use-view-actions.ts +2 -23
  4. package/client/features/workspace/tab-resolution.ts +1 -8
  5. package/client/features/workspace/use-workspace-navigation.ts +4 -3
  6. package/client/features/workspace/workspace-content.tsx +2 -11
  7. package/client/features/workspace/workspace-preferences.ts +67 -10
  8. package/client/features/workspace/workspace-state.ts +40 -15
  9. package/client/store/ui.ts +1 -6
  10. package/client/store/workspace-session.ts +30 -0
  11. package/dist/chunk-0h4zypgf.js +1 -0
  12. package/dist/chunk-1tksq43z.js +72 -0
  13. package/dist/chunk-6gxf0xr8.js +5 -0
  14. package/dist/{chunk-ec5ennpv.js → chunk-a865c7x4.js} +1 -1
  15. package/dist/{chunk-pdt9hxfw.js → chunk-f44cs6mw.js} +2 -2
  16. package/dist/{chunk-44khk4sp.js → chunk-h3qag4a6.js} +2 -2
  17. package/dist/{chunk-ectsnw81.js → chunk-q2tpy0h7.js} +2 -2
  18. package/dist/{chunk-rmd0ctfx.js → chunk-r95acex1.js} +74 -74
  19. package/dist/chunk-w5h9grdr.js +1 -0
  20. package/dist/{chunk-n0fawy9x.js → chunk-xj1pjhng.js} +1 -1
  21. package/dist/index.html +1 -1
  22. package/lib/moi-context.ts +19 -5
  23. package/lib/types.ts +4 -5
  24. package/lib/workspace-layout.ts +3 -20
  25. package/package.json +2 -1
  26. package/server/AGENTS.md +1 -1
  27. package/server/README.md +21 -18
  28. package/server/api/index.ts +122 -118
  29. package/server/cli/commands/init.ts +7 -2
  30. package/server/cli/commands/remote.ts +128 -26
  31. package/server/cli/remote-control.ts +12 -9
  32. package/server/cli/remote-operations.ts +47 -44
  33. package/server/control.ts +9 -1
  34. package/server/onboarding/jobs.ts +1 -1
  35. package/server/remote/broker-client.ts +76 -0
  36. package/server/remote/broker.ts +81 -0
  37. package/server/remote/client.ts +212 -152
  38. package/server/remote/errors.ts +2 -0
  39. package/server/remote/routes.ts +121 -0
  40. package/server/scratchpad/document.ts +3 -2
  41. package/server/sessions/pending-views.ts +2 -1
  42. package/server/sessions/send-message.ts +102 -0
  43. package/server/sessions/view-sessions.ts +4 -94
  44. package/server/web.ts +2 -1
  45. package/server/workspace-state/file.ts +2 -0
  46. package/server/workspaces/api.ts +4 -8
  47. package/server/workspaces/tabs.ts +1 -2
  48. package/skill/SKILL.md +75 -34
  49. package/skill/references/SCRATCHPAD.md +4 -0
  50. package/skill/references/UI-COMPONENTS.md +1 -1
  51. package/dist/chunk-ba6mz56s.js +0 -72
  52. package/dist/chunk-en7w5ypg.js +0 -1
  53. package/dist/chunk-f695wcx5.js +0 -5
  54. package/dist/chunk-zv22wv0g.js +0 -1
@@ -1 +1 @@
1
- import{on}from"/chunk-44khk4sp.js";import{h}from"/chunk-pdt9hxfw.js";async function r(){try{let e=await h("/api/proxy-user");if(!e||typeof e!=="object"||Array.isArray(e)||e.provider!==void 0&&e.provider!=="cloudflare-access"||e.provider===void 0&&e.profile!==void 0)return;return on(e),e}catch{}}async function n(){return r()}export{n as loadProxyUser};
1
+ import{on}from"/chunk-h3qag4a6.js";import{h}from"/chunk-f44cs6mw.js";async function r(){try{let e=await h("/api/proxy-user");if(!e||typeof e!=="object"||Array.isArray(e)||e.provider!==void 0&&e.provider!=="cloudflare-access"||e.provider===void 0&&e.profile!==void 0)return;return on(e),e}catch{}}async function n(){return r()}export{n as loadProxyUser};
@@ -1,2 +1,2 @@
1
- class Ao extends Error{status;constructor(e,t){super(t);this.status=e;this.name="HttpError"}}async function o(e,t){let s=await e.text();return new Ao(e.status,s||t)}async function h(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s);return n.json()}async function me(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s)}function P(e,t){return{method:e,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}
2
- export{Ao,h,me,P};
1
+ class Ao extends Error{status;constructor(e,t){super(t);this.status=e;this.name="HttpError"}}async function o(e,t){let s=await e.text();return new Ao(e.status,s||t)}async function h(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s);return n.json()}async function he(e,t,s="Request failed"){let n=await fetch(e,t);if(!n.ok)throw await o(n,s)}function S(e,t){return{method:e,headers:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)}}
2
+ export{Ao,h,he,S};
@@ -1,2 +1,2 @@
1
- var lt=Object.create;var{getPrototypeOf:dt,defineProperty:rr,getOwnPropertyNames:pt}=Object;var fr=Object.prototype.hasOwnProperty;function ht(r){return this[r]}var gt,ut,e=(r,t,a)=>{var o=r!=null&&typeof r==="object";if(o){var i=t?gt??=new WeakMap:ut??=new WeakMap,c=i.get(r);if(c)return c}a=r!=null?lt(dt(r)):{};let d=t||!r||!r.__esModule||!fr.call(r,"default")?rr(a,"default",{value:r,enumerable:!0}):a;if(r&&typeof r==="object"||typeof r==="function"){for(let n of pt(r))if(!fr.call(d,n))rr(d,n,{get:ht.bind(r,n),enumerable:!0})}if(o)i.set(r,d);return d};var I=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var mt=(r)=>r;function ft(r,t){this[r]=mt.bind(null,t)}var Ft=(r,t)=>{for(var a in t)rr(r,a,{get:t[a],enumerable:!0,configurable:!0,set:ft.bind(t,a)})};var tn=((r)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var xr,tr,F,Fe=(r,t)=>{for(var[a,o,i]of xr||[])for(var c=[r],d=globalThis,n=d.document,s,p,g,h,u;p=c.pop();)if(!tr[p]&&(g=o[p])){tr[p]=1;for(h=1;h<g.length;h++)c.push(i[g[h]]);if(!t&&p!==r&&(s=n&&n.head)){if(F===void 0)F=(h=n.querySelector("meta[property=csp-nonce]"))&&(h.nonce||h.getAttribute("nonce"))||"";if(u=n.createElement("link"),u.rel="modulepreload",u.crossOrigin="",F)u.nonce=F;u.href=new d.URL(g[0],a),s.appendChild(u)}}},xt=(r,t,a,o)=>{for(var i={},c=0;c<t.length;c++)i[t[c]]=a[c];(xr||=[]).push([r,i,t]),tr||={},Fe(t[o],1)};xt(import.meta.url,["44khk4sp","ba6mz56s","en7w5ypg","ec5ennpv","nf2wkvf9","rmd0ctfx","f695wcx5","ectsnw81","pdt9hxfw","zv22wv0g","n0fawy9x"],[["/chunk-44khk4sp.js"],["/chunk-ba6mz56s.js",6,0,7,8],["/chunk-en7w5ypg.js",7],["/chunk-ec5ennpv.js",0,8],["/chunk-nf2wkvf9.js"],["/chunk-rmd0ctfx.js",6,7,0,10,8],["/chunk-f695wcx5.js",0,7,8],["/chunk-ectsnw81.js",0,8],["/chunk-pdt9hxfw.js"],["/chunk-zv22wv0g.js",10],["/chunk-n0fawy9x.js"]],0);
2
- if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);var A=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function Q(r){return typeof r==="string"&&A.includes(r)}function Jr(r){let t=2166136261;for(let a=0;a<r.length;a++)t^=r.charCodeAt(a),t=Math.imul(t,16777619);return A[(t>>>0)%A.length]??A[0]}var rn=1;var yt=8192,kt=320;function Be(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)}function L(r,t=256){return typeof r==="string"&&r.length>0&&!r.includes("\x00")&&new TextEncoder().encode(r).length<=t}function yr(r){return Be(r)&&L(r.id,240)&&r.id.trim().length>0&&(r.name===void 0||L(r.name)&&r.name.trim().length>0)&&Q(r.color)&&(r.avatar===void 0||L(r.avatar,yt))&&(r.email===void 0||L(r.email,kt))}function N(r,t){return typeof r==="string"&&r.length<=t&&!r.includes("\x00")}function zt(r){if(!N(r,2048))return!1;try{return["http:","https:"].includes(new URL(r).protocol)}catch{return!1}}function nt(r){if(!Be(r)||!N(r.id,240)||!r.id.trim()||r.id!==r.id.trim()||!N(r.name,256)||r.avatar!==void 0&&!zt(r.avatar))throw Error("Invalid identity");let t={id:r.id,name:r.name,...r.avatar!==void 0?{avatar:r.avatar}:{}};if(r.type==="agent")return{...t,type:"agent"};if(r.type==="user"&&N(r.email,320)&&typeof r.isAnonymous==="boolean")return{...t,type:"user",email:r.email,isAnonymous:r.isAnonymous};throw Error("Invalid identity")}var ze=(r)=>`${r.type}:${r.id}`,bt=(r)=>r.type==="agent"?`agent:${r.id}`:r.id;var W,kr=0,zr=0,ar=new Set,Te=()=>W,br=()=>zr,ce=()=>kr;function Qr(r){return ar.add(r),()=>{ar.delete(r)}}function vt(r){let t=r===null?null:nt(r);if((W&&ze(W))!==(t&&ze(t)))kr++;zr++,W=t,ar.forEach((o)=>o())}var _t=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function _r(r,t){let a=r.filter((o)=>o!==t);return a[Math.floor(Math.random()*a.length)]??r[0]}function Ct(r){return{name:_r(_t,r?.name),color:_r(A,r?.color)}}function Et(r,t){let a=t.name.trim();return{id:r,...a?{name:a}:{},color:t.color}}function Cr(){return Et(`local-${crypto.randomUUID().slice(0,8)}`,Ct())}var ir="moi:local-profile",_,E,D=new Set;function nr(r,t){return JSON.stringify(r)===JSON.stringify(t)}function P(r){if(!r||typeof r.id!=="string"||!r.id.trim())throw Error("A user profile needs an id.");if(r.name!==void 0&&typeof r.name!=="string")throw Error("A user profile name must be a string when provided.");if(r.color!==void 0&&!Q(r.color))throw Error("A user profile color must be one of the user palette names.");let t=r.id.trim(),a=r.name?.trim(),o={id:t,...a?{name:a}:{},color:r.color??Jr(t),...r.avatar!==void 0?{avatar:r.avatar}:{},...r.email!==void 0?{email:r.email}:{}};if(!yr(o))throw Error("Invalid user profile.");return Object.freeze(o)}var or,Er;function pe(){let r=Te();if(r===void 0)return _;if(r!==Er){Er=r;let t=!r||r.type==="user"&&r.isAnonymous?void 0:P({id:bt(r),name:r.name||void 0,avatar:r.avatar,email:r.type==="user"?r.email||void 0:void 0});if(!nr(or,t))or=t}return or}function wt(r){let t=pe(),a=ve(),o=()=>{let c=pe(),d=ve();if(t===c&&a===d)return;t=c,a=d,r()};D.add(o);let i=Qr(o);return()=>{D.delete(o),i()}}function ve(){return Te()!==void 0?"external":E}function on({provider:r,profile:t}){if(ve()==="external")return;if(r===void 0){if(E===void 0||E==="local")return;E=void 0,_=void 0}else{let a=t===void 0?void 0:P(t);if(E===r&&nr(_,a))return;E=r,_=a}D.forEach((a)=>a())}function At(){try{localStorage.setItem(ir,JSON.stringify(_))}catch{}}function eo(r){if(ve()!==void 0&&ve()!=="local")return;let t=P(r);E="local",_=t,At(),D.forEach((a)=>a())}function Ar(r,t){if(!r||!t||t.provider!==void 0||ve()!==void 0)return;try{let a=localStorage.getItem(ir);if(a){eo(JSON.parse(a));return}}catch{}eo(Cr())}function Sr(r){if(r.key!==ir||!r.newValue||ve()!=="local")return;try{let t=P(JSON.parse(r.newValue));if(nr(t,_))return;_=t,D.forEach((a)=>a())}catch{}}function Pr(){return window.addEventListener("storage",Sr),()=>window.removeEventListener("storage",Sr)}var Pt={setTimeout:(r,t)=>setTimeout(r,t),clearTimeout:(r)=>clearTimeout(r),setInterval:(r,t)=>setInterval(r,t),clearInterval:(r)=>clearInterval(r)},jt=class{#r=Pt;#t=!1;setTimeoutProvider(r){this.#r=r}setTimeout(r,t){return this.#r.setTimeout(r,t)}clearTimeout(r){this.#r.clearTimeout(r)}setInterval(r,t){return this.#r.setInterval(r,t)}clearInterval(r){this.#r.clearInterval(r)}},He=new jt;function jr(r){setTimeout(r,0)}var cr=typeof window>"u"||"Deno"in globalThis;function H(){}function Ir(r,t){return typeof r==="function"?r(t):r}function to(r){return typeof r==="number"&&r>=0&&r!==1/0}function ro(r,t){return Math.max(r+(t||0)-Date.now(),0)}function U(r,t){return typeof r==="function"?r(t):r}function Zt(r,t){let{type:a="all",exact:o,fetchStatus:i,predicate:c,queryKey:d,stale:n}=r;if(d){if(o){if(t.queryHash!==R(d,t.options))return!1}else if(!C(t.queryKey,d))return!1}if(a!=="all"){let s=t.isActive();if(a==="active"&&!s)return!1;if(a==="inactive"&&s)return!1}if(typeof n==="boolean"&&t.isStale()!==n)return!1;if(i&&i!==t.state.fetchStatus)return!1;if(c&&!c(t))return!1;return!0}function B(r,t){let{exact:a,status:o,predicate:i,mutationKey:c}=r;if(c){if(!t.options.mutationKey)return!1;if(a){if(Ue(t.options.mutationKey)!==Ue(c))return!1}else if(!C(t.options.mutationKey,c))return!1}if(o&&t.state.status!==o)return!1;if(i&&!i(t))return!1;return!0}function R(r,t){return(t?.queryKeyHashFn||Ue)(r)}function Ue(r){return JSON.stringify(r,(t,a)=>sr(a)?Object.keys(a).sort().reduce((o,i)=>(o[i]=a[i],o),{}):a)}function C(r,t){if(r===t)return!0;if(typeof r!==typeof t)return!1;if(r&&t&&typeof r==="object"&&typeof t==="object"){if(Array.isArray(r)&&Array.isArray(t)){for(let o=0;o<t.length;o++)if(!C(r[o],t[o]))return!1;return!0}let a=Object.keys(t);for(let o of a)if(!C(r[o],t[o]))return!1;return!0}return!1}var Mt=Object.prototype.hasOwnProperty;function We(r,t,a=0){if(r===t)return r;if(a>500)return t;let o=Mr(r)&&Mr(t);if(!o&&!(sr(r)&&sr(t)))return t;let i=(o?r:Object.keys(r)).length,c=o?t:Object.keys(t),d=c.length,n=o?Array(d):{},s=0;for(let p=0;p<d;p++){let g=o?p:c[p],h=r[g],u=t[g];if(h===u){if(n[g]=h,o?p<i:Mt.call(r,g))s++;continue}if(h===null||u===null||typeof h!=="object"||typeof u!=="object"){n[g]=u;continue}let y=We(h,u,a+1);if(n[g]=y,y===h)s++}return i===d&&s===i?r:n}function St(r,t){if(!t||Object.keys(r).length!==Object.keys(t).length)return!1;for(let a in r)if(r[a]!==t[a])return!1;return!0}function Mr(r){return Array.isArray(r)&&r.length===Object.keys(r).length}function sr(r){if(!Or(r))return!1;let t=r.constructor;if(t===void 0)return!0;let a=t.prototype;if(!Or(a))return!1;if(!a.hasOwnProperty("isPrototypeOf"))return!1;if(Object.getPrototypeOf(r)!==Object.prototype)return!1;return!0}function Or(r){return Object.prototype.toString.call(r)==="[object Object]"}function qr(r){return new Promise((t)=>{He.setTimeout(t,r)})}function vr(r,t,a){if(typeof a.structuralSharing==="function")return a.structuralSharing(r,t);else if(a.structuralSharing!==!1)return We(r,t);return t}function Dr(r,t,a=0){let o=[...r,t];return a&&o.length>a?o.slice(1):o}function Ur(r,t,a=0){let o=[t,...r];return a&&o.length>a?o.slice(0,-1):o}var j=Symbol();function K(r,t){if(!r.queryFn&&t?.initialPromise)return()=>t.initialPromise;if(!r.queryFn||r.queryFn===j)return()=>Promise.reject(Error(`Missing queryFn: '${r.queryHash}'`));return r.queryFn}function Jt(r,t){if(typeof r==="function")return r(...t);return!!r}function Rr(r,t,a){let o=!1,i;return Object.defineProperty(r,"signal",{enumerable:!0,get:()=>{if(i??=t(),o)return i;if(o=!0,i.aborted)a();else i.addEventListener("abort",a,{once:!0});return i}}),r}var Ot=()=>cr,Qt=()=>Ot();var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(r){return this.listeners.add(r),this.onSubscribe(),()=>{this.listeners.delete(r),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var It=class extends ge{#r;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r((t)=>{if(typeof t==="boolean")this.setFocused(t);else this.onFocus()})}setFocused(r){if(this.#r!==r)this.#r=r,this.onFocus()}onFocus(){let r=this.isFocused();this.listeners.forEach((t)=>{t(r)})}isFocused(){if(typeof this.#r==="boolean")return this.#r;return globalThis.document?.visibilityState!=="hidden"}},er=new It;var Tr=jr;function qt(){let r=[],t=0,a=(n)=>{n()},o=(n)=>{n()},i=Tr,c=(n)=>{if(t)r.push(n);else i(()=>{a(n)})},d=()=>{let n=r;if(r=[],n.length)i(()=>{o(()=>{n.forEach((s)=>{a(s)})})})};return{batch:(n)=>{let s;t++;try{s=n()}finally{if(t--,!t)d()}return s},batchCalls:(n)=>(...s)=>{c(()=>{n(...s)})},schedule:c,setNotifyFunction:(n)=>{a=n},setBatchNotifyFunction:(n)=>{o=n},setScheduler:(n)=>{i=n}}}var M=qt();var Dt=class extends ge{#r=!0;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r(!0),a=()=>r(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",a)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r(this.setOnline.bind(this))}setOnline(r){if(this.#r!==r)this.#r=r,this.listeners.forEach((t)=>{t(r)})}isOnline(){return this.#r}},O=new Dt;function Ut(r){return Math.min(1000*2**r,30000)}function lr(r){return(r??"online")==="online"?O.isOnline():!0}var V=class extends Error{constructor(r){super("CancelledError");this.revert=r?.revert,this.silent=r?.silent}};function Y(r){let t=!1,a=0,o,i="pending",c,d,n=new Promise((v,f)=>{c=v,d=f});n.catch(H);let s=()=>i!=="pending",p=(v)=>{if(!s()){let f=new V(v);m(f),r.onCancel?.(f)}},g=()=>{t=!0},h=()=>{t=!1},u=()=>er.isFocused()&&(r.networkMode==="always"||O.isOnline())&&r.canRun(),y=()=>lr(r.networkMode)&&r.canRun(),w=(v)=>{if(!s())o?.(),i="resolved",c(v)},m=(v)=>{if(!s())o?.(),i="rejected",d(v)},k=()=>new Promise((v)=>{o=(f)=>{if(s()||u())v(f)},r.onPause?.()}).then(()=>{if(o=void 0,!s())r.onContinue?.()}),T=()=>{if(s())return;let v,f=a===0?r.initialPromise:void 0;try{v=f??r.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(w).catch((b)=>{if(s())return;let z=r.retry??(Qt()?0:3),S=r.retryDelay??Ut,st=typeof S==="function"?S(a,b):S,ct=z===!0||typeof z==="number"&&a<z||typeof z==="function"&&z(a,b);if(t||!ct){m(b);return}a++,r.onFail?.(a,b),qr(st).then(()=>u()?void 0:k()).then(()=>{if(t)m(b);else T()})})};return{promise:n,status:()=>i,cancel:p,continue:()=>(o?.(),n),cancelRetry:g,continueRetry:h,canStart:y,start:()=>{if(y())T();else k().then(T);return n}}}var X=class{#r;destroy(){this.clearGcTimeout()}scheduleGc(){if(this.clearGcTimeout(),to(this.gcTime))this.#r=He.setTimeout(()=>{this.optionalRemove()},this.gcTime)}updateGcTime(r){this.gcTime=Math.max(this.gcTime||0,r??(Qt()?1/0:300000))}clearGcTimeout(){if(this.#r!==void 0)He.clearTimeout(this.#r),this.#r=void 0}};function Lr(r){return{onFetch:(t,a)=>{let o=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,c=t.state.data?.pages||[],d=t.state.data?.pageParams||[],n={pages:[],pageParams:[]},s=0,p=async()=>{let g=!1,h=(w)=>{Rr(w,()=>t.signal,()=>g=!0)},u=K(t.options,t.fetchOptions),y=async(w,m,k)=>{if(g)return Promise.reject(t.signal.reason);if(m==null&&w.pages.length)return Promise.resolve(w);let v=(()=>{let S={client:t.client,queryKey:t.queryKey,pageParam:m,direction:k?"backward":"forward",meta:t.options.meta};return h(S),S})(),f=await u(v),{maxPages:b}=t.options,z=k?Ur:Dr;return{pages:z(w.pages,f,b),pageParams:z(w.pageParams,m,b)}};if(i&&c.length){let w=i==="backward",m=w?Rt:Fr,k={pages:c,pageParams:d};n=await y(k,m(o,k),w)}else{let w=r??c.length;do{let m=s===0?d[0]??o.initialPageParam:Fr(o,n);if(s>0&&m==null)break;n=await y(n,m),s++}while(s<w)}return n};if(t.options.persister)t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},a);else t.fetchFn=p}}}function Fr(r,{pages:t,pageParams:a}){let o=t.length-1;return t.length>0?r.getNextPageParam(t[o],t,a[o],a):void 0}function Rt(r,{pages:t,pageParams:a}){return t.length>0?r.getPreviousPageParam?.(t[0],t,a[0],a):void 0}var Br=class extends X{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r){super();this.#n=!1,this.#c=r.defaultOptions,this.setOptions(r.options),this.observers=[],this.#i=r.client,this.#o=this.#i.getQueryCache(),this.queryKey=r.queryKey,this.queryHash=r.queryHash,this.#t=Wr(this.options),this.state=r.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#r}get promise(){return this.#e?.promise}setOptions(r){if(this.options={...this.#c,...r},r?._type)this.#r=r._type;if(this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=Wr(this.options);if(t.data!==void 0)this.setState(Nr(t.data,t.dataUpdatedAt)),this.#t=t}}optionalRemove(){if(!this.observers.length&&this.state.fetchStatus==="idle")this.#o.remove(this)}setData(r,t){let a=vr(this.state.data,r,this.options);return this.#s({data:a,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),a}setState(r){this.#s({type:"setState",state:r})}cancel(r){let t=this.#e?.promise;return this.#e?.cancel(r),t?t.then(H).catch(H):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((r)=>U(r.options.enabled,this)!==!1)}isDisabled(){if(this.getObserversCount()>0)return!this.isActive();return this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){if(this.getObserversCount()>0)return this.observers.some((r)=>U(r.options.staleTime,this)==="static");return!1}isStale(){if(this.getObserversCount()>0)return this.observers.some((r)=>r.getCurrentResult().isStale);return this.state.data===void 0||this.state.isInvalidated}isStaleByTime(r=0){if(this.state.data===void 0)return!0;if(r==="static")return!1;if(this.state.isInvalidated)return!0;return!ro(this.state.dataUpdatedAt,r)}onFocus(){this.observers.find((r)=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#e?.continue()}onOnline(){this.observers.find((r)=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#e?.continue()}addObserver(r){if(!this.observers.includes(r))this.observers.push(r),this.clearGcTimeout(),this.#o.notify({type:"observerAdded",query:this,observer:r})}removeObserver(r){let t=this.observers.indexOf(r);if(t!==-1){if(this.observers.splice(t,1),!this.observers.length){if(this.#e)if(this.#n||this.state.fetchStatus==="paused"&&this.state.status==="pending")this.#e.cancel({revert:!0});else this.#e.cancelRetry();this.scheduleGc()}this.#o.notify({type:"observerRemoved",query:this,observer:r})}}getObserversCount(){return this.observers.length}invalidate(){if(!this.state.isInvalidated)this.#s({type:"invalidate"})}async fetch(r,t){if(this.state.fetchStatus!=="idle"&&this.#e?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#e)return this.#e.continueRetry(),this.#e.promise}if(r)this.setOptions(r);if(!this.options.queryFn){let s=this.observers.find((p)=>p.options.queryFn);if(s)this.setOptions(s.options)}let a=new AbortController,o=(s)=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#n=!0,a.signal)})},i=()=>{let s=K(this.options,t),g=(()=>{let h={client:this.#i,queryKey:this.queryKey,meta:this.meta};return o(h),h})();if(this.#n=!1,this.options.persister)return this.options.persister(s,g,this);return s(g)},d=(()=>{let s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return o(s),s})();if((this.#r==="infinite"?Lr(this.options.pages):this.options.behavior)?.onFetch(d,this),this.#a=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==d.fetchOptions?.meta)this.#s({type:"fetch",meta:d.fetchOptions?.meta});let n=this.#e=Y({initialPromise:t?.initialPromise,fn:d.fetchFn,onCancel:(s)=>{if(s instanceof V&&s.revert)this.setState({...this.#a,fetchStatus:"idle"});a.abort()},onFail:(s,p)=>{this.#s({type:"failed",failureCount:s,error:p})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0});try{let s=await n.start();if(s===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#o.config.onSuccess?.(s,this),this.#o.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof V){if(s.silent)return this.#e.promise;else if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#s({type:"error",error:s}),this.#o.config.onError?.(s,this),this.#o.config.onSettled?.(this.state.data,s,this),s}finally{if(this.#e===n)this.#e=void 0;this.scheduleGc()}}#s(r){let t=(a)=>{switch(r.type){case"failed":return{...a,fetchFailureCount:r.failureCount,fetchFailureReason:r.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,..._o(a.data,this.options),fetchMeta:r.meta??null};case"success":let o={...a,...Nr(r.data,r.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!r.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#a=r.manual?o:void 0,o;case"error":let i=r.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...r.state}}};this.state=t(this.state),M.batch(()=>{this.observers.slice().forEach((a)=>{a.onQueryUpdate()}),this.#o.notify({query:this,type:"updated",action:r})})}};function _o(r,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:lr(t.networkMode)?"fetching":"paused",...r===void 0&&{error:null,status:"pending"}}}function Nr(r,t){return{data:r,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Wr(r){let t=typeof r.initialData==="function"?r.initialData():r.initialData,a=t!==void 0,o=a?typeof r.initialDataUpdatedAt==="function"?r.initialDataUpdatedAt():r.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:a?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var Hr=class extends X{#r;#t;#a;#o;constructor(r){super();this.#r=r.client,this.mutationId=r.mutationId,this.#a=r.mutationCache,this.#t=[],this.state=r.state||Mo(),this.setOptions(r.options),this.scheduleGc()}setOptions(r){this.options=r,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(r){if(!this.#t.includes(r))this.#t.push(r),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",mutation:this,observer:r})}removeObserver(r){this.#t=this.#t.filter((t)=>t!==r),this.scheduleGc(),this.#a.notify({type:"observerRemoved",mutation:this,observer:r})}optionalRemove(){if(!this.#t.length)if(this.state.status==="pending")this.scheduleGc();else this.#a.remove(this)}continue(){return this.#o?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(r){let t=()=>{this.#i({type:"continue"})},a={client:this.#r,meta:this.options.meta,mutationKey:this.options.mutationKey},o=this.#o=Y({fn:()=>{if(!this.options.mutationFn)return Promise.reject(Error("No mutationFn found"));return this.options.mutationFn(r,a)},onFail:(d,n)=>{this.#i({type:"failed",failureCount:d,error:n})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#a.canRun(this)}),i=this.state.status==="pending",c=!o.canStart();try{if(i)t();else{if(this.#i({type:"pending",variables:r,isPaused:c}),this.#a.config.onMutate)await this.#a.config.onMutate(r,this,a);let n=await this.options.onMutate?.(r,a);if(n!==this.state.context)this.#i({type:"pending",context:n,variables:r,isPaused:c})}let d=await o.start();return await this.#a.config.onSuccess?.(d,r,this.state.context,this,a),await this.options.onSuccess?.(d,r,this.state.context,a),await this.#a.config.onSettled?.(d,null,this.state.variables,this.state.context,this,a),await this.options.onSettled?.(d,null,r,this.state.context,a),this.#i({type:"success",data:d}),d}catch(d){try{await this.#a.config.onError?.(d,r,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onError?.(d,r,this.state.context,a)}catch(n){Promise.reject(n)}try{await this.#a.config.onSettled?.(void 0,d,this.state.variables,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onSettled?.(void 0,d,r,this.state.context,a)}catch(n){Promise.reject(n)}throw this.#i({type:"error",error:d}),d}finally{if(this.#o===o)this.#o=void 0;this.#a.runNext(this)}}#i(r){let t=(a)=>{switch(r.type){case"failed":return{...a,failureCount:r.failureCount,failureReason:r.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:r.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:r.isPaused,status:"pending",variables:r.variables,submittedAt:Date.now()};case"success":return{...a,data:r.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:r.error,failureCount:a.failureCount+1,failureReason:r.error,isPaused:!1,status:"error"}}};this.state=t(this.state),M.batch(()=>{this.#t.forEach((a)=>{a.onMutationUpdate(r)}),this.#a.notify({mutation:this,type:"updated",action:r})})}};function Mo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Kr=class extends ge{#r;#t;#a;constructor(r={}){super();this.config=r,this.#r=new Set,this.#t=new Map,this.#a=0}build(r,t,a){let o=new Hr({client:r,mutationCache:this,mutationId:++this.#a,options:r.defaultMutationOptions(t),state:a});return this.add(o),o}add(r){this.#r.add(r);let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a)a.push(r);else this.#t.set(t,[r])}this.notify({type:"added",mutation:r})}remove(r){if(this.#r.delete(r)){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a){if(a.length>1){let o=a.indexOf(r);if(o!==-1)a.splice(o,1)}else if(a[0]===r)this.#t.delete(t)}}}this.notify({type:"removed",mutation:r})}canRun(r){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t)?.find((o)=>o.state.status==="pending");return!a||a===r}else return!0}runNext(r){let t=J(r);if(typeof t==="string")return this.#t.get(t)?.find((a)=>a!==r&&a.state.isPaused)?.continue()??Promise.resolve();else return Promise.resolve()}clear(){M.batch(()=>{this.#r.forEach((r)=>{this.notify({type:"removed",mutation:r})}),this.#r.clear(),this.#t.clear()})}getAll(){return Array.from(this.#r)}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>B(t,a))}findAll(r={}){return this.getAll().filter((t)=>B(r,t))}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}resumePausedMutations(){let r=this.getAll().filter((t)=>t.state.isPaused);return M.batch(()=>Promise.all(r.map((t)=>t.continue().catch(H))))}};function J(r){return r.options.scope?.id}var Vr=class extends ge{#r;constructor(r={}){super();this.config=r,this.#r=new Map}build(r,t,a){let o=t.queryKey,i=t.queryHash??R(o,t),c=this.get(i);if(!c)c=new Br({client:r,queryKey:o,queryHash:i,options:r.defaultQueryOptions(t),state:a,defaultOptions:r.getQueryDefaults(o)}),this.add(c);return c}add(r){if(!this.#r.has(r.queryHash))this.#r.set(r.queryHash,r),this.notify({type:"added",query:r})}remove(r){let t=this.#r.get(r.queryHash);if(t){if(r.destroy(),t===r)this.#r.delete(r.queryHash);this.notify({type:"removed",query:r})}}clear(){M.batch(()=>{this.getAll().forEach((r)=>{this.remove(r)})})}get(r){return this.#r.get(r)}getAll(){return[...this.#r.values()]}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>Zt(t,a))}findAll(r={}){let t=this.getAll();return Object.keys(r).length>0?t.filter((a)=>Zt(r,a)):t}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}onFocus(){M.batch(()=>{this.getAll().forEach((r)=>{r.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach((r)=>{r.onOnline()})})}};var dr=class{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r={}){this.#r=r.queryCache||new Vr,this.#t=r.mutationCache||new Kr,this.#a=r.defaultOptions||{},this.#o=new Map,this.#i=new Map,this.#e=0}mount(){if(this.#e++,this.#e!==1)return;this.#c=er.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onFocus()}),this.#n=O.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onOnline()})}unmount(){if(this.#e--,this.#e!==0)return;this.#c?.(),this.#c=void 0,this.#n?.(),this.#n=void 0}isFetching(r){return this.#r.findAll({...r,fetchStatus:"fetching"}).length}isMutating(r){return this.#t.findAll({...r,status:"pending"}).length}getQueryData(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state.data}ensureQueryData(r){let t=this.defaultQueryOptions(r),a=this.#r.build(this,t),o=a.state.data;if(o===void 0)return this.fetchQuery(r);if(r.revalidateIfStale&&a.isStaleByTime(U(t.staleTime,a)))this.prefetchQuery(t);return Promise.resolve(o)}getQueriesData(r){return this.#r.findAll(r).map(({queryKey:t,state:a})=>[t,a.data])}setQueryData(r,t,a){let o=this.defaultQueryOptions({queryKey:r}),i=this.#r.get(o.queryHash)?.state.data,c=Ir(t,i);if(c===void 0)return;return this.#r.build(this,o).setData(c,{...a,manual:!0})}setQueriesData(r,t,a){return M.batch(()=>this.#r.findAll(r).map(({queryKey:o})=>[o,this.setQueryData(o,t,a)]))}getQueryState(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state}removeQueries(r){let t=this.#r;M.batch(()=>{t.findAll(r).forEach((a)=>{t.remove(a)})})}resetQueries(r,t){let a=this.#r;return M.batch(()=>{let o=a.findAll(r),i=new Set(o);return o.forEach((c)=>{c.reset()}),this.refetchQueries({type:"active",predicate:(c)=>i.has(c)},t)})}cancelQueries(r,t={}){let a={revert:!0,...t},o=M.batch(()=>this.#r.findAll(r).map((i)=>i.cancel(a)));return Promise.all(o).then(H).catch(H)}invalidateQueries(r,t={}){return M.batch(()=>{if(this.#r.findAll(r).forEach((a)=>{a.invalidate()}),r?.refetchType==="none")return Promise.resolve();return this.refetchQueries({...r,type:r?.refetchType??r?.type??"active"},t)})}refetchQueries(r,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0},o=M.batch(()=>this.#r.findAll(r).filter((i)=>!i.isDisabled()&&!i.isStatic()).map((i)=>{let c=i.fetch(void 0,a);if(!a.throwOnError)c=c.catch(H);return i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(o).then(H)}async query(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t),o=a.isStaleByTime(U(t.staleTime,a))?await a.fetch(t):a.state.data,i=t.select;if(i)return i(o);return o}fetchQuery(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t);return a.isStaleByTime(U(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(r){return this.fetchQuery(r).then(H).catch(H)}infiniteQuery(r){return r._type="infinite",this.query(r)}fetchInfiniteQuery(r){return r._type="infinite",this.fetchQuery(r)}prefetchInfiniteQuery(r){return this.fetchInfiniteQuery(r).then(H).catch(H)}ensureInfiniteQueryData(r){return r._type="infinite",this.ensureQueryData(r)}resumePausedMutations(){if(O.isOnline())return this.#t.resumePausedMutations();return Promise.resolve()}getQueryCache(){return this.#r}getMutationCache(){return this.#t}getDefaultOptions(){return this.#a}setDefaultOptions(r){this.#a=r}setQueryDefaults(r,t){this.#o.set(Ue(r),{queryKey:r,defaultOptions:t})}getQueryDefaults(r){let t=[...this.#o.values()],a={};return t.forEach((o)=>{if(C(r,o.queryKey))Object.assign(a,o.defaultOptions)}),a}setMutationDefaults(r,t){this.#i.set(Ue(r),{mutationKey:r,defaultOptions:t})}getMutationDefaults(r){let t=[...this.#i.values()],a={};return t.forEach((o)=>{if(C(r,o.mutationKey))Object.assign(a,o.defaultOptions)}),a}defaultQueryOptions(r){if(r._defaulted)return r;let t={...this.#a.queries,...this.getQueryDefaults(r.queryKey),...r,_defaulted:!0};if(!t.queryHash)t.queryHash=R(t.queryKey,t);if(t.refetchOnReconnect===void 0)t.refetchOnReconnect=t.networkMode!=="always";if(t.throwOnError===void 0)t.throwOnError=!!t.suspense;if(!t.networkMode&&t.persister)t.networkMode="offlineFirst";if(t.queryFn===j)t.enabled=!1;return t}defaultMutationOptions(r){if(r?._defaulted)return r;return{...this.#a.mutations,...r?.mutationKey&&this.getMutationDefaults(r.mutationKey),...r,_defaulted:!0}}clear(){this.#r.clear(),this.#t.clear()}};var it=new dr;var l={all:["workspaces"],discover:["workspaces","discover"],previews:["workspaces","previews"],layout:(r)=>["workspaces","layout",r],widgets:(r)=>["workspaces","widgets",r],appletThumbnails:(r)=>["workspaces","applet-thumbnails",r],views:(r)=>["workspaces","views",r],sessions:(r)=>["workspaces","sessions",r],events:(r,t)=>["workspaces","events",r,t],state:(r)=>["workspaces","state",r],mcp:(r)=>["workspaces","mcp",r],harness:(r)=>["workspaces","harness",r],skills:(r)=>["workspaces","skills",r],env:(r)=>["workspaces","env",r]};var pr=(r,t)=>t.getQueryData(l.layout(r));function Bt(r,t=it){return pr(r,t)?.isRemote??!1}function ie(r,t=it){let a=pr(r,t)?.apiBase;if(!a)throw Error("Workspace identity is not loaded");return a}function hr(r,t=it){let a=pr(r,t)?.apiBase;return a?decodeURIComponent(a.slice(16)):r}function gr(r){if(!Be(r)||!Array.isArray(r.members)||!Array.isArray(r.invitations))throw Error("Invalid workspace members");let t=r.members.map((o)=>{let i=nt(o);if(Be(o)&&o.membershipId!==void 0){if(typeof o.membershipId!=="string"||!o.membershipId||o.membershipId.length>240)throw Error("Invalid membership id");return{...i,membershipId:o.membershipId}}return i}),a=r.invitations.map((o)=>{if(!Be(o)||typeof o.id!=="string"||!o.id||typeof o.email!=="string"||!o.email||typeof o.expiresAt!=="string"||!Number.isFinite(Date.parse(o.expiresAt)))throw Error("Invalid invitation");return{id:o.id,email:o.email,expiresAt:o.expiresAt}});if(new Set(t.map(ze)).size!==t.length||new Set(a.map((o)=>o.id)).size!==a.length)throw Error("Duplicate workspace member or invitation");return{members:t,invitations:a}}function G(r){if(!/^(?:[A-Za-z0-9_-]{1,64}:)?[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(r))throw Error("Invalid workspace id");return r}var ur;function x(){let r=ce();if(ur?.accountGeneration!==r)ur={accountGeneration:r,lists:new Map,complete:!1};return ur}var Xr=0,mr=new Set;function q(){Xr++,mr.forEach((r)=>r())}var Gr=()=>Xr,$r=new WeakMap,Tt={members:[],invitations:[]},Yr=new WeakMap;function Zr(r){if(!x().complete)return;if(r.includes(":"))return Tt;let t=Te();if(t?.type!=="user"||t.isAnonymous)return;let a=$r.get(t);if(!a)a={members:[t],invitations:[]},$r.set(t,a);return a}function Z(r,t){let{lists:a}=x();a.set(r,We(a.get(r),t))}function rt(r,t){Z(G(r),gr(t)),q()}function tt(r){if(!Array.isArray(r))throw Error("Invalid workspace members");let t=r.map((i)=>[G(i.id),gr(i)]),a=new Set(t.map(([i])=>i));if(a.size!==t.length)throw Error("Duplicate workspace id");let{lists:o}=x();for(let i of o.keys())if(!a.has(i))o.delete(i);for(let[i,c]of t)Z(i,c);x().complete=!0,q()}function at(r){x().lists.delete(G(r)),q()}function et(){x().lists.clear(),q()}function nn(r,t){let a=hr(r),o=x().lists.get(a)??Zr(a),i=o&&t(o);if(!i)return;Z(a,i),q()}function sn(r){let t=ze(r);for(let[a,o]of x().lists)Z(a,{...o,members:o.members.map((i)=>ze(i)===t?{...r,...i.membershipId&&{membershipId:i.membershipId}}:i)});q()}function Do(r){let t=hr(r);return x().lists.get(t)??Zr(t)}function an(r){let t=Do(r);if(!t)return;let a=Yr.get(t);if(!a)a=t.members.map((o)=>P({id:bt(o),name:o.name||void 0,avatar:o.avatar,email:o.type==="user"?o.email||void 0:void 0})),Yr.set(t,a);return a}function wr(r){mr.add(r);let t=it.getQueryCache().subscribe((a)=>{let[o,i]=a.query.queryKey;if(o===l.all[0]&&i==="layout")r()});return()=>{mr.delete(r),t()}}function ot(){if(typeof window>"u")return;let r=window;r.moi??={},r.moi.identity={set:vt,getRevision:br},r.moi.workspaceMembers={set:rt,setAll:tt,remove:at,clear:et,getRevision:Gr}}ot();Pr();async function Lt(r){let[{mount:t},a,o]=await Promise.all([(Fe("ba6mz56s"),import("/chunk-ba6mz56s.js")),(Fe("en7w5ypg"),import("/chunk-en7w5ypg.js")).then((i)=>i.loadAppConfig()),(Fe("ec5ennpv"),import("/chunk-ec5ennpv.js")).then((i)=>i.loadProxyUser())]);Ar(a?.environment==="local"&&!a.demo,o),t(r)}globalThis.__init=Lt;export{e,I,Ft,tn,Fe,Jr,rn,Be,nt,ze,bt,Te,br,ce,Qr,vt,pe,wt,ve,on,eo,He,H,to,ro,U,Zt,Ue,We,St,vr,Jt,Qt,ge,er,M,_o,Mo,it,l,Bt,ie,nn,sn,Do,an,wr};
1
+ var ht=Object.create;var{getPrototypeOf:gt,defineProperty:ar,getOwnPropertyNames:ut}=Object;var xr=Object.prototype.hasOwnProperty;function mt(r){return this[r]}var ft,bt,e=(r,t,a)=>{var o=r!=null&&typeof r==="object";if(o){var i=t?ft??=new WeakMap:bt??=new WeakMap,c=i.get(r);if(c)return c}a=r!=null?ht(gt(r)):{};let d=t||!r||!r.__esModule||!xr.call(r,"default")?ar(a,"default",{value:r,enumerable:!0}):a;if(r&&typeof r==="object"||typeof r==="function"){for(let n of ut(r))if(!xr.call(d,n))ar(d,n,{get:mt.bind(r,n),enumerable:!0})}if(o)i.set(r,d);return d};var C=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var xt=(r)=>r;function yt(r,t){this[r]=xt.bind(null,t)}var Bt=(r,t)=>{for(var a in t)ar(r,a,{get:t[a],enumerable:!0,configurable:!0,set:yt.bind(t,a)})};var tn=((r)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,a)=>(typeof require<"u"?require:t)[a]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var yr,ir,F,Le=(r,t)=>{for(var[a,o,i]of yr||[])for(var c=[r],d=globalThis,n=d.document,s,p,g,h,u;p=c.pop();)if(!ir[p]&&(g=o[p])){ir[p]=1;for(h=1;h<g.length;h++)c.push(i[g[h]]);if(!t&&p!==r&&(s=n&&n.head)){if(F===void 0)F=(h=n.querySelector("meta[property=csp-nonce]"))&&(h.nonce||h.getAttribute("nonce"))||"";if(u=n.createElement("link"),u.rel="modulepreload",u.crossOrigin="",F)u.nonce=F;u.href=new d.URL(g[0],a),s.appendChild(u)}}},kt=(r,t,a,o)=>{for(var i={},c=0;c<t.length;c++)i[t[c]]=a[c];(yr||=[]).push([r,i,t]),ir||={},Le(t[o],1)};kt(import.meta.url,["h3qag4a6","1tksq43z","w5h9grdr","a865c7x4","nf2wkvf9","r95acex1","6gxf0xr8","q2tpy0h7","f44cs6mw","0h4zypgf","xj1pjhng"],[["/chunk-h3qag4a6.js"],["/chunk-1tksq43z.js",6,0,7,8],["/chunk-w5h9grdr.js",7],["/chunk-a865c7x4.js",0,8],["/chunk-nf2wkvf9.js"],["/chunk-r95acex1.js",6,7,0,10,8],["/chunk-6gxf0xr8.js",0,7,8],["/chunk-q2tpy0h7.js",0,8],["/chunk-f44cs6mw.js"],["/chunk-0h4zypgf.js",10],["/chunk-xj1pjhng.js"]],0);
2
+ if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);var P=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function Q(r){return typeof r==="string"&&P.includes(r)}function Jr(r){let t=2166136261;for(let a=0;a<r.length;a++)t^=r.charCodeAt(a),t=Math.imul(t,16777619);return P[(t>>>0)%P.length]??P[0]}var rn=1;var _t=8192,Ct=320;function Fe(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)}function L(r,t=256){return typeof r==="string"&&r.length>0&&!r.includes("\x00")&&new TextEncoder().encode(r).length<=t}function kr(r){return Fe(r)&&L(r.id,240)&&r.id.trim().length>0&&(r.name===void 0||L(r.name)&&r.name.trim().length>0)&&Q(r.color)&&(r.avatar===void 0||L(r.avatar,_t))&&(r.email===void 0||L(r.email,Ct))}function N(r,t){return typeof r==="string"&&r.length<=t&&!r.includes("\x00")}function Et(r){if(!N(r,2048))return!1;try{return["http:","https:"].includes(new URL(r).protocol)}catch{return!1}}function ot(r){if(!Fe(r)||!N(r.id,240)||!r.id.trim()||r.id!==r.id.trim()||!N(r.name,256)||r.avatar!==void 0&&!Et(r.avatar))throw Error("Invalid identity");let t={id:r.id,name:r.name,...r.avatar!==void 0?{avatar:r.avatar}:{}};if(r.type==="agent")return{...t,type:"agent"};if(r.type==="user"&&N(r.email,320)&&typeof r.isAnonymous==="boolean")return{...t,type:"user",email:r.email,isAnonymous:r.isAnonymous};throw Error("Invalid identity")}var Be=(r)=>`${r.type}:${r.id}`,vt=(r)=>r.type==="agent"?`agent:${r.id}`:r.id;var W,zr=0,_r=0,nr=new Set,Te=()=>W,wr=()=>_r,ce=()=>zr;function Qr(r){return nr.add(r),()=>{nr.delete(r)}}function wt(r){let t=r===null?null:ot(r);if((W&&Be(W))!==(t&&Be(t)))zr++;_r++,W=t,nr.forEach((o)=>o())}var At=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function Cr(r,t){let a=r.filter((o)=>o!==t);return a[Math.floor(Math.random()*a.length)]??r[0]}function Pt(r){return{name:Cr(At,r?.name),color:Cr(P,r?.color)}}function jt(r,t){let a=t.name.trim();return{id:r,...a?{name:a}:{},color:t.color}}function Er(){return jt(`local-${crypto.randomUUID().slice(0,8)}`,Pt())}var cr="moi:local-profile",_,S,D=new Set;function lr(r,t){return JSON.stringify(r)===JSON.stringify(t)}function j(r){if(!r||typeof r.id!=="string"||!r.id.trim())throw Error("A user profile needs an id.");if(r.name!==void 0&&typeof r.name!=="string")throw Error("A user profile name must be a string when provided.");if(r.color!==void 0&&!Q(r.color))throw Error("A user profile color must be one of the user palette names.");let t=r.id.trim(),a=r.name?.trim(),o={id:t,...a?{name:a}:{},color:r.color??Jr(t),...r.avatar!==void 0?{avatar:r.avatar}:{},...r.email!==void 0?{email:r.email}:{}};if(!kr(o))throw Error("Invalid user profile.");return Object.freeze(o)}var sr,Ar;function pe(){let r=Te();if(r===void 0)return _;if(r!==Ar){Ar=r;let t=!r||r.type==="user"&&r.isAnonymous?void 0:j({id:vt(r),name:r.name||void 0,avatar:r.avatar,email:r.type==="user"?r.email||void 0:void 0});if(!lr(sr,t))sr=t}return sr}function St(r){let t=pe(),a=we(),o=()=>{let c=pe(),d=we();if(t===c&&a===d)return;t=c,a=d,r()};D.add(o);let i=Qr(o);return()=>{D.delete(o),i()}}function we(){return Te()!==void 0?"external":S}function on({provider:r,profile:t}){if(we()==="external")return;if(r===void 0){if(S===void 0||S==="local")return;S=void 0,_=void 0}else{let a=t===void 0?void 0:j(t);if(S===r&&lr(_,a))return;S=r,_=a}D.forEach((a)=>a())}function Mt(){try{localStorage.setItem(cr,JSON.stringify(_))}catch{}}function eo(r){if(we()!==void 0&&we()!=="local")return;let t=j(r);S="local",_=t,Mt(),D.forEach((a)=>a())}function jr(r,t){if(!r||!t||t.provider!==void 0||we()!==void 0)return;try{let a=localStorage.getItem(cr);if(a){eo(JSON.parse(a));return}}catch{}eo(Er())}function Pr(r){if(r.key!==cr||!r.newValue||we()!=="local")return;try{let t=j(JSON.parse(r.newValue));if(lr(t,_))return;_=t,D.forEach((a)=>a())}catch{}}function Mr(){return window.addEventListener("storage",Pr),()=>window.removeEventListener("storage",Pr)}var Ot={setTimeout:(r,t)=>setTimeout(r,t),clearTimeout:(r)=>clearTimeout(r),setInterval:(r,t)=>setInterval(r,t),clearInterval:(r)=>clearInterval(r)},qt=class{#r=Ot;#t=!1;setTimeoutProvider(r){this.#r=r}setTimeout(r,t){return this.#r.setTimeout(r,t)}clearTimeout(r){this.#r.clearTimeout(r)}setInterval(r,t){return this.#r.setInterval(r,t)}clearInterval(r){this.#r.clearInterval(r)}},ze=new qt;function Or(r){setTimeout(r,0)}var pr=typeof window>"u"||"Deno"in globalThis;function H(){}function Ur(r,t){return typeof r==="function"?r(t):r}function to(r){return typeof r==="number"&&r>=0&&r!==1/0}function ro(r,t){return Math.max(r+(t||0)-Date.now(),0)}function U(r,t){return typeof r==="function"?r(t):r}function er(r,t){let{type:a="all",exact:o,fetchStatus:i,predicate:c,queryKey:d,stale:n}=r;if(d){if(o){if(t.queryHash!==R(d,t.options))return!1}else if(!E(t.queryKey,d))return!1}if(a!=="all"){let s=t.isActive();if(a==="active"&&!s)return!1;if(a==="inactive"&&s)return!1}if(typeof n==="boolean"&&t.isStale()!==n)return!1;if(i&&i!==t.state.fetchStatus)return!1;if(c&&!c(t))return!1;return!0}function B(r,t){let{exact:a,status:o,predicate:i,mutationKey:c}=r;if(c){if(!t.options.mutationKey)return!1;if(a){if(He(t.options.mutationKey)!==He(c))return!1}else if(!E(t.options.mutationKey,c))return!1}if(o&&t.state.status!==o)return!1;if(i&&!i(t))return!1;return!0}function R(r,t){return(t?.queryKeyHashFn||He)(r)}function He(r){return JSON.stringify(r,(t,a)=>dr(a)?Object.keys(a).sort().reduce((o,i)=>(o[i]=a[i],o),{}):a)}function E(r,t){if(r===t)return!0;if(typeof r!==typeof t)return!1;if(r&&t&&typeof r==="object"&&typeof t==="object"){if(Array.isArray(r)&&Array.isArray(t)){for(let o=0;o<t.length;o++)if(!E(r[o],t[o]))return!1;return!0}let a=Object.keys(t);for(let o of a)if(!E(r[o],t[o]))return!1;return!0}return!1}var Dt=Object.prototype.hasOwnProperty;function Ue(r,t,a=0){if(r===t)return r;if(a>500)return t;let o=qr(r)&&qr(t);if(!o&&!(dr(r)&&dr(t)))return t;let i=(o?r:Object.keys(r)).length,c=o?t:Object.keys(t),d=c.length,n=o?Array(d):{},s=0;for(let p=0;p<d;p++){let g=o?p:c[p],h=r[g],u=t[g];if(h===u){if(n[g]=h,o?p<i:Dt.call(r,g))s++;continue}if(h===null||u===null||typeof h!=="object"||typeof u!=="object"){n[g]=u;continue}let y=Ue(h,u,a+1);if(n[g]=y,y===h)s++}return i===d&&s===i?r:n}function It(r,t){if(!t||Object.keys(r).length!==Object.keys(t).length)return!1;for(let a in r)if(r[a]!==t[a])return!1;return!0}function qr(r){return Array.isArray(r)&&r.length===Object.keys(r).length}function dr(r){if(!Dr(r))return!1;let t=r.constructor;if(t===void 0)return!0;let a=t.prototype;if(!Dr(a))return!1;if(!a.hasOwnProperty("isPrototypeOf"))return!1;if(Object.getPrototypeOf(r)!==Object.prototype)return!1;return!0}function Dr(r){return Object.prototype.toString.call(r)==="[object Object]"}function Rr(r){return new Promise((t)=>{ze.setTimeout(t,r)})}function Sr(r,t,a){if(typeof a.structuralSharing==="function")return a.structuralSharing(r,t);else if(a.structuralSharing!==!1)return Ue(r,t);return t}function Tr(r,t,a=0){let o=[...r,t];return a&&o.length>a?o.slice(1):o}function Fr(r,t,a=0){let o=[t,...r];return a&&o.length>a?o.slice(0,-1):o}var O=Symbol();function K(r,t){if(!r.queryFn&&t?.initialPromise)return()=>t.initialPromise;if(!r.queryFn||r.queryFn===O)return()=>Promise.reject(Error(`Missing queryFn: '${r.queryHash}'`));return r.queryFn}function tr(r,t){if(typeof r==="function")return r(...t);return!!r}function Lr(r,t,a){let o=!1,i;return Object.defineProperty(r,"signal",{enumerable:!0,get:()=>{if(i??=t(),o)return i;if(o=!0,i.aborted)a();else i.addEventListener("abort",a,{once:!0});return i}}),r}var Ut=()=>pr,rr=()=>Ut();var ye=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(r){return this.listeners.add(r),this.onSubscribe(),()=>{this.listeners.delete(r),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var Rt=class extends ye{#r;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r((t)=>{if(typeof t==="boolean")this.setFocused(t);else this.onFocus()})}setFocused(r){if(this.#r!==r)this.#r=r,this.onFocus()}onFocus(){let r=this.isFocused();this.listeners.forEach((t)=>{t(r)})}isFocused(){if(typeof this.#r==="boolean")return this.#r;return globalThis.document?.visibilityState!=="hidden"}},or=new Rt;var Nr=Or;function Tt(){let r=[],t=0,a=(n)=>{n()},o=(n)=>{n()},i=Nr,c=(n)=>{if(t)r.push(n);else i(()=>{a(n)})},d=()=>{let n=r;if(r=[],n.length)i(()=>{o(()=>{n.forEach((s)=>{a(s)})})})};return{batch:(n)=>{let s;t++;try{s=n()}finally{if(t--,!t)d()}return s},batchCalls:(n)=>(...s)=>{c(()=>{n(...s)})},schedule:c,setNotifyFunction:(n)=>{a=n},setBatchNotifyFunction:(n)=>{o=n},setScheduler:(n)=>{i=n}}}var M=Tt();var Ft=class extends ye{#r=!0;#t;#a;constructor(){super();this.#a=(r)=>{if(typeof window<"u"&&window.addEventListener){let t=()=>r(!0),a=()=>r(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",a)}}}}onSubscribe(){if(!this.#t)this.setEventListener(this.#a)}onUnsubscribe(){if(!this.hasListeners())this.#t?.(),this.#t=void 0}setEventListener(r){this.#a=r,this.#t?.(),this.#t=r(this.setOnline.bind(this))}setOnline(r){if(this.#r!==r)this.#r=r,this.listeners.forEach((t)=>{t(r)})}isOnline(){return this.#r}},I=new Ft;function Qt(r){return Math.min(1000*2**r,30000)}function hr(r){return(r??"online")==="online"?I.isOnline():!0}var V=class extends Error{constructor(r){super("CancelledError");this.revert=r?.revert,this.silent=r?.silent}};function Y(r){let t=!1,a=0,o,i="pending",c,d,n=new Promise((v,f)=>{c=v,d=f});n.catch(H);let s=()=>i!=="pending",p=(v)=>{if(!s()){let f=new V(v);m(f),r.onCancel?.(f)}},g=()=>{t=!0},h=()=>{t=!1},u=()=>or.isFocused()&&(r.networkMode==="always"||I.isOnline())&&r.canRun(),y=()=>hr(r.networkMode)&&r.canRun(),w=(v)=>{if(!s())o?.(),i="resolved",c(v)},m=(v)=>{if(!s())o?.(),i="rejected",d(v)},k=()=>new Promise((v)=>{o=(f)=>{if(s()||u())v(f)},r.onPause?.()}).then(()=>{if(o=void 0,!s())r.onContinue?.()}),T=()=>{if(s())return;let v,f=a===0?r.initialPromise:void 0;try{v=f??r.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(w).catch((b)=>{if(s())return;let z=r.retry??(rr()?0:3),A=r.retryDelay??Qt,dt=typeof A==="function"?A(a,b):A,pt=z===!0||typeof z==="number"&&a<z||typeof z==="function"&&z(a,b);if(t||!pt){m(b);return}a++,r.onFail?.(a,b),Rr(dt).then(()=>u()?void 0:k()).then(()=>{if(t)m(b);else T()})})};return{promise:n,status:()=>i,cancel:p,continue:()=>(o?.(),n),cancelRetry:g,continueRetry:h,canStart:y,start:()=>{if(y())T();else k().then(T);return n}}}var X=class{#r;destroy(){this.clearGcTimeout()}scheduleGc(){if(this.clearGcTimeout(),to(this.gcTime))this.#r=ze.setTimeout(()=>{this.optionalRemove()},this.gcTime)}updateGcTime(r){this.gcTime=Math.max(this.gcTime||0,r??(rr()?1/0:300000))}clearGcTimeout(){if(this.#r!==void 0)ze.clearTimeout(this.#r),this.#r=void 0}};function Br(r){return{onFetch:(t,a)=>{let o=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,c=t.state.data?.pages||[],d=t.state.data?.pageParams||[],n={pages:[],pageParams:[]},s=0,p=async()=>{let g=!1,h=(w)=>{Lr(w,()=>t.signal,()=>g=!0)},u=K(t.options,t.fetchOptions),y=async(w,m,k)=>{if(g)return Promise.reject(t.signal.reason);if(m==null&&w.pages.length)return Promise.resolve(w);let v=(()=>{let A={client:t.client,queryKey:t.queryKey,pageParam:m,direction:k?"backward":"forward",meta:t.options.meta};return h(A),A})(),f=await u(v),{maxPages:b}=t.options,z=k?Fr:Tr;return{pages:z(w.pages,f,b),pageParams:z(w.pageParams,m,b)}};if(i&&c.length){let w=i==="backward",m=w?Lt:Wr,k={pages:c,pageParams:d};n=await y(k,m(o,k),w)}else{let w=r??c.length;do{let m=s===0?d[0]??o.initialPageParam:Wr(o,n);if(s>0&&m==null)break;n=await y(n,m),s++}while(s<w)}return n};if(t.options.persister)t.fetchFn=()=>t.options.persister?.(p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},a);else t.fetchFn=p}}}function Wr(r,{pages:t,pageParams:a}){let o=t.length-1;return t.length>0?r.getNextPageParam(t[o],t,a[o],a):void 0}function Lt(r,{pages:t,pageParams:a}){return t.length>0?r.getPreviousPageParam?.(t[0],t,a[0],a):void 0}var Vr=class extends X{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r){super();this.#n=!1,this.#c=r.defaultOptions,this.setOptions(r.options),this.observers=[],this.#i=r.client,this.#o=this.#i.getQueryCache(),this.queryKey=r.queryKey,this.queryHash=r.queryHash,this.#t=Kr(this.options),this.state=r.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#r}get promise(){return this.#e?.promise}setOptions(r){if(this.options={...this.#c,...r},r?._type)this.#r=r._type;if(this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=Kr(this.options);if(t.data!==void 0)this.setState(Hr(t.data,t.dataUpdatedAt)),this.#t=t}}optionalRemove(){if(!this.observers.length&&this.state.fetchStatus==="idle")this.#o.remove(this)}setData(r,t){let a=Sr(this.state.data,r,this.options);return this.#s({data:a,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),a}setState(r){this.#s({type:"setState",state:r})}cancel(r){let t=this.#e?.promise;return this.#e?.cancel(r),t?t.then(H).catch(H):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((r)=>U(r.options.enabled,this)!==!1)}isDisabled(){if(this.getObserversCount()>0)return!this.isActive();return this.options.queryFn===O||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){if(this.getObserversCount()>0)return this.observers.some((r)=>U(r.options.staleTime,this)==="static");return!1}isStale(){if(this.getObserversCount()>0)return this.observers.some((r)=>r.getCurrentResult().isStale);return this.state.data===void 0||this.state.isInvalidated}isStaleByTime(r=0){if(this.state.data===void 0)return!0;if(r==="static")return!1;if(this.state.isInvalidated)return!0;return!ro(this.state.dataUpdatedAt,r)}onFocus(){this.observers.find((r)=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#e?.continue()}onOnline(){this.observers.find((r)=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#e?.continue()}addObserver(r){if(!this.observers.includes(r))this.observers.push(r),this.clearGcTimeout(),this.#o.notify({type:"observerAdded",query:this,observer:r})}removeObserver(r){let t=this.observers.indexOf(r);if(t!==-1){if(this.observers.splice(t,1),!this.observers.length){if(this.#e)if(this.#n||this.state.fetchStatus==="paused"&&this.state.status==="pending")this.#e.cancel({revert:!0});else this.#e.cancelRetry();this.scheduleGc()}this.#o.notify({type:"observerRemoved",query:this,observer:r})}}getObserversCount(){return this.observers.length}invalidate(){if(!this.state.isInvalidated)this.#s({type:"invalidate"})}async fetch(r,t){if(this.state.fetchStatus!=="idle"&&this.#e?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#e)return this.#e.continueRetry(),this.#e.promise}if(r)this.setOptions(r);if(!this.options.queryFn){let s=this.observers.find((p)=>p.options.queryFn);if(s)this.setOptions(s.options)}let a=new AbortController,o=(s)=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#n=!0,a.signal)})},i=()=>{let s=K(this.options,t),g=(()=>{let h={client:this.#i,queryKey:this.queryKey,meta:this.meta};return o(h),h})();if(this.#n=!1,this.options.persister)return this.options.persister(s,g,this);return s(g)},d=(()=>{let s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return o(s),s})();if((this.#r==="infinite"?Br(this.options.pages):this.options.behavior)?.onFetch(d,this),this.#a=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==d.fetchOptions?.meta)this.#s({type:"fetch",meta:d.fetchOptions?.meta});let n=this.#e=Y({initialPromise:t?.initialPromise,fn:d.fetchFn,onCancel:(s)=>{if(s instanceof V&&s.revert)this.setState({...this.#a,fetchStatus:"idle"});a.abort()},onFail:(s,p)=>{this.#s({type:"failed",failureCount:s,error:p})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0});try{let s=await n.start();if(s===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#o.config.onSuccess?.(s,this),this.#o.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof V){if(s.silent)return this.#e.promise;else if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#s({type:"error",error:s}),this.#o.config.onError?.(s,this),this.#o.config.onSettled?.(this.state.data,s,this),s}finally{if(this.#e===n)this.#e=void 0;this.scheduleGc()}}#s(r){let t=(a)=>{switch(r.type){case"failed":return{...a,fetchFailureCount:r.failureCount,fetchFailureReason:r.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,..._o(a.data,this.options),fetchMeta:r.meta??null};case"success":let o={...a,...Hr(r.data,r.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!r.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#a=r.manual?o:void 0,o;case"error":let i=r.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...r.state}}};this.state=t(this.state),M.batch(()=>{this.observers.slice().forEach((a)=>{a.onQueryUpdate()}),this.#o.notify({query:this,type:"updated",action:r})})}};function _o(r,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:hr(t.networkMode)?"fetching":"paused",...r===void 0&&{error:null,status:"pending"}}}function Hr(r,t){return{data:r,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Kr(r){let t=typeof r.initialData==="function"?r.initialData():r.initialData,a=t!==void 0,o=a?typeof r.initialDataUpdatedAt==="function"?r.initialDataUpdatedAt():r.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:a?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:a?"success":"pending",fetchStatus:"idle"}}var $r=class extends X{#r;#t;#a;#o;constructor(r){super();this.#r=r.client,this.mutationId=r.mutationId,this.#a=r.mutationCache,this.#t=[],this.state=r.state||Mo(),this.setOptions(r.options),this.scheduleGc()}setOptions(r){this.options=r,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(r){if(!this.#t.includes(r))this.#t.push(r),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",mutation:this,observer:r})}removeObserver(r){this.#t=this.#t.filter((t)=>t!==r),this.scheduleGc(),this.#a.notify({type:"observerRemoved",mutation:this,observer:r})}optionalRemove(){if(!this.#t.length)if(this.state.status==="pending")this.scheduleGc();else this.#a.remove(this)}continue(){return this.#o?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(r){let t=()=>{this.#i({type:"continue"})},a={client:this.#r,meta:this.options.meta,mutationKey:this.options.mutationKey},o=this.#o=Y({fn:()=>{if(!this.options.mutationFn)return Promise.reject(Error("No mutationFn found"));return this.options.mutationFn(r,a)},onFail:(d,n)=>{this.#i({type:"failed",failureCount:d,error:n})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#a.canRun(this)}),i=this.state.status==="pending",c=!o.canStart();try{if(i)t();else{if(this.#i({type:"pending",variables:r,isPaused:c}),this.#a.config.onMutate)await this.#a.config.onMutate(r,this,a);let n=await this.options.onMutate?.(r,a);if(n!==this.state.context)this.#i({type:"pending",context:n,variables:r,isPaused:c})}let d=await o.start();return await this.#a.config.onSuccess?.(d,r,this.state.context,this,a),await this.options.onSuccess?.(d,r,this.state.context,a),await this.#a.config.onSettled?.(d,null,this.state.variables,this.state.context,this,a),await this.options.onSettled?.(d,null,r,this.state.context,a),this.#i({type:"success",data:d}),d}catch(d){try{await this.#a.config.onError?.(d,r,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onError?.(d,r,this.state.context,a)}catch(n){Promise.reject(n)}try{await this.#a.config.onSettled?.(void 0,d,this.state.variables,this.state.context,this,a)}catch(n){Promise.reject(n)}try{await this.options.onSettled?.(void 0,d,r,this.state.context,a)}catch(n){Promise.reject(n)}throw this.#i({type:"error",error:d}),d}finally{if(this.#o===o)this.#o=void 0;this.#a.runNext(this)}}#i(r){let t=(a)=>{switch(r.type){case"failed":return{...a,failureCount:r.failureCount,failureReason:r.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:r.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:r.isPaused,status:"pending",variables:r.variables,submittedAt:Date.now()};case"success":return{...a,data:r.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:r.error,failureCount:a.failureCount+1,failureReason:r.error,isPaused:!1,status:"error"}}};this.state=t(this.state),M.batch(()=>{this.#t.forEach((a)=>{a.onMutationUpdate(r)}),this.#a.notify({mutation:this,type:"updated",action:r})})}};function Mo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yr=class extends ye{#r;#t;#a;constructor(r={}){super();this.config=r,this.#r=new Set,this.#t=new Map,this.#a=0}build(r,t,a){let o=new $r({client:r,mutationCache:this,mutationId:++this.#a,options:r.defaultMutationOptions(t),state:a});return this.add(o),o}add(r){this.#r.add(r);let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a)a.push(r);else this.#t.set(t,[r])}this.notify({type:"added",mutation:r})}remove(r){if(this.#r.delete(r)){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t);if(a){if(a.length>1){let o=a.indexOf(r);if(o!==-1)a.splice(o,1)}else if(a[0]===r)this.#t.delete(t)}}}this.notify({type:"removed",mutation:r})}canRun(r){let t=J(r);if(typeof t==="string"){let a=this.#t.get(t)?.find((o)=>o.state.status==="pending");return!a||a===r}else return!0}runNext(r){let t=J(r);if(typeof t==="string")return this.#t.get(t)?.find((a)=>a!==r&&a.state.isPaused)?.continue()??Promise.resolve();else return Promise.resolve()}clear(){M.batch(()=>{this.#r.forEach((r)=>{this.notify({type:"removed",mutation:r})}),this.#r.clear(),this.#t.clear()})}getAll(){return Array.from(this.#r)}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>B(t,a))}findAll(r={}){return this.getAll().filter((t)=>B(r,t))}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}resumePausedMutations(){let r=this.getAll().filter((t)=>t.state.isPaused);return M.batch(()=>Promise.all(r.map((t)=>t.continue().catch(H))))}};function J(r){return r.options.scope?.id}var Xr=class extends ye{#r;constructor(r={}){super();this.config=r,this.#r=new Map}build(r,t,a){let o=t.queryKey,i=t.queryHash??R(o,t),c=this.get(i);if(!c)c=new Vr({client:r,queryKey:o,queryHash:i,options:r.defaultQueryOptions(t),state:a,defaultOptions:r.getQueryDefaults(o)}),this.add(c);return c}add(r){if(!this.#r.has(r.queryHash))this.#r.set(r.queryHash,r),this.notify({type:"added",query:r})}remove(r){let t=this.#r.get(r.queryHash);if(t){if(r.destroy(),t===r)this.#r.delete(r.queryHash);this.notify({type:"removed",query:r})}}clear(){M.batch(()=>{this.getAll().forEach((r)=>{this.remove(r)})})}get(r){return this.#r.get(r)}getAll(){return[...this.#r.values()]}find(r){let t={exact:!0,...r};return this.getAll().find((a)=>er(t,a))}findAll(r={}){let t=this.getAll();return Object.keys(r).length>0?t.filter((a)=>er(r,a)):t}notify(r){M.batch(()=>{this.listeners.forEach((t)=>{t(r)})})}onFocus(){M.batch(()=>{this.getAll().forEach((r)=>{r.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach((r)=>{r.onOnline()})})}};var gr=class{#r;#t;#a;#o;#i;#e;#c;#n;constructor(r={}){this.#r=r.queryCache||new Xr,this.#t=r.mutationCache||new Yr,this.#a=r.defaultOptions||{},this.#o=new Map,this.#i=new Map,this.#e=0}mount(){if(this.#e++,this.#e!==1)return;this.#c=or.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onFocus()}),this.#n=I.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onOnline()})}unmount(){if(this.#e--,this.#e!==0)return;this.#c?.(),this.#c=void 0,this.#n?.(),this.#n=void 0}isFetching(r){return this.#r.findAll({...r,fetchStatus:"fetching"}).length}isMutating(r){return this.#t.findAll({...r,status:"pending"}).length}getQueryData(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state.data}ensureQueryData(r){let t=this.defaultQueryOptions(r),a=this.#r.build(this,t),o=a.state.data;if(o===void 0)return this.fetchQuery(r);if(r.revalidateIfStale&&a.isStaleByTime(U(t.staleTime,a)))this.prefetchQuery(t);return Promise.resolve(o)}getQueriesData(r){return this.#r.findAll(r).map(({queryKey:t,state:a})=>[t,a.data])}setQueryData(r,t,a){let o=this.defaultQueryOptions({queryKey:r}),i=this.#r.get(o.queryHash)?.state.data,c=Ur(t,i);if(c===void 0)return;return this.#r.build(this,o).setData(c,{...a,manual:!0})}setQueriesData(r,t,a){return M.batch(()=>this.#r.findAll(r).map(({queryKey:o})=>[o,this.setQueryData(o,t,a)]))}getQueryState(r){let t=this.defaultQueryOptions({queryKey:r});return this.#r.get(t.queryHash)?.state}removeQueries(r){let t=this.#r;M.batch(()=>{t.findAll(r).forEach((a)=>{t.remove(a)})})}resetQueries(r,t){let a=this.#r;return M.batch(()=>{let o=a.findAll(r),i=new Set(o);return o.forEach((c)=>{c.reset()}),this.refetchQueries({type:"active",predicate:(c)=>i.has(c)},t)})}cancelQueries(r,t={}){let a={revert:!0,...t},o=M.batch(()=>this.#r.findAll(r).map((i)=>i.cancel(a)));return Promise.all(o).then(H).catch(H)}invalidateQueries(r,t={}){return M.batch(()=>{if(this.#r.findAll(r).forEach((a)=>{a.invalidate()}),r?.refetchType==="none")return Promise.resolve();return this.refetchQueries({...r,type:r?.refetchType??r?.type??"active"},t)})}refetchQueries(r,t={}){let a={...t,cancelRefetch:t.cancelRefetch??!0},o=M.batch(()=>this.#r.findAll(r).filter((i)=>!i.isDisabled()&&!i.isStatic()).map((i)=>{let c=i.fetch(void 0,a);if(!a.throwOnError)c=c.catch(H);return i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(o).then(H)}async query(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t),o=a.isStaleByTime(U(t.staleTime,a))?await a.fetch(t):a.state.data,i=t.select;if(i)return i(o);return o}fetchQuery(r){let t=this.defaultQueryOptions(r);if(t.retry===void 0)t.retry=!1;let a=this.#r.build(this,t);return a.isStaleByTime(U(t.staleTime,a))?a.fetch(t):Promise.resolve(a.state.data)}prefetchQuery(r){return this.fetchQuery(r).then(H).catch(H)}infiniteQuery(r){return r._type="infinite",this.query(r)}fetchInfiniteQuery(r){return r._type="infinite",this.fetchQuery(r)}prefetchInfiniteQuery(r){return this.fetchInfiniteQuery(r).then(H).catch(H)}ensureInfiniteQueryData(r){return r._type="infinite",this.ensureQueryData(r)}resumePausedMutations(){if(I.isOnline())return this.#t.resumePausedMutations();return Promise.resolve()}getQueryCache(){return this.#r}getMutationCache(){return this.#t}getDefaultOptions(){return this.#a}setDefaultOptions(r){this.#a=r}setQueryDefaults(r,t){this.#o.set(He(r),{queryKey:r,defaultOptions:t})}getQueryDefaults(r){let t=[...this.#o.values()],a={};return t.forEach((o)=>{if(E(r,o.queryKey))Object.assign(a,o.defaultOptions)}),a}setMutationDefaults(r,t){this.#i.set(He(r),{mutationKey:r,defaultOptions:t})}getMutationDefaults(r){let t=[...this.#i.values()],a={};return t.forEach((o)=>{if(E(r,o.mutationKey))Object.assign(a,o.defaultOptions)}),a}defaultQueryOptions(r){if(r._defaulted)return r;let t={...this.#a.queries,...this.getQueryDefaults(r.queryKey),...r,_defaulted:!0};if(!t.queryHash)t.queryHash=R(t.queryKey,t);if(t.refetchOnReconnect===void 0)t.refetchOnReconnect=t.networkMode!=="always";if(t.throwOnError===void 0)t.throwOnError=!!t.suspense;if(!t.networkMode&&t.persister)t.networkMode="offlineFirst";if(t.queryFn===O)t.enabled=!1;return t}defaultMutationOptions(r){if(r?._defaulted)return r;return{...this.#a.mutations,...r?.mutationKey&&this.getMutationDefaults(r.mutationKey),...r,_defaulted:!0}}clear(){this.#r.clear(),this.#t.clear()}};var nt=new gr;var l={all:["workspaces"],discover:["workspaces","discover"],previews:["workspaces","previews"],layout:(r)=>["workspaces","layout",r],widgets:(r)=>["workspaces","widgets",r],appletThumbnails:(r)=>["workspaces","applet-thumbnails",r],views:(r)=>["workspaces","views",r],sessions:(r)=>["workspaces","sessions",r],events:(r,t)=>["workspaces","events",r,t],state:(r)=>["workspaces","state",r],mcp:(r)=>["workspaces","mcp",r],harness:(r)=>["workspaces","harness",r],skills:(r)=>["workspaces","skills",r],env:(r)=>["workspaces","env",r]};var ur=(r,t)=>t.getQueryData(l.layout(r));function zt(r,t=nt){return ur(r,t)?.isRemote??!1}function ie(r,t=nt){let a=ur(r,t)?.apiBase;if(!a)throw Error("Workspace identity is not loaded");return a}function vr(r,t=nt){let a=ur(r,t)?.apiBase;return a?decodeURIComponent(a.slice(16)):r}function mr(r){if(!Fe(r)||!Array.isArray(r.members)||!Array.isArray(r.invitations))throw Error("Invalid workspace members");let t=r.members.map((o)=>{let i=ot(o);if(Fe(o)&&o.membershipId!==void 0){if(typeof o.membershipId!=="string"||!o.membershipId||o.membershipId.length>240)throw Error("Invalid membership id");return{...i,membershipId:o.membershipId}}return i}),a=r.invitations.map((o)=>{if(!Fe(o)||typeof o.id!=="string"||!o.id||typeof o.email!=="string"||!o.email||typeof o.expiresAt!=="string"||!Number.isFinite(Date.parse(o.expiresAt)))throw Error("Invalid invitation");return{id:o.id,email:o.email,expiresAt:o.expiresAt}});if(new Set(t.map(Be)).size!==t.length||new Set(a.map((o)=>o.id)).size!==a.length)throw Error("Duplicate workspace member or invitation");return{members:t,invitations:a}}function G(r){if(!/^(?:[A-Za-z0-9_-]{1,64}:)?[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(r))throw Error("Invalid workspace id");return r}var fr;function x(){let r=ce();if(fr?.accountGeneration!==r)fr={accountGeneration:r,lists:new Map,complete:!1};return fr}var rt=0,br=new Set;function q(){rt++,br.forEach((r)=>r())}var tt=()=>rt,Gr=new WeakMap,Nt={members:[],invitations:[]},Zr=new WeakMap;function at(r){if(!x().complete)return;if(r.includes(":"))return Nt;let t=Te();if(t?.type!=="user"||t.isAnonymous)return;let a=Gr.get(t);if(!a)a={members:[t],invitations:[]},Gr.set(t,a);return a}function Z(r,t){let{lists:a}=x();a.set(r,Ue(a.get(r),t))}function et(r,t){Z(G(r),mr(t)),q()}function it(r){if(!Array.isArray(r))throw Error("Invalid workspace members");let t=r.map((i)=>[G(i.id),mr(i)]),a=new Set(t.map(([i])=>i));if(a.size!==t.length)throw Error("Duplicate workspace id");let{lists:o}=x();for(let i of o.keys())if(!a.has(i))o.delete(i);for(let[i,c]of t)Z(i,c);x().complete=!0,q()}function st(r){x().lists.delete(G(r)),q()}function ct(){x().lists.clear(),q()}function nn(r,t){let a=vr(r),o=x().lists.get(a)??at(a),i=o&&t(o);if(!i)return;Z(a,i),q()}function sn(r){let t=Be(r);for(let[a,o]of x().lists)Z(a,{...o,members:o.members.map((i)=>Be(i)===t?{...r,...i.membershipId&&{membershipId:i.membershipId}}:i)});q()}function Do(r){let t=vr(r);return x().lists.get(t)??at(t)}function an(r){let t=Do(r);if(!t)return;let a=Zr.get(t);if(!a)a=t.members.map((o)=>j({id:vt(o),name:o.name||void 0,avatar:o.avatar,email:o.type==="user"?o.email||void 0:void 0})),Zr.set(t,a);return a}function Ir(r){br.add(r);let t=nt.getQueryCache().subscribe((a)=>{let[o,i]=a.query.queryKey;if(o===l.all[0]&&i==="layout")r()});return()=>{br.delete(r),t()}}function lt(){if(typeof window>"u")return;let r=window;r.moi??={},r.moi.identity={set:wt,getRevision:wr},r.moi.workspaceMembers={set:et,setAll:it,remove:st,clear:ct,getRevision:tt}}lt();Mr();async function Wt(r){let[{mount:t},a,o]=await Promise.all([(Le("1tksq43z"),import("/chunk-1tksq43z.js")),(Le("w5h9grdr"),import("/chunk-w5h9grdr.js")).then((i)=>i.loadAppConfig()),(Le("a865c7x4"),import("/chunk-a865c7x4.js")).then((i)=>i.loadProxyUser())]);jr(a?.environment==="local"&&!a.demo,o),t(r)}globalThis.__init=Wt;export{e,C,Bt,tn,Le,Jr,rn,Fe,ot,Be,vt,Te,wr,ce,Qr,wt,pe,St,we,on,eo,ze,H,to,ro,U,er,He,Ue,It,Sr,tr,rr,ye,or,M,_o,Mo,nt,l,zt,ie,nn,sn,Do,an,Ir};
@@ -1,2 +1,2 @@
1
- import{e,I}from"/chunk-44khk4sp.js";import{h}from"/chunk-pdt9hxfw.js";var r=I(function(l,i){i.exports=globalThis.__esm.react});var p=e(r(),1);var f={environment:"local",demo:!1,demoInstallUrl:"https://moi.computer"},t=f,o=new Set;function s(n){return o.add(n),()=>{o.delete(n)}}async function c(){try{t=await h("/api/config");for(let n of o)n();return t}catch{}}async function ti(){return c()}function ne(){return t.demo?"/demo":"/"}function B(){return p.useSyncExternalStore(s,()=>t,()=>t)}
2
- export{r,ti,ne,B};
1
+ import{e,C}from"/chunk-h3qag4a6.js";import{h}from"/chunk-f44cs6mw.js";var r=C(function(l,i){i.exports=globalThis.__esm.react});var p=e(r(),1);var f={environment:"local",demo:!1,demoInstallUrl:"https://moi.computer"},t=f,o=new Set;function s(n){return o.add(n),()=>{o.delete(n)}}async function c(){try{t=await h("/api/config");for(let n of o)n();return t}catch{}}async function ei(){return c()}function ne(){return t.demo?"/demo":"/"}function B(){return p.useSyncExternalStore(s,()=>t,()=>t)}
2
+ export{r,ei,ne,B};