@skillmaker/cli-win32-x64 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/skillmaker.exe +0 -0
- package/package.json +1 -1
- package/viewer-dist/_astro/NextShell.BO2mdAaA.js +31 -0
- package/viewer-dist/_astro/index.sW4IKXt0.css +1 -0
- package/viewer-dist/index.html +1 -1
- package/viewer-dist/_astro/NextShell.BEF_RI5q.js +0 -31
- package/viewer-dist/_astro/index.CV5TvEA0.css +0 -1
package/bin/skillmaker.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillmaker/cli-win32-x64",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "skillmaker CLI binary + viewer assets for win32-x64. Installed automatically as an optionalDependency of skillmaker-studio -- not meant to be depended on or invoked directly.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{r as p}from"./index.DBy5LfQW.js";var un={exports:{}},st={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Is;function ko(){if(Is)return st;Is=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,i,o){var a=null;if(o!==void 0&&(a=""+o),i.key!==void 0&&(a=""+i.key),"key"in i){o={};for(var l in i)l!=="key"&&(o[l]=i[l])}else o=i;return i=o.ref,{$$typeof:e,type:s,key:a,ref:i!==void 0?i:null,props:o}}return st.Fragment=t,st.jsx=n,st.jsxs=n,st}var _s;function wo(){return _s||(_s=1,un.exports=ko()),un.exports}var r=wo();const wn="sm-active-project",jo=()=>{try{return typeof localStorage>"u"?null:localStorage.getItem(wn)}catch{return null}};let Mt=jo();const jn=new Set,Jn=()=>Mt,De=e=>{if(e!==Mt){Mt=e;try{typeof localStorage<"u"&&(e===null?localStorage.removeItem(wn):localStorage.setItem(wn,e))}catch{}for(const t of jn)t()}},So=e=>(jn.add(e),()=>jn.delete(e)),Hn=()=>p.useSyncExternalStore(So,Jn,()=>null),No=e=>e==="/api/health"||e==="/api/chat/providers"||e==="/api/events-stream"||e==="/api/projects"||e.startsWith("/api/projects/")||e.startsWith("/api/fs/"),ne=e=>{if(!e.startsWith("/api/")||No(e))return e;const t=Mt;return t===null?e:`/api/projects/${encodeURIComponent(t)}${e.slice(4)}`},Co=()=>{const[e,t]=p.useState("loading");return p.useEffect(()=>{let n=!1;return(async()=>{try{const s=await fetch("/api/projects",{headers:{accept:"application/json"}});if(!s.ok)throw new Error(String(s.status));const i=await s.json(),o=Array.isArray(i.projects)?i.projects:[],a=o.map(c=>typeof c.slug=="string"?c.slug:null).filter(c=>c!==null);if(n)return;const l=Jn();if(l===null||!a.includes(l)){const c=o.find(u=>typeof u.slug=="string"&&u.ok!==!1);De(typeof c?.slug=="string"?c.slug:a[0]??null)}t("ready")}catch{n||t("no-server")}})(),()=>{n=!0}},[]),e},Eo=(e,t,n)=>Math.min(n,Math.max(t,e)),Ro=(e,t)=>{if(typeof window>"u")return t;const n=window.localStorage.getItem(e),s=n===null?Number.NaN:Number(n);return Number.isFinite(s)?s:t};function Sn(e,t,n,s,i){const[o,a]=p.useState(()=>Ro(t,n)),[l,c]=p.useState(!1),u=p.useRef(o),h=p.useCallback(f=>{f.preventDefault(),c(!0);const m=b=>{const v=e==="left"?b.clientX:window.innerWidth-b.clientX,y=typeof i=="function"?i():i,x=Eo(v,s,y);u.current=x,a(x)},g=()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",g),c(!1);try{window.localStorage.setItem(t,String(u.current))}catch{}};window.addEventListener("mousemove",m),window.addEventListener("mouseup",g)},[e,t,s,i]);return{width:o,dragging:l,onDragStart:h}}function $o({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),r.jsx("line",{x1:"5.5",y1:"2.5",x2:"5.5",y2:"13.5"})]})}function Io({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),r.jsx("line",{x1:"10.5",y1:"2.5",x2:"10.5",y2:"13.5"})]})}function _o({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("circle",{cx:"3.5",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("line",{x1:"6.5",y1:"4.5",x2:"13.5",y2:"4.5"}),r.jsx("circle",{cx:"3.5",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("line",{x1:"6.5",y1:"8",x2:"13.5",y2:"8"}),r.jsx("circle",{cx:"3.5",cy:"11.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("line",{x1:"6.5",y1:"11.5",x2:"13.5",y2:"11.5"})]})}function Ao({size:e=15}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("rect",{x:"1.5",y:"2",width:"3.4",height:"9",rx:"0.8"}),r.jsx("rect",{x:"6.3",y:"2",width:"3.4",height:"12",rx:"0.8"}),r.jsx("rect",{x:"11.1",y:"2",width:"3.4",height:"6",rx:"0.8"})]})}function To({size:e=15}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("path",{d:"M2 4.5l1.5 1.5L6 3.5"}),r.jsx("line",{x1:"8",y1:"4.5",x2:"14",y2:"4.5"}),r.jsx("path",{d:"M2 10.5l1.5 1.5L6 9.5"}),r.jsx("line",{x1:"8",y1:"10.5",x2:"14",y2:"10.5"})]})}function xr({open:e}){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:`transition-transform duration-150 ${e?"rotate-90":""}`,children:r.jsx("path",{d:"M6 3.5L10.5 8L6 12.5"})})}function gr({size:e=14}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[r.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),r.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}function Oo({size:e=16}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"currentColor",children:r.jsx("path",{d:"M8 .8a7.2 7.2 0 0 0-2.28 14.03c.36.07.5-.16.5-.35v-1.22c-2 .43-2.43-.97-2.43-.97-.33-.83-.8-1.05-.8-1.05-.66-.45.05-.44.05-.44.72.05 1.1.75 1.1.75.65 1.1 1.7.79 2.1.6.07-.47.26-.79.46-.97-1.6-.18-3.28-.8-3.28-3.56 0-.79.28-1.43.74-1.94-.07-.18-.32-.91.07-1.9 0 0 .6-.2 1.98.74a6.9 6.9 0 0 1 3.6 0c1.38-.93 1.98-.74 1.98-.74.4.99.15 1.72.07 1.9.46.5.74 1.15.74 1.94 0 2.77-1.69 3.38-3.3 3.56.26.22.5.66.5 1.33v1.97c0 .2.13.42.5.35A7.2 7.2 0 0 0 8 .8Z"})})}function Po({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),r.jsx("path",{d:"M6.2 6.2a1.8 1.8 0 1 1 2.7 1.6c-.55.32-.9.6-.9 1.3v.3"}),r.jsx("circle",{cx:"8",cy:"11.4",r:"0.7",fill:"currentColor",stroke:"none"})]})}function Fo({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("path",{d:"M9.5 2.5h4v4"}),r.jsx("line",{x1:"13.5",y1:"2.5",x2:"9",y2:"7"}),r.jsx("path",{d:"M6.5 13.5h-4v-4"}),r.jsx("line",{x1:"2.5",y1:"13.5",x2:"7",y2:"9"})]})}function Mo({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("path",{d:"M7 3v4H3"}),r.jsx("line",{x1:"7",y1:"7",x2:"2.5",y2:"2.5"}),r.jsx("path",{d:"M9 13V9h4"}),r.jsx("line",{x1:"9",y1:"9",x2:"13.5",y2:"13.5"})]})}function Lo({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("circle",{cx:"8",cy:"8",r:"3"}),r.jsx("line",{x1:"8",y1:"1.2",x2:"8",y2:"3.2"}),r.jsx("line",{x1:"8",y1:"12.8",x2:"8",y2:"14.8"}),r.jsx("line",{x1:"1.2",y1:"8",x2:"3.2",y2:"8"}),r.jsx("line",{x1:"12.8",y1:"8",x2:"14.8",y2:"8"}),r.jsx("line",{x1:"3.2",y1:"3.2",x2:"4.6",y2:"4.6"}),r.jsx("line",{x1:"11.4",y1:"11.4",x2:"12.8",y2:"12.8"}),r.jsx("line",{x1:"12.8",y1:"3.2",x2:"11.4",y2:"4.6"}),r.jsx("line",{x1:"4.6",y1:"11.4",x2:"3.2",y2:"12.8"})]})}function Do({size:e=16}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:r.jsx("path",{d:"M13.2 9.8A5.6 5.6 0 0 1 6.2 2.8a5.6 5.6 0 1 0 7 7Z"})})}function Uo({size:e=16}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:r.jsx("path",{d:"M1.5 4.5a1 1 0 0 1 1-1h3l1.5 1.8h6.5a1 1 0 0 1 1 1v6.2a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1z"})})}const Ee=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let s=0,i=t.length;s<i;s++)n=t[s](n);return n}}},Bo={pipe(){return Ee(this,arguments)}},Yt=(function(){function e(){}return e.prototype=Bo,e})(),U=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,s){return arguments.length>=2?t(n,s):function(i){return t(i,n)}};case 3:return function(n,s,i){return arguments.length>=3?t(n,s,i):function(o){return t(o,n,s)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);const n=arguments;return function(s){return t(s,...n)}}}},lt=e=>e,Vo=e=>()=>e,br=Vo(void 0),Wo=br;function Oe(e){const t=new WeakMap;return n=>{if(t.has(n))return t.get(n);const s=e(n);return t.set(n,s),s}}const Nn=e=>{const t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");const n=Object.getPrototypeOf(e);let s=n;for(;s!==null&&s!==Object.prototype;){const i=Reflect.ownKeys(s);for(let o=0;o<i.length;o++)t.add(i[o]);s=Object.getPrototypeOf(s)}return t.has("constructor")&&typeof e.constructor=="function"&&n===e.constructor.prototype&&t.delete("constructor"),t},Cn=new WeakSet;function yr(e){return typeof e=="string"}function vr(e){return typeof e=="number"}function Ko(e){return typeof e=="boolean"}function qo(e){return typeof e=="symbol"}function Jo(e){return yr(e)||vr(e)||qo(e)}function zn(e){return typeof e=="function"}function Ho(e){return e!=null}function zo(e){return!0}function Go(e){return typeof e=="object"&&e!==null||zn(e)}const G=U(2,(e,t)=>Go(e)&&t in e),ue="~effect/interfaces/Hash",H=e=>{switch(typeof e){case"number":return Gn(e);case"bigint":return W(e.toString(10));case"boolean":return W(String(e));case"symbol":return W(String(e));case"string":return W(e);case"undefined":return W("undefined");case"function":case"object":{if(e===null)return W("null");if(e instanceof Date)return W(e.toISOString());if(e instanceof RegExp)return W(e.toString());{if(Cn.has(e))return En(e);if(fn.has(e))return fn.get(e);const t=ta(e,()=>Yo(e)?e[ue]():typeof e=="function"?En(e):Array.isArray(e)||ArrayBuffer.isView(e)?kr(e):e instanceof Map?Qo(e):e instanceof Set?ea(e):Zo(e));return fn.set(e,t),t}}default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},En=e=>(dn.has(e)||dn.set(e,Gn(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),dn.get(e)),ge=U(2,(e,t)=>e*53^t),Xt=e=>e&3221225471|e>>>1&1073741824,Yo=e=>G(e,ue),Gn=e=>{if(e!==e)return W("NaN");if(e===1/0)return W("Infinity");if(e===-1/0)return W("-Infinity");let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Xt(t)},W=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Xt(t)},Xo=(e,t)=>{let n=12289;for(const s of t)n^=ge(H(s),H(e[s]));return Xt(n)},Zo=e=>Xo(e,Nn(e)),Yn=(e,t)=>n=>{let s=e;for(const i of n)s^=t(i);return Xt(s)},kr=Yn(6151,H),Qo=Yn(W("Map"),([e,t])=>ge(H(e),H(t))),ea=Yn(W("Set"),H),dn=new WeakMap,fn=new WeakMap,hn=new WeakSet;function ta(e,t){if(hn.has(e))return W("[Circular]");hn.add(e);const n=t();return hn.delete(e),n}const de="~effect/interfaces/Equal";function ae(){return arguments.length===1?e=>Ae(e,arguments[0]):Ae(arguments[0],arguments[1])}function Ae(e,t){if(e===t)return!0;if(e==null||t==null)return!1;const n=typeof e;return n!==typeof t?!1:n==="number"&&e!==e&&t!==t?!0:n!=="object"&&n!=="function"||Cn.has(e)||Cn.has(t)?!1:ra(e,t,sa)}function na(e,t,n){const s=pn.has(e),i=mn.has(t);if(s&&i)return!0;if(s||i)return!1;pn.add(e),mn.add(t);const o=n();return pn.delete(e),mn.delete(t),o}const pn=new WeakSet,mn=new WeakSet;function sa(e,t){if(H(e)!==H(t))return!1;if(e instanceof Date)return t instanceof Date?e.toISOString()===t.toISOString():!1;if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;const n=As(e),s=As(t);if(n!==s)return!1;const i=n&&s;return typeof e=="function"&&!i?!1:na(e,t,()=>i?e[de](t):Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:ia(e,t):ArrayBuffer.isView(e)?!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength?!1:oa(e,t):e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:la(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:da(e,t):aa(e,t))}function ra(e,t,n){let s=It.get(e);if(!s)s=new WeakMap,It.set(e,s);else if(s.has(t))return s.get(t);const i=n(e,t);s.set(t,i);let o=It.get(t);return o||(o=new WeakMap,It.set(t,o)),o.set(e,i),i}const It=new WeakMap;function ia(e,t){for(let n=0;n<e.length;n++)if(!Ae(e[n],t[n]))return!1;return!0}function oa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function aa(e,t){const n=Nn(e),s=Nn(t);if(n.size!==s.size)return!1;for(const i of n)if(!s.has(i)||!Ae(e[i],t[i]))return!1;return!0}function ca(e,t){return function(s,i){for(const[o,a]of s){let l=!1;for(const[c,u]of i)if(e(o,c)&&t(a,u)){l=!0;break}if(!l)return!1}return!0}}const la=ca(Ae,Ae);function ua(e){return function(n,s){for(const i of n){let o=!1;for(const a of s)if(e(i,a)){o=!0;break}if(!o)return!1}return!0}}const da=ua(Ae),As=e=>G(e,de),fa=()=>ae,wr=e=>e.length>0,Xn=Symbol.for("~effect/Redactable"),ha=e=>G(e,Xn);function pa(e){return ha(e)?jr(e):e}function jr(e){return e[Xn](globalThis[ut]?.context??ma)}const ut="~effect/Fiber/currentFiber",ma={"~effect/Context":{},mapUnsafe:new Map,pipe(){return Ee(this,arguments)}};function z(e,t){const n=t?.space??0,s=new WeakSet,i=n?typeof n=="number"?" ".repeat(n):n:"",o=u=>i.repeat(u),a=(u,h)=>{const f=u?.constructor;return f&&f!==Object.prototype.constructor&&f.name?`${f.name}(${h})`:h},l=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,h=0){if(Array.isArray(u)){if(s.has(u))return Ts;if(s.add(u),!i||u.length<=1)return`[${u.map(m=>c(m,h)).join(",")}]`;const f=u.map(m=>c(m,h+1)).join(`,
|
|
10
|
+
`+o(h+1));return`[
|
|
11
|
+
${o(h+1)}${f}
|
|
12
|
+
${o(h)}]`}if(u instanceof Date)return ga(u);if(!t?.ignoreToString&&G(u,"toString")&&typeof u.toString=="function"&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){const f=ba(u);return u instanceof Error&&u.cause?`${f} (cause: ${c(u.cause,h)})`:f}if(typeof u=="string")return JSON.stringify(u);if(typeof u=="number"||u==null||typeof u=="boolean"||typeof u=="symbol")return String(u);if(typeof u=="bigint")return String(u)+"n";if(typeof u=="object"||typeof u=="function"){if(s.has(u))return Ts;if(s.add(u),Xn in u)return z(jr(u));if(Symbol.iterator in u)return`${u.constructor.name}(${c(Array.from(u),h)})`;const f=l(u);if(!i||f.length<=1){const g=`{${f.map(b=>`${Lt(b)}:${c(u[b],h)}`).join(",")}}`;return a(u,g)}const m=`{
|
|
13
|
+
${f.map(g=>`${o(h+1)}${Lt(g)}: ${c(u[g],h+1)}`).join(`,
|
|
14
|
+
`)}
|
|
15
|
+
${o(h)}}`;return a(u,m)}return String(u)}return c(e,0)}const Ts="[Circular]";function Lt(e){return typeof e=="string"?JSON.stringify(e):String(e)}function xa(e){return e.map(t=>`[${Lt(t)}]`).join("")}function ga(e){try{return e.toISOString()}catch{return"Invalid Date"}}function ba(e){try{const t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}const Zn=Symbol.for("nodejs.util.inspect.custom"),Sr=e=>{try{if(G(e,"toJSON")&&zn(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(Sr)}catch{return"[toJSON threw]"}return pa(e)};class Zt{called=!1;self;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new Zt(this.self)}}const ya=()=>{const e="~effect/Utils/internal",t={[e]:i=>i()},n={[e]:i=>{try{return i()}finally{}}};return t[e](()=>new Error().stack)?.includes(e)===!0?t[e]:n[e]},Qn=ya(),Pe="~effect/Effect",xt="~effect/Exit",va={_A:lt,_E:lt,_R:lt},Nr=`${Pe}/identifier`,L=`${Pe}/args`,J=`${Pe}/evaluate`,ce=`${Pe}/successCont`,we=`${Pe}/failureCont`,qe=`${Pe}/ensureCont`,$e=Symbol.for("effect/Effect/Yield"),es={pipe(){return Ee(this,arguments)},toJSON(){return{...this}},toString(){return z(this.toJSON(),{ignoreToString:!0,space:2})},[Zn](){return this.toJSON()}},ka={[Pe]:va,...es,[Symbol.iterator](){return new Zt(this)},toJSON(){return{_id:"Effect",op:this[Nr],...L in this?{args:this[L]}:void 0}}},wa=e=>G(e,xt),Ot="~effect/Cause",xn="~effect/Cause/Reason",Cr=e=>G(e,Ot);class Ye{[Ot];reasons;constructor(t){this[Ot]=Ot,this.reasons=t}pipe(){return Ee(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${z(this.reasons)})`}[Zn](){return this.toJSON()}[de](t){return Cr(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((n,s)=>ae(n,t.reasons[s]))}[ue](){return kr(this.reasons)}}const Os=new WeakMap;class ts{[xn];annotations;_tag;constructor(t,n,s){if(this[xn]=xn,this._tag=t,n!==Qt&&typeof s=="object"&&s!==null&&n.size>0){const i=Os.get(s);i&&(n=new Map([...i,...n])),Os.set(s,n)}this.annotations=n}annotate(t,n){if(t.mapUnsafe.size===0)return this;const s=new Map(this.annotations);t.mapUnsafe.forEach((o,a)=>{n?.overwrite!==!0&&s.has(a)||s.set(a,o)});const i=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return i.annotations=s,i}pipe(){return Ee(this,arguments)}toString(){return z(this)}[Zn](){return this.toString()}}const Qt=new Map;class Er extends ts{error;constructor(t,n=Qt){super("Fail",n,t),this.error=t}toString(){return`Fail(${z(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[de](t){return ns(t)&&ae(this.error,t.error)&&ae(this.annotations,t.annotations)}[ue](){return ge(W(this._tag))(ge(H(this.error))(H(this.annotations)))}}const Rn=e=>new Ye(e),ja=e=>new Ye([new Er(e)]);class Sa extends ts{defect;constructor(t,n=Qt){super("Die",n,t),this.defect=t}toString(){return`Die(${z(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[de](t){return Ca(t)&&ae(this.defect,t.defect)&&ae(this.annotations,t.annotations)}[ue](){return ge(W(this._tag))(ge(H(this.defect))(H(this.annotations)))}}const Na=e=>new Ye([new Sa(e)]),$n=U(e=>Cr(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Ye(e.reasons.map(s=>s.annotate(t,n)))),ns=e=>e._tag==="Fail",Ca=e=>e._tag==="Die",Rr=e=>e._tag==="Interrupt";function Ea(e){return gt("Effect.evaluate: Not implemented")}const Xe=e=>({...ka,[Nr]:e.op,[J]:e[J]??Ea,[ce]:e[ce],[we]:e[we],[qe]:e[qe]}),ve=e=>{const t=Xe(e);return function(){const n=Object.create(t);return n[L]=e.single===!1?arguments:arguments[0],n}},$r=e=>{const t={...Xe(e),[xt]:xt,_tag:e.op,get[e.prop](){return this[L]},toString(){return`${e.op}(${z(this[L])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[L]}},[de](n){return wa(n)&&n._tag===this._tag&&ae(this[L],n[L])},[ue](){return ge(W(e.op),H(this[L]))}};return function(n){const s=Object.create(t);return s[L]=n,s}},Se=$r({op:"Success",prop:"value",[J](e){const t=e.getCont(ce);return t?t[ce](this[L],e,this):e.yieldWith(this)}}),ss={key:"effect/Cause/StackTrace"},Ne=$r({op:"Failure",prop:"cause",[J](e){let t=this[L],n=!1;e.currentStackFrame&&(t=$n(t,{mapUnsafe:new Map([[ss.key,e.currentStackFrame]])}),n=!0);let s=e.getCont(we);for(;e.interruptible&&e._interruptedCause&&s;)s=e.getCont(we);return s?s[we](t,e,n?void 0:this):e.yieldWith(n?this:Ne(t))}}),rs=e=>Ne(ja(e)),gt=e=>Ne(Na(e)),In=ve({op:"WithFiber",[J](e){return this[L](e)}}),Ra=(function(){class e extends globalThis.Error{}const t=Xe({op:"YieldableError",[J](){return rs(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),$a=(function(){const e=Symbol.for("effect/Data/Error/plainArgs");return class extends Ra{constructor(n){super(n?.message,n?.cause?{cause:n.cause}:void 0),n&&(Object.assign(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Ir=e=>{class t extends $a{_tag=e}return t.prototype.name=e,t},_r="~effect/data/Option",Ar={[_r]:{_A:e=>e},...es,[Symbol.iterator](){return new Zt(this)}},Ia=Object.defineProperty(Object.assign(Object.create(Ar),{_tag:"Some",_op:"Some",[de](e){return Tr(e)&&Pr(e)&&ae(this.value,e.value)},[ue](){return ge(H(this._tag))(H(this.value))},toString(){return`some(${z(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:Sr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),_a=H("None"),Aa=Object.assign(Object.create(Ar),{_tag:"None",_op:"None",valueOrUndefined:void 0,[de](e){return Tr(e)&&Or(e)},[ue](){return _a},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Tr=e=>G(e,_r),Or=e=>e._tag==="None",Pr=e=>e._tag==="Some",Ta=Object.create(Aa),Oa=e=>{const t=Object.create(Ia);return t.value=e,t},St=()=>Ta,q=Oa,is=Or,_t=Pr,Fr=U(2,(e,t)=>is(e)?St():q(t(e.value))),Ps=globalThis.Array,bt=e=>Ps.isArray(e)?e:Ps.from(e),Mr=U(2,(e,t)=>[...e,t]),Pa=U(2,(e,t)=>bt(e).concat(bt(t))),gn=wr,Dt=wr;function Fa(e,t){return e<0||e>=t.length}const Ma=U(2,(e,t)=>{const n=Math.floor(t);if(Fa(n,e))throw new Error(`Index out of bounds: ${n}`);return e[n]}),La=Ma(0),Da=e=>e.slice(1),Ua=U(3,(e,t,n)=>{const s=bt(e),i=bt(t);return Dt(s)?Dt(i)?Ka(n)(Pa(s,i)):s:i}),Ba=U(2,(e,t)=>Ua(e,t,fa())),Va=()=>[],Wa=U(2,(e,t)=>e.map(t)),Ka=U(2,(e,t)=>{const n=bt(e);if(Dt(n)){const s=[La(n)],i=Da(n);for(const o of i)s.every(a=>!t(o,a))&&s.push(o);return s}return[]}),qa=e=>Xe({op:e.label,[J]:e.evaluate}),Ja=Object.getOwnPropertyDescriptor,Ha=Object.prototype.hasOwnProperty,za=Object.isExtensible,Ga=()=>{const e=Ja(Error,"stackTraceLimit");return e===void 0?za(Error):Ha.call(e,"writable")?e.writable===!0:e.set!==void 0},Ya=Ga(),Xa=()=>Error.stackTraceLimit,Fs=e=>{Ya&&(Error.stackTraceLimit=e)},Ms="~effect/Context/Service",Za=function(){const e=Xa();Fs(2);const t=new Error;Fs(e);function n(){}const s=n;return Object.setPrototypeOf(s,Qa),Object.defineProperty(s,"stack",{get(){return t.stack}}),arguments.length>0?(s.key=arguments[0],arguments[1]?.defaultValue&&(s[_n]=_n,s.defaultValue=arguments[1].defaultValue),s):function(i,o){return s.key=i,o?.make&&(s.make=o.make),s}},Qa={[Ms]:Ms,...qa({label:"Service",evaluate(e){return Se(bn(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of(e){return e},context(e){return Ur(this,e)},use(e){return In(t=>e(bn(t.context,this)))},useSync(e){return In(t=>Se(e(bn(t.context,this))))}},_n="~effect/Context/Reference",Lr="~effect/Context",en=e=>{const t=Object.create(ec);return t.mapUnsafe=e,t.mutable=!1,t},ec={...es,[Lr]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[de](e){if(!tc(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(const t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!ae(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[ue](){return Gn(this.mapUnsafe.size)}},tc=e=>G(e,Lr),Dr=()=>nc,nc=en(new Map),Ur=(e,t)=>en(new Map([[e.key,t]])),sc=U(3,(e,t,n)=>ac(e,s=>{s.set(t.key,n)})),rc=U(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(_n in t)return Br(t);throw oc(t)}return e.mapUnsafe.get(t.key)}),bn=rc,ic=(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):Br(t),yn="~effect/Context/defaultValue",Br=e=>yn in e?e[yn]:e[yn]=e.defaultValue(),oc=e=>{const t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){const n=e.stack.split(`
|
|
16
|
+
`);if(n.length>2){const s=n[2].match(/at (.*)/);s&&(t.message=t.message+` (defined at ${s[1]})`)}}if(t.stack){const n=t.stack.split(`
|
|
17
|
+
`);n.splice(1,3),t.stack=n.join(`
|
|
18
|
+
`)}return t},ac=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;const n=new Map(e.mapUnsafe);return t(n),en(n)},Ze=Za,Vr=Ze("effect/Scheduler",{defaultValue:()=>new Kr}),Wr="setImmediate"in globalThis?e=>{const t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{const t=setTimeout(e,0);return()=>clearTimeout(t)};class cc{buckets=[];scheduleTask(t,n){const s=this.buckets,i=s.length;let o,a=0;for(;a<i&&!(s[a][0]>n);a++)o=s[a];o&&o[0]===n?o[1].push(t):a===i?s.push([n,[t]]):s.splice(a,0,[n,[t]])}drain(){const t=this.buckets;return this.buckets=[],t}}class Kr{executionMode;setImmediate;constructor(t="async",n=Wr){this.executionMode=t,this.setImmediate=n}shouldYield(t){return t.currentOpCount>=t.maxOpsBeforeYield}makeDispatcher(){return new lc(this.setImmediate)}}class lc{tasks=new cc;running=void 0;setImmediate;constructor(t=Wr){this.setImmediate=t}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){const t=this.tasks.drain();for(let n=0;n<t.length;n++){const s=t[n][1];for(let i=0;i<s.length;i++)s[i]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}}const uc=Ze("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),dc=Ze("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1}),fc="effect/Tracer/ParentSpan",hc="effect/Tracer",pc="effect/observability/Metric/FiberRuntimeMetricsKey",mc=Ze("effect/References/CurrentStackFrame",{defaultValue:br}),xc=Ze("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),gc=Ze("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),bc="dev";class yc extends ts{fiberId;constructor(t,n=Qt){super("Interrupt",n,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[de](t){return Rr(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[ue](){return ge(W(`${this._tag}:${this.fiberId}`))(En(this.annotations))}}const vc=e=>new Ye([new yc(e)]),kc=e=>e.reasons.some(Rr),wc=U(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;const n=new Ye(Ba(e.reasons,t.reasons));return ae(e,n)?e:n}),jc=U(2,(e,t)=>{let n=!1;const s=e.reasons.map(i=>ns(i)?(n=!0,new Er(t(i.error))):i);return n?Rn(s):e}),Ls=`~effect/Fiber/${bc}`,Sc={_A:lt,_E:lt},Nc={id:0},Cc=()=>globalThis[ut];class qr{constructor(t,n=!0){this[Ls]=Sc,this.setContext(t),this.id=++Nc.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=n,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[Ls];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(t){return ic(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Wo):(this._observers.push(t),()=>{const n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}interruptUnsafe(t,n){if(this._exit)return;let s=vc(t);this.currentStackFrame&&(s=$n(s,Ur(ss,this.currentStackFrame))),n&&(s=$n(s,n)),this._interruptedCause=this._interruptedCause?wc(this._interruptedCause,s):s,this.interruptible&&this.evaluate(yt(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){const s=this._yielded;this._yielded=void 0,s()}const n=this.runLoop(t);if(n!==$e){this._exit=n,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let s=0;s<this._observers.length;s++)this._observers[s](n);this._observers.length=0}}runLoop(t){const n=globalThis[ut];globalThis[ut]=this;let s=!1,i=t;this.currentOpCount=0;const o=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!s&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){s=!0;const a=i;i=Re(Ac,()=>a)}if(i=this.currentTracerContext?this.currentTracerContext(i,this):i[J](this),o!==this.currentLoopCount)return $e;if(i===$e){const a=this._yielded;return xt in a?(this._yielded=void 0,a):$e}}}catch(a){return G(i,J)?this.runLoop(gt(a)):gt(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{globalThis[ut]=n}}getCont(t){for(;;){const n=this._stack.pop();if(!n)return;const s=n[qe]&&n[qe](this);if(s)return s[t]=s,s;if(n[t])return n}}yieldWith(t){return this._yielded=t,$e}children(){return this._children??=new Set}pipe(){return Ee(this,arguments)}setContext(t){this.context=t;const n=this.getRef(Vr);n!==this.currentScheduler&&(this.currentScheduler=n,this._dispatcher=void 0),this.currentSpan=t.mapUnsafe.get(fc),this.currentLogLevel=this.getRef(xc),this.minimumLogLevel=this.getRef(gc),this.currentStackFrame=t.mapUnsafe.get(mc.key),this.maxOpsBeforeYield=this.getRef(uc),this.currentPreventYield=this.getRef(dc),this.runtimeMetrics=t.mapUnsafe.get(pc);const s=t.mapUnsafe.get(hc);this.currentTracerContext=s?s.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}const Jr=e=>{if(!e.currentStackFrame)return;const t=new Map;return t.set(ss.key,e.currentStackFrame),en(t)},Ec=e=>Hr(t=>{const n=e[Symbol.iterator](),s=[];let i;function o(){let a=n.next();for(;!a.done;){if(a.value._exit){s.push(a.value._exit),a=n.next();continue}i=a.value.addObserver(l=>{s.push(l),o()});return}t(le(s))}return o(),Ic(()=>i?.())}),Rc=e=>In(t=>{const n=Jr(t);for(const s of e)s.interruptUnsafe(t.id,n);return Bc(Ec(e))}),le=Se,yt=Ne,$c=rs,Ic=ve({op:"Sync",[J](e){const t=this[L](),n=e.getCont(ce);return n?n[ce](t,e):e.yieldWith(Se(t))}}),Ut=ve({op:"Suspend",[J](e){return this[L]()}}),_c=ve({op:"Yield",[J](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Je)},this[L]??0),e.yieldWith(()=>{t=!0})}}),Ac=_c(0),Tc=e=>le(q(e)),Oc=le(St()),Pc=e=>Ut(()=>yt(Qn(e))),Fc=e=>gt(e),At=le(void 0),Mc=ve({op:"Async",single:!1,[J](e){const t=Qn(()=>this[L][0].bind(e.currentScheduler));let n=!1,s=!1;const i=this[L][1]?new AbortController:void 0,o=t(a=>{n||(n=!0,s?e.evaluate(a):s=a)},i?.signal);return s!==!1?s:(s=!0,e._yielded=()=>{n=!0},i===void 0&&o===void 0||e._stack.push(Lc(()=>(n=!0,i?.abort(),o??Je))),$e)}}),Lc=ve({op:"AsyncFinalizer",[qe](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Zc))},[we](e,t){return kc(e)?Re(this[L](),()=>yt(e)):yt(e)}}),Hr=e=>Mc(e,e.length>=2),Dc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Uc=(e,...t)=>Dc(e.length,t.length===0?function(){return Ds(()=>e.apply(this,arguments))}:function(){let n=Ds(()=>e.apply(this,arguments));for(const s of t)n=s(n);return n}),Ds=e=>{try{const t=e();let n;for(;;){const s=t.next(n);if(s.done)return le(s.value);const i=s.value;if(i&&i._tag==="Success"){n=i.value;continue}else{if(i&&i._tag==="Failure")return s.value;{let o=!0;return Ut(()=>o?(o=!1,Re(s.value,a=>Us(t,a))):Ut(()=>Us(e())))}}}}catch(t){return Fc(t)}},Us=ve({op:"Iterator",single:!1,[ce](e,t){const n=this[L][0];for(;;){const s=n.next(e);if(s.done)return le(s.value);if(Ce(s.value)){if(s.value._tag==="Failure")return s.value}else return t._stack.push(this),s.value;e=s.value.value}},[J](e){return this[ce](this[L][1],e)}}),Bc=e=>Re(e,t=>Je),Re=U(2,(e,t)=>{const n=Object.create(Vc);return n[L]=e,n[ce]=t.length!==1?s=>t(s):t,n}),Vc=Xe({op:"OnSuccess",[J](e){return e._stack.push(this),this[L]}}),Ce=e=>xt in e,Wc=U(2,(e,t)=>Ce(e)?e._tag==="Success"?t(e.value):e:Re(e,t)),Kc=U(2,(e,t)=>Re(e,n=>le(Qn(()=>t(n))))),qc=U(2,(e,t)=>Ce(e)?Hc(e,t):Kc(e,t)),Jc=e=>e._tag==="Success",Je=Se(void 0),Hc=U(2,(e,t)=>e._tag==="Success"?Se(t(e.value)):e),zc=U(2,(e,t)=>{const n=Object.create(Gc);return n[L]=e,n[we]=t.length!==1?s=>t(s):t,n}),Gc=Xe({op:"OnFailure",[J](e){return e._stack.push(this),this[L]}}),zr=e=>Ce(e)?Se(e):Yc(e),Yc=ve({op:"Exit",[J](e){return e._stack.push(this),this[L]},[ce](e,t,n){return le(n??Se(e))},[we](e,t,n){return le(n??Ne(e))}}),Xc=ve({op:"SetInterruptible",[qe](e){if(e.interruptible=this[L],e._interruptedCause&&e.interruptible)return()=>yt(e._interruptedCause)}}),Zc=Xc(!0),Qc=e=>{const t=e.onItem,n=e.step;return(s,i,o)=>{let a=o?.start??0;const l=o?.end??i.length,c=o?.concurrency??1;let u=!1,h,f,m,g=!1,b,v;const y=()=>{let x=!1;for(;!b&&a<l;a++){const w=i[a],N=v??t(s,w,a);if(Ce(N)){if(b=n(s,w,N,a),b)break}else{if(c===1)return Re(zr(N),C=>(b=n(s,w,C,a),a++,b??y()??At));if(h){v=void 0;const C=el(h,N,!0,!0,"inherit");if(C._exit){if(b=n(s,w,C._exit,a),b)break;continue}f?f.add(C):f=new Set([C]);const R=a;if(C.addObserver(F=>{if(f.delete(C),b){if(!g&&F._tag==="Failure")for(const A of F.cause.reasons)A._tag!=="Interrupt"&&(b._tag==="Failure"?b.cause.reasons.push(A):b=Ne(Rn([A])))}else{const A=n(s,w,F,R);A&&(b=A._tag==="Failure"?Ne(Rn(A.cause.reasons.slice())):A,y())}if(x){const A=y();A&&m(A)}else u&&f.size===0&&m(b??At)}),f.size<c)continue;x=!0,a++;return}else return Hr(C=>{h=Cc(),v=N,m=C;const R=y();return R?C(R):Ut(()=>(b=Je,g=!0,f?Rc(f):At))})}}if(u=!0,b){if(f&&f.size>0){const w=Jr(h);f.forEach(N=>N.interruptUnsafe(h.id,w));return}if(m||b._tag==="Failure")return b}else if(m)if(f)f.size===0&&m(At);else return Je};return y()}},tn=()=>Qc,el=(e,t,n=!1,s=!1,i=!1)=>{const o=i==="inherit"?e.interruptible:!i,a=new qr(e.context,o);return n?a.evaluate(t):e.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),!s&&!a._exit&&(e.children().add(a),a.addObserver(()=>e._children.delete(a))),a},Gr=e=>(t,n)=>{const s=new qr(n?.scheduler?sc(e,Vr,n.scheduler):e,n?.uninterruptible!==!0);if(s.evaluate(t),s._exit)return s;if(n?.signal)if(n.signal.aborted)s.interruptUnsafe();else{const i=()=>s.interruptUnsafe();n.signal.addEventListener("abort",i,{once:!0}),s.addObserver(()=>n.signal.removeEventListener("abort",i))}return n?.onFiberStart&&n.onFiberStart(s),s},tl=e=>{const t=Gr(e);return(n,s)=>{const i=t(n,s);return new Promise(o=>{i.addObserver(a=>o(a))})}},nl=tl(Dr()),sl=e=>{const t=Gr(e);return n=>{if(Ce(n))return n;const s=new Kr("sync"),i=t(n,{scheduler:s});return i.currentDispatcher?.flush(),i._exit??gt(new il(i))}},rl=sl(Dr()),Bs="~effect/Cause/AsyncFiberError";class il extends Ir("AsyncFiberError"){[Bs]=Bs;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}}const Yr=ns,os=jc,ol=Ne,nn=rs,al=Je,as=Jc,cl=class extends Yt{constructor(t){super(),t&&Object.assign(this,t)}},ll=Ir,oe=le,cs=Oc,ul=Tc,X=$c,Xr=Pc,dl=Re,Vs=zr,Zr=zc,fl=nl,Qr=rl,ei=qc,Ie=Wc,An=Uc;function it(e,t,n){return t==="__proto__"?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n,e}function hl(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function pl(e){return t=>hl(t)?.[e]}const ml=pl("identifier"),ls=Oe(e=>{const t=ml(e);return typeof t=="string"?t:e.getExpected(ls)}),Tn="~effect/SchemaIssue/Issue";function ti(e){return G(e,Tn)}let fe=class{[Tn]=Tn;toString(){return Sl(this)}},xl=class extends fe{_tag="Filter";actual;filter;issue;constructor(t,n,s){super(),this.actual=t,this.filter=n,this.issue=s}};class gl extends fe{_tag="Encoding";ast;actual;issue;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issue=s}}class Te extends fe{_tag="Pointer";path;issue;constructor(t,n){super(),this.path=t,this.issue=n}}class ni extends fe{_tag="MissingKey";annotations;constructor(t){super(),this.annotations=t}}class si extends fe{_tag="UnexpectedKey";ast;actual;constructor(t,n){super(),this.ast=t,this.actual=n}}class ee extends fe{_tag="Composite";ast;actual;issues;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issues=s}}class Nt extends fe{_tag="InvalidType";ast;actual;constructor(t,n){super(),this.ast=t,this.actual=n}}class Bt extends fe{_tag="InvalidValue";actual;annotations;constructor(t,n){super(),this.actual=t,this.annotations=n}}class Ws extends fe{_tag="AnyOf";ast;actual;issues;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.issues=s}}class bl extends fe{_tag="OneOf";ast;actual;successes;constructor(t,n,s){super(),this.ast=t,this.actual=n,this.successes=s}}function On(e,t){if(ti(t))return t;if(typeof t=="string")return new Bt(q(e),{message:t});const n=typeof t.issue=="string"?new Bt(q(e),{message:t.issue}):t.issue;return new Te(t.path,n)}function yl(e,t){if(t!==void 0)return typeof t=="boolean"?t?void 0:new Bt(q(e)):On(e,t)}function vl(e,t,n){return Array.isArray(n)?Dt(n)?n.length===1?On(e,n[0]):new ee(t,q(e),Wa(n,s=>On(e,s))):void 0:yl(e,n)}const kl=e=>{const t=vt(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return Pn(ls(e.ast),Ks(e.actual));case"InvalidValue":return`Invalid data ${Ks(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${z(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${z(e.actual)}`}},wl=e=>vt(e.issue)??vt(e);function Pn(e,t){return`Expected ${e}, got ${t}`}function Le(e,t,n,s){switch(e._tag){case"Filter":{const i=s(e);if(i!==void 0)return[{path:t,message:i}];switch(e.issue._tag){case"InvalidValue":return[{path:t,message:Pn(ri(e.filter),z(e.actual))}];default:return Le(e.issue,t,n,s)}}case"Encoding":return Le(e.issue,t,n,s);case"Pointer":return Le(e.issue,[...t,...e.path],n,s);case"Composite":return e.issues.flatMap(i=>Le(i,t,n,s));case"AnyOf":{const i=vt(e);if(e.issues.length===0){if(i!==void 0)return[{path:t,message:i}];const o=Pn(ls(e.ast),z(e.actual));return[{path:t,message:o}]}return e.issues.flatMap(o=>Le(o,t,n,s))}default:return[{path:t,message:n(e)}]}}function ri(e){const t=e.annotations?.expected;if(typeof t=="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(n=>ri(n)).join(" & ")}}function jl(){return e=>Le(e,[],kl,wl).map(Nl).join(`
|
|
19
|
+
`)}const Sl=jl();function Nl(e){let t=e.message;if(e.path&&e.path.length>0){const n=xa(e.path);t+=`
|
|
20
|
+
at ${n}`}return t}function vt(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return rt(e.ast.annotations);case"InvalidValue":case"Forbidden":return rt(e.annotations);case"MissingKey":return rt(e.annotations,"messageMissingKey");case"UnexpectedKey":return rt(e.ast.annotations,"messageUnexpectedKey");case"Filter":return rt(e.filter.annotations);case"Encoding":return vt(e.issue)}}function rt(e,t="message"){const n=e?.[t];if(typeof n=="string")return n}function Ks(e){return is(e)?"no value provided":z(e.value)}function us(e){let t;for(const n of e.reasons){if(!Yr(n)||!ti(n.error))return;t??=n.error}return t}function ii(e,t){const n=us(e);if(n===void 0)throw new Error(t,{cause:e});return n}class kt extends Yt{run;constructor(t){super(),this.run=t}map(t){return new kt((n,s)=>this.run(n,s).pipe(ei(Fr(t))))}compose(t){return qs(this)?t:qs(t)?this:new kt((n,s)=>this.run(n,s).pipe(Ie(i=>t.run(i,s))))}}const ds=new kt(oe);function qs(e){return e.run===ds.run}function Fn(){return ds}function Cl(){return ds}function be(e){return El(Fr(e))}function El(e){return new kt(t=>oe(e(t)))}function Rl(){return be(globalThis.String)}function oi(){return be(globalThis.Number)}const Mn="~effect/SchemaTransformation/Transformation";class ye{[Mn]=Mn;_tag="Transformation";decode;encode;constructor(t,n){this.decode=t,this.encode=n}flip(){return new ye(this.encode,this.decode)}compose(t){return new ye(this.decode.compose(t.decode),t.encode.compose(this.encode))}}function $l(e){return G(e,Mn)}const Il=e=>$l(e)?e:new ye(e.decode,e.encode),_l=new ye(Fn(),Fn());function Al(){return _l}const ai=new ye(oi(),Rl());function Qe(e){return t=>t._tag===e}const Tl=Qe("Declaration"),Ol=Qe("Never"),Vt=Qe("Literal"),Pl=Qe("UniqueSymbol"),Fl=Qe("Arrays"),Ml=Qe("Objects");class ie{to;transformation;constructor(t,n){this.to=t,this.transformation=n}}const ci={};class Wt{isOptional;isMutable;defaultValue;annotations;constructor(t,n,s=void 0,i=void 0){this.isOptional=t,this.isMutable=n,this.defaultValue=s,this.annotations=i}}const Js="~effect/Schema";class he{[Js]=Js;annotations;checks;encoding;context;constructor(t=void 0,n=void 0,s=void 0,i=void 0){this.annotations=t,this.checks=n,this.encoding=s,this.context=i}toString(){return`<${this._tag}>`}}class fs extends he{_tag="Declaration";typeParameters;run;encodingChecks;constructor(t,n,s,i,o,a,l){super(s,i,o,a),this.typeParameters=t,this.run=n,this.encodingChecks=l}getParser(){const t=this.run(this.typeParameters);return(n,s)=>is(n)?cs:ei(t(n.value,this,s),q)}_rebuild(t,n,s){const i=He(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&s===this.encodingChecks?this:new fs(i,this.run,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){const t=this.annotations?.expected;return typeof t=="string"?t:"<Declaration>"}}let Ll=class extends he{_tag="Null";getParser(){return Ni(this,null)}getExpected(){return"null"}};const Dl=new Ll;let Ul=class extends he{_tag="Unknown";getParser(){return Rt(this,zo)}getExpected(){return"unknown"}};const Bl=new Ul;let dt=class extends he{_tag="Literal";literal;constructor(t,n,s,i,o){if(super(n,s,i,o),typeof t=="number"&&!globalThis.Number.isFinite(t))throw new Error(`A numeric literal must be finite, got ${z(t)}`);this.literal=t}getParser(){return Ni(this,this.literal)}matchPart(t,n){return t===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?Hs(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:Hs(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Hs(e){const t=globalThis.String(e.literal);return te(e,[new ie(new dt(t),new ye(be(()=>e.literal),be(()=>t)))])}let Vl=class extends he{_tag="String";getParser(){return Rt(this,yr)}matchPart(t,n){return Ci(this,t,n)}getExpected(){return"string"}};const li=new Vl;let Wl=class extends he{_tag="Number";getParser(){return Rt(this,vr)}matchKey(t,n){return this._match(fu,t,n)}matchPart(t,n){return this._match(Dn,t,n)}_match(t,n,s){return t.test(n)?Ci(this,globalThis.Number(n),s):void 0}toCodecJson(){return this.checks&&(ot(this.checks,"isFinite")||ot(this.checks,"isInt"))?this:te(this,[tu])}toCodecStringTree(){return this.checks&&(ot(this.checks,"isFinite")||ot(this.checks,"isInt"))?te(this,[pu]):te(this,[mu])}getExpected(){return"number"}};function ot(e,t){return e.some(n=>{switch(n._tag){case"Filter":return n.annotations?.meta?._tag===t;case"FilterGroup":return ot(n.checks,t)}})}const ui=new Wl;let Kl=class extends he{_tag="Boolean";getParser(){return Rt(this,Ko)}getExpected(){return"boolean"}};const ql=new Kl;class sn extends he{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(t,n,s,i,o,a,l,c){super(i,o,a,l),this.isMutable=t,this.elements=n,this.rest=s,this.encodingChecks=c;const u=n.findIndex(je);if(u!==-1&&(n.slice(u+1).some(h=>!je(h))||s.length>1))throw new Error("A required element cannot follow an optional element. ts(1257)");if(s.length>1&&s.slice(1).some(je))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(t){const n=this,s=n.elements.map(h=>({ast:h,parser:t(h)})),i=n.rest.map(h=>({ast:h,parser:t(h)})),o=s.length,[a,...l]=i,c=l.length;function u(h,f){return f<o?s[f]:f>=h?l[f-h]:a}return An(function*(h,f){if(h._tag==="None")return h;const m=h.value;if(!Array.isArray(m))return yield*X(new Nt(n,h));const g=m.length,b={ast:n,getParser:u,oinput:h,len:g,tailThreshold:Hl(g,o,c),output:new globalThis.Array(g),issues:void 0,options:f},v=hs(f?.concurrency),y=Jl(b,m,{concurrency:v?.concurrency,end:n.rest.length===0?o:Math.max(g,o+c)});if(y&&(yield*y),n.rest.length===0&&g>o)for(let x=o;x<=g-1;x++){const w=new Te([x],new si(n,m[x]));if(f.errors==="all")b.issues?b.issues.push(w):b.issues=[w];else return yield*X(new ee(n,h,[w]))}return b.issues?yield*X(new ee(n,h,b.issues)):q(b.output)})}_rebuild(t,n,s){const i=He(this.elements,t),o=He(this.rest,t);return i===this.elements&&o===this.rest&&n===this.checks&&s===this.encodingChecks?this:new sn(this.isMutable,i,o,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}getExpected(){return"array"}}const Jl=tn()({onItem(e,t,n){const s=n<e.len?q(t):St();return e.getParser(e.tailThreshold,n).parser(s,e.options)},step(e,t,n,s){if(n._tag==="Failure")return Kt(e,e.ast,s,n);if(n.value._tag==="Some")e.output[s]=n.value.value;else{const i=e.getParser(e.tailThreshold,s);if(je(i.ast))return;const o=new Te([s],new ni(i.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(o):e.issues=[o];else return nn(new ee(e.ast,e.oinput,[o]))}}});function Hl(e,t,n){return Math.max(t,e-n)}const hs=e=>(e=e==="unbounded"?1/0:e??1,e>1?{concurrency:e}:void 0),Kt=(e,t,n,s)=>{if(s.cause.reasons.length===0)return s;const i=us(s.cause);if(i===void 0)return ol(os(s.cause,a=>new ee(t,e.oinput,[new Te([n],a)])));const o=new Te([n],i);if(e.options.errors==="all")e.issues?e.issues.push(o):e.issues=[o];else return nn(new ee(t,e.oinput,[o]))},di="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function zl(e,t,n=ci){let s,i;function o(a){switch(a._tag){case"String":case"TemplateLiteral":return(s??=Object.keys(e)).filter(l=>a.matchPart(l,n)!==void 0);case"Number":return(s??=Object.keys(e)).filter(l=>a.matchKey(l,n)!==void 0);case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(l=>a.matchKey(l,n)!==void 0);case"Union":return[...new Set(a.types.flatMap(o))];default:return[]}}return o(bs(Et(t)))}class ps{name;type;constructor(t,n){this.name=t,this.type=n}}function Ln(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(Ln);default:return!1}}function Gl(e){return Ln(e)&&Ln(Et(e))}class fi{parameter;type;merge;constructor(t,n,s){if(!Gl(t))throw new Error(`Invalid index signature parameter ${t._tag}`);if(this.parameter=t,this.type=n,this.merge=s,je(n)&&!Si(n))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}class rn extends he{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(t,n,s,i,o,a,l){super(s,i,o,a),this.propertySignatures=t,this.indexSignatures=n,this.encodingChecks=l;const c=t.map(u=>u.name).filter((u,h,f)=>f.indexOf(u)!==h);if(c.length>0)throw new Error(`Duplicate identifiers: ${JSON.stringify(c)}. ts(2300)`)}getParser(t){const n=this,s=[],i=new Set,o=[];for(const c of n.propertySignatures)s.push(c.name),i.add(c.name),o.push({ps:c,parser:t(c.type),name:c.name,type:c.type});const a=n.indexSignatures.length;if(n.propertySignatures.length===0&&n.indexSignatures.length===0)return Rt(n,Ho);const l=a>0?tn()({onItem:An(function*(c,[u,h]){const m=t(bs(h.parameter))(q(u),c.options),g=Ce(m)?m:yield*Vs(m);if(g._tag==="Failure"){const w=Kt(c,n,u,g);w&&(yield*w);return}const b=q(c.input[u]),y=t(h.type)(b,c.options),x=Ce(y)?y:yield*Vs(y);if(x._tag==="Failure"){const w=Kt(c,n,u,x);w&&(yield*w);return}else if(g.value._tag==="Some"&&x.value._tag==="Some"){const w=g.value.value;if(i.has(u)||i.has(w))return;const N=x.value.value;if(h.merge&&h.merge.decode&&Object.hasOwn(c.out,w)){const[C,R]=h.merge.decode.combine([w,c.out[w]],[w,N]);it(c.out,C,R)}else it(c.out,w,N)}}),step:(c,u,h)=>h._tag==="Failure"?h:void 0}):void 0;return An(function*(c,u){if(c._tag==="None")return c;const h=c.value;if(!(typeof h=="object"&&h!==null&&!Array.isArray(h)))return yield*X(new Nt(n,c));const f={},m={ast:n,oinput:c,input:h,out:f,issues:void 0,options:u},g=u.errors==="all",b=u.onExcessProperty==="error",v=u.onExcessProperty==="preserve";let y;if(n.indexSignatures.length===0&&(b||v)){y=Reflect.ownKeys(h);for(let N=0;N<y.length;N++){const C=y[N];if(!i.has(C))if(b){const R=new Te([C],new si(n,h[C]));if(g){m.issues?m.issues.push(R):m.issues=[R];continue}else return yield*X(new ee(n,c,[R]))}else it(f,C,h[C])}}const x=hs(u?.concurrency),w=Yl(m,o,x);if(w&&(yield*w),l){const N=Va();for(let R=0;R<a;R++){const F=n.indexSignatures[R],A=zl(h,F.parameter,u);for(let K=0;K<A.length;K++){const k=A[K];N.push([k,F])}}const C=l(m,N,x);C&&(yield*C)}if(m.issues)return yield*X(new ee(n,c,m.issues));if(u.propertyOrder==="original"){const N=(y??Reflect.ownKeys(h)).concat(s),C={};for(const R of N)Object.hasOwn(f,R)&&it(C,R,f[R]);return q(C)}return q(f)})}_rebuild(t,n,s,i,o){const a=He(this.propertySignatures,c=>{const u=t(c.type);return u===c.type?c:new ps(c.name,u)}),l=He(this.indexSignatures,c=>{const u=n(c.parameter),h=t(c.type),f=s?c.merge?.flip():c.merge;return u===c.parameter&&h===c.type&&f===c.merge?c:new fi(u,h,f)});return a===this.propertySignatures&&l===this.indexSignatures&&i===this.checks&&o===this.encodingChecks?this:new rn(a,l,this.annotations,i,void 0,this.context,o)}flip(t){return this._rebuild(t,t,!0,this.encodingChecks,this.checks)}recur(t,n=t){return this._rebuild(t,n,!1,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?"object | array":"object"}}const Yl=tn()({onItem(e,t){const n=Object.hasOwn(e.input,t.name)?q(e.input[t.name]):St();return t.parser(n,e.options)},step(e,t,n){if(n._tag==="Failure")return Kt(e,e.ast,t.name,n);if(n.value._tag==="Some")it(e.out,t.name,n.value.value);else if(!je(t.type)){const s=new Te([t.name],new ni(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(s):e.issues=[s];return}else return nn(new ee(e.ast,e.oinput,[s]))}}});function hi(e,t){return e?t?[...e,...t]:e:t}function ms(e,t,n){return new rn(Reflect.ownKeys(e).map(s=>new ps(s,e[s].ast)),[],n,t)}function Xl(e){return e.ast}function pi(e,t=void 0){return new sn(!1,e.map(n=>n.ast),[],void 0,t)}function xs(e,t,n){return new on(e.map(Xl),t,void 0,n)}function mi(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["object","array"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(mi)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function gs(e){switch(e._tag){default:return[];case"Declaration":{const t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{const n=t.type;if(!je(n)){if(Vt(n))return[{key:t.name,literal:n.literal}];if(Pl(n))return[{key:t.name,literal:n.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,n)=>Vt(t)&&!je(t)?[{key:n,literal:t.literal}]:[]);case"Suspend":return gs(e.thunk())}}const zs=new WeakMap;function Zl(e){let t=zs.get(e);if(t)return t;t={};for(const n of e){const s=Et(n);if(Ol(s))continue;const i=mi(s),o=gs(s);t.byType??={};for(const a of i)(t.byType[a]??=[]).push(n);if(o.length>0){t.bySentinel??=new Map;for(const{key:a,literal:l}of o){let c=t.bySentinel.get(a);c||t.bySentinel.set(a,c=new Map);let u=c.get(l);u||c.set(l,u=[]),u.push(n)}}else{t.otherwise??={};for(const a of i)(t.otherwise[a]??=[]).push(n)}}return zs.set(e,t),t}function Gs(e){return t=>{const n=Et(t);return n._tag==="Literal"?n.literal===e:n._tag==="UniqueSymbol"?n.symbol===e:!0}}function Ql(e,t){const n=Zl(t),s=e===null?"null":Array.isArray(e)?"array":typeof e;if(n.bySentinel){const i=n.otherwise?.[s]??[];if(s==="object"||s==="array"){for(const[o,a]of n.bySentinel)if(Object.hasOwn(e,o)){const l=a.get(e[o]);if(l)return[...l,...i].filter(Gs(e))}}return i}return(n.byType?.[s]??[]).filter(Gs(e))}let on=class xi extends he{_tag="Union";types;mode;encodingChecks;constructor(t,n,s,i,o,a,l){super(s,i,o,a),this.types=t,this.mode=n,this.encodingChecks=l}getParser(t){const n=this;return(s,i)=>{if(s._tag==="None")return oe(s);const o=s.value,a=Ql(o,n.types),l={ast:n,recur:t,oinput:s,input:o,out:void 0,successes:[],issues:void 0,options:i},c=hs(i?.concurrency),u=eu(l,a,c);return u?dl(u,h=>l.out?oe(l.out):X(new Ws(n,o,l.issues??[]))):l.out?oe(l.out):X(new Ws(n,o,l.issues??[]))}}_rebuild(t,n,s){const i=He(this.types,t);return i===this.types&&n===this.checks&&s===this.encodingChecks?this:new xi(i,this.mode,this.annotations,n,void 0,this.context,s)}recur(t){return this._rebuild(t,this.checks,this.encodingChecks)}flip(t){return this._rebuild(t,this.encodingChecks,this.checks)}matchPart(t,n){for(const s of this.types){const i=s.matchPart(t,n);if(i!==void 0)return i}}getExpected(t){const n=this.annotations?.expected;if(typeof n=="string")return n;if(this.types.length===0)return"never";const s=this.types.map(i=>{const o=Et(i);switch(o._tag){case"Arrays":{const a=o.elements.filter(Vt);if(a.length>0)return`${Ys(o.isMutable)}[ ${a.map(l=>t(l)+Xs(l.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{const a=o.propertySignatures.filter(l=>Vt(l.type));if(a.length>0)return`{ ${a.map(l=>`${Ys(l.type.context?.isMutable)}${Lt(l.name)}${Xs(l.type.context?.isOptional)}: ${t(l.type)}`).join(", ")}, ... }`;break}}return t(o)});return Array.from(new Set(s)).join(" | ")}};const eu=tn()({onItem(e,t){return e.recur(t)(e.oinput,e.options)},step(e,t,n){if(n._tag==="Failure"){const s=us(n.cause);if(s===void 0)return n;e.issues?e.issues.push(s):e.issues=[s]}else{if(e.out&&e.ast.mode==="oneOf")return e.successes.push(t),nn(new bl(e.ast,e.input,e.successes));if(e.out=n.value,e.successes.push(t),e.ast.mode==="anyOf")return al}}}),gi=new on([new dt("Infinity"),new dt("-Infinity"),new dt("NaN")],"anyOf"),tu=new ie(new on([ui,gi],"anyOf"),new ye(oi(),be(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Ys(e){return e?"":"readonly "}function Xs(e){return e?"?":""}class qt extends Yt{_tag="Filter";run;annotations;aborted;constructor(t,n=void 0,s=!1){super(),this.run=t,this.annotations=n,this.aborted=s}annotate(t){return new qt(this.run,{...this.annotations,...t},this.aborted)}abort(){return new qt(this.run,this.annotations,!0)}and(t,n){return new Jt([this,t],n)}}class Jt extends Yt{_tag="FilterGroup";checks;annotations;constructor(t,n=void 0){super(),this.checks=t,this.annotations=n}annotate(t){return new Jt(this.checks,{...this.annotations,...t})}and(t,n){return new Jt([this,t],n)}}function nu(e,t,n=!1){return new qt((s,i,o)=>vl(s,i,e(s,i,o)),t,n)}function su(e,t){const n=e.source;return nu(s=>e.test(s),{expected:`a string matching the RegExp ${n}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function Ct(e,t){const n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}function te(e,t){return e.encoding===t?e:Ct(e,n=>{n.encoding.value=t})}function bi(e,t){return e.context===t?e:Ct(e,n=>{n.context.value=t})}function yi(e,t){if(e.checks){const n=e.checks[e.checks.length-1];return vi(e,Mr(e.checks.slice(0,-1),n.annotate(t)))}return Ct(e,n=>{n.annotations.value={...n.annotations.value,...t}})}function vi(e,t){if(e._tag==="Suspend"&&t!==void 0)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Ct(e,n=>{n.checks.value=t})}function Ht(e,t){return vi(e,hi(e.checks,t))}function ki(e,t){const n=e,s=n[n.length-1],i=t(s.to);return i!==s.to?Mr(e.slice(0,e.length-1),new ie(i,s.transformation)):e}function ru(e){return t=>t.encoding?te(t,ki(t.encoding,e)):t}function iu(e){function t(n){return n.encoding?te(n,ki(n.encoding,t)):e(n)}return Oe(t)}function ou(e,t,n){const s=new ie(e,t);return te(n,n.encoding?[...n.encoding,s]:[s])}function He(e,t){let n=!1;const s=new Array(e.length);for(let i=0;i<e.length;i++){const o=e[i],a=t(o);a!==o&&(n=!0),s[i]=a}return n?s:e}function wi(e,t){const n=e.context?new Wt(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new Wt(!1,!1,void 0,t);return bi(e,n)}const au=ru(ji);function ji(e){const t=e.context?e.context.isOptional===!1?new Wt(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new Wt(!0,!1);return au(bi(e,t))}function cu(e,t,n){return ou(e,n,t)}function lu(e){const t=[],n=[];function s(i){switch(i._tag){case"Literal":Jo(i.literal)&&t.push(i.literal);return;case"UniqueSymbol":t.push(i.symbol);return;case"Never":return;case"Union":for(let o=0;o<i.types.length;o++)s(i.types[o]);return;default:n.push(i)}}return s(e),{literals:t,parameters:n}}function uu(e,t,n){const{literals:s,parameters:i}=lu(e);return new rn(s.map(o=>new ps(o,t)),i.map(o=>new fi(o,t,n)))}function je(e){return e.context?.isOptional??!1}const zt=Oe(e=>{if(e.encoding)return zt(te(e,void 0));const t=e,n=t.recur?.(zt)??t,s=n.encodingChecks;return s?Ct(n,i=>{i.encodingChecks.value=void 0,n===e&&(i.checks.value=hi(n.checks,s))}):n}),Et=Oe(e=>zt(We(e)));function du(e,t){const n=t,s=n.length,i=n[s-1],o=[new ie(We(te(e,void 0)),n[0].transformation.flip())];for(let l=1;l<s;l++)o.unshift(new ie(We(n[l-1].to),n[l].transformation.flip()));const a=We(i.to);return a.encoding?te(a,[...a.encoding,...o]):te(a,o)}const We=Oe(e=>{if(e.encoding)return du(e,e.encoding);const t=e;return t.flip?.(We)??t.recur?.(We)??t});function Si(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(Si);default:return!1}}function Ni(e,t){const n=ul(t);return s=>s._tag==="None"?cs:s.value===t?n:X(new Nt(e,s))}function Rt(e,t){return n=>n._tag==="None"?cs:t(n.value)?oe(n):X(new Nt(e,n))}function Ci(e,t,n){if(n?.disableChecks||e.checks===void 0)return t;const s=[];return ft(e.checks,t,s,e,n),s.length===0?t:void 0}const bs=iu(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(bs)}}),Dn=new globalThis.RegExp(`^${di}$`),fu=new globalThis.RegExp(`(?:${di}|Infinity|-Infinity|NaN)`);function hu(e){return su(Dn,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:Dn},...e})}const Ei=Ht(li,[hu()]),pu=new ie(Ei,ai),mu=new ie(new on([Ei,gi],"anyOf"),ai);function ft(e,t,n,s,i){for(let o=0;o<e.length;o++){const a=e[o];if(a._tag==="FilterGroup")ft(a.checks,t,n,s,i);else{const l=a.run(t,s,i);if(l&&(n.push(new xl(t,a,l)),a.aborted||i?.errors!=="all"))return}}}const Ri="~effect/Schema/Class",xu="~structural",ys=e=>e,at=Oe(e=>{switch(e._tag){case"Declaration":{const t=e.annotations?.[Ri];if(zn(t)){const n=t(e.typeParameters),s=at(n.to);return te(e,s===n.to?[n]:[new ie(s,n.transformation)])}return e}case"Objects":case"Arrays":return e.recur(t=>{const n=t.context?.defaultValue;return n?te(at(t),n):at(t)});case"Suspend":return e.recur(at);default:return e}});function vs(e){const t=at(zt(e.ast)),n=Ii(t);return(s,i)=>n(s,i?.disableChecks?i?.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions)}function $i(e){const t=vs(e);return(n,s)=>{const i=Qr(t(n,s));return as(i)?q(i.value):(ii(i.cause,"Option adapter can only return none for schema issues"),St())}}function gu(e){const t=vs(e);return(n,s)=>{const i=Qr(t(n,s));if(as(i))return i.value;const o=ii(i.cause,"Constructor adapter can only throw schema issues");throw new Error(o.toString(),{cause:o})}}function bu(e,t){const n=Ii(e.ast);return t===void 0?n:(s,i)=>n(s,yu(t,i))}const yu=(e,t)=>t===void 0?e:{...e,...t};function Ii(e){const t=Pt(e);return(n,s)=>Ie(t(q(n),s??ci),i=>i._tag==="None"?X(new Bt(i)):oe(i.value))}function Zs(e,t){return Zr(e,n=>Xr(()=>os(n,t)))}const Pt=Oe(e=>{let t;const n=e.checks,s=e.encoding,i=s,o=i?.length??0,a=e.encodingChecks,l=(n?n[n.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!s&&!n&&!a)return(h,f)=>(t??=e.getParser(Pt),l&&(f={...f,...l}),t(h,f));const c=Fl(e)||Ml(e)||Tl(e)&&e.typeParameters.length>0,u=n&&c?n.filter(h=>h.annotations?.[xu]):void 0;return(h,f)=>{l&&(f={...f,...l});let m;if(i){for(let v=o-1;v>=0;v--){const y=i[v],x=y.to,w=Pt(x);if(m=m?Ie(m,N=>w(N,f)):w(h,f),y.transformation._tag==="Transformation"){const N=y.transformation.decode;m=Ie(m,C=>N.run(C,f))}else m=y.transformation.decode(m,f)}m=Zs(m,v=>new gl(e,h,v))}t??=e.getParser(Pt);const g=v=>{let y=t(v,f);return a&&!f?.disableChecks&&(y=Ie(y,x=>{if(_t(v)&&_t(x)){const w=[];if(ft(a,v.value,w,e,f),gn(w))return X(new ee(e,v,w))}return oe(x)})),n&&!f?.disableChecks&&(f?.errors==="all"&&u&&u.length>0&&_t(v)&&(y=Zs(y,x=>{const w=[];return ft(u,v.value,w,e,f),gn(w)?x._tag==="Composite"&&x.ast===e?new ee(e,x.actual,[...x.issues,...w]):new ee(e,v,[x,...w]):x})),y=Ie(y,x=>{if(_t(x)){const w=x.value,N=[];if(ft(n,w,N,e,f),gn(N))return X(new ee(e,x,N))}return oe(x)})),y};return m?Ie(m,g):g(h)}}),Un="~effect/Schema/Schema",vu={[Un]:Un,pipe(){return Ee(this,arguments)},annotate(e){return this.rebuild(yi(this.ast,e))},annotateKey(e){return this.rebuild(wi(this.ast,e))},check(...e){return this.rebuild(Ht(this.ast,e))}};function _i(e,t){const n=Object.create(vu);return t&&Object.assign(n,t),n.ast=e,n.rebuild=s=>_i(s,t),n.makeEffect=(s,i)=>Ai(vs(n)(s,i)),n.make=gu(n),n.makeOption=$i(n),n}const Bn="~effect/Schema/SchemaError";class ku extends ll("SchemaError"){[Bn]=Bn;constructor(t){super({issue:t})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}function Ai(e){return Zr(e,t=>Xr(()=>os(t,n=>new ku(n))))}const ht=Un;function wu(e){return G(e,Bn)}function ju(e,t){const n=bu(e,t);return(s,i)=>Ai(n(s,i))}function Su(e,t){let n;for(const s of e.reasons){if(!Yr(s)||!wu(s.error))throw new globalThis.Error(t,{cause:e});n??=s.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function Nu(e){return fl(e).then(t=>{if(as(t))return t.value;throw Su(t.cause,"Promise adapter can only reject schema errors")})}function ze(e,t){const n=ju(e,t);return(s,i)=>Nu(n(s,i))}const Y=_i;function Cu(e){return G(e,ht)&&e[ht]===ht}const M=ys(e=>Y(ji(e.ast),{schema:e}));function Fe(e){const t=Y(new dt(e),{literal:e,transform(n){return t.pipe(ws(Fe(n),{decode:be(()=>n),encode:be(()=>e)}))}});return t}const Ti=Y(Bl),Eu=Y(Dl),d=Y(li),V=Y(ui),Z=Y(ql);function ks(e,t){return Y(e,{fields:t,mapFields(n,s){const i=n(this.fields);return ks(ms(i,s?.unsafePreserveChecks?this.ast.checks:void 0),i)}})}function se(e){return ks(ms(e,void 0),e)}function Ru(e,t,n){return Y(uu(e.ast,t.ast,void 0),{key:e,value:t})}function Oi(e,t){return Y(e,{elements:t,mapElements(n,s){const i=n(this.elements);return Oi(pi(i,s?.unsafePreserveChecks?this.ast.checks:void 0),i)}})}function Pi(e){return Oi(pi(e),e)}const I=ys(e=>Y(new sn(!1,[],[e.ast]),{value:e}));function Fi(e,t){return Y(e,{members:t,mapMembers(n,s){const i=n(this.members);return Fi(xs(i,this.ast.mode,s?.unsafePreserveChecks?this.ast.checks:void 0),i)}})}function wt(e,t){return Fi(xs(e,"anyOf",void 0),e)}function B(e){const t=e.map(Fe);return Y(xs(t,"anyOf",void 0),{literals:e,members:t,mapMembers(n){return wt(n(this.members))},pick(n){return B(n)},transform(n){return wt(t.map((s,i)=>s.transform(n[i])))}})}const T=ys(e=>wt([e,Eu]));function ws(e,t){return n=>Y(cu(n.ast,e.ast,t?Il(t):Al()),{from:n,to:e})}const $u=globalThis.Symbol.for("immer-draftable"),Qs={};function Mi(e,t,n,s,i){const o=_u(n,t,s),a=Li(t),l=class extends e{constructor(...[c,u]){const f=u?.["~payload"],m=f?.token===Qs?f.value:n.make(c??{},u);super(m,{...u,disableChecks:!0,"~payload":{token:Qs,value:m}})}static[ht]=ht;get[a](){return a}static[$u]=!0;static identifier=t;static fields=n.fields;static get ast(){return o(this).ast}static pipe(){return Ee(this,arguments)}static rebuild(c){return o(this).rebuild(c)}static make(c,u){return new this(c,u)}static makeOption(c,u){return $i(o(this))(c??{},u)}static makeEffect(c,u){return o(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(yi(this.ast,c))}static annotateKey(c){return this.rebuild(wi(this.ast,c))}static check(...c){return this.rebuild(Ht(this.ast,c))}static extend(c){return(u,h)=>{const f=Di(u)?u:se(u),m={...n.fields,...f.fields},g=ms(m,n.ast.checks,{identifier:c});return Mi(this,c,ks(Ht(g,f.ast.checks),m),h,i)}}static mapFields(c,u){return n.mapFields(c,u)}};return i!==void 0&&Object.assign(l.prototype,i(t)),l}function Iu(e){return new ye(be(t=>new e(t)),Fn())}function Li(e){return`~effect/Schema/Class/${e}`}function _u(e,t,n){let s;return i=>{if(s!==void 0)return s;const o=Iu(i),a=Y(new fs([e.ast],()=>(l,c)=>l instanceof i||G(l,Li(t))?oe(l):X(new Nt(c,q(l))),{identifier:t,[Ri]:([l])=>new ie(l,o),toCodec:([l])=>new ie(l.ast,o),toArbitrary:([l])=>()=>({arbitrary:l.arbitrary.map(c=>new i(c)),terminal:l.terminal?.map(c=>new i(c))}),toFormatter:([l])=>c=>`${i.identifier}(${l(c)})`,"~sentinels":gs(e.ast),...n}));return s=ws(a,o)(e)}}function Di(e){return Cu(e)}const E=e=>(t,n)=>{const s=Di(t)?t:se(t);return Mi(cl,e,s,n,i=>({toString(){return`${i}(${z({...this})})`}}))};class pt extends Error{_tag="RuntimeFetchError";path;status;constructor(t,n,s){super(n),this.name="RuntimeFetchError",this.path=t,this.status=s}}class Au extends Error{_tag="RuntimeDecodeError";path;constructor(t,n){super(n),this.name="RuntimeDecodeError",this.path=t}}const et=async(e,t)=>{let n;try{n=await fetch(ne(e),{headers:{accept:"application/json"}})}catch(i){throw new pt(e,`network error fetching ${e}: ${String(i)}`)}if(!n.ok)throw new pt(e,`${e} responded ${n.status}`,n.status);let s;try{s=await n.json()}catch(i){throw new pt(e,`${e} did not return valid JSON: ${String(i)}`)}try{return await ze(t)(s)}catch(i){throw new Au(e,`${e} response failed schema decode: ${String(i)}`)}},an=async(e,t)=>{let n;try{n=await fetch(ne(e),{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(t)})}catch(i){throw new pt(e,`network error posting to ${e}: ${String(i)}`)}let s;try{s=await n.json()}catch(i){throw new pt(e,`${e} did not return valid JSON: ${String(i)}`,n.status)}return{status:n.status,ok:n.ok,body:s}},js=B(["idea","researching","drafting","evaluating","published"]),Ui=B(["working","awaiting-review"]),Bi=B(["no-version","in-sync","design-changed","output-hand-edited","both"]);class Vi extends E("BundleRecord")({slug:d,name:d,oneLiner:d,tags:I(d),created:d,stage:js,substate:Ui,archived:Z,designHash:d,outputHash:d,drift:Bi,stageChangedAt:M(d)}){}class Wi extends E("VersionRecord")({bundle:d,hash:d,designHash:d,label:M(d),recordedAt:d,snapshot:M(Z)}){}class Rp extends E("BundlesResponse")({bundles:I(Vi),fixtureCounts:Ru(d,V)}){}class Tu extends E("FixtureRecord")({bundle:d,caseName:d,class:d,risks:I(d),hasPromptMd:Z}){}const Ou=B(["covered","partial","gap","n/a"]);class Pu extends E("RiskCoverageRecord")({bundle:d,riskId:d,family:d,description:M(d),coverage:Ou,fixtureCase:M(d)}){}class Fu extends E("WarningRecord")({bundle:M(d),source:d,message:d}){}const Ki=B(["running","completed","failed","infra-error"]),Mu=B(["pass","fail","partial"]);class Lu extends E("RunRecord")({id:d,bundle:d,fixtureCase:M(d),versionHash:d,provider:d,model:d,startedAt:d,endedAt:M(d),status:Ki,verdict:M(Mu),gradedAt:M(d)}){}class Du extends E("WorkspaceSummary")({path:d,name:d}){}class Uu extends E("ConfigSummary")({skillsDir:d,viewerPort:V,providers:I(d),publishTargets:I(se({id:d,kind:d}))}){}class Bu extends E("StateResponse")({workspace:Du,config:Uu}){}class $p extends E("HealthResponse")({ok:Z,version:d}){}const Ge=["idea","researching","drafting","evaluating","published"],Vu={idea:"Idea",researching:"Research",drafting:"Draft",evaluating:"Evals",published:"Publish"};class Wu extends E("GuardStatus")({stage:js,approvedForForward:Z,gateApproved:Z}){}class tt extends E("ActorView")({kind:B(["user","agent","process"]),name:d,provider:M(d)}){}class $t extends E("EventView")({id:d,type:d,at:d,actor:tt,payload:Ti}){}class qi extends E("MeasurementRecord")({bundle:d,fixtureCase:d,versionHash:d,provider:d,model:d,n:V,passes:V,partial:V,fail:V,passRate:V,ci:T(Pi([V,V]))}){}class Ku extends E("StationAvailability")({state:d,skill:d}){}class qu extends E("DossierContext")({name:d,body:d,upstream:M(d),downstream:M(d),hands:M(d)}){}class Ju extends E("DossierRecord")({job:M(d),contexts:I(qu),outOfScope:M(d),basis:M(d),evidence:M(d),fitCriterion:M(d)}){}class Hu extends E("LineageRecord")({custody:I($t),forkOf:T(d),forks:I(d),upstream:T(se({source:d,ref:T(d)}))}){}class zu extends E("BundleDetailResponse")({bundle:Vi,guardStatus:Wu,events:I($t),versions:I(Wi),fixtures:I(Tu),riskCoverage:I(Pu),warnings:I(Fu),runs:I(Lu),measurements:I(qi),station:T(Ku),dossier:Ju,lineage:Hu,files:I(d),instructionsPath:T(d),unverified:Z}){}class Gu extends E("FixtureGradingView")({answerKey:T(d),checks:I(d)}){}class Yu extends E("FixtureDetailResponse")({caseName:d,class:T(d),risks:I(d),context:T(d),promptMd:T(d),legacyPrompt:T(d),grading:T(Gu),warnings:I(d)}){}class Xu extends E("RunDetailRun")({id:d,bundle:d,fixtureCase:M(d),skillVersionHash:d,provider:d,model:d,startedAt:d,endedAt:M(d),status:Ki}){}class Ip extends E("RunDetailResponse")({run:Xu,transcript:I(Ti),artifacts:I(d),gradingHistory:I($t),checks:I(d)}){}class _p extends E("TriggerRunResponse")({runId:d,status:Fe("started")}){}class Ap extends E("TriggerStationRunResponse")({runId:d,status:Fe("started")}){}class Zu extends E("PostEventResponse")({status:B(["appended","already_appended"]),event:$t}){}class Tp extends E("RecordVersionResponse")({status:B(["appended","already_appended"]),hash:d,designHash:d,label:T(d)}){}class Qu extends E("CreateBundleResponse")({status:B(["created","already_exists"]),slug:d}){}class ed extends E("BundleFileResponse")({path:d,content:d}){}class Ss extends E("ApiErrorResponse")({error:d}){}const td=B(["task","bug","improvement","eval"]),Ji=B(["open","in-progress","done","wont-do"]);class nd extends E("ChecklistItemView")({text:d,done:Z}){}const Hi=se({kind:Fe("field-report"),eventId:d}),zi=se({kind:Fe("intake"),intakeId:d}),Gi=se({kind:Fe("run"),runId:d}),sd=wt([Hi,zi,Gi]),rd=wt([Hi,zi,Gi,se({kind:B(["field-report","intake"]),ref:d})]),id=rd.pipe(ws(sd,{decode:be(e=>"ref"in e?e.kind==="field-report"?{kind:"field-report",eventId:e.ref}:{kind:"intake",intakeId:e.ref}:e),encode:Cl()}));class od extends E("TodoRecord")({id:d,kind:td,status:Ji,title:d,detail:M(d),checklist:M(I(nd)),priority:V,bundle:M(d),created:d,terminalAt:M(d),pinned:M(Z),swept:Z,source:tt,origin:M(id)}){}class ad extends E("TodosResponse")({todos:I(od)}){}class Op extends E("EventsResponse")({events:I($t),nextCursor:T(d)}){}class cd extends E("CatalogEntry")({slug:d,name:d,oneLiner:d,tags:I(d),stage:js,substate:M(Ui),archived:Z,drift:Bi,latestVersion:T(se({hash:d,label:T(d),recordedAt:d})),fixtureCount:V,measuredFixtureCount:V,openTodoCount:V,unverified:Z,lastShipment:T(se({destination:d,versionHash:d,at:d})),lastActivityAt:d}){}class ld extends E("CatalogResponse")({entries:I(cd)}){}class ud extends E("SkillbookChangelogEntry")({type:B(["version","published","gate","shipped","reported"]),at:d,summary:d}){}class dd extends E("ShipReceipt")({fixtureCase:d,provider:d,model:d,n:V,passes:V,passRate:V,ci:T(Pi([V,V]))}){}class fd extends E("SkillbookShipment")({at:d,versionHash:d,destination:d,purpose:d,receipts:I(dd)}){}class hd extends E("SkillbookBundle")({slug:d,name:d,oneLiner:d,stage:d,designMarkdown:d,latestVersion:T(Wi),measurements:I(qi),changelog:I(ud),shipments:I(fd),inBook:Z}){}class Pp extends E("SkillbookResponse")({workspaceName:d,bundles:I(hd)}){}const pd=B(["worked","failed","surprise"]);class md extends E("FieldReportView")({id:d,bundle:d,outcome:pd,report:d,versionHash:T(d),destination:T(d),at:d,actor:tt,fixtureCase:T(d),todo:T(se({id:d,title:d,status:Ji}))}){}class Fp extends E("FieldReportsResponse")({reports:I(md)}){}const xd=B(["ours","licensed","unclear"]),gd=B(["return","new","conflict"]),Ns=B(["aside","load-bearing"]);class bd extends E("IntakeCrateView")({intake:d,source:d,ref:T(d),claimedName:T(d),claimedVersionHash:T(d),rights:T(xd),stakes:T(Ns),hurts:T(d),notes:T(d),at:d,actor:tt,verdict:gd}){}const yd=B(["return","new","upgrade","fork","salvage"]);class vd extends E("RecentlyRoutedView")({intake:d,disposition:yd,bundle:T(d),reason:d,claimedName:T(d),stakes:T(Ns),hurts:T(d),at:d,actor:tt,unverified:Z}){}class kd extends E("SalvagedCrateView")({intake:d,claimedName:T(d),bundle:T(d),reason:d,stakes:T(Ns),hurts:T(d),at:d,actor:tt}){}class Mp extends E("IntakeResponse")({crates:I(bd),recentlyRouted:I(vd),salvaged:I(kd)}){}class Lp extends E("PublishTarget")({id:d,kind:d,path:M(d)}){}class wd extends E("PublishTargetResult")({target:d,kind:d,status:B(["published","already_published"]),url:M(d)}){}class Dp extends E("PublishBundleResponse")({bundle:d,versionHash:d,results:I(wd)}){}const jd=()=>et("/api/state",Bu),Sd=e=>et(`/api/bundles/${encodeURIComponent(e)}`,zu),Nd=(e,t)=>et(`/api/bundles/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`,ed),Cd=(e,t)=>et(`/api/bundles/${encodeURIComponent(e)}/fixtures/${encodeURIComponent(t)}`,Yu),Ed=e=>et("/api/todos",ad),Rd=()=>et("/api/catalog",ld),Yi=e=>Ss.make({error:`request failed with status ${e}`}),cn=async e=>{const t=await an("/api/events",e);return t.ok?{ok:!0,response:await ze(Zu)(t.body)}:{ok:!1,error:(await ze(Ss)(t.body).catch(()=>Yi(t.status))).error}},$d=async(e,t)=>{const n=await an("/api/bundles",{slug:e});return n.ok?{ok:!0,response:await ze(Qu)(n.body)}:{ok:!1,error:(await ze(Ss)(n.body).catch(()=>Yi(n.status))).error}},Id=e=>{if(typeof e!="object"||e===null)return;const t=e;if(typeof t.id!="string"||t.id.length===0)return;const n=Array.isArray(t.efforts)?t.efforts.filter(s=>typeof s=="string"):[];return{id:t.id,label:typeof t.label=="string"&&t.label.length>0?t.label:t.id,...typeof t.description=="string"?{description:t.description}:{},efforts:n,...typeof t.defaultEffort=="string"?{defaultEffort:t.defaultEffort}:{}}},_d=e=>{if(typeof e!="object"||e===null)return;const t=e;if(typeof t.provider!="string"||t.provider.length===0)return;const n=Array.isArray(t.models)?t.models.map(Id).filter(s=>s!==void 0):[];return{provider:t.provider,title:typeof t.title=="string"&&t.title.length>0?t.title:t.provider,models:n,...typeof t.currentModelId=="string"?{currentModelId:t.currentModelId}:{},...typeof t.currentEffort=="string"?{currentEffort:t.currentEffort}:{},imageSupport:t.imageSupport!==!1,probed:t.probed===!0,...typeof t.note=="string"?{note:t.note}:{}}},Xi=async()=>{try{const e=await fetch("/api/chat/providers",{headers:{accept:"application/json"}});if(!e.ok)return null;const t=await e.json();return Array.isArray(t.providers)?t.providers.map(_d).filter(n=>n!==void 0):null}catch{return null}},er=e=>{if(typeof e!="object"||e===null)return;const t=e;if(!(typeof t.skill!="string"||!Array.isArray(t.providers)))return t};function Ad(e){const[t,n]=p.useState(!0),[s,i]=p.useState(void 0),[o,a]=p.useState([]),[l,c]=p.useState(void 0),[u,h]=p.useState(0);p.useEffect(()=>{let g=!1;return i(void 0),a([]),fetch(ne(`/api/chat/${encodeURIComponent(e)}/state`),{headers:{accept:"application/json"}}).then(async b=>{if(g)return;if(!b.ok){n(!1);return}const v=er(await b.json());if(v===void 0){n(!1);return}n(!0),i(v)}).catch(()=>{g||n(!1)}),()=>{g=!0}},[e]),p.useEffect(()=>{if(!t)return;const g=new EventSource(ne(`/api/chat/${encodeURIComponent(e)}/stream`)),b=()=>{a([])},v=y=>{let x;try{x=JSON.parse(String(y.data))}catch{return}if(typeof x=="object"&&x!==null&&x.type==="state"){const w=er(x.state);w!==void 0&&i(w);return}a(w=>[...w,x])};return g.addEventListener("open",b),g.addEventListener("message",v),()=>{g.removeEventListener("open",b),g.removeEventListener("message",v),g.close()}},[e,t,u]);const f=p.useCallback((g,b,v)=>{c(void 0),an(`/api/chat/${encodeURIComponent(e)}/${g}`,b).then(y=>{if(!y.ok){const x=y.body;c(typeof x?.error=="string"?x.error:`${g} failed (${y.status})`);return}v?.()}).catch(y=>c(String(y)))},[e]),m=p.useRef(f);return m.current=f,{available:t,state:s,events:o,actionError:l,start:p.useCallback((g,b,v)=>{m.current("session",{provider:g,mode:b,...v?.model!==void 0?{model:v.model}:{},...v?.effort!==void 0?{effort:v.effort}:{}},()=>h(y=>y+1))},[]),send:p.useCallback((g,b)=>{m.current("message",{text:g,...b!==void 0&&b.length>0?{images:b}:{}})},[]),setModel:p.useCallback((g,b)=>{m.current("model",{model:g,...b!==void 0?{effort:b}:{}})},[]),answerPermission:p.useCallback((g,b,v)=>{m.current("permission",{requestId:g,optionId:b,decision:v})},[]),cancelTurn:p.useCallback(()=>{m.current("cancel",{})},[])}}const Td=new Set(["a","an","the","this","that","these","those","it","its","i","we","you","me","us","my","our","your","and","or","but","so","if","then","than","as","to","of","in","on","at","by","for","from","with","into","onto","about","is","are","was","were","be","been","being","am","do","does","did","can","could","would","should","will","shall","may","might","must","want","wants","need","needs","like","help","please","let","lets","make","makes","create","creates","build","builds","write","writes","skill","skills","new","some","any","all","when","how","what","which","who","there"]),Od=5,tr=3,Pd=e=>e.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/[\s-]+/).filter(t=>t.length>0),Fd=e=>{const t=Pd(e);let s=t.filter(i=>!Td.has(i)).slice(0,Od);if(s.length<tr){const i=new Set(s);for(const o of t){if(s.length>=tr)break;i.has(o)||(i.add(o),s=[...s,o])}s=[...s].sort((o,a)=>t.indexOf(o)-t.indexOf(a))}return s.length===0?"new-skill":s.join("-")},Md=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},Ld=(e,t)=>Md(Fd(e),t),Dd=e=>{if(typeof e!="object"||e===null)return null;const t=e.candidates;if(!Array.isArray(t))return null;const n=[];for(const s of t){if(typeof s!="object"||s===null)continue;const{path:i,slug:o}=s;typeof i!="string"||i.length===0||n.push({path:i,slug:typeof o=="string"&&o.length>0?o:void 0})}return n},Ud=async()=>{try{const e=await fetch(ne("/api/adopt/candidates"),{headers:{accept:"application/json"}});return e.ok?Dd(await e.json()):null}catch{return null}},Bd=async()=>{try{return(await jd()).config.providers}catch{return null}},Vd=(e,t,n,s)=>{const i=s?.trim()??"";return n==="revise"&&i.length===0?{ok:!1,error:"Send back requires notes -- say what needs to change."}:{ok:!0,input:{type:"review.resolved",payload:{bundle:e,state:t,decision:n,...i.length>0?{notes:i}:{}}}}},Zi=e=>Ge[Ge.indexOf(e)+1],Wd=(e,t)=>{const n=Zi(t);return n===void 0?{ok:!1,error:`"${t}" is the last stage -- there is nowhere to advance to.`}:{ok:!0,input:{type:"bundle.stage_changed",payload:{bundle:e,from:t,to:n}}}},Kd=(e,t,n,s)=>{if(Ge.indexOf(n)>=Ge.indexOf(t))return{ok:!1,error:`"${n}" is not earlier than "${t}" -- moving back requires an earlier stage.`};const i=s.trim();return i.length===0?{ok:!1,error:"Moving to an earlier stage requires a reason."}:{ok:!0,input:{type:"bundle.stage_changed",payload:{bundle:e,from:t,to:n,reason:i}}}},Cs=async e=>{if(!e.ok)return e;const t=await cn(e.input);return t.ok?{ok:!0}:{ok:!1,error:t.error}},Qi=(e,t,n,s)=>Cs(Vd(e,t,n,s)),eo=(e,t)=>Cs(Wd(e,t)),qd=(e,t,n,s)=>Cs(Kd(e,t,n,s)),Jd=async(e,t)=>{const n=e.trim();if(n.length===0)return{ok:!1,error:"A slug is required."};const s=await $d(n);return s.ok?s.response.status==="already_exists"?{ok:!1,error:`A skill named "${s.response.slug}" already exists.`}:{ok:!0,slug:s.response.slug}:{ok:!1,error:s.error}};class Hd extends E("AdoptedEntry")({slug:d,path:d,warnings:I(d)}){}class zd extends E("AdoptReport")({found:V,adopted:I(Hd),skipped:I(se({relativePath:d})),challenged:I(se({path:d})),warnings:I(d)}){}const Gd=async e=>{const t=e.trim();if(t.length===0)return{ok:!1,error:"A project-relative path is required."};const n=await an("/api/adopt",{path:t});if(!n.ok){const i=n.body;return{ok:!1,error:typeof i?.error=="string"?i.error:`adopt failed with status ${n.status}`}}let s;try{s=await ze(zd)(n.body)}catch(i){return{ok:!1,error:`adopt response failed schema decode: ${String(i)}`}}return s.adopted.length===0?{ok:!1,error:Yd(s)}:{ok:!0,report:s}},Yd=e=>e.found===0?"No SKILL.md found at that path.":e.skipped.length>0&&e.challenged.length===0?"That skill is already adopted.":e.challenged.length>0?"That skill looks like an arrival from elsewhere -- route it via `skillmaker receive` instead of adopting.":"Nothing was adopted.",Vn="::",vn=(e,t)=>`${e}${Vn}${t??""}`,Xd=e=>{const t=e.indexOf(Vn);if(t===-1)return{provider:e};const n=e.slice(t+Vn.length);return{provider:e.slice(0,t),...n.length>0?{model:n}:{}}},Zd=e=>e.charAt(0).toUpperCase()+e.slice(1),Qd=(e,t)=>{const n=e?.find(i=>i.provider===t.provider),s=t.model!==void 0?n?.models.find(i=>i.id===t.model):void 0;return{...n!==void 0?{entry:n}:{},...s!==void 0?{model:s}:{}}},ef=(e,t)=>{const n=e?.find(s=>s.provider===t);return n===void 0?!0:n.imageSupport},to=(e,t)=>{const n=e?.find(i=>i.models.length>0)??e?.[0];if(n!==void 0){const i=n.models.find(o=>o.id===n.currentModelId)??n.models[0];return{provider:n.provider,...i!==void 0?{model:i.id}:{},...i?.defaultEffort!==void 0?{effort:i.defaultEffort}:{}}}const s=t[0];return s!==void 0?{provider:s}:void 0},nr="cursor-pointer truncate bg-transparent text-xs text-ink-muted outline-none hover:text-ink disabled:cursor-default disabled:opacity-60";function no({catalog:e,providers:t,selection:n,onChange:s,disabled:i=!1,lockProvider:o}){const a=e!==null&&e.length>0?e:t.map(f=>({provider:f,title:f,models:[],imageSupport:!0,probed:!1})),{model:l}=Qd(e,n),c=l?.efforts??[],u=n.effort??l?.defaultEffort??c[0]??"",h=f=>{const{provider:m,model:g}=Xd(f),b=e?.find(y=>y.provider===m),v=g!==void 0?b?.models.find(y=>y.id===g):void 0;s({provider:m,...g!==void 0?{model:g}:{},...v?.defaultEffort!==void 0?{effort:v.defaultEffort}:{}})};return r.jsxs(r.Fragment,{children:[c.length>0&&r.jsx("select",{className:`max-w-[28%] ${nr}`,value:u,disabled:i,title:"Reasoning effort for this model",onChange:f=>s({...n,effort:f.target.value}),children:c.map(f=>r.jsx("option",{value:f,children:Zd(f)},f))}),r.jsx("select",{className:`max-w-[45%] ${nr}`,value:vn(n.provider,n.model),disabled:i,title:"Model for the session (grouped by agent; picking a model picks its agent)",onChange:f=>h(f.target.value),children:a.map(f=>f.models.length>0?r.jsx("optgroup",{label:f.title,children:f.models.map(m=>r.jsx("option",{value:vn(f.provider,m.id),disabled:o!==void 0&&f.provider!==o,title:m.description,children:m.label},m.id))},f.provider):r.jsx("option",{value:vn(f.provider,void 0),disabled:o!==void 0&&f.provider!==o,title:f.note!==void 0?`${f.title}: ${f.note}`:f.title,children:f.title},f.provider))})]})}const re="overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,black_calc(100%_-_20px),transparent_calc(100%_-_2px))]",Es={Idea:"bg-neutral-200 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300",Research:"bg-sky-100 text-sky-800",Drafting:"bg-indigo-100 text-indigo-800",Evals:"bg-amber-100 text-amber-800",Published:"bg-emerald-100 text-emerald-800"},tf={proven:"●",partial:"◐",unmeasured:"◌",gap:"○"};function nf({stage:e}){return r.jsx("span",{className:`shrink-0 rounded px-1.5 text-[10px] ${Es[e]}`,children:e})}function Q({label:e,primary:t,onClick:n,title:s,disabled:i}){return r.jsx("button",{type:"button",title:s,onClick:n,disabled:i,className:t?"rounded bg-amber-600 px-3 py-1.5 font-display text-sm text-white shadow hover:bg-amber-700 disabled:cursor-default disabled:bg-amber-600/50 disabled:hover:bg-amber-600/50":"rounded border border-border bg-surface px-3 py-1.5 font-display text-sm text-ink-muted hover:text-ink disabled:cursor-default disabled:opacity-60 disabled:hover:text-ink-muted",children:e})}function Ue({active:e,onClick:t,title:n,children:s,className:i="",...o}){return r.jsx("button",{type:"button",title:n,onClick:t,className:`rounded p-1.5 ${e?"bg-surface text-ink shadow-sm":"text-ink-muted hover:bg-surface hover:text-ink"} ${i}`,...o,children:s})}const sr=10;function sf({project:e,onCreated:t,onAdopted:n}){const[s,i]=p.useState(""),[o,a]=p.useState(void 0),[l,c]=p.useState(null),[u,h]=p.useState(null),[f,m]=p.useState([]),[g,b]=p.useState(!1),[v,y]=p.useState(new Set),[x,w]=p.useState(!1),[N,C]=p.useState(null),R=o===null,F=!R&&o!==void 0&&!x&&s.trim().length>0,A=u??to(l,o??[])??void 0;p.useEffect(()=>{let j=!1;return Bd().then(P=>{j||a(P)}),Xi().then(P=>{j||c(P)}),Ud().then(P=>{!j&&P!==null&&m(P)}),Rd().then(P=>{j||y(new Set(P.entries.map(D=>D.slug)))},()=>{}),()=>{j=!0}},[]);const K=async()=>{const j=s.trim();if(j.length===0||x||R||o===void 0)return;const P=A?.provider??o[0]??"claude-code";w(!0),C(null);const D=Ld(j,v),S=await Jd(D);if(!S.ok){w(!1),C(S.error);return}t(S.slug,P,j,A?.model,A?.effort)},k=async j=>{if(x||R)return;w(!0),C(null);const P=await Gd(j.path);if(!P.ok){w(!1),C(P.error);return}const D=P.report.adopted[0]?.slug;if(D===void 0){w(!1),C("Nothing was adopted.");return}n(D)};return r.jsx("div",{className:"flex min-h-full justify-center p-6",children:r.jsxs("div",{className:"w-full max-w-xl pt-[18vh]",children:[r.jsx("h1",{className:"pb-4 text-center font-display text-xl",children:"What skill would you like to create? Tell us about it."}),r.jsxs("div",{className:"rounded-xl border border-border bg-surface/95 shadow-lg focus-within:border-amber-300",children:[r.jsx("textarea",{className:"max-h-64 w-full resize-none bg-transparent px-4 pb-1.5 pt-3.5 text-sm outline-none disabled:opacity-60",rows:3,placeholder:R?"Start the server to create skills":"A skill that…",value:s,disabled:R||x,autoFocus:!0,onChange:j=>{i(j.target.value),j.target.style.height="auto",j.target.style.height=`${j.target.scrollHeight}px`},onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),K())}}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 pb-3",children:[A!==void 0?r.jsx(no,{catalog:l,providers:o??[],selection:A,onChange:h,disabled:R||x}):r.jsx("select",{className:"max-w-[45%] cursor-default truncate bg-transparent text-xs text-ink-muted outline-none",value:"",disabled:!0,title:"Model for the new skill's session",children:r.jsx("option",{value:"",children:"model"})}),r.jsx("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-600 text-white shadow hover:bg-amber-700 disabled:opacity-35",title:"Create the skill and start the conversation",disabled:!F,onClick:()=>void K(),children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[r.jsx("line",{x1:"8",y1:"13",x2:"8",y2:"3.5"}),r.jsx("path",{d:"M4 7.5L8 3.5l4 4"})]})})]})]}),R&&r.jsx("p",{className:"pt-3 text-center text-xs text-ink-muted",children:"The studio server isn't running — creating and importing skills needs it."}),N!==null&&r.jsx("p",{className:"pt-3 text-center text-xs text-red-600",children:N}),f.length>0&&r.jsxs("section",{className:"pt-6",children:[r.jsx("h2",{className:"pb-2 text-xs uppercase tracking-widest text-ink-muted",children:"Import one of these?"}),r.jsx("div",{className:"space-y-1.5",children:(g?f:f.slice(0,sr)).map(j=>r.jsxs("button",{type:"button",disabled:x||R,onClick:()=>void k(j),className:"flex w-full items-center gap-2 rounded border border-border bg-surface px-3 py-2 text-left text-sm shadow-sm hover:shadow disabled:opacity-60",title:`Import ${j.path} into ${e}`,children:[r.jsx("span",{className:`min-w-0 flex-1 ${re}`,children:j.path}),j.slug!==void 0&&r.jsxs("span",{className:"shrink-0 text-xs text-ink-muted",children:["→ ",j.slug]})]},j.path))}),!g&&f.length>sr&&r.jsxs("button",{type:"button",className:"mt-2 cursor-pointer text-xs text-ink-muted underline-offset-2 hover:text-ink hover:underline",onClick:()=>b(!0),children:["Show all ",f.length]})]})]})})}const rf=e=>/\.(md|markdown)$/i.test(e),of=e=>{const t=e.trim();if(t.length===0)return;const n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(t);if(n===null)return t;const s=(n[1]??"").toLowerCase();return s==="http"||s==="https"||s==="mailto"?t:void 0},rr=(e,t,n)=>{let s=e.indexOf(t,n);for(;s>0&&e[s-1]==="\\";)s=e.indexOf(t,s+1);return s},pe=e=>{const t=[];let n="";const s=()=>{n.length>0&&(t.push({kind:"text",text:n}),n="")};let i=0;for(;i<e.length;){const o=e[i]??"";if(o==="`"){const a=e.indexOf("`",i+1);if(a!==-1){s(),t.push({kind:"code",text:e.slice(i+1,a)}),i=a+1;continue}}if(o==="["){const a=/^\[([^\]]*)\]\(((?:[^()\s]|\([^()\s]*\))*)(?:\s+"[^"]*")?\)/.exec(e.slice(i));if(a!==null){const l=a[1]??"",c=a[2]??"",u=of(c);s(),u!==void 0?t.push({kind:"link",href:u,children:pe(l)}):t.push({kind:"text",text:l}),i+=a[0].length;continue}}if(e.startsWith("**",i)){const a=rr(e,"**",i+2);if(a!==-1&&a>i+2){s(),t.push({kind:"strong",children:pe(e.slice(i+2,a))}),i=a+2;continue}}if(o==="*"){const a=rr(e,"*",i+1);if(a!==-1&&a>i+1){s(),t.push({kind:"em",children:pe(e.slice(i+1,a))}),i=a+1;continue}}n+=o,i+=1}return s(),t},af=/^\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/,ir=/^---\s*$/,cf=e=>{let t=e.split(`
|
|
21
|
+
`);if(ir.test(t[0]??"")){const o=t.findIndex((a,l)=>l>0&&ir.test(a));o!==-1&&(t=t.slice(o+1))}const n=[];let s=!1,i=!1;for(const o of t){if(!i&&o.trim().startsWith("```")){s=!s,n.push(o);continue}if(s){n.push(o);continue}let a=o,l="";for(;a.length>0;)if(i){const c=a.indexOf("-->");c===-1?a="":(a=a.slice(c+3),i=!1)}else{const c=a.indexOf("<!--");c===-1?(l+=a,a=""):(l+=a.slice(0,c),a=a.slice(c+4),i=!0)}(l.length>0||o.trim().length===0)&&n.push(l)}return n.join(`
|
|
22
|
+
`)},or=e=>{let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())},lf=e=>{const t=cf(e).split(`
|
|
23
|
+
`),n=[];let s=!1,i,o=[],a=[],l=!1,c=[],u=[];const h=()=>{c.length>0&&(n.push({kind:"paragraph",children:pe(c.join(" "))}),c=[])},f=()=>{a.length>0&&(n.push({kind:"list",ordered:l,items:a}),a=[])},m=()=>{u.length>0&&(n.push({kind:"blockquote",children:pe(u.join(" "))}),u=[])},g=()=>{h(),f(),m()};let b=0;for(;b<t.length;){const v=t[b]??"";if(v.trim().startsWith("```")){if(s)n.push({kind:"code",text:o.join(`
|
|
24
|
+
`),lang:i}),o=[],i=void 0,s=!1;else{g();const C=v.trim().slice(3).trim();i=C.length>0?C:void 0,s=!0}b+=1;continue}if(s){o.push(v),b+=1;continue}const y=/^(#{1,6})\s+(.*)$/.exec(v);if(y!==null){g();const C=Math.min(6,Math.max(1,(y[1]??"#").length));n.push({kind:"heading",level:C,children:pe(y[2]??"")}),b+=1;continue}if(v.trim().startsWith("|")&&af.test((t[b+1]??"").trim())){g();const C=or(v).map(pe),R=[];let F=b+2;for(;F<t.length&&(t[F]??"").trim().startsWith("|");)R.push(or(t[F]??"").map(pe)),F+=1;n.push({kind:"table",header:C,rows:R}),b=F;continue}const x=/^>\s?(.*)$/.exec(v.trim());if(x!==null){h(),f(),u.push(x[1]??""),b+=1;continue}const w=/^\s*[-*+]\s+(.*)$/.exec(v),N=/^\s*\d+[.)]\s+(.*)$/.exec(v);if(w!==null||N!==null){h(),m();const C=w===null;a.length>0&&C!==l&&f(),l=C,a.push(pe(w?.[1]??N?.[1]??"")),b+=1;continue}if(v.trim().length===0){g(),b+=1;continue}f(),m(),c.push(v.trim()),b+=1}return s&&n.push({kind:"code",text:o.join(`
|
|
25
|
+
`),lang:i}),g(),n},me=({nodes:e})=>r.jsx(r.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"text":return r.jsx("span",{children:t.text},n);case"code":return r.jsx("code",{className:"rounded bg-neutral-100 px-1 font-mono text-[0.9em] dark:bg-neutral-900",children:t.text},n);case"strong":return r.jsx("strong",{className:"font-semibold",children:r.jsx(me,{nodes:t.children})},n);case"em":return r.jsx("em",{children:r.jsx(me,{nodes:t.children})},n);case"link":return r.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"text-sky-700 underline decoration-dotted underline-offset-2 hover:decoration-solid dark:text-sky-300",children:r.jsx(me,{nodes:t.children})},n)}})}),uf={1:"text-base font-semibold text-neutral-900 dark:text-neutral-100",2:"text-sm font-semibold text-neutral-900 dark:text-neutral-100",3:"text-sm font-semibold text-neutral-800 dark:text-neutral-200",4:"text-xs font-semibold text-neutral-800 dark:text-neutral-200",5:"text-xs font-semibold text-neutral-700 dark:text-neutral-300",6:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400"},df=({block:e})=>{switch(e.kind){case"heading":{const t=`h${e.level}`;return r.jsx(t,{className:uf[e.level],children:r.jsx(me,{nodes:e.children})})}case"paragraph":return r.jsx("p",{className:"text-neutral-700 dark:text-neutral-300",children:r.jsx(me,{nodes:e.children})});case"list":{const t=e.items.map((n,s)=>r.jsx("li",{children:r.jsx(me,{nodes:n})},s));return e.ordered?r.jsx("ol",{className:"list-decimal pl-5 text-neutral-700 dark:text-neutral-300",children:t}):r.jsx("ul",{className:"list-disc pl-5 text-neutral-700 dark:text-neutral-300",children:t})}case"code":return r.jsx("pre",{className:"overflow-x-auto rounded-md bg-neutral-100 p-2 font-mono text-[0.9em] dark:bg-neutral-900",children:r.jsx("code",{children:e.text})});case"table":return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"border-collapse text-left",children:[r.jsx("thead",{children:r.jsx("tr",{children:e.header.map((t,n)=>r.jsx("th",{className:"border border-neutral-200 px-2 py-1 font-semibold text-neutral-800 dark:border-neutral-800 dark:text-neutral-200",children:r.jsx(me,{nodes:t})},n))})}),r.jsx("tbody",{children:e.rows.map((t,n)=>r.jsx("tr",{children:t.map((s,i)=>r.jsx("td",{className:"border border-neutral-200 px-2 py-1 text-neutral-700 dark:border-neutral-800 dark:text-neutral-300",children:r.jsx(me,{nodes:s})},i))},n))})]})});case"blockquote":return r.jsx("blockquote",{className:"border-l-2 border-neutral-300 pl-3 text-neutral-600 dark:border-neutral-700 dark:text-neutral-400",children:r.jsx(me,{nodes:e.children})})}},ln=({markdown:e,className:t})=>r.jsx("div",{className:t??"flex flex-col gap-2 text-[13px] leading-relaxed",children:lf(e).map((n,s)=>r.jsx(df,{block:n},s))}),so=({path:e,content:t,preClassName:n,renderedClassName:s})=>{const[i,o]=p.useState(!1);return rf(e)?r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"flex justify-end",children:r.jsx("button",{type:"button",onClick:()=>o(l=>!l),"aria-pressed":i,className:"rounded-md border border-neutral-300 px-2 py-0.5 font-mono text-[10px] text-neutral-600 hover:border-neutral-500 dark:border-neutral-700 dark:text-neutral-300",children:i?"Rendered":"Raw"})}),i?r.jsx("pre",{className:n,children:t.length>0?t:"(empty)"}):r.jsx("div",{className:s??"max-h-96 overflow-auto rounded-md border border-neutral-200 p-3 dark:border-neutral-800",children:t.length>0?r.jsx(ln,{markdown:t}):r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"(empty)"})})]}):r.jsx("pre",{className:n,children:t.length>0?t:"(empty)"})},ro=["Idea","Research","Drafting","Evals","Published"],ar={idea:"Idea",researching:"Research",drafting:"Drafting",evaluating:"Evals",published:"Published"},ff=e=>typeof e=="string"&&ro.includes(e),hf=e=>typeof e=="string"&&e in ar?ar[e]:ff(e)?e:"Idea",pf=e=>{if(typeof e!="object"||e===null)return null;const t=e;return typeof t.slug!="string"||t.slug.length===0?null:{slug:t.slug,stage:hf(t.stage),oneLiner:typeof t.oneLiner=="string"?t.oneLiner:"",awaitingReview:t.substate==="awaiting-review"}},mf=e=>{if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.name!="string"||t.name.length===0||typeof t.path!="string")return null;const n=Array.isArray(t.skills)?t.skills.map(pf).filter(s=>s!==null):[];return{slug:typeof t.slug=="string"&&t.slug.length>0?t.slug:t.name,name:t.name,path:t.path,skills:n,ok:t.ok!==!1,...typeof t.error=="string"?{error:t.error}:{}}},xf=e=>{if(typeof e!="object"||e===null)return null;const t=e.projects;return Array.isArray(t)?t.map(mf).filter(n=>n!==null):null},io=async()=>{try{const e=await fetch("/api/projects",{headers:{accept:"application/json"}});return e.ok?xf(await e.json()):null}catch{return null}},cr=async e=>{try{const t=e===void 0?"":`?path=${encodeURIComponent(e)}`,n=await fetch(`/api/fs/list${t}`,{headers:{accept:"application/json"}});if(!n.ok)return null;const s=await n.json();return typeof s.path!="string"||!Array.isArray(s.dirs)?null:{path:s.path,parent:typeof s.parent=="string"?s.parent:null,home:typeof s.home=="string"?s.home:"/",isProject:s.isProject===!0,dirs:s.dirs.filter(i=>typeof i=="object"&&i!==null&&typeof i.name=="string"&&typeof i.path=="string")}}catch{return null}},gf=async e=>{try{const t=await fetch(`/api/fs/validate?path=${encodeURIComponent(e)}`,{headers:{accept:"application/json"}});if(!t.ok)return null;const n=await t.json();return typeof n.path!="string"?null:{...n,path:n.path,valid:n.valid===!0}}catch{return null}},bf=async e=>{try{const t=await fetch("/api/fs/mkdir",{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({path:e})});if(t.ok)return null;const n=await t.json();return typeof n.error=="string"?n.error:`mkdir failed (${t.status})`}catch(t){return String(t)}},yf=async(e,t={})=>{try{const n=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({path:e,...t})}),s=await n.json();return n.ok?{kind:"registered",slug:typeof s.project?.slug=="string"?s.project.slug:null,initialized:s.initialized===!0}:s.status==="needs_init"?{kind:"needs_init"}:{kind:"error",message:typeof s.error=="string"?s.error:`register failed (${n.status})`}}catch(n){return{kind:"error",message:String(n)}}},vf=400,kf=2e3,wf=1e3,jf=3e4,Sf=(e,{debounceMs:t=vf,maxWaitMs:n=kf}={},s={setTimeout:(i,o)=>globalThis.setTimeout(i,o),clearTimeout:i=>globalThis.clearTimeout(i)})=>{let i,o;const a=()=>{i!==void 0&&(s.clearTimeout(i),i=void 0),o!==void 0&&(s.clearTimeout(o),o=void 0)},l=()=>{a(),e()};return{signal:()=>{i!==void 0&&s.clearTimeout(i),i=s.setTimeout(l,t),o===void 0&&(o=s.setTimeout(l,n))},cancel:a}},Nf=e=>Math.min(wf*2**Math.max(0,Math.min(e,30)),jf),Be=new Set;let Ke,jt,Ft,ct=0;const Cf=()=>{for(const e of[...Be])e()},oo=()=>{if(typeof EventSource>"u")return;const e=new EventSource("/api/events-stream");Ke=e,e.onopen=()=>{const t=ct>0;ct=0,t&&jt?.signal()},e.onmessage=t=>{try{const n=JSON.parse(String(t.data)),s=Jn();if(typeof n.project=="string"&&s!==null&&n.project!==s)return}catch{}jt?.signal()},e.onerror=()=>{if(e.close(),Ke!==e||(Ke=void 0,Be.size===0))return;const t=Nf(ct);ct+=1,Ft=setTimeout(oo,t)}},Ef=()=>{if(Ft!==void 0&&(clearTimeout(Ft),Ft=void 0),Ke!==void 0){const e=Ke;Ke=void 0,e.onerror=null,e.close()}jt?.cancel(),jt=void 0,ct=0},ao=e=>(Be.add(e),Be.size===1&&(jt=Sf(Cf),oo()),()=>{Be.delete(e),Be.size===0&&Ef()}),co=()=>{const[e,t]=p.useState(0);return p.useEffect(()=>ao(()=>t(n=>n+1)),[]),e},kn=e=>{const t=e.indexOf("·");return t===-1?e:e.slice(0,t).trim()},lo=e=>typeof e=="object"&&e!==null,mt=(e,t)=>{if(!lo(e))return;const n=e[t];return typeof n=="string"?n:void 0},Rf=(e,t)=>{if(!lo(e))return[];const n=e[t];return Array.isArray(n)?n.filter(s=>typeof s=="string"):[]},Tt=e=>Vu[e]??e,$f=(e,t)=>{for(const n of e){if(n.type==="review.resolved")return;if(n.type!=="review.requested")continue;const s=mt(n.payload,"state"),i=s===void 0?"Review the submitted work":`Review the ${Tt(s)}-stage work`,o=s!==void 0&&s!==t?`This review was requested by the ${Tt(s)} station; this skill has since moved to ${Tt(t)}. No ${Tt(t)}-stage work exists to approve yet.`:void 0;return{requestedState:s,title:i,staleNote:o,question:mt(n.payload,"question"),artifacts:Rf(n.payload,"artifacts")}}},If=(e,t)=>{for(const n of e){if(n.type!=="review.resolved"||mt(n.payload,"state")!==t)continue;const s=mt(n.payload,"decision");if(s!=="approve"&&s!=="revise")continue;const i=mt(n.payload,"notes");return{decision:s,headline:s==="approve"?"Approved":"Sent back",at:n.at,notes:i,nextStep:s==="revise"?"Notes were recorded and will be given to the agent on the next station run.":i!==void 0?"Approval recorded; the notes are kept in the journal for the record.":"Approval recorded — this stage can move forward."}}},_f=(e,t,n)=>{const s=t.filter(i=>i.risks.includes(e)).map(i=>i.caseName);return n!==void 0&&!s.includes(n)?[...s,n]:s},Af=(e,t)=>{const n=new Set(t);return e.filter(s=>!s.risks.some(i=>n.has(i))).map(s=>s.caseName)},Tf=e=>[...new Set(e.map(t=>t.model))].sort(),Of=e=>{const t=new Set(e.fixtureCases),n=e.measurements.filter(s=>t.has(s.fixtureCase));return e.models.map(s=>{const i=n.filter(l=>l.model===s),o=e.scope==="all"?i:e.latestVersionHash===null?[]:i.filter(l=>l.versionHash===e.latestVersionHash),a=o.some(l=>l.passes>0)?"proven":o.some(l=>l.n>0)?"failing":i.some(l=>l.n>0)?"stale":"unmeasured";return{model:s,status:a}})},Pf=(e,t)=>e==="gap"||e==="partial"?e:t.some(n=>n.status==="proven")?"proven":"unmeasured",lr=(e,t)=>e.filter(n=>n.fixtureCase===t).slice().sort((n,s)=>s.startedAt.localeCompare(n.startedAt)),ur=72,Ff=e=>{const t=e.sentence.trim(),n=t.length>ur?`${t.slice(0,ur-1).trimEnd()}…`:t;return{todo:{id:e.id,kind:"eval",status:"open",title:`Cover ${e.riskId}: ${n}`,detail:`Coverage gap: no fixture covers ${e.riskId}.`,priority:15,bundle:e.bundle,created:e.created,source:{kind:"user",name:"viewer"}}}},Mf=e=>{const t=e.promptMd??e.legacyPrompt??e.context;if(t===null)return null;const n=t.split(`
|
|
26
|
+
`).map(s=>s.trim()).find(s=>s.length>0&&!s.startsWith("#"));return n===void 0?null:n.length>160?`${n.slice(0,159).trimEnd()}…`:n},Lf=e=>{const t=[],n=new Map;for(const s of e){const i=n.get(s.family);i===void 0?(t.push(s.family),n.set(s.family,[s])):i.push(s)}return t.map(s=>({family:s,claims:n.get(s)??[]}))},Df=(e,t)=>e!==null?`running ${Math.min(e.completed+1,e.total)} of ${e.total}…`:t>0?"running…":"Run all fixtures",uo={idea:"Idea",researching:"Research",drafting:"Drafting",evaluating:"Evals",published:"Published"},Uf=e=>{const t=e.bundle!==void 0?` · ${e.bundle}`:"";switch(e.origin?.kind){case"run":return`run${t}`;case"field-report":return`report${t}`;case"intake":return`intake${t}`;case void 0:return e.kind==="eval"?`gap${t}`:"human"}},Bf=e=>e.status==="open"||e.status==="in-progress"?{title:e.title,origin:Uf(e),state:e.status}:void 0,Vf=e=>e.flatMap(t=>{const n=Bf(t);return n===void 0?[]:[n]}),Wf=async()=>{const e=await io();if(e===null)throw new Error("projects unavailable");return e},fo=async()=>{const e=await Ed();return Vf(e.todos)},Kf=e=>e==="idea"||e==="researching"||e==="drafting"||e==="evaluating"||e==="published"?e:void 0,qf=e=>{const t=$f(e.events,e.bundle.stage),n=If(e.events,e.bundle.stage);return{slug:e.bundle.slug,stage:e.bundle.stage,substate:e.bundle.substate,approvedForForward:e.guardStatus.approvedForForward,gateApproved:e.guardStatus.gateApproved,pending:t===void 0?void 0:{requestedState:Kf(t.requestedState),question:t.question,artifacts:t.artifacts},outcome:n===void 0?void 0:{decision:n.decision,at:n.at,notes:n.notes}}},Jf={IN:"Input",RE:"Reasoning",OUT:"Output",ADV:"Adversarial",CHN:"Chain"},Hf=async e=>{const t=await Sd(e),n=t.instructionsPath===null?null:await Nd(e,t.instructionsPath).then(c=>c.content,()=>null),s=new Set(t.measurements.filter(c=>c.passes>0).map(c=>c.fixtureCase)),i=t.riskCoverage.map(c=>{const u=_f(c.riskId,t.fixtures,c.fixtureCase),h=c.coverage==="gap"?"gap":c.coverage==="partial"?"partial":u.some(f=>s.has(f))?"proven":"unmeasured";return{id:c.riskId,family:Jf[c.family]??c.family,sentence:c.description!==void 0&&c.description.length>0?c.description:"(no description)",status:h,fixtures:u.length,fixtureCases:u}}),o=t.versions.at(-1),a=[...new Set(t.measurements.filter(c=>c.passes>0).map(c=>kn(c.model)))],l=t.riskCoverage.filter(c=>c.coverage!=="gap").length;return{name:t.bundle.name.length>0?t.bundle.name:t.bundle.slug,oneLiner:t.bundle.oneLiner,versions:[...t.versions].map(c=>({hash:c.hash,shortHash:c.hash.replace(/^sha256:/,"").slice(0,8),label:c.label??null,recordedAt:c.recordedAt})).reverse(),loop:qf(t),instructions:n,stage:uo[t.bundle.stage],versionShort:o===void 0?null:o.hash.replace(/^sha256:/,"").slice(0,8),drift:t.bundle.drift.replace(/-/g," "),provenOn:a.length===0?"none yet":a.join(", "),coverage:`${l} of ${t.riskCoverage.length} claims`,claims:i,evals:{slug:e,latestVersionHash:o?.hash??null,runs:t.runs.map(c=>({id:c.id,fixtureCase:c.fixtureCase??null,versionHash:c.versionHash,provider:c.provider,model:kn(c.model),startedAt:c.startedAt,status:c.status,verdict:c.verdict??null})),measurements:t.measurements.map(c=>({fixtureCase:c.fixtureCase,versionHash:c.versionHash,model:kn(c.model),n:c.n,passes:c.passes})),unclaimed:Af(t.fixtures,t.riskCoverage.map(c=>c.riskId))},events:t.events.slice(0,5).map(c=>({type:c.type,at:new Date(c.at).toLocaleDateString(void 0,{month:"short",day:"numeric"})}))}},zf=async e=>{const t=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/files`));if(!t.ok)throw new Error(`files: ${t.status}`);return((await t.json()).files??[]).filter(s=>typeof s.path=="string"&&typeof s.size=="number").filter(s=>!s.path.endsWith("/.gitkeep"))},Rs=async(e,t)=>{const n=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`));if(!n.ok)throw new Error(`file: ${n.status}`);const s=await n.json();if(typeof s.content!="string")throw new Error("file: malformed response");return s.content},Gf=async(e,t)=>{const n=await Cd(e,t);return{summary:Mf(n),hasAnswerKey:n.grading!==null&&n.grading.answerKey!==null&&n.grading.answerKey.trim().length>0,checkCount:n.grading?.checks.length??0,fixtureClass:n.class}},Yf=async(e,t)=>{const n=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/runs/${encodeURIComponent(t)}`));if(!n.ok)throw new Error(`run: ${n.status}`);const s=await n.json();return{skillInvoked:typeof s.skillInvoked=="boolean"?s.skillInvoked:null,artifacts:Array.isArray(s.artifacts)?s.artifacts.filter(i=>typeof i=="string"):[]}};function Xf(e){const t=co(),n=Hn(),[s,i]=p.useState({status:"loading"}),o=p.useRef(void 0);return p.useEffect(()=>{let a=!1;const l=o.current===e;return o.current=e,l||i({status:"loading"}),e().then(c=>{a||i({data:c,status:"live"})},()=>{a||i(c=>l&&c.status==="live"?c:{status:"error"})}),()=>{a=!0}},[e,t,n]),s}function nt(e,t){const n=co(),s=Hn(),[i,o]=p.useState(void 0);return p.useEffect(()=>{let a=!1;return e().then(l=>{a||o(l)},()=>{}),()=>{a=!0}},[e,n,s]),i??t}const xe=e=>typeof e=="object"&&e!==null,Zf=e=>{if(!Array.isArray(e))return[];const t=[];for(const n of e)!xe(n)||typeof n.data!="string"||typeof n.mimeType!="string"||t.push({data:n.data,mimeType:n.mimeType,...typeof n.name=="string"?{name:n.name}:{}});return t},Qf=e=>xe(e)&&e.type==="text"&&typeof e.text=="string"?e.text:void 0,eh=e=>typeof e.t=="string"?e.t:"",th=e=>{if(!xe(e)||!Array.isArray(e.options))return[];const t=[];for(const n of e.options)xe(n)&&typeof n.optionId=="string"&&typeof n.kind=="string"&&t.push({optionId:n.optionId,kind:n.kind,...typeof n.name=="string"?{name:n.name}:{}});return t},nh=e=>xe(e)&&xe(e.toolCall)&&typeof e.toolCall.title=="string"?e.toolCall.title:"Permission requested",sh=e=>({approve:e.find(t=>t.kind==="allow_once")??e.find(t=>t.kind==="allow_always")??e.find(t=>t.kind.includes("allow")),deny:e.find(t=>t.kind==="reject_once")??e.find(t=>t.kind==="reject_always")??e.find(t=>t.kind.includes("reject")||t.kind.includes("deny"))}),rh=(e,t,n,s)=>{const i=e[e.length-1];i!==void 0&&i.kind===t?e[e.length-1]={...i,text:i.text+n}:e.push({kind:t,text:n,t:s})},ih=e=>{const t=[],n=new Map,s=new Map;for(const i of e){if(!xe(i)||typeof i.type!="string")continue;const o=eh(i);if(i.type==="user_message"&&typeof i.text=="string"){const a=Zf(i.images);t.push({kind:"user",text:i.text,t:o,...a.length>0?{images:a}:{}});continue}if(i.type==="update"&&xe(i.update)&&xe(i.update.update)){const a=i.update.update,l=typeof a.sessionUpdate=="string"?a.sessionUpdate:"";if(l==="agent_message_chunk"||l==="user_message_chunk"){const c=Qf(a.content);c!==void 0&&c.length>0&&rh(t,l==="user_message_chunk"?"user":"agent",c,o);continue}if(l==="tool_call"||l==="tool_call_update"){const c=typeof a.toolCallId=="string"?a.toolCallId:"";if(c.length===0)continue;const u=typeof a.title=="string"?a.title:void 0,h=typeof a.status=="string"?a.status:void 0,f=n.get(c);if(f!==void 0)u!==void 0&&(f.title=u),h!==void 0&&(f.status=h);else{const m={kind:"tool",toolCallId:c,title:u??"tool call",status:h??"pending",t:o};n.set(c,m),t.push(m)}continue}continue}if(i.type==="permission_request"&&typeof i.id=="string"){s.set(i.id,t.length),t.push({kind:"permission",id:i.id,title:nh(i.params),options:th(i.params),resolved:void 0,t:o});continue}if(i.type==="permission_resolved"&&typeof i.id=="string"){const a=s.get(i.id),l=a!==void 0?t[a]:void 0;a!==void 0&&l!==void 0&&l.kind==="permission"&&(t[a]={...l,resolved:{outcome:typeof i.outcome=="string"?i.outcome:"resolved",...typeof i.optionId=="string"?{optionId:i.optionId}:{}}});continue}if(i.type==="error"&&typeof i.message=="string"){t.push({kind:"error",message:i.message,t:o});continue}}return t},Wn=[{slug:"skills",name:"skills",path:"~/Documents/code/skills",skills:[{slug:"to-tickets",stage:"Evals",oneLiner:"Decompose a decided scope into tracer-bullet tickets"},{slug:"release-notes",stage:"Idea",oneLiner:"Draft release notes from merged PRs"},{slug:"standup-summarizer",stage:"Idea",oneLiner:"Summarize the day across repos"},{slug:"pr-description-writer",stage:"Drafting",oneLiner:"Write PR descriptions from diffs"},{slug:"changelog-curator",stage:"Research",oneLiner:"Curate user-facing changelogs"},{slug:"incident-scribe",stage:"Idea",oneLiner:"Turn incident channels into postmortems"},{slug:"meeting-actions",stage:"Idea",oneLiner:"Extract action items from transcripts"}]},{slug:"skillmaker-studio",name:"skillmaker-studio",path:"~/Documents/code/skillmaker-studio",skills:[{slug:"skillmaker-dev-release",stage:"Published",oneLiner:"Cut a skillmaker-studio release"},{slug:"to-tickets",stage:"Published",oneLiner:"Decompose scope into tickets (installed)"}]}],ho=[{title:"IN-1 fixture may not force skill invocation — add trigger variant",origin:"run · to-tickets",state:"open"},{title:"Cover RE-2 (DAG validity) — no fixture yet",origin:"gap · to-tickets",state:"open"},{title:"Grow partial-decomposition past smoke (n=1 of 5)",origin:"gap · to-tickets",state:"open"},{title:"Permission denials review after first canary run",origin:"human",state:"in-progress"}],oh=[{id:"IN-1",family:"Input",sentence:"Input too vague to decompose: refuses and asks for concrete scope",status:"proven",fixtures:1,fixtureCases:["vague-scope-refusal"]},{id:"IN-2",family:"Input",sentence:"Already-partial decomposition is respected, not discarded",status:"unmeasured",fixtures:1,fixtureCases:["partial-decomposition"]},{id:"RE-1",family:"Reasoning",sentence:"Blocking edges are real — never merely-related",status:"partial",fixtures:1,fixtureCases:["partial-decomposition"]},{id:"RE-2",family:"Reasoning",sentence:"The DAG is valid: no cycles, no dangling references",status:"gap",fixtures:0,fixtureCases:[]},{id:"OUT-3",family:"Output",sentence:"Never talks to a tracker API",status:"gap",fixtures:0,fixtureCases:[]}],ah=["design.md","output/SKILL.md","research/notes.md","research/decisions.md","evals/risk-map.md","evals/fixtures/vague-scope-refusal/","evals/fixtures/partial-decomposition/"],ch={name:"to-tickets",oneLiner:"Decompose a decided scope into tracer-bullet tickets",versions:[],loop:null,instructions:"Decompose an already-decided scope into vertical-slice implementation tickets…",stage:"Evals",versionShort:"811e4580",drift:"in sync",provenOn:"Opus 4.6 (1 claim)",coverage:"2 of 5 claims",claims:oh,evals:null,events:[{type:"run.graded",at:"yesterday"},{type:"station drafting completed",at:"2d ago"},{type:"bundle.created",at:"2d ago"}]},lh=ah.map(e=>({path:e,size:0}));function uh({skill:e,width:t,intro:n=null,onIntroConsumed:s,fileRequest:i=null,onFileRequestHandled:o}){const[a,l]=p.useState("chat"),[c,u]=p.useState(null),[h,f]=p.useState(!0),m=g=>{u(g),g!==null&&t<420&&f(!1)};return p.useEffect(()=>{i!=null&&(l("files"),m(i),o?.())},[i]),r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-1 px-2",children:[["files","chat"].map(g=>r.jsx("button",{type:"button",onClick:()=>l(g),className:`rounded px-2 py-1 font-display text-xs uppercase ${a===g?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface hover:text-ink hover:shadow-sm"}`,children:g},g)),r.jsx("span",{className:"flex-1"}),a==="files"&&c!==null&&r.jsx(Ue,{active:h,onClick:()=>f(!h),title:h?"Hide file browser":"Show file browser",children:r.jsx(Uo,{})}),r.jsx("span",{className:"w-16 shrink-0"})]}),a==="files"?r.jsx(fh,{skill:e,selected:c,treeOpen:h,onSelect:m}):r.jsx(Nh,{skill:e,intro:n,onIntroConsumed:s})]})}function dh(e){const t={name:"",path:"",dirs:[],files:[]};for(const n of e){const s=n.path.split("/");let i=t;for(let o=0;o<s.length-1;o++){const a=s.slice(0,o+1).join("/");let l=i.dirs.find(c=>c.path===a);l===void 0&&(l={name:s[o]??"",path:a,dirs:[],files:[]},i.dirs.push(l)),i=l}i.files.push(n)}return t}function fh({skill:e,selected:t,treeOpen:n,onSelect:s}){const i=p.useCallback(()=>zf(e),[e]),o=nt(i,lh),a=dh(o),l=Sn("right","sm-next-treew",208,140,420);return t===null?r.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-4 text-sm",children:r.jsx(Kn,{dir:a,depth:0,selected:t,onSelect:s})}):r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:`flex shrink-0 items-center gap-1 border-b border-border px-3 py-1.5 text-xs ${re}`,children:[r.jsx("span",{className:"text-ink-muted",children:e}),t.split("/").map((c,u,h)=>r.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap",children:[r.jsx("span",{className:"text-ink-muted",children:"›"}),r.jsx("span",{className:u===h.length-1?"font-display":"text-ink-muted",children:c})]},`${c}-${u}`))]}),r.jsxs("div",{className:"flex min-h-0 flex-1",children:[r.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto p-3",children:r.jsx(ph,{skill:e,path:t})}),r.jsxs("div",{className:`relative shrink-0 overflow-hidden border-border ${l.dragging?"":"transition-[width] duration-200 ease-out"} ${n?"border-l":""}`,style:{width:n?l.width:0},children:[n&&r.jsx("div",{className:"absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:l.onDragStart,title:"Drag to resize"}),r.jsx("div",{className:"h-full overflow-y-auto px-1 py-2 text-sm",style:{width:l.width},children:r.jsx(Kn,{dir:a,depth:0,selected:t,onSelect:s})})]})]})]})}function hh({dir:e,depth:t,selected:n,onSelect:s}){const[i,o]=p.useState(!0);return r.jsxs("div",{children:[r.jsxs("button",{type:"button",onClick:()=>o(!i),className:`flex w-full items-center gap-1 rounded py-0.5 text-left text-ink-muted hover:bg-surface/60 ${re}`,style:{paddingLeft:6+t*12},title:e.path,children:[r.jsx("span",{className:"shrink-0",children:r.jsx(xr,{open:i})}),r.jsx("span",{className:`min-w-0 flex-1 ${re}`,children:e.name})]}),i&&r.jsx(Kn,{dir:e,depth:t+1,selected:n,onSelect:s})]})}function Kn({dir:e,depth:t,selected:n,onSelect:s}){return r.jsxs(r.Fragment,{children:[e.dirs.map(i=>r.jsx(hh,{dir:i,depth:t,selected:n,onSelect:s},i.path)),e.files.map(i=>{const o=i.path.split("/").pop()??i.path,a=i.path===n;return r.jsx("button",{type:"button",onClick:()=>s(i.path),className:`block w-full rounded py-0.5 pr-1 text-left ${re} ${a?"bg-surface text-ink shadow-sm":"text-ink-muted hover:bg-surface/60"}`,style:{paddingLeft:20+t*12},title:i.path,children:o},i.path)})]})}function ph({skill:e,path:t}){const n=p.useCallback(()=>Rs(e,t),[e,t]),s=nt(n,null);return s===null?r.jsx("p",{className:"text-sm text-ink-muted",children:"Loading…"}):r.jsx(so,{path:t,content:s,preClassName:"whitespace-pre-wrap break-words text-xs leading-relaxed [font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace]",renderedClassName:"rounded border border-border bg-surface p-3 text-sm shadow-sm"})}const mh=[{role:"agent",text:"Research is approved. Want me to start drafting, or is there anything in the notes you want changed first?",sentAt:"Jul 23, 9:38 AM"},{role:"user",text:"go ahead and draft",sentAt:"Jul 23, 9:41 AM"},{role:"agent",status:"running drafting",text:"Writing design.md and output/SKILL.md in the sandbox…",sentAt:"Jul 23, 9:41 AM"}];function xh(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:[r.jsx("rect",{x:"5.5",y:"5.5",width:"8",height:"8",rx:"1.5"}),r.jsx("path",{d:"M10.5 5.5v-2a1.5 1.5 0 0 0-1.5-1.5h-5A1.5 1.5 0 0 0 2.5 3.5v5A1.5 1.5 0 0 0 4 10h1.5"})]})}function po({text:e,sentAt:t,align:n}){const[s,i]=p.useState(!1),o=()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},a=r.jsx("button",{type:"button",className:"rounded p-1 hover:bg-surface hover:text-ink hover:shadow-sm",title:"Copy message",onClick:o,children:r.jsx(xh,{})}),l=r.jsx("span",{children:s?"Copied":t});return r.jsx("div",{className:`flex h-6 items-center gap-1.5 text-xs text-ink-muted opacity-0 transition-opacity group-hover:opacity-100 ${n==="right"?"justify-end pr-1":"pl-0.5"}`,children:n==="left"?r.jsxs(r.Fragment,{children:[a,l]}):r.jsxs(r.Fragment,{children:[l,a]})})}function gh({image:e}){const[t,n]=p.useState(!1);return r.jsx("button",{type:"button",className:"block overflow-hidden rounded border border-border",title:`${e.name??e.mimeType} — click to ${t?"shrink":"enlarge"}`,onClick:()=>n(!t),children:r.jsx("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name??"attached image",className:t?"max-h-96 max-w-full":"h-16 w-auto"})})}function mo({text:e,sentAt:t,images:n=[]}){return r.jsxs("div",{className:"group flex flex-col items-end pt-3",children:[r.jsxs("div",{className:"max-w-[85%] rounded-xl bg-amber-50 px-3 py-2 shadow-sm",children:[n.length>0&&r.jsx("div",{className:"flex flex-wrap justify-end gap-1.5 pb-1",children:n.map((s,i)=>r.jsx(gh,{image:s},i))}),e.length>0&&r.jsx("p",{className:"whitespace-pre-wrap",children:e})]}),r.jsx("div",{className:"self-stretch",children:r.jsx(po,{text:e,sentAt:t,align:"right"})})]})}function xo({text:e,sentAt:t,status:n}){return r.jsxs("div",{className:"group pt-3",children:[n&&r.jsx("div",{className:"pb-0.5 font-display text-xs text-ink-muted",children:n}),r.jsx("div",{className:n?"text-ink-muted":"",children:r.jsx(ln,{markdown:e})}),r.jsx(po,{text:e,sentAt:t,align:"left"})]})}function bh({title:e,status:t}){return r.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded border border-border bg-surface/60 px-2 py-1 text-xs text-ink-muted",title:`${e} — ${t}`,children:[r.jsx("span",{className:"truncate",children:e}),r.jsx("span",{className:"ml-auto shrink-0",children:t})]})}function yh({item:e,onAnswer:t}){const{approve:n,deny:s}=sh(e.options);return e.resolved!==void 0?r.jsxs("div",{className:"mt-2 rounded border border-border bg-surface/60 px-2 py-1 text-xs text-ink-muted",children:[e.title," — ",e.resolved.outcome]}):r.jsxs("div",{className:"mt-2 rounded-xl border border-amber-300 bg-amber-50/60 px-3 py-2 text-sm shadow-sm",children:[r.jsx("div",{className:"pb-0.5 font-display text-xs uppercase tracking-widest text-ink-muted",children:"permission"}),r.jsx("p",{className:"pb-2",children:e.title}),r.jsxs("div",{className:"flex gap-2",children:[n&&r.jsx("button",{type:"button",className:"rounded bg-amber-200 px-2 py-1 text-xs hover:bg-amber-300",onClick:()=>t(e.id,n.optionId,"allowed"),children:"Approve"}),s&&r.jsx("button",{type:"button",className:"rounded border border-border px-2 py-1 text-xs hover:bg-surface",onClick:()=>t(e.id,s.optionId,"denied"),children:"Deny"})]})]})}const Gt=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})};function vh({state:e,provider:t,onStart:n}){const s=e.resumable.find(i=>i.provider===t);return r.jsxs("div",{className:"px-3 pt-4 text-sm",children:[r.jsxs("p",{className:"text-ink-muted",children:["Start a session with ",r.jsx("span",{className:"font-display",children:t})," — or pick a different agent below."]}),r.jsxs("div",{className:"flex gap-2 pt-3",children:[s&&r.jsxs("button",{type:"button",className:"rounded bg-amber-200 px-2.5 py-1.5 text-xs hover:bg-amber-300",title:`Resume the session from ${Gt(s.updatedAt)}`,onClick:()=>n(t,"resume"),children:["Resume (",Gt(s.updatedAt),")"]}),r.jsx("button",{type:"button",className:`rounded px-2.5 py-1.5 text-xs ${s?"border border-border hover:bg-surface":"bg-amber-200 hover:bg-amber-300"}`,disabled:t.length===0,onClick:()=>n(t,"new"),children:s?"Start fresh":"Start"})]}),e.lastError&&r.jsx("p",{className:"pt-3 text-xs text-red-600",children:e.lastError})]})}function kh(){return r.jsx(r.Fragment,{children:mh.map((e,t)=>e.role==="user"?r.jsx(mo,{text:e.text,sentAt:e.sentAt},t):r.jsx(xo,{text:e.text,sentAt:e.sentAt,status:e.status},t))})}const wh=5*1024*1024;function jh(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",children:r.jsx("path",{d:"M13.2 7.3l-5 5a3.1 3.1 0 0 1-4.4-4.4l5.6-5.6a2.1 2.1 0 0 1 3 3l-5.6 5.6a1.1 1.1 0 0 1-1.6-1.6l5-5"})})}const Sh=e=>new Promise(t=>{if(!e.type.startsWith("image/")){t(`"${e.name}" is not an image`);return}if(e.size>wh){t(`"${e.name}" is ${(e.size/(1024*1024)).toFixed(1)}MB — the limit is 5MB per image`);return}const n=new FileReader;n.onerror=()=>t(`could not read "${e.name}"`),n.onload=()=>{const s=String(n.result),i=s.indexOf(",");if(i===-1){t(`could not read "${e.name}"`);return}t({data:s.slice(i+1),mimeType:e.type,name:e.name})},n.readAsDataURL(e)});function Nh({skill:e,intro:t=null,onIntroConsumed:n}){const s=Ad(e),[i,o]=p.useState(""),[a,l]=p.useState(null),[c,u]=p.useState([]),[h,f]=p.useState(null),[m,g]=p.useState(void 0),b=p.useRef(null),v=p.useRef(null);p.useEffect(()=>{if(!s.available)return;let k=!1;return Xi().then(j=>{k||g(j)}),()=>{k=!0}},[s.available]);const y=ih(s.events),x=s.state?.active??null,w=s.available&&x!==null&&x.status==="ready",N=x!==null?{provider:x.provider,...x.modelId!==void 0?{model:x.modelId}:{},...x.effort!==void 0?{effort:x.effort}:{}}:a??to(m??null,s.state?.providers??[])??{provider:s.state?.defaultProvider??"claude-code"},C=ef(m??null,N.provider),R=k=>{if(x===null){l(k);return}x.status==="ready"&&k.provider===x.provider&&k.model!==void 0&&s.setModel(k.model,k.effort)},F=p.useRef("start");p.useEffect(()=>{if(!(t===null||t.slug!==e||!s.available||s.state===void 0)){if(F.current==="start"&&(F.current="send",x===null)){s.start(t.provider,"new",t.model!==void 0?{model:t.model,...t.effort!==void 0?{effort:t.effort}:{}}:void 0);return}F.current==="send"&&x!==null&&x.status==="ready"&&(F.current="done",s.send(t.message),n?.())}},[t,e,s,x,n]),p.useEffect(()=>{const k=b.current;k&&(k.scrollTop=k.scrollHeight)},[y.length,x?.status]);const A=k=>{k.length!==0&&(f(null),Promise.all(k.map(Sh)).then(j=>{const P=j.filter(S=>typeof S!="string"),D=j.find(S=>typeof S=="string");P.length>0&&u(S=>[...S,...P]),D!==void 0&&f(D)}))},K=()=>{const k=i.trim();k.length===0&&c.length===0||!w||(s.send(k,c),o(""),u([]),f(null))};return r.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[r.jsxs("div",{ref:b,className:"h-full overflow-y-auto px-6 pb-28 text-sm",children:[!s.available&&r.jsx(kh,{}),s.available&&s.state!==void 0&&x===null&&r.jsx(vh,{state:s.state,provider:N.provider,onStart:(k,j)=>s.start(k,j,N.model!==void 0?{model:N.model,...N.effort!==void 0?{effort:N.effort}:{}}:void 0)}),s.available&&x!==null&&x.status==="starting"&&r.jsx("p",{className:"pt-3 text-ink-muted",children:"Starting the agent…"}),s.available&&x!==null&&x.modelFallback!==void 0&&r.jsx("p",{className:"pt-2 text-xs text-amber-700 dark:text-amber-400",children:x.modelFallback}),s.available&&y.map((k,j)=>k.kind==="user"?r.jsx(mo,{text:k.text,sentAt:Gt(k.t),images:k.images},j):k.kind==="agent"?r.jsx(xo,{text:k.text,sentAt:Gt(k.t)},j):k.kind==="tool"?r.jsx(bh,{title:k.title,status:k.status},k.toolCallId):k.kind==="permission"?r.jsx(yh,{item:k,onAnswer:s.answerPermission},k.id):r.jsx("div",{className:"mt-2 rounded border border-red-200 bg-red-50 px-2 py-1 text-xs text-red-700",children:k.message},j)),s.available&&x!==null&&x.status==="running"&&r.jsxs("div",{className:"flex items-center gap-2 pt-3 text-xs text-ink-muted",children:[r.jsx("span",{children:"running…"}),r.jsx("button",{type:"button",className:"rounded border border-border px-1.5 py-0.5 hover:bg-surface",onClick:s.cancelTurn,children:"Stop"})]}),s.actionError&&r.jsx("p",{className:"pt-2 text-xs text-red-600",children:s.actionError})]}),r.jsxs("div",{className:"absolute inset-x-2 bottom-2 rounded-xl border border-border bg-surface/95 shadow-lg backdrop-blur-sm focus-within:border-amber-300",children:[c.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1.5 px-4 pt-3",children:c.map((k,j)=>r.jsxs("span",{className:"relative inline-block",children:[r.jsx("img",{src:`data:${k.mimeType};base64,${k.data}`,alt:k.name??"attachment",className:"h-12 w-auto rounded border border-border"}),r.jsx("button",{type:"button",className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-ink text-[10px] leading-none text-white shadow dark:text-canvas",title:`Remove ${k.name??"image"}`,onClick:()=>u(P=>P.filter((D,S)=>S!==j)),children:"×"})]},j))}),h!==null&&r.jsx("p",{className:"px-4 pt-2 text-xs text-red-600",children:h}),r.jsx("input",{className:"w-full bg-transparent px-4 pb-1.5 pt-3.5 text-sm outline-none disabled:opacity-60",placeholder:w||!s.available?"What should we do?":x===null?"Choose a model to start":"Agent is working…",value:i,disabled:s.available&&!w,onChange:k=>o(k.target.value),onPaste:k=>{if(!C)return;const j=Array.from(k.clipboardData?.files??[]).filter(P=>P.type.startsWith("image/"));j.length>0&&(k.preventDefault(),A(j))},onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),K())}}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-3 pb-3",children:[C&&r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:v,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,className:"hidden",onChange:k=>{A(Array.from(k.target.files??[])),k.target.value=""}}),r.jsx("button",{type:"button",className:"rounded p-1 text-ink-muted hover:bg-surface hover:text-ink disabled:opacity-35",title:"Attach images (or paste into the input)",disabled:s.available&&!w&&x!==null,onClick:()=>v.current?.click(),children:r.jsx(jh,{})})]}),r.jsx("span",{className:"flex-1"}),r.jsx(no,{catalog:m??null,providers:s.state?.providers??[],selection:N,onChange:R,disabled:x!==null&&x.status!=="ready",...x!==null?{lockProvider:x.provider}:{}}),r.jsx("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded-full bg-amber-600 text-white shadow hover:bg-amber-700 disabled:opacity-35",title:"Send",disabled:s.available&&!w,onClick:K,children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[r.jsx("line",{x1:"8",y1:"13",x2:"8",y2:"3.5"}),r.jsx("path",{d:"M4 7.5L8 3.5l4 4"})]})})]})]})]})}const Ch=250;function Eh({onClose:e,onRegistered:t}){const[n,s]=p.useState(""),[i,o]=p.useState(null),[a,l]=p.useState(null),[c,u]=p.useState(""),[h,f]=p.useState(!1),[m,g]=p.useState(!1),[b,v]=p.useState(!1),[y,x]=p.useState(null),w=p.useRef(void 0);p.useEffect(()=>{cr().then(k=>{k!==null&&(o(k),s(k.path))})},[]),p.useEffect(()=>{if(w.current!==void 0&&clearTimeout(w.current),n.length===0){l(null);return}return w.current=setTimeout(()=>{gf(n).then(l)},Ch),()=>{w.current!==void 0&&clearTimeout(w.current)}},[n]);const N=k=>{g(!1),x(null),cr(k).then(j=>{j!==null&&(o(j),s(j.path))})},C=async k=>{v(!0),x(null);const j=a!==null&&!a.valid&&a.creatable===!0,P=await yf(n,{...j?{create:!0,init:!0}:{},...k?{init:!0}:{}});if(v(!1),P.kind==="registered"){t(P.slug),e();return}if(P.kind==="needs_init"&&!k){await C(!0);return}if(P.kind==="needs_init"){x("Could not set up this directory.");return}x(P.message)},R=async()=>{const k=c.trim();if(k.length===0||i===null)return;v(!0),x(null);const j=`${i.path.endsWith("/")?i.path.slice(0,-1):i.path}/${k}`,P=await bf(j);if(v(!1),P!==null){x(P);return}f(!1),u(""),N(j)},A=a===null?null:a.valid?a.registered===!0?{text:"Already registered.",tone:"warn"}:a.isProject===!0?{text:"Existing skillmaker project -- will be registered.",tone:"ok"}:null:a.creatable===!0?{text:"Does not exist -- will be created and set up.",tone:"warn"}:{text:a.reason??"Invalid path.",tone:"bad"},K=!b&&n.length>0&&a!==null&&a.registered!==!0&&(a.valid||a.creatable===!0);return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onMouseDown:k=>k.target===k.currentTarget&&e(),children:r.jsxs("div",{className:"w-[520px] max-w-[92vw] rounded-lg border border-border bg-paper p-4 shadow-xl",children:[r.jsx("div",{className:"pb-2 font-display text-lg",children:"New project"}),r.jsx("p",{className:"pb-3 text-xs text-ink-muted",children:"A project is a directory on this machine. Pick an existing one or create a new folder; a directory without a skillmaker setup gets the default scaffold."}),r.jsx("label",{className:"block pb-1 text-xs uppercase tracking-widest text-ink-muted",htmlFor:"np-path",children:"Directory path"}),r.jsx("input",{id:"np-path",type:"text",value:n,onChange:k=>{g(!1),s(k.target.value)},spellCheck:!1,className:"w-full rounded border border-border bg-surface px-2 py-1.5 font-mono text-sm",placeholder:"/absolute/path/to/project"}),A!==null&&r.jsx("div",{className:`pt-1 text-xs ${A.tone==="ok"?"text-green-700 dark:text-green-400":A.tone==="warn"?"text-amber-700 dark:text-amber-400":"text-red-700 dark:text-red-400"}`,children:A.text}),r.jsxs("div",{className:"mt-3 rounded border border-border",children:[r.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-2 py-1.5 text-xs",children:[r.jsx("button",{type:"button",className:"rounded px-1.5 py-0.5 text-ink-muted hover:bg-surface hover:text-ink disabled:opacity-40",disabled:i?.parent==null,onClick:()=>i?.parent!=null&&N(i.parent),children:"↑ Up"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-muted",title:i?.path??"",children:i?.path??"…"}),r.jsx("button",{type:"button",className:"rounded px-1.5 py-0.5 text-ink-muted hover:bg-surface hover:text-ink",onClick:()=>f(!0),children:"+ New folder"})]}),r.jsxs("div",{className:"max-h-48 overflow-y-auto p-1",children:[h&&r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:k=>u(k.target.value),onKeyDown:k=>{k.key==="Enter"&&R(),k.key==="Escape"&&f(!1)},className:"flex-1 rounded border border-border bg-surface px-2 py-0.5 font-mono text-sm",placeholder:"folder-name"}),r.jsx(Q,{label:"Create",onClick:()=>void R(),disabled:b||c.trim().length===0})]}),(i?.dirs??[]).map(k=>r.jsxs("button",{type:"button",onClick:()=>N(k.path),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-sm hover:bg-surface",children:[r.jsx("span",{className:"text-ink-muted",children:"▸"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:k.name}),k.isProject&&r.jsx("span",{className:"rounded bg-amber-200 px-1.5 text-[10px] text-amber-900",children:"project"})]},k.path)),i!==null&&i.dirs.length===0&&!h&&r.jsx("div",{className:"px-2 py-2 text-xs text-ink-muted",children:"No subdirectories."})]})]}),y!==null&&r.jsx("div",{className:"pt-2 text-xs text-red-700 dark:text-red-400",children:y}),m?r.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[r.jsx(Q,{label:"Cancel",onClick:()=>g(!1),disabled:b}),r.jsx(Q,{label:"Create project",primary:!0,onClick:()=>void C(!0),disabled:b})]}):r.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[r.jsx(Q,{label:"Cancel",onClick:e,disabled:b}),r.jsx(Q,{label:b?"Working…":a?.isProject===!0?"Add project":"Create project",primary:!0,onClick:()=>void C(!1),disabled:!K})]})]})})}const Rh=20,$h=6e3,Ih=(e,t)=>{const n=e!==null&&Array.isArray(e.active)&&e.active.length>0,s=t!==null&&typeof t.active=="object"&&t.active!==null&&t.active.status==="running";return n||s},dr=async e=>{try{const t=await fetch(e,{headers:{accept:"application/json"}});return t.ok?await t.json():null}catch{return null}},fr=async e=>{const t=e.slice(0,Rh),n=await Promise.all(t.map(async s=>{const[i,o]=await Promise.all([dr(ne(`/api/bundles/${encodeURIComponent(s)}/runs-active`)),dr(ne(`/api/chat/${encodeURIComponent(s)}/state`))]);return i===null&&o===null?{slug:s,running:!1,reachable:!1}:{slug:s,running:Ih(i,o),reachable:!0}}));if(n.length>0&&n.every(s=>!s.reachable))throw new Error("presence: server absent");return new Set(n.filter(s=>s.running).map(s=>s.slug))};function _h(e){const[t,n]=p.useState(new Set),s=p.useRef(!1),i=p.useRef(!1),o=e.join(`
|
|
27
|
+
`);p.useEffect(()=>{let l=!1;const c=o.length===0?[]:o.split(`
|
|
28
|
+
`),u=()=>{s.current||i.current||c.length===0||(i.current=!0,fr(c).then(f=>{l||n(f)}).catch(()=>{s.current=!0,l||n(new Set)}).finally(()=>{i.current=!1}))};u();const h=ao(u);return()=>{l=!0,h()}},[o]);const a=t.size>0;return p.useEffect(()=>{if(!a||s.current)return;const l=o.length===0?[]:o.split(`
|
|
29
|
+
`),c=setInterval(()=>{s.current||i.current||l.length===0||(i.current=!0,fr(l).then(n).catch(()=>{s.current=!0,n(new Set)}).finally(()=>{i.current=!1}))},$h);return()=>clearInterval(c)},[a,o]),p.useMemo(()=>t,[t])}const Ah="sm-theme";function Th(){return document.documentElement.classList.contains("dark")?"dark":"light"}function Oh(e){document.documentElement.classList.toggle("dark",e==="dark");try{localStorage.setItem(Ah,e)}catch{}}const qn=5;function Ph({center:e,onNavigate:t}){const[n,s]=p.useState(Wn),[i,o]=p.useState(()=>Object.fromEntries(Wn.map(y=>[y.name,!0]))),[a,l]=p.useState({}),[c,u]=p.useState(!1),h=Hn(),m=nt(fo,ho).filter(y=>y.state==="open").length,g=n.flatMap(y=>i[y.name]??!1?(a[y.name]??!1?y.skills:y.skills.slice(0,qn)).map(x=>x.slug):[]),b=_h(g),v=p.useCallback(()=>{let y=!1;return io().then(x=>{y||x===null||x.length===0||(s(x),o(Object.fromEntries(x.map(w=>[w.name,!0]))))}),()=>{y=!0}},[]);return p.useEffect(()=>v(),[v]),r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsx("div",{className:"h-11 shrink-0"}),r.jsx("div",{className:"px-4 pb-2",children:r.jsx("span",{className:"font-display text-lg tracking-tight",children:"SKILLMAKER STUDIO"})}),r.jsxs("nav",{className:"px-2",children:[r.jsx(hr,{label:"Board",icon:r.jsx(Ao,{}),active:e.kind==="board",onClick:()=>t({kind:"board"})}),r.jsx(hr,{label:"Tasks",icon:r.jsx(To,{}),active:e.kind==="tasks",badge:m,onClick:()=>t({kind:"tasks"})})]}),r.jsxs("div",{className:"mt-4 flex-1 overflow-y-auto px-2",children:[r.jsxs("div",{className:"group flex items-center pb-1 pl-3 pr-1",children:[r.jsx("span",{className:"flex-1 text-xs uppercase tracking-widest text-ink-muted",children:"Projects"}),r.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-ink-muted opacity-0 transition-opacity hover:text-ink group-hover:opacity-100",title:"New project (register a directory)",onClick:()=>u(!0),children:r.jsx(gr,{})})]}),n.map(y=>r.jsx(Mh,{project:y,active:y.slug===h,open:i[y.name]??!1,expanded:a[y.name]??!1,center:e,running:b,onToggle:()=>{De(y.slug),o({...i,[y.name]:!(i[y.name]??!1)})},onToggleExpanded:()=>l({...a,[y.name]:!(a[y.name]??!1)}),onOpenSkill:x=>{De(y.slug),t({kind:"skill",project:y.name,slug:x})},onNewSkill:()=>{De(y.slug),t({kind:"new-skill",project:y.name})}},y.slug))]}),r.jsxs("div",{className:"flex items-center gap-1 border-t border-border px-3 py-2",children:[r.jsx("a",{href:"https://github.com/sociotechnica-org/skillmaker-studio",target:"_blank",rel:"noreferrer",className:"rounded p-1.5 text-ink-muted hover:bg-surface hover:text-ink",title:"GitHub",children:r.jsx(Oo,{})}),r.jsx("a",{href:"#",className:"rounded p-1.5 text-ink-muted hover:bg-surface hover:text-ink",title:"Docs",children:r.jsx(Po,{})}),r.jsx(Fh,{})]}),c&&r.jsx(Eh,{onClose:()=>u(!1),onRegistered:y=>{y!==null&&(De(y),t({kind:"new-skill",project:y})),v()}})]})}function Fh(){const[e,t]=p.useState(null);if(p.useEffect(()=>{t(Th())},[]),e===null)return r.jsx("span",{className:"h-7 w-7"});const n=e==="dark"?"light":"dark";return r.jsx(Ue,{title:n==="dark"?"Switch to dark mode":"Switch to light mode",onClick:()=>{Oh(n),t(n)},children:e==="dark"?r.jsx(Lo,{}):r.jsx(Do,{})})}function hr({label:e,icon:t,active:n,badge:s,onClick:i}){return r.jsxs("button",{type:"button",onClick:i,className:`flex w-full items-center gap-2 rounded px-3 py-1.5 text-left font-display text-sm ${n?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface/60"}`,children:[r.jsx("span",{className:"text-ink-muted",children:t}),r.jsx("span",{className:"flex-1",children:e}),s?r.jsx("span",{className:"rounded-full bg-amber-200 px-2 text-xs",children:s}):null]})}function Mh({project:e,active:t,open:n,expanded:s,center:i,running:o,onToggle:a,onToggleExpanded:l,onOpenSkill:c,onNewSkill:u}){const h=s?e.skills:e.skills.slice(0,qn),f=e.skills.length-qn;return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:`group flex items-center rounded pr-1 hover:bg-surface/60 ${t?"bg-surface shadow-sm":""}`,children:[r.jsxs("button",{type:"button",onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 px-3 py-1 text-left font-display text-sm",title:e.error!==void 0?`${e.path} — ${e.error}`:e.path,children:[r.jsx("span",{className:"shrink-0 text-ink-muted",children:r.jsx(xr,{open:n})}),r.jsx("span",{className:`min-w-0 flex-1 ${re} ${e.ok===!1?"text-ink-muted line-through":""}`,children:e.name}),e.ok===!1&&r.jsx("span",{className:"shrink-0 rounded bg-red-200 px-1.5 text-[10px] text-red-900",title:e.error,children:"broken"})]}),r.jsx("button",{type:"button",className:"shrink-0 rounded p-1 text-ink-muted opacity-0 transition-opacity hover:text-ink group-hover:opacity-100",title:"New skill · import",onClick:u,children:r.jsx(gr,{})})]}),r.jsx("div",{className:`grid transition-[grid-template-rows] duration-150 ease-out ${n?"[grid-template-rows:1fr]":"[grid-template-rows:0fr]"}`,children:r.jsxs("div",{className:"overflow-hidden",children:[h.map(m=>{const g=i.kind==="skill"&&i.project===e.name&&i.slug===m.slug;return r.jsxs("button",{type:"button",onClick:()=>c(m.slug),className:`flex w-full items-center gap-2 rounded py-1 pl-8 pr-2 text-left text-sm ${g?"bg-surface shadow-sm":"text-ink-muted hover:bg-surface/60"}`,children:[r.jsx("span",{className:`min-w-0 flex-1 ${re}`,children:m.slug}),m.awaitingReview===!0&&r.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500",title:"Awaiting review"}),r.jsx(nf,{stage:m.stage}),o.has(m.slug)&&r.jsx("span",{className:"h-3 w-3 shrink-0 animate-spin rounded-full border border-amber-500 border-t-transparent",title:"Running"})]},m.slug)}),f>0&&r.jsx("button",{type:"button",onClick:l,className:"py-0.5 pl-8 text-left text-xs text-ink-muted hover:text-ink",children:s?"Show less":`Show ${f} more`})]})})]})}const Lh=3e3,go=async e=>{try{const t=await e.json();if(typeof t.error=="string")return t.error}catch{}return`request failed (${e.status})`},Dh=async e=>{const t=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/runs-active`));if(!t.ok)throw new Error(`runs-active: ${t.status}`);return await t.json()},Uh=async(e,t)=>{const n=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/run`),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fixture:t})});return n.ok?null:go(n)},Bh=async e=>{const t=await fetch(ne(`/api/bundles/${encodeURIComponent(e)}/run-all`),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});return t.ok?null:go(t)};function Vh(e){const[t,n]=p.useState({active:[],runAll:null}),[s,i]=p.useState(null),[o,a]=p.useState(!1),l=p.useRef(!0);p.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=p.useCallback(async()=>{if(e.length!==0)try{const m=await Dh(e);if(!l.current)return;n(m),a(m.active.length>0||m.runAll!==null)}catch{l.current&&a(!1)}},[e]);p.useEffect(()=>{c()},[c]),p.useEffect(()=>{if(!o)return;const m=setInterval(()=>void c(),Lh);return()=>clearInterval(m)},[o,c]);const u=p.useCallback(async m=>{if(e.length===0)return;const g=await m();l.current&&(i(g),g===null&&(a(!0),c()))},[c,e]),h=p.useCallback(m=>void u(()=>Uh(e,m)),[u,e]),f=p.useCallback(()=>void u(()=>Bh(e)),[u,e]);return{activeFixtures:new Set(t.active.map(m=>m.fixture)),runAll:t.runAll,error:s,runFixture:h,runAllFixtures:f}}const bo=8,Wh={proven:"bg-emerald-100 text-emerald-800",failing:"bg-rose-100 text-rose-800",stale:"bg-amber-100 text-amber-800",unmeasured:"border border-border text-ink-muted"},Kh={proven:"●",failing:"✕",stale:"◔",unmeasured:"◌"},qh={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",partial:"bg-amber-100 text-amber-800"};function Jh({chips:e}){return r.jsx("span",{className:"flex shrink-0 gap-1",children:e.map(t=>r.jsxs("span",{title:`${t.model}: ${t.status}`,className:`rounded px-1 text-[10px] ${Wh[t.status]}`,children:[Kh[t.status]," ",t.model]},t.model))})}function Hh({glance:e}){return e===void 0||e.state!=="ready"||e.value.skillInvoked===null?null:e.value.skillInvoked?r.jsx("span",{className:"rounded bg-sky-100 px-1 text-[10px] text-sky-800",title:"Transcript shows the skill was exercised",children:"invoked"}):r.jsx("span",{className:"rounded bg-rose-100 px-1 text-[10px] text-rose-800",title:"No evidence the skill was exercised — model-default behavior",children:"not invoked"})}const yo=e=>e.replace(/^sha256:/,"").slice(0,8),zh=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})};function Gh({page:e}){const t=e.evals,[n,s]=p.useState("latest"),[i,o]=p.useState(new Set),[a,l]=p.useState(new Set),[c,u]=p.useState({}),[h,f]=p.useState({}),[m,g]=p.useState({}),[b,v]=p.useState(new Set),[y,x]=p.useState(new Set),[w,N]=p.useState({}),C=t===null?[]:Tf(t.measurements),R=Vh(t?.slug??""),F=R.activeFixtures.size>0||R.runAll!==null,A=(S,$)=>{u(O=>O[$]!==void 0?O:(Gf(S.slug,$).then(_=>u(ke=>({...ke,[$]:{state:"ready",value:_}})),()=>u(_=>({..._,[$]:{state:"error"}}))),{...O,[$]:{state:"loading"}}))},K=(S,$)=>{f(O=>O[$]!==void 0?O:(Yf(S.slug,$).then(_=>f(ke=>({...ke,[$]:{state:"ready",value:_}})),()=>f(_=>({..._,[$]:{state:"error"}}))),{...O,[$]:{state:"loading"}}))},k=(S,$)=>{g(O=>O[$]!==void 0?O:(Rs(S.slug,`runs/${$}/response.md`).then(_=>g(ke=>({...ke,[$]:{state:"ready",value:_}})),()=>g(_=>({..._,[$]:{state:"ready",value:null}}))),{...O,[$]:{state:"loading"}}))},j=S=>{const $=!i.has(S.id);if(o(O=>{const _=new Set(O);return _.has(S.id)?_.delete(S.id):_.add(S.id),_}),$&&t!==null)for(const O of S.fixtureCases){A(t,O);for(const _ of lr(t.runs,O).slice(0,bo))K(t,_.id)}},P=S=>{const $=!a.has(S);l(O=>{const _=new Set(O);return _.has(S)?_.delete(S):_.add(S),_}),$&&t!==null&&(K(t,S),k(t,S))},D=S=>{if(t===null||y.has(S.id)||b.has(S.id))return;const $=Ff({riskId:S.id,sentence:S.sentence,bundle:t.slug,id:`td-${crypto.randomUUID()}`,created:new Date().toISOString().slice(0,10)});x(O=>new Set(O).add(S.id)),N(({[S.id]:O,..._})=>_),cn({type:"todo.opened",payload:{todo:$.todo}}).then(O=>{O.ok?v(_=>new Set(_).add(S.id)):N(_=>({..._,[S.id]:O.error}))}).catch(O=>N(_=>({..._,[S.id]:O.message}))).finally(()=>x(O=>{const _=new Set(O);return _.delete(S.id),_}))};return r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t===null?r.jsx("span",{}):r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("span",{className:"text-ink-muted",children:"Version:"}),[{id:"latest",label:t.latestVersionHash===null?"Latest (none recorded)":`Latest ${yo(t.latestVersionHash)}`},{id:"all",label:"All versions"}].map(S=>r.jsx("button",{type:"button",onClick:()=>s(S.id),className:`rounded-full px-2 py-0.5 font-display ${n===S.id?"bg-surface text-ink shadow-sm":"text-ink-muted hover:text-ink"}`,children:S.label},S.id))]}),r.jsxs("div",{className:"flex shrink-0 gap-2",children:[r.jsx(Q,{label:"New claim"}),r.jsx(Q,{label:Df(R.runAll,R.activeFixtures.size),primary:!0,disabled:t===null||F,onClick:R.runAllFixtures})]})]}),R.error!==null&&r.jsx("p",{className:"pt-1 text-right text-xs text-rose-700",children:R.error}),r.jsx("div",{className:"mt-1 space-y-2",children:Lf(e.claims).map(S=>r.jsxs("div",{children:[r.jsx("div",{className:"pt-1 font-display text-[10px] uppercase tracking-wide text-ink-muted",children:S.family}),r.jsx("div",{className:"mt-1 space-y-1",children:S.claims.map($=>{const O=t===null?[]:Of({measurements:t.measurements,fixtureCases:$.fixtureCases,scope:n,latestVersionHash:t.latestVersionHash,models:C}),_=t===null?$.status:Pf($.status,O),ke=i.has($.id);return r.jsxs("div",{className:"rounded border border-border bg-surface px-3 py-2 shadow-sm",children:[r.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[r.jsx("span",{title:_,children:tf[_]}),r.jsx("span",{className:"min-w-0 flex-1",children:$.sentence}),O.length>0&&r.jsx(Jh,{chips:O}),r.jsx("span",{className:"font-mono text-[10px] text-ink-muted",children:$.id}),r.jsx("span",{className:"rounded bg-neutral-100 px-1.5 text-[10px] text-ink-muted dark:bg-neutral-800",children:_})]}),r.jsx("div",{className:"pl-6 text-xs text-ink-muted",children:$.fixtures>0?t===null?`${$.fixtures} fixture${$.fixtures===1?"":"s"} · expand ▸`:r.jsxs("button",{type:"button",onClick:()=>j($),className:"hover:text-ink",children:[$.fixtures," fixture",$.fixtures===1?"":"s"," · ",ke?"collapse ▾":"expand ▸"]}):b.has($.id)?r.jsx("span",{className:"text-emerald-700",children:"queued ✓"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>D($),title:"Mints a task",className:"underline hover:text-ink disabled:opacity-60",disabled:t===null||y.has($.id),children:y.has($.id)?"queueing…":"no fixture — add to Tasks"}),w[$.id]!==void 0&&r.jsx("span",{className:"pl-2 text-rose-700",children:w[$.id]})]})}),ke&&t!==null&&r.jsx("div",{className:"mt-2 space-y-2 border-l border-border pl-4",children:$.fixtureCases.map(Me=>r.jsx(Yh,{caseName:Me,running:R.activeFixtures.has(Me),onRun:()=>R.runFixture(Me),glance:c[Me],runs:lr(t.runs,Me),runGlances:h,runResponses:m,expandedRuns:a,onToggleRun:P},Me))})]},$.id)})})]},S.family))}),t!==null&&t.unclaimed.length>0&&r.jsxs("p",{className:"pt-2 text-xs text-ink-muted",children:["Unclaimed fixtures — evidence without a claim: ",r.jsx("span",{className:"font-mono",children:t.unclaimed.join(", ")})]})]})}function Yh({caseName:e,running:t,onRun:n,glance:s,runs:i,runGlances:o,runResponses:a,expandedRuns:l,onToggleRun:c}){const u=i.slice(0,bo),h=i.length-u.length;return r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"font-mono text-ink",children:e}),t?r.jsx("span",{className:"rounded bg-amber-100 px-1 text-[10px] text-amber-800",children:"running…"}):r.jsx("button",{type:"button",onClick:n,title:`Run fixture ${e} (same engine as skillmaker run)`,className:"rounded border border-border px-1 text-[10px] text-ink-muted hover:text-ink",children:"▸ Run"}),s!==void 0&&s.state==="ready"&&r.jsxs(r.Fragment,{children:[s.value.fixtureClass!==null&&r.jsx("span",{className:"rounded bg-neutral-100 px-1 text-[10px] text-ink-muted dark:bg-neutral-800",children:s.value.fixtureClass}),s.value.hasAnswerKey?r.jsx("span",{className:"rounded bg-emerald-100 px-1 text-[10px] text-emerald-800",title:"case.json carries an answer key",children:"answer key"}):r.jsx("span",{className:"rounded border border-border px-1 text-[10px] text-ink-muted",title:"No answer key authored yet",children:"no answer key"}),s.value.checkCount>0&&r.jsxs("span",{className:"text-[10px] text-ink-muted",children:[s.value.checkCount," check",s.value.checkCount===1?"":"s"]})]}),s!==void 0&&s.state==="error"&&r.jsx("span",{className:"text-[10px] text-rose-700",children:"fixture unreadable"})]}),r.jsx("div",{className:`text-xs text-ink-muted ${re}`,children:s===void 0||s.state==="loading"?"Loading fixture…":s.state==="error"?"":s.value.summary??"(no prompt authored)"}),u.length===0?r.jsx("p",{className:"pt-1 text-[11px] text-ink-muted",children:"No runs yet."}):r.jsxs("div",{className:"mt-1 space-y-1",children:[u.map(f=>{const m=l.has(f.id);return r.jsxs("div",{children:[r.jsxs("button",{type:"button",onClick:()=>c(f.id),className:"flex w-full items-center gap-2 rounded bg-paper px-2 py-1 text-left text-[11px] hover:bg-neutral-100 dark:hover:bg-neutral-800",children:[r.jsx("span",{className:"shrink-0 text-ink-muted",children:m?"▾":"▸"}),r.jsx("span",{className:"shrink-0 text-ink-muted",children:zh(f.startedAt)}),r.jsxs("span",{className:`min-w-0 flex-1 ${re}`,children:[f.provider," · ",f.model]}),r.jsx("span",{className:"shrink-0 text-ink-muted",children:f.status}),f.verdict!==null&&r.jsx("span",{className:`shrink-0 rounded px-1 text-[10px] ${qh[f.verdict]??""}`,children:f.verdict}),r.jsx(Hh,{glance:o[f.id]})]}),m&&r.jsx(Xh,{run:f,glance:o[f.id],response:a[f.id]})]},f.id)}),h>0&&r.jsxs("p",{className:"text-[10px] text-ink-muted",children:["+",h," older run",h===1?"":"s"]})]})]})}function Xh({run:e,glance:t,response:n}){const s=t!==void 0&&t.state==="ready"?t.value.artifacts.filter(i=>!i.endsWith("response.md")):[];return r.jsxs("div",{className:"ml-4 mt-1 rounded border border-border bg-paper p-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[10px] text-ink-muted",children:[r.jsx("span",{className:"font-mono",children:e.id}),r.jsxs("span",{children:["version ",yo(e.versionHash)]}),t!==void 0&&t.state==="error"&&r.jsx("span",{className:"text-rose-700",children:"run detail unreadable"})]}),r.jsx("div",{className:"pt-1",children:n===void 0||n.state==="loading"?r.jsx("p",{className:"text-[11px] text-ink-muted",children:"Loading response…"}):n.state==="error"||n.value===null?r.jsx("p",{className:"text-[11px] text-ink-muted",children:"No response captured."}):r.jsx(so,{path:"response.md",content:n.value,preClassName:"max-h-60 overflow-auto rounded bg-surface p-2 font-mono text-[11px]",renderedClassName:"max-h-60 overflow-auto rounded border border-border bg-surface p-2"})}),s.length>0&&r.jsxs("p",{className:"pt-1 text-[10px] text-ink-muted",children:["Artifacts: ",r.jsx("span",{className:"font-mono",children:s.join(", ")})]}),r.jsx(Zh,{run:e})]})}function Zh({run:e}){const[t,n]=p.useState(null),[s,i]=p.useState(""),[o,a]=p.useState(!1),[l,c]=p.useState(null),[u,h]=p.useState(!1),f=g=>{n(g),a(!0),c(null);const b={id:e.id,verdict:g,...s.trim().length>0?{notes:s.trim()}:{}};cn({type:"run.graded",payload:b}).then(v=>{v.ok?h(!0):c(v.error)}).catch(v=>c(v.message)).finally(()=>a(!1))},m=e.verdict!==null;return r.jsxs("div",{className:"mt-2 border-t border-border pt-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[r.jsx("span",{className:"text-ink-muted",children:u&&t!==null?`Graded: ${t}`:m?`Graded: ${e.verdict} —`:"Grade this run:"}),!u&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:o,onClick:()=>f("pass"),className:"rounded border border-border bg-surface px-2 py-0.5 font-display hover:bg-emerald-50 disabled:opacity-50",children:m?"Regrade pass":"Pass"}),r.jsx("button",{type:"button",disabled:o,onClick:()=>f("fail"),className:"rounded border border-border bg-surface px-2 py-0.5 font-display hover:bg-rose-50 disabled:opacity-50",children:m?"Regrade fail":"Fail"}),r.jsx("input",{className:"min-w-0 flex-1 rounded border border-border bg-surface px-2 py-0.5 text-[11px] outline-none focus:border-amber-300",placeholder:"Notes (optional)",value:s,onChange:g=>i(g.target.value)})]})]}),l!==null&&r.jsx("p",{className:"pt-1 text-[10px] text-rose-700",children:l})]})}const _e=e=>uo[e],Qh=async(e,t)=>{const n=await cn({type:"review.requested",payload:{bundle:e,state:t}});if(!n.ok)return{ok:!1,error:n.error};const s=await Qi(e,t,"approve",void 0);return s.ok?eo(e,t):s};function ep({loop:e}){return e.substate!=="awaiting-review"?null:r.jsx("div",{className:"pb-4",children:r.jsx(np,{loop:e})})}function tp({loop:e}){const[t,n]=p.useState(!1),[s,i]=p.useState(null),[o,a]=p.useState(!1),l=Ge.slice(0,Ge.indexOf(e.stage)),[c,u]=p.useState(l[0]??"idea"),[h,f]=p.useState(""),m=Zi(e.stage),g=v=>{n(!0),i(null),v().then(y=>{n(!1),y.ok||i(y.error)})},b=m===void 0||e.substate==="awaiting-review"?null:e.approvedForForward?r.jsx(Q,{primary:!0,disabled:t,label:`Move to ${_e(m)}`,title:"The guard already allows this move (an approved review is on record).",onClick:()=>g(()=>eo(e.slug,e.stage))}):r.jsx(Q,{primary:!0,disabled:t,label:`Approve & move to ${_e(m)}`,title:"Director sign-off: records the review pair (request, approve) in the journal, then advances.",onClick:()=>g(()=>Qh(e.slug,e.stage))});return b===null&&l.length===0?null:r.jsxs("div",{className:"pb-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b,l.length>0&&r.jsx("button",{type:"button",className:"rounded border border-border bg-canvas px-2.5 py-1 font-display text-xs text-ink-muted shadow-sm hover:bg-surface hover:text-ink",onClick:()=>a(!o),children:o?"Cancel":"Move to an earlier stage…"})]}),o&&l.length>0&&r.jsxs("div",{className:"mt-2 rounded border border-border bg-surface p-3 text-sm shadow-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-ink-muted",children:"Back to"}),r.jsx("select",{className:"cursor-pointer rounded border border-border bg-transparent px-1.5 py-0.5 text-xs outline-none",value:c,onChange:v=>u(v.target.value),children:l.map(v=>r.jsx("option",{value:v,children:_e(v)},v))})]}),r.jsx("textarea",{className:"mt-2 w-full rounded border border-border bg-transparent p-2 text-sm outline-none focus:border-amber-300",rows:2,placeholder:"Why is this going back? (required)",value:h,onChange:v=>f(v.target.value)}),r.jsx("div",{className:"pt-1",children:r.jsx(Q,{disabled:t,label:`Move back to ${_e(c)}`,onClick:()=>g(()=>qd(e.slug,e.stage,c,h))})})]}),s!==null&&r.jsx("p",{className:"pt-2 text-xs text-red-600",children:s})]})}function np({loop:e}){const[t,n]=p.useState(""),[s,i]=p.useState(!1),[o,a]=p.useState(null),l=e.pending,c=l?.requestedState,u=c!==void 0?`Review the ${_e(c)} work`:"Review the submitted work",h=c!==void 0&&c!==e.stage?`Requested by the ${_e(c)} station; this skill has since moved to ${_e(e.stage)}.`:null,f=c??e.stage,m=g=>{i(!0),a(null),Qi(e.slug,f,g,t.length>0?t:void 0).then(b=>{i(!1),b.ok||a(b.error)})};return r.jsxs("div",{className:"rounded-xl border border-amber-300 bg-amber-50/60 p-4 shadow-sm",children:[r.jsx("div",{className:"pb-1 font-display text-xs uppercase tracking-widest text-ink-muted",children:"awaiting review"}),r.jsx("h2",{className:"font-display text-lg",children:u}),h!==null&&r.jsx("p",{className:"pt-1 text-xs text-ink-muted",children:h}),l?.question!==void 0&&r.jsx("p",{className:"pt-2 text-sm",children:l.question}),l!==void 0&&l.artifacts.length>0&&r.jsx("ul",{className:"pt-2 text-sm",children:l.artifacts.map(g=>r.jsx("li",{className:"font-mono text-xs text-ink-muted",children:g},g))}),r.jsx("textarea",{className:"mt-3 w-full rounded border border-border bg-surface p-2 text-sm outline-none focus:border-amber-300",rows:2,placeholder:"Notes — optional on approve, required to send back",value:t,onChange:g=>n(g.target.value)}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx(Q,{primary:!0,disabled:s,label:"Approve",onClick:()=>m("approve")}),r.jsx(Q,{disabled:s,label:"Send back with notes",title:"Send back requires notes — say what needs to change.",onClick:()=>m("revise")})]}),o!==null&&r.jsx("p",{className:"pt-2 text-xs text-red-600",children:o})]})}const sp="relative z-10 -mb-px cursor-pointer rounded-t-lg border border-b-0 border-neutral-900/50 bg-well px-3 pb-1.5 pt-2 font-mono text-[11px] uppercase text-ink",rp="cursor-pointer rounded-t-lg border border-b-0 border-border bg-canvas px-3 py-1.5 font-mono text-[11px] uppercase text-ink-muted hover:bg-well/70 hover:text-ink",Ve="current";function ip({slug:e,page:t,pinned:n,onOpenFile:s}){const[i,o]=p.useState("overview"),a=b=>{const v=t.events.find(y=>b.some(x=>y.type.startsWith(x)));return v===void 0?"":`${v.type}-${v.at}`},l=a(["station.","review."]),c=a(["run."]),[u,h]=p.useState(()=>{if(typeof window>"u")return{};try{return JSON.parse(window.localStorage.getItem(`sm-tab-seen-${e}`)??"{}")}catch{return{}}}),f=(b,v)=>{const y={...u,[b]:v};h(y);try{window.localStorage.setItem(`sm-tab-seen-${e}`,JSON.stringify(y))}catch{}},m=i!=="research"&&l!==""&&u.research!==l,g=i!=="eval"&&c!==""&&u.eval!==c;return r.jsxs("div",{className:"flex min-h-full flex-col",children:[r.jsx("div",{className:"w-full px-6 pt-4",children:r.jsxs("div",{className:"mx-auto max-w-3xl",children:[t.loop!==null&&r.jsx(ep,{loop:t.loop}),r.jsx("div",{className:"flex items-end gap-1",children:[{id:"overview",label:"Overview",onClick:()=>o("overview"),dot:!1},{id:"research",label:"Research",onClick:()=>{o("research"),f("research",l)},dot:m},{id:"eval",label:"Eval",onClick:()=>{o("eval"),f("eval",c)},dot:g},{id:"publish",label:"Publish",onClick:()=>o("publish"),dot:!1}].map(b=>r.jsxs("button",{type:"button",onClick:b.onClick,className:i===b.id?sp:rp,children:[b.label,b.dot&&r.jsx("span",{className:"ml-1.5 inline-block h-1.5 w-1.5 rounded-full bg-amber-500 align-middle"})]},b.id))})]})}),r.jsx("div",{className:"flex-1 border-t border-neutral-900/50 bg-well",children:r.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[i==="overview"&&r.jsx(cp,{page:t,pinned:n,onOpenFile:s}),i==="research"&&r.jsx(dp,{slug:e,onOpenFile:s}),i==="eval"&&r.jsx(Gh,{page:t}),i==="publish"&&r.jsx(fp,{page:t,pinned:n})]})})]})}function op({slug:e,page:t,pinned:n,onPin:s}){const[i,o]=p.useState(!1),[a,l]=p.useState(!1),c=t.versions.find(u=>u.hash===n);return r.jsxs("div",{className:"relative flex items-center gap-1.5",children:[r.jsx("button",{type:"button",className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded hover:bg-surface ${n===Ve?"text-ink-muted hover:text-ink":"bg-amber-600/15 text-amber-700"}`,title:n===Ve?"Version history — every tab is a lens on the selected draft":`Viewing version ${c?.shortHash??n} — click to change`,onClick:()=>{l(!a),o(!1)},children:r.jsx(ap,{})}),a&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close",className:"fixed inset-0 z-20 cursor-default",onClick:()=>l(!1)}),r.jsxs("div",{className:"absolute right-0 top-9 z-30 w-56 rounded border border-border bg-surface py-1 shadow-xl",children:[r.jsx(pr,{selected:n===Ve,label:"Current draft",detail:null,onPick:()=>{s(Ve),l(!1)}}),t.versions.length>0&&r.jsx("div",{className:"mx-2 my-1 border-t border-border"}),t.versions.map(u=>r.jsx(pr,{selected:n===u.hash,label:u.shortHash,detail:u.label,onPick:()=>{s(u.hash),l(!1)}},u.hash)),t.versions.length===0&&r.jsx("p",{className:"px-3 py-1.5 text-xs text-ink-muted",children:"No recorded versions yet."})]})]}),r.jsx("button",{type:"button",className:"cursor-pointer rounded bg-amber-600 px-3 py-1 font-display text-sm text-white shadow hover:bg-amber-700",onClick:()=>{o(!i),l(!1)},children:"Publish"}),i&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close",className:"fixed inset-0 z-20 cursor-default",onClick:()=>o(!1)}),r.jsx("div",{className:"absolute right-0 top-9 z-30 w-72 rounded border border-border bg-surface p-3 shadow-xl",children:t.loop===null?r.jsx("p",{className:"text-xs text-ink-muted",children:"Stage actions need the server."}):r.jsx(tp,{loop:t.loop})})]})]})}function ap(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[r.jsx("path",{d:"M 13.8 6.2 A 6 6 0 1 0 14 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("path",{d:"M 14.6 2.9 L 13.8 6.2 L 10.9 5.2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M 8 5.2 V 8 L 10 9.4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function pr({selected:e,label:t,detail:n,onPick:s}){return r.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-well",onClick:s,children:[r.jsx("span",{className:`w-3 shrink-0 ${e?"text-ink":"text-transparent"}`,children:"✓"}),r.jsx("span",{className:e?"text-ink":"text-ink-muted",children:t}),n!==null&&r.jsx("span",{className:"truncate text-ink-muted/70",children:n})]})}function cp({page:e,pinned:t,onOpenFile:n}){return r.jsxs("div",{className:"text-sm",children:[t!==Ve&&r.jsx("p",{className:"pb-2 text-xs text-ink-muted",children:"Showing the current draft — historical snapshots arrive with the version store."}),e.instructions===null?r.jsx("p",{className:"text-ink-muted",children:"No SKILL.md yet — start a chat and frame it."}):r.jsxs(r.Fragment,{children:[r.jsx(ln,{markdown:lp(e.instructions)}),r.jsx("button",{type:"button",className:"mt-3 cursor-pointer rounded border border-border bg-canvas px-3 py-1.5 font-display text-xs text-ink-muted hover:text-ink",onClick:()=>n("output/SKILL.md"),children:"Open full SKILL.md in Files"})]})]})}function lp(e){const t=e.split(`
|
|
30
|
+
`);let n=0;const s=[];for(const i of t){if(/^#{1,3} /.test(i)&&(n+=1,n===2))break;s.push(i)}return s.join(`
|
|
31
|
+
`).trim()}const up=["research/notes.md","research/decisions.md"];function dp({slug:e,onOpenFile:t}){const n=p.useCallback(async()=>(await Promise.all(up.map(o=>Rs(e,o).then(a=>({path:o,content:a}),()=>null)))).filter(o=>o!==null).map(o=>({path:o.path,content:o.content})),[e]),s=nt(n,null);return r.jsxs("div",{className:"text-sm",children:[s===null&&r.jsx("p",{className:"text-ink-muted",children:"Loading research…"}),s!==null&&s.length===0&&r.jsx("p",{className:"text-ink-muted",children:"No research yet — run the research station or ask the agent to gather sources."}),s!==null&&s.map(i=>r.jsxs("details",{open:i.path.endsWith("notes.md"),className:"mb-3",children:[r.jsxs("summary",{className:"cursor-pointer font-display text-xs uppercase text-ink-muted hover:text-ink",children:[i.path.replace("research/",""),r.jsx("button",{type:"button",className:"ml-2 cursor-pointer text-[10px] underline",onClick:o=>{o.preventDefault(),t(i.path)},children:"open in Files"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto pt-1",children:r.jsx(ln,{markdown:i.content})})]},i.path))]})}function fp({page:e,pinned:t}){return r.jsxs("div",{className:"text-sm",children:[r.jsxs("p",{className:"text-ink-muted",children:["Publishing writes the selected draft over the skill's live ",r.jsx("span",{className:"font-mono text-xs",children:"SKILL.md"}),", stamped with its evidence state."]}),r.jsx("h3",{className:"pt-3 font-display text-xs uppercase text-ink-muted",children:"Versions"}),r.jsxs("div",{className:"mt-1 space-y-1",children:[r.jsx(mr,{active:t===Ve,title:"Current draft",subtitle:e.drift,action:r.jsx("button",{type:"button",className:"rounded bg-amber-600 px-2.5 py-1 font-display text-xs text-white opacity-50",title:"Publish flow lands with the version snapshot store — design in progress",disabled:!0,children:"Publish"})}),e.versions.map(n=>r.jsx(mr,{active:t===n.hash,title:n.shortHash+(n.label!==null?` · ${n.label}`:""),subtitle:`recorded ${new Date(n.recordedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}`,action:r.jsx("button",{type:"button",className:"rounded border border-border px-2.5 py-1 font-display text-xs text-ink-muted opacity-50",title:"Revert requires the version snapshot store (versions are hashes today, not content)",disabled:!0,children:"Revert"})},n.hash)),e.versions.length===0&&r.jsx("p",{className:"text-xs text-ink-muted",children:"No versions recorded yet."})]}),r.jsx("p",{className:"pt-3 text-xs text-ink-muted",children:"Evidence per version lives in the Eval tab — pin a version in the top bar and switch tabs to see its measurements."})]})}function mr({active:e,title:t,subtitle:n,action:s}){return r.jsxs("div",{className:`flex items-center gap-2 rounded border px-2 py-1.5 ${e?"border-amber-400 bg-canvas":"border-border"}`,children:[r.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[r.jsx("span",{className:"font-mono text-xs",children:t}),r.jsx("span",{className:"pl-2 text-xs text-ink-muted",children:n})]}),s]})}function $s(e){const t=p.useCallback(()=>Hf(e),[e]);return nt(t,ch)}function hp({onOpenSkill:e}){const t=nt(Wf,Wn);return r.jsxs("div",{className:"p-6",children:[r.jsx("h1",{className:"pb-4 font-display text-2xl",children:"Board"}),r.jsx("div",{className:"grid grid-cols-5 gap-3",children:ro.map(n=>r.jsxs("div",{className:"rounded border border-border bg-paper p-2",children:[r.jsx("div",{className:`mb-2 inline-block rounded px-2 py-0.5 font-display text-xs ${Es[n]}`,children:n}),t.flatMap(s=>s.skills.filter(i=>i.stage===n).map(i=>r.jsxs("button",{type:"button",onClick:()=>e(s,i.slug),className:"mb-2 block w-full rounded bg-surface p-2 text-left shadow-sm hover:shadow",children:[r.jsx("div",{className:`font-display text-sm ${re}`,children:i.slug}),r.jsx("div",{className:`text-xs text-ink-muted ${re}`,children:s.name})]},`${s.name}/${i.slug}`)))]},n))}),r.jsx("p",{className:"pt-3 text-xs text-ink-muted",children:"All projects · Archived: drawer"})]})}function pp(){const{data:e,status:t}=Xf(fo),n=t==="error"?ho:e??[];return r.jsxs("div",{className:"p-6",children:[r.jsx("h1",{className:"pb-4 font-display text-2xl",children:"Tasks"}),t==="live"&&n.length===0&&r.jsx("p",{className:"text-sm text-ink-muted",children:"No open tasks."}),r.jsx("div",{className:"max-w-2xl space-y-2",children:n.map(s=>r.jsxs("div",{className:"flex items-center justify-between rounded border border-border bg-surface p-3 shadow-sm",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:`text-sm ${re}`,children:s.title}),r.jsx("div",{className:"text-xs text-ink-muted",children:s.origin})]}),r.jsx(Q,{label:s.state==="open"?"Start":"In progress"})]},s.title))})]})}function vo({slug:e,elevated:t}){const n=$s(e);return r.jsxs("div",{className:`w-56 rounded border border-border bg-surface p-3 text-sm ${t?"shadow-xl":"shadow-md"}`,children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-ink-muted",children:"Stage"}),r.jsx("span",{className:`rounded px-1.5 text-xs ${Es[n.stage]}`,children:n.stage})]}),r.jsxs("div",{className:"flex justify-between pt-1",children:[r.jsx("span",{className:"text-ink-muted",children:"Version"}),r.jsx("span",{className:"font-mono text-xs",children:n.versionShort??"none"})]}),r.jsxs("div",{className:"flex justify-between pt-1",children:[r.jsx("span",{className:"text-ink-muted",children:"Drift"}),r.jsx("span",{className:"text-xs",children:n.drift})]}),r.jsxs("div",{className:"flex justify-between pt-1",children:[r.jsx("span",{className:"text-ink-muted",children:"Proven on"}),r.jsx("span",{className:"text-xs",children:n.provenOn})]}),r.jsxs("div",{className:"flex justify-between pt-1",children:[r.jsx("span",{className:"text-ink-muted",children:"Coverage"}),r.jsx("span",{className:"text-xs",children:n.coverage})]})]})}function mp({slug:e,pinned:t,overviewOpen:n,onOpenFile:s}){const i=$s(e);return r.jsxs("div",{className:"flex min-h-full",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(ip,{slug:e,page:i,pinned:t,onOpenFile:s})}),r.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-200 ease-out ${n?"w-[244px]":"w-0"}`,children:r.jsx("div",{className:"sticky top-0 mr-[10px] mt-[10px]",children:r.jsx(vo,{slug:e})})})]})}function xp({slug:e,pinned:t,onPin:n}){const s=$s(e);return r.jsx(op,{slug:e,page:s,pinned:t,onPin:n})}function Up(){Co();const[e,t]=p.useState(!0),[n,s]=p.useState(!0),[i,o]=p.useState({kind:"board"}),[a,l]=p.useState(!0),[c,u]=p.useState(null),[h,f]=p.useState("current"),[m,g]=p.useState(!1),[b,v]=p.useState(null),y=Sn("left","sm-next-leftw",256,180,440),x=Sn("right","sm-next-rightw",320,240,()=>Math.max(340,window.innerWidth-300-(e?y.width:0))),w=y.dragging||x.dragging,[N,C]=p.useState(!1),R=i.kind==="skill",F=R&&n,A=F&&N,K=i.kind==="board"?"Board":i.kind==="tasks"?"Tasks":i.kind==="new-skill"?"New skill":i.slug,k=a&&!F,j=()=>{F?g(!m):l(!a)},P=D=>{if(!m)return;const S=D.target;S.closest("[data-overview-overlay]")||S.closest("[data-overview-toggle]")||g(!1)};return r.jsxs("div",{className:`relative flex h-screen overflow-hidden bg-canvas ${w?"cursor-col-resize select-none":""}`,onMouseDownCapture:P,children:[r.jsx(Ue,{active:e,onClick:()=>t(!e),title:e?"Hide sidebar":"Show sidebar",className:"absolute left-2 top-2 z-20",children:r.jsx($o,{})}),F&&r.jsx(Ue,{active:N,onClick:()=>C(!N),title:N?"Restore layout":"Expand panel",className:"absolute right-10 top-2 z-20",children:N?r.jsx(Mo,{}):r.jsx(Fo,{})}),R&&r.jsx(Ue,{active:n,onClick:()=>s(!n),title:n?"Hide panel":"Show panel",className:"absolute right-2 top-2 z-20",children:r.jsx(Io,{})}),r.jsxs("aside",{className:`relative shrink-0 overflow-hidden border-border bg-paper ${y.dragging?"":"transition-[width] duration-200 ease-out"} ${e?"border-r":""}`,style:{width:e?y.width:0},children:[r.jsx("div",{className:"h-full",style:{width:y.width},children:r.jsx(Ph,{center:i,onNavigate:o})}),e&&r.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:y.onDragStart,title:"Drag to resize"})]}),r.jsxs("div",{className:`relative flex min-w-[300px] flex-col ${A?"hidden":"flex-1"}`,children:[i.kind==="skill"&&m&&r.jsx("div",{"data-overview-overlay":!0,className:"absolute right-[10px] top-[54px] z-30",children:r.jsx(vo,{slug:i.slug,elevated:!0})}),r.jsxs("header",{className:"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[!e&&r.jsx("span",{className:"w-7 shrink-0"}),r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[(i.kind==="skill"||i.kind==="new-skill")&&r.jsxs("span",{className:"shrink-0 whitespace-nowrap font-display text-sm text-ink-muted",children:[i.project," /"]}),r.jsx("span",{className:"truncate font-display text-sm",title:K,children:K}),R&&r.jsx("span",{className:"text-ink-muted",children:"···"})]}),i.kind==="skill"&&r.jsx(xp,{slug:i.slug,pinned:h,onPin:f}),R&&r.jsx(Ue,{active:k||m,onClick:j,title:k||m?"Hide overview":"Show overview","data-overview-toggle":!0,children:r.jsx(_o,{})}),R&&!n&&r.jsx("span",{className:"w-7 shrink-0"})]}),r.jsxs("main",{className:"relative flex-1 overflow-y-auto",children:[i.kind==="board"&&r.jsx(hp,{onOpenSkill:(D,S)=>{De(D.slug),o({kind:"skill",project:D.name,slug:S})}}),i.kind==="tasks"&&r.jsx(pp,{}),i.kind==="skill"&&r.jsx(mp,{slug:i.slug,pinned:h,overviewOpen:k,onOpenFile:D=>{s(!0),u(D)}}),i.kind==="new-skill"&&r.jsx(sf,{project:i.project,onCreated:(D,S,$,O,_)=>{v({slug:D,provider:S,message:$,...O!==void 0?{model:O}:{},..._!==void 0?{effort:_}:{}}),o({kind:"skill",project:i.project,slug:D}),s(!0)},onAdopted:D=>o({kind:"skill",project:i.project,slug:D})})]})]}),r.jsxs("aside",{className:`relative overflow-hidden border-border bg-paper ${x.dragging||A?"":"transition-[width] duration-200 ease-out"} ${F?"border-l":""} ${A?"flex-1":"shrink-0"}`,style:A?void 0:{width:F?x.width:0},children:[F&&!A&&r.jsx("div",{className:"absolute inset-y-0 left-0 z-10 w-2 cursor-col-resize hover:bg-amber-400/40",onMouseDown:x.onDragStart,title:"Drag to resize"}),r.jsx("div",{className:"h-full",style:A?void 0:{width:x.width},children:R&&r.jsx(uh,{skill:i.slug,width:A?9999:x.width,fileRequest:c,onFileRequestHandled:()=>u(null),intro:b!==null&&b.slug===i.slug?b:null,onIntroConsumed:()=>v(null)})})]})]})}export{Up as default};
|