@ogygie/studio 0.25.0 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -2648,7 +2648,7 @@ function previewsDirOf(specId, composition = null) {
2648
2648
  return composition === null ? `${PREVIEWS_DIR}/${specId}` : `${PREVIEWS_DIR}/${specId}/${composition}`;
2649
2649
  }
2650
2650
  function previewSpecIdOf(path) {
2651
- const match = /^previews\/([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\//.exec(path);
2651
+ const match = /^previews\/([a-z][a-z0-9]*(?:-[a-z0-9]+)*)(?:\/|$)/.exec(path);
2652
2652
  return match?.[1] ?? null;
2653
2653
  }
2654
2654
  function orderStates(states) {
@@ -2755,7 +2755,7 @@ function createHostedSpecStorage(deps) {
2755
2755
  return defaultReader.currentRef();
2756
2756
  },
2757
2757
  async listDirectory(path) {
2758
- const entries = await defaultReader.listDirectory(path);
2758
+ const entries = await (await readerOf(path)).listDirectory(path);
2759
2759
  if (path.replace(/\/$/, "") !== "specs") return entries;
2760
2760
  const known = new Set(entries.map((entry) => entry.path));
2761
2761
  const extra = [];
@@ -65,7 +65,7 @@ ${s.join(`
65
65
 
66
66
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of t.seen.entries()){const h=d[1];if(i===d[0]){c(d);continue}if(t.external){const p=t.external.registry.get(d[0])?.id;if(i!==d[0]&&p){c(d);continue}}if(t.metadataRegistry.get(d[0])?.id){c(d);continue}if(h.cycle){c(d);continue}h.count>1&&t.reused==="ref"&&c(d)}t.external&&(t.sharedDefsExtractedFor=t.external)}function Qb(t){const i=t.anyOf;if(!Array.isArray(i)||i.length===0||t.type!==void 0)return;const s=[];for(const r of i){if(!r||typeof r!="object")return;Qb(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const c=r.type;for(const d of Array.isArray(c)?c:[c]){if(typeof d!="string")return;s.includes(d)||s.push(d)}}delete t.anyOf,t.type=s.length===1?s[0]:s}const Gb=new Set(["type","properties","required","additionalProperties"]),Yy=["oneOf","anyOf"];function Vy(t){const i=t.additionalProperties;return i===void 0||i===!1||typeof i!="object"||i===null?null:Object.keys(i).length?i:null}function Kf(t){const i=[];for(const c of t){if(typeof c!="object"||c.type!=="object")return null;for(const d in c)if(!Gb.has(d))return null;i.push(c)}const s={},r=new Set;for(const c of i){for(const d in c.properties){if(Object.prototype.hasOwnProperty.call(s,d))continue;const h=[];for(const p of i){const v=p.properties?.[d]??Vy(p);v!=null&&(h.some(g=>JSON.stringify(g)===JSON.stringify(v))||h.push(v))}const m=h.length===1?h[0]:Kf(h)??{allOf:h};zi(s,d,m)}for(const d of c.required??[])r.add(d)}const o={type:"object",properties:s};if(r.size&&(o.required=[...r]),i.every(c=>c.additionalProperties===!1))o.additionalProperties=!1;else{const c=[];for(const d of i){const h=Vy(d);h&&!c.some(m=>JSON.stringify(m)===JSON.stringify(h))&&c.push(h)}c.length===1?o.additionalProperties=c[0]:c.length>1&&(o.additionalProperties={allOf:c})}return o}function zz(t){const i=t.allOf;if(!Array.isArray(i)||i.length<2)return;for(const o of Gb)if(o in t)return;const s=i.filter(o=>Yy.some(c=>Array.isArray(o[c])));let r=null;if(!s.length)r=Kf(i);else{const o=s[0],c=Yy.find(m=>Array.isArray(o[m]));if(Object.keys(o).length!==1)return;const d=i.filter(m=>m!==o),h=o[c].map(m=>Kf([...d,m]));if(h.some(m=>!m))return;r={[c]:h}}r&&(delete t.allOf,dr(t,r))}function Kb(t,i){const s=t.seen.get(i);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=h=>{const m=t.seen.get(h);if(m.ref===null)return;const p=m.def??m.schema,v={...p},g=m.ref;if(m.ref=null,g){r(g);const S=t.seen.get(g),E=S.schema;if(E.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(E)):dr(p,E),dr(p,v),h._zod.parent===g)for(const T in p)T==="$ref"||T==="allOf"||T in v||delete p[T];if(E.$ref&&S.def)for(const T in p)T==="$ref"||T==="allOf"||T in S.def&&JSON.stringify(p[T])===JSON.stringify(S.def[T])&&delete p[T]}const x=h._zod.parent;if(x&&x!==g){r(x);const S=t.seen.get(x);if(S?.schema.$ref&&(p.$ref=S.schema.$ref,S.def))for(const E in p)E==="$ref"||E==="allOf"||E in S.def&&JSON.stringify(p[E])===JSON.stringify(S.def[E])&&delete p[E]}t.override({zodSchema:h,jsonSchema:p,path:m.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(const h of[...t.seen.entries()].reverse())r(h[0]);if(t.target!=="openapi-3.0")for(const h of t.seen.entries())Qb(h[1].def??h[1].schema);for(const h of t.deferred)h();if(t.intersections.length){const h=new Map;for(const m of t.seen.values())for(const p of[m.schema,m.def]){const v=p?.allOf;if(!Array.isArray(v))continue;const g=h.get(v);g?g.push(p):h.set(v,[p])}for(const m of t.intersections)for(const p of h.get(m)??[])zz(p)}}const o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const h=t.external.registry.get(i)?.id;if(!h)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(h)}dr(o,s.defId?s.schema:s.def??s.schema);const c=t.metadataRegistry.get(i)?.id;c!==void 0&&o.id===c&&delete o.id;const d=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(const h of t.seen.entries()){const m=h[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,zi(d,m.defId,m.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(d).length>0&&(t.target==="draft-2020-12"?o.$defs=d:o.definitions=d);try{const h=JSON.parse(JSON.stringify(o));return Object.defineProperty(h,"~standard",{value:{...i["~standard"],jsonSchema:{input:_o(i,"input",t.processors),output:_o(i,"output",t.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function yt(t,i){const s=i??{seen:new Set};if(s.seen.has(t))return!1;s.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return yt(r.element,s);if(r.type==="set")return yt(r.valueType,s);if(r.type==="lazy")return yt(r.getter(),s);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return yt(r.innerType,s);if(r.type==="intersection")return yt(r.left,s)||yt(r.right,s);if(r.type==="record"||r.type==="map")return yt(r.keyType,s)||yt(r.valueType,s);if(r.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:yt(r.in,s)||yt(r.out,s);if(r.type==="object"){for(const o in r.shape)if(yt(r.shape[o],s))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(yt(o,s))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(yt(o,s))return!0;return!!(r.rest&&yt(r.rest,s))}return!1}const Tz=(t,i={})=>s=>{const r=Hb({...s,processors:i});return tt(t,r),$b(r,t),Kb(r,t)},_o=(t,i,s={})=>r=>{const{libraryOptions:o,target:c}=r??{},d=Hb({...o??{},target:c,io:i,processors:s});return tt(t,d),$b(d,t),Kb(d,t)},ns=(t,i,s)=>{(t[i]===void 0||s>t[i])&&(t[i]=s)},is=(t,i,s)=>{(t[i]===void 0||s<t[i])&&(t[i]=s)},Fy=(t,i)=>{ns(t,"minimum",i),is(t,"maximum",i)},Yb=(t,i)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(i)||t.multipleOf.push(i)},Vb=(t,i)=>{t.patterns??(t.patterns=new Set),t.patterns.add(i)},Fb=(t,i)=>{t.mime=t.mime?t.mime.filter(s=>i.includes(s)):[...i]},Pb=(t,i)=>{t.format=i,i.includes("int")&&(t.isInt=!0)},Py=(t,i)=>ns(t,"minimum",i.minimum),Xy=(t,i)=>is(t,"maximum",i.maximum),Jy=t=>(i,s)=>{Pb(i,s.format);const[r,o]=t[s.format];ns(i,"minimum",r),is(i,"maximum",o)},jz={greater_than:(t,i)=>ns(t,i.inclusive?"minimum":"exclusiveMinimum",i.value),less_than:(t,i)=>is(t,i.inclusive?"maximum":"exclusiveMaximum",i.value),multiple_of:(t,i)=>Yb(t,i.value),number_format:Jy(pb),bigint_format:Jy(YE),min_length:Py,max_length:Xy,length_equals:(t,i)=>Fy(t,i.length),min_size:Py,max_size:Xy,size_equals:(t,i)=>Fy(t,i.size),string_format:(t,i)=>{Pb(t,i.format),i.pattern&&Vb(t,i.pattern),(i.format==="base64"||i.format==="base64url")&&(t.contentEncoding=i.format),(i.local||i.precision===-1)&&(t.laxFormat=!0)},mime_type:(t,i)=>Fb(t,i.mime)};function rn(t){const i={},s=t._zod.def,r=t._zod.traits.has("$ZodCheck")?[t,...s.checks??[]]:s.checks??[];for(const c of r)jz[c._zod.def.check]?.(i,c._zod.def);const o=t._zod.bag;o.minimum!==void 0&&ns(i,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&ns(i,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&is(i,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&is(i,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Yb(i,o.multipleOf),o.format!==void 0&&(i.format??(i.format=o.format),o.format.includes("int")&&(i.isInt=!0)),o.mime&&Fb(i,o.mime);for(const c of o.patterns??[])Vb(i,c);return i}const Nz={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Az=new Map([[Ab,VO],[_d,FO]]),Xb=t=>Az.get(t)??t,Rz=(t,i,s,r)=>{const o=s;o.type="string";const{minimum:c,maximum:d,format:h,patterns:m,contentEncoding:p,laxFormat:v}=rn(t);if(typeof c=="number"&&(o.minLength=c),typeof d=="number"&&(o.maxLength=d),h&&(o.format=Nz[h]??h,o.format===""&&delete o.format,(h==="time"||v)&&delete o.format),p&&(o.contentEncoding=p),m&&m.size>0){const g=[...m].map(Xb);g.length===1?o.pattern=g[0].source:g.length>1&&(o.allOf=[...g.map(x=>({...i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"?{type:"string"}:{},pattern:x.source}))])}},Cz=(t,i,s,r)=>{const o=s,{minimum:c,maximum:d,multipleOf:h,exclusiveMaximum:m,exclusiveMinimum:p,isInt:v}=rn(t);o.type=v?"integer":"number";const g=typeof p=="number"&&p>=(c??Number.NEGATIVE_INFINITY),x=typeof m=="number"&&m<=(d??Number.POSITIVE_INFINITY),S=i.target==="draft-04"||i.target==="openapi-3.0";if(g?S?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof c=="number"&&(o.minimum=c),x?S?(o.maximum=m,o.exclusiveMaximum=!0):o.exclusiveMaximum=m:typeof d=="number"&&(o.maximum=d),h){const E=new Set;for(const R of h)Number.isFinite(R)&&R!==0?E.add(Math.abs(R)):Ei(t,i,o,r,`A multipleOf divisor of ${R} cannot be represented in JSON Schema`);const[O,...T]=E;O!==void 0&&(o.multipleOf=O),T.length&&(o.allOf=[...o.allOf??[],...T.map(R=>({multipleOf:R}))])}},Mz=(t,i,s,r)=>{s.type="boolean"},Dz=(t,i,s,r)=>{s.not={}},kz=(t,i,s,r)=>{},Uz=(t,i,s,r)=>{const o=t._zod.def,c=qf(o.entries);if(c.length===0){s.not={};return}c.every(d=>typeof d=="number")&&(s.type="number"),c.every(d=>typeof d=="string")&&(s.type="string"),s.enum=c},Lz=(t,i,s,r)=>{const o=t._zod.def;if(o.values.length===0){s.not={};return}const c=[];for(const d of o.values)if(d===void 0){if(Ei(t,i,s,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof d=="bigint"){if(Ei(t,i,s,r,"BigInt literals cannot be represented in JSON Schema"))return;c.push(Number(d))}else c.push(d);if(c.length!==0)if(c.length===1){const d=c[0];s.type=d===null?"null":typeof d,i.target==="draft-04"||i.target==="openapi-3.0"?s.enum=[d]:s.const=d}else c.every(d=>typeof d=="number")&&(s.type="number"),c.every(d=>typeof d=="string")&&(s.type="string"),c.every(d=>typeof d=="boolean")&&(s.type="boolean"),c.every(d=>d===null)&&(s.type="null"),s.enum=c},Zz=(t,i,s,r)=>{Ei(t,i,s,r,"Custom types cannot be represented in JSON Schema")},qz=(t,i,s,r)=>{Ei(t,i,s,r,"Transforms cannot be represented in JSON Schema")},Bz=(t,i,s,r)=>{const o=s,c=t._zod.def,{minimum:d,maximum:h}=rn(t);typeof d=="number"&&(o.minItems=d),typeof h=="number"&&(o.maxItems=h),o.type="array",o.items=tt(c.element,i,{...r,path:[...r.path,"items"]})};function Eo(t){const i=t._zod.def;return i.type==="pipe"&&i.in._zod.traits.has("$ZodTransform")?Eo(i.out):i.type==="catch"?Eo(i.innerType):t._zod.optin}const Hz=(t,i,s,r)=>{const o=s,c=t._zod.def,d=c.shape;if(Object.getOwnPropertySymbols(d).length&&Ei(t,i,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const p in d)zi(o.properties,p,tt(d[p],i,{...r,path:[...r.path,"properties",p]}));const m=[];for(const p of Object.keys(d)){const v=c.shape[p];(i.io==="input"?Eo(v)===void 0:v._zod.optout===void 0)&&m.push(p)}m.length>0&&(o.required=m),c.catchall?._zod.def.type==="never"?o.additionalProperties=!1:c.catchall?c.catchall&&(o.additionalProperties=tt(c.catchall,i,{...r,path:[...r.path,"additionalProperties"]})):i.io==="output"&&(o.additionalProperties=!1)},$z=(t,i,s,r)=>{const o=t._zod.def,c=o.inclusive===!1,d=o.options.map((h,m)=>tt(h,i,{...r,path:[...r.path,c?"oneOf":"anyOf",m]}));c?s.oneOf=d:s.anyOf=d},Qz=(t,i,s,r)=>{const o=t._zod.def,c=tt(o.left,i,{...r,path:[...r.path,"allOf",0]}),d=tt(o.right,i,{...r,path:[...r.path,"allOf",1]}),h=p=>"allOf"in p&&Object.keys(p).length===1,m=[...h(c)?c.allOf:[c],...h(d)?d.allOf:[d]];s.allOf=m,i.intersections.push(m)};function Yf(t,i,s){if(i.$ref){if(s.has(i))return i;s.add(i);const E=t.get(i)?.def;if(!E)return i;const O=Yf(t,E,s);return O===E?i:O}for(const E of["anyOf","oneOf"]){const O=i[E];if(!Array.isArray(O))continue;const T=O.map(R=>Yf(t,R,s));T.some((R,q)=>R!==O[q])&&(i={...i,[E]:T})}const r=Array.isArray(i.type)?i.type:[i.type],o=!r.includes("string")&&r.some(E=>E==="number"||E==="integer"),c=i.enum??(i.const!==void 0?[i.const]:void 0);if(!o&&!c?.some(E=>typeof E=="number"))return i;const{minimum:d,maximum:h,exclusiveMinimum:m,exclusiveMaximum:p,multipleOf:v,format:g,id:x,...S}=i;return S.enum?S.enum=S.enum.map(E=>typeof E=="number"?String(E):E):typeof S.const=="number"&&(S.const=String(S.const)),o&&(S.type="string",c||(S.pattern=(r.includes("number")?bd:n2).source)),S}const Vf=new WeakMap;function Gz(t){const i=new Map;for(const r of t.seen.values())r.def&&!i.has(r.schema)&&i.set(r.schema,r);const s=new Map;for(const r of Vf.get(t)??[]){const o=t.seen.get(r),c=(o?.def??o?.schema)?.propertyNames;if(!c||c===!0||s.has(c))continue;const d=Yf(i,c,new Set);d!==c&&s.set(c,d)}if(s.size)for(const r of t.seen.values())for(const o of[r.schema,r.def]){const c=o&&s.get(o.propertyNames);c&&(o.propertyNames=c)}}const Kz=(t,i,s,r)=>{const o=s,c=t._zod.def;o.type="object";const d=c.keyType,h=rn(d).patterns;if(c.mode==="loose"&&h&&h.size>0){const v=tt(c.valueType,i,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const g of h)zi(o.patternProperties,Xb(g).source,v)}else{if(i.target==="draft-07"||i.target==="draft-2020-12"){o.propertyNames=tt(c.keyType,i,{...r,path:[...r.path,"propertyNames"]});let v=Vf.get(i);v||(v=[],Vf.set(i,v),i.deferred.push(()=>Gz(i))),v.push(t)}o.additionalProperties=tt(c.valueType,i,{...r,path:[...r.path,"additionalProperties"]})}const m=d._zod.values,p=i.io==="input"&&Eo(c.valueType)!==void 0;if(m&&!c.partial&&!p){const v=[...m].filter(g=>typeof g=="string"||typeof g=="number");v.length>0&&(o.required=v.map(String))}},Yz=(t,i,s,r)=>{const o=t._zod.def,c=tt(o.innerType,i,r),d=i.seen.get(t);i.target==="openapi-3.0"?(d.ref=o.innerType,s.nullable=!0):s.anyOf=[c,{type:"null"}]},Vz=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);c.ref=o.innerType},Ed=Symbol();function Jb(t,i,s,r,o){let c=!1;const d=JSON.stringify(t,(h,m)=>typeof m!="bigint"?m:(c=!0,null));return c?(Ei(i,s,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ed):JSON.parse(d)}const Fz=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);c.ref=o.innerType;const d=Jb(o.defaultValue,t,i,s,r);d!==Ed&&(s.default=d)},Pz=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);if(c.ref=o.innerType,i.io!=="input")return;const d=Jb(o.defaultValue,t,i,s,r);d!==Ed&&(s._prefault=d)},Xz=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);c.ref=o.innerType;let d;try{d=o.catchValue(void 0)}catch{Ei(t,i,s,r,"Dynamic catch values are not supported in JSON Schema");return}s.default=d},Jz=(t,i,s,r)=>{const o=t._zod.def,c=o.in._zod.traits.has("$ZodTransform"),d=i.io==="input"?c?o.out:o.in:o.out;tt(d,i,r);const h=i.seen.get(t);h.ref=d},Iz=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);c.ref=o.innerType,s.readOnly=!0},Ib=(t,i,s,r)=>{const o=t._zod.def;tt(o.innerType,i,r);const c=i.seen.get(t);c.ref=o.innerType},Iy=new WeakSet([Object.prototype,Error.prototype]);function Jl(t,i,s){Object.defineProperty(t,i,{configurable:!0,enumerable:!1,get(){const r=s(this);return Object.defineProperty(this,i,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,i,{value:r,configurable:!0,writable:!0})}})}const Wz=(t,i)=>{mO.init(t,i),t.name="ZodError";const s=Object.getPrototypeOf(t);Iy.has(s)||(Iy.add(s),Jl(s,"format",r=>o=>yO(r,o)),Jl(s,"flatten",r=>o=>gO(r,o)),Jl(s,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Bf,2)}),Jl(s,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Bf,2)}),Object.defineProperty(s,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},en=$("ZodError",Wz,void 0,{Parent:Error}),eT=pd(en),tT=gd(en),nT=yd(en),iT=vd(en),aT=EO(en),sT=OO(en),rT=wO(en),lT=zO(en),oT=TO(en),uT=jO(en),cT=NO(en),fT=AO(en);function dT(){ln.localeError||pn(Rw())}function Mo(){ln.memoizer||pn({memoizer:jw()})}const Ke=$("ZodType",(t,i)=>(dT(),Ge.init(t,i),t.def=i,t.type=i.type,t),{check(...t){const i=this.def;return this.clone($t(i,{checks:[...i.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,i){return Ti(this,t,i)},brand(){return this},register(t,i){return t.add(this,i),this},refine(t,i){return this.check(sj(t,i))},superRefine(t,i){return this.check(rj(t,i))},overwrite(t){return this.check(ls(t))},optional(){return tv(this)},exactOptional(){return VT(this)},nullable(){return nv(this)},nullish(){return tv(nv(this))},nonoptional(t){return IT(this,t)},array(){return _e(this)},or(t){return Do([this,t])},and(t){return $T(this,t)},transform(t){return iv(this,YT(t))},default(t){return PT(this,t)},prefault(t){return JT(this,t)},catch(t){return ej(this,t)},pipe(t){return iv(this,t)},readonly(){return ij(this)},describe(t){const i=this.clone();return ur.add(i,{description:t}),i},meta(...t){if(t.length===0)return ur.get(this);const i=this.clone();return ur.add(i,t[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...i){return i.length===0?t(this):t(this,...i)},get"~standard"(){return yb(this,"~standard",{...wb(this),jsonSchema:{input:_o(this,"input"),output:_o(this,"output")}})},set"~standard"(t){_i(this,"~standard",t)},parse:function t(i,s){return eT(this,i,s,{callee:t})},parseAsync:async function t(i,s){return await tT(this,i,s,{callee:t})},safeParse(t,i){return nT(this,t,i)},async safeParseAsync(t,i){return iT(this,t,i)},get spa(){return this?.safeParseAsync},set spa(t){_i(this,"spa",t)},validate(t,i){return SO(this,t,i)},validateAsync(t,i){return _O(this,t,i)},encode:function t(i,s){return aT(this,i,s,{callee:t})},decode:function t(i,s){return sT(this,i,s,{callee:t})},encodeAsync:async function t(i,s){return await rT(this,i,s,{callee:t})},decodeAsync:async function t(i,s){return await lT(this,i,s,{callee:t})},safeEncode(t,i){return oT(this,t,i)},safeDecode(t,i){return uT(this,t,i)},async safeEncodeAsync(t,i){return cT(this,t,i)},async safeDecodeAsync(t,i){return fT(this,t,i)},toJSONSchema(t){return Tz(this,{})(t)},get description(){return ur.get(this)?.description},get _def(){return this._zod.def}}),Wb=$("_ZodString",(t,i)=>{xd.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Rz(t,s,r)},vb({format:t=>rn(t).format??null,minLength:t=>rn(t).minimum??null,maxLength:t=>rn(t).maximum??null},{regex(...t){return this.check(fz(...t))},includes(...t){return this.check(mz(...t))},startsWith(...t){return this.check(pz(...t))},endsWith(...t){return this.check(gz(...t))},min(...t){return this.check(xo(...t))},max(...t){return this.check(qb(...t))},length(...t){return this.check(Bb(...t))},nonempty(...t){return this.check(xo(1,...t))},lowercase(t){return this.check(dz(t))},uppercase(t){return this.check(hz(t))},trim(){return this.check(vz())},normalize(...t){return this.check(yz(...t))},toLowerCase(){return this.check(bz())},toUpperCase(){return this.check(Sz())},slugify(){return this.check(xz())}})),e0=$("ZodString",(t,i)=>{xd.init(t,i),Wb.init(t,i)},{email(t){return this.check(kw(gT,t))},url(t){return this.check(Hw(vT,t))},jwt(t){return this.check(nz(MT,t))},emoji(t){return this.check($w(bT,t))},guid(t){return this.check(Uw(yT,t))},uuid(t){return this.check(Lw(Il,t))},uuidv4(t){return this.check(Zw(Il,t))},uuidv6(t){return this.check(qw(Il,t))},uuidv7(t){return this.check(Bw(Il,t))},nanoid(t){return this.check(Qw(ST,t))},cuid(t){return this.check(Gw(xT,t))},cuid2(t){return this.check(Kw(_T,t))},ulid(t){return this.check(Yw(ET,t))},base64(t){return this.check(Ww(AT,t))},base64url(t){return this.check(ez(RT,t))},xid(t){return this.check(Vw(OT,t))},ksuid(t){return this.check(Fw(wT,t))},ipv4(t){return this.check(Pw(zT,t))},ipv6(t){return this.check(Xw(TT,t))},cidrv4(t){return this.check(Jw(jT,t))},cidrv6(t){return this.check(Iw(NT,t))},e164(t){return this.check(tz(CT,t))},datetime(t){return this.check(Zb(t0,t))},date(t){return this.check(iz(hT,t))},time(t){return this.check(az(mT,t))},duration(t){return this.check(sz(pT,t))}});function Y(t){return Dw(e0,t)}const Ye=$("ZodStringFormat",(t,i)=>{$e.init(t,i),Wb.init(t,i)}),t0=$("ZodISODateTime",(t,i)=>{L2.init(t,i),Ye.init(t,i)}),hT=$("ZodISODate",(t,i)=>{Z2.init(t,i),Ye.init(t,i)}),mT=$("ZodISOTime",(t,i)=>{q2.init(t,i),Ye.init(t,i)}),pT=$("ZodISODuration",(t,i)=>{B2.init(t,i),Ye.init(t,i)}),gT=$("ZodEmail",(t,i)=>{E2.init(t,i),Ye.init(t,i)}),yT=$("ZodGUID",(t,i)=>{x2.init(t,i),Ye.init(t,i)}),Il=$("ZodUUID",(t,i)=>{_2.init(t,i),Ye.init(t,i)}),vT=$("ZodURL",(t,i)=>{N2.init(t,i),Ye.init(t,i)}),bT=$("ZodEmoji",(t,i)=>{A2.init(t,i),Ye.init(t,i)}),ST=$("ZodNanoID",(t,i)=>{R2.init(t,i),Ye.init(t,i)}),xT=$("ZodCUID",(t,i)=>{C2.init(t,i),Ye.init(t,i)}),_T=$("ZodCUID2",(t,i)=>{M2.init(t,i),Ye.init(t,i)}),ET=$("ZodULID",(t,i)=>{D2.init(t,i),Ye.init(t,i)}),OT=$("ZodXID",(t,i)=>{k2.init(t,i),Ye.init(t,i)}),wT=$("ZodKSUID",(t,i)=>{U2.init(t,i),Ye.init(t,i)}),zT=$("ZodIPv4",(t,i)=>{H2.init(t,i),Ye.init(t,i)}),TT=$("ZodIPv6",(t,i)=>{Q2.init(t,i),Ye.init(t,i)}),jT=$("ZodCIDRv4",(t,i)=>{G2.init(t,i),Ye.init(t,i)}),NT=$("ZodCIDRv6",(t,i)=>{Y2.init(t,i),Ye.init(t,i)}),AT=$("ZodBase64",(t,i)=>{V2.init(t,i),Ye.init(t,i)}),RT=$("ZodBase64URL",(t,i)=>{P2.init(t,i),Ye.init(t,i)}),CT=$("ZodE164",(t,i)=>{X2.init(t,i),Ye.init(t,i)}),MT=$("ZodJWT",(t,i)=>{I2.init(t,i),Ye.init(t,i)}),n0=$("ZodNumber",(t,i)=>{Rb.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Cz(t,s,r,o),t.isFinite=!0},vb({minValue:t=>{const{minimum:i,exclusiveMinimum:s}=rn(t);return Math.max(i??Number.NEGATIVE_INFINITY,s??Number.NEGATIVE_INFINITY)},maxValue:t=>{const{maximum:i,exclusiveMaximum:s}=rn(t);return Math.min(i??Number.POSITIVE_INFINITY,s??Number.POSITIVE_INFINITY)},isInt:t=>{const{isInt:i,multipleOf:s}=rn(t);return!!i||!!s?.some(Number.isSafeInteger)},format:t=>rn(t).format??null},{gt(t,i){return this.check(Qy(t,i))},gte(t,i){return this.check(xf(t,i))},min(t,i){return this.check(xf(t,i))},lt(t,i){return this.check($y(t,i))},lte(t,i){return this.check(Sf(t,i))},max(t,i){return this.check(Sf(t,i))},int(t){return this.check(Wy(t))},safe(t){return this.check(Wy(t))},positive(t){return this.check(Qy(0,t))},nonnegative(t){return this.check(xf(0,t))},negative(t){return this.check($y(0,t))},nonpositive(t){return this.check(Sf(0,t))},multipleOf(t,i){return this.check(Gy(t,i))},step(t,i){return this.check(Gy(t,i))},finite(){return this}}));function Qe(t){return rz(n0,t)}const DT=$("ZodNumberFormat",(t,i)=>{W2.init(t,i),n0.init(t,i)});function Wy(t){return lz(DT,t)}const kT=$("ZodBoolean",(t,i)=>{ew.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Mz(t,s,r)});function Wt(t){return oz(kT,t)}const UT=$("ZodUnknown",(t,i)=>{tw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>kz()});function Ff(){return uz(UT)}const LT=$("ZodNever",(t,i)=>{nw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Dz(t,s,r)});function ZT(t){return cz(LT,t)}const i0=$("ZodArray",(t,i)=>{Mo(),sw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Bz(t,s,r,o),t.element=i.element},{min(t,i){return this.check(xo(t,i))},nonempty(t){return this.check(xo(1,t))},max(t,i){return this.check(qb(t,i))},length(t,i){return this.check(Bb(t,i))},unwrap(){return this.element}});function _e(t,i){return _z(i0,t,i)}const qT=$("ZodObject",(t,i)=>{Mo(),ow.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Hz(t,s,r,o),rO(t,"shape",s=>s._zod.def.shape,!1)},{keyof(){return jt(Object.keys(this._zod.def.shape))},catchall(t){return this.clone($t(this._zod.def,{catchall:t}))},passthrough(){return this.clone($t(this._zod.def,{catchall:Ff()}))},loose(){return this.clone($t(this._zod.def,{catchall:Ff()}))},strict(){return this.clone($t(this._zod.def,{catchall:ZT()}))},strip(){return this.clone($t(this._zod.def,{catchall:void 0}))},extend(t){return PE(this,t)},safeExtend(t){return XE(this,t)},merge(t){return JE(this,t)},pick(t){return VE(this,t)},omit(t){return FE(this,t)},partial(...t){return Oy(a0,this,t[0])},exactPartial(...t){return Oy(s0,this,t[0],"exactPartial")},required(...t){return IE(l0,this,t[0])}});function re(t,i){const s={type:"object",shape:t??{},...ie(i)};return new qT(s)}const BT=$("ZodUnion",(t,i)=>{uw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>$z(t,s,r,o),t.options=i.options});function Do(t,i){return new BT({type:"union",options:t,...ie(i)})}const HT=$("ZodIntersection",(t,i)=>{cw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Qz(t,s,r,o)});function $T(t,i){return new HT({type:"intersection",left:t,right:i})}const ev=$("ZodRecord",(t,i)=>{Mo(),fw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Kz(t,s,r,o),t.keyType=i.keyType,t.valueType=i.valueType});function QT(t,i,s){return!i||!i._zod?new ev({type:"record",keyType:Y(),valueType:t,...ie(i)}):new ev({type:"record",keyType:t,valueType:i,...ie(s)})}const Oo=$("ZodEnum",(t,i)=>{dw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(r,o,c)=>Uz(t,r,o),t.enum=i.entries,t.options=[...t._zod.values];const s=new Set(Object.keys(i.entries));t.extract=(r,o)=>{const c={};for(const d of r)if(s.has(d))c[d]=i.entries[d];else throw new Error(`Key ${d} not found in enum`);return new Oo({...i,checks:[],...ie(o),entries:c})},t.exclude=(r,o)=>{const c={...i.entries};for(const d of r)if(s.has(d))delete c[d];else throw new Error(`Key ${d} not found in enum`);return new Oo({...i,checks:[],...ie(o),entries:c})}});function jt(t,i){const s=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new Oo({type:"enum",entries:s,...ie(i)})}const GT=$("ZodLiteral",(t,i)=>{hw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Lz(t,s,r,o),t.values=new Set(i.values),Object.defineProperty(t,"value",{get(){if(i.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return i.values[0]}})});function pi(t,i){return new GT({type:"literal",values:Array.isArray(t)?t:[t],...ie(i)})}const KT=$("ZodTransform",(t,i)=>{Mo(),mw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>qz(t,s,r,o),t._zod.parse=(s,r)=>{if(r.direction==="backward")throw new bb(t.constructor.name);s.addIssue=c=>{if(typeof c=="string")s.issues.push(br(c,s.value,i));else{const d=c;d.fatal&&(d.continue=!1),d.code??(d.code="custom"),"input"in d||(d.input=s.value),d.inst??(d.inst=t),s.issues.push(br(d))}};const o=i.transform(s.value,s);return o instanceof Promise?o.then(c=>(s.value=c,s)):(s.value=o,s)}});function YT(t){return new KT({type:"transform",transform:t})}const a0=$("ZodOptional",(t,i)=>{Db.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Ib(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function tv(t){return new a0({type:"optional",innerType:t})}const s0=$("ZodExactOptional",(t,i)=>{pw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Ib(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function VT(t){return new s0({type:"optional",innerType:t})}const FT=$("ZodNullable",(t,i)=>{gw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Yz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function nv(t){return new FT({type:"nullable",innerType:t})}const r0=$("ZodDefault",(t,i)=>{yw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Fz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function PT(t,i){return new r0({type:"default",innerType:t,get defaultValue(){return typeof i=="function"?i():hb(i)}})}const XT=$("ZodPrefault",(t,i)=>{vw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Pz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function JT(t,i){return new XT({type:"prefault",innerType:t,get defaultValue(){return typeof i=="function"?i():hb(i)}})}const l0=$("ZodNonOptional",(t,i)=>{bw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Vz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function IT(t,i){return new l0({type:"nonoptional",innerType:t,...ie(i)})}const WT=$("ZodCatch",(t,i)=>{Sw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Xz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function ej(t,i){return new WT({type:"catch",innerType:t,catchValue:typeof i=="function"?i:oO(i)})}const tj=$("ZodPipe",(t,i)=>{xw.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Jz(t,s,r,o),t.in=i.in,t.out=i.out});function iv(t,i){return new tj({type:"pipe",in:t,out:i})}const nj=$("ZodReadonly",(t,i)=>{_w.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Iz(t,s,r,o),t.unwrap=()=>t._zod.def.innerType});function ij(t){return new nj({type:"readonly",innerType:t})}const aj=$("ZodCustom",(t,i)=>{Ew.init(t,i),Ke.init(t,i),t._zod.processJSONSchema=(s,r,o)=>Zz(t,s,r,o)});function sj(t,i={}){return Ez(aj,t,i)}function rj(t,i){return Oz(t,i)}function lj(t){return Zb(t0,t)}const dt=Y().regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,"kebab-case required"),o0=Y().regex(/^package:[a-z][a-z0-9]*(-[a-z0-9]+)*$/,"expected package:<kebab-case-name>"),oj=re({method:jt(["GET","POST","PUT","PATCH","DELETE"]),path:Y().startsWith("/api/"),description:Y().min(10),schemaInput:Y().describe("Exported name of the input Zod schema, e.g. CreateOrderInputSchema"),schemaOutput:Y().describe("Exported name of the output Zod schema"),invalidates:_e(Y()).optional().describe("Cache roots this mutation stales BEYOND its own path root (cross-feature dependency, read by the manifest-derived client — never guessed in a screen). Each value must be an existing feature name or route root")}),uj=jt(["reference","ownerless"]),cj=Do([Y(),re({name:Y(),shared:pi(!0),sharedKind:uj.optional()})]),fj=re({name:dt,intent:Y().min(20).max(300).describe("The feature's 'why' in 1-3 sentences"),app:Y().optional().describe("Name of the owning app (apps[].name); defaults to the api app"),folder:Y().describe("Path relative to the app root, e.g. src/features/orders"),spec:Y().nullable().describe("Path to the spec, e.g. specs/orders.spec.md, null for technical features"),routes:_e(oj),dbTables:_e(cj).describe("Drizzle tables owned by this feature (one table = one owner). String = tenant-scoped; { name, shared: true } = shared referential"),dependsOn:_e(Do([dt,o0])).describe("Features imported through their index.ts, and product packages as package:<name> — nothing else"),status:jt(["skeleton","in-progress","delivered"])}),dj=Y().regex(/^\d+\.\d+\.\d+$/,"expected a plain x.y.z version"),hj=re({packages:_e(re({name:Y().describe("Published npm name, e.g. @ogygie/core"),path:Y().describe("Folder relative to the repo root"),intent:Y().min(20),spec:Y().nullable(),status:jt(["skeleton","in-progress","delivered"])})),templates:re({project:Y().describe("Folder copied by `ogygie init`"),feature:Y().describe("Reserved for `ogygie generate feature` (not wired yet)")}),governedFiles:Y().describe("Module declaring the exhaustive list of files `upgrade` may overwrite (D3)")}),mj=re({canonical:Y().regex(/^[a-z][a-zA-Z0-9]*$/,"camelCase English term required").describe("The one machine term for this concept, e.g. gadget"),forbiddenAliases:_e(Y().min(2).regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,"lowercase root (kebab-case allowed) required")).min(1).describe("Roots the code may never carry for this concept, e.g. widget"),reference:Y().optional().describe("Anchor into AGENTS.product.md where the concept is explained")}),pj=re({entries:_e(mj)}),gj=re({name:dt,path:Y().describe("Folder relative to the repo root, e.g. packages/solver"),intent:Y().min(20).max(300).describe("The package's 'why' in 1-3 sentences"),spec:Y().nullable(),dependsOn:_e(o0).describe("Other PRODUCT packages, as package:<name> — never a feature: a package that depended on one would live under an app, and would be a feature"),status:jt(["skeleton","in-progress","delivered"])}),yj=re({column:Y().min(1).describe("SQL name of the tenant column, e.g. workspace_id — the one AGENTS.product.md announces"),rawDbAllowed:_e(dt).default([]).describe("Features allowed to reach the raw database: the tenancy socle, which BUILDS the contexts and therefore predates them. Every other feature goes through tenantDb")}),vj=re({version:pi(1),product:re({name:Y(),description:Y().min(20)}),ogygieVersion:dj.optional(),framework:hj.optional(),apps:_e(re({name:Y(),path:Y(),type:jt(["api","front","gateway"]),entryPoint:Y(),vendored:pi(!0).optional()})),features:_e(fj),tenancy:yj.optional().describe("Product values the framework gates need — absent, the tenancy checks do not run"),packages:_e(gj).optional().describe("Product code living outside every app — libraries, engines. Absent = the project has none"),vocabulary:pj.optional().describe("The product's closed vocabulary — declared here, enforced by `ogygie verify-vocabulary`. Absent = gate silent"),conventions:re({agentsMd:pi("AGENTS.md"),failuresMd:pi("FAILURES.md"),specsFolder:pi("specs/")})}).superRefine((t,i)=>{const s=new Set(t.features.map(g=>g.name)),r=new Set;(t.packages??[]).forEach((g,x)=>{s.has(g.name)&&i.addIssue({code:"custom",path:["packages",x,"name"],message:`"${g.name}" is already the name of a feature — one name designates one thing`}),r.has(g.name)&&i.addIssue({code:"custom",path:["packages",x,"name"],message:`package "${g.name}" is declared twice`}),r.add(g.name)});const o=g=>(g.split("/").pop()??g).replace(/\.spec\.md$/,""),c=new Set([...t.features.map(g=>g.name),...r]);(t.framework?.packages??[]).forEach((g,x)=>{if(g.spec===null)return;const S=o(g.spec);c.has(S)&&i.addIssue({code:"custom",path:["framework","packages",x,"spec"],message:`spec "${S}" is already owned by a feature or a product package — one spec, one owner`})});const d=(g,x)=>{g.forEach((S,E)=>{if(!S.startsWith("package:"))return;const O=S.slice(8);r.has(O)||i.addIssue({code:"custom",path:[...x,E],message:`dependency "${S}" matches no declared package`})})};t.features.forEach((g,x)=>{d(g.dependsOn,["features",x,"dependsOn"])}),(t.packages??[]).forEach((g,x)=>{d(g.dependsOn,["packages",x,"dependsOn"])}),(t.tenancy?.rawDbAllowed??[]).forEach((g,x)=>{s.has(g)||i.addIssue({code:"custom",path:["tenancy","rawDbAllowed",x],message:`"${g}" matches no declared feature`})});const h=new Map,m=new Map;(t.vocabulary?.entries??[]).forEach((g,x)=>{const S=g.canonical.toLowerCase(),E=h.get(S);E!==void 0?i.addIssue({code:"custom",path:["vocabulary","entries",x,"canonical"],message:`canonical "${g.canonical}" is already declared by entry ${E}`}):h.set(S,x)}),(t.vocabulary?.entries??[]).forEach((g,x)=>{g.forbiddenAliases.forEach((S,E)=>{const O=["vocabulary","entries",x,"forbiddenAliases",E],T=h.get(S);if(T!==void 0){i.addIssue({code:"custom",path:O,message:`alias "${S}" is the canonical term of entry ${T} — a term cannot be both`});return}const R=m.get(S);if(R!==void 0){i.addIssue({code:"custom",path:O,message:`alias "${S}" is already forbidden by entry ${R} — one alias belongs to one concept`});return}m.set(S,x)})});const p=new Map(t.apps.map(g=>[g.name,g])),v=new Set(t.features.map(g=>g.name));for(const g of t.features)for(const x of g.routes){const S=x.path.split("/")[2];S!==void 0&&v.add(S)}t.features.forEach((g,x)=>{g.routes.forEach((S,E)=>{for(const O of S.invalidates??[])v.has(O)||i.addIssue({code:"custom",path:["features",x,"routes",E,"invalidates"],message:`invalidates target "${O}" matches no feature name and no route root`})})}),t.features.forEach((g,x)=>{if(g.app===void 0)return;const S=p.get(g.app);if(S===void 0){i.addIssue({code:"custom",path:["features",x,"app"],message:`app "${g.app}" is not declared in apps[]`});return}S.type!=="api"&&(g.routes.length>0||g.dbTables.length>0)&&i.addIssue({code:"custom",path:["features",x],message:"a non-api feature owns no HTTP routes and no DB tables — declare them on the api feature"})})}),bj=Y().regex(/^.+ blockedBy:[a-z][a-z0-9]*(-[a-z0-9]+)*$/,'Expected "<behavior> blockedBy:<feature-name>" (feature name in kebab-case)'),os=re({id:dt.describe("Identical to the feature name in the manifest"),status:jt(["draft","validated","implemented"]),depends_on:_e(dt),priority:jt(["P0","P1","P2"]),refs:_e(Y()).default([]).describe("References to the domain model, e.g. 'modele-gally §4.2'"),deferred:_e(bj).default([]).describe("Behaviors deferred to a later feature, blocked by name")}),Ja=["# @intent","# Comportements","# Contrats de données","# États UI","# Non-objectifs","# Budget"],u0=re({ogygie:pi(!0).describe("Marker: lets an agent tell our errors from noise"),code:Y().regex(/^[A-Z][A-Z0-9_]+$/,"SCREAMING_SNAKE_CASE, stable over time"),message:Y().min(10).describe("Human-readable sentence (technical English)"),file:Y().nullable().describe("Relative path of the file involved, null when not localizable"),cause:Y().describe("The precise datum or condition that triggered the error"),suggestedFix:Y().describe("Concrete action to fix — never empty"),details:QT(Y(),Ff()).default({}),timestamp:lj()});class Od extends Error{payload;constructor(i){super(i.message),this.name="StudioApiError",this.payload=i}}async function pt(t,i,s){const r=await fetch(t,s),o=await r.json();if(!r.ok){const c=u0.safeParse(o);throw c.success?new Od(c.data):new Error(`HTTP ${r.status} on ${t} (non-OgygieError payload)`)}return i.parse(o)}function xr(t){return{headers:{"content-type":"application/json"},body:JSON.stringify(t)}}const Sj=os.shape.status,wd=re({id:dt,status:Sj,priority:os.shape.priority,depends_on:_e(dt),filePath:Y(),presentSections:_e(Y())}),xj=re({id:Y(),filePath:Y(),error:u0}),_j=Do([wd,xj]),Ej=re({specs:_e(_j)});re({specId:dt});const Oj=re({frontmatter:os,body:Y(),presentSections:_e(Y())});re({frontmatter:os,body:Y().max(2e5).optional()});const wj=re({spec:wd});re({id:dt.max(80)});const zj=re({spec:wd}),Tj=re({manifest:vj}),jj=re({name:Y().min(1).max(200),contentBase64:Y().min(1).max(57e5)});re({brief:Y().min(50).max(2e4),specId:dt.optional(),attachments:_e(jj).max(5).default([])});const Nj=re({specId:dt,attempts:Qe().int().min(1).max(2),problemsFixed:_e(Y()),isNewFeature:Wt(),isAmendment:Wt(),compositions:_e(Y()).default([]),generation:re({derivable:Qe().int().nonnegative(),hole:Qe().int().nonnegative()}).nullable().default(null),usage:_e(re({model:Y(),inputTokens:Qe().int().nonnegative(),outputTokens:Qe().int().nonnegative()}))}),c0=jt(["green","red","pending","none"]),Aj=re({specId:dt,branch:Y(),pullRequest:re({number:Qe().int().positive(),url:Y(),headSha:Y(),title:Y()}).nullable(),specStatus:jt(["draft","validated","implemented","unreadable","absent"]),checks:c0,checkRuns:_e(re({name:Y(),conclusion:Y().nullable()})),mergeable:Wt().nullable(),requiredRole:jt(["approver","operator"]),canMerge:Wt(),blockers:_e(Y()),labels:_e(Y()).default([]),needsOperator:Wt().default(!1)}),Rj=re({pullRequests:_e(re({specId:dt,number:Qe().int().positive(),url:Y(),checks:c0,needsOperator:Wt().default(!1)}))}),Cj=re({specId:dt,pullRequestNumber:Qe().int().positive(),mergeSha:Y(),mergedBy:Y(),mergedAt:Y()}),Mj=jt(["development","staging","production"]),f0=jt(["staging","production"]);re({environment:f0});const Dj=re({environments:_e(re({name:Mj,ref:Y(),sha:Y().nullable(),deployment:re({id:Qe().int(),state:Y().nullable(),createdAt:Y()}).nullable()})),releases:_e(Y())});re({sha:Y().regex(/^[0-9a-f]{40}$/),rollback:Wt().optional(),reason:Y().min(10).max(2e3).optional()});const kj=re({environment:f0,fromSha:Y().nullable(),toSha:Y(),actor:Y(),at:Y(),deploymentId:Qe().int(),releaseTag:Y().nullable(),includedPullRequests:_e(re({number:Qe().int(),specId:Y().nullable(),message:Y(),authoredAt:Y()})),destructiveMigration:Wt(),rollback:Wt()});re({month:Y().regex(/^\d{4}-\d{2}$/).optional()});const Uj=re({month:Y(),specs:_e(re({specId:Y(),pullRequestNumber:Qe().int(),runs:Qe().int(),inputTokens:Qe().int(),outputTokens:Qe().int(),estimatedUsd:Qe(),uncostedModels:_e(Y())})),totals:re({runs:Qe().int(),inputTokens:Qe().int(),outputTokens:Qe().int(),estimatedUsd:Qe()}),budgetUsd:Qe().nullable(),budgetRatio:Qe().nullable(),warning:Wt()}),av=re({state:Y(),path:Y(),sizeBytes:Qe().int().nonnegative()}),Lj=re({specId:dt,previews:_e(av),composition:Y().nullable().default(null),compositions:_e(re({name:Y(),selected:Wt(),previews:_e(av)})).default([])}),Zj=re({specId:dt,composition:Y(),alreadySelected:Wt()});function qj(){return Hn({queryKey:["specs"],queryFn:()=>pt("/api/specs",Ej)})}function Bj(t){return Hn({queryKey:["specs",t],queryFn:()=>pt(`/api/specs/${t}`,Oj)})}function Hj(){return Hn({queryKey:["manifest"],queryFn:()=>pt("/api/manifest",Tj)})}function $j(t){const i=wi();return ss({mutationFn:s=>pt(`/api/specs/${t}`,wj,{method:"PUT",...xr(s)}),onSuccess:async()=>{await i.invalidateQueries({queryKey:["specs"]})}})}function Qj(){const t=wi();return ss({mutationFn:i=>pt("/api/specs",zj,{method:"POST",...xr(i)}),onSuccess:async()=>{await t.invalidateQueries({queryKey:["specs"]})}})}const Gj=re({email:Y(),displayName:Y(),role:Y()});function ko(){return Hn({queryKey:["me"],queryFn:()=>pt("/api/auth/me",Gj),retry:!1})}function Kj(){const t=wi();return ss({mutationFn:i=>pt("/api/briefs",Nj,{method:"POST",...xr(i)}),onSuccess:async()=>{await t.invalidateQueries({queryKey:["specs"]})}})}function Yj(t){return Hn({queryKey:["specs",t,"pull-request"],queryFn:()=>pt(`/api/specs/${t}/pull-request`,Aj),retry:!1})}function Vj(t){return Hn({queryKey:["pull-requests"],queryFn:()=>pt("/api/pull-requests",Rj),enabled:t,retry:!1})}function Fj(t){const i=wi();return ss({mutationFn:()=>pt(`/api/specs/${t}/merge`,Cj,{method:"POST"}),onSuccess:async()=>{await i.invalidateQueries({queryKey:["specs"]})}})}function Pj(){return Hn({queryKey:["environments"],queryFn:()=>pt("/api/environments",Dj),retry:!1})}function Xj(){const t=wi();return ss({mutationFn:i=>{const{environment:s,...r}=i;return pt(`/api/environments/${s}/promotions`,kj,{method:"POST",...xr(r)})},onSuccess:async()=>{await t.invalidateQueries({queryKey:["environments"]})}})}function Jj(t){return Hn({queryKey:["consumption",t],queryFn:()=>pt(`/api/consumption?month=${t}`,Uj),retry:!1})}function Ij(t){return Hn({queryKey:["specs",t,"previews"],queryFn:()=>pt(`/api/specs/${t}/previews`,Lj),retry:!1})}function Wj(t){const i=wi();return ss({mutationFn:s=>pt(`/api/specs/${t}/compositions/${s}/select`,Zj,{method:"POST"}),onSuccess:async()=>{await i.invalidateQueries({queryKey:["specs"]})}})}const eN={primary:"bg-accent text-accent-contrast hover:bg-accent-strong shadow-raised",secondary:"border border-border bg-surface-raised text-text hover:border-border-strong hover:bg-surface-sunken",danger:"bg-danger-soft text-danger border border-danger/40 hover:border-danger",ghost:"text-text-muted hover:text-text hover:bg-surface-sunken"};function mt({voice:t="secondary",size:i="md",className:s="",type:r="button",children:o,...c}){const d=i==="sm"?"px-2.5 py-1 text-xs":"px-3.5 py-2 text-sm";return b.jsx("button",{type:r,className:`inline-flex items-center justify-center gap-2 rounded-md font-medium transition-[background-color,border-color,color,transform] duration-(--duration-fast) ease-swell active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 ${d} ${eN[t]} ${s}`,...c,children:o})}const tN={neutral:"bg-surface-sunken text-text-muted border-border",accent:"bg-accent-soft text-accent border-accent/30",positive:"bg-positive-soft text-positive border-positive/30",warning:"bg-warning-soft text-warning border-warning/30",danger:"bg-danger-soft text-danger border-danger/30",orichalcum:"bg-surface-sunken text-orichalcum border-orichalcum/40"};function ft({tone:t="neutral",mono:i=!1,children:s,title:r}){return b.jsx("span",{title:r,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium leading-tight ${i?"font-mono":""} ${tN[t]}`,children:s})}function d0({status:t}){const i=t==="validated"?"accent":t==="implemented"?"positive":"neutral";return b.jsx(ft,{tone:i,children:t})}function h0({title:t,hint:i,action:s}){return b.jsxs("div",{className:"studio-rise flex flex-col items-center gap-3 rounded-lg border border-dashed border-border-strong/60 bg-surface-raised/60 px-6 py-12 text-center",children:[b.jsx("p",{className:"font-display text-xl font-semibold text-text",children:t}),i!==void 0&&b.jsx("p",{className:"max-w-md text-sm text-text-muted",children:i}),s]})}function nN(t){return t instanceof Od?t.payload:null}function Nt({error:t}){const i=nN(t);if(i===null){const s=t instanceof Error?t.message:String(t);return b.jsx("div",{role:"alert",className:"rounded-md border border-danger/40 bg-danger-soft p-4 text-sm text-text",children:s})}return b.jsx(m0,{error:i})}function m0({error:t}){return b.jsxs("div",{role:"alert",className:"studio-rise rounded-md border border-danger/40 bg-danger-soft p-4 text-sm text-text",children:[b.jsx("p",{className:"font-mono text-xs font-bold uppercase tracking-wide text-danger",children:t.code}),b.jsx("p",{className:"mt-1 font-medium",children:t.message}),b.jsxs("dl",{className:"mt-2 space-y-1 text-xs text-text-muted",children:[t.file!=null&&b.jsxs("div",{className:"flex gap-2",children:[b.jsx("dt",{className:"shrink-0 font-semibold text-text",children:"Fichier"}),b.jsx("dd",{className:"font-mono",children:t.file})]}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx("dt",{className:"shrink-0 font-semibold text-text",children:"Cause"}),b.jsx("dd",{className:"font-mono break-all",children:t.cause})]}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx("dt",{className:"shrink-0 font-semibold text-text",children:"Correction suggérée"}),b.jsx("dd",{children:t.suggestedFix})]})]})]})}var iN=mv();function p0({open:t,title:i,children:s,onClose:r}){return X.useEffect(()=>{if(!t)return;const o=c=>{c.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,r]),t?iN.createPortal(b.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-surface-sunken/70 p-4 backdrop-blur-sm",children:b.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":i,className:"studio-rise w-full max-w-md rounded-lg border border-border bg-surface-raised p-5 shadow-overlay",children:[b.jsxs("div",{className:"flex items-start justify-between gap-4",children:[b.jsx("h2",{className:"font-display text-xl font-semibold text-text",children:i}),b.jsx("button",{type:"button",onClick:r,className:"rounded p-1 text-text-faint transition-colors hover:bg-surface-sunken hover:text-text","aria-label":"Fermer",children:"✕"})]}),b.jsx("div",{className:"mt-3 text-sm text-text-muted",children:s})]})}),document.body):null}function _r({eyebrow:t,title:i,explanation:s,actions:r}){return b.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4 border-b border-border pb-4",children:[b.jsxs("div",{className:"min-w-0",children:[t!==void 0&&b.jsx("p",{className:"mb-1 font-mono text-xs uppercase tracking-[0.18em] text-text-faint",children:t}),b.jsx("h1",{className:"font-display text-2xl font-semibold leading-tight text-text",children:i}),s!==void 0&&b.jsx("p",{className:"mt-1 max-w-2xl text-sm text-text-muted",children:s})]}),r!==void 0&&b.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:r})]})}function Oi({children:t,className:i="",...s}){return b.jsx("section",{className:`rounded-lg border border-border bg-surface-raised p-4 shadow-raised ${i}`,...s,children:t})}const aN=[{status:"draft",title:"Draft",explanation:"en écriture",accent:"border-t-border-strong"},{status:"validated",title:"Validated",explanation:"signées, à implémenter",accent:"border-t-accent"},{status:"implemented",title:"Implemented",explanation:"livrées",accent:"border-t-positive"}],sN={P0:"danger",P1:"accent",P2:"neutral"},rN={green:"positive",red:"danger",pending:"warning",none:"neutral"},lN={green:"CI verte",red:"CI rouge",pending:"CI en cours",none:"aucun check"};function sv(t){return!("error"in t)}function oN(t){return t instanceof HTMLElement&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable)}function uN(){const{data:t,isPending:i,error:s}=qj(),r=ko(),o=Vj(r.data!==void 0),[c,d]=X.useState(""),[h,m]=X.useState(!1),p=X.useRef(null);if(X.useEffect(()=>{const O=T=>{T.metaKey||T.ctrlKey||T.altKey||oN(T.target)||(T.key==="/"?(T.preventDefault(),p.current?.focus()):T.key==="n"&&(T.preventDefault(),m(!0)))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[]),s)return b.jsx(Nt,{error:s});if(i)return b.jsx(dN,{});const v=t.specs.filter(sv),g=t.specs.filter(O=>!sv(O));if(t.specs.length===0)return b.jsx(h0,{title:"Aucune spec dans ce repo",hint:"Créez la première depuis le template canonique — elle naîtra en draft.",action:b.jsx(rv,{open:h,onOpen:()=>m(!0),onClose:()=>m(!1)})});const x=c.trim().toLowerCase(),S=O=>x===""||O.id.includes(x)||O.depends_on.some(T=>T.includes(x)),E=new Map((o.data?.pullRequests??[]).map(O=>[O.specId,O]));return b.jsxs("div",{className:"space-y-6",children:[b.jsx(_r,{eyebrow:"Specs",title:"Board",explanation:`${v.length} spec${v.length>1?"s":""} lisible${v.length>1?"s":""} · le repo est l'état, le board n'est qu'une vue.`,actions:b.jsxs(b.Fragment,{children:[b.jsx("input",{ref:p,type:"search",value:c,onChange:O=>d(O.target.value),placeholder:"Filtrer ( / )","aria-label":"Filtrer les specs",className:"w-44 rounded-md border border-border bg-surface-raised px-3 py-2 text-sm text-text transition-colors focus:border-accent"}),b.jsx(rv,{open:h,onOpen:()=>m(!0),onClose:()=>m(!1)})]})}),g.length>0&&b.jsx("section",{"aria-label":"Specs illisibles",className:"space-y-2",children:g.map(O=>b.jsx(m0,{error:O.error},O.filePath))}),b.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:aN.map(O=>b.jsx(cN,{column:O,specs:v.filter(T=>T.status===O.status&&S(T)),pullsBySpec:E},O.status))})]})}function cN({column:t,specs:i,pullsBySpec:s}){return b.jsxs("section",{"aria-label":`Colonne ${t.title}`,className:`flex flex-col rounded-lg border border-border border-t-2 bg-surface-sunken/50 p-3 ${t.accent}`,children:[b.jsxs("h2",{className:"mb-3 flex items-baseline justify-between px-1",children:[b.jsxs("span",{className:"font-display text-lg font-semibold text-text",children:[t.title," ",b.jsx("span",{className:"ml-1 text-sm font-normal text-text-faint",children:t.explanation})]}),b.jsx(cd,{value:i.length,className:"font-mono text-xs text-text-faint"})]}),i.length===0?b.jsx("p",{className:"rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-text-faint",children:"Aucune spec ici"}):b.jsx("ul",{className:"space-y-2",children:i.map((r,o)=>b.jsx("li",{className:"studio-reveal",style:{"--i":o},children:b.jsx(fN,{summary:r,pull:s.get(r.id)})},r.id))})]})}function fN({summary:t,pull:i}){const s=new Set(t.presentSections);return b.jsxs(rs,{to:"/specs/$specId",params:{specId:t.id},className:"group block rounded-md border border-border bg-surface-raised p-3 shadow-raised transition-[border-color,transform,box-shadow] duration-(--duration-base) ease-swell hover:-translate-y-0.5 hover:border-accent/60 hover:shadow-overlay",children:[b.jsxs("div",{className:"flex items-start justify-between gap-2",children:[b.jsx("p",{className:"min-w-0 truncate font-mono text-sm font-medium text-text group-hover:text-accent",children:t.id}),b.jsx(ft,{tone:sN[t.priority]??"neutral",children:t.priority})]}),b.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[b.jsx("ul",{"aria-label":`${s.size} sections sur ${Ja.length}`,className:"flex flex-1 gap-0.5",children:Ja.map(r=>b.jsx("li",{title:r,className:`h-1 flex-1 rounded-full ${s.has(r)?"bg-accent":"bg-border"}`},r))}),b.jsxs("span",{className:"font-mono text-xs text-text-faint",children:[s.size,"/",Ja.length]})]}),(t.depends_on.length>0||i!==void 0)&&b.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[i!==void 0&&b.jsxs(ft,{tone:i.needsOperator?"orichalcum":rN[i.checks]??"neutral",mono:!0,title:i.needsOperator?"en attente de l'opérateur (needs-operator)":lN[i.checks]??i.checks,children:["#",i.number,i.needsOperator&&b.jsx("span",{"aria-hidden":"true",children:" ⚑"})]}),t.depends_on.map(r=>b.jsxs(ft,{mono:!0,title:`dépend de ${r}`,children:["← ",r]},r))]})]})}function dN(){return b.jsx("div",{"aria-label":"Chargement du board",className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[0,1,2].map(t=>b.jsx("div",{className:"studio-breathe h-64 rounded-lg border border-border"},t))})}function rv({open:t,onOpen:i,onClose:s}){const[r,o]=X.useState(""),c=jo(),d=Qj(),h=()=>{d.mutate({id:r},{onSuccess:async m=>{s(),await c({to:"/specs/$specId",params:{specId:m.spec.id}})}})};return b.jsxs(b.Fragment,{children:[b.jsx(mt,{voice:"primary",onClick:()=>{d.reset(),o(""),i()},children:"Nouvelle spec"}),b.jsx(p0,{open:t,title:"Nouvelle spec depuis le template",onClose:s,children:b.jsxs("form",{onSubmit:m=>{m.preventDefault(),h()},className:"space-y-3",children:[b.jsxs("label",{className:"block text-sm text-text-muted",children:["Identifiant (kebab-case, il nomme le fichier specs/<id>.spec.md)",b.jsx("input",{value:r,onChange:m=>o(m.target.value),placeholder:"ma-nouvelle-feature",autoFocus:!0,className:"mt-1 w-full rounded-md border border-border bg-surface px-3 py-2 font-mono text-sm text-text focus:border-accent"})]}),d.error instanceof Od&&b.jsx(Nt,{error:d.error}),b.jsxs("div",{className:"flex justify-end gap-2",children:[b.jsx(mt,{voice:"ghost",onClick:s,children:"Annuler"}),b.jsx(mt,{voice:"primary",type:"submit",disabled:d.isPending||r==="",children:"Créer en draft"})]})]})})]})}function hN(t){const i=`
67
67
  ${t}`,s=[];let r=0;for(const o of Ja){const c=i.indexOf(`
68
- ${o}`,r);c!==-1&&(s.push(o),r=c+o.length)}return s}const mN={green:"CI verte",red:"CI rouge",pending:"CI en cours",none:"aucun check"},pN={green:"positive",red:"danger",pending:"warning",none:"neutral"};function gN({specId:t,role:i}){const s=Yj(t),r=Fj(t);if(s.error)return b.jsx(Nt,{error:s.error});if(s.isPending)return b.jsx("div",{"aria-label":"Chargement de la pull request",className:"h-20 animate-pulse rounded-lg border border-border bg-surface-sunken/60"});const o=s.data;if(r.isSuccess)return b.jsxs("section",{role:"status",className:"studio-rise rounded-lg border border-positive/40 bg-positive-soft p-4 text-sm text-text",children:["Pull request #",r.data.pullRequestNumber," fusionnée : la spec est sur la branche par défaut, le déploiement de développement suit."]});const c=o.canMerge&&ov(i,o.requiredRole);return b.jsxs(Oi,{"aria-label":"Pull request de la spec",className:"text-sm",children:[b.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b.jsx("h2",{className:"font-display text-lg font-semibold text-text",children:"Pull request"}),o.pullRequest!==null&&b.jsxs(b.Fragment,{children:[b.jsxs("a",{className:"font-mono text-accent underline-offset-4 hover:underline",href:o.pullRequest.url,target:"_blank",rel:"noreferrer",children:["#",o.pullRequest.number]}),b.jsx(ft,{tone:pN[o.checks]??"neutral",children:mN[o.checks]??o.checks}),b.jsx(d0,{status:o.specStatus}),o.needsOperator&&b.jsx(ft,{tone:"orichalcum",children:"en attente de l'opérateur"})]})]}),b.jsx(mt,{voice:"primary",size:"sm",disabled:!c||r.isPending,onClick:()=>r.mutate(),children:r.isPending?"Fusion…":"Fusionner"})]}),o.pullRequest===null?b.jsxs("p",{className:"mt-2 text-text-muted",children:["Aucune pull request ouverte : la prochaine sauvegarde en ouvre une sur ",b.jsx("code",{className:"font-mono text-text",children:o.branch}),"."]}):b.jsxs("p",{className:"mt-2 text-text-muted",children:[b.jsx("span",{className:"text-text",children:o.pullRequest.title})," · branche ",b.jsx("code",{className:"font-mono",children:o.branch})]}),o.blockers.length>0&&b.jsx("ul",{className:"mt-3 space-y-1 text-text-muted",children:o.blockers.map(d=>b.jsxs("li",{className:"flex gap-2",children:[b.jsx("span",{"aria-hidden":"true",className:"text-warning",children:"●"}),d]},d))}),o.pullRequest!==null&&!ov(i,o.requiredRole)&&b.jsxs("p",{className:"mt-3 text-text-muted",children:["La fusion exige le rôle ",o.requiredRole,"."]}),r.error!=null&&b.jsx("div",{className:"mt-3",children:b.jsx(Nt,{error:r.error})})]})}const lv={reader:0,author:1,approver:2,operator:3};function ov(t,i){return(lv[t]??-1)>=(lv[i]??99)}const yN={empty:"Vide",loading:"Chargement",nominal:"Nominal",error:"Erreur"};function vN({specId:t}){const i=Ij(t),s=Wj(t),[r,o]=X.useState(null),[c,d]=X.useState(null);if(i.error)return b.jsx(Nt,{error:i.error});if(i.isPending)return b.jsx("div",{"aria-label":"Chargement des aperçus",className:"h-24 animate-pulse rounded-lg border border-border bg-surface-sunken/60"});const h=i.data.compositions,m=i.data.composition,p=h.length>1?h.find(S=>S.name===c)??h.find(S=>S.selected)??h[0]??null:null,v=p===null?i.data.previews:p.previews;if(v.length===0&&p===null)return b.jsxs("section",{"aria-label":"Aperçus de l'écran",className:"rounded-lg border border-dashed border-border-strong/60 bg-surface-raised/60 p-4 text-sm text-text-muted",children:[b.jsx("h2",{className:"font-display text-lg font-semibold text-text",children:"Aperçus"}),b.jsx("p",{className:"mt-1",children:"Aucun aperçu sur la branche : la spéculation n'a pas encore rendu d'écran, ou cette spec n'en décrit pas."})]});const g=v.some(S=>S.state===r)?r??"":v[0]?.state??"",x=p===null?`/api/specs/${t}/previews/${g}`:`/api/specs/${t}/previews/${p.name}/${g}`;return b.jsxs(Oi,{"aria-label":"Aperçus de l'écran",className:"text-sm",children:[h.length>1&&b.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 border-b border-border pb-3",children:[b.jsx("span",{className:"font-mono text-xs uppercase tracking-[0.18em] text-text-faint",children:"Compositions"}),b.jsx("div",{role:"radiogroup","aria-label":"Compositions proposées",className:"flex flex-wrap gap-1.5",children:h.map(S=>b.jsx("button",{type:"button",role:"radio","aria-checked":p?.name===S.name,onClick:()=>d(S.name),className:`rounded-full border px-3 py-1 font-mono text-xs transition-colors ${p?.name===S.name?"border-accent bg-accent-soft text-accent":"border-border text-text-muted hover:text-text"}`,children:S.name},S.name))}),p!==null&&p.name===m&&b.jsx(ft,{tone:"positive",children:"retenue"}),p!==null&&p.name!==m&&b.jsx(mt,{voice:"primary",size:"sm",disabled:s.isPending,onClick:()=>s.mutate(p.name),children:s.isPending?"Sélection…":"Retenir cette composition"})]}),s.error!=null&&b.jsx("div",{className:"mb-3",children:b.jsx(Nt,{error:s.error})}),b.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b.jsxs("h2",{className:"font-display text-lg font-semibold text-text",children:["Aperçus ",b.jsx("span",{className:"ml-1 text-sm font-normal text-text-faint",children:"l'écran tel qu'il sera"})]}),b.jsx("div",{role:"tablist",className:"inline-flex rounded-md border border-border bg-surface-sunken p-0.5",children:v.map(S=>b.jsx("button",{role:"tab",type:"button","aria-selected":S.state===g,onClick:()=>o(S.state),className:`rounded px-3 py-1 text-xs font-medium transition-colors duration-(--duration-fast) ease-swell ${S.state===g?"bg-accent text-accent-contrast shadow-raised":"text-text-muted hover:text-text"}`,children:yN[S.state]??S.state},S.state))})]}),b.jsx("iframe",{title:`Aperçu ${g}`,sandbox:"",src:x,className:"mt-3 h-[480px] w-full rounded-md border border-border bg-surface-raised"})]})}function g0(t){return t instanceof r0?g0(t.def.innerType):t}function bN(){const t=os.shape;return Object.keys(t).map(i=>{const s=g0(t[i]);if(s instanceof Oo)return{name:i,kind:"enum",options:s.options.map(r=>String(r)),readOnly:!1};if(s instanceof i0)return{name:i,kind:"string-array",readOnly:!1};if(s instanceof e0)return{name:i,kind:"text",readOnly:i==="id"};throw new Error(`deriveFrontmatterFields: unsupported schema for "${String(i)}" — extend the derivation, never hand-describe the form`)})}function uv(t){return{id:t.id,status:t.status,depends_on:t.depends_on.join(`
68
+ ${o}`,r);c!==-1&&(s.push(o),r=c+o.length)}return s}const mN={green:"CI verte",red:"CI rouge",pending:"CI en cours",none:"aucun check"},pN={green:"positive",red:"danger",pending:"warning",none:"neutral"};function gN({specId:t,role:i}){const s=Yj(t),r=Fj(t);if(s.error)return b.jsx(Nt,{error:s.error});if(s.isPending)return b.jsx("div",{"aria-label":"Chargement de la pull request",className:"h-20 animate-pulse rounded-lg border border-border bg-surface-sunken/60"});const o=s.data;if(r.isSuccess)return b.jsxs("section",{role:"status",className:"studio-rise rounded-lg border border-positive/40 bg-positive-soft p-4 text-sm text-text",children:["Pull request #",r.data.pullRequestNumber," fusionnée : la spec est sur la branche par défaut, le déploiement de développement suit."]});const c=o.canMerge&&ov(i,o.requiredRole);return b.jsxs(Oi,{"aria-label":"Pull request de la spec",className:"text-sm",children:[b.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[b.jsx("h2",{className:"font-display text-lg font-semibold text-text",children:"Pull request"}),o.pullRequest!==null&&b.jsxs(b.Fragment,{children:[b.jsxs("a",{className:"font-mono text-accent underline-offset-4 hover:underline",href:o.pullRequest.url,target:"_blank",rel:"noreferrer",children:["#",o.pullRequest.number]}),b.jsx(ft,{tone:pN[o.checks]??"neutral",children:mN[o.checks]??o.checks}),b.jsx(d0,{status:o.specStatus}),o.needsOperator&&b.jsx(ft,{tone:"orichalcum",children:"en attente de l'opérateur"})]})]}),b.jsx(mt,{voice:"primary",size:"sm",disabled:!c||r.isPending,onClick:()=>r.mutate(),children:r.isPending?"Fusion…":"Fusionner"})]}),o.pullRequest===null?b.jsxs("p",{className:"mt-2 text-text-muted",children:["Aucune pull request ouverte : la prochaine sauvegarde en ouvre une sur ",b.jsx("code",{className:"font-mono text-text",children:o.branch}),"."]}):b.jsxs("p",{className:"mt-2 text-text-muted",children:[b.jsx("span",{className:"text-text",children:o.pullRequest.title})," · branche ",b.jsx("code",{className:"font-mono",children:o.branch})]}),o.blockers.length>0&&b.jsx("ul",{className:"mt-3 space-y-1 text-text-muted",children:o.blockers.map(d=>b.jsxs("li",{className:"flex gap-2",children:[b.jsx("span",{"aria-hidden":"true",className:"text-warning",children:"●"}),d]},d))}),o.pullRequest!==null&&!ov(i,o.requiredRole)&&b.jsxs("p",{className:"mt-3 text-text-muted",children:["La fusion exige le rôle ",o.requiredRole,"."]}),r.error!=null&&b.jsx("div",{className:"mt-3",children:b.jsx(Nt,{error:r.error})})]})}const lv={reader:0,author:1,approver:2,operator:3};function ov(t,i){return(lv[t]??-1)>=(lv[i]??99)}const yN={empty:"Vide",loading:"Chargement",nominal:"Nominal",error:"Erreur"};function vN({specId:t}){const i=Ij(t),s=Wj(t),[r,o]=X.useState(null),[c,d]=X.useState(null);if(i.error)return b.jsx(Nt,{error:i.error});if(i.isPending)return b.jsx("div",{"aria-label":"Chargement des aperçus",className:"h-24 animate-pulse rounded-lg border border-border bg-surface-sunken/60"});const h=i.data.compositions,m=i.data.composition,p=h.length>0?h.find(S=>S.name===c)??h.find(S=>S.selected)??h[0]??null:null,v=p===null?i.data.previews:p.previews;if(v.length===0&&p===null)return b.jsxs("section",{"aria-label":"Aperçus de l'écran",className:"rounded-lg border border-dashed border-border-strong/60 bg-surface-raised/60 p-4 text-sm text-text-muted",children:[b.jsx("h2",{className:"font-display text-lg font-semibold text-text",children:"Aperçus"}),b.jsx("p",{className:"mt-1",children:"Aucun aperçu sur la branche : la spéculation n'a pas encore rendu d'écran, ou cette spec n'en décrit pas."})]});const g=v.some(S=>S.state===r)?r??"":v[0]?.state??"",x=p===null?`/api/specs/${t}/previews/${g}`:`/api/specs/${t}/previews/${p.name}/${g}`;return b.jsxs(Oi,{"aria-label":"Aperçus de l'écran",className:"text-sm",children:[h.length>1&&b.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 border-b border-border pb-3",children:[b.jsx("span",{className:"font-mono text-xs uppercase tracking-[0.18em] text-text-faint",children:"Compositions"}),b.jsx("div",{role:"radiogroup","aria-label":"Compositions proposées",className:"flex flex-wrap gap-1.5",children:h.map(S=>b.jsx("button",{type:"button",role:"radio","aria-checked":p?.name===S.name,onClick:()=>d(S.name),className:`rounded-full border px-3 py-1 font-mono text-xs transition-colors ${p?.name===S.name?"border-accent bg-accent-soft text-accent":"border-border text-text-muted hover:text-text"}`,children:S.name},S.name))}),p!==null&&p.name===m&&b.jsx(ft,{tone:"positive",children:"retenue"}),p!==null&&p.name!==m&&b.jsx(mt,{voice:"primary",size:"sm",disabled:s.isPending,onClick:()=>s.mutate(p.name),children:s.isPending?"Sélection…":"Retenir cette composition"})]}),s.error!=null&&b.jsx("div",{className:"mb-3",children:b.jsx(Nt,{error:s.error})}),b.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b.jsxs("h2",{className:"font-display text-lg font-semibold text-text",children:["Aperçus ",b.jsx("span",{className:"ml-1 text-sm font-normal text-text-faint",children:"l'écran tel qu'il sera"})]}),b.jsx("div",{role:"tablist",className:"inline-flex rounded-md border border-border bg-surface-sunken p-0.5",children:v.map(S=>b.jsx("button",{role:"tab",type:"button","aria-selected":S.state===g,onClick:()=>o(S.state),className:`rounded px-3 py-1 text-xs font-medium transition-colors duration-(--duration-fast) ease-swell ${S.state===g?"bg-accent text-accent-contrast shadow-raised":"text-text-muted hover:text-text"}`,children:yN[S.state]??S.state},S.state))})]}),b.jsx("iframe",{title:`Aperçu ${g}`,sandbox:"",src:x,className:"mt-3 h-[480px] w-full rounded-md border border-border bg-surface-raised"})]})}function g0(t){return t instanceof r0?g0(t.def.innerType):t}function bN(){const t=os.shape;return Object.keys(t).map(i=>{const s=g0(t[i]);if(s instanceof Oo)return{name:i,kind:"enum",options:s.options.map(r=>String(r)),readOnly:!1};if(s instanceof i0)return{name:i,kind:"string-array",readOnly:!1};if(s instanceof e0)return{name:i,kind:"text",readOnly:i==="id"};throw new Error(`deriveFrontmatterFields: unsupported schema for "${String(i)}" — extend the derivation, never hand-describe the form`)})}function uv(t){return{id:t.id,status:t.status,depends_on:t.depends_on.join(`
69
69
  `),priority:t.priority,refs:t.refs.join(`
70
70
  `),deferred:t.deferred.join(`
71
71
  `)}}function _f(t){return t.split(`
@@ -19,7 +19,7 @@
19
19
  // Storage may be unavailable: Abysse then, the default.
20
20
  }
21
21
  </script>
22
- <script type="module" crossorigin src="/assets/index-DB0QPAUz.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-Hn0BK2s5.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-xcKC2Au6.css">
24
24
  </head>
25
25
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygie/studio",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Ogygie framework dev studio: projects a repo's specs and manifest into a local UI. Ships its built UI; launched by `ogygie studio`.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@fastify/static": "^10.1.3",
26
- "@ogygie/core": "0.25.0",
27
- "@ogygie/generate": "0.25.0",
26
+ "@ogygie/core": "0.25.2",
27
+ "@ogygie/generate": "0.25.2",
28
28
  "fastify": "^5.0.0",
29
29
  "fastify-type-provider-zod": "^6.0.0",
30
30
  "zod": "^4.0.0"