@pimote/pimote 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/client/build/_app/immutable/assets/0.DBrr7n4n.css +2 -0
- package/client/build/_app/immutable/assets/2.DE6k3bQj.css +1 -0
- package/client/build/_app/immutable/chunks/5vSSf6qG.js +5 -0
- package/client/build/_app/immutable/chunks/{BTSGQ0LP.js → B8lQCytv.js} +1 -1
- package/client/build/_app/immutable/chunks/CT6ckxpD.js +1 -0
- package/client/build/_app/immutable/chunks/DlJOVoUQ.js +1 -0
- package/client/build/_app/immutable/chunks/YxmLwfhj.js +1 -0
- package/client/build/_app/immutable/chunks/{L5t1qIFa.js → uZO1iyJZ.js} +2 -2
- package/client/build/_app/immutable/chunks/yWVx3W2o.js +1 -0
- package/client/build/_app/immutable/entry/app.CNzpBgAg.js +2 -0
- package/client/build/_app/immutable/entry/start.DYkTAHh1.js +1 -0
- package/client/build/_app/immutable/nodes/0.DNlQhEb_.js +10 -0
- package/client/build/_app/immutable/nodes/1.B8zmHMre.js +1 -0
- package/client/build/_app/immutable/nodes/2.W9yV4-x2.js +54 -0
- package/client/build/_app/version.json +1 -1
- package/client/build/index.html +8 -8
- package/package.json +3 -3
- package/patches/{@mariozechner+pi-coding-agent+0.65.0.patch → @mariozechner+pi-coding-agent+0.67.6.patch} +4 -4
- package/server/dist/folder-index.js +8 -4
- package/server/dist/git-branch.js +32 -0
- package/server/dist/message-mapper.js +65 -2
- package/server/dist/server.js +3 -0
- package/server/dist/session-manager.js +35 -4
- package/server/dist/ws-handler.js +271 -31
- package/client/build/_app/immutable/assets/0.CsjXJ2oE.css +0 -2
- package/client/build/_app/immutable/assets/2.CIRqqeIr.css +0 -1
- package/client/build/_app/immutable/chunks/BN18Mjoo.js +0 -1
- package/client/build/_app/immutable/chunks/BTW4yCoz.js +0 -1
- package/client/build/_app/immutable/chunks/CnuZs6QA.js +0 -1
- package/client/build/_app/immutable/chunks/CvWR-ThL.js +0 -1
- package/client/build/_app/immutable/chunks/D5m3x_L9.js +0 -5
- package/client/build/_app/immutable/entry/app.BjHwmkZK.js +0 -2
- package/client/build/_app/immutable/entry/start.CZeUhs5D.js +0 -1
- package/client/build/_app/immutable/nodes/0.HHf1ps7Y.js +0 -5
- package/client/build/_app/immutable/nodes/1.CjbUSBAL.js +0 -1
- package/client/build/_app/immutable/nodes/2.C22f_gRz.js +0 -49
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,H as t,V as n,ot as r,r as i,rt as a,t as o,tt as s}from"./BTSGQ0LP.js";import{t as c}from"./CnuZs6QA.js";var l=class{constructor(e,t){this.status=e,typeof t==`string`?this.body={message:t}:t?this.body=t:this.body={message:`Error: ${e}`}}toString(){return JSON.stringify(this.body)}},u=class{constructor(e,t){this.status=e,this.location=t}},d=class extends Error{constructor(e,t,n){super(n),this.status=e,this.text=t}};new URL(`sveltekit-internal://`);function f(e,t){return e===`/`||t===`ignore`?e:t===`never`?e.endsWith(`/`)?e.slice(0,-1):e:t===`always`&&!e.endsWith(`/`)?e+`/`:e}function p(e){return e.split(`%25`).map(decodeURI).join(`%25`)}function ee(e){for(let t in e)e[t]=decodeURIComponent(e[t]);return e}function m({href:e}){return e.split(`#`)[0]}function h(...e){let t=5381;for(let n of e)if(typeof n==`string`){let e=n.length;for(;e;)t=t*33^n.charCodeAt(--e)}else if(ArrayBuffer.isView(n)){let e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r=e.length;for(;r;)t=t*33^e[--r]}else throw TypeError(`value must be a string or TypedArray`);return(t>>>0).toString(36)}new TextEncoder,new TextDecoder;function g(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var te=window.fetch;window.fetch=(e,t)=>((e instanceof Request?e.method:t?.method||`GET`)!==`GET`&&_.delete(b(e)),te(e,t));var _=new Map;function v(e,t){let n=b(e,t),r=document.querySelector(n);if(r?.textContent){r.remove();let{body:e,...t}=JSON.parse(r.textContent),i=r.getAttribute(`data-ttl`);return i&&_.set(n,{body:e,init:t,ttl:1e3*Number(i)}),r.getAttribute(`data-b64`)!==null&&(e=g(e)),Promise.resolve(new Response(e,t))}return window.fetch(e,t)}function y(e,t,n){if(_.size>0){let t=b(e,n),r=_.get(t);if(r){if(performance.now()<r.ttl&&[`default`,`force-cache`,`only-if-cached`,void 0].includes(n?.cache))return new Response(r.body,r.init);_.delete(t)}}return window.fetch(t,n)}function b(e,t){let n=`script[data-sveltekit-fetched][data-url=${JSON.stringify(e instanceof Request?e.url:e)}]`;if(t?.headers||t?.body){let e=[];t.headers&&e.push([...new Headers(t.headers)].join(`,`)),t.body&&(typeof t.body==`string`||ArrayBuffer.isView(t.body))&&e.push(t.body),n+=`[data-hash="${h(...e)}"]`}return n}var ne=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;function re(e){let t=[];return{pattern:e===`/`?/^\/$/:RegExp(`^${ae(e).map(e=>{let n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(e);if(n)return t.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),`(?:/([^]*))?`;let r=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(e);if(r)return t.push({name:r[1],matcher:r[2],optional:!0,rest:!1,chained:!0}),`(?:/([^/]+))?`;if(!e)return;let i=e.split(/\[(.+?)\](?!\])/);return`/`+i.map((e,n)=>{if(n%2){if(e.startsWith(`x+`))return se(String.fromCharCode(parseInt(e.slice(2),16)));if(e.startsWith(`u+`))return se(String.fromCharCode(...e.slice(2).split(`-`).map(e=>parseInt(e,16))));let[,r,a,o,s]=ne.exec(e);return t.push({name:o,matcher:s,optional:!!r,rest:!!a,chained:a?n===1&&i[0]===``:!1}),a?`([^]*?)`:r?`([^/]*)?`:`([^/]+?)`}return se(e)}).join(``)}).join(``)}/?$`),params:t}}function ie(e){return e!==``&&!/^\([^)]+\)$/.test(e)}function ae(e){return e.slice(1).split(`/`).filter(ie)}function oe(e,t,n){let r={},i=e.slice(1),a=i.filter(e=>e!==void 0),o=0;for(let e=0;e<t.length;e+=1){let s=t[e],c=i[e-o];if(s.chained&&s.rest&&o&&(c=i.slice(e-o,e+1).filter(e=>e).join(`/`),o=0),c===void 0)if(s.rest)c=``;else continue;if(!s.matcher||n[s.matcher](c)){r[s.name]=c;let n=t[e+1],l=i[e+1];n&&!n.rest&&n.optional&&l&&s.chained&&(o=0),!n&&!l&&Object.keys(r).length===a.length&&(o=0);continue}if(s.optional&&s.chained){o++;continue}return}if(!o)return r}function se(e){return e.normalize().replace(/[[\]]/g,`\\$&`).replace(/%/g,`%25`).replace(/\//g,`%2[Ff]`).replace(/\?/g,`%3[Ff]`).replace(/#/g,`%23`).replace(/[.*+?^${}()|\\]/g,`\\$&`)}function ce({nodes:e,server_loads:t,dictionary:n,matchers:r}){let i=new Set(t);return Object.entries(n).map(([t,[n,i,s]])=>{let{pattern:c,params:l}=re(t),u={id:t,exec:e=>{let t=c.exec(e);if(t)return oe(t,l,r)},errors:[1,...s||[]].map(t=>e[t]),layouts:[0,...i||[]].map(o),leaf:a(n)};return u.errors.length=u.layouts.length=Math.max(u.errors.length,u.layouts.length),u});function a(t){let n=t<0;return n&&(t=~t),[n,e[t]]}function o(t){return t===void 0?t:[i.has(t),e[t]]}}function le(e,t=JSON.parse){try{return t(sessionStorage[e])}catch{}}function ue(e,t,n=JSON.stringify){let r=n(t);try{sessionStorage[e]=r}catch{}}var x=globalThis.__sveltekit_1otbek3?.base??``,de=globalThis.__sveltekit_1otbek3?.assets??x??``,fe=`sveltekit:snapshot`,pe=`sveltekit:scroll`,me=`sveltekit:states`,S=`sveltekit:history`,C=`sveltekit:navigation`,w={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},he=location.origin;function ge(e){if(e instanceof URL)return e;let t=document.baseURI;if(!t){let e=document.getElementsByTagName(`base`);t=e.length?e[0].href:document.URL}return new URL(e,t)}function T(){return{x:pageXOffset,y:pageYOffset}}function E(e,t){return e.getAttribute(`data-sveltekit-${t}`)}var _e={...w,"":w.hover};function ve(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11&&(t=t.host),t}function ye(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()===`A`&&e.hasAttribute(`href`))return e;e=ve(e)}}function be(e,t,n){let r;try{if(r=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){let e=location.hash.split(`#`)[1]||`/`;r.hash=`#${e}${r.hash}`}}catch{}let i=e instanceof SVGAElement?e.target.baseVal:e.target,a=!r||!!i||we(r,t,n)||(e.getAttribute(`rel`)||``).split(/\s+/).includes(`external`),o=r?.origin===he&&e.hasAttribute(`download`);return{url:r,external:a,target:i,download:o}}function D(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=e;for(;s&&s!==document.documentElement;)r===null&&(r=E(s,`preload-code`)),i===null&&(i=E(s,`preload-data`)),t===null&&(t=E(s,`keepfocus`)),n===null&&(n=E(s,`noscroll`)),a===null&&(a=E(s,`reload`)),o===null&&(o=E(s,`replacestate`)),s=ve(s);function c(e){switch(e){case``:case`true`:return!0;case`off`:case`false`:return!1;default:return}}return{preload_code:_e[r??`off`],preload_data:_e[i??`off`],keepfocus:c(t),noscroll:c(n),reload:c(a),replace_state:c(o)}}function xe(e){let t=r(e),n=!0;function i(){n=!0,t.update(e=>e)}function a(e){n=!1,t.set(e)}function o(e){let r;return t.subscribe(t=>{(r===void 0||n&&t!==r)&&e(r=t)})}return{notify:i,set:a,subscribe:o}}var Se={v:()=>{}};function Ce(){let{set:e,subscribe:t}=r(!1);async function n(){clearTimeout(void 0);try{let t=await fetch(`${de}/_app/version.json`,{headers:{pragma:`no-cache`,"cache-control":`no-cache`}});if(!t.ok)return!1;let n=(await t.json()).version!==c;return n&&(e(!0),Se.v(),clearTimeout(void 0)),n}catch{return!1}}return{subscribe:t,check:n}}function we(e,t,n){return e.origin!==he||!e.pathname.startsWith(t)?!0:n?e.pathname!==location.pathname:!1}function Te(e){}var Ee=new Set([`load`,`prerender`,`csr`,`ssr`,`trailingSlash`,`config`]);new Set([...Ee,`entries`]);var De=new Set([...Ee]);new Set([...De,`actions`,`entries`]);function Oe(e){return e.filter(e=>e!=null)}function ke(e){return e instanceof l||e instanceof d?e.status:500}function Ae(e){return e instanceof d?e.text:`Internal Error`}var O,k,A,je=i.toString().includes(`$$`)||/function \w+\(\) \{\}/.test(i.toString()),Me=`a:`;je?(O={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL(Me)},k={current:null},A={current:!1}):(O=new class{#e=a({});get data(){return e(this.#e)}set data(e){s(this.#e,e)}#t=a(null);get form(){return e(this.#t)}set form(e){s(this.#t,e)}#n=a(null);get error(){return e(this.#n)}set error(e){s(this.#n,e)}#r=a({});get params(){return e(this.#r)}set params(e){s(this.#r,e)}#i=a({id:null});get route(){return e(this.#i)}set route(e){s(this.#i,e)}#a=a({});get state(){return e(this.#a)}set state(e){s(this.#a,e)}#o=a(-1);get status(){return e(this.#o)}set status(e){s(this.#o,e)}#s=a(new URL(Me));get url(){return e(this.#s)}set url(e){s(this.#s,e)}},k=new class{#e=a(null);get current(){return e(this.#e)}set current(e){s(this.#e,e)}},A=new class{#e=a(!1);get current(){return e(this.#e)}set current(e){s(this.#e,e)}},Se.v=()=>A.current=!0);function Ne(e){Object.assign(O,e)}var{onMount:Pe,tick:Fe}=o,Ie=new Set([`icon`,`shortcut icon`,`apple-touch-icon`]),j=null,M=le(`sveltekit:scroll`)??{},N=le(`sveltekit:snapshot`)??{},P={url:xe({}),page:xe({}),navigating:r(null),updated:Ce()};function Le(e){M[e]=T()}function Re(e,t){let n=e+1;for(;M[n];)delete M[n],n+=1;for(n=t+1;N[n];)delete N[n],n+=1}function F(e,t=!1){return t?location.replace(e.href):location.href=e.href,new Promise(()=>{})}async function ze(){if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistration(x||`/`);e&&await e.update()}}function Be(){}var Ve,He,I,L,Ue,R,z=[],B=[],V=null;function H(){V?.fork?.then(e=>e?.discard()),V=null}var U=new Map,We=new Set,Ge=new Set,W=new Set,G={branch:[],error:null,url:null,nav:null},Ke=!1,K=!1,qe=!0,q=!1,J=!1,Je=!1,Ye=!1,Xe,Y,X,Z,Ze=new Set,Qe=new Map;async function $e(e,t,n){globalThis.__sveltekit_1otbek3&&(globalThis.__sveltekit_1otbek3.query,globalThis.__sveltekit_1otbek3.prerender),document.URL!==location.href&&(location.href=location.href),R=e,await e.hooks.init?.(),Ve=ce(e),L=document.documentElement,Ue=t,He=e.nodes[0],I=e.nodes[1],He(),I(),Y=history.state?.[S],X=history.state?.[C],Y||(Y=X=Date.now(),history.replaceState({...history.state,[S]:Y,[C]:X},``));let r=M[Y];function i(){r&&(history.scrollRestoration=`manual`,scrollTo(r.x,r.y))}n?(i(),await Dt(Ue,n)):(await Q({type:`enter`,url:ge(R.hash?Nt(new URL(location.href)):location.href),replace_state:!0}),i()),Et()}function et(){z.length=0,Ye=!1}function tt(e){B.some(e=>e?.snapshot)&&(N[e]=B.map(e=>e?.snapshot?.capture()))}function nt(e){N[e]?.forEach((e,t)=>{B[t]?.snapshot?.restore(e)})}function rt(){Le(Y),ue(pe,M),tt(X),ue(fe,N)}async function it(e,n,r,i){let a;n.invalidateAll&&H(),await Q({type:`goto`,url:ge(e),keepfocus:n.keepFocus,noscroll:n.noScroll,replace_state:n.replaceState,state:n.state,redirect_count:r,nav_token:i,accept:()=>{n.invalidateAll&&(Ye=!0,a=[],Qe.forEach((e,t)=>{for(let n of e.keys())a.push(t+`/`+n)})),n.invalidate&&n.invalidate.forEach(Tt)}}),n.invalidateAll&&t().then(t).then(()=>{Qe.forEach((e,t)=>{e.forEach(({resource:e},n)=>{a?.includes(t+`/`+n)&&e.refresh?.()})})})}async function at(e){if(e.id!==V?.id){H();let t={};Ze.add(t),V={id:e.id,token:t,promise:ht({...e,preload:t}).then(e=>(Ze.delete(t),e.type===`loaded`&&e.state.error&&H(),e)),fork:null}}return V.promise}async function ot(e){let t=(await yt(e,!1))?.route;t&&await Promise.all([...t.layouts,t.leaf].filter(Boolean).map(e=>e[1]()))}async function st(e,t,n){let r={params:G.params,route:{id:G.route?.id??null},url:new URL(location.href)};G={...e.state,nav:r};let i=document.querySelector(`style[data-sveltekit]`);if(i&&i.remove(),Object.assign(O,e.props.page),Xe=new R.root({target:t,props:{...e.props,stores:P,components:B},hydrate:n,sync:!1,transformError:void 0}),await Promise.resolve(),nt(X),n){let e={from:null,to:{...r,scroll:M[Y]??T()},willUnload:!1,type:`enter`,complete:Promise.resolve()};W.forEach(t=>t(e))}K=!0}async function ct({url:e,params:t,branch:n,errors:r,status:i,error:a,route:o,form:s}){let c=`never`;if(x&&(e.pathname===x||e.pathname===x+`/`))c=`always`;else for(let e of n)e?.slash!==void 0&&(c=e.slash);e.pathname=f(e.pathname,c),e.search=e.search;let l={type:`loaded`,state:{url:e,params:t,branch:n,error:a,route:o},props:{constructors:Oe(n).map(e=>e.node.component),page:Mt(O)}};s!==void 0&&(l.props.form=s);let u={},d=!O,p=0;for(let e=0;e<Math.max(n.length,G.branch.length);e+=1){let t=n[e],r=G.branch[e];t?.data!==r?.data&&(d=!0),t&&(u={...u,...t.data},d&&(l.props[`data_${p}`]=u),p+=1)}return(!G.url||e.href!==G.url.href||G.error!==a||s!==void 0&&s!==O.form||d)&&(l.props.page={error:a,params:t,route:{id:o?.id??null},state:{},status:i,url:new URL(e),form:s??null,data:d?u:O.data}),l}async function lt({loader:e,parent:t,url:n,params:r,route:i,server_data_node:a}){let o={dependencies:new Set,params:new Set,parent:!1,route:!1,url:!1,search_params:new Set},s=await e();return{node:s,loader:e,server:a,universal:s.universal?.load?{type:`data`,data:null,uses:o}:null,data:a?.data??null,slash:s.universal?.trailingSlash??a?.slash}}function ut(e,t,n){let r=e instanceof Request?e.url:e,i=new URL(r,n);return i.origin===n.origin&&(r=i.href.slice(n.origin.length)),{resolved:i,promise:K?y(r,i.href,t):v(r,t)}}function dt(e,t,n,r,i,a){if(Ye)return!0;if(!i)return!1;if(i.parent&&e||i.route&&t||i.url&&n)return!0;for(let e of i.search_params)if(r.has(e))return!0;for(let e of i.params)if(a[e]!==G.params[e])return!0;for(let e of i.dependencies)if(z.some(t=>t(new URL(e))))return!0;return!1}function ft(e,t){return e?.type===`data`?e:e?.type===`skip`?t??null:null}function pt(e,t){if(!e)return new Set(t.searchParams.keys());let n=new Set([...e.searchParams.keys(),...t.searchParams.keys()]);for(let r of n){let i=e.searchParams.getAll(r),a=t.searchParams.getAll(r);i.every(e=>a.includes(e))&&a.every(e=>i.includes(e))&&n.delete(r)}return n}function mt({error:e,url:t,route:n,params:r}){return{type:`loaded`,state:{error:e,url:t,route:n,params:r,branch:[]},props:{page:Mt(O),constructors:[]}}}async function ht({id:e,invalidating:t,url:n,params:r,route:i,preload:a}){if(V?.id===e)return Ze.delete(V.token),V.promise;let{errors:o,layouts:s,leaf:c}=i,d=[...s,c];o.forEach(e=>e?.().catch(()=>{})),d.forEach(e=>e?.[1]().catch(()=>{}));let f=G.url?e!==xt(G.url):!1,p=G.route?i.id!==G.route.id:!1,ee=pt(G.url,n),m=!1,h=d.map(async(e,t)=>{if(!e)return;let a=G.branch[t];return e[1]===a?.loader&&!dt(m,p,f,ee,a.universal?.uses,r)?a:(m=!0,lt({loader:e[1],url:n,params:r,route:i,parent:async()=>{let e={};for(let n=0;n<t;n+=1)Object.assign(e,(await h[n])?.data);return e},server_data_node:ft(e[0]?{type:`skip`}:null,e[0]?a?.server:void 0)}))});for(let e of h)e.catch(()=>{});let g=[];for(let e=0;e<d.length;e+=1)if(d[e])try{g.push(await h[e])}catch(t){if(t instanceof u)return{type:`redirect`,location:t.location};if(Ze.has(a))return mt({error:await $(t,{params:r,url:n,route:{id:i.id}}),url:n,params:r,route:i});let s=ke(t),c;if((void 0)?.includes(t))s=t.status??s,c=t.error;else if(t instanceof l)c=t.body;else{if(await P.updated.check())return await ze(),await F(n);c=await $(t,{params:r,url:n,route:{id:i.id}})}let d=await gt(e,g,o);return d?ct({url:n,params:r,branch:g.slice(0,d.idx).concat(d.node),errors:o,status:s,error:c,route:i}):await Ct(n,{id:i.id},c,s)}else g.push(void 0);return ct({url:n,params:r,branch:g,errors:o,status:200,error:null,route:i,form:t?void 0:null})}async function gt(e,t,n){for(;e--;)if(n[e]){let r=e;for(;!t[r];)--r;try{return{idx:r+1,node:{node:await n[e](),loader:n[e],data:{},server:null,universal:null}}}catch{continue}}}async function _t({status:e,error:t,url:n,route:r}){let i={};try{return ct({url:n,params:i,branch:[await lt({loader:He,url:n,params:i,route:r,parent:()=>Promise.resolve({}),server_data_node:ft(null)}),{node:await I(),loader:I,universal:null,server:null,data:null}],status:e,error:t,errors:[],route:null})}catch(e){if(e instanceof u)return it(new URL(e.location,location.href),{},0);throw e}}async function vt(e){let t=e.href;if(U.has(t))return U.get(t);let n;try{let r=(async()=>{let t=await R.hooks.reroute({url:new URL(e),fetch:async(t,n)=>ut(t,n,e).promise})??e;if(typeof t==`string`){let n=new URL(e);R.hash?n.hash=t:n.pathname=t,t=n}return t})();U.set(t,r),n=await r}catch{U.delete(t);return}return n}async function yt(e,t){if(e&&!we(e,x,R.hash)){let n=await vt(e);if(!n)return;let r=bt(n);for(let n of Ve){let i=n.exec(r);if(i)return{id:xt(e),invalidating:t,route:n,params:ee(i),url:e}}}}function bt(e){return p(R.hash?e.hash.replace(/^#/,``).replace(/[?#].+/,``):e.pathname.slice(x.length))||`/`}function xt(e){return(R.hash?e.hash.replace(/^#/,``):e.pathname)+e.search}function St({url:e,type:t,intent:n,delta:r,event:i,scroll:a}){let o=!1,s=jt(G,n,e,t,a??null);r!==void 0&&(s.navigation.delta=r),i!==void 0&&(s.navigation.event=i);let c={...s.navigation,cancel:()=>{o=!0,s.reject(Error(`navigation cancelled`))}};return q||We.forEach(e=>e(c)),o?null:s}async function Q({type:e,url:r,popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c={},redirect_count:l=0,nav_token:u={},accept:f=Be,block:p=Be,event:ee}){let m=Z;Z=u;let h=await yt(r,!1),g=e===`enter`?jt(G,h,r,e):St({url:r,type:e,delta:i?.delta,intent:h,scroll:i?.scroll,event:ee});if(!g){p(),Z===u&&(Z=m);return}let te=Y,_=X;f(),q=!0,K&&g.navigation.type!==`enter`&&P.navigating.set(k.current=g.navigation);let v=h&&await ht(h);if(!v){if(we(r,x,R.hash))return await F(r,s);v=await Ct(r,{id:null},await $(new d(404,`Not Found`,`Not found: ${r.pathname}`),{url:r,params:{},route:{id:null}}),404,s)}if(r=h?.url||r,Z!==u)return g.reject(Error(`navigation aborted`)),!1;if(v.type===`redirect`){if(l<20){await Q({type:e,url:new URL(v.location,r),popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c,redirect_count:l+1,nav_token:u}),g.fulfil(void 0);return}v=await _t({status:500,error:await $(Error(`Redirect loop`),{url:r,params:{},route:{id:null}}),url:r,route:{id:null}})}else v.props.page.status>=400&&await P.updated.check()&&(await ze(),await F(r,s));if(et(),Le(te),tt(_),v.props.page.url.pathname!==r.pathname&&(r.pathname=v.props.page.url.pathname),c=i?i.state:c,!i){let e=s?0:1,t={[S]:Y+=e,[C]:X+=e,[me]:c};(s?history.replaceState:history.pushState).call(history,t,``,r),s||Re(Y,X)}let y=h&&V?.id===h.id?V.fork:null;V?.fork&&!y&&H(),V=null,v.props.page.state=c;let b;if(K){let e=(await Promise.all(Array.from(Ge,e=>e(g.navigation)))).filter(e=>typeof e==`function`);if(e.length>0){function t(){e.forEach(e=>{W.delete(e)})}e.push(t),e.forEach(e=>{W.add(e)})}let t=g.navigation.to;G={...v.state,nav:{params:t.params,route:t.route,url:t.url}},v.props.page&&(v.props.page.url=r);let i=y&&await y;i?b=i.commit():(j=null,Xe.$set(v.props),j&&Object.assign(v.props.page,j),Ne(v.props.page),b=n?.()),Je=!0}else await st(v,Ue,!1);let{activeElement:ne}=document;await b,await t(),await t();let re=null;if(qe){let e=i?i.scroll:o?T():null;e?scrollTo(e.x,e.y):(re=r.hash&&document.getElementById(Pt(r)))?re.scrollIntoView():scrollTo(0,0)}let ie=document.activeElement!==ne&&document.activeElement!==document.body;!a&&!ie&&At(r,!re),qe=!0,v.props.page&&(j&&Object.assign(v.props.page,j),Object.assign(O,v.props.page)),q=!1,e===`popstate`&&nt(X),g.fulfil(void 0),g.navigation.to&&(g.navigation.to.scroll=T()),W.forEach(e=>e(g.navigation)),P.navigating.set(k.current=null)}async function Ct(e,t,n,r,i){return e.origin===he&&e.pathname===location.pathname&&!Ke?await _t({status:r,error:n,url:e,route:t}):await F(e,i)}function wt(){let e,t={element:void 0,href:void 0},n;L.addEventListener(`mousemove`,t=>{let n=t.target;clearTimeout(e),e=setTimeout(()=>{a(n,w.hover)},20)});function r(e){e.defaultPrevented||a(e.composedPath()[0],w.tap)}L.addEventListener(`mousedown`,r),L.addEventListener(`touchstart`,r,{passive:!0});let i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(ot(new URL(t.target.href)),i.unobserve(t.target))},{threshold:0});async function a(e,r){let i=ye(e,L),a=i===t.element&&i?.href===t.href&&r>=n;if(!i||a)return;let{url:o,external:s,download:c}=be(i,x,R.hash);if(s||c)return;let l=D(i),u=o&&xt(G.url)===xt(o);if(!(l.reload||u))if(r<=l.preload_data){t={element:i,href:i.href},n=w.tap;let e=await yt(o,!1);if(!e)return;at(e)}else r<=l.preload_code&&(t={element:i,href:i.href},n=r,ot(o))}function o(){i.disconnect();for(let e of L.querySelectorAll(`a`)){let{url:t,external:n,download:r}=be(e,x,R.hash);if(n||r)continue;let a=D(e);a.reload||(a.preload_code===w.viewport&&i.observe(e),a.preload_code===w.eager&&ot(t))}}W.add(o),o()}function $(e,t){if(e instanceof l)return e.body;let n=ke(e),r=Ae(e);return R.hooks.handleError({error:e,event:t,status:n,message:r})??{message:r}}function Tt(e){if(typeof e==`function`)z.push(e);else{let{href:t}=new URL(e,location.href);z.push(e=>e.href===t)}}function Et(){history.scrollRestoration=`manual`,addEventListener(`beforeunload`,e=>{let t=!1;if(rt(),!q){let e=jt(G,void 0,null,`leave`),n={...e.navigation,cancel:()=>{t=!0,e.reject(Error(`navigation cancelled`))}};We.forEach(e=>e(n))}t?(e.preventDefault(),e.returnValue=``):history.scrollRestoration=`auto`}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&rt()}),navigator.connection?.saveData||wt(),L.addEventListener(`click`,async t=>{if(t.button||t.which!==1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.defaultPrevented)return;let n=ye(t.composedPath()[0],L);if(!n)return;let{url:r,external:i,target:a,download:o}=be(n,x,R.hash);if(!r)return;if(a===`_parent`||a===`_top`){if(window.parent!==window)return}else if(a&&a!==`_self`)return;let s=D(n);if(!(n instanceof SVGAElement)&&r.protocol!==location.protocol&&!(r.protocol===`https:`||r.protocol===`http:`)||o)return;let[c,l]=(R.hash?r.hash.replace(/^#/,``):r.href).split(`#`),u=c===m(location);if(i||s.reload&&(!u||!l)){St({url:r,type:`link`,event:t})?q=!0:t.preventDefault();return}if(l!==void 0&&u){let[,i]=G.url.href.split(`#`);if(i===l){if(t.preventDefault(),l===``||l===`top`&&n.ownerDocument.getElementById(`top`)===null)scrollTo({top:0});else{let e=n.ownerDocument.getElementById(decodeURIComponent(l));e&&(e.scrollIntoView(),e.focus())}return}if(J=!0,Le(Y),e(r),!s.replace_state)return;J=!1}t.preventDefault(),await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,0)}),setTimeout(e,100)}),await Q({type:`link`,url:r,keepfocus:s.keepfocus,noscroll:s.noscroll,replace_state:s.replace_state??r.href===location.href,event:t})}),L.addEventListener(`submit`,e=>{if(e.defaultPrevented)return;let t=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if((n?.formTarget||t.target)===`_blank`||(n?.formMethod||t.method)!==`get`)return;let r=new URL(n?.hasAttribute(`formaction`)&&n?.formAction||t.action);if(we(r,x,!1))return;let i=e.target,a=D(i);if(a.reload)return;e.preventDefault(),e.stopPropagation();let o=new FormData(i,n);r.search=new URLSearchParams(o).toString(),Q({type:`form`,url:r,keepfocus:a.keepfocus,noscroll:a.noscroll,replace_state:a.replace_state??r.href===location.href,event:e})}),addEventListener(`popstate`,async t=>{if(!kt)if(t.state?.[`sveltekit:history`]){let n=t.state[S];if(Z={},n===Y)return;let r=M[n],i=t.state[`sveltekit:states`]??{},a=new URL(t.state[`sveltekit:pageurl`]??location.href),o=t.state[C],s=G.url?m(location)===m(G.url):!1;if(o===X&&(Je||s)){i!==O.state&&(O.state=i),e(a),M[Y]=T(),r&&scrollTo(r.x,r.y),Y=n;return}let c=n-Y;await Q({type:`popstate`,url:a,popped:{state:i,scroll:r,delta:c},accept:()=>{Y=n,X=o},block:()=>{history.go(-c)},nav_token:Z,event:t})}else J||(e(new URL(location.href)),R.hash&&location.reload())}),addEventListener(`hashchange`,()=>{J&&(J=!1,history.replaceState({...history.state,[S]:++Y,[C]:X},``,location.href))});for(let e of document.querySelectorAll(`link`))Ie.has(e.rel)&&(e.href=e.href);addEventListener(`pageshow`,e=>{e.persisted&&P.navigating.set(k.current=null)});function e(e){G.url=O.url=e,P.page.set(Mt(O)),P.page.notify()}}async function Dt(e,{status:t=200,error:n,node_ids:r,params:i,route:a,server_route:o,data:s,form:c}){Ke=!0;let l=new URL(location.href),d;({params:i={},route:a={id:null}}=await yt(l,!1)||{}),d=Ve.find(({id:e})=>e===a.id);let f,p=!0;try{let e=r.map(async(t,n)=>{let r=s[n];return r?.uses&&(r.uses=Ot(r.uses)),lt({loader:R.nodes[t],url:l,params:i,route:a,parent:async()=>{let t={};for(let r=0;r<n;r+=1)Object.assign(t,(await e[r]).data);return t},server_data_node:ft(r)})}),o=await Promise.all(e);if(d){let e=d.layouts;for(let t=0;t<e.length;t++)e[t]||o.splice(t,0,void 0)}f=await ct({url:l,params:i,branch:o,status:t,error:n,errors:d?.errors,form:c,route:d??null})}catch(t){if(t instanceof u){await F(new URL(t.location,location.href));return}f=await _t({status:ke(t),error:await $(t,{url:l,params:i,route:a}),url:l,route:a}),e.textContent=``,p=!1}f.props.page&&(f.props.page.state={}),await st(f,e,p)}function Ot(e){return{dependencies:new Set(e?.dependencies??[]),params:new Set(e?.params??[]),parent:!!e?.parent,route:!!e?.route,url:!!e?.url,search_params:new Set(e?.search_params??[])}}var kt=!1;function At(e,t=!0){let n=document.querySelector(`[autofocus]`);if(n)n.focus();else{let n=Pt(e);if(n&&document.getElementById(n)){let{x:r,y:i}=T();setTimeout(()=>{let a=history.state;kt=!0,location.replace(new URL(`#${n}`,location.href)),history.replaceState(a,``,e),t&&scrollTo(r,i),kt=!1})}else{let e=document.body,t=e.getAttribute(`tabindex`);e.tabIndex=-1,e.focus({preventScroll:!0,focusVisible:!1}),t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t)}let r=getSelection();if(r&&r.type!==`None`){let e=[];for(let t=0;t<r.rangeCount;t+=1)e.push(r.getRangeAt(t));setTimeout(()=>{if(r.rangeCount===e.length){for(let t=0;t<r.rangeCount;t+=1){let n=e[t],i=r.getRangeAt(t);if(n.commonAncestorContainer!==i.commonAncestorContainer||n.startContainer!==i.startContainer||n.endContainer!==i.endContainer||n.startOffset!==i.startOffset||n.endOffset!==i.endOffset)return}r.removeAllRanges()}})}}}function jt(e,t,n,r,i=null){let a,o,s=new Promise((e,t)=>{a=e,o=t});return s.catch(()=>{}),{navigation:{from:{params:e.params,route:{id:e.route?.id??null},url:e.url,scroll:T()},to:n&&{params:t?.params??null,route:{id:t?.route?.id??null},url:n,scroll:i},willUnload:!t,type:r,complete:s},fulfil:a,reject:o}}function Mt(e){return{data:e.data,error:e.error,form:e.form,params:e.params,route:e.route,state:e.state,status:e.status,url:e.url}}function Nt(e){let t=new URL(e);return t.hash=decodeURIComponent(e.hash),t}function Pt(e){let t;if(R.hash){let[,,n]=e.hash.split(`#`,3);t=n??``}else t=e.hash.slice(1);return decodeURIComponent(t)}export{A as a,O as i,P as n,Te as o,k as r,$e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,W as n,et as r,nt as i,rt as a,tt as o}from"./BTSGQ0LP.js";import{t as s}from"./CnuZs6QA.js";var c=[`forEach`,`isDisjointFrom`,`isSubsetOf`,`isSupersetOf`],l=[`difference`,`intersection`,`symmetricDifference`,`union`],u=!1,d=class e extends Set{#e=new Map;#t=a(0);#n=a(0);#r=n||-1;constructor(e){if(super(),e){for(var t of e)super.add(t);this.#n.v=super.size}u||this.#a()}#i(e){return n===this.#r?a(e):i(e)}#a(){u=!0;var n=e.prototype,r=Set.prototype;for(let e of c)n[e]=function(...n){return t(this.#t),r[e].apply(this,n)};for(let i of l)n[i]=function(...n){return t(this.#t),new e(r[i].apply(this,n))}}has(e){var n=super.has(e),r=this.#e,i=r.get(e);if(i===void 0){if(!n)return t(this.#t),!1;i=this.#i(!0),r.set(e,i)}return t(i),n}add(e){return super.has(e)||(super.add(e),o(this.#n,super.size),r(this.#t)),this}delete(e){var t=super.delete(e),n=this.#e,i=n.get(e);return i!==void 0&&(n.delete(e),o(i,!1)),t&&(o(this.#n,super.size),r(this.#t)),t}clear(){if(super.size!==0){super.clear();var e=this.#e;for(var t of e.values())o(t,!1);e.clear(),o(this.#n,0),r(this.#t)}}keys(){return this.values()}values(){return t(this.#t),super.values()}entries(){return t(this.#t),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return t(this.#n)}},f=class extends Map{#e=new Map;#t=a(0);#n=a(0);#r=n||-1;constructor(e){if(super(),e){for(var[t,n]of e)super.set(t,n);this.#n.v=super.size}}#i(e){return n===this.#r?a(e):i(e)}has(e){var n=this.#e,r=n.get(e);if(r===void 0)if(super.has(e))r=this.#i(0),n.set(e,r);else return t(this.#t),!1;return t(r),!0}forEach(e,t){this.#a(),super.forEach(e,t)}get(e){var n=this.#e,r=n.get(e);if(r===void 0)if(super.has(e))r=this.#i(0),n.set(e,r);else{t(this.#t);return}return t(r),super.get(e)}set(e,t){var n=this.#e,i=n.get(e),a=super.get(e),s=super.set(e,t),c=this.#t;if(i===void 0)i=this.#i(0),n.set(e,i),o(this.#n,super.size),r(c);else if(a!==t){r(i);var l=c.reactions===null?null:new Set(c.reactions);(l===null||!i.reactions?.every(e=>l.has(e)))&&r(c)}return s}delete(e){var t=this.#e,n=t.get(e),i=super.delete(e);return n!==void 0&&(t.delete(e),o(n,-1)),i&&(o(this.#n,super.size),r(this.#t)),i}clear(){if(super.size!==0){super.clear();var e=this.#e;o(this.#n,0);for(var t of e.values())o(t,-1);r(this.#t),e.clear()}}#a(){t(this.#t);var e=this.#e;if(this.#n.v!==e.size){for(var n of super.keys())if(!e.has(n)){var r=this.#i(0);e.set(n,r)}}for([,r]of this.#e)t(r)}keys(){return t(this.#t),super.keys()}values(){return this.#a(),super.values()}entries(){return this.#a(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return t(this.#n),super.size}},p=`pimote:clientId`,m=`pimote:activeSessions`,h=`pimote:viewedSessionId`,g=`pimote:showArchived`,_=`pimote:sessionPillSwipeHintShown`;function v(){try{return localStorage.getItem(p)}catch{return null}}function y(e){try{localStorage.setItem(p,e)}catch{}}function b(){try{let e=localStorage.getItem(m);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.folderPath==`string`):[]}catch{return[]}}function x(e){try{localStorage.setItem(m,JSON.stringify(e))}catch{}}function S(){try{return localStorage.getItem(h)}catch{return null}}function C(e){try{e===null?localStorage.removeItem(h):localStorage.setItem(h,e)}catch{}}function w(){try{return localStorage.getItem(g)===`true`}catch{return!1}}function T(e){try{localStorage.setItem(g,String(e))}catch{}}function E(){try{return localStorage.getItem(_)===`true`}catch{return!1}}function D(e){try{localStorage.setItem(_,String(e))}catch{}}var O=1,k=v()??(()=>{let e=crypto.randomUUID();return y(e),e})(),A=new class{clientId=k;#e=a(`disconnected`);get status(){return t(this.#e)}set status(e){o(this.#e,e,!0)}#t=a(!1);get ready(){return t(this.#t)}set ready(e){o(this.#t,e,!0)}#n=a(`idle`);get phase(){return t(this.#n)}set phase(e){o(this.#n,e,!0)}#r=a(0);get reconnectCountdown(){return t(this.#r)}set reconnectCountdown(e){o(this.#r,e,!0)}#i=a(null);get syncProgress(){return t(this.#i)}set syncProgress(e){o(this.#i,e,!0)}#a=a(null);get syncDetail(){return t(this.#a)}set syncDetail(e){o(this.#a,e,!0)}sessionCursors=new Map;#o=a(e(new f));get subscribedSessions(){return t(this.#o)}set subscribedSessions(e){o(this.#o,e,!0)}ws=null;pending=new Map;listeners=new Set;reconnectTimer=null;countdownInterval=null;reconnectDelay=1e3;intentionalClose=!1;onReconnected=null;onSessionOwned=null;onPendingAdopt=null;pendingAdopt=null;connect(){if(this.ws&&(this.ws.readyState===WebSocket.CONNECTING||this.ws.readyState===WebSocket.OPEN))return;this.ready=!1,this.clearCountdownInterval(),this.phase=`connecting`,this.status=this.status===`disconnected`?`connecting`:`reconnecting`,this.syncDetail=null;let e=location.protocol===`https:`?`wss:`:`ws:`;this.ws=new WebSocket(`${e}//${location.host}/ws?clientId=${k}&version=${encodeURIComponent(s)}`),this.ws.onopen=()=>{this.status=`connected`,this.reconnectDelay=1e3;let e=this.subscribedSessions.size;e>0&&(this.phase=`syncing`,this.syncProgress={done:0,total:e},this.syncDetail=`Restoring sessions`);let t=[];for(let[n,r]of this.subscribedSessions){let i=this.sessionCursors.get(n),a=this.send({type:`open_session`,folderPath:r,sessionId:n,...i===void 0?{}:{lastCursor:i}}).then(t=>{if(!t.success){t.error===`session_owned`?this.onSessionOwned?.(n):console.warn(`[ConnectionStore] Failed to restore session ${n}: ${t.error??`unknown error`}`);return}let r=t.data;this.phase===`syncing`&&(this.syncDetail=this.labelForRestoreMode(r?.restoreMode,e))}).catch(()=>{}).finally(()=>{this.syncProgress&&={done:this.syncProgress.done+1,total:this.syncProgress.total}});t.push(a)}Promise.all(t).then(()=>{if(this.ready=!0,this.phase=`ready`,this.syncProgress=null,this.syncDetail=null,this.onReconnected?.(),this.pendingAdopt){let{sessionId:e,folderPath:t}=this.pendingAdopt;this.pendingAdopt=null,this.onPendingAdopt?.(e,t)}}),this.reregisterPushSubscription()},this.ws.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(`type`in t&&t.type===`version_mismatch`){console.log(`[ConnectionStore] Version mismatch — reloading (server=${t.serverVersion}, client=${s})`),location.reload();return}if(`id`in t&&`success`in t){let e=t,n=this.pending.get(e.id);n&&(this.pending.delete(e.id),n.resolve(e));return}let n=t;if(n.type===`buffered_events`&&`events`in n&&`sessionId`in n){let e=n,t=this.sessionCursors.get(e.sessionId)??0;for(let n of e.events)typeof n.cursor==`number`&&n.cursor>t&&(t=n.cursor);this.sessionCursors.set(e.sessionId,t)}else `cursor`in n&&typeof n.cursor==`number`&&`sessionId`in n&&typeof n.sessionId==`string`&&this.sessionCursors.set(n.sessionId,n.cursor);for(let e of this.listeners)try{e(n)}catch(e){console.error(`[ConnectionStore] Event listener error:`,e)}},this.ws.onclose=()=>{this.ws=null,this.ready=!1;for(let[,e]of this.pending)e.reject(Error(`WebSocket closed`));this.pending.clear(),this.intentionalClose?(this.status=`disconnected`,this.phase=`idle`,this.syncDetail=null,this.intentionalClose=!1):(this.status=`reconnecting`,this.scheduleReconnect())},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.clearCountdownInterval(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.ws?.close()}addSubscribedSession(e,t){this.subscribedSessions.set(e,t)}removeSubscribedSession(e){this.subscribedSessions.delete(e),this.sessionCursors.delete(e)}send(e){let t=e.id??`cmd-${O++}`,n={...e,id:t};return new Promise((e,r)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){r(Error(`WebSocket not connected`));return}this.pending.set(t,{resolve:e,reject:r}),this.ws.send(JSON.stringify(n))})}onEvent(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async reregisterPushSubscription(){try{if(!(`serviceWorker`in navigator)||!(`PushManager`in window)||Notification.permission!==`granted`)return;let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!e)return;let t=e.toJSON();if(!t.endpoint||!t.keys?.p256dh||!t.keys?.auth)return;await this.send({type:`register_push`,subscription:{endpoint:t.endpoint,keys:{p256dh:t.keys.p256dh,auth:t.keys.auth}}})}catch{}}clearCountdownInterval(){this.countdownInterval&&=(clearInterval(this.countdownInterval),null)}scheduleReconnect(){this.reconnectTimer||=(this.phase=`backoff`,this.syncDetail=null,this.reconnectCountdown=Math.ceil(this.reconnectDelay/1e3),this.clearCountdownInterval(),this.countdownInterval=setInterval(()=>{this.reconnectCountdown=Math.max(0,this.reconnectCountdown-1)},1e3),setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.connect()},this.reconnectDelay))}get phaseLabel(){return this.phase===`ready`?`Connected`:this.phase===`syncing`?this.syncProgress?`Syncing ${this.syncProgress.done}/${this.syncProgress.total}…`:`Syncing…`:this.phase===`connecting`?this.status===`reconnecting`?`Reconnecting…`:`Connecting…`:this.phase===`backoff`?`Reconnecting in ${this.reconnectCountdown}s`:`Disconnected`}labelForRestoreMode(e,t){if(t>1)switch(e){case`incremental_replay`:return`Replaying sessions from offset`;case`full_resync_cursor_stale`:return`Full resync (offset too old)`;case`disk_full_resync`:return`Reopening sessions from disk`;default:return`Full resync`}switch(e){case`incremental_replay`:return`Replaying from offset`;case`full_resync_cursor_stale`:return`Full resync (offset too old)`;case`disk_full_resync`:return`Reopening from disk`;default:return`Full resync`}}};function j(){let e=new f;return{getCommands(t){return e.get(t)??[]},setCommands(t,n){e.set(t,n)},removeSession(t){e.delete(t)},clear(){e.clear()}}}var M=j(),N=new class{#e=a(e([]));get cards(){return t(this.#e)}set cards(e){o(this.#e,e,!0)}get hasCards(){return this.cards.length>0}handlePanelUpdate(e){this.cards=e}reset(){this.cards=[]}},P=class{#e=a(e({}));get sessions(){return t(this.#e)}set sessions(e){o(this.#e,e,!0)}#t=a(null);get viewedSessionId(){return t(this.#t)}set viewedSessionId(e){o(this.#t,e,!0)}#n=a(null);get pendingNewSession(){return t(this.#n)}set pendingNewSession(e){o(this.#n,e,!0)}_nextMessageKey=0;generateMessageKeys(e){return Array.from({length:e},()=>`msg-`+ this._nextMessageKey++)}get viewed(){return this.sessions[this.viewedSessionId]??null}get activeSessions(){return Object.values(this.sessions)}createSessionState(e,t,n){return{sessionId:e,folderPath:t,projectName:n,firstMessage:void 0,messages:[],isStreaming:!1,isCompacting:!1,model:null,thinkingLevel:`off`,streamingMessage:null,streamingKey:null,messageKeys:[],toolExecutions:{},autoCompactionEnabled:!1,messageCount:0,status:`idle`,needsAttention:!1,conflictingProcesses:[],conflictingRemoteSessions:[],pendingTakeover:!1,sessionName:null,extensionTitle:null,restoreMode:null,isRestoring:!1,panelCards:[],widgetCards:{},gitBranch:null,contextUsage:null,draftText:``,pendingSteeringMessages:[],lastBotActivityTimestamp:null,optimisticMessageKey:null}}firstUserMessage(e){for(let t of e){if(t.role!==`user`)continue;let e=t.content.find(e=>e.type===`text`);if(e?.text)return e.text}}persistSessions(){x(Object.values(this.sessions).filter(e=>!e.sessionId.startsWith(`pending-`)).map(e=>({sessionId:e.sessionId,folderPath:e.folderPath})))}persistViewedSession(){this.viewedSessionId?.startsWith(`pending-`)||C(this.viewedSessionId)}addOptimisticUserMessage(e,t){let n=this.sessions[e];if(!n)return;let r=[];t&&r.push({type:`text`,text:t});let i={role:`user`,content:r},a=`msg-`+ this._nextMessageKey++;n.messages=[...n.messages,i],n.messageKeys=[...n.messageKeys,a],n.optimisticMessageKey=a}handleEvent(e){let t=`sessionId`in e?e.sessionId:void 0;if(e.type===`buffered_events`){let t=e;for(let e of t.events)this.handleEvent(e);return}if(!t)return;let n=this.sessions[t];if(n){switch(e.type){case`agent_start`:n.status=`working`,n.isStreaming=!0;break;case`agent_end`:n.status=`idle`,n.isStreaming=!1,t!==this.viewedSessionId&&(n.needsAttention=!0),A.send({type:`get_session_meta`,sessionId:t}).then(e=>{e.success&&e.data&&this.updateMeta(t,e.data.meta)}).catch(()=>{});break;case`message_start`:{let t=e;if(t.role===`user`&&n.optimisticMessageKey)break;n.streamingKey=`msg-`+ this._nextMessageKey++,n.streamingMessage={role:t.role,content:[]};break}case`message_update`:{let t=e;if(!n.streamingMessage)break;if(t.subtype===`start`){let e={type:t.content.type,text:``,streaming:!0};t.content.type===`tool_call`&&(e.toolCallId=t.toolCallId,e.toolName=t.toolName),n.streamingMessage.content[t.contentIndex]=e}else if(t.subtype===`delta`){let e=n.streamingMessage.content[t.contentIndex];e&&(e.text=(e.text??``)+t.content.text)}else if(t.subtype===`end`){let e=n.streamingMessage.content[t.contentIndex];e&&(e.streaming=!1)}break}case`message_end`:{let t=e.message;if(t.role===`user`&&n.optimisticMessageKey){let e=n.messageKeys.indexOf(n.optimisticMessageKey);if(e!==-1){let r=[...n.messages];r[e]=t,n.messages=r}n.optimisticMessageKey=null,n.streamingMessage=null,n.streamingKey=null}else n.messages=[...n.messages,t],n.streamingKey&&(n.messageKeys=[...n.messageKeys,n.streamingKey]),n.streamingMessage=null,n.streamingKey=null;if(n.messageCount++,t.role===`user`&&n.firstMessage===void 0){let e=t.content.find(e=>e.type===`text`);e&&e.text&&(n.firstMessage=e.text)}if(t.role===`user`&&n.pendingSteeringMessages.length>0){let e=t.content.find(e=>e.type===`text`);if(e?.text){let t=n.pendingSteeringMessages.indexOf(e.text);t!==-1&&n.pendingSteeringMessages.splice(t,1)}}t.role===`toolResult`&&this.applyToolResults(n,t);break}case`tool_execution_start`:{let t=e;n.toolExecutions[t.toolCallId]={name:t.toolName,args:t.args,partialResult:``,status:`running`};break}case`tool_execution_update`:{let t=e,r=n.toolExecutions[t.toolCallId];r&&(r.partialResult+=t.content);break}case`tool_execution_end`:{let t=e,r=n.toolExecutions[t.toolCallId];r&&(r.status=`completed`,r.result=t.result,r.isError=t.isError);break}case`auto_compaction_start`:n.isCompacting=!0;break;case`auto_compaction_end`:n.isCompacting=!1,A.send({type:`get_session_meta`,sessionId:t}).then(e=>{e.success&&e.data&&this.updateMeta(t,e.data.meta)}).catch(()=>{});break;case`full_resync`:{let r=e,i=r.state,a=r.messages,o=this.createSessionState(n.sessionId,n.folderPath,n.projectName);o.draftText=n.draftText,o.extensionTitle=n.extensionTitle,o.restoreMode=n.restoreMode,o.isRestoring=n.isRestoring,o.widgetCards=n.widgetCards,o.model=i.model,o.thinkingLevel=i.thinkingLevel,o.isStreaming=i.isStreaming,o.isCompacting=i.isCompacting,o.autoCompactionEnabled=i.autoCompactionEnabled,o.messageCount=i.messageCount,o.sessionName=i.sessionName??null,o.messages=a,o.firstMessage=this.firstUserMessage(a),o.status=i.isStreaming?`working`:`idle`,o.messageKeys=this.generateMessageKeys(a.length),this.rebuildToolExecutions(o),this.sessions[t]=o;break}case`session_restore`:{let t=e;n.restoreMode=t.status===`started`?t.mode:null,n.isRestoring=t.status===`started`;break}case`session_conflict`:{let t=e;n.conflictingProcesses=t.processes,n.conflictingRemoteSessions=t.remoteSessions??[];break}case`session_renamed`:n.sessionName=e.name;break;case`panel_update`:n.panelCards=e.cards,t===this.viewedSessionId&&this.syncViewedPanelStore();break}`timestamp`in e&&typeof e.timestamp==`string`&&(n.lastBotActivityTimestamp=e.timestamp)}}combinedPanelCards(e){return e?[...e.panelCards,...Object.values(e.widgetCards)]:[]}syncViewedPanelStore(){N.handlePanelUpdate(this.combinedPanelCards(this.viewed))}addSession(e,t,n){this.sessions[e]=this.createSessionState(e,t,n),this.persistSessions()}removeSession(e){let t=this.viewedSessionId===e,{[e]:n,...r}=this.sessions;if(this.sessions=r,t){let e=Object.keys(this.sessions);this.viewedSessionId=e.length>0?e[0]:null,this.syncViewedPanelStore()}this.persistSessions(),this.persistViewedSession()}replaceSession(e,t,n,r){let i=this.sessions[e];if(!i)return;let{[e]:a,...o}=this.sessions,s=this.createSessionState(t,n,r);s.model=i.model,s.thinkingLevel=i.thinkingLevel,s.autoCompactionEnabled=i.autoCompactionEnabled,s.gitBranch=i.gitBranch,o[t]=s,this.sessions=o,this.viewedSessionId===e&&(this.viewedSessionId=t,this.syncViewedPanelStore()),this.persistSessions(),this.persistViewedSession()}switchTo(e){this.viewedSessionId=e;let t=this.sessions[e];t&&(t.needsAttention=!1),this.syncViewedPanelStore(),this.persistViewedSession()}isActiveSession(e){return e in this.sessions}updateMeta(e,t){let n=this.sessions[e];n&&(n.gitBranch=t.gitBranch,n.contextUsage=t.contextUsage)}applyToolResults(e,t){for(let n of t.content)if(n.type===`tool_result`&&n.toolCallId){let t=e.toolExecutions[n.toolCallId];t?(t.status=`completed`,t.result=n.result):e.toolExecutions[n.toolCallId]={name:n.toolName??`unknown`,args:void 0,partialResult:``,status:`completed`,result:n.result}}}rebuildToolExecutions(e){e.toolExecutions={};for(let t of e.messages)t.role===`toolResult`&&this.applyToolResults(e,t)}clearConflict(e){let t=this.sessions[e];t&&(t.conflictingProcesses=[],t.conflictingRemoteSessions=[])}},F=new P;async function I(e){try{let[t,n,r,i]=await Promise.all([A.send({type:`get_state`,sessionId:e}),A.send({type:`get_messages`,sessionId:e}),A.send({type:`get_session_meta`,sessionId:e}),A.send({type:`get_commands`,sessionId:e})]),a=F.sessions[e];if(!a)return;if(t.success&&t.data){let e=t.data.state;a.model=e.model,a.thinkingLevel=e.thinkingLevel,a.isStreaming=e.isStreaming,a.isCompacting=e.isCompacting,a.autoCompactionEnabled=e.autoCompactionEnabled,a.messageCount=e.messageCount,a.sessionName=e.sessionName??null,a.status=e.isStreaming?`working`:`idle`}if(n.success&&n.data){let e=n.data.messages;a.messages=e,a.messageKeys=F.generateMessageKeys(e.length),a.messageCount=e.length,a.firstMessage=F.firstUserMessage(e),F.rebuildToolExecutions(a)}if(r.success&&r.data){let t=r.data.meta;F.updateMeta(e,t)}if(i.success&&i.data){let t=i.data.commands;M.setCommands(e,t)}}catch(e){console.error(`[SessionRegistry] Failed to fetch full session data:`,e)}}async function L(e){try{let[t,n]=await Promise.all([A.send({type:`get_session_meta`,sessionId:e}),A.send({type:`get_commands`,sessionId:e})]);if(t.success&&t.data&&F.updateMeta(e,t.data.meta),n.success&&n.data){let t=n.data.commands;M.setCommands(e,t)}}catch(e){console.error(`[SessionRegistry] Failed to refresh session meta/commands:`,e)}}async function R(e,t,n){let r=t.split(`/`).pop()||`Unknown`,i=n?.switchTo!==!1;F.sessions[e]||F.addSession(e,t,r),A.addSubscribedSession(e,t),i&&F.switchTo(e);try{let r=await A.send({type:`open_session`,folderPath:t,sessionId:e,...n?.force?{force:!0}:{}});if(!r.success){if(r.error===`session_owned`){let t=F.sessions[e];return t&&(t.pendingTakeover=!0),!1}return F.removeSession(e),A.removeSubscribedSession(e),M.removeSession(e),!1}return await L(e),i&&A.send({type:`view_session`,sessionId:e}).catch(()=>{}),!0}catch(t){return console.error(`[SessionRegistry] Failed to open existing session:`,t),F.removeSession(e),A.removeSubscribedSession(e),M.removeSession(e),!1}}A.onEvent(e=>{switch(e.type){case`session_opened`:{let t=e.folder,n=t?.name??`Unknown`,r=F.pendingNewSession;r&&F.sessions[r]?(F.pendingNewSession=null,F.replaceSession(r,e.sessionId,t?.path??``,n)):(F.addSession(e.sessionId,t?.path??``,n),F.switchTo(e.sessionId)),A.addSubscribedSession(e.sessionId,t?.path??``),I(e.sessionId);break}case`session_closed`:F.removeSession(e.sessionId),A.removeSubscribedSession(e.sessionId),M.removeSession(e.sessionId);break;case`session_replaced`:{let t=e,n=t.folder,r=n?.name??`Unknown`;F.replaceSession(t.oldSessionId,t.newSessionId,n?.path??``,r),A.removeSubscribedSession(t.oldSessionId),A.addSubscribedSession(t.newSessionId,n?.path??``),M.removeSession(t.oldSessionId),I(t.newSessionId);break}default:`sessionId`in e&&F.handleEvent(e);break}}),A.onSessionOwned=e=>{let t=F.sessions[e];t&&(t.pendingTakeover=!0)},A.onPendingAdopt=(e,t)=>{R(e,t,{force:!0,switchTo:!0})},A.onReconnected=()=>{for(let e of F.activeSessions)e.sessionId.startsWith(`pending-`)||L(e.sessionId);let e=F.viewedSessionId;e&&!e.startsWith(`pending-`)&&A.send({type:`view_session`,sessionId:e}).catch(()=>{})};var z=b(),B=S();for(let{sessionId:e,folderPath:t}of z){let n=t.split(`/`).pop()||`Unknown`;F.addSession(e,t,n),A.addSubscribedSession(e,t)}B&&F.sessions[B]&&(F.viewedSessionId=B);function V(e){let t=F.sessions[e];t&&(t.pendingTakeover=!1,R(e,t.folderPath,{force:!0,switchTo:!0}))}function H(e){F.removeSession(e),A.removeSubscribedSession(e)}function U(e){F.switchTo(e),A.send({type:`view_session`,sessionId:e}).catch(()=>{})}function W(e){A.send({type:`close_session`,sessionId:e}).catch(()=>{})}function G(e){let t=F.sessions[e];if(!t||F.pendingNewSession)return;let n=`pending-${crypto.randomUUID()}`;F.addSession(n,t.folderPath,t.projectName),F.switchTo(n),F.pendingNewSession=n,A.send({type:`open_session`,folderPath:t.folderPath}).then(e=>{e.success||(F.pendingNewSession===n&&(F.pendingNewSession=null),F.removeSession(n))}).catch(()=>{F.pendingNewSession===n&&(F.pendingNewSession=null),F.removeSession(n)})}export{d as _,G as a,U as c,A as d,E as f,f as g,T as h,H as i,N as l,D as m,W as n,R as o,w as p,V as r,F as s,P as t,M as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`1775570014702`;export{e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,o as t,s as n}from"./BTW4yCoz.js";export{t as openExistingSession,n as sessionRegistry,e as switchToSession};
|