@kubitnodes/stellaris 0.3.25 → 0.3.27
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/dist/cli/index.js +340 -131
- package/dist/server/index.js +818 -178
- package/package.json +1 -1
- package/web/dist/assets/{BackLink-UTiLF1J4.js → BackLink-qSxOMeEG.js} +1 -1
- package/web/dist/assets/{Button-Cp4cNRUX.js → Button-CxjWy598.js} +1 -1
- package/web/dist/assets/{ChannelForms-DD2B0tey.js → ChannelForms-BVidWMId.js} +1 -1
- package/web/dist/assets/{ChannelView-CY3oG9hZ.js → ChannelView-rqfk1Tyu.js} +1 -1
- package/web/dist/assets/{CitizenView-BNK5ro-6.js → CitizenView-xU99R8hS.js} +1 -1
- package/web/dist/assets/{CitizensView-WPQ6Jhl3.js → CitizensView-Bgw6PRSo.js} +1 -1
- package/web/dist/assets/{CliIcon-C7bwChMP.js → CliIcon-BB2NdLxN.js} +1 -1
- package/web/dist/assets/{CronsView-_pdgwX1I.js → CronsView-BrXrcfC6.js} +1 -1
- package/web/dist/assets/{FileTree-jyDUSu7g.js → FileTree-CHDmrOhY.js} +1 -1
- package/web/dist/assets/{FileView-DcQvlc8V.js → FileView-DUMfKYRW.js} +1 -1
- package/web/dist/assets/{KnowledgeView-DDl0HQPG.js → KnowledgeView-Qog6c92V.js} +1 -1
- package/web/dist/assets/{Markdown-DT3V-EVe.js → Markdown-C7RbUEZE.js} +1 -1
- package/web/dist/assets/{MessageItem-agtEugfG.js → MessageItem-DgWh5pJF.js} +1 -1
- package/web/dist/assets/{MetricsView-DiXyYeWP.js → MetricsView-DuOyISk1.js} +1 -1
- package/web/dist/assets/{NeedsYouView-CKmuYan_.js → NeedsYouView-CrmHXZAn.js} +1 -1
- package/web/dist/assets/{Overview-CKcTqsMM.js → Overview-xatORJK6.js} +1 -1
- package/web/dist/assets/{Pane-BaM0TdE6.js → Pane-BlIRwUtQ.js} +1 -1
- package/web/dist/assets/{Picker-C2ig-0dT.js → Picker-BSOB2JM_.js} +1 -1
- package/web/dist/assets/ProjectView-CVt28SoI.js +1 -0
- package/web/dist/assets/{ProposalView-B5yjTAcn.js → ProposalView-DJ0aJm7J.js} +1 -1
- package/web/dist/assets/{ProposalsView-p4KjwV9p.js → ProposalsView-C0r1ya8_.js} +1 -1
- package/web/dist/assets/{Quota-CfFGIql9.js → Quota-59QJZrPa.js} +1 -1
- package/web/dist/assets/{RunnersView-DdvwoOur.js → RunnersView-CcAAfw6y.js} +1 -1
- package/web/dist/assets/{SkillFileList-CgrCnuaC.js → SkillFileList-Cs_f3RPo.js} +1 -1
- package/web/dist/assets/{SkillView-Di5Z9h2L.js → SkillView-BvVx3LSL.js} +1 -1
- package/web/dist/assets/{SocietyView-BDiVxUC5.js → SocietyView-CJRrypjI.js} +1 -1
- package/web/dist/assets/{StickyList-BaV_KZ8x.js → StickyList-BbGq82Jj.js} +1 -1
- package/web/dist/assets/{SubjectThread-DD_ZCCnr.js → SubjectThread-DdkyhVqK.js} +1 -1
- package/web/dist/assets/{TaskView-CKcs-MOC.js → TaskView-CyEWpCvS.js} +1 -1
- package/web/dist/assets/{TasksView-oZMjncOU.js → TasksView-D10XP1uk.js} +1 -1
- package/web/dist/assets/{ThreadForms-CG5Y926b.js → ThreadForms-D94Jj0ES.js} +1 -1
- package/web/dist/assets/{ThreadItem-D-n2arFA.js → ThreadItem-CYmdCPOf.js} +1 -1
- package/web/dist/assets/{ThreadView-CT9vd0P4.js → ThreadView-D79G2zgF.js} +1 -1
- package/web/dist/assets/{citizen-BiHfph2A.js → citizen-CgA4vJjy.js} +1 -1
- package/web/dist/assets/{compose-DY1WL8zB.js → compose-3ksQaHF6.js} +1 -1
- package/web/dist/assets/format-DpQyO6r1.js +55 -0
- package/web/dist/assets/{governance-C6ez5MLh.js → governance-YialJVYK.js} +1 -1
- package/web/dist/assets/{index-CPXALUV6.js → index-DhuCp-VF.js} +3 -3
- package/web/dist/assets/{mentions-BEL5U6ra.js → mentions-Buc5vs-j.js} +1 -1
- package/web/dist/assets/{tasks-CAI8Eci7.js → tasks-DLTeaHys.js} +1 -1
- package/web/dist/assets/{useMatch-CINzyDWa.js → useMatch-DPEg8ohe.js} +1 -1
- package/web/dist/index.html +8 -8
- package/web/dist/assets/ProjectView-T2OHTh5j.js +0 -1
- package/web/dist/assets/format-CENiwkJC.js +0 -55
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChannelView-
|
|
2
|
-
import{$ as e,$t as t,An as n,At as r,Bn as i,Bt as a,Cn as o,Dn as s,E as c,En as l,F as u,Fn as d,Ft as f,Gn as p,Hn as m,I as h,In as g,It as _,J as v,Jt as y,K as b,Kt as ee,Ln as x,M as S,Mn as C,Mt as te,Nn as w,Nt as ne,On as re,Pn as ie,Q as ae,Qt as oe,S as se,T as ce,Un as le,V as ue,Vn as de,Wn as fe,X as pe,Xt as me,Y as he,Yt as ge,Z as _e,Zt as ve,_ as ye,_n as be,an as xe,at as Se,bn as Ce,bt as T,cn as E,ct as we,dn as Te,en as Ee,et as De,f as Oe,fn as D,gn as ke,gt as Ae,hn as je,i as Me,in as Ne,j as Pe,jn as Fe,jt as Ie,k as Le,kn as Re,l as ze,ln as Be,mn as Ve,n as He,nn as Ue,nt as We,on as Ge,ot as Ke,pn as qe,q as Je,qn as Ye,qt as Xe,r as Ze,rn as Qe,rt as $e,s as et,sn as tt,t as nt,tn as rt,tt as it,u as at,un as ot,ut as st,v as ct,vn as lt,x as ut,xn as dt,yn as ft,yt as pt,z as mt}from"./format-CENiwkJC.js";import{n as ht,r as gt,t as _t}from"./Button-Cp4cNRUX.js";import{i as vt,n as yt,r as bt,t as xt}from"./useMatch-CINzyDWa.js";import{i as St,n as Ct,r as wt,t as Tt}from"./compose-DY1WL8zB.js";import{n as Et,r as Dt,t as Ot}from"./CliIcon-C7bwChMP.js";import{a as kt,n as At,r as jt,s as Mt,t as Nt}from"./tasks-CAI8Eci7.js";import{a as Pt,d as Ft}from"./governance-C6ez5MLh.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var It=class extends Re{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new gt({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Lt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){s.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>w(t,e))}findAll(e={}){return this.getAll().filter(t=>w(e,t))}notify(e){s.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return s.batch(()=>Promise.all(e.map(e=>e.continue().catch(d))))}};function Lt(e){return e.options.scope?.id}var Rt=class extends Re{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??C(r,t),a=this.get(i);return a||(a=new o({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){s.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ie(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ie(e,t)):t}notify(e){s.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){s.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){s.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},zt=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Rt,this.#t=e.mutationCache||new It,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=re.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=l.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(x(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,r){let i=this.defaultQueryOptions({queryKey:e}),a=this.#e.get(i.queryHash)?.state.data,o=n(t,a);if(o!==void 0)return this.#e.build(this,i).setData(o,{...r,manual:!0})}setQueriesData(e,t,n){return s.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;s.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return s.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=s.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(d).catch(d)}invalidateQueries(e,t={}){return s.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=s.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(d)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(d)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(x(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(x(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(d).catch(d)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(d).catch(d)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return l.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Fe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{g(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Fe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{g(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=C(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===i&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Bt=p((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function ee(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,x||(x=!0,re());else{var t=n(l);t!==null&&oe(ee,t.startTime-e)}}}var x=!1,S=-1,C=5,te=-1;function w(){return g?!0:!(e.unstable_now()-te<C)}function ne(){if(g=!1,x){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(ee,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():x=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(ee,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,x||(x=!0,re()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Vt=p(((e,t)=>{t.exports=Bt()})),Ht=p((e=>{var t=fe();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),Ut=p(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ht()})),Wt=p((e=>{var t=Vt(),n=fe(),r=Ut();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function ee(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function x(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function S(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var C=Object.assign,te=Symbol.for(`react.element`),w=Symbol.for(`react.transitional.element`),ne=Symbol.for(`react.portal`),re=Symbol.for(`react.fragment`),ie=Symbol.for(`react.strict_mode`),ae=Symbol.for(`react.profiler`),oe=Symbol.for(`react.consumer`),se=Symbol.for(`react.context`),ce=Symbol.for(`react.forward_ref`),le=Symbol.for(`react.suspense`),ue=Symbol.for(`react.suspense_list`),de=Symbol.for(`react.memo`),pe=Symbol.for(`react.lazy`),me=Symbol.for(`react.activity`),he=Symbol.for(`react.legacy_hidden`),ge=Symbol.for(`react.memo_cache_sentinel`),_e=Symbol.for(`react.view_transition`),ve=Symbol.for(`react.recoverable`),ye=Symbol.iterator;function be(e){return typeof e!=`object`||!e?null:(e=ye&&e[ye]||e[`@@iterator`],typeof e==`function`?e:null)}var xe=Symbol.for(`react.client.reference`);function Se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===xe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case re:return`Fragment`;case ae:return`Profiler`;case ie:return`StrictMode`;case le:return`Suspense`;case ue:return`SuspenseList`;case me:return`Activity`;case _e:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ne:return`Portal`;case se:return e.displayName||`Context`;case oe:return(e._context.displayName||`Context`)+`.Consumer`;case ce:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case de:return t=e.displayName||null,t===null?Se(e.type)||`Memo`:t;case pe:t=e._payload,e=e._init;try{return Se(e(t))}catch{}}return null}var Ce=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,we={pending:!1,data:null,method:null,action:null},Te=[],Ee=-1;function De(e){return{current:e}}function Oe(e){0>Ee||(e.current=Te[Ee],Te[Ee]=null,Ee--)}function D(e,t){Ee++,Te[Ee]=e.current,e.current=t}var ke=De(null),Ae=De(null),je=De(null),Me=De(null);function Ne(e,t){switch(D(je,t),D(Ae,e),D(ke,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Oe(ke),D(ke,e)}function Pe(){Oe(ke),Oe(Ae),Oe(je)}function Fe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,D(Me,e)),t=ke.current;var n=dp(t,e.type);t!==n&&(D(Ae,e),D(ke,n))}function Ie(e){Ae.current===e&&(Oe(ke),Oe(Ae)),Me.current===e&&(Oe(Me),sh._currentValue=we)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1<e.stack.indexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChannelView-rqfk1Tyu.js","assets/format-DpQyO6r1.js","assets/Button-CxjWy598.js","assets/BackLink-qSxOMeEG.js","assets/ThreadForms-D94Jj0ES.js","assets/compose-3ksQaHF6.js","assets/mentions-Buc5vs-j.js","assets/ChannelForms-BVidWMId.js","assets/MessageItem-DgWh5pJF.js","assets/tasks-DLTeaHys.js","assets/Markdown-C7RbUEZE.js","assets/Pane-BlIRwUtQ.js","assets/StickyList-BbGq82Jj.js","assets/ThreadItem-CYmdCPOf.js","assets/ThreadView-D79G2zgF.js","assets/SocietyView-CJRrypjI.js","assets/Overview-xatORJK6.js","assets/CliIcon-BB2NdLxN.js","assets/citizen-CgA4vJjy.js","assets/ProjectView-CVt28SoI.js","assets/Picker-BSOB2JM_.js","assets/FileTree-CHDmrOhY.js","assets/KnowledgeView-Qog6c92V.js","assets/SkillView-BvVx3LSL.js","assets/governance-YialJVYK.js","assets/SkillFileList-Cs_f3RPo.js","assets/TasksView-D10XP1uk.js","assets/TaskView-CyEWpCvS.js","assets/SubjectThread-DdkyhVqK.js","assets/FileView-DUMfKYRW.js","assets/MetricsView-DuOyISk1.js","assets/CitizensView-Bgw6PRSo.js","assets/Quota-59QJZrPa.js","assets/NeedsYouView-CrmHXZAn.js","assets/RunnersView-CcAAfw6y.js","assets/CronsView-BrXrcfC6.js","assets/ProposalsView-C0r1ya8_.js","assets/ProposalView-DJ0aJm7J.js","assets/CitizenView-xU99R8hS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{$ as e,$t as t,An as n,At as r,Bn as i,Bt as a,Cn as o,Dn as s,E as c,En as l,F as u,Fn as d,Ft as f,Gn as p,Hn as m,I as h,In as g,It as _,J as v,Jt as y,K as b,Kt as ee,Ln as x,M as S,Mn as C,Mt as te,Nn as w,Nt as ne,On as re,Pn as ie,Q as ae,Qt as oe,S as se,T as ce,Un as le,V as ue,Vn as de,Wn as fe,X as pe,Xt as me,Y as he,Yt as ge,Z as _e,Zt as ve,_ as ye,_n as be,an as xe,at as Se,bn as Ce,bt as T,cn as E,ct as we,dn as Te,en as Ee,et as De,f as Oe,fn as D,gn as ke,gt as Ae,hn as je,i as Me,in as Ne,j as Pe,jn as Fe,jt as Ie,k as Le,kn as Re,l as ze,ln as Be,mn as Ve,n as He,nn as Ue,nt as We,on as Ge,ot as Ke,pn as qe,q as Je,qn as Ye,qt as Xe,r as Ze,rn as Qe,rt as $e,s as et,sn as tt,t as nt,tn as rt,tt as it,u as at,un as ot,ut as st,v as ct,vn as lt,x as ut,xn as dt,yn as ft,yt as pt,z as mt}from"./format-DpQyO6r1.js";import{n as ht,r as gt,t as _t}from"./Button-CxjWy598.js";import{i as vt,n as yt,r as bt,t as xt}from"./useMatch-DPEg8ohe.js";import{i as St,n as Ct,r as wt,t as Tt}from"./compose-3ksQaHF6.js";import{n as Et,r as Dt,t as Ot}from"./CliIcon-BB2NdLxN.js";import{a as kt,n as At,r as jt,s as Mt,t as Nt}from"./tasks-DLTeaHys.js";import{a as Pt,d as Ft}from"./governance-YialJVYK.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var It=class extends Re{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new gt({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Lt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Lt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){s.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>w(t,e))}findAll(e={}){return this.getAll().filter(t=>w(e,t))}notify(e){s.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return s.batch(()=>Promise.all(e.map(e=>e.continue().catch(d))))}};function Lt(e){return e.options.scope?.id}var Rt=class extends Re{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??C(r,t),a=this.get(i);return a||(a=new o({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){s.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ie(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ie(e,t)):t}notify(e){s.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){s.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){s.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},zt=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Rt,this.#t=e.mutationCache||new It,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=re.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=l.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(x(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,r){let i=this.defaultQueryOptions({queryKey:e}),a=this.#e.get(i.queryHash)?.state.data,o=n(t,a);if(o!==void 0)return this.#e.build(this,i).setData(o,{...r,manual:!0})}setQueriesData(e,t,n){return s.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;s.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return s.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=s.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(d).catch(d)}invalidateQueries(e,t={}){return s.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=s.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(d)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(d)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(x(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(x(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(d).catch(d)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(d).catch(d)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return l.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Fe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{g(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Fe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{g(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=C(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===i&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Bt=p((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function ee(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,x||(x=!0,re());else{var t=n(l);t!==null&&oe(ee,t.startTime-e)}}}var x=!1,S=-1,C=5,te=-1;function w(){return g?!0:!(e.unstable_now()-te<C)}function ne(){if(g=!1,x){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(ee,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():x=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(ee,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,x||(x=!0,re()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Vt=p(((e,t)=>{t.exports=Bt()})),Ht=p((e=>{var t=fe();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),Ut=p(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ht()})),Wt=p((e=>{var t=Vt(),n=fe(),r=Ut();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function ee(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function x(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function S(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var C=Object.assign,te=Symbol.for(`react.element`),w=Symbol.for(`react.transitional.element`),ne=Symbol.for(`react.portal`),re=Symbol.for(`react.fragment`),ie=Symbol.for(`react.strict_mode`),ae=Symbol.for(`react.profiler`),oe=Symbol.for(`react.consumer`),se=Symbol.for(`react.context`),ce=Symbol.for(`react.forward_ref`),le=Symbol.for(`react.suspense`),ue=Symbol.for(`react.suspense_list`),de=Symbol.for(`react.memo`),pe=Symbol.for(`react.lazy`),me=Symbol.for(`react.activity`),he=Symbol.for(`react.legacy_hidden`),ge=Symbol.for(`react.memo_cache_sentinel`),_e=Symbol.for(`react.view_transition`),ve=Symbol.for(`react.recoverable`),ye=Symbol.iterator;function be(e){return typeof e!=`object`||!e?null:(e=ye&&e[ye]||e[`@@iterator`],typeof e==`function`?e:null)}var xe=Symbol.for(`react.client.reference`);function Se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===xe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case re:return`Fragment`;case ae:return`Profiler`;case ie:return`StrictMode`;case le:return`Suspense`;case ue:return`SuspenseList`;case me:return`Activity`;case _e:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case ne:return`Portal`;case se:return e.displayName||`Context`;case oe:return(e._context.displayName||`Context`)+`.Consumer`;case ce:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case de:return t=e.displayName||null,t===null?Se(e.type)||`Memo`:t;case pe:t=e._payload,e=e._init;try{return Se(e(t))}catch{}}return null}var Ce=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,we={pending:!1,data:null,method:null,action:null},Te=[],Ee=-1;function De(e){return{current:e}}function Oe(e){0>Ee||(e.current=Te[Ee],Te[Ee]=null,Ee--)}function D(e,t){Ee++,Te[Ee]=e.current,e.current=t}var ke=De(null),Ae=De(null),je=De(null),Me=De(null);function Ne(e,t){switch(D(je,t),D(Ae,e),D(ke,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Oe(ke),D(ke,e)}function Pe(){Oe(ke),Oe(Ae),Oe(je)}function Fe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,D(Me,e)),t=ke.current;var n=dp(t,e.type);t!==n&&(D(Ae,e),D(ke,n))}function Ie(e){Ae.current===e&&(Oe(ke),Oe(Ae)),Me.current===e&&(Oe(Me),sh._currentValue=we)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Le+e+Re}var Be=!1;function Ve(e,t){if(!e||Be)return``;Be=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
5
|
`),l=s.split(`
|
|
@@ -20,4 +20,4 @@ Error generating stack: `+e.message+`
|
|
|
20
20
|
`)){let n=co(o.slice(0,t));o=o.slice(t+2),n!==``&&e.onData(n)}e.onBatch?.()}}catch{if(n.aborted)return}i=!0,await so(r,n),r=Math.min(r*2,15e3)}})(),()=>t.abort()}function uo(e,t,n={}){return $e(e,t,it(n))}function fo(e){let t=it(e);return t===void 0?e.scope:`${e.scope}/${t}`}function po(e,t){return[...e.values()].filter(e=>e.agent===t).toSorted((e,t)=>t.lastAt.localeCompare(e.lastAt))}var mo=400,ho=400,go=4e3,_o=/^\[([^\]]*)\] (.*?) from @([a-z0-9][a-z0-9-]*)(?:, who .*?)? \(message [0-9A-Z]+\)$/;function vo(e){let t=e.split(/^### /m).slice(1).flatMap(e=>{let[t=``,...n]=e.split(`
|
|
21
21
|
`),r=_o.exec(t.trim());return r===null?[]:[{at:r[1]??``,where:r[2]??``,author:r[3]??``,body:n.join(`
|
|
22
22
|
`).trim()}]});return{posts:t,from:[...new Set(t.map(e=>e.author))]}}function yo(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);return t===null?e:t[1]===`board`?t[2]??e:`${t[1]}:${t[2]}`}function bo(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function xo(e){return e.replaceAll(/\s+/g,` `).trim()}function So(e){return e.split(`
|
|
23
|
-
`).map(e=>e.trim()).find(e=>e.length>0)??``}function Co(e){return/^\/bin\/(?:ba)?sh -lc (["'])([\s\S]*)\1$/.exec(e.trim())?.[2]??e}function wo(e){return typeof e==`object`&&e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e)):{}}var To=[`file_path`,`path`,`url`,`query`,`pattern`,`description`,`prompt`];function Eo(e){let t=wo(e),n=t.command;if(typeof n==`string`){let e=Co(n);return{summary:bo(xo(e),ho),detail:bo(e,go)}}let r=bo(JSON.stringify(e??null,null,2),go),i=t.changes;if(Array.isArray(i))return{summary:bo(i.map(e=>wo(e).path).filter(e=>typeof e==`string`).join(`, `),ho),detail:r};let a=To.map(e=>t[e]).find(e=>typeof e==`string`&&e.trim()!==``),o=Object.values(t).filter(e=>typeof e==`string`||typeof e==`number`);return{summary:bo(xo(a??o.slice(0,3).join(` · `)),ho),detail:r}}var Do=`StructuredOutput`;function Oo(e,t){try{return wo(JSON.parse(e)).summary===t}catch{return!1}}function ko(e,t,n){let r=[...e.steps,t],i=r.length-n;return{...e,steps:i>0?r.slice(i):r,fromStart:e.fromStart&&i<=0,lastAt:t.at}}function Ao(e,t,{maxSteps:n}={maxSteps:mo}){let{event:r}=t,i=uo(t.agent,t.project,t),a=e.get(i),o=new Map(e),s={agent:t.agent,scope:t.project,...t.thread===void 0?{}:{thread:t.thread},...t.channel===void 0?{}:{channel:t.channel},...t.place===void 0?{}:{place:t.place}};if(r.type===`turn_started`)return o.set(i,{...s,startedAt:t.ts,fromStart:!0,model:r.model??null,steps:[],lastAt:t.ts,end:null}),o;let c=a!==void 0&&a.end===null?a:{...s,startedAt:t.ts,fromStart:!1,model:null,steps:[],lastAt:t.ts,end:null};switch(r.type){case`text`:o.set(i,ko(c,{kind:`say`,seq:t.seq,at:t.ts,text:r.delta},n));break;case`tool_call`:if(r.name===Do)break;o.set(i,ko(c,{kind:`tool`,seq:t.seq,at:t.ts,name:r.name,...Eo(r.input),ok:null,output:null},n));break;case`tool_result`:{let e=c.steps.findIndex(e=>e.kind===`tool`&&e.name===r.name&&e.ok===null),n=c.steps[e];if(n?.kind===`tool`){let a=c.steps.with(e,{...n,ok:r.ok,output:r.output??null});o.set(i,{...c,steps:a,lastAt:t.ts})}break}case`error`:o.set(i,ko(c,{kind:`error`,seq:t.seq,at:t.ts,message:r.message},n));break;case`steered`:o.set(i,ko(c,{kind:`steer`,seq:t.seq,at:t.ts,...vo(r.text??``)},n));break;case`turn_completed`:{let e=r.status?.summary??null,n=c.steps.at(-1),a=n?.kind===`say`&&e!==null&&Oo(n.text,e);o.set(i,{...c,steps:a?c.steps.slice(0,-1):c.steps,lastAt:t.ts,end:{at:t.ts,exitReason:r.exitReason,summary:e}});break}}return o}function jo(e,t,n,r={}){let i=new Map;for(let[a,o]of e.entries())i=Ao(i,{seq:a+1,ts:o.ts,agent:t,project:n,...r.thread===void 0?{}:{thread:r.thread},...r.channel===void 0?{}:{channel:r.channel},...r.place===void 0?{}:{place:r.place},event:o.event},{maxSteps:1/0});return i.get(uo(t,n,r))}function Mo(e,t){if(yo(e)!==`post_message`)return null;let n=wo(t).body,r=typeof n==`string`?So(n).replace(/^[#>*\-\s]+/,``):``;return r===``?null:bo(r,ho)}function No(e){let t=e.steps.at(-1);return t===void 0?null:t.kind===`tool`?`${yo(t.name)} · ${t.summary}`:t.kind===`steer`?`took ${Po(t.posts.length)}${t.from.length===0?``:` from ${t.from.join(`, `)}`}`:bo(So(t.kind===`say`?t.text:t.message),ho)}function Po(e){return e===1?`1 post`:`${e} posts`}function Fo(e,t){return Ze(t-Date.parse(e))}var Io=class{turns=new Map;listeners=new Set;eventListeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});snapshot=()=>this.turns;listen=e=>(this.eventListeners.add(e),()=>{this.eventListeners.delete(e)});follow(e){return lo({token:e,url:()=>`/api/turns/stream?since=0`,onOpen:()=>{this.turns=new Map,this.emit()},onData:e=>{let t=Ke.safeParse(JSON.parse(e));if(t.success){this.turns=Ao(this.turns,t.data);for(let e of this.eventListeners)e(t.data)}},onBatch:()=>this.emit()})}emit(){for(let e of this.listeners)e()}},Lo=(0,O.createContext)(null);function Ro(){let e=(0,O.useContext)(Lo);if(e===null)throw Error(`useLiveTurns needs a LiveContext`);return(0,O.useSyncExternalStore)(e.subscribe,e.snapshot)}var zo=`calc(2.5 * (1.25rem + 0.125rem + 11px * 1.5 + 0.75rem) + 0.25rem)`;function Bo(e,t){if(e||t)return`linear-gradient(to bottom, ${e?`transparent, black 1rem`:`black`}, ${t?`black calc(100% - 1rem), transparent`:`black`})`}function Vo(e,t){let[n,r]=(0,O.useState)({above:!1,below:!1});return(0,O.useLayoutEffect)(()=>{let n=e.current;if(n===null||t.current===null)throw Error(`the list of turns is not mounted`);let i=()=>{let e=n.scrollTop>0,t=n.scrollTop+n.clientHeight<n.scrollHeight-1;r(n=>n.above===e&&n.below===t?n:{above:e,below:t})};i(),n.addEventListener(`scroll`,i,{passive:!0});let a=new ResizeObserver(i);return a.observe(t.current),()=>{n.removeEventListener(`scroll`,i),a.disconnect()}},[e,t]),n}function Ho({activeCitizen:e,activeScope:t}){let n=Le(),r=ct(),i=Ro(),a=no(),o=ut(5e3),s=pe(n.data?.running??[]),c=n.data?.pending.length??0,l=(0,O.useRef)(null),u=(0,O.useRef)(null),d=Vo(l,u),f=[d.above||d.below?`${s.length} running`:null,c>0?`${c} queued`:null].filter(e=>e!==null),p=Bo(d.above,d.below);return(0,A.jsxs)(`section`,{"aria-label":`Working now`,className:`mt-3`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center justify-between px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:[(0,A.jsx)(`span`,{children:`Working now`}),f.length>0?(0,A.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:f.join(` · `)}):null]}),(0,A.jsx)(`div`,{ref:l,className:`scrollbar-hidden -mx-1 scroll-py-4 overflow-y-auto px-1 py-0.5`,style:{height:zo,...p===void 0?{}:{maskImage:p}},children:(0,A.jsx)(`div`,{ref:u,children:s.length===0?(0,A.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`Nobody is in a turn.`}):(0,A.jsx)(`ul`,{children:s.map(({agent:n,scope:s,thread:c,channel:l,place:u})=>{let d=i.get(uo(n,s,{thread:c,channel:l,place:u})),f=d!==void 0&&d.end===null,p=r.data?.find(e=>e.name===n)?.cli??null,m=f?No(d):null,h=fo({scope:s,thread:c,channel:l,place:u}),g=n===e&&(t===null||t===h||t===s),_=s===`society`?`society`:s,v=c===void 0?l===void 0?u===void 0?null:`${u}'s channels`:`#${l}`:a.get(c)?.title??`a thread`;return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/citizen/$name`,params:{name:n},search:{scope:h},className:`block rounded-lg px-2 py-1.5 transition-colors ${g?`bg-surface-2/80 text-fg-primary`:`text-fg-secondary hover:bg-surface-2/50 hover:text-fg-primary`}`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{className:`relative grid size-4 shrink-0 place-items-center`,children:[p===null?null:(0,A.jsx)(Ot,{cli:p,size:13}),(0,A.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 size-1.5 animate-pulse rounded-full bg-emerald-400`})]}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:v===null?_:`${_} · ${v}`}),f?(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-tertiary`,children:[d.fromStart?``:`≥ `,Fo(d.startedAt,o)]}):null]}),(0,A.jsx)(`span`,{className:`mt-0.5 block truncate pl-5.5 text-[11px] text-fg-muted`,children:m===null?`Starting…`:(0,A.jsx)(oo,{text:m,links:!1})})]})},h===s?`${n}/${s}`:`${n}/${h}`)})})})})]})}var Uo=`flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors`;function Wo(e){return`block truncate rounded-md px-2 text-[11px] font-semibold tracking-wider uppercase transition-colors ${e?`text-fg-primary`:`text-fg-muted hover:text-fg-primary`}`}var Go=`bg-surface-2/80 text-fg-primary`,Ko=`text-fg-secondary hover:bg-surface-2/50 hover:text-fg-primary`;function qo({slug:e,active:t}){let n=(mt(e).data??[]).filter(kt).length;return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/p/$slug/tasks`,params:{slug:e},className:`${Uo} ${t?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◇`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`tasks`}),n>0?(0,A.jsx)(`span`,{title:`${n} tasks in play`,className:`rounded-md bg-surface-2/70 px-1.5 text-[11px] text-fg-tertiary`,children:n}):null]})})}function Jo({value:e,title:t}){return e===0?null:(0,A.jsx)(`span`,{title:t,className:`rounded-md bg-amber-500/15 px-1.5 text-[11px] text-amber-300`,children:e})}function F({active:e}){let t=(ce().data??[]).filter(Ft).length,n=Ia().length;return(0,A.jsxs)(`section`,{"aria-label":`Governance`,className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:`Governance`}),(0,A.jsxs)(`ul`,{children:[(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/needs-you`,className:`${Uo} ${e===`needs-you`?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◉`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`needs you`}),(0,A.jsx)(Jo,{value:n,title:`${n} waiting on you`})]})}),(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/proposals`,className:`${Uo} ${e===`proposals`?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◈`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`proposals`}),(0,A.jsx)(Jo,{value:t,title:`${t} waiting on you`})]})})]})]})}function I({activeChannel:e,activeTasks:t,activeCitizen:n,activeScope:r,activeGovernance:i,activeOverview:a}){let o=ze(),s=se(),c=ue(),l=Ma();(0,O.useEffect)(()=>{o.data!==void 0&&Na(o.data.map(e=>[e.ref,e.lastMessageId]))},[o.data]);let u=(0,O.useMemo)(()=>(s.data??[]).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.slug.localeCompare(t.slug)),[s.data]),d=u.filter(e=>e.archived!==void 0),f=(0,O.useMemo)(()=>{let e=(o.data??[]).filter(e=>e.archived===void 0);return[{key:`society`,label:`Society`,project:null,channels:e.filter(e=>e.project===null)},...u.filter(e=>e.archived===void 0).map(t=>({key:t.slug,label:t.name,project:t.slug,channels:e.filter(e=>e.project===t.slug)}))]},[o.data,u]),p=(0,O.useMemo)(()=>{let e=new Map;for(let t of c.data??[])t.state===`open`&&e.set(t.channel,(e.get(t.channel)??0)+1);return e},[c.data]);return(0,A.jsxs)(wa,{label:`Board navigator`,className:`top-[72px] bottom-4 left-4 w-64`,children:[(0,A.jsxs)(`header`,{className:`flex items-center justify-between px-4 pt-4 pb-1`,children:[(0,A.jsx)(`span`,{className:`text-caps`,children:`Board`}),(0,A.jsx)(y,{to:`/`,"aria-label":`Close the board`,className:`grid size-7 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`,children:`✕`})]}),(0,A.jsxs)(`nav`,{className:`flex-1 overflow-y-auto px-2 pb-3`,children:[(0,A.jsx)(Ho,{activeCitizen:n,activeScope:r}),(0,A.jsx)(F,{active:i}),f.map(n=>(0,A.jsxs)(`section`,{className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`pb-1`,children:n.project===null?(0,A.jsx)(y,{to:`/society`,className:Wo(a===n.key),children:n.label}):(0,A.jsx)(y,{to:`/p/$slug`,params:{slug:n.project},className:Wo(a===n.key),children:n.label})}),(0,A.jsxs)(`ul`,{children:[n.channels.map(t=>{let n=t.ref===e,r=p.get(t.ref)??0,i=!n&&Fa(l,t.ref,t.lastMessageId);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/c/$`,params:{_splat:t.ref},className:`${Uo} ${n?Go:Ko}`,children:[(0,A.jsx)(`span`,{className:`text-fg-muted`,children:`#`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${i?`font-semibold`:``}`,children:t.name}),r>0?(0,A.jsx)(`span`,{title:`${r} open threads`,className:`rounded-md bg-surface-2/70 px-1.5 text-[11px] text-fg-tertiary`,children:r}):null,i?(0,A.jsx)(`span`,{"aria-label":`new messages`,className:`size-1.5 rounded-full bg-emerald-400`}):null]})},t.ref)}),n.project===null?null:(0,A.jsx)(qo,{slug:n.project,active:n.project===t})]})]},n.key)),d.length===0?null:(0,A.jsxs)(`section`,{"aria-label":`Archived projects`,className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:`Archived`}),(0,A.jsx)(`ul`,{children:d.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/p/$slug`,params:{slug:e.slug},className:`${Uo} ${a===e.slug?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`▫`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]})},e.slug))})]})]})]})}var L=(0,O.createContext)(void 0);function Yo(e,t){let n=new URL(e);return n.searchParams.set(n.hostname===`github.com`?`size`:`s`,String(t)),n.href}function Xo({name:e,members:t}){let n=(0,O.useContext)(L),r=t?.find(t=>t.name===e)?.cli??null;return r===null?e===`user`&&n!==void 0?(0,A.jsx)(`img`,{src:Yo(n.avatarUrl,56),alt:``,width:28,height:28,referrerPolicy:`no-referrer`,className:`size-7 shrink-0 rounded-lg bg-surface-2/80 object-cover`}):e===`user`?(0,A.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-fg-primary/90 text-[10px] font-semibold text-surface-0`,children:`you`}):(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface-2/50 text-xs text-fg-muted`,children:`✦`}):(0,A.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface-2/80`,children:(0,A.jsx)(Ot,{cli:r,size:16})})}function Zo({name:e,members:t}){let n=t?.find(t=>t.name===e)?.cli??null;return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 align-middle`,children:[n===null?null:(0,A.jsx)(Ot,{cli:n,size:12}),(0,A.jsx)(`span`,{className:`text-fg-secondary`,children:e})]})}function Qo(e,t){return e===`user`?t?.login??`you`:e}function $o(){let e=(0,O.useContext)(L);return t=>Qo(t,e)}var es=6;function ts({target:e,placeholder:t,initialText:n=``,className:r=`border-t border-line p-3`,focusOnOpen:i=!1,onPosted:a,onEmptyEscape:o}){let{api:s}=Pe(),c=m(),l=ct(),[u,d]=(0,O.useState)(n),[f,p]=(0,O.useState)(0),[h,g]=(0,O.useState)(0),[_,v]=(0,O.useState)(!1),y=(0,O.useRef)(null),ee=(0,O.useRef)(null),x=ht({mutationFn:async t=>{if(`channel`in e)return s.sendMessage({channel:e.channel,body:t});if(`threadId`in e)return s.sendMessage({thread_id:e.threadId,body:t});let n=await s.openThread({channel:st,title:ga(t)});return s.sendMessage({thread_id:n.id,body:t})},onSuccess:t=>{d(n),c.invalidateQueries({queryKey:t.thread===void 0?[`channel`,t.channel]:[`thread`,t.thread]}),`ask`in e&&c.invalidateQueries({queryKey:[`threads`]}),c.invalidateQueries({queryKey:[`requests`]}),a?.(t)}});(0,O.useEffect)(()=>{i&&y.current?.focus()},[i]),(0,O.useLayoutEffect)(()=>{let e=y.current;e!==null&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`,ee.current!==null&&(e.setSelectionRange(ee.current,ee.current),ee.current=null))});let S=_?null:wt(u,f),C=(l.data??[]).filter(e=>e.status===`active`&&e.cli!==null),te=S===null?[]:C.filter(e=>e.name.startsWith(S.prefix)).slice(0,es),w=e=>{if(S===null)return;let t=Tt(u,f,S.start,e);ee.current=t.caret,d(t.text),p(t.caret)},ne=()=>{u.trim()!==``&&u.trim()!==n.trim()&&!x.isPending&&x.mutate(u.trim())};return(0,A.jsxs)(`form`,{className:r,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,A.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl bg-surface-2/50 pr-1.5 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] focus-within:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.16)]`,children:[te.length>0?(0,A.jsx)(`ul`,{"aria-label":`Citizens to mention`,className:`card absolute bottom-full left-2 mb-2 w-60 overflow-hidden py-1`,children:te.map((e,t)=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),w(e.name)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${t===h?`bg-surface-2 text-fg-primary`:`text-fg-secondary`}`,children:[e.cli===null?null:(0,A.jsx)(Ot,{cli:e.cli,size:14}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] text-fg-muted`,children:e.role})]})},e.name))}):null,(0,A.jsx)(`textarea`,{ref:y,rows:1,value:u,placeholder:t,"aria-label":t,onChange:e=>{d(e.target.value),p(e.target.selectionStart),g(0),v(!1)},onSelect:e=>p(e.currentTarget.selectionStart),onKeyDown:e=>{if(te.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:te.length-1;g((h+t)%te.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),w(te[Math.min(h,te.length-1)]?.name??``);return}if(e.key===`Escape`){e.preventDefault(),v(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),ne()):e.key===`Escape`&&u===``&&o!==void 0&&(e.preventDefault(),o())},className:`block max-h-48 w-full resize-none bg-transparent px-3 py-2.5 text-sm text-fg-primary outline-none placeholder:text-fg-muted`}),(0,A.jsx)(`div`,{className:`shrink-0 pb-1.5`,children:(0,A.jsx)(_t,{variant:`primary`,type:`submit`,disabled:u.trim()===``||u.trim()===n.trim()||x.isPending,children:x.isPending?`Sending…`:`Send`})})]}),x.error===null?null:(0,A.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-red-400`,children:x.error instanceof b?x.error.message:`The message was not sent.`})]})}var R=5;function ns(e,t,n){switch(e.kind){case`answering`:return{text:`${Ct(e.who)} ${e.who.length===1?`is`:`are`} answering…`,tone:`text-emerald-300`};case`queued`:return{text:`${Ct(e.who)} will answer next`,tone:`text-amber-300`};case`waiting`:return{text:`waiting for an answer`,tone:`text-fg-muted`};case`answered`:return{text:`answered by ${n(e.by)}`,tone:`text-fg-secondary`}}let r=He(t.body,160);return{text:`closed by ${n(e.by??`board`)}${r===``?``:` · ${r}`}`,tone:`text-fg-muted`}}function rs({left:e,width:t,onClose:n}){let r=ue(),i=Le(),a=Ma(),o=ut(3e4),s=$o(),c=(0,O.useRef)(null),l=ha(r.data??[]).slice(0,R),u=pe(i.data?.running??[]),d=pe(i.data?.pending??[]);return(0,O.useEffect)(()=>{let e=e=>{e.target instanceof Node&&c.current?.contains(e.target)===!1&&n()};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[n]),(0,A.jsxs)(`section`,{ref:c,"aria-label":`Ask`,className:`absolute top-[26%] z-30 flex flex-col gap-2`,style:{left:e,width:t},children:[(0,A.jsx)(`div`,{className:Ca,children:(0,A.jsx)(ts,{target:{ask:!0},placeholder:`Ask the front desk`,className:`p-2`,focusOnOpen:!0,onEmptyEscape:n})}),l.length===0?null:(0,A.jsx)(`ol`,{"aria-label":`Your asks`,className:`${Ca} max-h-[40vh] overflow-y-auto py-1`,children:l.map(e=>{let t=ns(_a(e,u,d),e,s),n=va(e,a);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/thread/$threadId`,params:{threadId:e.id},className:`block px-4 py-2 transition-colors hover:bg-surface-2/50`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-primary ${n?`font-semibold`:``}`,children:e.title}),n?(0,A.jsx)(`span`,{"aria-label":`new answer`,className:`size-1.5 shrink-0 rounded-full bg-emerald-400`}):null,(0,A.jsx)(`time`,{dateTime:e.openedAt,className:`shrink-0 text-meta`,children:nt(e.openedAt,o)})]}),(0,A.jsx)(`span`,{className:`mt-0.5 block truncate text-xs ${t.tone}`,children:t.text})]})},e.id)})})]})}function is({unread:e,onOpen:t}){let n=$o(),[r]=e,i=r===void 0?null:e.length===1?`${n(r.lastAuthor??`board`)} answered “${r.title}”`:`${e.length} new answers`;return(0,A.jsxs)(`button`,{type:`button`,onClick:t,className:`pointer-events-auto flex max-w-full min-w-0 items-center gap-2 rounded-full px-3 py-1.5 text-meta transition-colors hover:text-fg-secondary`,children:[i===null?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 shrink-0 rounded-full bg-emerald-400`}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-fg-secondary`,children:i}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,A.jsx)(`kbd`,{className:`shrink-0 rounded border border-line px-1.5 font-sans text-[11px] text-fg-secondary`,children:`Space`}),(0,A.jsx)(`span`,{className:`shrink-0`,children:`to ask`})]})}var as={working:{label:`working`,style:`bg-emerald-500/15 text-emerald-300`},queued:{label:`queued`,style:`bg-amber-500/15 text-amber-300`},idle:{label:`resting`,style:`bg-surface-2 text-fg-tertiary`}};function os(e,t,n,r){return t.state===`working`?`In a turn at ${n}`:t.state===`queued`?`Queued for ${n}`:e.lastTurnAt===void 0?`No turns yet`:`Last turn ${nt(e.lastTurnAt,r)}`}function ss({member:e,star:t,place:n,now:r}){let i=e.lastModel??e.model,a=as[t.state];return(0,A.jsxs)(`article`,{className:`card w-72 p-3.5`,"aria-label":`${e.name}, ${e.role}`,children:[(0,A.jsxs)(`header`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-md bg-surface-2/70`,children:(0,A.jsx)(Ot,{cli:t.cli,size:18})}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h2`,{className:`text-title truncate`,children:e.name}),(0,A.jsxs)(`p`,{className:`truncate text-meta`,children:[e.role,i===void 0?``:` · ${i}`]})]}),(0,A.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${a.style}`,children:a.label})]}),(0,A.jsx)(`p`,{className:`mt-2.5 text-sm text-fg-secondary`,children:os(e,t,n,r)})]})}function cs({society:e,citizens:t,citizensOpen:n,onToggleCitizens:r,runnersOpen:i,onToggleRunners:a,enrolling:o,cronsOpen:s,onToggleCrons:c,failingCrons:l,attention:u,onOpenAttention:d,paused:f,onTogglePause:p,pauseBusy:m,boardOpen:h,onToggleBoard:g,metricsOpen:_,onToggleMetrics:v,logsOpen:y,onToggleLogs:b,onSignOut:ee}){return(0,A.jsxs)(`header`,{className:`pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsx)(`span`,{className:`text-display`,children:`Stellaris`}),e===void 0?null:(0,A.jsx)(`span`,{className:`text-meta`,children:e})]}),(0,A.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-2`,children:[u===0?null:(0,A.jsxs)(`button`,{type:`button`,onClick:d,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs text-amber-300 transition-colors hover:text-amber-200 focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-amber-300`}),u,` `,u===1?`needs`:`need`,` you`]}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":f,disabled:m,onClick:p,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none disabled:opacity-50 ${f?`text-amber-300 hover:text-amber-200`:`text-fg-tertiary hover:text-fg-primary`}`,children:f?`Paused · resume`:`Pause`}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":n,onClick:r,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${n?`text-fg-primary`:`text-fg-tertiary hover:text-fg-primary`}`,children:t===1?`1 citizen`:`${t} citizens`}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-label":o===0?`Runners`:`Runners, ${o} waiting for approval`,onClick:a,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${i?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:[`Runners`,o===0?null:(0,A.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1 text-[11px] text-amber-300`,children:o})]}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":s,"aria-label":l===0?`Crons`:`Crons, ${l} failing`,onClick:c,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${s?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:[`Crons`,l===0?null:(0,A.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1 text-[11px] text-amber-300`,children:l})]}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":h,onClick:g,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${h?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Board`}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":_,onClick:v,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${_?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Metrics`}),(0,A.jsx)(`button`,{type:`button`,"aria-expanded":y,onClick:b,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${y?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Logs`}),(0,A.jsx)(`button`,{type:`button`,onClick:ee,className:`h-7 rounded-md px-2.5 text-xs text-fg-tertiary transition-colors hover:bg-surface-2/60 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:`Sign out`})]})]})}var ls={waiting_stage:`stage waiting`,backlog:`backlog`,role_gap:`role gap`,churn:`churn`,stale_thread:`stale thread`,idle_member:`idle member`,blocked_capability:`missing capability`,turn_cost:`spend`,scaled:`replica added`,runner:`runner`,home_conflict:`edits to reconcile`,stuck_workspace:`work left on no branch`,cron_failing:`cron failing`,turn_refused:`model refusing turns`};function us(e,t){let n=new Set(t),r=new Map;for(let t of e)n.has(t.signal.key)&&r.set(t.signal.key,t.id);return new Set(r.values())}function z(e){return[e.project??``,e.agent??``,e.role===void 0?``:`role ${e.role}`,De(e)?`wakes the steward`:``].filter(e=>e.length>0)}function ds({onClose:e}){let t=S(!0),n=Le(),r=ut(3e4),i=t.data??[],a=us(i,n.data?.signals??[]);return(0,A.jsxs)(wa,{label:`Operations log`,className:`top-[72px] right-4 z-20 max-h-[min(70vh,640px)]`,style:{width:400},children:[(0,A.jsxs)(`header`,{className:`flex items-center gap-3 border-b border-line px-4 py-3`,children:[(0,A.jsx)(`h2`,{className:`min-w-0 flex-1 text-heading`,children:`Operations log`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Close the log`,onClick:e,className:`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:`×`})]}),i.length===0?(0,A.jsx)(`p`,{className:`px-4 py-4 text-meta`,children:t.data===void 0?`Reading the log…`:`Nothing measured yet.`}):(0,A.jsx)(`ol`,{className:`flex-1 overflow-y-auto`,children:i.toReversed().map(({id:e,ts:t,signal:n})=>{let i=De(n),o=z(n);return(0,A.jsxs)(`li`,{className:`border-b border-line/60 px-4 py-2.5 last:border-b-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`rounded-md px-1.5 py-px text-[11px] ${i?`bg-amber-500/15 text-amber-300`:`bg-surface-2 text-fg-tertiary`}`,children:ls[n.kind]}),a.has(e)?(0,A.jsx)(`span`,{className:`text-[11px] text-emerald-300`,children:`holds now`}):null,(0,A.jsx)(`time`,{dateTime:t,title:t,className:`ml-auto shrink-0 text-meta`,children:nt(t,r)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:(0,A.jsx)(oo,{text:n.summary})}),o.length===0&&n.taskId===void 0?null:(0,A.jsxs)(`p`,{className:`mt-0.5 text-meta`,children:[o.join(` · `),n.taskId===void 0?null:(0,A.jsxs)(A.Fragment,{children:[o.length===0?``:` · `,(0,A.jsx)(y,{to:`/task/$taskId`,params:{taskId:n.taskId},className:`text-fg-tertiary underline-offset-2 hover:text-fg-primary hover:underline`,children:`the task`})]})]})]},e)})})]})}var fs=32;function ps(e,t){return t.width+t.x-e.clientX}function ms({width:e,min:t,max:n,onResize:r,onToggle:i}){let a=(0,O.useRef)(null),o=t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),a.current={x:t.clientX,width:e})},s=e=>{a.current!==null&&r(ps(e,a.current),!1)},c=e=>{a.current!==null&&(r(ps(e,a.current),!0),a.current=null)};return(0,A.jsx)(`button`,{type:`button`,"aria-label":`Width of the board's content, ${e} of at most ${n} pixels: drag or use the arrow keys, Enter widens it all the way or back`,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onClick:e=>{e.detail===0&&i()},onDoubleClick:i,onKeyDown:i=>{let a=i.key===`ArrowLeft`?e+fs:i.key===`ArrowRight`?e-fs:i.key===`Home`?t:i.key===`End`?n:null;a!==null&&(i.preventDefault(),r(a,!0))},className:`absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize touch-none before:absolute before:inset-y-4 before:left-0.5 before:w-0.5 before:rounded-full before:transition-colors hover:before:bg-fg-muted/60 focus-visible:outline-none focus-visible:before:bg-fg-primary/60 active:before:bg-fg-primary/60`})}function hs({mark:e,project:t,members:n}){let r=n?.find(t=>t.name===e.holder)?.cli??null,i=Nt.find(t=>t.phase===e.phase)?.label??e.phase;return(0,A.jsxs)(`article`,{className:`card w-72 p-4`,"aria-label":`Task ${e.title}`,children:[(0,A.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(`h2`,{className:`text-title min-w-0 flex-1`,children:e.title}),(0,A.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${At[e.phase]}`,children:i.toLowerCase()})]}),(0,A.jsxs)(`dl`,{className:`mt-3 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Project`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:t}),(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Stage`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:e.stage}),e.holder===null?e.waitingFor===null?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Waiting for`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:e.waitingFor})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Held by`}),(0,A.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-1 text-fg-secondary`,children:[r===null?null:(0,A.jsx)(Ot,{cli:r,size:12}),e.holder,e.linked===null?` · resting`:` · in a turn on it`]})]})]})]})}function gs(e,t){let n=`latest`;return lo({token:e,url:()=>`/api/events/stream?since=${n}`,onData:e=>{let r=Se.parse(JSON.parse(e));n=r.id,t.onEvent(r)},onOpen:e=>{e&&t.onResume()}})}function _s(e){return typeof e==`string`?e:void 0}function vs(e){let{type:t,payload:n,actor:r}=e;if(t===`message.posted`){let e=_s(n.thread);return e===void 0?[[`channels`],[`channel`,_s(n.channel)],[`requests`]]:[[`threads`],[`thread`,e],[`requests`]]}if(t.startsWith(`thread.`))return[[`threads`],[`thread`,_s(n.threadId)],[`channel`],[`requests`]];if(t.startsWith(`task.`)||t.startsWith(`merge.`)||t.startsWith(`pull_request.`)||t===`lease.expired`){let e=[[`tasks`],[`task`,_s(n.taskId)],[`members`],[`metrics`]];return t===`merge.completed`?[...e,[`project-file`,_s(n.project)]]:e}return t===`turn.completed`||t===`turn.failed`?[[`scheduler`],[`members`],[`turns`,r],[`memory`,r],[`agent-skills`,r],[`conflicts`,r],[`history`,r],[`task-file`],[`task-changes`],[`task-diff`],[`project-file`],[`metrics`],[`tokens`],[`crons`]]:t===`turn.started`?[[`scheduler`],[`members`],[`metrics`]]:t.startsWith(`turn.`)||t===`wake.requested`||t===`paused.changed`?[[`scheduler`],[`members`]]:t===`knowledge.written`||t===`knowledge.removed`?[[`knowledge`,_s(n.project)??`society`]]:t===`dashboard.updated`?[[`dashboard`,_s(n.project)]]:t.startsWith(`cron.`)?[[`crons`]]:t===`society.configured`?[[`society`],[`crons`]]:t.startsWith(`agent.`)||t===`subscription.changed`?[[`members`],[`crons`]]:t.startsWith(`project.`)||t===`channel.added`||t===`channel.archived`?[[`projects`],[`channels`],[`society`],[`crons`]]:t===`role.added`?[[`roles`]]:t===`runner.quota`?[[`runners`]]:t.startsWith(`runner.`)?[[`runners`],[`models`],[`server-version`]]:t.startsWith(`proposal.`)?[[`proposals`],[`proposal`,_s(n.proposalId)],[`metrics`]]:t===`skill.promoted`||t===`skill.removed`?[[`skills`]]:t===`ops.signal`?[[`signals`],[`scheduler`],[`metrics`]]:[]}function ys(e,t){for(let n of vs(t)){let t=n.filter(e=>e!==void 0);e.invalidateQueries({queryKey:t})}}var bs=`stellaris.contentWidth`;function xs(e){return Math.round(Math.min(680,Math.max(420,e*.4)))}function Ss(e){return Math.max(420,e-256-48)}function Cs(e,t){let n=Ss(e);return t===`widest`?n:Math.round(Math.min(n,Math.max(420,t??xs(e))))}function ws(e,t){return Cs(e,t)>=Ss(e)?null:`widest`}function Ts(){let e=localStorage.getItem(bs);if(e===`widest`)return`widest`;let t=Number(e);return e!==null&&Number.isFinite(t)&&t>0?t:null}function Es(e){e===null?localStorage.removeItem(bs):localStorage.setItem(bs,String(e))}var Ds=class{fetch;asked=new Set;waiting=new Set;found=new Map;listeners=new Set;refs=[];scheduled=!1;constructor(e){this.fetch=e}want(e){for(let t of e)this.asked.has(t)||(this.asked.add(t),this.waiting.add(t));this.waiting.size>0&&!this.scheduled&&(this.scheduled=!0,queueMicrotask(()=>void this.flush()))}async flush(){this.scheduled=!1;let e=[...this.waiting];this.waiting.clear();let t=this.found.size;for(let t=0;t<e.length;t+=50)try{for(let n of await this.fetch(e.slice(t,t+50)))this.found.set(n.id,n)}catch{}if(this.found.size!==t){this.refs=[...this.found.values()];for(let e of this.listeners)e()}}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));snapshot=()=>this.refs},Os=`stellaris.trail`;function ks(e,t,n){let r={};for(let[n,i]of Object.entries(e))Number(n)<t&&(r[Number(n)]=i);return r[t]=n,r}function As(e,t){let n=e[t-1];return n===void 0||new URL(n,`http://board`).pathname===`/`?null:n}function js(){try{let e=JSON.parse(sessionStorage.getItem(Os)??`{}`);if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&Number.isInteger(Number(n))&&(t[Number(n)]=r);return t}catch{return{}}}function Ms(e){sessionStorage.setItem(Os,JSON.stringify(e))}function Ns(e,t){return decodeURIComponent(e.split(`/`)[t]??``)}function Ps(e,t){let{pathname:n}=new URL(e,`http://board`),r=n.split(`/`).filter(e=>e!==``),[i=``,a=``,o=``]=r;if(i===`task`&&o===`files`)return r.slice(3).map(decodeURIComponent).at(-1)??`the task's files`;if(i===`task`||i===`thread`||i===`proposal`)return t.entity(a)??`the ${i}`;if(i===`c`)return`#${decodeURIComponent(r.at(-1)??``)}`;if(i===`p`){let e=t.project(a)??a;return o===`files`?r.slice(3).map(decodeURIComponent).at(-1)??`the files of ${e}`:o===`tasks`?`the tasks of ${e}`:e}if(i===`knowledge`)return Ns(n,3);if(i===`skills`)return Ns(n,2);if(i===`citizen`)return decodeURIComponent(a);if(i===`crons`){let n=new URL(e,`http://board`).searchParams.get(`cron`);return(n===null?void 0:t.entity(n))??`the crons`}return{society:`the society`,citizens:`the citizens`,"needs-you":`what needs you`,proposals:`the proposals`,metrics:`the metrics`,runners:`the runners`}[i]??`the previous view`}var Fs=typeof sessionStorage>`u`?{}:js(),Is=new Set;function Ls(e,t){if(Fs[e]!==t||Fs[e+1]!==void 0){Fs=ks(Fs,e,t),Ms(Fs);for(let e of Is)e()}}function Rs(){return(0,O.useSyncExternalStore)(e=>(Is.add(e),()=>Is.delete(e)),()=>Fs)}function zs(e,t){let n=Nt.find(t=>t.phase===e.phase)?.label.toLowerCase(),r=e.holder===null?e.waitingFor===null?null:`for ${e.waitingFor}`:`held by ${e.holder}${e.linked===null?``:`, in a turn there`}`;return[`Task ${e.title} at ${t}`,`stage ${e.stage}`,n,r].filter(e=>e!=null).join(`, `)}var Bs=Math.PI*(3-Math.sqrt(5)),Vs=68,Hs=44,Us=58,Ws=26,Gs=13,Ks=.3,qs=1.5*Math.PI,Js=28,Ys=280,Xs=8,Zs=40;function Qs(e){return Math.max(Us,Vs*Math.sqrt(Math.max(0,e-1))+Hs)}function $s(e){return e+Ws}function ec(e){let t=new Map;for(let n of e.toSorted()){let e=We(n);if(e!==null){let n=t.get(e.agent)??[];n.includes(e.scope)||t.set(e.agent,[...n,e.scope])}}return t}function tc(e){let t=e.projects.filter(e=>e.archived===void 0).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.slug.localeCompare(t.slug)),n=new Set(t.map(e=>e.slug)),r=e=>n.has(e)?e:Ae,i=ec(e.scheduler.running),a=ec(e.scheduler.pending),o=new Set(e.scheduler.resident.map(e=>e.split(`/`)[0])),s=e.members.filter(e=>e.cli!==null).filter(e=>e.status===`active`).toSorted((e,t)=>e.name.localeCompare(t.name)),c=s.flatMap(e=>{let t=[...new Set((i.get(e.name)??[]).map(r))];if(t.length>0)return t.map(t=>({id:t===`society`?e.name:`${e.name}/${t}`,member:e,state:`working`,scope:t,queuedFor:null}));let n=a.get(e.name)?.[0];return[{id:e.name,member:e,state:n===void 0?`idle`:`queued`,scope:Ae,queuedFor:n===void 0?null:r(n)}]}),l=new Map([[Ae,new Map(s.map((e,t)=>[e.name,t]))]]);for(let e of t){let t=s.filter(t=>t.memberships.includes(e.slug)),n=c.filter(t=>t.scope===e.slug).map(e=>e.member).filter(t=>!t.memberships.includes(e.slug));l.set(e.slug,new Map([...t,...n].map((e,t)=>[e.name,t])))}let u=new Map([...l].map(([e,t])=>[e,t.size])),d={id:Ae,label:`society`,kind:`society`,x:0,y:0,radius:Qs(u.get(`society`)??0)},f=[d,...ic(t,u,d)],p=new Map(f.map(e=>[e.id,e])),m=c.map(({id:e,member:t,state:n,scope:r,queuedFor:i})=>{let a=p.get(r)??d,s=l.get(a.id)?.get(t.name)??0,c=Vs*Math.sqrt(s),u=s*Bs-Math.PI/2;return{id:e,name:t.name,cli:t.cli,state:n,resident:o.has(t.name),anchor:a.id,queuedFor:i,x:Math.round(a.x+c*Math.cos(u)),y:Math.round(a.y+c*Math.sin(u))}}),h=nc(e.tasks??[],f,m),g=Math.max(...f.map(e=>Math.hypot(e.x,e.y)+$s(e.radius)));return{anchors:f,stars:m,tasks:h,radius:Math.round(g+Zs)}}function nc(e,t,n){let r=[];for(let i of t){if(i.kind!==`project`)continue;let t=e.filter(e=>e.project===i.id).flatMap(e=>{let t=Mt(e);return t===`done`||t===`abandoned`?[]:[{task:e,phase:t}]}).toSorted((e,t)=>e.task.id.localeCompare(t.task.id)),a=Math.min(Ks,qs/Math.max(1,t.length)),o=i.radius+Gs;t.forEach(({task:e,phase:t},s)=>{let c=s%2==0?1:-1,l=-Math.PI/2+c*Math.ceil(s/2)*a,u=t===`landing`?null:e.claimedBy??null,d=pt(e),f=u===null?null:n.find(e=>e.name===u&&e.anchor===i.id)?.id??null;r.push({id:e.id,title:e.title,project:i.id,phase:t,stage:d?.name??e.stage,holder:u,waitingFor:u===null&&t!==`landing`&&d!==void 0?jt(d):null,linked:f,x:Math.round(i.x+o*Math.cos(l)),y:Math.round(i.y+o*Math.sin(l))})})}return r}function rc(e,t,n){let r=e.stars.filter(e=>e.name===t);return(r.find(e=>e.anchor===n)??r[0])?.id??null}function ic(e,t,n){let r=[],i=$s(n.radius),a=Xs;for(let n=0,o=0;n<e.length;o+=1){let s=e.slice(n,n+a);n+=a,a+=4;let c=s.map(e=>Qs(t.get(e.slug)??0)),l=c.map($s),u=l.map(e=>2*e+Js),d=u.reduce((e,t)=>e+t,0),f=u.map(e=>2*Math.PI*e/d),p=-Math.PI/2-(f[0]??0)/2+(o===0?0:Math.PI/s.length),m=f.map(e=>{let t=p+e/2;return p+=e,t}),h=Math.max(o===0?Ys:0,i+Math.max(...l)+Js);if(s.length>1)for(let e=0;e<s.length;e+=1){let t=(e+1)%s.length,n=((f[e]??0)+(f[t]??0))/2,r=((l[e]??0)+(l[t]??0)+Js)/(2*Math.sin(n/2));h=Math.max(h,r)}s.forEach((e,t)=>{let n=m[t]??0;r.push({id:e.slug,label:e.name,kind:`project`,x:Math.round(h*Math.cos(n)),y:Math.round(h*Math.sin(n)),radius:Math.round(c[t]??Us)})}),i=h+Math.max(...l)}return r}var ac=.15,oc=.45,sc=1.35,cc=64,lc=1.15;function uc(e,t,n){return Math.min(n,Math.max(t,e))}function dc(e){return Math.max(240,e.width-e.left-e.right)}function fc(e){return{x:e.left+dc(e)/2,y:e.height/2}}function pc(e,t){return{x:0,y:0,scale:uc(Math.min(dc(e),e.height)/(2*t),oc,sc)}}function mc(e,t,n,r){let i=uc(e.scale*n,ac,3),a=fc(t),o=e.x+(r.x-a.x)/e.scale,s=e.y+(r.y-a.y)/e.scale;return{x:o-(r.x-a.x)/i,y:s-(r.y-a.y)/i,scale:i}}function hc(e,t,n){return{...e,x:e.x-t/e.scale,y:e.y-n/e.scale}}function gc(e,t,n){let r=fc(t),i=r.x+(n.x-e.x)*e.scale,a=r.y+(n.y-e.y)*e.scale,o=n.reach*e.scale;if(i-o>=t.left&&i+o<=t.width-t.right&&a-o>=cc&&a+o<=t.height)return null;let s=Math.min(dc(t),t.height-cc)/(2*n.reach*lc);return{x:n.x,y:n.y,scale:Math.min(e.scale,uc(s,ac,3))}}var _c=`#0a0a0a`,vc=`#171717`,yc=`212, 212, 212`,bc=`163, 163, 163`,xc=`115, 115, 115`,Sc=`"Instrument Sans Variable", ui-sans-serif, sans-serif`,Cc=`500 12px "Onest Variable", ui-sans-serif, sans-serif`,wc=`600 10px "Onest Variable", ui-sans-serif, sans-serif`,Tc={waiting:`#fcd34d`,working:`#6ee7b7`,returned:`#fdba74`,landing:`#7dd3fc`},Ec=`500 11px ${Sc}`,Dc=5,Oc=240,kc=34,Ac=.06,jc=15,Mc=5,Nc=4.2,Pc=280;function Fc(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Ic(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)/4294967296*Math.PI*2}function B(e,t){return(e%t+t)%t}function Lc(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function Rc(e){let t=document.createElement(`canvas`);t.width=256,t.height=256;let n=t.getContext(`2d`);if(n!==null){let t=Lc(e),r=n.createRadialGradient(128,128,0,128,128,128);r.addColorStop(0,`rgba(${t}, 0.55)`),r.addColorStop(.22,`rgba(${t}, 0.2)`),r.addColorStop(.55,`rgba(${t}, 0.05)`),r.addColorStop(1,`rgba(${t}, 0)`),n.fillStyle=r,n.fillRect(0,0,256,256)}return t}var zc=class{canvas;options;ctx;glyphs;glows=new Map;bodies=new Map;marks=new Map;bubbles=new Map;clock=0;specks;spheres=new Map;radius=400;scale=1;camX=0;camY=0;target={x:0,y:0,scale:1};mode=`home`;focusPending=!1;width=0;height=0;dpr=1;hovered=null;focus=null;paused=!1;insetLeft=0;insetRight=0;centerX=0;frameId=null;last=0;constructor(e,t){this.canvas=e,this.options=t;let n=e.getContext(`2d`);if(n===null)throw Error(`the sky needs a 2D canvas context`);this.ctx=n,this.glyphs={claude:new Path2D(Et.claude.path),codex:new Path2D(Et.codex.path)};let r=Fc(7);this.specks=Array.from({length:Pc},()=>({x:r(),y:r(),size:.5+r()*1.1,alpha:.12+r()*.45,rate:.2+r()*.8,phase:r()*Math.PI*2}))}setModel(e){this.radius=e.radius;for(let t of e.anchors){let e=this.spheres.get(t.id);e===void 0?this.spheres.set(t.id,{anchor:t,x:t.x,y:t.y,radius:t.radius}):e.anchor=t}for(let t of this.spheres.keys())e.anchors.some(e=>e.id===t)||this.spheres.delete(t);let t=new Set(e.stars.map(e=>e.id)),n=[...this.bodies.entries()].filter(([e])=>!t.has(e));for(let r of e.stars){let i=this.bodies.get(r.id);if(i!==void 0){i.star=r,i.leaving=!1;continue}let a=n.findIndex(([,e])=>e.star.name===r.name),o=n[a];if(o!==void 0){n.splice(a,1),this.bodies.delete(o[0]),this.bodies.set(r.id,{...o[1],star:r,leaving:!1});continue}let s=[...this.bodies.values()].find(e=>e.star.name===r.name&&t.has(e.star.id)),c=e.anchors.find(e=>e.id===r.anchor),l=s??c??r;this.bodies.set(r.id,{star:r,x:this.options.reducedMotion?r.x:l.x,y:this.options.reducedMotion?r.y:l.y,vx:0,vy:0,phase:Ic(r.name),presence:+!!this.options.reducedMotion,leaving:!1,screen:{x:0,y:0},flash:0})}for(let[,t]of n){let n=e.stars.find(e=>e.name===t.star.name);t.leaving=!0,n!==void 0&&(t.star={...t.star,x:n.x,y:n.y})}let r=new Set(e.tasks.map(e=>e.id));for(let t of e.tasks){let e=this.marks.get(t.id);e===void 0?this.marks.set(t.id,{mark:t,x:t.x,y:t.y,presence:+!!this.options.reducedMotion,leaving:!1,screen:{x:0,y:0}}):(e.mark=t,e.leaving=!1)}for(let[e,t]of this.marks)r.has(e)||(t.leaving=!0)}flash(e){let t=this.bodies.get(e);t!==void 0&&!this.options.reducedMotion&&(t.flash=1)}say(e,t){this.bodies.has(e)&&this.bubbles.set(e,{text:t,born:this.clock})}setHovered(e){this.hovered=e}setPaused(e){this.paused=e}setFocus(e){this.focus=e,this.focusPending=!0}zoomBy(e,t){let n=this.view();this.target=mc(this.target,n,e,t??fc(n)),this.mode=`manual`}panBy(e,t){this.target=hc(this.target,e,t),this.camX-=e/this.scale,this.camY-=t/this.scale,this.mode=`manual`}home(){this.mode=`home`}view(){return{width:this.width,height:this.height,left:this.insetLeft,right:this.insetRight}}frameFocus(e){let t=this.focus===null?void 0:this.spheres.get(this.focus);if(t===void 0||t.anchor.kind===`society`){this.mode===`focus`&&(this.mode=`home`);return}let n=gc(this.target,e,{x:t.anchor.x,y:t.anchor.y,reach:t.anchor.radius+kc});n!==null&&(this.target=n,this.mode=`focus`)}setInsets(e,t){this.insetLeft=e,this.insetRight=t}hitTestAnchor(e,t){let n=null,r=1/0;for(let i of this.spheres.values()){let a=this.toScreen(i.x,i.y),o=Math.hypot(a.x-e,a.y-t);o<=i.radius*this.scale&&o<r&&(n=i.anchor.id,r=o)}return n}resize(e,t,n){this.width=e,this.height=t,this.dpr=n,this.canvas.width=Math.round(e*n),this.canvas.height=Math.round(t*n)}hitTestMark(e,t){let n=null,r=10;for(let[i,a]of this.marks){let o=Math.hypot(a.screen.x-e,a.screen.y-t);!a.leaving&&o<r&&(n=i,r=o)}return n}hitTest(e,t){let n=null,r=Math.max(jc*this.scale+8,18);for(let[i,a]of this.bodies){if(a.leaving)continue;let o=Math.hypot(a.screen.x-e,a.screen.y-t);o<r&&(n=i,r=o)}return n}start(){this.frameId===null&&(this.last=performance.now()/1e3,this.frameId=requestAnimationFrame(this.frame))}stop(){this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}frame=e=>{let t=e/1e3;this.clock=t;let n=Math.min(.05,Math.max(0,t-this.last));this.last=t,this.step(n),this.draw(this.options.reducedMotion?0:t),this.frameId=requestAnimationFrame(this.frame)};step(e){let t=this.view();this.mode===`home`&&(this.target=pc(t,this.radius)),this.focusPending&&this.width>0&&(this.focusPending=!1,this.frameFocus(t));let n=this.options.reducedMotion?1:Math.min(1,e*3);this.scale+=(this.target.scale-this.scale)*n,this.camX+=(this.target.x-this.camX)*n,this.camY+=(this.target.y-this.camY)*n;let r=fc(t).x;this.centerX=this.centerX===0?r:this.centerX+(r-this.centerX)*n;for(let e of this.spheres.values())e.x+=(e.anchor.x-e.x)*n,e.y+=(e.anchor.y-e.y)*n,e.radius+=(e.anchor.radius-e.radius)*n;for(let[t,n]of this.bodies){if(this.options.reducedMotion)n.x=n.star.x,n.y=n.star.y,n.presence=+!n.leaving;else{n.vx+=(Mc*(n.star.x-n.x)-Nc*n.vx)*e,n.vy+=(Mc*(n.star.y-n.y)-Nc*n.vy)*e,n.x+=n.vx*e,n.y+=n.vy*e;let t=+!n.leaving;n.presence+=(t-n.presence)*Math.min(1,e*2.5)}n.flash=Math.max(0,n.flash-e*2.2),n.leaving&&n.presence<.02&&this.bodies.delete(t)}for(let[t,r]of this.marks){r.x+=(r.mark.x-r.x)*n,r.y+=(r.mark.y-r.y)*n;let i=+!r.leaving;r.presence+=(i-r.presence)*(this.options.reducedMotion?1:Math.min(1,e*2.5)),r.leaving&&r.presence<.02&&this.marks.delete(t)}for(let[e,t]of this.bubbles)(this.clock-t.born>Dc||this.bodies.get(e)?.leaving!==!1)&&this.bubbles.delete(e)}toScreen(e,t){return{x:this.centerX+(e-this.camX)*this.scale,y:this.height/2+(t-this.camY)*this.scale}}glow(e){let t=this.glows.get(e);return t===void 0&&(t=Rc(e),this.glows.set(e,t)),t}draw(e){let{ctx:t}=this;t.setTransform(this.dpr,0,0,this.dpr,0,0),t.fillStyle=_c,t.fillRect(0,0,this.width,this.height),this.drawSpecks(e),this.drawAnchors(),this.drawTasks(e);let n=[...this.bodies.values()].toSorted((e,t)=>Number(e.star.id===this.hovered)-Number(t.star.id===this.hovered));for(let t of n)this.drawBody(t,e);this.drawBubbles();let r=this.hovered?.startsWith(`task:`)===!0?this.hovered.slice(5):null,i=r===null?this.hovered===null?void 0:this.bodies.get(this.hovered):this.marks.get(r);this.options.onHoverPosition(i===void 0||i.leaving?null:i.screen)}drawTasks(e){let{ctx:t}=this;for(let e of this.marks.values())e.screen=this.toScreen(e.x,e.y);t.save(),t.lineWidth=1;for(let n of this.marks.values()){let r=n.mark.linked===null?void 0:this.bodies.get(n.mark.linked);if(r===void 0||r.leaving)continue;let i=Lc(Tc[n.mark.phase]),a=Math.min(n.presence,r.presence),o=n.screen,s=r.screen,c=t.createLinearGradient(o.x,o.y,s.x,s.y);if(c.addColorStop(0,`rgba(${i}, ${(.55*a).toFixed(3)})`),c.addColorStop(1,`rgba(${i}, ${(.12*a).toFixed(3)})`),t.strokeStyle=c,t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(s.x,s.y),t.stroke(),e!==0){let n=(e*.45+r.phase)%1;t.beginPath(),t.arc(s.x+(o.x-s.x)*n,s.y+(o.y-s.y)*n,1.4,0,Math.PI*2),t.fillStyle=`rgba(${i}, ${(.85*a).toFixed(3)})`,t.fill()}}t.restore();for(let[n,r]of this.marks){let{mark:i,screen:a}=r,o=this.hovered===`task:${n}`,s=Tc[i.phase],c=i.phase===`waiting`&&e!==0?.65+.35*Math.sin(e*1.6+a.x):1,l=Math.max(3,4*this.scale)*(o?1.5:1);t.save(),t.globalAlpha=r.presence*c*(this.paused?.7:1),t.globalCompositeOperation=`lighter`;let u=l*7;t.drawImage(this.glow(s),a.x-u/2,a.y-u/2,u,u),t.globalCompositeOperation=`source-over`,t.translate(a.x,a.y),t.rotate(Math.PI/4),t.fillStyle=s,t.fillRect(-l/2,-l/2,l,l),o&&(t.strokeStyle=`rgba(255, 255, 255, 0.8)`,t.lineWidth=1,t.strokeRect(-l/2-2,-l/2-2,l+4,l+4)),t.restore()}}drawBubbles(){let{ctx:e}=this;e.save(),e.font=Ec,e.textAlign=`left`,e.textBaseline=`middle`;for(let[t,n]of this.bubbles){let r=this.bodies.get(t);if(r===void 0)continue;let i=this.clock-n.born,a=Math.min(1,i/.25,(Dc-i)/1.2)*r.presence;if(a<=0)continue;let o=n.text;if(e.measureText(o).width>Oc){for(;o.length>1&&e.measureText(`${o}…`).width>Oc;)o=o.slice(0,-1);o=`${o.trimEnd()}…`}let s=e.measureText(o).width+16,c=this.options.reducedMotion?0:i*7,l=Math.max(10,jc*this.scale),u=r.screen.x-s/2,d=r.screen.y-l-14-22-c;e.globalAlpha=a,e.beginPath(),e.roundRect(u,d,s,22,7),e.fillStyle=`rgba(23, 23, 23, 0.92)`,e.fill(),e.strokeStyle=`rgba(255, 255, 255, 0.1)`,e.lineWidth=1,e.stroke(),e.fillStyle=`rgba(${yc}, 1)`,e.fillText(o,u+8,d+11+.5)}e.restore()}drawSpecks(e){let{ctx:t}=this,n=-this.camX*this.scale*Ac,r=-this.camY*this.scale*Ac;for(let i of this.specks){let a=e===0?1:.6+.4*Math.sin(e*i.rate+i.phase);t.fillStyle=`rgba(255, 255, 255, ${(i.alpha*a*(this.paused?.6:1)).toFixed(3)})`,t.fillRect(B(i.x*this.width+n,this.width),B(i.y*this.height+r,this.height),i.size,i.size)}let i=this.toScreen(0,0),a=t.createRadialGradient(i.x,i.y,0,i.x,i.y,320*this.scale);a.addColorStop(0,`rgba(255, 255, 255, 0.035)`),a.addColorStop(1,`rgba(255, 255, 255, 0)`),t.fillStyle=a,t.fillRect(0,0,this.width,this.height)}drawAnchors(){let{ctx:e}=this,t=this.toScreen(0,0);e.save(),e.setLineDash([2,7]),e.lineWidth=1,e.strokeStyle=`rgba(255, 255, 255, 0.07)`;for(let n of this.spheres.values())if(n.anchor.kind===`project`){let r=this.toScreen(n.x,n.y);e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(r.x,r.y),e.stroke()}e.restore();for(let{anchor:t,x:n,y:r,radius:i}of this.spheres.values()){let a=this.toScreen(n,r),o=i*this.scale,s=t.id===this.focus;if(t.kind===`project`){let t=e.createRadialGradient(a.x,a.y,0,a.x,a.y,o*1.8);t.addColorStop(0,`rgba(160, 170, 255, ${s?.1:.05})`),t.addColorStop(1,`rgba(160, 170, 255, 0)`),e.fillStyle=t,e.fillRect(a.x-o*1.8,a.y-o*1.8,o*3.6,o*3.6)}e.beginPath(),e.arc(a.x,a.y,o,0,Math.PI*2),e.lineWidth=s?1.5:1,e.strokeStyle=s?`rgba(255, 255, 255, 0.28)`:t.kind===`society`?`rgba(255, 255, 255, 0.09)`:`rgba(255, 255, 255, 0.06)`,e.stroke(),e.textAlign=`center`,e.textBaseline=`top`,t.kind===`society`?(e.font=wc,e.letterSpacing=`2px`,e.fillStyle=`rgba(${xc}, 0.9)`,e.fillText(t.label.toUpperCase(),a.x,a.y+o+10),e.letterSpacing=`0px`):(e.font=Cc,e.fillStyle=s?`rgba(245, 245, 245, 1)`:`rgba(${bc}, 0.95)`,e.fillText(t.label,a.x,a.y+o+10))}}drawBody(e,t){let{ctx:n}=this,{star:r}=e,i=Et[r.cli],a=r.id===this.hovered,o=r.state===`working`,s=o?2.5:5,c=s*(Math.sin(t*.29+e.phase)+.6*Math.sin(t*.17+e.phase*2.1)),l=s*(Math.cos(t*.23+e.phase*1.3)+.6*Math.cos(t*.11+e.phase)),u=this.toScreen(e.x+c,e.y+l);e.screen=u;let d=o?2.4:r.state===`queued`?1.4:.7,f=t===0?.5:.5+.5*Math.sin(t*d+e.phase),p=((o?.95+.35*f:r.state===`queued`?.7+.2*f:.5+.2*f)+(a?.25:0)+.8*e.flash)*e.presence*(this.paused?.7:1),m=Math.max(10,jc*this.scale),h=(o?170:130)*this.scale*(.9+.15*f);n.save(),n.globalCompositeOperation=`lighter`,n.globalAlpha=Math.min(1,p),n.drawImage(this.glow(i.accent),u.x-h/2,u.y-h/2,h,h),n.restore(),n.save(),n.globalAlpha=e.presence;let g=Lc(i.accent);if(o&&t!==0){let r=(t+e.phase)%1.8/1.8;n.beginPath(),n.arc(u.x,u.y,m+(6+30*r)*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(${g}, ${(.4*(1-r)).toFixed(3)})`,n.lineWidth=1.25,n.stroke()}e.flash>0&&(n.beginPath(),n.arc(u.x,u.y,m+(3+12*(1-e.flash))*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(255, 255, 255, ${(.55*e.flash).toFixed(3)})`,n.lineWidth=1.25,n.stroke()),r.resident&&(n.beginPath(),n.arc(u.x,u.y,m+5*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(${g}, 0.3)`,n.lineWidth=1,n.stroke()),r.state===`queued`&&(n.beginPath(),n.arc(u.x,u.y,m+8*this.scale,0,Math.PI*2),n.setLineDash([3,4]),n.lineDashOffset=-t*8,n.strokeStyle=`rgba(${yc}, 0.55)`,n.lineWidth=1,n.stroke(),n.setLineDash([])),n.beginPath(),n.arc(u.x,u.y,m,0,Math.PI*2),n.fillStyle=vc,n.fill(),n.strokeStyle=`rgba(${g}, ${a?.95:.6})`,n.lineWidth=a?1.75:1.25,n.stroke(),n.save();let _=m*1.2/24;if(n.translate(u.x,u.y),n.scale(_,_),n.translate(-12,-12),n.fillStyle=i.fill,n.fill(this.glyphs[r.cli],`evenodd`),n.restore(),o)for(let r=0;r<3;r+=1){let i=t*1.8+r*Math.PI*2/3+e.phase,a=m+9*this.scale;n.beginPath(),n.arc(u.x+a*Math.cos(i),u.y+a*Math.sin(i),1.6,0,Math.PI*2),n.fillStyle=`rgba(${g}, 0.9)`,n.fill()}n.font=`500 ${Math.max(9,Math.min(11,11*this.scale)).toFixed(1)}px ${Sc}`,n.textAlign=`center`,n.textBaseline=`top`,n.fillStyle=`rgba(${yc}, ${a||o?1:.7})`,n.fillText(r.name,u.x,u.y+m+8*this.scale+3),n.restore()}},Bc=15e3,Vc=26,Hc=12,Uc=4,Wc=.0015,Gc=.01,Kc=1.3,qc=`grid size-7 place-items-center rounded-md text-sm text-fg-tertiary transition-colors hover:bg-surface-2/70 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`;function Jc(e,t,n,r){if(e===null)return;if(t===null){e.style.visibility=`hidden`;return}let i=e.offsetWidth,a=e.offsetHeight,o=r.left+Hc,s=n.width-r.right-Hc,c=t.x+Vc+i<=s?t.x+Vc:t.x-Vc-i,l=Math.min(Math.max(Hc,t.y-a/3),n.height-a-Hc);e.style.transform=`translate(${Math.round(Math.max(o,c))}px, ${Math.round(l)}px)`,e.style.visibility=`visible`}function Yc({model:e,paused:t,hovered:n,onHover:r,insets:i,focus:a,onSelectAnchor:o,onSelectStar:s,onSelectTask:c,live:l,card:u}){let d=(0,O.useRef)(null),f=(0,O.useRef)(null),p=(0,O.useRef)(null),m=(0,O.useRef)(i);(0,O.useLayoutEffect)(()=>{m.current=i},[i]);let h=(0,O.useRef)(e);(0,O.useLayoutEffect)(()=>{h.current=e},[e]);let g=no(),_=(0,O.useRef)(g);(0,O.useLayoutEffect)(()=>{_.current=g},[g]);let v=(0,O.useRef)(null),y=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{let e=d.current;if(e===null)throw Error(`the sky's canvas is not mounted`);let t=e.getBoundingClientRect(),n=new zc(e,{reducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,onHoverPosition:e=>Jc(f.current,e,t,m.current)});p.current=n;let r=new ResizeObserver(()=>{t=e.getBoundingClientRect(),n.resize(t.width,t.height,window.devicePixelRatio)});r.observe(e);let i=e=>{e.preventDefault();let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaY;n.zoomBy(Math.exp(-t*(e.ctrlKey?Gc:Wc)),{x:e.offsetX,y:e.offsetY})};return e.addEventListener(`wheel`,i,{passive:!1}),n.start(),()=>{e.removeEventListener(`wheel`,i),r.disconnect(),n.stop(),p.current=null}},[]),(0,O.useEffect)(()=>{p.current?.setModel(e)},[e]),(0,O.useEffect)(()=>l.listen(e=>{let t=p.current;if(t===null||e.event.type!==`tool_call`||Date.now()-Date.parse(e.ts)>Bc)return;let n=rc(h.current,e.agent,e.project);if(n===null)return;t.flash(n);let r=Mo(e.event.name,e.event.input);r!==null&&t.say(n,Ua(r,_.current))}),[l]),(0,O.useEffect)(()=>{p.current?.setPaused(t)},[t]),(0,O.useEffect)(()=>{p.current?.setHovered(n)},[n]),(0,O.useEffect)(()=>{p.current?.setFocus(a)},[a]),(0,O.useEffect)(()=>{p.current?.setInsets(i.left,i.right)},[i.left,i.right]),(0,A.jsxs)(`div`,{className:`absolute inset-0`,children:[(0,A.jsx)(`canvas`,{ref:d,className:`size-full touch-none`,"aria-hidden":`true`,onPointerDown:e=>{e.button===0&&(v.current={x:e.clientX,y:e.clientY,dragging:!1},y.current=!1)},onPointerUp:e=>{v.current?.dragging===!0&&(e.currentTarget.releasePointerCapture(e.pointerId),e.currentTarget.style.cursor=`grab`),v.current=null},onPointerMove:e=>{let t=p.current,i=v.current;if(i!==null&&t!==null){let n=e.clientX-i.x,a=e.clientY-i.y;if(!i.dragging&&Math.hypot(n,a)>Uc&&(i.dragging=!0,y.current=!0,e.currentTarget.setPointerCapture(e.pointerId),r(null)),i.dragging){t.panBy(n,a),i.x=e.clientX,i.y=e.clientY,e.currentTarget.style.cursor=`grabbing`;return}}let{offsetX:a,offsetY:o}=e.nativeEvent,s=t?.hitTest(a,o)??null,c=s===null?t?.hitTestMark(a,o)??null:null,l=s??(c===null?null:`task:${c}`),u=l===null?t?.hitTestAnchor(a,o)??null:null;e.currentTarget.style.cursor=l!==null||u!==null?`pointer`:`grab`,l!==n&&r(l)},onPointerLeave:()=>r(null),onClick:e=>{let t=p.current,{offsetX:n,offsetY:r}=e.nativeEvent;if(t===null||y.current){y.current=!1;return}let i=t.hitTest(n,r),a=i===null?t.hitTestMark(n,r):null,l=i===null&&a===null?t.hitTestAnchor(n,r):null;i===null?a===null?l!==null&&o(l):c(a):s(i)}}),(0,A.jsxs)(`fieldset`,{className:`card absolute bottom-4 flex flex-col gap-0.5 p-1`,style:{right:i.right+16},children:[(0,A.jsx)(`legend`,{className:`sr-only`,children:`Camera`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,className:qc,onClick:()=>p.current?.zoomBy(Kc),children:`+`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,className:qc,onClick:()=>p.current?.zoomBy(1/Kc),children:`−`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Fit the whole sky`,title:`Fit the whole sky`,className:qc,onClick:()=>p.current?.home(),children:`⤢`})]}),(0,A.jsx)(`div`,{ref:f,className:`pointer-events-none absolute top-0 left-0 will-change-transform`,style:{visibility:`hidden`},children:u})]})}var Xc={left:0,right:0};function Zc(){let[e,t]=(0,O.useState)(()=>window.innerWidth);return(0,O.useEffect)(()=>{let e=()=>t(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function Qc(e,t){return e.startsWith(t)?decodeURIComponent(e.slice(t.length)):null}function $c(){let{api:e,token:t,signOut:n,expire:r}=Pe(),i=m();(0,O.useEffect)(()=>gs(t,{onEvent:e=>ys(i,e),onResume:()=>void i.invalidateQueries()}),[t,i]);let[a]=(0,O.useState)(()=>new Io);(0,O.useEffect)(()=>a.follow(t),[a,t]);let o=u(),s=ye(),c=ct(),l=se(),d=Le(),f=ue(),p=et(),g=ce(),_=at(),[v]=(0,O.useState)(()=>new Ds(t=>e.messages(t))),y=(0,O.useSyncExternalStore)(v.subscribe,v.snapshot),ee=(0,O.useCallback)(e=>v.want(e),[v]),x=s.data?.signIn,S=(0,O.useMemo)(()=>za(f.data??[],p,g.data??[],_.data??[],{messages:y,name:e=>Qo(e,x)}),[f.data,p,g.data,_.data,y,x]),C=St(),te=ht({mutationFn:t=>e.setPaused(t),onSuccess:()=>void i.invalidateQueries({queryKey:[`scheduler`]})}),w=la({select:e=>e.location.pathname}),ne=la({select:e=>e.location.href}),re=la({select:e=>e.location.state.__TSR_index});(0,O.useEffect)(()=>Ls(re,ne),[re,ne]);let[ie,ae]=(0,O.useState)(!1),[oe,le]=(0,O.useState)(null),de=oe===w,fe=(0,O.useCallback)(()=>le(null),[]),pe=(0,O.useRef)(!0),me=Ma(),he=Li({strict:!1}),[ge,_e]=(0,O.useState)(null),ve=ut(3e4),be=Zc(),xe=w!==`/`,[Se,Ce]=(0,O.useState)(Ts),T=Cs(be,Se),E=(e,t)=>{let n=Cs(be,e),r=n>=Ss(be)?`widest`:n;Ce(r),t&&Es(r)},we=()=>{let e=ws(be,Se);Ce(e),Es(e)},Te=(0,O.useMemo)(()=>xe?{left:288,right:T+32}:Xc,[xe,T]),Ee=Qc(w,`/thread/`),De=h(Qc(w,`/task/`)),D=Qc(w,`/c/`)??(Ee===null?null:f.data?.find(e=>e.id===Ee)?.channel??null),ke=/^\/p\/([^/]+)\/tasks$/.exec(w)?.[1]??De.data?.project??null,je=Qc(w,`/citizen/`),Me=je===null?null:he.scope??null,Ne=Me?.split(`/`)[0]??null,Fe=w===`/needs-you`?`needs-you`:w===`/proposals`||w.startsWith(`/proposal/`)?`proposals`:null,Ie=Ia().length,Re=Oe().data?.length??0,ze=_.data?.filter(ya).length??0,Be=w===`/society`||w.startsWith(`/skills/`)?Ae:/^\/p\/([^/]+)$/.exec(w)?.[1]??/^\/knowledge\/([^/]+)\//.exec(w)?.[1]??null;(0,O.useEffect)(()=>{let e=()=>{pe.current=!0},t=e=>{if(e.key===`Tab`&&(pe.current=!1),document.querySelector(`:modal`)!==null)return;let t=e.target instanceof HTMLElement?e.target:null;if(!(t?.closest(`input, textarea, select, [contenteditable]`)!=null||e.metaKey||e.ctrlKey||e.altKey)){if(e.key===` `){if(t?.closest(`button, a, summary, [role='button']`)!=null&&!pe.current)return;e.preventDefault(),le(w)}else e.key===`Escape`&&(de?le(null):ie?ae(!1):xe&&C({to:`/`}))}};return window.addEventListener(`keydown`,t),window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`pointerdown`,e)}},[xe,ie,de,w,C]);let Ve=[o,c,l,d].some(e=>e.error instanceof b&&e.error.status===401);(0,O.useEffect)(()=>{Ve&&r()},[Ve,r]);let He=(0,O.useMemo)(()=>c.data===void 0||l.data===void 0||d.data===void 0?null:tc({members:c.data,projects:l.data,scheduler:d.data,tasks:p}),[c.data,l.data,d.data,p]);if(He===null){let e=[c,l,d].some(e=>e.error!==null);return(0,A.jsx)(`main`,{className:`grid h-full place-items-center`,children:(0,A.jsx)(`p`,{className:`text-meta`,"aria-live":`polite`,children:e?`The board server is not answering. Retrying…`:`Reading the board…`})})}let Ue=(Fe!==null||w===`/metrics`||w===`/runners`||w===`/crons`?`society`:null)??Be??ke??(D===null?je===null?null:Ne??He.stars.find(e=>e.name===je)?.anchor??null:D.includes(`/`)?D.split(`/`)[0]??null:`society`),We=be-Te.left-Te.right,Ge=We>=460,Ke=Math.min(560,(Ge?We:be)-32),qe={left:(Ge?Te.left:0)+((Ge?We:be)-Ke)/2,width:Ke},Je=ha(f.data??[]).filter(e=>va(e,me)),Ye=e=>e===`society`?`the society`:l.data?.find(t=>t.slug===e)?.name??e,Xe=He.stars.find(e=>e.id===ge),Ze=He.tasks.find(e=>`task:${e.id}`===ge),Qe=c.data?.find(e=>e.name===Xe?.name),$e=Xe===void 0?`the society`:Ye(Xe.queuedFor??Xe.anchor),tt=e=>{let t=He.stars.find(t=>t.id===e);t!==void 0&&C({to:`/citizen/$name`,params:{name:t.name},search:t.state===`working`?{scope:t.anchor}:{}})},nt=e=>{C({to:`/task/$taskId`,params:{taskId:e}})};return(0,A.jsx)(Lo,{value:a,children:(0,A.jsx)(eo,{value:S,children:(0,A.jsx)(to,{value:ee,children:(0,A.jsx)(L,{value:s.data?.signIn,children:(0,A.jsxs)(`main`,{className:`relative h-full overflow-hidden`,children:[(0,A.jsx)(Yc,{model:He,paused:d.data?.paused??!1,hovered:ge,onHover:_e,insets:Te,focus:Ue,onSelectAnchor:e=>{C(e===`society`?{to:`/society`}:{to:`/p/$slug`,params:{slug:e}})},onSelectStar:tt,onSelectTask:nt,live:a,card:Ze===void 0?Xe===void 0||Qe===void 0?null:(0,A.jsx)(ss,{member:Qe,star:Xe,place:$e,now:ve}):(0,A.jsx)(hs,{mark:Ze,project:Ye(Ze.project),members:c.data})}),(0,A.jsx)(cs,{society:o.data?.name,citizens:new Set(He.stars.map(e=>e.name)).size,citizensOpen:w===`/citizens`,onToggleCitizens:()=>void C(w===`/citizens`?{to:`/`}:{to:`/citizens`}),runnersOpen:w===`/runners`,onToggleRunners:()=>void C(w===`/runners`?{to:`/`}:{to:`/runners`}),enrolling:Re,cronsOpen:w===`/crons`,onToggleCrons:()=>void C(w===`/crons`?{to:`/`}:{to:`/crons`}),failingCrons:ze,attention:Ie,onOpenAttention:()=>void C({to:`/needs-you`}),paused:d.data?.paused??!1,onTogglePause:()=>te.mutate(!(d.data?.paused??!1)),pauseBusy:te.isPending,boardOpen:xe,onToggleBoard:()=>void C(xe?{to:`/`}:{to:`/c/$`,params:{_splat:`general`}}),logsOpen:ie,metricsOpen:w===`/metrics`,onToggleMetrics:()=>void C(w===`/metrics`?{to:`/`}:{to:`/metrics`}),onToggleLogs:()=>ae(!ie),onSignOut:n}),xe?(0,A.jsx)(I,{activeChannel:D,activeTasks:ke,activeCitizen:je,activeScope:Me,activeGovernance:Fe,activeOverview:Be}):null,xe?(0,A.jsxs)(wa,{label:`Board content`,className:`top-[72px] right-4 bottom-4`,style:{width:T},children:[(0,A.jsx)(ms,{width:T,min:420,max:Ss(be),onResize:E,onToggle:we}),(0,A.jsx)($i,{})]}):null,ie?(0,A.jsx)(ds,{onClose:()=>ae(!1)}):null,de?(0,A.jsx)(rs,{left:qe.left,width:qe.width,onClose:fe}):(0,A.jsx)(`div`,{className:`pointer-events-none absolute bottom-5 flex justify-center px-16`,style:{left:Te.left,right:Te.right},children:(0,A.jsx)(is,{unread:Je,onOpen:()=>le(w)})}),He.stars.length===0&&!xe?(0,A.jsx)(`p`,{className:`pointer-events-none absolute inset-x-0 top-1/2 mt-24 text-center text-meta`,children:`No citizens yet.`}):null,(0,A.jsx)(`ul`,{className:`sr-only`,"aria-label":`Tasks in play`,children:He.tasks.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`button`,{type:`button`,onFocus:()=>_e(`task:${e.id}`),onBlur:()=>_e(null),onClick:()=>nt(e.id),children:zs(e,Ye(e.project))})},e.id))}),(0,A.jsx)(`ul`,{className:`sr-only`,"aria-label":`Citizens`,children:He.stars.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onFocus:()=>_e(e.id),onBlur:()=>_e(null),onClick:()=>tt(e.id),children:[e.name,`, `,e.state,e.state===`working`?` at ${Ye(e.anchor)}`:``]})},e.id))})]})})})})})}var el=`modulepreload`,tl=function(e){return`/`+e},nl={},rl=function(e){return e.pathname.endsWith(`.css`)},il=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},al=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=tl(t,n);let r=s(t),i=rl(r);return il(nl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:el,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ol(e){let t=a.safeParse(e.message);return t.success?{message:t.data}:{}}function sl(e){let t=Number(e.line);return Number.isInteger(t)&&t>0?{line:t}:{}}function cl(){return null}var V=Hi({component:$c}),ll=aa({routeTree:V.addChildren([Bi({getParentRoute:()=>V,path:`/`,component:cl}),Bi({getParentRoute:()=>V,path:`/c/$`,validateSearch:ol,component:j(()=>al(()=>import(`./ChannelView-CY3oG9hZ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])),`ChannelView`)}),Bi({getParentRoute:()=>V,path:`/thread/$threadId`,validateSearch:ol,component:j(()=>al(()=>import(`./ThreadView-CT9vd0P4.js`),__vite__mapDeps([14,1,2,3,10,6,4,5,8,9,11,12,13])),`ThreadView`)}),Bi({getParentRoute:()=>V,path:`/society`,component:j(()=>al(()=>import(`./SocietyView-BDiVxUC5.js`),__vite__mapDeps([15,1,2,7,5,4,6,11,16,17,18])),`SocietyView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug`,component:j(()=>al(()=>import(`./ProjectView-T2OHTh5j.js`),__vite__mapDeps([19,1,2,9,10,6,4,5,7,11,16,17,18,20])),`ProjectView`)}),Bi({getParentRoute:()=>V,path:`/knowledge/$scope/$topic`,component:j(()=>al(()=>import(`./KnowledgeView-DDl0HQPG.js`),__vite__mapDeps([21,1,2,5,3,10,6,4,11])),`KnowledgeView`)}),Bi({getParentRoute:()=>V,path:`/skills/$name`,component:j(()=>al(()=>import(`./SkillView-Di5Z9h2L.js`),__vite__mapDeps([22,1,2,5,23,9,3,10,6,4,11,16,17,18,24])),`SkillView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug/tasks`,component:j(()=>al(()=>import(`./TasksView-oZMjncOU.js`),__vite__mapDeps([25,1,9,11])),`TasksView`)}),Bi({getParentRoute:()=>V,path:`/task/$taskId`,component:j(()=>al(()=>import(`./TaskView-CKcs-MOC.js`),__vite__mapDeps([26,1,2,9,23,3,10,6,4,5,11,12,20,27,8])),`TaskView`)}),Bi({getParentRoute:()=>V,path:`/task/$taskId/files/$`,validateSearch:sl,component:j(()=>al(()=>import(`./FileView-DcQvlc8V.js`),__vite__mapDeps([28,1,3,10,6,11])),`TaskFileView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug/files/$`,validateSearch:sl,component:j(()=>al(()=>import(`./FileView-DcQvlc8V.js`),__vite__mapDeps([28,1,3,10,6,11])),`ProjectFileView`)}),Bi({getParentRoute:()=>V,path:`/metrics`,validateSearch:t=>{let n=e.safeParse(t.window);return n.success?{window:n.data}:{}},component:j(()=>al(()=>import(`./MetricsView-DiXyYeWP.js`),__vite__mapDeps([29,1,11,16,17,18])),`MetricsView`)}),Bi({getParentRoute:()=>V,path:`/citizens`,validateSearch:t=>{let n=e.safeParse(t.window);return n.success?{window:n.data}:{}},component:j(()=>al(()=>import(`./CitizensView-WPQ6Jhl3.js`),__vite__mapDeps([30,1,17,11,18,31,2])),`CitizensView`)}),Bi({getParentRoute:()=>V,path:`/needs-you`,component:j(()=>al(()=>import(`./NeedsYouView-CKmuYan_.js`),__vite__mapDeps([32,1,23,9,11])),`NeedsYouView`)}),Bi({getParentRoute:()=>V,path:`/runners`,validateSearch:e=>typeof e.code==`string`?{code:e.code}:{},component:j(()=>al(()=>import(`./RunnersView-DdvwoOur.js`),__vite__mapDeps([33,1,2,17,4,5,6,11,31,18])),`RunnersView`)}),Bi({getParentRoute:()=>V,path:`/crons`,validateSearch:e=>({...typeof e.agent==`string`?{agent:e.agent}:{},...typeof e.cron==`string`?{cron:e.cron}:{}}),component:j(()=>al(()=>import(`./CronsView-_pdgwX1I.js`),__vite__mapDeps([34,1,2,17,10,6,4,5,11,18,35])),`CronsView`)}),Bi({getParentRoute:()=>V,path:`/proposals`,component:j(()=>al(()=>import(`./ProposalsView-p4KjwV9p.js`),__vite__mapDeps([36,1,23,9,11])),`ProposalsView`)}),Bi({getParentRoute:()=>V,path:`/proposal/$proposalId`,component:j(()=>al(()=>import(`./ProposalView-B5yjTAcn.js`),__vite__mapDeps([37,1,2,17,9,23,3,10,6,4,5,11,12,24,36,27,8])),`ProposalView`)}),Bi({getParentRoute:()=>V,path:`/citizen/$name`,validateSearch:e=>({...typeof e.scope==`string`?{scope:e.scope}:{},...e.tab===`turns`||e.tab===`memory`||e.tab===`history`?{tab:e.tab}:{},...typeof e.turn==`string`?{turn:e.turn}:{}}),component:j(()=>al(()=>import(`./CitizenView-BNK5ro-6.js`),__vite__mapDeps([38,1,2,17,10,6,4,5,11,12,18,35,31])),`CitizenView`)})])});function ul({signInError:e}){let t=m(),[n,r]=(0,O.useState)(ae),i=(0,O.useCallback)(()=>{v(),t.clear(),r(null)},[t]),a=(0,O.useCallback)(()=>{n!==null&&he(n).signOut().catch(()=>void 0),i(),ll.navigate({to:`/`})},[n,i]),o=(0,O.useMemo)(()=>n===null?null:{api:he(n),token:n,signOut:a,expire:i},[n,a,i]);return o===null?(0,A.jsx)(pa,{initialError:e,onEnter:e=>{_e(e),r(e)}}):(0,A.jsx)(Me,{value:o,children:(0,A.jsx)(ca,{router:ll})})}var dl={expired:`The sign-in took too long or was already used. Try again.`,declined:`GitHub sign-in was cancelled.`,github:`GitHub could not confirm who signed in. Try again.`,"not-allowed":`That GitHub account is not allowed on this board.`};function fl(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`session`),r=t.get(`signin-error`);return n===null&&r===null?null:{token:n===null||n===``?null:n,error:r===null?null:dl[r]??`GitHub sign-in failed.`}}function pl(){let e=fl(window.location.hash);return e!==null&&(e.token!==null&&_e(e.token),window.history.replaceState(window.history.state,``,`${window.location.pathname}${window.location.search}`)),e}var ml=new zt({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),hl=pl(),gl=document.getElementById(`root`);if(gl===null)throw Error(`missing #root element`);(0,ua.createRoot)(gl).render((0,A.jsx)(O.StrictMode,{children:(0,A.jsx)(de,{client:ml,children:(0,A.jsx)(ul,{signInError:hl?.error??null})})}));export{Ii as A,Pa as C,Sa as D,ya as E,la as O,Ia as S,xa as T,oo as _,Xo as a,Ya as b,fo as c,Po as d,yo as f,ao as g,Ro as h,ts as i,Ut as j,Li as k,Fo as l,po as m,As as n,Zo as o,jo as p,Rs as r,$o as s,Ps as t,uo as u,no as v,ba as w,$a as x,ro as y};
|
|
23
|
+
`).map(e=>e.trim()).find(e=>e.length>0)??``}function Co(e){return/^\/bin\/(?:ba)?sh -lc (["'])([\s\S]*)\1$/.exec(e.trim())?.[2]??e}function wo(e){return typeof e==`object`&&e&&!Array.isArray(e)?Object.fromEntries(Object.entries(e)):{}}var To=[`file_path`,`path`,`url`,`query`,`pattern`,`description`,`prompt`];function Eo(e){let t=wo(e),n=t.command;if(typeof n==`string`){let e=Co(n);return{summary:bo(xo(e),ho),detail:bo(e,go)}}let r=bo(JSON.stringify(e??null,null,2),go),i=t.changes;if(Array.isArray(i))return{summary:bo(i.map(e=>wo(e).path).filter(e=>typeof e==`string`).join(`, `),ho),detail:r};let a=To.map(e=>t[e]).find(e=>typeof e==`string`&&e.trim()!==``),o=Object.values(t).filter(e=>typeof e==`string`||typeof e==`number`);return{summary:bo(xo(a??o.slice(0,3).join(` · `)),ho),detail:r}}var Do=`StructuredOutput`;function Oo(e,t){try{return wo(JSON.parse(e)).summary===t}catch{return!1}}function ko(e,t,n){let r=[...e.steps,t],i=r.length-n;return{...e,steps:i>0?r.slice(i):r,fromStart:e.fromStart&&i<=0,lastAt:t.at}}function Ao(e,t,{maxSteps:n}={maxSteps:mo}){let{event:r}=t,i=uo(t.agent,t.project,t),a=e.get(i),o=new Map(e),s={agent:t.agent,scope:t.project,...t.thread===void 0?{}:{thread:t.thread},...t.channel===void 0?{}:{channel:t.channel},...t.place===void 0?{}:{place:t.place}};if(r.type===`turn_started`)return o.set(i,{...s,startedAt:t.ts,fromStart:!0,model:r.model??null,steps:[],lastAt:t.ts,end:null}),o;let c=a!==void 0&&a.end===null?a:{...s,startedAt:t.ts,fromStart:!1,model:null,steps:[],lastAt:t.ts,end:null};switch(r.type){case`text`:o.set(i,ko(c,{kind:`say`,seq:t.seq,at:t.ts,text:r.delta},n));break;case`tool_call`:if(r.name===Do)break;o.set(i,ko(c,{kind:`tool`,seq:t.seq,at:t.ts,name:r.name,...Eo(r.input),ok:null,output:null},n));break;case`tool_result`:{let e=c.steps.findIndex(e=>e.kind===`tool`&&e.name===r.name&&e.ok===null),n=c.steps[e];if(n?.kind===`tool`){let a=c.steps.with(e,{...n,ok:r.ok,output:r.output??null});o.set(i,{...c,steps:a,lastAt:t.ts})}break}case`error`:o.set(i,ko(c,{kind:`error`,seq:t.seq,at:t.ts,message:r.message},n));break;case`steered`:o.set(i,ko(c,{kind:`steer`,seq:t.seq,at:t.ts,...vo(r.text??``)},n));break;case`turn_completed`:{let e=r.status?.summary??null,n=c.steps.at(-1),a=n?.kind===`say`&&e!==null&&Oo(n.text,e);o.set(i,{...c,steps:a?c.steps.slice(0,-1):c.steps,lastAt:t.ts,end:{at:t.ts,exitReason:r.exitReason,summary:e}});break}}return o}function jo(e,t,n,r={}){let i=new Map;for(let[a,o]of e.entries())i=Ao(i,{seq:a+1,ts:o.ts,agent:t,project:n,...r.thread===void 0?{}:{thread:r.thread},...r.channel===void 0?{}:{channel:r.channel},...r.place===void 0?{}:{place:r.place},event:o.event},{maxSteps:1/0});return i.get(uo(t,n,r))}function Mo(e,t){if(yo(e)!==`post_message`)return null;let n=wo(t).body,r=typeof n==`string`?So(n).replace(/^[#>*\-\s]+/,``):``;return r===``?null:bo(r,ho)}function No(e){let t=e.steps.at(-1);return t===void 0?null:t.kind===`tool`?`${yo(t.name)} · ${t.summary}`:t.kind===`steer`?`took ${Po(t.posts.length)}${t.from.length===0?``:` from ${t.from.join(`, `)}`}`:bo(So(t.kind===`say`?t.text:t.message),ho)}function Po(e){return e===1?`1 post`:`${e} posts`}function Fo(e,t){return Ze(t-Date.parse(e))}var Io=class{turns=new Map;listeners=new Set;eventListeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});snapshot=()=>this.turns;listen=e=>(this.eventListeners.add(e),()=>{this.eventListeners.delete(e)});follow(e){return lo({token:e,url:()=>`/api/turns/stream?since=0`,onOpen:()=>{this.turns=new Map,this.emit()},onData:e=>{let t=Ke.safeParse(JSON.parse(e));if(t.success){this.turns=Ao(this.turns,t.data);for(let e of this.eventListeners)e(t.data)}},onBatch:()=>this.emit()})}emit(){for(let e of this.listeners)e()}},Lo=(0,O.createContext)(null);function Ro(){let e=(0,O.useContext)(Lo);if(e===null)throw Error(`useLiveTurns needs a LiveContext`);return(0,O.useSyncExternalStore)(e.subscribe,e.snapshot)}var zo=`calc(2.5 * (1.25rem + 0.125rem + 11px * 1.5 + 0.75rem) + 0.25rem)`;function Bo(e,t){if(e||t)return`linear-gradient(to bottom, ${e?`transparent, black 1rem`:`black`}, ${t?`black calc(100% - 1rem), transparent`:`black`})`}function Vo(e,t){let[n,r]=(0,O.useState)({above:!1,below:!1});return(0,O.useLayoutEffect)(()=>{let n=e.current;if(n===null||t.current===null)throw Error(`the list of turns is not mounted`);let i=()=>{let e=n.scrollTop>0,t=n.scrollTop+n.clientHeight<n.scrollHeight-1;r(n=>n.above===e&&n.below===t?n:{above:e,below:t})};i(),n.addEventListener(`scroll`,i,{passive:!0});let a=new ResizeObserver(i);return a.observe(t.current),()=>{n.removeEventListener(`scroll`,i),a.disconnect()}},[e,t]),n}function Ho({activeCitizen:e,activeScope:t}){let n=Le(),r=ct(),i=Ro(),a=no(),o=ut(5e3),s=pe(n.data?.running??[]),c=n.data?.pending.length??0,l=(0,O.useRef)(null),u=(0,O.useRef)(null),d=Vo(l,u),f=[d.above||d.below?`${s.length} running`:null,c>0?`${c} queued`:null].filter(e=>e!==null),p=Bo(d.above,d.below);return(0,A.jsxs)(`section`,{"aria-label":`Working now`,className:`mt-3`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center justify-between px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:[(0,A.jsx)(`span`,{children:`Working now`}),f.length>0?(0,A.jsx)(`span`,{className:`font-normal tracking-normal normal-case`,children:f.join(` · `)}):null]}),(0,A.jsx)(`div`,{ref:l,className:`scrollbar-hidden -mx-1 scroll-py-4 overflow-y-auto px-1 py-0.5`,style:{height:zo,...p===void 0?{}:{maskImage:p}},children:(0,A.jsx)(`div`,{ref:u,children:s.length===0?(0,A.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`Nobody is in a turn.`}):(0,A.jsx)(`ul`,{children:s.map(({agent:n,scope:s,thread:c,channel:l,place:u})=>{let d=i.get(uo(n,s,{thread:c,channel:l,place:u})),f=d!==void 0&&d.end===null,p=r.data?.find(e=>e.name===n)?.cli??null,m=f?No(d):null,h=fo({scope:s,thread:c,channel:l,place:u}),g=n===e&&(t===null||t===h||t===s),_=s===`society`?`society`:s,v=c===void 0?l===void 0?u===void 0?null:`${u}'s channels`:`#${l}`:a.get(c)?.title??`a thread`;return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/citizen/$name`,params:{name:n},search:{scope:h},className:`block rounded-lg px-2 py-1.5 transition-colors ${g?`bg-surface-2/80 text-fg-primary`:`text-fg-secondary hover:bg-surface-2/50 hover:text-fg-primary`}`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{className:`relative grid size-4 shrink-0 place-items-center`,children:[p===null?null:(0,A.jsx)(Ot,{cli:p,size:13}),(0,A.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 size-1.5 animate-pulse rounded-full bg-emerald-400`})]}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:v===null?_:`${_} · ${v}`}),f?(0,A.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-tertiary`,children:[d.fromStart?``:`≥ `,Fo(d.startedAt,o)]}):null]}),(0,A.jsx)(`span`,{className:`mt-0.5 block truncate pl-5.5 text-[11px] text-fg-muted`,children:m===null?`Starting…`:(0,A.jsx)(oo,{text:m,links:!1})})]})},h===s?`${n}/${s}`:`${n}/${h}`)})})})})]})}var Uo=`flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm transition-colors`;function Wo(e){return`block truncate rounded-md px-2 text-[11px] font-semibold tracking-wider uppercase transition-colors ${e?`text-fg-primary`:`text-fg-muted hover:text-fg-primary`}`}var Go=`bg-surface-2/80 text-fg-primary`,Ko=`text-fg-secondary hover:bg-surface-2/50 hover:text-fg-primary`;function qo({slug:e,active:t}){let n=(mt(e).data??[]).filter(kt).length;return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/p/$slug/tasks`,params:{slug:e},className:`${Uo} ${t?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◇`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`tasks`}),n>0?(0,A.jsx)(`span`,{title:`${n} tasks in play`,className:`rounded-md bg-surface-2/70 px-1.5 text-[11px] text-fg-tertiary`,children:n}):null]})})}function Jo({value:e,title:t}){return e===0?null:(0,A.jsx)(`span`,{title:t,className:`rounded-md bg-amber-500/15 px-1.5 text-[11px] text-amber-300`,children:e})}function F({active:e}){let t=(ce().data??[]).filter(Ft).length,n=Ia().length;return(0,A.jsxs)(`section`,{"aria-label":`Governance`,className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:`Governance`}),(0,A.jsxs)(`ul`,{children:[(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/needs-you`,className:`${Uo} ${e===`needs-you`?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◉`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`needs you`}),(0,A.jsx)(Jo,{value:n,title:`${n} waiting on you`})]})}),(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/proposals`,className:`${Uo} ${e===`proposals`?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`◈`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`proposals`}),(0,A.jsx)(Jo,{value:t,title:`${t} waiting on you`})]})})]})]})}function I({activeChannel:e,activeTasks:t,activeCitizen:n,activeScope:r,activeGovernance:i,activeOverview:a}){let o=ze(),s=se(),c=ue(),l=Ma();(0,O.useEffect)(()=>{o.data!==void 0&&Na(o.data.map(e=>[e.ref,e.lastMessageId]))},[o.data]);let u=(0,O.useMemo)(()=>(s.data??[]).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.slug.localeCompare(t.slug)),[s.data]),d=u.filter(e=>e.archived!==void 0),f=(0,O.useMemo)(()=>{let e=(o.data??[]).filter(e=>e.archived===void 0);return[{key:`society`,label:`Society`,project:null,channels:e.filter(e=>e.project===null)},...u.filter(e=>e.archived===void 0).map(t=>({key:t.slug,label:t.name,project:t.slug,channels:e.filter(e=>e.project===t.slug)}))]},[o.data,u]),p=(0,O.useMemo)(()=>{let e=new Map;for(let t of c.data??[])t.state===`open`&&e.set(t.channel,(e.get(t.channel)??0)+1);return e},[c.data]);return(0,A.jsxs)(wa,{label:`Board navigator`,className:`top-[72px] bottom-4 left-4 w-64`,children:[(0,A.jsxs)(`header`,{className:`flex items-center justify-between px-4 pt-4 pb-1`,children:[(0,A.jsx)(`span`,{className:`text-caps`,children:`Board`}),(0,A.jsx)(y,{to:`/`,"aria-label":`Close the board`,className:`grid size-7 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary`,children:`✕`})]}),(0,A.jsxs)(`nav`,{className:`flex-1 overflow-y-auto px-2 pb-3`,children:[(0,A.jsx)(Ho,{activeCitizen:n,activeScope:r}),(0,A.jsx)(F,{active:i}),f.map(n=>(0,A.jsxs)(`section`,{className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`pb-1`,children:n.project===null?(0,A.jsx)(y,{to:`/society`,className:Wo(a===n.key),children:n.label}):(0,A.jsx)(y,{to:`/p/$slug`,params:{slug:n.project},className:Wo(a===n.key),children:n.label})}),(0,A.jsxs)(`ul`,{children:[n.channels.map(t=>{let n=t.ref===e,r=p.get(t.ref)??0,i=!n&&Fa(l,t.ref,t.lastMessageId);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/c/$`,params:{_splat:t.ref},className:`${Uo} ${n?Go:Ko}`,children:[(0,A.jsx)(`span`,{className:`text-fg-muted`,children:`#`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${i?`font-semibold`:``}`,children:t.name}),r>0?(0,A.jsx)(`span`,{title:`${r} open threads`,className:`rounded-md bg-surface-2/70 px-1.5 text-[11px] text-fg-tertiary`,children:r}):null,i?(0,A.jsx)(`span`,{"aria-label":`new messages`,className:`size-1.5 rounded-full bg-emerald-400`}):null]})},t.ref)}),n.project===null?null:(0,A.jsx)(qo,{slug:n.project,active:n.project===t})]})]},n.key)),d.length===0?null:(0,A.jsxs)(`section`,{"aria-label":`Archived projects`,className:`mt-3`,children:[(0,A.jsx)(`h3`,{className:`px-2 pb-1 text-[11px] font-semibold tracking-wider text-fg-muted uppercase`,children:`Archived`}),(0,A.jsx)(`ul`,{children:d.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/p/$slug`,params:{slug:e.slug},className:`${Uo} ${a===e.slug?Go:Ko}`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`text-fg-muted`,children:`▫`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]})},e.slug))})]})]})]})}var L=(0,O.createContext)(void 0);function Yo(e,t){let n=new URL(e);return n.searchParams.set(n.hostname===`github.com`?`size`:`s`,String(t)),n.href}function Xo({name:e,members:t}){let n=(0,O.useContext)(L),r=t?.find(t=>t.name===e)?.cli??null;return r===null?e===`user`&&n!==void 0?(0,A.jsx)(`img`,{src:Yo(n.avatarUrl,56),alt:``,width:28,height:28,referrerPolicy:`no-referrer`,className:`size-7 shrink-0 rounded-lg bg-surface-2/80 object-cover`}):e===`user`?(0,A.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-fg-primary/90 text-[10px] font-semibold text-surface-0`,children:`you`}):(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface-2/50 text-xs text-fg-muted`,children:`✦`}):(0,A.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface-2/80`,children:(0,A.jsx)(Ot,{cli:r,size:16})})}function Zo({name:e,members:t}){let n=t?.find(t=>t.name===e)?.cli??null;return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 align-middle`,children:[n===null?null:(0,A.jsx)(Ot,{cli:n,size:12}),(0,A.jsx)(`span`,{className:`text-fg-secondary`,children:e})]})}function Qo(e,t){return e===`user`?t?.login??`you`:e}function $o(){let e=(0,O.useContext)(L);return t=>Qo(t,e)}var es=6;function ts({target:e,placeholder:t,initialText:n=``,className:r=`border-t border-line p-3`,focusOnOpen:i=!1,onPosted:a,onEmptyEscape:o}){let{api:s}=Pe(),c=m(),l=ct(),[u,d]=(0,O.useState)(n),[f,p]=(0,O.useState)(0),[h,g]=(0,O.useState)(0),[_,v]=(0,O.useState)(!1),y=(0,O.useRef)(null),ee=(0,O.useRef)(null),x=ht({mutationFn:async t=>{if(`channel`in e)return s.sendMessage({channel:e.channel,body:t});if(`threadId`in e)return s.sendMessage({thread_id:e.threadId,body:t});let n=await s.openThread({channel:st,title:ga(t)});return s.sendMessage({thread_id:n.id,body:t})},onSuccess:t=>{d(n),c.invalidateQueries({queryKey:t.thread===void 0?[`channel`,t.channel]:[`thread`,t.thread]}),`ask`in e&&c.invalidateQueries({queryKey:[`threads`]}),c.invalidateQueries({queryKey:[`requests`]}),a?.(t)}});(0,O.useEffect)(()=>{i&&y.current?.focus()},[i]),(0,O.useLayoutEffect)(()=>{let e=y.current;e!==null&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`,ee.current!==null&&(e.setSelectionRange(ee.current,ee.current),ee.current=null))});let S=_?null:wt(u,f),C=(l.data??[]).filter(e=>e.status===`active`&&e.cli!==null),te=S===null?[]:C.filter(e=>e.name.startsWith(S.prefix)).slice(0,es),w=e=>{if(S===null)return;let t=Tt(u,f,S.start,e);ee.current=t.caret,d(t.text),p(t.caret)},ne=()=>{u.trim()!==``&&u.trim()!==n.trim()&&!x.isPending&&x.mutate(u.trim())};return(0,A.jsxs)(`form`,{className:r,onSubmit:e=>{e.preventDefault(),ne()},children:[(0,A.jsxs)(`div`,{className:`relative flex items-end gap-2 rounded-xl bg-surface-2/50 pr-1.5 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] focus-within:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.16)]`,children:[te.length>0?(0,A.jsx)(`ul`,{"aria-label":`Citizens to mention`,className:`card absolute bottom-full left-2 mb-2 w-60 overflow-hidden py-1`,children:te.map((e,t)=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),w(e.name)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${t===h?`bg-surface-2 text-fg-primary`:`text-fg-secondary`}`,children:[e.cli===null?null:(0,A.jsx)(Ot,{cli:e.cli,size:14}),(0,A.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] text-fg-muted`,children:e.role})]})},e.name))}):null,(0,A.jsx)(`textarea`,{ref:y,rows:1,value:u,placeholder:t,"aria-label":t,onChange:e=>{d(e.target.value),p(e.target.selectionStart),g(0),v(!1)},onSelect:e=>p(e.currentTarget.selectionStart),onKeyDown:e=>{if(te.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:te.length-1;g((h+t)%te.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),w(te[Math.min(h,te.length-1)]?.name??``);return}if(e.key===`Escape`){e.preventDefault(),v(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),ne()):e.key===`Escape`&&u===``&&o!==void 0&&(e.preventDefault(),o())},className:`block max-h-48 w-full resize-none bg-transparent px-3 py-2.5 text-sm text-fg-primary outline-none placeholder:text-fg-muted`}),(0,A.jsx)(`div`,{className:`shrink-0 pb-1.5`,children:(0,A.jsx)(_t,{variant:`primary`,type:`submit`,disabled:u.trim()===``||u.trim()===n.trim()||x.isPending,children:x.isPending?`Sending…`:`Send`})})]}),x.error===null?null:(0,A.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-red-400`,children:x.error instanceof b?x.error.message:`The message was not sent.`})]})}var R=5;function ns(e,t,n){switch(e.kind){case`answering`:return{text:`${Ct(e.who)} ${e.who.length===1?`is`:`are`} answering…`,tone:`text-emerald-300`};case`queued`:return{text:`${Ct(e.who)} will answer next`,tone:`text-amber-300`};case`waiting`:return{text:`waiting for an answer`,tone:`text-fg-muted`};case`answered`:return{text:`answered by ${n(e.by)}`,tone:`text-fg-secondary`}}let r=He(t.body,160);return{text:`closed by ${n(e.by??`board`)}${r===``?``:` · ${r}`}`,tone:`text-fg-muted`}}function rs({left:e,width:t,onClose:n}){let r=ue(),i=Le(),a=Ma(),o=ut(3e4),s=$o(),c=(0,O.useRef)(null),l=ha(r.data??[]).slice(0,R),u=pe(i.data?.running??[]),d=pe(i.data?.pending??[]);return(0,O.useEffect)(()=>{let e=e=>{e.target instanceof Node&&c.current?.contains(e.target)===!1&&n()};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[n]),(0,A.jsxs)(`section`,{ref:c,"aria-label":`Ask`,className:`absolute top-[26%] z-30 flex flex-col gap-2`,style:{left:e,width:t},children:[(0,A.jsx)(`div`,{className:Ca,children:(0,A.jsx)(ts,{target:{ask:!0},placeholder:`Ask the front desk`,className:`p-2`,focusOnOpen:!0,onEmptyEscape:n})}),l.length===0?null:(0,A.jsx)(`ol`,{"aria-label":`Your asks`,className:`${Ca} max-h-[40vh] overflow-y-auto py-1`,children:l.map(e=>{let t=ns(_a(e,u,d),e,s),n=va(e,a);return(0,A.jsx)(`li`,{children:(0,A.jsxs)(y,{to:`/thread/$threadId`,params:{threadId:e.id},className:`block px-4 py-2 transition-colors hover:bg-surface-2/50`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-primary ${n?`font-semibold`:``}`,children:e.title}),n?(0,A.jsx)(`span`,{"aria-label":`new answer`,className:`size-1.5 shrink-0 rounded-full bg-emerald-400`}):null,(0,A.jsx)(`time`,{dateTime:e.openedAt,className:`shrink-0 text-meta`,children:nt(e.openedAt,o)})]}),(0,A.jsx)(`span`,{className:`mt-0.5 block truncate text-xs ${t.tone}`,children:t.text})]})},e.id)})})]})}function is({unread:e,onOpen:t}){let n=$o(),[r]=e,i=r===void 0?null:e.length===1?`${n(r.lastAuthor??`board`)} answered “${r.title}”`:`${e.length} new answers`;return(0,A.jsxs)(`button`,{type:`button`,onClick:t,className:`pointer-events-auto flex max-w-full min-w-0 items-center gap-2 rounded-full px-3 py-1.5 text-meta transition-colors hover:text-fg-secondary`,children:[i===null?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 shrink-0 rounded-full bg-emerald-400`}),(0,A.jsx)(`span`,{className:`min-w-0 truncate text-fg-secondary`,children:i}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}),(0,A.jsx)(`kbd`,{className:`shrink-0 rounded border border-line px-1.5 font-sans text-[11px] text-fg-secondary`,children:`Space`}),(0,A.jsx)(`span`,{className:`shrink-0`,children:`to ask`})]})}var as={working:{label:`working`,style:`bg-emerald-500/15 text-emerald-300`},queued:{label:`queued`,style:`bg-amber-500/15 text-amber-300`},idle:{label:`resting`,style:`bg-surface-2 text-fg-tertiary`}};function os(e,t,n,r){return t.state===`working`?`In a turn at ${n}`:t.state===`queued`?`Queued for ${n}`:e.lastTurnAt===void 0?`No turns yet`:`Last turn ${nt(e.lastTurnAt,r)}`}function ss({member:e,star:t,place:n,now:r}){let i=e.lastModel??e.model,a=as[t.state];return(0,A.jsxs)(`article`,{className:`card w-72 p-3.5`,"aria-label":`${e.name}, ${e.role}`,children:[(0,A.jsxs)(`header`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-md bg-surface-2/70`,children:(0,A.jsx)(Ot,{cli:t.cli,size:18})}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`h2`,{className:`text-title truncate`,children:e.name}),(0,A.jsxs)(`p`,{className:`truncate text-meta`,children:[e.role,i===void 0?``:` · ${i}`]})]}),(0,A.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${a.style}`,children:a.label})]}),(0,A.jsx)(`p`,{className:`mt-2.5 text-sm text-fg-secondary`,children:os(e,t,n,r)})]})}function cs({society:e,citizens:t,citizensOpen:n,onToggleCitizens:r,runnersOpen:i,onToggleRunners:a,enrolling:o,cronsOpen:s,onToggleCrons:c,failingCrons:l,attention:u,onOpenAttention:d,paused:f,onTogglePause:p,pauseBusy:m,boardOpen:h,onToggleBoard:g,metricsOpen:_,onToggleMetrics:v,logsOpen:y,onToggleLogs:b,onSignOut:ee}){return(0,A.jsxs)(`header`,{className:`pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,A.jsx)(`span`,{className:`text-display`,children:`Stellaris`}),e===void 0?null:(0,A.jsx)(`span`,{className:`text-meta`,children:e})]}),(0,A.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-2`,children:[u===0?null:(0,A.jsxs)(`button`,{type:`button`,onClick:d,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs text-amber-300 transition-colors hover:text-amber-200 focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-amber-300`}),u,` `,u===1?`needs`:`need`,` you`]}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":f,disabled:m,onClick:p,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none disabled:opacity-50 ${f?`text-amber-300 hover:text-amber-200`:`text-fg-tertiary hover:text-fg-primary`}`,children:f?`Paused · resume`:`Pause`}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":n,onClick:r,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${n?`text-fg-primary`:`text-fg-tertiary hover:text-fg-primary`}`,children:t===1?`1 citizen`:`${t} citizens`}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-label":o===0?`Runners`:`Runners, ${o} waiting for approval`,onClick:a,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${i?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:[`Runners`,o===0?null:(0,A.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1 text-[11px] text-amber-300`,children:o})]}),(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":s,"aria-label":l===0?`Crons`:`Crons, ${l} failing`,onClick:c,className:`card inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${s?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:[`Crons`,l===0?null:(0,A.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1 text-[11px] text-amber-300`,children:l})]}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":h,onClick:g,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${h?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Board`}),(0,A.jsx)(`button`,{type:`button`,"aria-pressed":_,onClick:v,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${_?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Metrics`}),(0,A.jsx)(`button`,{type:`button`,"aria-expanded":y,onClick:b,className:`card inline-flex h-7 items-center rounded-md px-2.5 text-xs transition-colors focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none ${y?`text-fg-primary`:`text-fg-secondary hover:text-fg-primary`}`,children:`Logs`}),(0,A.jsx)(`button`,{type:`button`,onClick:ee,className:`h-7 rounded-md px-2.5 text-xs text-fg-tertiary transition-colors hover:bg-surface-2/60 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:`Sign out`})]})]})}var ls={waiting_stage:`stage waiting`,backlog:`backlog`,role_gap:`role gap`,churn:`churn`,stale_thread:`stale thread`,idle_member:`idle member`,blocked_capability:`missing capability`,turn_cost:`spend`,scaled:`replica added`,runner:`runner`,home_conflict:`edits to reconcile`,stuck_workspace:`work left on no branch`,cron_failing:`cron failing`,turn_refused:`model refusing turns`};function us(e,t){let n=new Set(t),r=new Map;for(let t of e)n.has(t.signal.key)&&r.set(t.signal.key,t.id);return new Set(r.values())}function z(e){return[e.project??``,e.agent??``,e.role===void 0?``:`role ${e.role}`,De(e)?`wakes the steward`:``].filter(e=>e.length>0)}function ds({onClose:e}){let t=S(!0),n=Le(),r=ut(3e4),i=t.data??[],a=us(i,n.data?.signals??[]);return(0,A.jsxs)(wa,{label:`Operations log`,className:`top-[72px] right-4 z-20 max-h-[min(70vh,640px)]`,style:{width:400},children:[(0,A.jsxs)(`header`,{className:`flex items-center gap-3 border-b border-line px-4 py-3`,children:[(0,A.jsx)(`h2`,{className:`min-w-0 flex-1 text-heading`,children:`Operations log`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Close the log`,onClick:e,className:`grid size-7 shrink-0 place-items-center rounded-lg text-fg-tertiary hover:bg-surface-2/70 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`,children:`×`})]}),i.length===0?(0,A.jsx)(`p`,{className:`px-4 py-4 text-meta`,children:t.data===void 0?`Reading the log…`:`Nothing measured yet.`}):(0,A.jsx)(`ol`,{className:`flex-1 overflow-y-auto`,children:i.toReversed().map(({id:e,ts:t,signal:n})=>{let i=De(n),o=z(n);return(0,A.jsxs)(`li`,{className:`border-b border-line/60 px-4 py-2.5 last:border-b-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`rounded-md px-1.5 py-px text-[11px] ${i?`bg-amber-500/15 text-amber-300`:`bg-surface-2 text-fg-tertiary`}`,children:ls[n.kind]}),a.has(e)?(0,A.jsx)(`span`,{className:`text-[11px] text-emerald-300`,children:`holds now`}):null,(0,A.jsx)(`time`,{dateTime:t,title:t,className:`ml-auto shrink-0 text-meta`,children:nt(t,r)})]}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:(0,A.jsx)(oo,{text:n.summary})}),o.length===0&&n.taskId===void 0?null:(0,A.jsxs)(`p`,{className:`mt-0.5 text-meta`,children:[o.join(` · `),n.taskId===void 0?null:(0,A.jsxs)(A.Fragment,{children:[o.length===0?``:` · `,(0,A.jsx)(y,{to:`/task/$taskId`,params:{taskId:n.taskId},className:`text-fg-tertiary underline-offset-2 hover:text-fg-primary hover:underline`,children:`the task`})]})]})]},e)})})]})}var fs=32;function ps(e,t){return t.width+t.x-e.clientX}function ms({width:e,min:t,max:n,onResize:r,onToggle:i}){let a=(0,O.useRef)(null),o=t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),a.current={x:t.clientX,width:e})},s=e=>{a.current!==null&&r(ps(e,a.current),!1)},c=e=>{a.current!==null&&(r(ps(e,a.current),!0),a.current=null)};return(0,A.jsx)(`button`,{type:`button`,"aria-label":`Width of the board's content, ${e} of at most ${n} pixels: drag or use the arrow keys, Enter widens it all the way or back`,onPointerDown:o,onPointerMove:s,onPointerUp:c,onPointerCancel:c,onClick:e=>{e.detail===0&&i()},onDoubleClick:i,onKeyDown:i=>{let a=i.key===`ArrowLeft`?e+fs:i.key===`ArrowRight`?e-fs:i.key===`Home`?t:i.key===`End`?n:null;a!==null&&(i.preventDefault(),r(a,!0))},className:`absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize touch-none before:absolute before:inset-y-4 before:left-0.5 before:w-0.5 before:rounded-full before:transition-colors hover:before:bg-fg-muted/60 focus-visible:outline-none focus-visible:before:bg-fg-primary/60 active:before:bg-fg-primary/60`})}function hs({mark:e,project:t,members:n}){let r=n?.find(t=>t.name===e.holder)?.cli??null,i=Nt.find(t=>t.phase===e.phase)?.label??e.phase;return(0,A.jsxs)(`article`,{className:`card w-72 p-4`,"aria-label":`Task ${e.title}`,children:[(0,A.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(`h2`,{className:`text-title min-w-0 flex-1`,children:e.title}),(0,A.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${At[e.phase]}`,children:i.toLowerCase()})]}),(0,A.jsxs)(`dl`,{className:`mt-3 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Project`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:t}),(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Stage`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:e.stage}),e.holder===null?e.waitingFor===null?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Waiting for`}),(0,A.jsx)(`dd`,{className:`min-w-0 truncate text-fg-secondary`,children:e.waitingFor})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`dt`,{className:`text-fg-muted`,children:`Held by`}),(0,A.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-1 text-fg-secondary`,children:[r===null?null:(0,A.jsx)(Ot,{cli:r,size:12}),e.holder,e.linked===null?` · resting`:` · in a turn on it`]})]})]})]})}function gs(e,t){let n=`latest`;return lo({token:e,url:()=>`/api/events/stream?since=${n}`,onData:e=>{let r=Se.parse(JSON.parse(e));n=r.id,t.onEvent(r)},onOpen:e=>{e&&t.onResume()}})}function _s(e){return typeof e==`string`?e:void 0}function vs(e){let{type:t,payload:n,actor:r}=e;if(t===`message.posted`){let e=_s(n.thread);return e===void 0?[[`channels`],[`channel`,_s(n.channel)],[`requests`]]:[[`threads`],[`thread`,e],[`requests`]]}if(t.startsWith(`thread.`))return[[`threads`],[`thread`,_s(n.threadId)],[`channel`],[`requests`]];if(t.startsWith(`task.`)||t.startsWith(`merge.`)||t.startsWith(`pull_request.`)||t===`lease.expired`){let e=[[`tasks`],[`task`,_s(n.taskId)],[`members`],[`metrics`]];return t===`merge.completed`?[...e,[`project-file`,_s(n.project)]]:e}return t===`turn.completed`||t===`turn.failed`?[[`scheduler`],[`members`],[`turns`,r],[`memory`,r],[`agent-skills`,r],[`conflicts`,r],[`history`,r],[`task-file`],[`task-changes`],[`task-diff`],[`project-file`],[`metrics`],[`tokens`],[`crons`]]:t===`turn.started`?[[`scheduler`],[`members`],[`metrics`]]:t.startsWith(`turn.`)||t===`wake.requested`||t===`paused.changed`?[[`scheduler`],[`members`]]:t===`knowledge.written`||t===`knowledge.removed`?[[`knowledge`,_s(n.project)??`society`]]:t===`dashboard.updated`?[[`dashboard`,_s(n.project)]]:t.startsWith(`cron.`)?[[`crons`]]:t===`society.configured`?[[`society`],[`crons`]]:t.startsWith(`agent.`)||t===`subscription.changed`?[[`members`],[`crons`]]:t.startsWith(`project.`)||t===`channel.added`||t===`channel.archived`?[[`projects`],[`channels`],[`society`],[`crons`]]:t===`role.added`?[[`roles`]]:t===`runner.quota`?[[`runners`]]:t.startsWith(`runner.`)?[[`runners`],[`models`],[`server-version`]]:t.startsWith(`proposal.`)?[[`proposals`],[`proposal`,_s(n.proposalId)],[`metrics`]]:t===`skill.promoted`||t===`skill.removed`?[[`skills`]]:t===`ops.signal`?[[`signals`],[`scheduler`],[`metrics`]]:[]}function ys(e,t){for(let n of vs(t)){let t=n.filter(e=>e!==void 0);e.invalidateQueries({queryKey:t})}}var bs=`stellaris.contentWidth`;function xs(e){return Math.round(Math.min(680,Math.max(420,e*.4)))}function Ss(e){return Math.max(420,e-256-48)}function Cs(e,t){let n=Ss(e);return t===`widest`?n:Math.round(Math.min(n,Math.max(420,t??xs(e))))}function ws(e,t){return Cs(e,t)>=Ss(e)?null:`widest`}function Ts(){let e=localStorage.getItem(bs);if(e===`widest`)return`widest`;let t=Number(e);return e!==null&&Number.isFinite(t)&&t>0?t:null}function Es(e){e===null?localStorage.removeItem(bs):localStorage.setItem(bs,String(e))}var Ds=class{fetch;asked=new Set;waiting=new Set;found=new Map;listeners=new Set;refs=[];scheduled=!1;constructor(e){this.fetch=e}want(e){for(let t of e)this.asked.has(t)||(this.asked.add(t),this.waiting.add(t));this.waiting.size>0&&!this.scheduled&&(this.scheduled=!0,queueMicrotask(()=>void this.flush()))}async flush(){this.scheduled=!1;let e=[...this.waiting];this.waiting.clear();let t=this.found.size;for(let t=0;t<e.length;t+=50)try{for(let n of await this.fetch(e.slice(t,t+50)))this.found.set(n.id,n)}catch{}if(this.found.size!==t){this.refs=[...this.found.values()];for(let e of this.listeners)e()}}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));snapshot=()=>this.refs},Os=`stellaris.trail`;function ks(e,t,n){let r={};for(let[n,i]of Object.entries(e))Number(n)<t&&(r[Number(n)]=i);return r[t]=n,r}function As(e,t){let n=e[t-1];return n===void 0||new URL(n,`http://board`).pathname===`/`?null:n}function js(){try{let e=JSON.parse(sessionStorage.getItem(Os)??`{}`);if(typeof e!=`object`||!e)return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&Number.isInteger(Number(n))&&(t[Number(n)]=r);return t}catch{return{}}}function Ms(e){sessionStorage.setItem(Os,JSON.stringify(e))}function Ns(e,t){return decodeURIComponent(e.split(`/`)[t]??``)}function Ps(e,t){let{pathname:n}=new URL(e,`http://board`),r=n.split(`/`).filter(e=>e!==``),[i=``,a=``,o=``]=r;if(i===`task`&&o===`files`)return r.slice(3).map(decodeURIComponent).at(-1)??`the task's files`;if(i===`task`||i===`thread`||i===`proposal`)return t.entity(a)??`the ${i}`;if(i===`c`)return`#${decodeURIComponent(r.at(-1)??``)}`;if(i===`p`){let e=t.project(a)??a;return o===`files`?r.slice(3).map(decodeURIComponent).at(-1)??`the files of ${e}`:o===`tasks`?`the tasks of ${e}`:e}if(i===`knowledge`)return Ns(n,3);if(i===`skills`)return Ns(n,2);if(i===`citizen`)return decodeURIComponent(a);if(i===`crons`){let n=new URL(e,`http://board`).searchParams.get(`cron`);return(n===null?void 0:t.entity(n))??`the crons`}return{society:`the society`,citizens:`the citizens`,"needs-you":`what needs you`,proposals:`the proposals`,metrics:`the metrics`,runners:`the runners`}[i]??`the previous view`}var Fs=typeof sessionStorage>`u`?{}:js(),Is=new Set;function Ls(e,t){if(Fs[e]!==t||Fs[e+1]!==void 0){Fs=ks(Fs,e,t),Ms(Fs);for(let e of Is)e()}}function Rs(){return(0,O.useSyncExternalStore)(e=>(Is.add(e),()=>Is.delete(e)),()=>Fs)}function zs(e,t){let n=Nt.find(t=>t.phase===e.phase)?.label.toLowerCase(),r=e.holder===null?e.waitingFor===null?null:`for ${e.waitingFor}`:`held by ${e.holder}${e.linked===null?``:`, in a turn there`}`;return[`Task ${e.title} at ${t}`,`stage ${e.stage}`,n,r].filter(e=>e!=null).join(`, `)}var Bs=Math.PI*(3-Math.sqrt(5)),Vs=68,Hs=44,Us=58,Ws=26,Gs=13,Ks=.3,qs=1.5*Math.PI,Js=28,Ys=280,Xs=8,Zs=40;function Qs(e,t){return e<t?-1:+(e>t)}function $s(e){return Math.max(Us,Vs*Math.sqrt(Math.max(0,e-1))+Hs)}function ec(e){return e+Ws}function tc(e){let t=new Map;for(let n of e.toSorted()){let e=We(n);if(e!==null){let n=t.get(e.agent)??[];n.includes(e.scope)||t.set(e.agent,[...n,e.scope])}}return t}function nc(e){let t=e.projects.filter(e=>e.archived===void 0).toSorted((e,t)=>Qs(e.createdAt,t.createdAt)||Qs(e.slug,t.slug)),n=new Set(t.map(e=>e.slug)),r=e=>n.has(e)?e:Ae,i=tc(e.scheduler.running),a=tc(e.scheduler.pending),o=new Set(e.scheduler.resident.map(e=>e.split(`/`)[0])),s=e.members.filter(e=>e.cli!==null).filter(e=>e.status===`active`).toSorted((e,t)=>Qs(e.name,t.name)),c=s.flatMap(e=>{let t=[...new Set((i.get(e.name)??[]).map(r))];if(t.length>0)return t.map(t=>({id:t===`society`?e.name:`${e.name}/${t}`,member:e,state:`working`,scope:t,queuedFor:null}));let n=a.get(e.name)?.[0];return[{id:e.name,member:e,state:n===void 0?`idle`:`queued`,scope:Ae,queuedFor:n===void 0?null:r(n)}]}),l=new Map([[Ae,new Map(s.map((e,t)=>[e.name,t]))]]);for(let e of t){let t=s.filter(t=>t.memberships.includes(e.slug)),n=c.filter(t=>t.scope===e.slug).map(e=>e.member).filter(t=>!t.memberships.includes(e.slug));l.set(e.slug,new Map([...t,...n].map((e,t)=>[e.name,t])))}let u=new Map([...l].map(([e,t])=>[e,t.size])),d={id:Ae,label:`society`,kind:`society`,x:0,y:0,radius:$s(u.get(`society`)??0)},f=[d,...ac(t,u,d)],p=new Map(f.map(e=>[e.id,e])),m=c.map(({id:e,member:t,state:n,scope:r,queuedFor:i})=>{let a=p.get(r)??d,s=l.get(a.id)?.get(t.name)??0,c=Vs*Math.sqrt(s),u=s*Bs-Math.PI/2;return{id:e,name:t.name,cli:t.cli,state:n,resident:o.has(t.name),anchor:a.id,queuedFor:i,x:Math.round(a.x+c*Math.cos(u)),y:Math.round(a.y+c*Math.sin(u))}}),h=rc(e.tasks??[],f,m),g=Math.max(...f.map(e=>Math.hypot(e.x,e.y)+ec(e.radius)));return{anchors:f,stars:m,tasks:h,radius:Math.round(g+Zs)}}function rc(e,t,n){let r=[];for(let i of t){if(i.kind!==`project`)continue;let t=e.filter(e=>e.project===i.id).flatMap(e=>{let t=Mt(e);return t===`done`||t===`abandoned`?[]:[{task:e,phase:t}]}).toSorted((e,t)=>Qs(e.task.id,t.task.id)),a=Math.min(Ks,qs/Math.max(1,t.length)),o=i.radius+Gs;t.forEach(({task:e,phase:t},s)=>{let c=s%2==0?1:-1,l=-Math.PI/2+c*Math.ceil(s/2)*a,u=t===`landing`?null:e.claimedBy??null,d=pt(e),f=u===null?null:n.find(e=>e.name===u&&e.anchor===i.id)?.id??null;r.push({id:e.id,title:e.title,project:i.id,phase:t,stage:d?.name??e.stage,holder:u,waitingFor:u===null&&t!==`landing`&&d!==void 0?jt(d):null,linked:f,x:Math.round(i.x+o*Math.cos(l)),y:Math.round(i.y+o*Math.sin(l))})})}return r}function ic(e,t,n){let r=e.stars.filter(e=>e.name===t);return(r.find(e=>e.anchor===n)??r[0])?.id??null}function ac(e,t,n){let r=[],i=ec(n.radius),a=Xs;for(let n=0,o=0;n<e.length;o+=1){let s=e.slice(n,n+a);n+=a,a+=4;let c=s.map(e=>$s(t.get(e.slug)??0)),l=c.map(ec),u=l.map(e=>2*e+Js),d=u.reduce((e,t)=>e+t,0),f=u.map(e=>2*Math.PI*e/d),p=-Math.PI/2-(f[0]??0)/2+(o===0?0:Math.PI/s.length),m=f.map(e=>{let t=p+e/2;return p+=e,t}),h=Math.max(o===0?Ys:0,i+Math.max(...l)+Js);if(s.length>1)for(let e=0;e<s.length;e+=1){let t=(e+1)%s.length,n=((f[e]??0)+(f[t]??0))/2,r=((l[e]??0)+(l[t]??0)+Js)/(2*Math.sin(n/2));h=Math.max(h,r)}s.forEach((e,t)=>{let n=m[t]??0;r.push({id:e.slug,label:e.name,kind:`project`,x:Math.round(h*Math.cos(n)),y:Math.round(h*Math.sin(n)),radius:Math.round(c[t]??Us)})}),i=h+Math.max(...l)}return r}var oc=.15,sc=.45,cc=1.35,lc=64,uc=1.15;function dc(e,t,n){return Math.min(n,Math.max(t,e))}function fc(e){return Math.max(240,e.width-e.left-e.right)}function pc(e){return{x:e.left+fc(e)/2,y:e.height/2}}function mc(e,t){return{x:0,y:0,scale:dc(Math.min(fc(e),e.height)/(2*t),sc,cc)}}function hc(e,t,n,r){let i=dc(e.scale*n,oc,3),a=pc(t),o=e.x+(r.x-a.x)/e.scale,s=e.y+(r.y-a.y)/e.scale;return{x:o-(r.x-a.x)/i,y:s-(r.y-a.y)/i,scale:i}}function gc(e,t,n){return{...e,x:e.x-t/e.scale,y:e.y-n/e.scale}}function _c(e,t,n){let r=pc(t),i=r.x+(n.x-e.x)*e.scale,a=r.y+(n.y-e.y)*e.scale,o=n.reach*e.scale;if(i-o>=t.left&&i+o<=t.width-t.right&&a-o>=lc&&a+o<=t.height)return null;let s=Math.min(fc(t),t.height-lc)/(2*n.reach*uc);return{x:n.x,y:n.y,scale:Math.min(e.scale,dc(s,oc,3))}}var vc=`#0a0a0a`,yc=`#171717`,bc=`212, 212, 212`,xc=`163, 163, 163`,Sc=`115, 115, 115`,Cc=`"Instrument Sans Variable", ui-sans-serif, sans-serif`,wc=`500 12px "Onest Variable", ui-sans-serif, sans-serif`,Tc=`600 10px "Onest Variable", ui-sans-serif, sans-serif`,Ec={waiting:`#fcd34d`,working:`#6ee7b7`,returned:`#fdba74`,landing:`#7dd3fc`},Dc=`500 11px ${Cc}`,Oc=5,kc=240,Ac=.06,jc=15,Mc=5,Nc=4.2,Pc=280;function Fc(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Ic(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)/4294967296*Math.PI*2}function B(e,t){return(e%t+t)%t}function Lc(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function Rc(e){let t=document.createElement(`canvas`);t.width=256,t.height=256;let n=t.getContext(`2d`);if(n!==null){let t=Lc(e),r=n.createRadialGradient(128,128,0,128,128,128);r.addColorStop(0,`rgba(${t}, 0.55)`),r.addColorStop(.22,`rgba(${t}, 0.2)`),r.addColorStop(.55,`rgba(${t}, 0.05)`),r.addColorStop(1,`rgba(${t}, 0)`),n.fillStyle=r,n.fillRect(0,0,256,256)}return t}var zc=class{canvas;options;ctx;glyphs;glows=new Map;bodies=new Map;marks=new Map;bubbles=new Map;clock=0;specks;spheres=new Map;radius=400;scale=1;camX=0;camY=0;target={x:0,y:0,scale:1};mode=`home`;focusPending=!1;width=0;height=0;dpr=1;hovered=null;focus=null;paused=!1;insetLeft=0;insetRight=0;centerX=0;frameId=null;last=0;constructor(e,t){this.canvas=e,this.options=t;let n=e.getContext(`2d`);if(n===null)throw Error(`the sky needs a 2D canvas context`);this.ctx=n,this.glyphs={claude:new Path2D(Et.claude.path),codex:new Path2D(Et.codex.path)};let r=Fc(7);this.specks=Array.from({length:Pc},()=>({x:r(),y:r(),size:.5+r()*1.1,alpha:.12+r()*.45,rate:.2+r()*.8,phase:r()*Math.PI*2}))}setModel(e){this.radius=e.radius;for(let t of e.anchors){let e=this.spheres.get(t.id);e===void 0?this.spheres.set(t.id,{anchor:t,x:t.x,y:t.y,radius:t.radius}):e.anchor=t}for(let t of this.spheres.keys())e.anchors.some(e=>e.id===t)||this.spheres.delete(t);let t=new Set(e.stars.map(e=>e.id)),n=[...this.bodies.entries()].filter(([e])=>!t.has(e));for(let r of e.stars){let i=this.bodies.get(r.id);if(i!==void 0){i.star=r,i.leaving=!1;continue}let a=n.findIndex(([,e])=>e.star.name===r.name),o=n[a];if(o!==void 0){n.splice(a,1),this.bodies.delete(o[0]),this.bodies.set(r.id,{...o[1],star:r,leaving:!1});continue}let s=[...this.bodies.values()].find(e=>e.star.name===r.name&&t.has(e.star.id)),c=e.anchors.find(e=>e.id===r.anchor),l=s??c??r;this.bodies.set(r.id,{star:r,x:this.options.reducedMotion?r.x:l.x,y:this.options.reducedMotion?r.y:l.y,vx:0,vy:0,phase:Ic(r.name),presence:+!!this.options.reducedMotion,leaving:!1,screen:{x:0,y:0},flash:0})}for(let[,t]of n){let n=e.stars.find(e=>e.name===t.star.name);t.leaving=!0,n!==void 0&&(t.star={...t.star,x:n.x,y:n.y})}let r=new Set(e.tasks.map(e=>e.id));for(let t of e.tasks){let e=this.marks.get(t.id);e===void 0?this.marks.set(t.id,{mark:t,x:t.x,y:t.y,presence:+!!this.options.reducedMotion,leaving:!1,screen:{x:0,y:0}}):(e.mark=t,e.leaving=!1)}for(let[e,t]of this.marks)r.has(e)||(t.leaving=!0)}flash(e){let t=this.bodies.get(e);t!==void 0&&!this.options.reducedMotion&&(t.flash=1)}say(e,t){this.bodies.has(e)&&this.bubbles.set(e,{text:t,born:this.clock})}setHovered(e){this.hovered=e}setPaused(e){this.paused=e}setFocus(e){this.focus=e,this.focusPending=!0}zoomBy(e,t){let n=this.view();this.target=hc(this.target,n,e,t??pc(n)),this.mode=`manual`}panBy(e,t){this.target=gc(this.target,e,t),this.camX-=e/this.scale,this.camY-=t/this.scale,this.mode=`manual`}home(){this.mode=`home`}view(){return{width:this.width,height:this.height,left:this.insetLeft,right:this.insetRight}}frameFocus(e){let t=this.focus===null?void 0:this.spheres.get(this.focus);if(t===void 0||t.anchor.kind===`society`){this.mode===`focus`&&(this.mode=`home`);return}let n=_c(this.target,e,{x:t.anchor.x,y:t.anchor.y,reach:t.anchor.radius+34});n!==null&&(this.target=n,this.mode=`focus`)}setInsets(e,t){this.insetLeft=e,this.insetRight=t}hitTestAnchor(e,t){let n=null,r=1/0;for(let i of this.spheres.values()){let a=this.toScreen(i.x,i.y),o=Math.hypot(a.x-e,a.y-t);o<=i.radius*this.scale&&o<r&&(n=i.anchor.id,r=o)}return n}resize(e,t,n){this.width=e,this.height=t,this.dpr=n,this.canvas.width=Math.round(e*n),this.canvas.height=Math.round(t*n)}hitTestMark(e,t){let n=null,r=10;for(let[i,a]of this.marks){let o=Math.hypot(a.screen.x-e,a.screen.y-t);!a.leaving&&o<r&&(n=i,r=o)}return n}hitTest(e,t){let n=null,r=Math.max(jc*this.scale+8,18);for(let[i,a]of this.bodies){if(a.leaving)continue;let o=Math.hypot(a.screen.x-e,a.screen.y-t);o<r&&(n=i,r=o)}return n}start(){this.frameId===null&&(this.last=performance.now()/1e3,this.frameId=requestAnimationFrame(this.frame))}stop(){this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}frame=e=>{let t=e/1e3;this.clock=t;let n=Math.min(.05,Math.max(0,t-this.last));this.last=t,this.step(n),this.draw(this.options.reducedMotion?0:t),this.frameId=requestAnimationFrame(this.frame)};step(e){let t=this.view();this.mode===`home`&&(this.target=mc(t,this.radius)),this.focusPending&&this.width>0&&(this.focusPending=!1,this.frameFocus(t));let n=this.options.reducedMotion?1:Math.min(1,e*3);this.scale+=(this.target.scale-this.scale)*n,this.camX+=(this.target.x-this.camX)*n,this.camY+=(this.target.y-this.camY)*n;let r=pc(t).x;this.centerX=this.centerX===0?r:this.centerX+(r-this.centerX)*n;for(let e of this.spheres.values())e.x+=(e.anchor.x-e.x)*n,e.y+=(e.anchor.y-e.y)*n,e.radius+=(e.anchor.radius-e.radius)*n;for(let[t,n]of this.bodies){if(this.options.reducedMotion)n.x=n.star.x,n.y=n.star.y,n.presence=+!n.leaving;else{n.vx+=(Mc*(n.star.x-n.x)-Nc*n.vx)*e,n.vy+=(Mc*(n.star.y-n.y)-Nc*n.vy)*e,n.x+=n.vx*e,n.y+=n.vy*e;let t=+!n.leaving;n.presence+=(t-n.presence)*Math.min(1,e*2.5)}n.flash=Math.max(0,n.flash-e*2.2),n.leaving&&n.presence<.02&&this.bodies.delete(t)}for(let[t,r]of this.marks){r.x+=(r.mark.x-r.x)*n,r.y+=(r.mark.y-r.y)*n;let i=+!r.leaving;r.presence+=(i-r.presence)*(this.options.reducedMotion?1:Math.min(1,e*2.5)),r.leaving&&r.presence<.02&&this.marks.delete(t)}for(let[e,t]of this.bubbles)(this.clock-t.born>Oc||this.bodies.get(e)?.leaving!==!1)&&this.bubbles.delete(e)}toScreen(e,t){return{x:this.centerX+(e-this.camX)*this.scale,y:this.height/2+(t-this.camY)*this.scale}}glow(e){let t=this.glows.get(e);return t===void 0&&(t=Rc(e),this.glows.set(e,t)),t}draw(e){let{ctx:t}=this;t.setTransform(this.dpr,0,0,this.dpr,0,0),t.fillStyle=vc,t.fillRect(0,0,this.width,this.height),this.drawSpecks(e),this.drawAnchors(),this.drawTasks(e);let n=[...this.bodies.values()].toSorted((e,t)=>Number(e.star.id===this.hovered)-Number(t.star.id===this.hovered));for(let t of n)this.drawBody(t,e);this.drawBubbles();let r=this.hovered?.startsWith(`task:`)===!0?this.hovered.slice(5):null,i=r===null?this.hovered===null?void 0:this.bodies.get(this.hovered):this.marks.get(r);this.options.onHoverPosition(i===void 0||i.leaving?null:i.screen)}drawTasks(e){let{ctx:t}=this;for(let e of this.marks.values())e.screen=this.toScreen(e.x,e.y);t.save(),t.lineWidth=1;for(let n of this.marks.values()){let r=n.mark.linked===null?void 0:this.bodies.get(n.mark.linked);if(r===void 0||r.leaving)continue;let i=Lc(Ec[n.mark.phase]),a=Math.min(n.presence,r.presence),o=n.screen,s=r.screen,c=t.createLinearGradient(o.x,o.y,s.x,s.y);if(c.addColorStop(0,`rgba(${i}, ${(.55*a).toFixed(3)})`),c.addColorStop(1,`rgba(${i}, ${(.12*a).toFixed(3)})`),t.strokeStyle=c,t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(s.x,s.y),t.stroke(),e!==0){let n=(e*.45+r.phase)%1;t.beginPath(),t.arc(s.x+(o.x-s.x)*n,s.y+(o.y-s.y)*n,1.4,0,Math.PI*2),t.fillStyle=`rgba(${i}, ${(.85*a).toFixed(3)})`,t.fill()}}t.restore();for(let[n,r]of this.marks){let{mark:i,screen:a}=r,o=this.hovered===`task:${n}`,s=Ec[i.phase],c=i.phase===`waiting`&&e!==0?.65+.35*Math.sin(e*1.6+a.x):1,l=Math.max(3,4*this.scale)*(o?1.5:1);t.save(),t.globalAlpha=r.presence*c*(this.paused?.7:1),t.globalCompositeOperation=`lighter`;let u=l*7;t.drawImage(this.glow(s),a.x-u/2,a.y-u/2,u,u),t.globalCompositeOperation=`source-over`,t.translate(a.x,a.y),t.rotate(Math.PI/4),t.fillStyle=s,t.fillRect(-l/2,-l/2,l,l),o&&(t.strokeStyle=`rgba(255, 255, 255, 0.8)`,t.lineWidth=1,t.strokeRect(-l/2-2,-l/2-2,l+4,l+4)),t.restore()}}drawBubbles(){let{ctx:e}=this;e.save(),e.font=Dc,e.textAlign=`left`,e.textBaseline=`middle`;for(let[t,n]of this.bubbles){let r=this.bodies.get(t);if(r===void 0)continue;let i=this.clock-n.born,a=Math.min(1,i/.25,(Oc-i)/1.2)*r.presence;if(a<=0)continue;let o=n.text;if(e.measureText(o).width>kc){for(;o.length>1&&e.measureText(`${o}…`).width>kc;)o=o.slice(0,-1);o=`${o.trimEnd()}…`}let s=e.measureText(o).width+16,c=this.options.reducedMotion?0:i*7,l=Math.max(10,jc*this.scale),u=r.screen.x-s/2,d=r.screen.y-l-14-22-c;e.globalAlpha=a,e.beginPath(),e.roundRect(u,d,s,22,7),e.fillStyle=`rgba(23, 23, 23, 0.92)`,e.fill(),e.strokeStyle=`rgba(255, 255, 255, 0.1)`,e.lineWidth=1,e.stroke(),e.fillStyle=`rgba(${bc}, 1)`,e.fillText(o,u+8,d+11+.5)}e.restore()}drawSpecks(e){let{ctx:t}=this,n=-this.camX*this.scale*Ac,r=-this.camY*this.scale*Ac;for(let i of this.specks){let a=e===0?1:.6+.4*Math.sin(e*i.rate+i.phase);t.fillStyle=`rgba(255, 255, 255, ${(i.alpha*a*(this.paused?.6:1)).toFixed(3)})`,t.fillRect(B(i.x*this.width+n,this.width),B(i.y*this.height+r,this.height),i.size,i.size)}let i=this.toScreen(0,0),a=t.createRadialGradient(i.x,i.y,0,i.x,i.y,320*this.scale);a.addColorStop(0,`rgba(255, 255, 255, 0.035)`),a.addColorStop(1,`rgba(255, 255, 255, 0)`),t.fillStyle=a,t.fillRect(0,0,this.width,this.height)}drawAnchors(){let{ctx:e}=this,t=this.toScreen(0,0);e.save(),e.setLineDash([2,7]),e.lineWidth=1,e.strokeStyle=`rgba(255, 255, 255, 0.07)`;for(let n of this.spheres.values())if(n.anchor.kind===`project`){let r=this.toScreen(n.x,n.y);e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(r.x,r.y),e.stroke()}e.restore();for(let{anchor:t,x:n,y:r,radius:i}of this.spheres.values()){let a=this.toScreen(n,r),o=i*this.scale,s=t.id===this.focus;if(t.kind===`project`){let t=e.createRadialGradient(a.x,a.y,0,a.x,a.y,o*1.8);t.addColorStop(0,`rgba(160, 170, 255, ${s?.1:.05})`),t.addColorStop(1,`rgba(160, 170, 255, 0)`),e.fillStyle=t,e.fillRect(a.x-o*1.8,a.y-o*1.8,o*3.6,o*3.6)}e.beginPath(),e.arc(a.x,a.y,o,0,Math.PI*2),e.lineWidth=s?1.5:1,e.strokeStyle=s?`rgba(255, 255, 255, 0.28)`:t.kind===`society`?`rgba(255, 255, 255, 0.09)`:`rgba(255, 255, 255, 0.06)`,e.stroke(),e.textAlign=`center`,e.textBaseline=`top`,t.kind===`society`?(e.font=Tc,e.letterSpacing=`2px`,e.fillStyle=`rgba(${Sc}, 0.9)`,e.fillText(t.label.toUpperCase(),a.x,a.y+o+10),e.letterSpacing=`0px`):(e.font=wc,e.fillStyle=s?`rgba(245, 245, 245, 1)`:`rgba(${xc}, 0.95)`,e.fillText(t.label,a.x,a.y+o+10))}}drawBody(e,t){let{ctx:n}=this,{star:r}=e,i=Et[r.cli],a=r.id===this.hovered,o=r.state===`working`,s=o?2.5:5,c=s*(Math.sin(t*.29+e.phase)+.6*Math.sin(t*.17+e.phase*2.1)),l=s*(Math.cos(t*.23+e.phase*1.3)+.6*Math.cos(t*.11+e.phase)),u=this.toScreen(e.x+c,e.y+l);e.screen=u;let d=o?2.4:r.state===`queued`?1.4:.7,f=t===0?.5:.5+.5*Math.sin(t*d+e.phase),p=((o?.95+.35*f:r.state===`queued`?.7+.2*f:.5+.2*f)+(a?.25:0)+.8*e.flash)*e.presence*(this.paused?.7:1),m=Math.max(10,jc*this.scale),h=(o?170:130)*this.scale*(.9+.15*f);n.save(),n.globalCompositeOperation=`lighter`,n.globalAlpha=Math.min(1,p),n.drawImage(this.glow(i.accent),u.x-h/2,u.y-h/2,h,h),n.restore(),n.save(),n.globalAlpha=e.presence;let g=Lc(i.accent);if(o&&t!==0){let r=(t+e.phase)%1.8/1.8;n.beginPath(),n.arc(u.x,u.y,m+(6+30*r)*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(${g}, ${(.4*(1-r)).toFixed(3)})`,n.lineWidth=1.25,n.stroke()}e.flash>0&&(n.beginPath(),n.arc(u.x,u.y,m+(3+12*(1-e.flash))*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(255, 255, 255, ${(.55*e.flash).toFixed(3)})`,n.lineWidth=1.25,n.stroke()),r.resident&&(n.beginPath(),n.arc(u.x,u.y,m+5*this.scale,0,Math.PI*2),n.strokeStyle=`rgba(${g}, 0.3)`,n.lineWidth=1,n.stroke()),r.state===`queued`&&(n.beginPath(),n.arc(u.x,u.y,m+8*this.scale,0,Math.PI*2),n.setLineDash([3,4]),n.lineDashOffset=-t*8,n.strokeStyle=`rgba(${bc}, 0.55)`,n.lineWidth=1,n.stroke(),n.setLineDash([])),n.beginPath(),n.arc(u.x,u.y,m,0,Math.PI*2),n.fillStyle=yc,n.fill(),n.strokeStyle=`rgba(${g}, ${a?.95:.6})`,n.lineWidth=a?1.75:1.25,n.stroke(),n.save();let _=m*1.2/24;if(n.translate(u.x,u.y),n.scale(_,_),n.translate(-12,-12),n.fillStyle=i.fill,n.fill(this.glyphs[r.cli],`evenodd`),n.restore(),o)for(let r=0;r<3;r+=1){let i=t*1.8+r*Math.PI*2/3+e.phase,a=m+9*this.scale;n.beginPath(),n.arc(u.x+a*Math.cos(i),u.y+a*Math.sin(i),1.6,0,Math.PI*2),n.fillStyle=`rgba(${g}, 0.9)`,n.fill()}n.font=`500 ${Math.max(9,Math.min(11,11*this.scale)).toFixed(1)}px ${Cc}`,n.textAlign=`center`,n.textBaseline=`top`,n.fillStyle=`rgba(${bc}, ${a||o?1:.7})`,n.fillText(r.name,u.x,u.y+m+8*this.scale+3),n.restore()}},Bc=15e3,Vc=26,Hc=12,Uc=4,Wc=.0015,Gc=.01,Kc=1.3,qc=`grid size-7 place-items-center rounded-md text-sm text-fg-tertiary transition-colors hover:bg-surface-2/70 hover:text-fg-primary focus-visible:ring-2 focus-visible:ring-fg-primary/30 focus-visible:outline-none`;function Jc(e,t,n,r){if(e===null)return;if(t===null){e.style.visibility=`hidden`;return}let i=e.offsetWidth,a=e.offsetHeight,o=r.left+Hc,s=n.width-r.right-Hc,c=t.x+Vc+i<=s?t.x+Vc:t.x-Vc-i,l=Math.min(Math.max(Hc,t.y-a/3),n.height-a-Hc);e.style.transform=`translate(${Math.round(Math.max(o,c))}px, ${Math.round(l)}px)`,e.style.visibility=`visible`}function Yc({model:e,paused:t,hovered:n,onHover:r,insets:i,focus:a,onSelectAnchor:o,onSelectStar:s,onSelectTask:c,live:l,card:u}){let d=(0,O.useRef)(null),f=(0,O.useRef)(null),p=(0,O.useRef)(null),m=(0,O.useRef)(i);(0,O.useLayoutEffect)(()=>{m.current=i},[i]);let h=(0,O.useRef)(e);(0,O.useLayoutEffect)(()=>{h.current=e},[e]);let g=no(),_=(0,O.useRef)(g);(0,O.useLayoutEffect)(()=>{_.current=g},[g]);let v=(0,O.useRef)(null),y=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{let e=d.current;if(e===null)throw Error(`the sky's canvas is not mounted`);let t=e.getBoundingClientRect(),n=new zc(e,{reducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,onHoverPosition:e=>Jc(f.current,e,t,m.current)});p.current=n;let r=new ResizeObserver(()=>{t=e.getBoundingClientRect(),n.resize(t.width,t.height,window.devicePixelRatio)});r.observe(e);let i=e=>{e.preventDefault();let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaY;n.zoomBy(Math.exp(-t*(e.ctrlKey?Gc:Wc)),{x:e.offsetX,y:e.offsetY})};return e.addEventListener(`wheel`,i,{passive:!1}),n.start(),()=>{e.removeEventListener(`wheel`,i),r.disconnect(),n.stop(),p.current=null}},[]),(0,O.useEffect)(()=>{p.current?.setModel(e)},[e]),(0,O.useEffect)(()=>l.listen(e=>{let t=p.current;if(t===null||e.event.type!==`tool_call`||Date.now()-Date.parse(e.ts)>Bc)return;let n=ic(h.current,e.agent,e.project);if(n===null)return;t.flash(n);let r=Mo(e.event.name,e.event.input);r!==null&&t.say(n,Ua(r,_.current))}),[l]),(0,O.useEffect)(()=>{p.current?.setPaused(t)},[t]),(0,O.useEffect)(()=>{p.current?.setHovered(n)},[n]),(0,O.useEffect)(()=>{p.current?.setFocus(a)},[a]),(0,O.useEffect)(()=>{p.current?.setInsets(i.left,i.right)},[i.left,i.right]),(0,A.jsxs)(`div`,{className:`absolute inset-0`,children:[(0,A.jsx)(`canvas`,{ref:d,className:`size-full touch-none`,"aria-hidden":`true`,onPointerDown:e=>{e.button===0&&(v.current={x:e.clientX,y:e.clientY,dragging:!1},y.current=!1)},onPointerUp:e=>{v.current?.dragging===!0&&(e.currentTarget.releasePointerCapture(e.pointerId),e.currentTarget.style.cursor=`grab`),v.current=null},onPointerMove:e=>{let t=p.current,i=v.current;if(i!==null&&t!==null){let n=e.clientX-i.x,a=e.clientY-i.y;if(!i.dragging&&Math.hypot(n,a)>Uc&&(i.dragging=!0,y.current=!0,e.currentTarget.setPointerCapture(e.pointerId),r(null)),i.dragging){t.panBy(n,a),i.x=e.clientX,i.y=e.clientY,e.currentTarget.style.cursor=`grabbing`;return}}let{offsetX:a,offsetY:o}=e.nativeEvent,s=t?.hitTest(a,o)??null,c=s===null?t?.hitTestMark(a,o)??null:null,l=s??(c===null?null:`task:${c}`),u=l===null?t?.hitTestAnchor(a,o)??null:null;e.currentTarget.style.cursor=l!==null||u!==null?`pointer`:`grab`,l!==n&&r(l)},onPointerLeave:()=>r(null),onClick:e=>{let t=p.current,{offsetX:n,offsetY:r}=e.nativeEvent;if(t===null||y.current){y.current=!1;return}let i=t.hitTest(n,r),a=i===null?t.hitTestMark(n,r):null,l=i===null&&a===null?t.hitTestAnchor(n,r):null;i===null?a===null?l!==null&&o(l):c(a):s(i)}}),(0,A.jsxs)(`fieldset`,{className:`card absolute bottom-4 flex flex-col gap-0.5 p-1`,style:{right:i.right+16},children:[(0,A.jsx)(`legend`,{className:`sr-only`,children:`Camera`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,className:qc,onClick:()=>p.current?.zoomBy(Kc),children:`+`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,className:qc,onClick:()=>p.current?.zoomBy(1/Kc),children:`−`}),(0,A.jsx)(`button`,{type:`button`,"aria-label":`Fit the whole sky`,title:`Fit the whole sky`,className:qc,onClick:()=>p.current?.home(),children:`⤢`})]}),(0,A.jsx)(`div`,{ref:f,className:`pointer-events-none absolute top-0 left-0 will-change-transform`,style:{visibility:`hidden`},children:u})]})}var Xc={left:0,right:0};function Zc(){let[e,t]=(0,O.useState)(()=>window.innerWidth);return(0,O.useEffect)(()=>{let e=()=>t(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function Qc(e,t){return e.startsWith(t)?decodeURIComponent(e.slice(t.length)):null}function $c(){let{api:e,token:t,signOut:n,expire:r}=Pe(),i=m();(0,O.useEffect)(()=>gs(t,{onEvent:e=>ys(i,e),onResume:()=>void i.invalidateQueries()}),[t,i]);let[a]=(0,O.useState)(()=>new Io);(0,O.useEffect)(()=>a.follow(t),[a,t]);let o=u(),s=ye(),c=ct(),l=se(),d=Le(),f=ue(),p=et(),g=ce(),_=at(),[v]=(0,O.useState)(()=>new Ds(t=>e.messages(t))),y=(0,O.useSyncExternalStore)(v.subscribe,v.snapshot),ee=(0,O.useCallback)(e=>v.want(e),[v]),x=s.data?.signIn,S=(0,O.useMemo)(()=>za(f.data??[],p,g.data??[],_.data??[],{messages:y,name:e=>Qo(e,x)}),[f.data,p,g.data,_.data,y,x]),C=St(),te=ht({mutationFn:t=>e.setPaused(t),onSuccess:()=>void i.invalidateQueries({queryKey:[`scheduler`]})}),w=la({select:e=>e.location.pathname}),ne=la({select:e=>e.location.href}),re=la({select:e=>e.location.state.__TSR_index});(0,O.useEffect)(()=>Ls(re,ne),[re,ne]);let[ie,ae]=(0,O.useState)(!1),[oe,le]=(0,O.useState)(null),de=oe===w,fe=(0,O.useCallback)(()=>le(null),[]),pe=(0,O.useRef)(!0),me=Ma(),he=Li({strict:!1}),[ge,_e]=(0,O.useState)(null),ve=ut(3e4),be=Zc(),xe=w!==`/`,[Se,Ce]=(0,O.useState)(Ts),T=Cs(be,Se),E=(e,t)=>{let n=Cs(be,e),r=n>=Ss(be)?`widest`:n;Ce(r),t&&Es(r)},we=()=>{let e=ws(be,Se);Ce(e),Es(e)},Te=(0,O.useMemo)(()=>xe?{left:288,right:T+32}:Xc,[xe,T]),Ee=Qc(w,`/thread/`),De=h(Qc(w,`/task/`)),D=Qc(w,`/c/`)??(Ee===null?null:f.data?.find(e=>e.id===Ee)?.channel??null),ke=/^\/p\/([^/]+)\/tasks$/.exec(w)?.[1]??De.data?.project??null,je=Qc(w,`/citizen/`),Me=je===null?null:he.scope??null,Ne=Me?.split(`/`)[0]??null,Fe=w===`/needs-you`?`needs-you`:w===`/proposals`||w.startsWith(`/proposal/`)?`proposals`:null,Ie=Ia().length,Re=Oe().data?.length??0,ze=_.data?.filter(ya).length??0,Be=w===`/society`||w.startsWith(`/skills/`)?Ae:/^\/p\/([^/]+)$/.exec(w)?.[1]??/^\/knowledge\/([^/]+)\//.exec(w)?.[1]??null;(0,O.useEffect)(()=>{let e=()=>{pe.current=!0},t=e=>{if(e.key===`Tab`&&(pe.current=!1),document.querySelector(`:modal`)!==null)return;let t=e.target instanceof HTMLElement?e.target:null;if(!(t?.closest(`input, textarea, select, [contenteditable]`)!=null||e.metaKey||e.ctrlKey||e.altKey)){if(e.key===` `){if(t?.closest(`button, a, summary, [role='button']`)!=null&&!pe.current)return;e.preventDefault(),le(w)}else e.key===`Escape`&&(de?le(null):ie?ae(!1):xe&&C({to:`/`}))}};return window.addEventListener(`keydown`,t),window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`pointerdown`,e)}},[xe,ie,de,w,C]);let Ve=[o,c,l,d].some(e=>e.error instanceof b&&e.error.status===401);(0,O.useEffect)(()=>{Ve&&r()},[Ve,r]);let He=(0,O.useMemo)(()=>c.data===void 0||l.data===void 0||d.data===void 0?null:nc({members:c.data,projects:l.data,scheduler:d.data,tasks:p}),[c.data,l.data,d.data,p]);if(He===null){let e=[c,l,d].some(e=>e.error!==null);return(0,A.jsx)(`main`,{className:`grid h-full place-items-center`,children:(0,A.jsx)(`p`,{className:`text-meta`,"aria-live":`polite`,children:e?`The board server is not answering. Retrying…`:`Reading the board…`})})}let Ue=(Fe!==null||w===`/metrics`||w===`/runners`||w===`/crons`?`society`:null)??Be??ke??(D===null?je===null?null:Ne??He.stars.find(e=>e.name===je)?.anchor??null:D.includes(`/`)?D.split(`/`)[0]??null:`society`),We=be-Te.left-Te.right,Ge=We>=460,Ke=Math.min(560,(Ge?We:be)-32),qe={left:(Ge?Te.left:0)+((Ge?We:be)-Ke)/2,width:Ke},Je=ha(f.data??[]).filter(e=>va(e,me)),Ye=e=>e===`society`?`the society`:l.data?.find(t=>t.slug===e)?.name??e,Xe=He.stars.find(e=>e.id===ge),Ze=He.tasks.find(e=>`task:${e.id}`===ge),Qe=c.data?.find(e=>e.name===Xe?.name),$e=Xe===void 0?`the society`:Ye(Xe.queuedFor??Xe.anchor),tt=e=>{let t=He.stars.find(t=>t.id===e);t!==void 0&&C({to:`/citizen/$name`,params:{name:t.name},search:t.state===`working`?{scope:t.anchor}:{}})},nt=e=>{C({to:`/task/$taskId`,params:{taskId:e}})};return(0,A.jsx)(Lo,{value:a,children:(0,A.jsx)(eo,{value:S,children:(0,A.jsx)(to,{value:ee,children:(0,A.jsx)(L,{value:s.data?.signIn,children:(0,A.jsxs)(`main`,{className:`relative h-full overflow-hidden`,children:[(0,A.jsx)(Yc,{model:He,paused:d.data?.paused??!1,hovered:ge,onHover:_e,insets:Te,focus:Ue,onSelectAnchor:e=>{C(e===`society`?{to:`/society`}:{to:`/p/$slug`,params:{slug:e}})},onSelectStar:tt,onSelectTask:nt,live:a,card:Ze===void 0?Xe===void 0||Qe===void 0?null:(0,A.jsx)(ss,{member:Qe,star:Xe,place:$e,now:ve}):(0,A.jsx)(hs,{mark:Ze,project:Ye(Ze.project),members:c.data})}),(0,A.jsx)(cs,{society:o.data?.name,citizens:new Set(He.stars.map(e=>e.name)).size,citizensOpen:w===`/citizens`,onToggleCitizens:()=>void C(w===`/citizens`?{to:`/`}:{to:`/citizens`}),runnersOpen:w===`/runners`,onToggleRunners:()=>void C(w===`/runners`?{to:`/`}:{to:`/runners`}),enrolling:Re,cronsOpen:w===`/crons`,onToggleCrons:()=>void C(w===`/crons`?{to:`/`}:{to:`/crons`}),failingCrons:ze,attention:Ie,onOpenAttention:()=>void C({to:`/needs-you`}),paused:d.data?.paused??!1,onTogglePause:()=>te.mutate(!(d.data?.paused??!1)),pauseBusy:te.isPending,boardOpen:xe,onToggleBoard:()=>void C(xe?{to:`/`}:{to:`/c/$`,params:{_splat:`general`}}),logsOpen:ie,metricsOpen:w===`/metrics`,onToggleMetrics:()=>void C(w===`/metrics`?{to:`/`}:{to:`/metrics`}),onToggleLogs:()=>ae(!ie),onSignOut:n}),xe?(0,A.jsx)(I,{activeChannel:D,activeTasks:ke,activeCitizen:je,activeScope:Me,activeGovernance:Fe,activeOverview:Be}):null,xe?(0,A.jsxs)(wa,{label:`Board content`,className:`top-[72px] right-4 bottom-4`,style:{width:T},children:[(0,A.jsx)(ms,{width:T,min:420,max:Ss(be),onResize:E,onToggle:we}),(0,A.jsx)($i,{})]}):null,ie?(0,A.jsx)(ds,{onClose:()=>ae(!1)}):null,de?(0,A.jsx)(rs,{left:qe.left,width:qe.width,onClose:fe}):(0,A.jsx)(`div`,{className:`pointer-events-none absolute bottom-5 flex justify-center px-16`,style:{left:Te.left,right:Te.right},children:(0,A.jsx)(is,{unread:Je,onOpen:()=>le(w)})}),He.stars.length===0&&!xe?(0,A.jsx)(`p`,{className:`pointer-events-none absolute inset-x-0 top-1/2 mt-24 text-center text-meta`,children:`No citizens yet.`}):null,(0,A.jsx)(`ul`,{className:`sr-only`,"aria-label":`Tasks in play`,children:He.tasks.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`button`,{type:`button`,onFocus:()=>_e(`task:${e.id}`),onBlur:()=>_e(null),onClick:()=>nt(e.id),children:zs(e,Ye(e.project))})},e.id))}),(0,A.jsx)(`ul`,{className:`sr-only`,"aria-label":`Citizens`,children:He.stars.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onFocus:()=>_e(e.id),onBlur:()=>_e(null),onClick:()=>tt(e.id),children:[e.name,`, `,e.state,e.state===`working`?` at ${Ye(e.anchor)}`:``]})},e.id))})]})})})})})}var el=`modulepreload`,tl=function(e){return`/`+e},nl={},rl=function(e){return e.pathname.endsWith(`.css`)},il=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},al=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=tl(t,n);let r=s(t),i=rl(r);return il(nl,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:el,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ol(e){let t=a.safeParse(e.message);return t.success?{message:t.data}:{}}function sl(e){let t=Number(e.line);return Number.isInteger(t)&&t>0?{line:t}:{}}function cl(){return null}var V=Hi({component:$c}),ll=aa({routeTree:V.addChildren([Bi({getParentRoute:()=>V,path:`/`,component:cl}),Bi({getParentRoute:()=>V,path:`/c/$`,validateSearch:ol,component:j(()=>al(()=>import(`./ChannelView-rqfk1Tyu.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])),`ChannelView`)}),Bi({getParentRoute:()=>V,path:`/thread/$threadId`,validateSearch:ol,component:j(()=>al(()=>import(`./ThreadView-D79G2zgF.js`),__vite__mapDeps([14,1,2,3,10,6,4,5,8,9,11,12,13])),`ThreadView`)}),Bi({getParentRoute:()=>V,path:`/society`,component:j(()=>al(()=>import(`./SocietyView-CJRrypjI.js`),__vite__mapDeps([15,1,2,7,5,4,6,11,16,17,18])),`SocietyView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug`,component:j(()=>al(()=>import(`./ProjectView-CVt28SoI.js`),__vite__mapDeps([19,1,2,9,10,6,4,5,7,11,20,16,17,18,21])),`ProjectView`)}),Bi({getParentRoute:()=>V,path:`/knowledge/$scope/$topic`,component:j(()=>al(()=>import(`./KnowledgeView-Qog6c92V.js`),__vite__mapDeps([22,1,2,5,3,10,6,4,11])),`KnowledgeView`)}),Bi({getParentRoute:()=>V,path:`/skills/$name`,component:j(()=>al(()=>import(`./SkillView-BvVx3LSL.js`),__vite__mapDeps([23,1,2,5,24,9,3,10,6,4,11,16,17,18,25])),`SkillView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug/tasks`,component:j(()=>al(()=>import(`./TasksView-D10XP1uk.js`),__vite__mapDeps([26,1,9,11])),`TasksView`)}),Bi({getParentRoute:()=>V,path:`/task/$taskId`,component:j(()=>al(()=>import(`./TaskView-CyEWpCvS.js`),__vite__mapDeps([27,1,2,9,24,3,10,6,4,5,11,12,21,28,8])),`TaskView`)}),Bi({getParentRoute:()=>V,path:`/task/$taskId/files/$`,validateSearch:sl,component:j(()=>al(()=>import(`./FileView-DUMfKYRW.js`),__vite__mapDeps([29,1,3,10,6,11])),`TaskFileView`)}),Bi({getParentRoute:()=>V,path:`/p/$slug/files/$`,validateSearch:sl,component:j(()=>al(()=>import(`./FileView-DUMfKYRW.js`),__vite__mapDeps([29,1,3,10,6,11])),`ProjectFileView`)}),Bi({getParentRoute:()=>V,path:`/metrics`,validateSearch:t=>{let n=e.safeParse(t.window);return n.success?{window:n.data}:{}},component:j(()=>al(()=>import(`./MetricsView-DuOyISk1.js`),__vite__mapDeps([30,1,11,16,17,18])),`MetricsView`)}),Bi({getParentRoute:()=>V,path:`/citizens`,validateSearch:t=>{let n=e.safeParse(t.window);return n.success?{window:n.data}:{}},component:j(()=>al(()=>import(`./CitizensView-Bgw6PRSo.js`),__vite__mapDeps([31,1,17,11,18,32,2])),`CitizensView`)}),Bi({getParentRoute:()=>V,path:`/needs-you`,component:j(()=>al(()=>import(`./NeedsYouView-CrmHXZAn.js`),__vite__mapDeps([33,1,24,9,11])),`NeedsYouView`)}),Bi({getParentRoute:()=>V,path:`/runners`,validateSearch:e=>typeof e.code==`string`?{code:e.code}:{},component:j(()=>al(()=>import(`./RunnersView-CcAAfw6y.js`),__vite__mapDeps([34,1,2,17,4,5,6,11,32,18])),`RunnersView`)}),Bi({getParentRoute:()=>V,path:`/crons`,validateSearch:e=>({...typeof e.agent==`string`?{agent:e.agent}:{},...typeof e.cron==`string`?{cron:e.cron}:{}}),component:j(()=>al(()=>import(`./CronsView-BrXrcfC6.js`),__vite__mapDeps([35,1,2,17,10,6,4,5,11,18,20])),`CronsView`)}),Bi({getParentRoute:()=>V,path:`/proposals`,component:j(()=>al(()=>import(`./ProposalsView-C0r1ya8_.js`),__vite__mapDeps([36,1,24,9,11])),`ProposalsView`)}),Bi({getParentRoute:()=>V,path:`/proposal/$proposalId`,component:j(()=>al(()=>import(`./ProposalView-DJ0aJm7J.js`),__vite__mapDeps([37,1,2,17,9,24,3,10,6,4,5,11,12,25,36,28,8])),`ProposalView`)}),Bi({getParentRoute:()=>V,path:`/citizen/$name`,validateSearch:e=>({...typeof e.scope==`string`?{scope:e.scope}:{},...e.tab===`turns`||e.tab===`memory`||e.tab===`history`?{tab:e.tab}:{},...typeof e.turn==`string`?{turn:e.turn}:{}}),component:j(()=>al(()=>import(`./CitizenView-xU99R8hS.js`),__vite__mapDeps([38,1,2,17,10,6,4,5,11,12,18,20,32])),`CitizenView`)})])});function ul({signInError:e}){let t=m(),[n,r]=(0,O.useState)(ae),i=(0,O.useCallback)(()=>{v(),t.clear(),r(null)},[t]),a=(0,O.useCallback)(()=>{n!==null&&he(n).signOut().catch(()=>void 0),i(),ll.navigate({to:`/`})},[n,i]),o=(0,O.useMemo)(()=>n===null?null:{api:he(n),token:n,signOut:a,expire:i},[n,a,i]);return o===null?(0,A.jsx)(pa,{initialError:e,onEnter:e=>{_e(e),r(e)}}):(0,A.jsx)(Me,{value:o,children:(0,A.jsx)(ca,{router:ll})})}var dl={expired:`The sign-in took too long or was already used. Try again.`,declined:`GitHub sign-in was cancelled.`,github:`GitHub could not confirm who signed in. Try again.`,"not-allowed":`That GitHub account is not allowed on this board.`};function fl(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`session`),r=t.get(`signin-error`);return n===null&&r===null?null:{token:n===null||n===``?null:n,error:r===null?null:dl[r]??`GitHub sign-in failed.`}}function pl(){let e=fl(window.location.hash);return e!==null&&(e.token!==null&&_e(e.token),window.history.replaceState(window.history.state,``,`${window.location.pathname}${window.location.search}`)),e}var ml=new zt({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),hl=pl(),gl=document.getElementById(`root`);if(gl===null)throw Error(`missing #root element`);(0,ua.createRoot)(gl).render((0,A.jsx)(O.StrictMode,{children:(0,A.jsx)(de,{client:ml,children:(0,A.jsx)(ul,{signInError:hl?.error??null})})}));export{Ii as A,Pa as C,Sa as D,ya as E,la as O,Ia as S,xa as T,oo as _,Xo as a,Ya as b,fo as c,Po as d,yo as f,ao as g,Ro as h,ts as i,Ut as j,Li as k,Fo as l,po as m,As as n,Zo as o,jo as p,Rs as r,$o as s,Ps as t,uo as u,no as v,ba as w,$a as x,ro as y};
|