@uibot/mcp-server 0.3.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.
Files changed (2) hide show
  1. package/dist/server.js +1 -1
  2. package/package.json +9 -9
package/dist/server.js CHANGED
@@ -135,4 +135,4 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
135
135
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
136
136
  `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){$r(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(n&&t.sep&&!t.value){let o=[];for(let s=0;s<t.sep.length;++s){let a=t.sep[s];switch(a.type){case"newline":o.push(s);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)i=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(Ce(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=He(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ce(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Qc(t.key)&&!Ce(t.sep,"newline")){let o=He(t.start),{key:s,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:a}]})}else if(i.length>0)t.sep=t.sep.concat(i,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:i,key:null,sep:[this.sourceToken]});else if(Ce(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(n||t.value)e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Ce(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(r)e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){$r(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||Ce(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);if(r)this.stack.push(r);else yield*this.pop(),yield*this.step()}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=Br(r),i=He(n);Jc(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
137
137
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
138
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Br(e),r=He(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Br(e),r=He(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}fv.Parser=Xc});var nl=h(function(kv){var Zc=mi(),yv=yt(),wt=ht(),hv=xn(),bv=E(),Cv=xi(),el=Ii();function tl(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Cv.LineCounter||null,prettyErrors:t}}function Sv(e,t={}){let{lineCounter:r,prettyErrors:n}=tl(t),i=new el.Parser(r?.addNewLine),o=new Zc.Composer(t),s=Array.from(o.compose(i.parse(e)));if(n&&r)for(let a of s)a.errors.forEach(wt.prettifyError(e,r)),a.warnings.forEach(wt.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function rl(e,t={}){let{lineCounter:r,prettyErrors:n}=tl(t),i=new el.Parser(r?.addNewLine),o=new Zc.Composer(t),s=null;for(let a of o.compose(i.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new wt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&r)s.errors.forEach(wt.prettifyError(e,r)),s.warnings.forEach(wt.prettifyError(e,r));return s}function vv(e,t,r){let n=void 0;if(typeof t==="function")n=t;else if(r===void 0&&t&&typeof t==="object")r=t;let i=rl(e,r);if(!i)return null;if(i.warnings.forEach((o)=>hv.warn(i.options.logLevel,o)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:n},r))}function wv(e,t,r){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=r??t??{};if(!i)return}if(bv.isDocument(e)&&!n)return e.toString(r);return new yv.Document(e,n,r).toString(r)}kv.parse=vv;kv.parseAllDocuments=Sv;kv.parseDocument=rl;kv.stringify=wv});import{realpathSync as Gl}from"node:fs";import{fileURLToPath as kk}from"node:url";import{Server as Rk}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as xk}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Ik,ListToolsRequestSchema as Ak}from"@modelcontextprotocol/sdk/types.js";var ig=Xl(Fs(),1);var Us=["SetState","ResetState","Request","Link","Validate","DisplayMessage","Login","Logout","CallMethod"],fn={SetState:{name:"SetState",description:"Set a page state path to an evaluated declarative value",params:{path:{type:"string"},value:{description:"Literal or supported PropValue expression"}},generation:{evaluatedParams:["value"],prerequisites:["Declare the state path on the same page"],example:{action:"SetState",params:{path:"open",value:{_not:{_state:"open"}}}}}},ResetState:{name:"ResetState",description:"Restore paths from the supplied initial map; missing values become null",params:{paths:{type:"array",items:{type:"string"}},initial:{type:"object"}},generation:{evaluatedParams:[],prerequisites:["Supply literal initial values; omitting paths resets keys in initial"],example:{action:"ResetState",params:{paths:["open"],initial:{open:!1}}}}},Request:{name:"Request",description:"Execute a configured connection request",params:{connectionId:{type:"string"},request:{type:"object"},loadingPath:{type:"string"},responsePath:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:["connectionId","request"],prerequisites:["Host must inject the declared connection driver and secrets; Studio local Spec preview does not"],example:{action:"Request",params:{connectionId:"projects",request:{id:"list",connectionId:"projects",payload:{operation:"FindAll",resource:"projects"}},responsePath:"rows"}}}},Link:{name:"Link",description:"Emit navigation to a literal URL or page path",params:{path:{type:"string"},url:{type:"string"},target:{enum:["_self","_blank"]}},generation:{evaluatedParams:[],prerequisites:["Host handles navigation; local page paths must exist"],example:{action:"Link",params:{path:"/details"}}}},Validate:{name:"Validate",description:"Emit form validation event; does not itself throw for invalid fields",params:{formId:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host form:validate listener; prefer native required controls and Form.Submit"],example:{action:"Validate",params:{formId:"contact"}}}},DisplayMessage:{name:"DisplayMessage",description:"Emit an evaluated message for the host to display",params:{message:{description:"Literal or supported PropValue expression"},level:{enum:["info","success","warning","error"]},duration:{type:"number"}},generation:{evaluatedParams:["message"],prerequisites:["Requires host message:display listener"],example:{action:"DisplayMessage",params:{message:"Saved locally",level:"success"}}}},Login:{name:"Login",description:"Set a supplied local session user or request external login",params:{user:{type:"object"},provider:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host session/auth; setting a local user is not server authentication"],example:{action:"Login",params:{provider:"configured-provider"}}}},Logout:{name:"Logout",description:"Clear the local session and emit auth:logout",params:{},generation:{evaluatedParams:[],prerequisites:["Host owns server session invalidation"],example:{action:"Logout",params:{}}}},CallMethod:{name:"CallMethod",description:"Emit a call to an existing block method",params:{blockId:{type:"string"},method:{type:"string"},args:{type:"array"}},generation:{evaluatedParams:["args"],prerequisites:["Requires an explicitly documented installed block method/listener; never invent a method"],example:{action:"CallMethod",params:{blockId:"documented-block",method:"documented-method",args:[]}}}}};var lg={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},Ix=Array.from(new Set(Object.values(lg).flat()));var mn=["component","template","design-guide","example","skill"],Ht=["experimental","candidate","recommended"];var js=["missing","declared","verified","external-consumer"],Vs=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure","packed-install","typecheck","browser"],Gt=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])})]);var zs=["resource-mcp-invalid-argument","resource-query-failed"];function Kt(e,t){return`Tool '${e}' is not wired in this build: no '${t}' discovery provider was supplied. `+`This is not an empty result — supply a 'discovery.${t}' provider to enable it.`}function Hs(e){return`Tool '${e}' is not wired in this build: no Hub service was supplied. Supply a service to enable component requests and task status.`}function ug(e){if(e.status==="ready")return{status:"ready",artifact:e.artifact};return{status:e.status,taskId:e.taskId,pollUrl:e.pollUrl}}function dg(e){switch(e.status){case"ready":return{taskId:e.taskId,status:"ready",artifact:e.artifact};case"failed":return{taskId:e.taskId,status:"failed",error:e.error};case"pending":case"running":return{taskId:e.taskId,status:e.status,...typeof e.progress==="number"?{progress:e.progress}:{}}}}function te(e){return{content:[{type:"json",json:e}]}}function j(e){return{content:[{type:"text",text:e}],isError:!0}}function yn(e,t){return{content:[{type:"json",json:{error:{code:e,detail:t}}}],isError:!0}}var Wt="uibot_resource_";function pg(e){return`${Wt}${e}`}function Gs(e,t){let r;if(e==="resource-kind")r={type:"string",enum:[...mn]};else if(e==="resource-maturity")r={type:"string",enum:[...Ht]};else if(e==="positive-integer")r={type:"integer",minimum:1};else r={type:"string"};return t?{type:"array",items:r}:r}function gg(){return Gt.map((e)=>{let t={},r=[];for(let n of e.positionals)if(t[n.property]=Gs(n.type,"variadic"in n&&n.variadic===!0),n.required)r.push(n.property);for(let n of e.options)t[n.property]=Gs(n.type,"multiple"in n&&n.multiple===!0);return{name:pg(e.name),description:e.summary,inputSchema:{type:"object",properties:t,additionalProperties:!1,...r.length?{required:r}:{}}}})}class ie extends Error{detail;code=zs[0];constructor(e){super(e);this.detail=e;this.name="ResourceMcpArgumentError"}}function zt(e,t){let r=new Set(t),n=Object.keys(e).find((i)=>!r.has(i));if(n)throw new ie(`unsupported argument: ${n}`)}function Ks(e,t){let r=e[t];if(r===void 0)return;if(typeof r!=="string"||!r.trim())throw new ie(`${t} must be a non-empty string`);return r}function Le(e,t,r){let n=e[t];if(n===void 0)return;if(!Array.isArray(n)||n.length===0||n.some((i)=>typeof i!=="string"||!i.trim()))throw new ie(`${t} must be a non-empty string array`);if(r){let i=n.find((o)=>!r.includes(o));if(i)throw new ie(`${t} contains unsupported value: ${i}`)}return n}function fg(e){if(e instanceof ie)return yn(e.code,e.detail);if(e&&typeof e==="object"){let t=e;if(typeof t.code==="string"){let r=typeof t.detail==="string"?t.detail:typeof t.message==="string"?t.message:t.code;return yn(t.code,r)}}return yn(zs[1],"resource query callback failed")}async function mg(e,t,r){try{if(e==="manifest")return zt(t,[]),te({data:{index:await r.manifest()}});if(e==="search"){zt(t,["text","kinds","tags","categories","capabilities","maturities","limit"]);let i=Ks(t,"text"),o=Le(t,"kinds",mn),s=Le(t,"tags"),a=Le(t,"categories"),c=Le(t,"capabilities"),l=Le(t,"maturities",Ht),p=t.limit;if(p!==void 0&&(typeof p!=="number"||!Number.isInteger(p)||p<=0))throw new ie("limit must be a positive integer");let g={...i?{text:i}:{},...o?{kinds:o}:{},...s?{tags:s}:{},...a?{categories:a}:{},...c?{capabilities:c}:{},...l?{maturities:l}:{},...typeof p==="number"?{limit:p}:{}};return te({data:{matches:await r.search(g)}})}if(e==="get"){zt(t,["id"]);let i=Ks(t,"id");if(!i)throw new ie("id must be a non-empty string");return te({data:{resource:await r.get(i)}})}zt(t,["roots"]);let n=Le(t,"roots");if(!n)throw new ie("roots must be a non-empty string array");return te({data:{plan:await r.build(n)}})}catch(n){return fg(n)}}function Ws(e){let t=[{name:"uibot_request_component",description:"Request a missing component from the UIBot Hub runtime.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Component name"},context:{type:"string",description:"Optional usage context"},requestedBy:{type:"string",description:"Requester identifier"},priority:{type:"string",enum:["low","normal","high"]}},required:["name"]}},{name:"uibot_get_task_status",description:"Read the status of a Hub task.",inputSchema:{type:"object",properties:{taskId:{type:"string",description:"Hub task identifier"}},required:["taskId"]}},{name:"uibot_list_catalog",description:"List catalog components available to agents (read-only discovery). Returns name/description/category entries.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Optional substring filter on name/description"}}}},{name:"uibot_get_design_md",description:"Get design-md entries (read-only). Omit id to list summaries; provide id for one full entry.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Optional design-md id"}}}},{name:"uibot_list_templates",description:"List installable UIBot templates (read-only discovery).",inputSchema:{type:"object",properties:{query:{type:"string",description:"Optional substring filter"}}}},{name:"uibot_validate",description:"Validate a generated artifact. Pass `spec` (UIBot Spec object, or JSON/YAML text) to compile it against the catalog and get missing-component gaps and warnings; pass `html` to run the design-quality rules. Fix every gap before handing the result on.",inputSchema:{type:"object",properties:{spec:{description:"UIBot Spec object, or its JSON/YAML text"},html:{type:"string",description:"Generated HTML document"}}}},...gg()];return{listTools(){return t.filter((r)=>{if(r.name==="uibot_request_component")return e.serviceAvailable!==!1;if(r.name==="uibot_get_task_status")return e.serviceAvailable!==!1;if(r.name==="uibot_list_catalog")return e.discovery?.listCatalog!=null;if(r.name==="uibot_get_design_md")return e.discovery?.getDesignMd!=null;if(r.name==="uibot_list_templates")return e.discovery?.listTemplates!=null;if(r.name==="uibot_validate")return e.validate!=null;if(r.name.startsWith(Wt))return e.resourceQuery!=null;return!0})},async callTool(r,n){if(r.startsWith(Wt)){let i=r.slice(Wt.length);if(!Gt.some((s)=>s.name===i))return j(`Unknown tool: ${r}`);if(!e.resourceQuery)return j(Kt(r,"resourceQuery"));return mg(i,n,e.resourceQuery)}if(r==="uibot_request_component"){if(e.serviceAvailable===!1)return j(Hs(r));let i=typeof n.name==="string"?n.name:"";if(!i)return j("Field 'name' is required");let o=await e.service.requestComponent({name:i,...typeof n.context==="string"?{context:n.context}:{},...typeof n.requestedBy==="string"?{requestedBy:n.requestedBy}:{},...n.priority==="low"||n.priority==="normal"||n.priority==="high"?{priority:n.priority}:{}});return te(ug(o))}if(r==="uibot_get_task_status"){if(e.serviceAvailable===!1)return j(Hs(r));let i=typeof n.taskId==="string"?n.taskId:"";if(!i)return j("Field 'taskId' is required");let o=e.service.getTaskStatus(i);return o?te(dg(o)):j("Task not found")}if(r==="uibot_list_catalog"){let i=e.discovery?.listCatalog;if(!i)return j(Kt(r,"listCatalog"));let o=await i(),s=Array.isArray(o)?o:[],a=typeof n.query==="string"?n.query.toLowerCase():"",c=a?s.filter((l)=>JSON.stringify(l).toLowerCase().includes(a)):s;return te({items:c,count:c.length})}if(r==="uibot_get_design_md"){let i=e.discovery?.getDesignMd;if(!i)return j(Kt(r,"getDesignMd"));let o=typeof n.id==="string"?n.id:void 0,s=await i(o)??(o?null:[]);return te({id:o??null,data:s})}if(r==="uibot_list_templates"){let i=e.discovery?.listTemplates;if(!i)return j(Kt(r,"listTemplates"));let o=await i(),s=Array.isArray(o)?o:[],a=typeof n.query==="string"?n.query.toLowerCase():"",c=a?s.filter((l)=>JSON.stringify(l).toLowerCase().includes(a)):s;return te({items:c,count:c.length})}if(r==="uibot_validate"){if(!e.validate)return j(`Tool '${r}' is not wired in this build: no 'validate' provider was supplied.`);let i=typeof n.html==="string"?n.html:void 0;if(n.spec===void 0&&i===void 0)return j("Provide 'spec' or 'html'");try{return te(await e.validate({...n.spec===void 0?{}:{spec:n.spec},...i===void 0?{}:{html:i}}))}catch(o){return j(o instanceof Error?o.message:String(o))}}return j(`Unknown tool: ${r}`)}}}function Ys(e){return e.map((t)=>t.type==="text"?{type:"text",text:t.text}:{type:"text",text:t.json===void 0?"null":JSON.stringify(t.json,null,2)})}import{existsSync as ql}from"node:fs";import{fileURLToPath as Fl}from"node:url";var Yt={AppNavigation:{name:"AppNavigation",tags:["navigation"],description:"Workspace navigation with configured groups, brand and account",category:"composite",level:"L2",props:{activePath:{type:"string"},brand:{type:"string"},logoSrc:{type:"string",description:"Optional brand image URL; preserve its aspect ratio"},subtitle:{type:"string"},groups:{type:"array"},workspaces:{type:"array"},userName:{type:"string"},email:{type:"string"},initials:{type:"string"},profileHref:{type:"string"}},events:{onNavigate:{description:"Serializable values in event.values"}}},Field:{name:"Field",tags:["form"],description:"Accessible controlled or local form field; native validation and scalar event values",category:"composite",level:"L2",props:{kind:{type:"string"},label:{type:"string"},name:{type:"string"},value:{description:"String, boolean, or string array according to kind"},defaultValue:{description:"Initial string, boolean, or string array"},options:{type:"array"},description:{type:"string"},error:{type:"string"},required:{type:"boolean"},disabled:{type:"boolean"},placeholder:{type:"string"},rows:{type:"number"},length:{type:"number"},autoComplete:{type:"string"}},events:{onChange:{description:"Serializable values in event.values"}}},StatCard:{name:"StatCard",tags:["metric"],description:"Metric with label, value and supporting text",category:"composite",level:"L2",props:{label:{type:"string"},value:{type:"string"},description:{type:"string"},icon:{type:"string"}},events:{}},BarChart:{name:"BarChart",tags:["chart"],description:"Accessible deterministic bar series with visible labels and hover values",category:"composite",level:"L2",props:{label:{type:"string"},data:{type:"array"},height:{type:"number"},prefix:{type:"string"}},events:{}},AvatarList:{name:"AvatarList",tags:["list"],description:"Compact people and activity list",category:"composite",level:"L2",props:{items:{type:"array"}},events:{}},IntegrationGrid:{name:"IntegrationGrid",tags:["data"],description:"Searchable integrations with explicit capability availability",category:"composite",level:"L2",props:{configurations:{type:"array"},configurable:{type:"boolean"},items:{type:"array"},pending:{type:"boolean"},error:{type:"string"}},events:{onConfigure:{description:"Workspace configuration intent and existing record version"},onAction:{description:"Serializable values in event.values"}}},ChatPanel:{name:"ChatPanel",tags:["interactive"],description:"Conversation selector and controlled message composition",category:"composite",level:"L2",props:{draft:{type:"string"},currentUserId:{type:"string"},conversations:{type:"array"},messages:{type:"array"},selectedId:{type:"string"},pending:{type:"boolean"},canSend:{type:"boolean"},error:{type:"string"}},events:{onDraftChange:{description:"Draft text in event.value; clear only after confirmed persistence"},onSelect:{description:"Serializable values in event.values"},onSend:{description:"Serializable values in event.values"}}},DataTable:{name:"DataTable",description:"Configurable record table with search, facets, sorting, stable selection and pagination. Server mode emits query intent without filtering current-page rows.",category:"composite",level:"L2",tags:["table","records","admin"],props:{rows:{type:"array"},columns:{type:"array"},filters:{type:"array"},actions:{type:"array"},bulkActions:{type:"array"},rowKey:{type:"string",default:"id"},searchKeys:{type:"array"},selectedIds:{type:"array"},view:{description:"Controlled TableView object or JSON-encoded URL view"},pageSize:{type:"number",default:10},server:{type:"boolean"},total:{type:"number"},hasNextPage:{type:"boolean"},loading:{type:"boolean"},error:{type:"string"},minWidth:{type:"number"},searchPlaceholder:{type:"string"},label:{type:"string"},selectable:{type:"boolean"},emptyText:{type:"string"}},events:{onViewChange:{description:"Query intent in event.values: search, filters JSON, sort, descending, page, pageSize"},onSelectionChange:{description:"Stable ids in event.values.ids"},onRowAction:{description:"event.values.id and action"},onBulkAction:{description:"event.values.ids and action"}}},Box:{name:"Box",description:"Flex container for composing layout. Use as a row or column spacer between other blocks.",category:"primitive",level:"L1",tags:["container","layout"],props:{direction:{type:"string",enum:["col","row"],default:"col",description:"Flex direction"},gap:{type:"string",enum:["none","xs","sm","md","lg","xl"],default:"md"},padding:{type:"string",enum:["none","xs","sm","md","lg","xl"]},align:{type:"string",enum:["start","center","end","stretch"]},justify:{type:"string",enum:["start","center","end","between","around"]},wrap:{type:"boolean",default:!1},full:{type:"boolean",default:!1}},usageScenarios:["Horizontal row of action buttons","Vertical stack of form fields","Two-column grid using two Box[direction=row] with flex-1 children"],constraints:["Do not use Box as a semantic section; prefer Card or PageLayout for major layout regions"]},PageLayout:{name:"PageLayout",description:"Top-level page scaffold: sticky header, optional sidebar, scrollable main area, optional footer.",category:"composite",level:"L2",tags:["page","layout"],props:{appearance:{type:"string",enum:["default","admin"]},routes:{type:"array"},headerLinks:{type:"array"},accountLinks:{type:"array"},tokens:{type:"object",description:"Admin frame sidebar/surface/foreground/accent/accent-foreground/border/font and primary/primary-foreground CSS tokens"},theme:{type:"string"},font:{type:"string"},direction:{type:"string"},initials:{type:"string"},title:{type:"string",description:"App or page title shown in the sticky header"},variant:{type:"string",enum:["sidebar","inset","floating"],default:"sidebar",description:"Frame: flush sidebar, inset main, or floating sidebar card"},collapsible:{type:"string",enum:["none","icon","offcanvas"],default:"none",description:"How the sidebar collapses; default none keeps v2.40 width"}},events:{onThemeChange:{description:"Selected theme in event.value"}},slots:{headerActions:{description:"Buttons or links placed in the top-right of the header"},sidebar:{description:"Left sidebar content, e.g. PageSiderMenu"},footer:{description:"Bottom footer strip"}},usageScenarios:["Admin dashboard shell","Settings page with left navigation","Landing page with header and main content"],constraints:["Use at most one PageLayout per page","Do not nest PageLayout inside another PageLayout"]},Card:{name:"Card",description:"Surface container with rounded border and optional header (title + description + actions slot).",category:"composite",level:"L2",tags:["card","surface"],props:{title:{type:"string",description:"Card heading"},description:{type:"string",description:"Supporting subtitle text"}},slots:{actions:{description:"Action buttons rendered in the top-right of the card header"},default:{description:"Card body content"}},usageScenarios:["Stats overview section","User profile panel","Settings form container"],constraints:["Avoid nesting Card directly inside another Card"]},Tabs:{name:"Tabs",description:"Tab switcher. Each child maps to the tab at the same index. Supports up to 6 tabs.",category:"composite",level:"L2",tags:["tabs","navigation"],props:{variant:{type:"string",enum:["underline","segmented"]},disabledTabs:{type:"array",items:{type:"integer"}},value:{type:"integer"},tabs:{type:"array",items:{type:"string"},description:"Tab label list, e.g. [Overview, Details, Activity]"},defaultTab:{type:"integer",default:0,description:"0-based index of the initially active tab"}},usageScenarios:["Split view of Overview / Settings / Logs","Mobile-friendly section switcher"],constraints:["Children count must equal tabs array length","Do not use more than 6 tabs"]},Drawer:{name:"Drawer",description:"Off-canvas side panel for secondary context (filters, details, comments). Rendered inline in preview.",category:"composite",level:"L2",tags:["drawer","overlay"],events:{onClose:{description:"Close requested; set controlled open false"}},props:{open:{type:"boolean"},pending:{type:"boolean"},title:{type:"string"}},usageScenarios:["Filter panel for a table","Item detail side sheet"],constraints:["Drawer is always visible in static preview — use conditionally in production via state"]},Modal:{name:"Modal",description:"Centered overlay dialog for focused tasks or confirmations. Rendered inline in preview.",category:"composite",level:"L2",tags:["modal","overlay"],events:{onClose:{description:"Close requested; set controlled open false"}},props:{open:{type:"boolean"},pending:{type:"boolean"},title:{type:"string"},description:{type:"string"}},usageScenarios:["Create / edit form dialog","Image preview lightbox"],constraints:["Modal is always visible in static preview — drive open/close state from actions in production"]},Divider:{name:"Divider",description:"Thin horizontal (default) or vertical separator line.",category:"primitive",level:"L1",tags:["separator"],props:{orientation:{type:"string",enum:["horizontal","vertical"],default:"horizontal"}},usageScenarios:["Visual break between form sections","Vertical separator between two columns"],constraints:[]},PageSiderMenu:{name:"PageSiderMenu",description:"Vertical sidebar navigation. Place MenuLink or MenuGroup blocks as children. Usually placed in the PageLayout sidebar slot.",category:"composite",level:"L2",tags:["sidebar","nav"],props:{title:{type:"string",description:"Section heading above menu items"}},slots:{header:{description:"Workspace switcher or brand above the menu list"},footer:{description:"User card or secondary links below the menu list"}},usageScenarios:["Admin left nav (Dashboard, Users, Settings)","Docs section navigation"],constraints:["Always use as a sibling inside PageLayout sidebar slot; do not place in main content area"]},MenuGroup:{name:"MenuGroup",description:"Labeled group of MenuLink items inside PageSiderMenu.",category:"composite",level:"L2",tags:["sidebar","nav"],props:{title:{type:"string",description:"Group heading shown above the links"}},usageScenarios:["Platform vs Workspace nav groups","Settings section grouping"],constraints:["Must be a direct child of PageSiderMenu"]},MenuLink:{name:"MenuLink",description:"Single navigation item inside a PageSiderMenu. Renders as an anchor with optional icon and badge.",category:"primitive",level:"L1",tags:["nav","link"],props:{label:{type:"string"},href:{type:"string"},icon:{type:"string",description:"Emoji or Unicode glyph"},badge:{type:"string",description:"Count or label shown on the right"},active:{type:"boolean",default:!1}},usageScenarios:["Dashboard menu item","Settings section link with unread badge"],constraints:["Must be a direct child of PageSiderMenu or MenuGroup"]},Link:{name:"Link",description:"Inline hyperlink. Variants: default (blue underline), muted (gray), button (filled CTA), outline (bordered CTA).",category:"primitive",level:"L1",tags:["link"],props:{label:{type:"string"},href:{type:"string"},variant:{type:"string",enum:["default","muted","button","outline"],default:"default"},target:{type:"string",enum:["_self","_blank"],default:"_self"},className:{type:"string",description:"Extra utility classes appended to the variant chrome."}},usageScenarios:["Inline 'Read more' link in a paragraph","CTA button-style link in a hero section"],constraints:[]},Breadcrumb:{name:"Breadcrumb",description:"Hierarchical page path trail. Pass an items array of {label, href?}.",category:"composite",level:"L2",tags:["breadcrumb","nav"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},href:{type:"string"}}},description:"Path segments"}},usageScenarios:["Page location context in an admin CRUD view","Multi-step wizard progress"],constraints:[]},List:{name:"List",description:"Unordered list of child blocks. Use with divided or compact for different visual densities.",category:"composite",level:"L2",tags:["list"],props:{divided:{type:"boolean",default:!1,description:"Add hairline dividers between items"},compact:{type:"boolean",default:!1},label:{type:"string",description:"ARIA label"}},usageScenarios:["Recent activity feed","Search result list"],constraints:[]},Table:{name:"Table",description:"Data grid with typed columns and row data. Columns define keys and display labels.",category:"composite",level:"L2",tags:["table","grid","data"],props:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"},align:{type:"string",enum:["left","center","right"]}}},description:"[{key, label, align?}]"},rows:{type:"array",items:{type:"object"},description:"Array of data objects keyed to column.key"},emptyText:{type:"string",default:"No data"},striped:{type:"boolean",default:!0},caption:{type:"string"}},usageScenarios:["User management list","Order history table","API endpoint catalog"],constraints:["rows entries must have keys matching column.key; missing keys render empty string","Avoid more than 8 columns"]},Stat:{name:"Stat",description:"KPI metric card: large value, label, optional trend arrow, and change string.",category:"primitive",level:"L2",tags:["stat","kpi","metric"],props:{label:{type:"string"},value:{type:"string",description:"Main metric value, e.g. 1,234 or $12k"},change:{type:"string",description:'Change label, e.g. "+12% vs last month"'},trend:{type:"string",enum:["up","down"]},description:{type:"string",description:"Secondary helper text"}},usageScenarios:["Dashboard KPI row (4 Stat blocks side-by-side in a Box[direction=row])","Single revenue metric in a Card"],constraints:["Do not put detailed charts inside a Stat; use Stat only for a single number + context"]},Markdown:{name:"Markdown",description:"Renders Markdown source into HTML. Supports # headings, **bold**, *italic*, `code`, and - lists.",category:"primitive",level:"L1",tags:["text","markdown","content"],props:{content:{type:"string",description:"Markdown source text"}},usageScenarios:["Documentation sections","Feature descriptions on a landing page","Release notes"],constraints:["No HTML injection; only Markdown syntax is parsed"]},Heading:{name:"Heading",description:"Semantic heading tag h1–h6 with size automatically mapped to the level.",category:"primitive",level:"L1",tags:["text","heading","typography"],props:{text:{type:"string"},level:{type:"integer",default:2,description:"1=largest, 6=smallest"},muted:{type:"boolean",default:!1,description:"Render in muted-foreground"}},usageScenarios:["Section title above a Table or Card","Hero headline on a landing page"],constraints:["Use only one h1 per page"]},Paragraph:{name:"Paragraph",description:"Body text block. Use size='lg' for lead copy, size='sm' for captions.",category:"primitive",level:"L1",tags:["text","typography"],props:{text:{type:"string"},size:{type:"string",enum:["sm","md","lg"],default:"md"},muted:{type:"boolean",default:!1}},usageScenarios:["Feature description below a Heading","Helper caption below a form field"],constraints:[]},Form:{name:"Form",description:"Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.",category:"composite",level:"L2",tags:["form","input"],props:{idempotent:{type:"boolean",description:"Emit a stable event.value idempotency key while retrying unchanged form values"},pending:{type:"boolean"},label:{type:"string"},layout:{type:"string",enum:["vertical","horizontal"],default:"vertical"}},events:{onChange:{description:"Bubbled native field changes with { type, name, value, checked }."},onSubmit:{description:"Runs after native submission is prevented.",payload:{type:"object",description:"{ type: 'submit', values: Record<string, value> }"}}},usageScenarios:["Create / edit entity form","Login form","Search filter form"],constraints:["Always include exactly one Form.Submit as the last child","Do not nest forms inside forms"]},"Form.Input":{name:"Form.Input",description:"Single-line text field. Supports text, email, password, number, tel, url, date types.",category:"primitive",level:"L1",tags:["form","input"],props:{name:{type:"string",description:"Field identifier (must be unique in the form)"},label:{type:"string"},type:{type:"string",enum:["text","email","password","number","tel","url","date","search"],default:"text"},placeholder:{type:"string"},helpText:{type:"string"},error:{type:"string"},required:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Email address field in a login form","Search bar with type=search","Price input with type=number"],constraints:["name prop is required and must be unique within the parent Form"]},"Form.Select":{name:"Form.Select",description:"Dropdown select field with an options array [{value, label}].",category:"primitive",level:"L1",tags:["form","select"],props:{name:{type:"string"},label:{type:"string"},options:{type:"array",items:{type:"object",properties:{value:{type:"string"},label:{type:"string"}}},description:"[{value, label}]"},placeholder:{type:"string"},required:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Role selector (Admin/Editor/Viewer)","Status filter dropdown"],constraints:[]},"Form.TextArea":{name:"Form.TextArea",description:"Multi-line text input. Use for descriptions, messages, or any free-form long text.",category:"primitive",level:"L1",tags:["form","textarea"],props:{name:{type:"string"},label:{type:"string"},placeholder:{type:"string"},rows:{type:"integer",default:4},helpText:{type:"string"},required:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Bio / description field on a profile form","Message body in a contact form"],constraints:[]},"Form.Checkbox":{name:"Form.Checkbox",description:"Single boolean checkbox with optional description beneath the label.",category:"primitive",level:"L1",tags:["form","checkbox"],props:{name:{type:"string"},label:{type:"string"},description:{type:"string"},checked:{type:"boolean",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value, checked }."}},usageScenarios:["Terms & conditions consent","Opt-in notification preference"],constraints:[]},"Form.Submit":{name:"Form.Submit",description:"Form submit button. Use variant=destructive for irreversible actions.",category:"primitive",level:"L1",tags:["form","button"],props:{label:{type:"string",default:"Submit"},variant:{type:"string",enum:["default","destructive","outline","ghost"],default:"default"},full:{type:"boolean",default:!1}},events:{onClick:{description:"Runs with a plain click payload before the parent form submits."}},usageScenarios:["Save button at the bottom of a form","Delete action with variant=destructive"],constraints:["Must be inside a Form block"]},Button:{name:"Button",description:"Standalone action button. Six visual variants and five sizes. Does not submit forms — use Form.Submit for that.",category:"primitive",level:"L1",tags:["button","action"],props:{label:{type:"string"},variant:{type:"string",enum:["default","destructive","outline","secondary","ghost","link"],default:"default"},size:{type:"string",enum:["xs","sm","default","lg","icon"],default:"default"},full:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1}},events:{onClick:{description:"Runs with a plain click payload."}},usageScenarios:["Primary CTA on a hero section","Row of outline action buttons in a Card actions slot","Ghost icon button in a toolbar"],constraints:["Use Form.Submit, not Button[type=submit], inside a Form","Do not place more than 3 primary (default) buttons on the same view"]},Toast:{name:"Toast",description:"Alert banner (info, success, warning, error); placement top-right floats it as a dismissible corner notice.",category:"primitive",level:"L1",tags:["toast","alert","notification"],props:{message:{type:"string"},title:{type:"string"},level:{type:"string",enum:["info","success","warning","error"],default:"info"},closeable:{type:"boolean",default:!0},placement:{type:"string",enum:["inline","top-right"],default:"inline"},duration:{type:"number",description:"Auto-dismiss after ms"}},usageScenarios:["Success message after form submit","Sample-data notice (top-right)"],constraints:["Keep floating notices to a title and one or two short lines"]},Dialog:{name:"Dialog",description:"Confirmation dialog with title, description, and optional cancel/confirm buttons. Rendered inline in preview.",category:"composite",level:"L2",tags:["dialog","modal","confirm"],props:{title:{type:"string"},description:{type:"string"},cancelLabel:{type:"string"},confirmLabel:{type:"string"},confirmVariant:{type:"string",enum:["default","destructive","outline"],default:"default"}},usageScenarios:["Delete confirmation prompt","Unsaved changes warning before navigation"],constraints:["Dialog is always visible in static preview — drive open/close state via actions in production"]},PanelHeader:{name:"PanelHeader",description:"Section title with optional eyebrow, description and an `actions` slot for buttons or links.",category:"primitive",level:"L1",tags:["header","section","title"],props:{eyebrow:{type:"string"},title:{type:"string"},description:{type:"string"}},slots:{actions:{description:"Buttons or links aligned to the right of the title"}},usageScenarios:["Title and helper text above a table","Panel header with a Refresh button"],constraints:["Use Heading for in-flow headings that need an explicit level"]},EmptyState:{name:"EmptyState",description:"Empty or recoverable status panel (role=status) with title, message and an optional action button.",category:"primitive",level:"L1",tags:["empty","status","placeholder"],props:{title:{type:"string"},message:{type:"string"},description:{type:"string",description:"Alias of message"},actionLabel:{type:"string",description:"Renders an action button when set"}},events:{onClick:{description:"Action button click; onAction is accepted as an alias."}},usageScenarios:["No results after filtering, with a Clear filters action"],constraints:["Use Alert for errors that need immediate attention"]},FactList:{name:"FactList",description:"Key/value fact list (dl). Pass `items` or FactRow children. Not a KPI card; use StatCard for metrics.",category:"composite",level:"L1",tags:["facts","key-value","details"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},code:{type:"boolean"},href:{type:"string"},hrefSection:{type:"string"}}}}},usageScenarios:["Provider detail: base URL, model, revision"],constraints:["Items render as plain rows or links; use FactRow children for onClick"]},FactRow:{name:"FactRow",description:"One fact row inside FactList. `code` renders the value monospaced; `href` / `hrefSection` (-> #section) render a link; onClick makes the value a button.",category:"primitive",level:"L1",tags:["facts","key-value"],props:{label:{type:"string"},value:{type:"string"},code:{type:"boolean",default:!1},href:{type:"string"},hrefSection:{type:"string"}},events:{onClick:{description:"Runs with a plain click payload."}},constraints:["Place inside FactList"]},Alert:{name:"Alert",description:"Inline alert with icon, title and description. destructive uses role=alert; other variants role=status. Status is conveyed by icon and hidden label text, not colour alone.",category:"primitive",level:"L1",tags:["alert","notice","feedback"],props:{variant:{type:"string",enum:["default","destructive","warning","success"],default:"default"},title:{type:"string"},description:{type:"string"},message:{type:"string",description:"Alias of description"}},usageScenarios:["Guardrail notice","Save succeeded","Request failed"]},Badge:{name:"Badge",description:"Small status label. Text is the status; colour is only reinforcement. Children or `label` provide the text.",category:"primitive",level:"L1",tags:["badge","status","label"],props:{variant:{type:"string",enum:["default","secondary","outline","success","warning","destructive"],default:"default"},label:{type:"string"}},usageScenarios:["Provider state: Active / Disabled","Row status in a table"]},Switch:{name:"Switch",description:"Controlled boolean switch (role=switch) with accessible label. Supports _bindState on checked; onChange carries event.checked.",category:"primitive",level:"L1",tags:["switch","toggle","form"],props:{label:{type:"string"},checked:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1}},events:{onChange:{description:"Runs with { type: 'change', checked }"}},usageScenarios:["Enable or disable a provider","Feature flag toggle"],constraints:["Always set label so the control has an accessible name"]},Skeleton:{name:"Skeleton",description:"Animated loading placeholder. Three presets: lines (text), card (avatar + lines), table (header + rows).",category:"primitive",level:"L1",tags:["skeleton","loading","placeholder"],props:{lines:{type:"integer",default:3,description:"Number of skeleton rows (for lines and table types)"},type:{type:"string",enum:["lines","card","table"],default:"lines"}},usageScenarios:["Loading state while fetching table data","Card placeholder during profile load"],constraints:["Replace with real content once data loads; do not keep Skeleton visible indefinitely"]}};var Jt={Grid:{name:"Grid",description:"Declarative grid layout. Maps cols/gap/responsive props to Tailwind grid classes; children become grid cells directly.",category:"primitive",level:"L1",tags:["layout","grid","container"],props:{cols:{enum:["1","2","3","4","5","6","auto",1,2,3,4,5,6],default:"auto",description:"Column count, or 'auto' for auto-fit minmax(220px,1fr)"},gap:{type:"string",enum:["none","xs","sm","md","lg","xl"],default:"md"},responsive:{type:"boolean",default:!1,description:"Use a mobile-first ladder (grid-cols-1 → sm:2 → lg:N) instead of a fixed column count"},align:{type:"string",enum:["start","center","end","stretch"]},justify:{type:"string",enum:["start","center","end","between","around"]}},usageScenarios:["4-up Stat dashboard row (cols=4)","Responsive card gallery (cols=3, responsive=true)","Two-column form layout (cols=2)"],constraints:["Grid children become grid cells directly; do not wrap each child in a Box","Use cols='auto' when the number of children is dynamic"]},StatGrid:{name:"StatGrid",description:"Responsive grid of KPI cards. Prefers child Stat blocks; falls back to inline rendering of an items array when there are no children.",category:"composite",level:"L2",tags:["stat","kpi","dashboard","grid"],props:{cols:{type:"string",enum:["1","2","3","4","auto"],default:"auto"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},change:{type:"string"},trend:{type:"string",enum:["up","down"]},description:{type:"string"}}},description:"Inline KPI items used when no Stat children are provided"}},usageScenarios:["Overview dashboard KPI row","Operations metrics summary above a table"],constraints:["Provide either Stat children or items, not both — children win when present"]},TrendChart:{name:"TrendChart",description:"Pure-SVG line / area chart with no third-party dependency. Draws one polyline per series on a shared vertical scale. Alias: LineChart.",category:"composite",level:"L2",tags:["chart","trend","line","svg"],props:{title:{type:"string"},series:{type:"array",items:{type:"object",properties:{name:{type:"string"},points:{type:"array",items:{type:"number"}},area:{type:"boolean",default:!1}}},description:"[{name, points:number[], area?}]"},labels:{type:"array",items:{type:"string"},description:"Optional x-axis labels"},width:{type:"integer",default:480},height:{type:"integer",default:160}},usageScenarios:["Evolution score trend over versions","Daily active users line chart"],constraints:["Keep each series under ~200 points; larger inputs produce heavy SVG DOM"]},LineChart:{name:"LineChart",description:"Alias of TrendChart — pure-SVG multi-series line / area chart.",category:"composite",level:"L2",tags:["chart","line","svg"],props:{title:{type:"string"},series:{type:"array",items:{type:"object",properties:{name:{type:"string"},points:{type:"array",items:{type:"number"}},area:{type:"boolean"}}}},width:{type:"integer",default:480},height:{type:"integer",default:160}},usageScenarios:["Same as TrendChart; use whichever name reads better in the spec"],constraints:["Identical implementation to TrendChart"]},KanbanBoard:{name:"KanbanBoard",description:"Horizontal kanban board: columns as swimlanes, cards grouped by their column id. Read-only display.",category:"composite",level:"L3",tags:["kanban","board","operations"],props:{columns:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"}}},description:"[{id, title}] swimlane definitions"},cards:{type:"array",items:{type:"object",properties:{id:{type:"string"},column:{type:"string"},title:{type:"string"},subtitle:{type:"string"},badge:{type:"string"}}},description:"[{id, column, title, subtitle?, badge?}] — column must match a column id"}},usageScenarios:["Operations task board (Todo / In progress / Done)","Release pipeline stages"],constraints:["Each card.column must reference an existing column.id, else the card is dropped","Up to 4 columns fit the container as an equal-width grid (no scrollbar); 5+ columns switch to a horizontal scroll strip"]},Matrix:{name:"Matrix",description:"Two-dimensional intensity grid (heatmap). Cell intensities are 0..1 and map to a color-mix of the primary token via inline style. Alias: Heatmap.",category:"composite",level:"L3",tags:["matrix","heatmap","grid","governance"],props:{caption:{type:"string"},rows:{type:"array",items:{type:"string"},description:"Row labels"},cols:{type:"array",items:{type:"string"},description:"Column labels"},cells:{type:"array",items:{type:"array",items:{type:"number"}},description:"rows×cols grid of intensities in [0,1]"},showValues:{type:"boolean",default:!1,description:"Print the numeric value in each cell"}},usageScenarios:["Governance capability coverage matrix","Risk heatmap (likelihood × impact)"],constraints:["Intensities are single-polar 0..1; negative / diverging scales are not supported","cells should be rows.length × cols.length; missing cells render as 0"]},Heatmap:{name:"Heatmap",description:"Alias of Matrix — two-dimensional 0..1 intensity grid.",category:"composite",level:"L3",tags:["heatmap","matrix","grid"],props:{caption:{type:"string"},rows:{type:"array",items:{type:"string"}},cols:{type:"array",items:{type:"string"}},cells:{type:"array",items:{type:"array",items:{type:"number"}}},showValues:{type:"boolean",default:!1}},usageScenarios:["Same as Matrix"],constraints:["Identical implementation to Matrix"]},DiagnosticsList:{name:"DiagnosticsList",description:"Levelled diagnostics list with a coloured left bar and glyph per severity (info / warn / error).",category:"composite",level:"L2",tags:["diagnostics","list","status","overview"],props:{items:{type:"array",items:{type:"object",properties:{level:{type:"string",enum:["info","warn","error"]},title:{type:"string"},detail:{type:"string"}}},description:"[{level, title, detail?}]"}},usageScenarios:["Overview page diagnostics slot","Spec validation results list"],constraints:["level defaults to 'info' when omitted or unrecognised"]},TimelineList:{name:"TimelineList",description:"Vertical timeline with a left rail and a status dot per item (ok / warn / error).",category:"composite",level:"L2",tags:["timeline","activity","operations"],props:{items:{type:"array",items:{type:"object",properties:{time:{type:"string"},title:{type:"string"},desc:{type:"string"},status:{type:"string",enum:["ok","warn","error"]}}},description:"[{time, title, desc?, status?}]"}},usageScenarios:["Operations event timeline","Deployment / audit history"],constraints:["status defaults to 'ok' when omitted"]},SearchableTable:{name:"SearchableTable",description:"Table with a built-in search box. Typing dispatches SetState onto searchKey and filters the resolved rows (case-insensitive substring across all columns).",category:"feature",level:"L3",tags:["table","search","interactive","data"],props:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"},align:{type:"string",enum:["left","center","right"]}}}},rows:{type:"array",items:{type:"object"},description:"Row objects keyed to column.key"},searchKey:{type:"string",default:"search",description:"State path the search query writes to"},placeholder:{type:"string",default:"Search…"},emptyText:{type:"string",default:"No matching rows",description:"Copy shown when the filtered row set is empty"}},usageScenarios:["Searchable plugins / catalog list in studio","User management table with live filtering"],constraints:["Requires a live host (dispatch) for the search box to update host state; client-side filtering still works on already-resolved rows"]},SplitMasterDetail:{name:"SplitMasterDetail",description:"Master/detail split: a selectable left list and a right detail pane. Clicking an item dispatches SetState onto selectKey; the detail slot (or children) renders the right pane.",category:"feature",level:"L3",tags:["split","master-detail","interactive","layout"],props:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"},subtitle:{type:"string"}}},description:"[{id, title, subtitle?}] left-list entries"},selectKey:{type:"string",default:"selectedId",description:"State path the selected id writes to"}},slots:{detail:{description:"Right-pane content; usually host-composed from the selected item via _find"}},usageScenarios:["Skills list → skill detail","Agents directory → agent inspector"],constraints:["Selection defaults to the first item's id until the host updates selectKey"]},DetailField:{name:"DetailField",description:"Label + value display row, for use inside a detail pane.",category:"primitive",level:"L1",tags:["detail","field","display"],props:{label:{type:"string"},value:{type:"string",description:"Any scalar; rendered as '—' when empty"},inline:{type:"boolean",default:!1,description:"Render label and value on one line"}},usageScenarios:["Field row inside a SplitMasterDetail detail pane","Read-only record summary"],constraints:["Use for scalar values; for structured data prefer KeyValueGrid"]},BadgeGroup:{name:"BadgeGroup",description:"Horizontal group of status badges. Items may be plain strings or {label, tone}.",category:"composite",level:"L1",tags:["badge","status","tags"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},tone:{type:"string",enum:["default","success","warning","error","info"]}}},description:"Array of strings or [{label, tone?}]"}},usageScenarios:["Status / tag chips on a list row","Capability flags on an agent card"],constraints:["tone defaults to 'default' when omitted or unrecognised"]},KeyValueGrid:{name:"KeyValueGrid",description:"Compact key/value grid for metadata. Accepts an items array or a plain record object.",category:"composite",level:"L1",tags:["key-value","metadata","grid","display"],props:{items:{type:"array",items:{type:"object",properties:{key:{type:"string"},value:{type:"string"}}},description:"[{key, value}] pairs (or pass a plain object as `data`)"},cols:{enum:["1","2","3",1,2,3],default:"2"}},usageScenarios:["Model metadata panel (provider, context, pricing)","Request / response header summary"],constraints:["Values are stringified for display; pass pre-formatted strings for control"]},Hero:{name:"Hero",description:"Asymmetric editorial hero: serif display title (with optional italic emphasis word), mono eyebrow with amber dot, warm radial-glow + blueprint dot-grid backdrop, grain overlay, staggered reveal, and primary/secondary CTAs. An optional right-side visual renders via the `aside` slot or children.",category:"presentation",level:"L3",tags:["hero","marketing","landing","editorial"],props:{eyebrow:{type:"string",description:"Mono uppercase kicker above the title"},title:{type:"string",description:"Serif display headline"},titleEmphasis:{type:"string",description:"Optional trailing word rendered italic + amber for emphasis"},subtitle:{type:"string",description:"Supporting lead paragraph"},primaryCta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"},secondaryCta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — outline button"},note:{type:"string",description:"Small mono note under the CTAs"}},slots:{aside:{description:"Right-pane visual (e.g. a rendered spec preview); hidden on mobile"}},usageScenarios:["Studio landing-page hero introducing 'AI writes the spec, the platform renders the UI'","Product launch hero with a spec snippet preview on the right"],constraints:["CTA props are {label, href}; href defaults to '#' when omitted","Use titleEmphasis for a single emphasis word, not the whole title"]},BrowserFrame:{name:"BrowserFrame",description:"Product-screenshot window shell: frames its `content` slot (or children) in a precise browser/app chrome — three traffic-light dots + a mono title/address bar — with a hairline border, long soft shadow, and an optional 3D tilt. Used to present a live-rendered UI as a product-shot visual (dogfood) instead of a static screenshot.",category:"presentation",level:"L2",tags:["frame","browser","window","screenshot","marketing"],props:{title:{type:"string",description:"Address/title shown in the window chrome (defaults to 'app.uibot.studio')"},variant:{type:"string",enum:["flat","tilt"],default:"flat",description:"'tilt' adds a subtle 3D perspective tilt for a product-shot feel"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the chrome address bar wash (0 amber · 1 teal · 2 rose · 3 indigo)"}},slots:{content:{description:"The UI rendered inside the frame; usually a real dashboard composed from data blocks"}},usageScenarios:["Hero visual framing a live-rendered mini dashboard as the product shot","Showcase row of small frames each rendering a different UI from the same engine"],constraints:["Frames the `content` slot, falling back to children; supply real spec blocks to render a live UI","Decorative chrome only — it does not add browser behaviour (no real address bar)"]},SectionHeader:{name:"SectionHeader",description:"Editorial section header: oversized mono section number (e.g. '01'), mono eyebrow, serif title, and a lead paragraph. Sets the rhythm between page sections.",category:"presentation",level:"L2",tags:["section","header","marketing","editorial"],props:{sectionNo:{type:"string",description:"Oversized mono numeral, e.g. '01'"},eyebrow:{type:"string",description:"Mono uppercase kicker"},title:{type:"string",description:"Serif section title"},lead:{type:"string",description:"Lead / intro paragraph"}},usageScenarios:["Numbered section dividers on a landing page (01 Features, 02 How it works)","Editorial chapter header above a FeatureGrid"],constraints:["sectionNo is display text; any string works (e.g. '01', 'A', '§1')"]},FeatureGrid:{name:"FeatureGrid",description:"Responsive grid of hairline feature cards with hover lift. Renders an `items` array (icon name + title + desc) into FeatureCards, or lays out FeatureCard children directly.",category:"presentation",level:"L2",tags:["features","grid","cards","marketing"],props:{cols:{type:"string",enum:["2","3","4"],default:"3"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string",description:"lucide icon name (sparkles, zap, layers, code, cpu, workflow, gauge, shield, wand, boxes)"},title:{type:"string"},desc:{type:"string"}}},description:"[{icon, title, desc}] feature entries"}},usageScenarios:["Three-up feature highlights under a SectionHeader","Capability grid (declarative spec, gap recovery, plugin catalog)"],constraints:["icon is a lucide name mapped to a built-in inline SVG; unknown names fall back to a dot","Provide either items or FeatureCard children — children win when present"]},FeatureCard:{name:"FeatureCard",description:"Single hairline feature card: inline-SVG icon, serif title, body copy, and optional children. Designed to sit inside a FeatureGrid but works standalone.",category:"presentation",level:"L1",tags:["feature","card","marketing"],props:{icon:{type:"string",description:"lucide icon name (see FeatureGrid)"},title:{type:"string"},desc:{type:"string"}},usageScenarios:["A single emphasised feature beside a screenshot","Composed children inside a FeatureGrid for custom card bodies"],constraints:["icon resolves against the built-in inline-SVG set; unknown → dot fallback"]},CodeShowcase:{name:"CodeShowcase",description:"Mono code panel with window chrome (three dots) and line numbers, used to showcase a UIBot YAML/JSON spec. Pure CSS, no syntax-highlighter dependency.",category:"presentation",level:"L2",tags:["code","spec","showcase","marketing"],props:{title:{type:"string",description:"Filename / label shown in the window chrome"},code:{type:"string",description:"Raw code string; newline-separated, rendered with line numbers"},caption:{type:"string",description:"Caption under the panel"}},usageScenarios:["Show an example UIBot YAML spec on the landing page","Before/after spec snippet in a docs section"],constraints:["code is plain text rendered verbatim with line numbers; no highlighting/escaping beyond React's default"]},CtaBand:{name:"CtaBand",description:"Inverted ink-black call-to-action band with grain overlay and a single amber CTA. Closes a landing page with high contrast.",category:"presentation",level:"L2",tags:["cta","band","marketing","conversion"],props:{title:{type:"string",description:"Serif headline"},subtitle:{type:"string",description:"Supporting line"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"}},usageScenarios:["Final 'Start building' band at the bottom of the landing page","Newsletter / docs CTA between sections"],constraints:["Single CTA by design; cta.href defaults to '#' when omitted"]},Faq:{name:"Faq",description:"Editorial accordion FAQ built on native <details>/<summary> — fully functional with zero JS / state wiring. Optional eyebrow/title/lead header; rows carry a mono index numeral, a hairline plus-mark that rotates 45° into a close-mark on open, and a grid-rows expand transition.",category:"presentation",level:"L2",tags:["faq","accordion","marketing","content"],props:{eyebrow:{type:"string",description:"Optional mono overline above the title (accent colored)"},title:{type:"string",description:"Optional serif heading above the list"},lead:{type:"string",description:"Optional muted intro line under the title"},defaultOpenFirst:{type:"boolean",description:"When true, the first row renders open on mount"},items:{type:"array",items:{type:"object",properties:{q:{type:"string"},a:{type:"string"}}},description:"[{q, a}] question/answer pairs; rows with an empty q are dropped"}},usageScenarios:["Pricing / product FAQ section on a landing page","Docs 'common questions' block"],constraints:["Uses native <details> so multiple rows can be open at once; no single-open behaviour","Answers render as plain text; pass pre-formatted strings"]},TeamGrid:{name:"TeamGrid",description:"Grid of team-member cards. Each shows an avatar (image when `avatar` is a URL, otherwise tinted initials), name, mono role and optional bio. Hairline cards with hover lift.",category:"presentation",level:"L2",tags:["team","people","grid","marketing"],props:{columns:{type:"string",enum:["2","3","4"],default:"3"},members:{type:"array",items:{type:"object",properties:{name:{type:"string"},role:{type:"string"},bio:{type:"string"},avatar:{type:"string",description:"Image URL, or short text/emoji shown as the avatar; falls back to initials"}}},description:"[{name, role?, bio?, avatar?}] — members with an empty name are dropped"}},usageScenarios:["About page 'meet the team' grid","Advisors / contributors showcase"],constraints:["avatar is treated as an image when it looks like a URL (http(s):/data:/leading slash); otherwise rendered as text","Initials are derived from the name when no avatar is given"]},Steps:{name:"Steps",description:"'How it works' steps with oversized mono numerals. variant 'numbered' (default) is a responsive card row; variant 'connected' is a vertical rail with a connecting line between numbered dots.",category:"presentation",level:"L2",tags:["steps","how-it-works","process","marketing"],props:{variant:{type:"string",enum:["numbered","connected"],default:"numbered",description:"'numbered' = card row with big numerals; 'connected' = vertical rail with a line"},steps:{type:"array",items:{type:"object",properties:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"Optional lucide icon name; replaces the numeral in the 'connected' dot"}}},description:"[{title, desc?, icon?}] in sequence order; steps with an empty title are dropped"}},usageScenarios:["Three-step onboarding ('Describe → Generate → Render')","Connected setup sequence in docs"],constraints:["Numbering is automatic (01, 02, …) from array order","icon only affects the 'connected' variant's dot; the numbered variant always shows the numeral","Numbered variant derives its column count from the step count (clamped 2–4), so 4 steps fill one row"]},BentoGrid:{name:"BentoGrid",description:"Asymmetric bento layout. Lays BentoCell children, or an `items` array, onto a CSS grid whose base column count is `cols`; cells opt into col/row spans to break the rhythm into a mixed-size mosaic. Hairline cards, per-cell accent tone.",category:"presentation",level:"L3",tags:["bento","grid","layout","marketing"],props:{cols:{type:"string",enum:["2","3","4","6"],default:"3",description:"Base column count of the grid (cells may span fewer/more)"},gap:{type:"string",enum:["none","sm","md","lg"],default:"md"},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"lucide icon name"},tone:{type:"integer",description:"Accent-hue index 0–3 (amber/teal/rose/indigo)"},span:{type:"object",properties:{col:{type:"integer"},row:{type:"integer"}},description:"Cell span; col 1–4, row 1–3"}}},description:"Inline cells used when no BentoCell children are provided"}},usageScenarios:["Feature mosaic where one tile is hero-sized (span col 2) and the rest are small","Capability bento mixing tall and wide tiles"],constraints:["Provide either BentoCell children or items — children win when present","span.col is clamped to 1–4 and span.row to 1–3 via static class maps (no purge risk)"]},BentoCell:{name:"BentoCell",description:"A single bento tile, usable standalone inside a BentoGrid. Reads span.col / span.row and maps them to static span classes so the cell can be as wide/tall as the mosaic needs. Optional icon/title/desc plus composed children.",category:"presentation",level:"L1",tags:["bento","cell","card","marketing"],props:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"lucide icon name"},tone:{type:"integer",description:"Accent-hue index 0–3 (amber/teal/rose/indigo)"},span:{type:"object",properties:{col:{type:"integer"},row:{type:"integer"}},description:"{col?, row?} — col clamped 1–4, row clamped 1–3"}},usageScenarios:["A hero tile (span col 2, row 2) holding a rendered preview inside a BentoGrid","Custom-bodied bento tile composed from child blocks"],constraints:["Spans are clamped 1–4 (col) / 1–3 (row) and emitted as static classes","Designed to sit inside a BentoGrid; standalone it renders as a lone card"]},Callout:{name:"Callout",description:"Emphasis callout panel: a tinted box (semantic or brand colour) with an icon, optional title and body. color-mix against the chosen token keeps the wash subtle and legible in light and dark.",category:"presentation",level:"L1",tags:["callout","note","alert","marketing"],props:{variant:{type:"string",enum:["info","success","warn","accent"],default:"info",description:"Colour/role: info (indigo) · success (green) · warn (amber) · accent (brand amber)"},title:{type:"string",description:"Emphasised lead line, coloured to the variant"},body:{type:"string",description:"Supporting paragraph"},icon:{type:"string",description:"Optional lucide icon name; defaults to a sensible glyph per variant"}},usageScenarios:["Inline 'Note' / 'Tip' block inside docs or a landing section","Success confirmation or warning banner above content"],constraints:["variant falls back to 'info' when omitted or unrecognised","icon defaults per variant (info→info, success→check, warn→alert, accent→sparkles)"]},PricingTable:{name:"PricingTable",description:"Responsive 2–4 column pricing grid of hairline cards. The `highlighted` plan gets an amber border + 'Popular' badge + solid amber CTA; others use an outline CTA. Features list with amber check glyphs. CTAs are {label, href} anchors.",category:"presentation",level:"L3",tags:["pricing","plans","marketing","conversion"],props:{plans:{type:"array",items:{type:"object",properties:{name:{type:"string"},price:{type:"string",description:"Display price, e.g. '$29' or 'Free'"},period:{type:"string",description:"Billing period suffix, e.g. '/mo'"},description:{type:"string",description:"Short plan summary line"},features:{type:"array",items:{type:"string"},description:"Bullet feature list"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber when highlighted, else outline"},highlighted:{type:"boolean",default:!1,description:"Mark the featured/popular plan"}}},description:"[{name, price, period?, description?, features[], cta{label,href}, highlighted?}]"},billingNote:{type:"string",description:"Mono note under the grid, e.g. 'Billed annually · cancel anytime'"}},usageScenarios:["Three-tier SaaS pricing section (Starter / Pro / Enterprise)","Two-up free-vs-paid comparison with a highlighted paid plan"],constraints:["Column count is derived from plans.length, clamped to 2–4","CTA props are {label, href}; href defaults to '#'","Mark at most one plan highlighted for a clear focal point"]},Testimonials:{name:"Testimonials",description:"Grid of testimonial cards (hairline `.mkt-card`, hover lift): optional star rating, serif italic pull-quote, and an initials avatar token + author + role. `columns` (1–3) controls the grid; avatar tints cycle the four accents.",category:"presentation",level:"L2",tags:["testimonials","social-proof","marketing","quotes"],props:{items:{type:"array",items:{type:"object",properties:{quote:{type:"string"},author:{type:"string"},role:{type:"string",description:"Author title / company"},avatar:{type:"string",description:"Explicit avatar token; defaults to author initials"},rating:{type:"integer",description:"Optional 1–5 star rating"}}},description:"[{quote, author, role?, avatar?, rating?}]"},columns:{type:"string",enum:["1","2","3"],description:"Grid column count (defaults from item count)"}},usageScenarios:["Three-up customer quote wall under a SectionHeader","Single highlighted testimonial beside a feature"],constraints:["avatar defaults to first-letter initials of author; no external images","rating is clamped to 0–5 and omitted when absent"]},LogoCloud:{name:"LogoCloud",description:"A single grayscale 'trusted by' logo strip. With no external images each logo is a mono wordmark (initials for long names); the row is dimmed/desaturated and lifts to full foreground on hover. Optional mono `label` above the row.",category:"presentation",level:"L1",tags:["logos","social-proof","marketing","brands"],props:{label:{type:"string",description:"Eyebrow above the row, e.g. 'Trusted by teams at'"},logos:{type:"array",items:{type:"object",properties:{name:{type:"string"}}},description:"Array of strings or [{name}] — rendered as mono wordmarks/initials"}},usageScenarios:["Logo strip directly under the hero for social proof","Press/partner row between sections"],constraints:["Text-only wordmarks — no external logo images are loaded","Names longer than 14 chars collapse to initials"]},StatBand:{name:"StatBand",description:"Big-number statistics band: oversized serif values with mono labels, divided by hairline rules. `tone` switches the surface — plain, muted (soft card panel) or inverse (ink-black panel with warm amber→rose glow + grain).",category:"presentation",level:"L2",tags:["stats","metrics","marketing","band"],props:{stats:{type:"array",items:{type:"object",properties:{value:{type:"string",description:"Big display value, e.g. '99.9%' or '12k+'"},label:{type:"string"},sub:{type:"string",description:"Optional sub-label under the metric"}}},description:"[{value, label, sub?}]"},tone:{type:"string",enum:["plain","muted","inverse"],default:"plain",description:"Surface treatment: plain (transparent) · muted (card panel) · inverse (ink-black glow panel)"}},usageScenarios:["Four-up headline metrics band (uptime / users / latency / saved)","Inverse-tone impact band between marketing sections"],constraints:["Column count derives from stats.length, clamped to 1–4","Values are display strings; pre-format numbers/units yourself"]},Newsletter:{name:"Newsletter",description:"Email-capture band: serif title + supporting line, then a token-styled email input beside a CTA anchor. Presentational — the input is decorative and the CTA navigates via {label, href}; wire real submission at the host.",category:"presentation",level:"L2",tags:["newsletter","subscribe","marketing","email"],props:{title:{type:"string",description:"Serif headline"},subtitle:{type:"string",description:"Supporting line under the title"},placeholder:{type:"string",default:"you@example.com",description:"Email input placeholder"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber submit button (defaults to 'Subscribe' / '#')"}},usageScenarios:["End-of-page 'Stay in the loop' email signup","Docs/blog newsletter band between content sections"],constraints:["Input is decorative; the form action points at cta.href — handle real submission upstream","Single email field + single CTA by design"]},Banner:{name:"Banner",description:"Slim full-width announcement bar: optional icon + message, an inline CTA link and a decorative dismiss '×'. `tone` picks one of the four brand accents; `solid` fills the strip with the accent instead of a soft tint.",category:"presentation",level:"L1",tags:["banner","announcement","marketing","notice"],props:{message:{type:"string",description:"Announcement text"},icon:{type:"string",description:"lucide icon name (defaults to 'sparkles')"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index (0 amber · 1 teal · 2 rose · 3 indigo)"},solid:{type:"boolean",default:!1,description:"Fill the strip with the accent colour"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — inline mono link on the right"},dismissible:{type:"boolean",default:!0,description:"Show the decorative × (presentational only)"}},usageScenarios:["Top-of-page launch/announcement strip above the hero","Soft-tint 'new docs available' notice between sections"],constraints:["The dismiss × is decorative — wire real dismissal at the host","tone is 0–3; CTA href defaults to '#'"]},FeatureSplit:{name:"FeatureSplit",description:"Alternating two-column feature section: an editorial text column (eyebrow, serif title, body, bulleted benefits, optional CTA) beside a visual column. The visual renders the `visual` slot (or children) — e.g. a BrowserFrame — falling back to a tinted blueprint placeholder. `reverse` flips the column order for an alternating page rhythm.",category:"presentation",level:"L3",tags:["feature","split","two-column","marketing"],props:{eyebrow:{type:"string",description:"Mono uppercase kicker"},title:{type:"string",description:"Serif feature title"},body:{type:"string",description:"Supporting paragraph"},bullets:{type:"array",items:{type:"object",properties:{icon:{type:"string"},text:{type:"string"}}},description:"Array of strings or [{icon?, text}] benefit rows"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"},reverse:{type:"boolean",default:!1,description:"Place the visual on the left"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the bullet chips / placeholder"}},slots:{visual:{description:"Right-pane visual (BrowserFrame, rendered preview, image); falls back to children then a placeholder"}},usageScenarios:["Alternating feature rows down a landing page (reverse every other)","Text + live BrowserFrame preview feature block"],constraints:["Provide a visual slot/children for the right pane; otherwise a tinted placeholder renders","bullets accept strings or {icon?, text}; CTA href defaults to '#'"]},ComparisonTable:{name:"ComparisonTable",description:"Feature comparison table across products/plans. The header lists columns (a `highlighted` column gets an amber-washed spine); each row pairs a feature label with one value per column — booleans render as amber check / muted cross glyphs, strings render verbatim. Horizontally scrollable on small screens.",category:"presentation",level:"L3",tags:["comparison","table","pricing","marketing"],props:{featureLabel:{type:"string",description:"Header label for the feature column (often blank)"},columns:{type:"array",items:{type:"object",properties:{name:{type:"string"},highlighted:{type:"boolean"}}},description:"Array of strings or [{name, highlighted?}] — column headers"},rows:{type:"array",items:{type:"object",properties:{feature:{type:"string"},values:{type:"array",items:{},description:"One value per column (boolean → ✓/✗, string → verbatim)"}}},description:"[{feature, values[]}] — values align positionally with columns"}},usageScenarios:["Plan feature comparison (Free / Pro / Enterprise) with a highlighted column","Product-vs-competitor capability matrix"],constraints:["values align by index with columns; missing/falsey values render as a muted cross","Booleans (or 'yes'/'no'/'true'/'false') become glyphs; other strings render verbatim"]},Roadmap:{name:"Roadmap",description:"Product roadmap / milestone timeline. A vertical rail with one node per milestone; node state drives the dot — a filled amber check for 'done', an amber ring + rocket for 'active', an outline flag for 'planned'. A marketing roadmap (distinct from the operational TimelineList activity log).",category:"presentation",level:"L2",tags:["roadmap","milestones","timeline","marketing"],props:{milestones:{type:"array",items:{type:"object",properties:{date:{type:"string",description:"Quarter/date label, e.g. 'Q3 2026'"},title:{type:"string"},desc:{type:"string"},state:{type:"string",enum:["done","active","planned"]}}},description:"[{date?, title, desc?, state?}] in sequence order"}},usageScenarios:["Public product roadmap section (shipped / in progress / planned)","Launch sequence with dated milestones"],constraints:["state defaults to 'planned' when omitted or unrecognised","milestones with an empty title are dropped"]},StatHighlight:{name:"StatHighlight",description:"Single big-number spotlight: an oversized serif value with an optional trend delta (up = amber, down = rose), a mono label and supporting copy. Draws the eye to one headline metric (distinct from StatBand's multi-stat row).",category:"presentation",level:"L1",tags:["stat","metric","highlight","marketing"],props:{value:{type:"string",description:"Big display value, e.g. '99.9%' or '12k+'"},label:{type:"string",description:"Mono uppercase label under the value"},body:{type:"string",description:"Supporting paragraph"},delta:{type:"string",description:"Trend delta pill text, e.g. '+12%'"},trend:{type:"string",enum:["up","down"],default:"up",description:"Delta direction: up (amber, arrow up) or down (rose, arrow down)"}},usageScenarios:["Centered headline metric between two content sections","Single KPI spotlight with a growth delta"],constraints:["Values/deltas are display strings; pre-format numbers/units yourself","trend only affects the delta pill colour/arrow; omit delta to hide the pill"]},IconList:{name:"IconList",description:"Benefit / checklist list with icons. Each item shows a tinted icon chip, a title and optional supporting line, laid into a 1–3 column grid; tints cycle the four accents. Lighter-weight than FeatureGrid (no card material) — for inline benefit/checklist runs.",category:"presentation",level:"L1",tags:["benefits","checklist","list","marketing"],props:{columns:{type:"string",enum:["1","2","3"],default:"2"},icon:{type:"string",description:"Default lucide icon for items without their own (defaults to 'check')"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string"},title:{type:"string"},desc:{type:"string"}}},description:"Array of strings or [{icon?, title, desc?}]"}},usageScenarios:["Two-column 'what's included' benefit list","Checklist of capabilities under a SectionHeader"],constraints:["items accept plain strings (→ title only) or {icon?, title, desc?}","icon falls back to the block-level `icon` (default 'check'); unknown names → dot"]},Footer:{name:"Footer",description:"Multi-column marketing footer: a brand block (serif wordmark + tagline) beside grouped link columns, with a bottom rule carrying a copyright line and small print. Pure layout off theme tokens.",category:"presentation",level:"L2",tags:["footer","navigation","marketing","layout"],props:{brand:{type:"string",description:"Brand wordmark (serif display under .marketing)"},tagline:{type:"string",description:"Short brand tagline under the wordmark"},groups:{type:"array",items:{type:"object",properties:{title:{type:"string"},links:{type:"array",items:{type:"object",properties:{label:{type:"string"},href:{type:"string"}}}}}},description:"[{title, links:[{label, href}]}] link columns"},copyright:{type:"string",description:"Bottom-left copyright line"},note:{type:"string",description:"Bottom-right mono small print"}},usageScenarios:["Site-wide marketing footer with Product / Company / Legal columns","Compact footer with brand + a single link group"],constraints:["link href defaults to '#' when omitted; empty groups/links are dropped","The bottom rule only renders when copyright or note is provided"]},AccordionList:{name:"AccordionList",description:"General-purpose content accordion on native <details>/<summary> — fully functional with zero JS. Each row is a standalone hairline card with an optional leading icon chip, a title and a body. `defaultOpenFirst` opens the first row. (Faq is the divided-single-card Q&A variant.)",category:"presentation",level:"L2",tags:["accordion","details","content","marketing"],props:{title:{type:"string",description:"Optional serif heading above the list"},defaultOpenFirst:{type:"boolean",default:!1,description:"Open the first row by default"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string",description:"Optional lucide icon for the row chip"},title:{type:"string"},body:{type:"string"}}},description:"[{icon?, title, body}] — rows with an empty title are dropped"}},usageScenarios:["Expandable feature explainers (icon + title + body) on a landing page","Docs 'details' sections with one card per topic"],constraints:["Uses native <details> so multiple rows can be open at once (no single-open behaviour)","Bodies render as plain text; pass pre-formatted strings"]},MetricCard:{name:"MetricCard",description:"KPI metric card with an inline pure-SVG sparkline: a mono label, a big value, a trend delta pill (up = amber, down = rose) and a sparkline drawn from a `points` series — no chart dependency. A `.mkt-card` with hover lift; `tone` selects the accent. Designed to sit in a Grid/StatGrid for a metrics row.",category:"presentation",level:"L2",tags:["metric","kpi","sparkline","card","dashboard"],props:{label:{type:"string",description:"Mono uppercase metric label"},value:{type:"string",description:"Big display value"},delta:{type:"string",description:"Trend delta pill, e.g. '+8.2%'"},trend:{type:"string",enum:["up","down"],default:"up",description:"Delta direction: up (amber) or down (rose)"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the sparkline stroke/fill"},points:{type:"array",items:{type:"number"},description:"Numeric series for the inline sparkline (auto-scaled)"}},usageScenarios:["Four-up KPI metrics row inside a Grid (revenue / users / latency / churn)","Single highlighted metric with a trend sparkline"],constraints:["points are auto-scaled to the card's min/max; keep series small (~<60 points)","value/delta are display strings; the sparkline is hidden when points is empty"]},GalleryGrid:{name:"GalleryGrid",description:"Caption gallery grid. Lays image tiles (or, with no `src`, a tinted blueprint placeholder) onto a 2–4 column responsive grid; a tile may opt into `wide` to span two columns for a mixed-rhythm mosaic. Captions sit on a gradient scrim over each tile. Hairline framing, hover lift — no external images required.",category:"presentation",level:"L2",tags:["gallery","images","grid","marketing"],props:{columns:{type:"string",enum:["2","3","4"],default:"3"},items:{type:"array",items:{type:"object",properties:{src:{type:"string",description:"Image URL; omit for a tinted placeholder"},caption:{type:"string",description:"Caption shown over a gradient scrim"},tone:{type:"integer",description:"Accent-hue index 0–3 for the placeholder"},wide:{type:"boolean",description:"Span two columns"}}},description:"[{src?, caption?, tone?, wide?}] gallery tiles"}},usageScenarios:["Screenshot gallery with a wide hero tile and smaller supporting tiles","Placeholder-driven layout mock before real imagery exists"],constraints:["src is treated as an image when it looks like a URL (http(s):/data:/leading slash); otherwise a placeholder renders","wide spans two columns from the sm breakpoint up"]}};var Ev=mi(),Pv=yt(),Tv=Zn(),Ai=ht(),Ov=rt(),Se=E(),Dv=me(),Lv=O(),Nv=he(),_v=be(),sE=_r(),Mv=Ri(),Bv=xi(),$v=Ii(),qr=nl(),il=et();var qv=Ev.Composer,Fv=Pv.Document,Uv=Tv.Schema,{YAMLError:jv,YAMLParseError:Vv,YAMLWarning:Hv}=Ai,Gv=Ov.Alias,{isAlias:Kv,isCollection:zv,isDocument:Wv,isMap:Yv,isNode:Jv,isPair:Qv,isScalar:Xv,isSeq:Zv}=Se,ew=Dv.Pair,tw=Lv.Scalar,rw=Nv.YAMLMap,nw=_v.YAMLSeq;var iw=Mv.Lexer,ow=Bv.LineCounter,sw=$v.Parser,{parse:Ge,parseAllDocuments:aw,parseDocument:cw,stringify:lw}=qr,{visit:uw,visitAsync:dw}=il;class H extends Error{code;details;constructor(e,t,r){super(t);this.name="CompileSpecError",this.code=e,this.details=r}}function pw(e,t){let r=Object.hasOwn(t,e)?t[e]:void 0;if(!r)throw new H("unknown-template",`unknown template "${e}"`,{template:e});let n=r.pages[0]?.blocks[0];if(!n||n.type!=="PageLayout")throw new H("invalid-shell-root",`template "${e}" root is not PageLayout`,{template:e});return n}function Fr(e,t,r,n){let i=e;if(e.template){if(r.has(e.template))throw new H("template-cycle",`template cycle at "${e.template}"`,{template:e.template});let o=pw(e.template,t),s=new Set(r);s.add(e.template);let a={...o.slots,...e.slots};if(n&&!e.slots?.sidebar)delete a.sidebar;let c=e.children??o.children,l=e.events??o.events,p=e.visible??o.visible;return i={...o,...e.id?{id:e.id}:{},props:{...o.props,...e.props},slots:a,...c?{children:c}:{},...l?{events:l}:{},...p!==void 0?{visible:p}:{}},Fr(i,t,s,n)}return{...i,...i.children?{children:i.children.map((o)=>Fr(o,t,r,n))}:{},...i.slots?{slots:Object.fromEntries(Object.entries(i.slots).map(([o,s])=>[o,s.map((a)=>Fr(a,t,r,n))]))}:{}}}function gw(e){let t=(r)=>{if(r.template)return!0;if(r.children?.some(t))return!0;return Object.values(r.slots??{}).some((n)=>n.some(t))};return e.pages.some((r)=>r.blocks.some(t))}function ol(e,t){return e.map((r)=>{if("children"in r&&Array.isArray(r.children))return{type:"MenuGroup",props:{title:r.label},children:ol(r.children,t)};let n=r,i={label:n.label,href:n.path};if(n.icon)i.icon=n.icon;if(n.path===t)i.active=!0;return{type:"MenuLink",props:i}})}function fw(e){let t=e.menus?.items;if(!t?.length)return e;return{...e,pages:e.pages.map((r)=>({...r,blocks:r.blocks.map((n)=>{if(n.type!=="PageLayout")return n;if(n.slots?.sidebar?.length)return n;return{...n,slots:{...n.slots,sidebar:[{type:"PageSiderMenu",props:{title:r.title??n.props?.title??"Menu"},children:ol(t,r.path)}]}}})}))}}function Ei(e,t={}){let r=Boolean(e.menus?.items?.length),n=gw(e)?{...e,pages:e.pages.map((i)=>({...i,blocks:i.blocks.map((o)=>Fr(o,t,new Set,r))}))}:e;return fw(n)}function mw(e){let t=new Map,r=new Map,n=new Map,i=(o,s)=>{if(o.id!==void 0){if(n.has(o.id)){let a=n.get(o.id);throw new H("duplicate-block-id",`Block id "${o.id}" is declared more than once`,{blockId:o.id,firstPageId:a,pageId:s})}n.set(o.id,s)}for(let a of o.children??[])i(a,s);for(let a of Object.values(o.slots??{}))for(let c of a)i(c,s)};return e.pages.forEach((o,s)=>{let a=t.get(o.id);if(a!==void 0)throw new H("duplicate-page-id",`Page id "${o.id}" is declared more than once`,{pageId:o.id,firstIndex:a,pageIndex:s});if(t.set(o.id,s),r.has(o.path)){let c=r.get(o.path);throw new H("duplicate-page-path",`Page path "${o.path}" is declared more than once`,{path:o.path,firstPageId:c,pageId:o.id})}r.set(o.path,o.id);for(let c of o.blocks)i(c,o.id)}),new Set(n.keys())}function yw(e,t,r){while(!0){let n=t.counter++,i=r?`${r}_${n}`:`${e}_${n}`;if(!t.reservedIds.has(i)&&!t.assignedIds.has(i))return i}}function Pi(e,t,r,n,i,o){let s=e.id??yw(t,n,o??i);if(n.assignedIds.has(s))throw new H("duplicate-block-id",`Block id "${s}" is declared more than once`,{blockId:s,pageId:t});n.assignedIds.add(s);let a=(e.children??[]).map((p)=>Pi(p,t,r,n,s,s)),c={};for(let[p,g]of Object.entries(e.slots??{}))c[p]=g.map((d)=>Pi(d,t,r,n,s,`${s}_${p}`));let l={id:s,pageId:t,type:e.type,...i?{parentId:i}:{},...e.props?{props:e.props}:{},...a.length?{children:a}:{},...Object.keys(c).length?{slots:c}:{},...e.events?{events:e.events}:{},...e.visible!==void 0?{visible:e.visible}:{},...e.template?{template:e.template}:{},...e.variant?{variant:e.variant}:{}};return r[s]=l,s}function Ti(e,t={}){e=Ei(e,t);let n={counter:0,reservedIds:mw(e),assignedIds:new Set},i=Object.create(null);return{version:"2.0",pages:e.pages.map((s)=>{let a=[];for(let c of s.blocks)a.push(Pi(c,s.id,i,n));return{id:s.id,path:s.path,...s.title?{title:s.title}:{},rootBlockIds:a,...s.state?{state:s.state}:{},...s.auth?{auth:s.auth}:{},...s.lifecycle?{lifecycle:s.lifecycle}:{},...s.computed?{computed:s.computed}:{},...s.urlState?{urlState:s.urlState}:{}}}),...e.design?{design:e.design}:{},...e.connections?{connections:e.connections.map((s)=>({...s}))}:{},blocks:i}}var kt=[{id:"_state",generation:{syntax:"page-state path",positions:["props","computed","action-value","visible"],example:{_state:"open"},prerequisite:"Declare the path on the same page"},bucket:"client",description:"Reads a value from the page state store"},{id:"_bindState",generation:{syntax:"page-state path",positions:["binding"],example:{_bindState:"name"},prerequisite:"Only installed controls implementing two-way binding"},bucket:"client",description:"Two-way state binding (read + write)"},{id:"_payload",generation:{syntax:"payload field",positions:["request-context"],example:{_payload:"name"},prerequisite:"Caller must supply request payload; ordinary preview props have no payload"},bucket:"client",description:"Request payload field"},{id:"_event",generation:{syntax:"event field",positions:["action-value"],example:{_event:"value"},prerequisite:"Only within an event action; permitted fields: type,name,value,checked,values"},bucket:"client",description:"Event payload field (e.g. form submit value)"},{id:"_global",generation:{syntax:"host-global field",positions:["host-context"],example:{_global:"configuredValue"},prerequisite:"Host-dependent and excluded from ordinary creation; no secrets"},bucket:"client",description:"Global (window) property access"},{id:"_if",generation:{syntax:"[condition, then, else]",positions:["props","computed","action-value"],example:{_if:[{_state:"open"},"Open","Closed"]}},bucket:"client",description:"Conditional ternary: [condition, then, else]"},{id:"_eq",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_eq:[{_state:"status"},"Active"]}},bucket:"client",description:"Equality: [a, b] → a === b"},{id:"_ne",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_ne:[{_state:"status"},"Active"]}},bucket:"client",description:"Inequality: [a, b] → a !== b"},{id:"_contains",generation:{syntax:"[haystack, needle]",positions:["props","computed","action-value","visible","predicate"],example:{_contains:[{_state:"name"},"orion"]}},bucket:"client",description:"Case-insensitive substring match: [haystack, needle] → haystack contains needle (empty needle → true)"},{id:"_gt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gt:[{_state:"count"},0]}},bucket:"client",description:"Greater-than for finite numbers: [a, b] → a > b. Non-numbers are false"},{id:"_lt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lt:[{_state:"count"},10]}},bucket:"client",description:"Less-than for finite numbers: [a, b] → a < b. Non-numbers are false"},{id:"_gte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gte:[{_state:"count"},0]}},bucket:"client",description:"Greater-or-equal for finite numbers: [a, b] → a >= b. Non-numbers are false"},{id:"_lte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lte:[{_state:"count"},10]}},bucket:"client",description:"Less-or-equal for finite numbers: [a, b] → a <= b. Non-numbers are false"},{id:"_in",generation:{syntax:"[value, array]",positions:["props","computed","action-value","visible","predicate"],example:{_in:[{_state:"status"},["Active","Draft"]]}},bucket:"client",description:"Membership: [value, array] → array includes value"},{id:"_not",generation:{syntax:"condition",positions:["props","computed","action-value","visible","predicate"],example:{_not:{_state:"open"}}},bucket:"client",description:"Logical NOT"},{id:"_and",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_and:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical AND over a list of conditions"},{id:"_or",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_or:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical OR over a list of conditions"},{id:"_user",generation:{syntax:"session user field",positions:["props","computed","action-value"],example:{_user:"name"},prerequisite:"Requires injected host session; no server ACL guarantee"},bucket:"client",description:"Current session user field (client-visible)"},{id:"_item",generation:{syntax:"item field or empty string",positions:["predicate","loop-props"],example:{_item:"name"},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list item in a loop scope"},{id:"_index",generation:{syntax:"ignored scalar marker",positions:["predicate","loop-props"],example:{_index:0},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list index in a loop scope"},{id:"_array.length",generation:{syntax:"array expression",positions:["props","computed","action-value"],example:{"_array.length":{_state:"rows"}}},bucket:"client",description:"Array length"},{id:"_string.concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{"_string.concat":["Hello ",{_state:"name"}]}},bucket:"client",description:"String concatenation over a list"},{id:"_number.add",generation:{syntax:"[left, right] (finite numbers)",positions:["action-value"],example:{"_number.add":[{_state:"count"},1]},prerequisite:"Both operands must evaluate to finite numbers or the action fails and writes nothing; use it in SetState value for counters (e.g. SetState count = count + 1), never for strings or arrays"},bucket:"client",description:"Finite number addition: [left, right] → left + right. Throws on non-number, non-finite or overflowing operands (no coercion, no fallback to 0)"},{id:"_computed",generation:{syntax:"computed name",positions:["props","computed","action-value","visible"],example:{_computed:"filtered"},prerequisite:"Declare page computed expression"},bucket:"client",description:"Reads a derived (computed) state value by name from the __computed namespace"},{id:"_filter",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_filter:[{_state:"rows"},{_eq:[{_item:"status"},"Active"]}]}},bucket:"client",description:"Filters an array: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_find",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_find:[{_state:"rows"},{_eq:[{_item:"name"},"Orion"]}]}},bucket:"client",description:"Finds the first matching element: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_len",generation:{syntax:"array/string/object expression",positions:["props","computed","action-value"],example:{_len:{_state:"rows"}}},bucket:"client",description:"Length of an array, string, or object (0 if empty)"},{id:"_concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{_concat:[[1],[2]]},prerequisite:"Concatenation is not numeric addition"},bucket:"client",description:"Concatenates a list: arrays are joined, otherwise values are string-concatenated"},{id:"_count",generation:{syntax:"array or [array, predicate?]",positions:["props","computed","action-value"],example:{_count:[{_state:"rows"}]}},bucket:"client",description:"Count of an array, or of elements matching a predicate: [array, predicate?]"},{id:"_groupCount",generation:{syntax:"[array, field]",positions:["props","computed","action-value"],example:{_groupCount:[{_state:"rows"},"status"]}},bucket:"client",description:"Counts array items by a field in one pass: [array, field] → { value: count }"},{id:"_sort",generation:{syntax:"[array, {by, order?, rank?}]",positions:["props","computed","action-value"],example:{_sort:[{_state:"rows"},{by:"name",order:"asc"}]}},bucket:"client",description:"Stable sort: [array, { by, order?: asc|desc, rank?: { field: values[] } }]. rank is enum order"},{id:"_js",generation:{syntax:"disabled",positions:[],example:{_js:"disabled"},prerequisite:"Arbitrary code execution is disabled; permissions do not enable it",disabled:!0},bucket:"client",description:"Legacy JS expression; execution is always disabled"}],Ur=new Set(kt.map((e)=>e.id));var sl=new Set(Us),hw=new Map(kt.map((e)=>[e.id,e])),ll=new Set(["array","boolean","integer","null","number","object","string"]),ul=new Set(["default","description","enum","items","properties","required","type"]);function al(e){if(!e)return[];return Object.keys(e)}function bw(e){if(!e||e.type!=="array")return;let t=e.items;if(!t||typeof t!=="object"||t.type!=="object"||!t.properties)return;return new Set(Object.keys(t.properties))}function Oi(e,t,r){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let[n,i]of e.entries())Oi(i,`${t}[${n}]`,r);return}for(let[n,i]of Object.entries(e)){let o=t?`${t}.${n}`:n;r(n,i,o),Oi(i,o,r)}}function jr(e,t,r,n,i,o,s,a){Oi(n,i,(c,l,p)=>{if((c==="_state"||c==="_bindState")&&typeof l==="string"){let g=l.split("."),d=g[0]??"";if(d==="__computed"){let u=g[1]??"";if(!s.has(u))e.push({code:"refs:computed-declared",message:`${t}: _computed "${u}" is not declared`,elementKey:r,path:p});return}if(!o.has(d))e.push({code:"refs:state-declared",message:`${t}: _state "${d}" is not declared in state`,elementKey:r,path:p})}if(c==="_computed"&&typeof l==="string"&&!s.has(l))e.push({code:"refs:computed-declared",message:`${t}: _computed "${l}" is not declared`,elementKey:r,path:p});if(c==="_item"&&typeof l==="string"&&l!==""&&a&&!a.has(l))e.push({code:"item:field-exists",message:`${t}: _item "${l}" is not in the item schema`,elementKey:r,path:p})})}function U(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Rt(e){return U(e)&&Object.keys(e).some((t)=>t.startsWith("_"))}var cl=new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_not","_and","_or"]);function Cw(e,t){if(new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_filter","_find","_groupCount","_sort","_number.add"]).has(e)){if(!Array.isArray(t)||t.length!==2)return!1;if(e==="_groupCount")return typeof t[1]==="string";if(e==="_sort"){let n=t[1];if(!U(n))return!1;if(!(typeof n.by==="string"&&n.by.length>0||Array.isArray(n.by)&&n.by.length>0&&n.by.every((o)=>typeof o==="string"&&o.length>0)))return!1;if(n.order!==void 0&&n.order!=="asc"&&n.order!=="desc")return!1;if(n.rank!==void 0&&(!U(n.rank)||Object.values(n.rank).some((o)=>!Array.isArray(o))))return!1;return Object.keys(n).every((o)=>["by","order","rank"].includes(o))}return!0}if(e==="_if")return Array.isArray(t)&&t.length===3;if(e==="_and"||e==="_or")return Array.isArray(t)&&t.length>0;if(e==="_string.concat"||e==="_concat")return Array.isArray(t)&&t.length>0;if(e==="_count")return!Array.isArray(t)||t.length===1||t.length===2;if(e==="_index")return typeof t==="number"&&Number.isFinite(t);if(["_state","_bindState","_computed","_event","_global","_payload","_user"].includes(e))return typeof t==="string"&&t.length>0;if(e==="_item")return typeof t==="string";return!0}function dl(e){return e.enum===void 0||Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every((t)=>t===null||typeof t==="string"||typeof t==="boolean"||typeof t==="number"&&Number.isFinite(t))}function Pe(e,t,r,n,i,o){if(r==="predicate"&&(!Rt(e)||!cl.has(Object.keys(e)[0]??"")))return n.push({code:"props:expression",message:`${i}: predicate must be a supported expression node`,elementKey:o,path:t}),!1;if(e===void 0)return n.push({code:"props:expression",message:`${i}: value is not part of the supported serialized expression syntax`,elementKey:o,path:t}),!1;if(Array.isArray(e))return e.reduce((d,u,m)=>Pe(u,`${t}[${m}]`,r,n,i,o)&&d,!0);if(!U(e)){if(typeof e==="number"&&!Number.isFinite(e)||e!==null&&!["string","number","boolean"].includes(typeof e))return n.push({code:"props:expression",message:`${i}: value is not part of the supported serialized expression syntax`,elementKey:o,path:t}),!1;return e===null||["string","number","boolean"].includes(typeof e)}let s=Object.keys(e).filter((d)=>d.startsWith("_"));if(s.length===0)return Object.entries(e).reduce((d,[u,m])=>Pe(m,`${t}.${u}`,r,n,i,o)&&d,!0);let a=s[0]??"",c=hw.get(a),l=`${t}.${a}`;if(s.length!==1||Object.keys(e).length!==1||!c)return n.push({code:"props:expression",message:`${i}: expression shape is not supported`,elementKey:o,path:l}),!1;if(c.generation?.disabled||!c.generation?.positions.includes(r)&&!(r==="props"&&c.generation?.positions.includes("binding"))&&!(r==="predicate-value"&&c.generation?.positions.some((d)=>["props","computed","predicate"].includes(d))))return n.push({code:"props:expression",message:`${i}: expression is not supported in this value position`,elementKey:o,path:l}),!1;let p=e[a];if(!Cw(a,p))return n.push({code:"props:expression",message:`${i}: expression operand shape is not supported`,elementKey:o,path:l}),!1;let g=(d)=>Rt(d)||Array.isArray(d);if(["_filter","_find","_groupCount","_sort"].includes(a)&&!g(Array.isArray(p)?p[0]:void 0)||a==="_in"&&!g(Array.isArray(p)?p[1]:void 0))return n.push({code:"props:expression",message:`${i}: expression array operand has an unsupported literal shape`,elementKey:o,path:l}),!1;if(a==="_count"&&(Array.isArray(p)?!g(p[0]):!g(p))||a==="_array.length"&&!g(p))return n.push({code:"props:expression",message:`${i}: expression array operand has an unsupported literal shape`,elementKey:o,path:l}),!1;if(["_gt","_lt","_gte","_lte"].includes(a)&&Array.isArray(p)){if(p.some((u)=>!Rt(u)&&(typeof u!=="number"||!Number.isFinite(u))))return n.push({code:"props:expression",message:`${i}: numeric comparison literals must be finite numbers`,elementKey:o,path:l}),!1}if(Array.isArray(p))return p.reduce((d,u,m)=>{let f=r;if((["_filter","_find"].includes(a)||a==="_count")&&m===1)f="predicate";else if(r==="predicate"||r==="predicate-value"){if(f=cl.has(a)?"predicate-value":r,r==="predicate"&&["_and","_or"].includes(a))f="predicate"}return Pe(u,`${l}[${m}]`,f,n,i,o)&&d},!0);if(U(p))return Pe(p,l,r==="predicate"&&a==="_not"?"predicate-value":r,n,i,o);return!0}function Di(e,t,r,n,i,o,s){let a=(g)=>s==="props"?`props:${g}`:`actions:params-${g}`;if(Object.keys(t).filter((g)=>!ul.has(g)).length>0){n.push({code:"schema:unsupported",message:`${i}: schema contains unsupported constraints`,elementKey:o,path:r});return}if(t.type!==void 0&&!ll.has(t.type)){n.push({code:"schema:unsupported",message:`${i}: schema type is not supported`,elementKey:o,path:r});return}if(!dl(t)){n.push({code:"schema:unsupported",message:`${i}: schema enum is not supported`,elementKey:o,path:r});return}if(t.required!==void 0&&(!Array.isArray(t.required)||t.required.some((g)=>typeof g!=="string"))){n.push({code:"schema:unsupported",message:`${i}: schema required list is not supported`,elementKey:o,path:r});return}if(t.items!==void 0&&(t.type!=="array"||!U(t.items))){n.push({code:"schema:unsupported",message:`${i}: schema items must describe an array`,elementKey:o,path:r});return}if(t.properties!==void 0&&(t.type!=="object"||!U(t.properties))){n.push({code:"schema:unsupported",message:`${i}: schema properties must describe an object`,elementKey:o,path:r});return}if(t.required?.length&&t.type!=="object"){n.push({code:"schema:unsupported",message:`${i}: schema required list is only supported for objects`,elementKey:o,path:r});return}if(Rt(e))return;let l=t.type;if(!(l===void 0||l==="null"&&e===null||l==="string"&&typeof e==="string"||l==="boolean"&&typeof e==="boolean"||l==="number"&&typeof e==="number"&&Number.isFinite(e)||l==="integer"&&typeof e==="number"&&Number.isInteger(e)||l==="array"&&Array.isArray(e)||l==="object"&&U(e))){n.push({code:a("type"),message:`${i}: value does not match the declared type`,elementKey:o,path:r});return}if(t.enum&&!t.enum.some((g)=>Object.is(g,e)))n.push({code:a("enum"),message:`${i}: value is outside the declared enum`,elementKey:o,path:r});if(l==="object"&&U(e)){for(let g of t.required??[])if(!Object.hasOwn(e,g))n.push({code:a("required"),message:`${i}: required object field is missing`,elementKey:o,path:`${r}.${g}`});for(let[g,d]of Object.entries(t.properties??{}))if(Object.hasOwn(e,g))Di(e[g],d,`${r}.${g}`,n,i,o,s)}if(l==="array"&&Array.isArray(e)&&t.items)e.forEach((g,d)=>{Di(g,t.items,`${r}[${d}]`,n,i,o,s)})}function pl(e,t,r,n,i,o,s){if(!r)return;for(let[a,c]of Object.entries(r)){let l=`${n}.${a}`;if(Li(c,l,e,i,o)&&t&&Object.hasOwn(t,a))Di(t[a],c,l,e,i,o,s)}}function gl(e,t,r,n,i,o,s={}){for(let[a,c]of Object.entries(t??{})){let l=n==="action-value"&&!s.evaluatedParams?.has(a)?"action-literal":n;Pe(c,`${r}.${a}`,l,e,i,o)}}function Li(e,t,r,n,i){if(Object.keys(e).some((s)=>!ul.has(s))||e.type!==void 0&&!ll.has(e.type)||!dl(e)||e.required!==void 0&&(!Array.isArray(e.required)||e.required.some((s)=>typeof s!=="string"))||e.items!==void 0&&(e.type!=="array"||!U(e.items))||e.properties!==void 0&&(e.type!=="object"||!U(e.properties))||Boolean(e.required?.length)&&e.type!=="object")return r.push({code:"schema:unsupported",message:`${n}: schema contains unsupported constraints`,elementKey:i,path:t}),!1;for(let[s,a]of Object.entries(e.properties??{}))if(!Li(a,`${t}.${s}`,r,n,i))return!1;if(e.items&&!Li(e.items,`${t}[]`,r,n,i))return!1;return!0}function Vr(e,t,r,n,i,o,s){if(!Array.isArray(n)){if(s)e.push({code:"actions:chain",message:`${t}: action chain must be an array`,elementKey:r,path:i});return}for(let[a,c]of n.entries()){if(!U(c)){if(s)e.push({code:"actions:chain",message:`${t}: action step must be an object`,elementKey:r,path:`${i}[${a}]`});continue}let l=c.action,p=`${i}[${a}]`;if(s&&(typeof l!=="string"||l.length===0))e.push({code:"actions:chain",message:`${t}: action step needs an action name`,elementKey:r,path:`${p}.action`});if(typeof l==="string"&&!sl.has(l)&&!Object.hasOwn(o.actions??{},l))e.push({code:"actions:registered",message:`${t}: action "${l}" is not in the catalog. Registered actions: ${[...sl,...Object.keys(o.actions??{})].join(", ")}. No equivalent is guaranteed: preserve the requirement and report unsupported behavior instead of disabling it.`,elementKey:r,path:`${p}.action`});if(s&&typeof l==="string"){let g=Object.hasOwn(o.actions??{},l)?o.actions[l]:Object.hasOwn(fn,l)?fn[l]:void 0,d=c.params;if(d!==void 0&&!U(d))e.push({code:"actions:chain",message:`${t}: action params must be an object`,elementKey:r,path:`${p}.params`});else{if(U(d))gl(e,d,`${p}.params`,"action-value",t,r,{evaluatedParams:new Set(g?.generation?.evaluatedParams??[])});if(g)pl(e,U(d)?d:void 0,g.params,`${p}.params`,t,r,"actions:params")}}if(Object.hasOwn(c,"onSuccess"))Vr(e,t,r,c.onSuccess,`${p}.onSuccess`,o,s);if(Object.hasOwn(c,"onError"))Vr(e,t,r,c.onError,`${p}.onError`,o,s)}}function fl(e,t,r=!1){let n=[],i=new Set([...al(e.state),...e.connectionIds??[]]),o=new Set(al(e.computed)),s=e.pageId??e.root;if(e.computed)for(let[a,c]of Object.entries(e.computed)){if(r)Pe(c,`computed.${a}`,"computed",n,`${s}.computed`,s);jr(n,`${s}.computed`,s,c,`computed.${a}`,i,o,Sw(e,t))}if(e.urlState)for(let[a,c]of Object.entries(e.urlState)){if(!i.has(a))n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" is not declared in state`,elementKey:s,path:`urlState.${a}`});if(!c||typeof c.param!=="string"||c.param.length===0)n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" needs a param name`,elementKey:s,path:`urlState.${a}.param`})}for(let[a,c]of Object.entries(e.elements)){let l=Object.hasOwn(t.components,c.type)?t.components[c.type]:void 0;if(!l)continue;let p=`${s}/${a}`,g=ml(l.props);if(r)gl(n,c.props,"props","props",p,a);if(c.visible!==null&&typeof c.visible==="object"){let d=Object.keys(c.visible);if(Array.isArray(c.visible)||d.length!==1||!d[0]?.startsWith("_"))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression, not a literal record`,elementKey:a,path:"visible"})}if(r&&c.visible!==void 0)if(typeof c.visible!=="boolean"&&!Rt(c.visible))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression`,elementKey:a,path:"visible"});else Pe(c.visible,"visible","visible",n,p,a);if(jr(n,p,a,c.props,"props",i,o,g),jr(n,p,a,c.visible,"visible",i,o,g),jr(n,p,a,c.events,"events",i,o,g),l.props){let d=new Set(Object.keys(l.props));for(let u of Object.keys(c.props??{}))if(!d.has(u))n.push({code:"props:declared",message:`${p}: prop "${u}" is not declared on ${c.type}`,elementKey:a,path:`props.${u}`});if(r)pl(n,c.props,l.props,"props",p,a,"props")}if(l.events){let d=new Set(Object.keys(l.events));for(let[u,m]of Object.entries(c.events??{})){if(!d.has(u))n.push({code:"events:declared",message:`${p}: event "${u}" is not declared on ${c.type}`,elementKey:a,path:`events.${u}`});Vr(n,p,a,m,`events.${u}`,t,r)}}else for(let[d,u]of Object.entries(c.events??{}))Vr(n,p,a,u,`events.${d}`,t,r)}return n.map((a)=>({...a,path:a.elementKey===s?`${s}/${a.path}`:`${s}/${a.elementKey}/${a.path}`}))}function ml(e){let t=new Set;for(let r of Object.values(e??{})){let n=bw(r);if(!n)continue;for(let i of n)t.add(i)}return t.size>0?t:void 0}function Sw(e,t){let r=new Set;for(let n of Object.values(e.elements)){let i=Object.hasOwn(t.components,n.type)?t.components[n.type]:void 0,o=ml(i?.props);if(!o)continue;for(let s of o)r.add(s)}return r.size>0?r:void 0}function yl(e){return e.map((t)=>({code:t.code,message:t.message,elementKey:t.elementKey,path:t.path}))}var hl=[{id:"_request",bucket:"server",description:"Executes a connection request server-side and injects the result"},{id:"_secret",bucket:"server",description:"Reads a server-side secret value; never transmitted to the client"}],Hr=new Set(hl.map((e)=>e.id));function Gr(e){if(!e||typeof e!=="object"||Array.isArray(e))return e;let t=e;if(typeof t.version==="number")return{...t,version:Number.isInteger(t.version)?t.version.toFixed(1):String(t.version)};return t}function Ni(e){return{...e,...e.props?{props:{...e.props}}:{},...e.children?{children:[...e.children]}:{},...e.slots?{slots:{...e.slots}}:{},...e.events?{events:{...e.events}}:{}}}function bl(e){return{...e,...e.roots?{roots:[...e.roots]}:{},...e.state?{state:{...e.state}}:{},elements:Object.fromEntries(Object.entries(e.elements).map(([t,r])=>[t,Ni(r)]))}}function ww(e){return e.type==="compiler:operator"}function kw(e){return e.type==="compiler:validator"}class xt{operators;validators;constructor(e={}){let t=(e.capabilities??[]).filter(ww).map((n)=>n.contribution),r=(e.capabilities??[]).filter(kw).map((n)=>n.contribution);this.operators=[...e.operators??[],...t],this.validators=[...e.validators??[],...r]}merge(e){if(e instanceof xt)return new xt({operators:[...this.operators,...e.operators],validators:[...this.validators,...e.validators]});return new xt({operators:[...this.operators,...e.operators??[]],validators:[...this.validators,...e.validators??[]],...e.capabilities?{capabilities:e.capabilities}:{}})}}function Rw(e={}){return new xt(e)}function _i(e,t={}){let r=t.format??"auto";if(r==="json")return Gr(JSON.parse(e));if(r==="yaml")return Gr(Ge(e));let n=e.trim();if(n.startsWith("{")||n.startsWith("["))return Gr(JSON.parse(n));return Gr(Ge(e))}function xw(e,t,r){let n=e.pages.find((s)=>s.id===t),i=[...n?.rootBlockIds??[]],o=Object.fromEntries(Object.entries(e.blocks).filter(([,s])=>s.pageId===t).map(([s,a])=>{let{id:c,pageId:l,parentId:p,...g}=a;return[s,Ni(g)]}));if(r&&i.length===0){let s=e.blocks.__empty__?`__empty__:${t}`:"__empty__";i.push(s),o[s]={type:"Empty"}}return{version:e.version,root:i[0]??"__empty__",roots:i,pageId:t,...n?.state?{state:n.state}:{},...n?.computed?{computed:n.computed}:{},...n?.urlState?{urlState:n.urlState}:{},...e.connections?{connectionIds:e.connections.map((s)=>s.id)}:{},elements:o}}function Iw(e,t){let r=[...t.roots??e.roots??[]];if(r.length>0&&t.root!==e.root)r[0]=t.root;else if(r.length===0&&t.elements[t.root])r.push(t.root);return r}async function Aw(e,t,r,n){let i=bl(e);for(let o of r.operators){let s={spec:i,catalog:t,warnings:n,getElement(c){return i.elements[c]},updateElement(c,l){i={...i,elements:{...i.elements,[c]:Ni(l)}}},addWarning(c){n.push(c)}},a=await o.apply(s);if(a)i=bl(a)}return i}function Cl(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ew(e,t,r,n,i){let o=Object.entries(e.elements);for(let a of e.roots?.length?e.roots:[e.root])if(!e.elements[a])r.push({code:"missing-root",message:`Root element "${a}" is missing from the elements map`,elementKey:a});for(let[a,c]of o){if(!(Cl(t.components,c.type)??Cl(t.templates,c.type)))n.push({missingType:c.type,elementKey:a,reason:c.template?"missing-template":"missing-component",context:`Element ${a} references ${c.type}`,path:`blocks.${a}.type`});for(let p of c.children??[])if(!e.elements[p])r.push({code:"dangling-child",message:`Element "${a}" references missing child "${p}"`,elementKey:a})}let s=fl(e,t,i);if(i){for(let a of s)n.push({missingType:a.code,elementKey:a.elementKey,reason:"invalid-spec",context:a.message,code:a.code,path:a.path});return}r.push(...yl(s))}async function Pw(e,t,r,n,i){for(let o of r.validators){let s={spec:e,catalog:t,warnings:n,gaps:i,addWarning(a){n.push(a)},addGap(a){i.push(a)}};await o.validate(s)}}function Ke(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let r of e)Ke(r,t);return}for(let[r,n]of Object.entries(e)){if(r.startsWith("_"))t.add(r);Ke(n,t)}}function Tw(e){let t=new Map;for(let[n,i]of Object.entries(e.blocks)){let o=new Set;Ke(i.props,o),Ke(i.visible,o);for(let s of o){let a=t.get(s)??new Set;a.add(n),t.set(s,a)}}for(let n of e.pages){let i=new Set;Ke(n.computed,i),Ke(n.lifecycle,i);for(let o of i){let s=t.get(o)??new Set;s.add(n.id),t.set(o,s)}}let r=[];for(let[n,i]of t){let o=Ur.has(n)?"client":Hr.has(n)?"server":n==="_ref"?"build":"shared";r.push({operatorId:n,bucket:o,blockIds:[...i]})}return r}async function Sl(e,t,r={}){let n=[],i=[],o=r.registry??Rw(),s=Ti(e,r.templates),a=Object.create(null),c=[];for(let[g,d]of s.pages.entries()){let u=xw(s,d.id,g===0),m=await Aw(u,t,o,n);Ew(m,t,n,i,r.strict===!0),await Pw(m,t,o,n,i);for(let[f,y]of Object.entries(m.elements)){let S=a[f];if(S)throw new H("duplicate-block-id",`Compiler output block id "${f}" conflicts across pages`,{blockId:f,firstPageId:S.pageId,pageId:d.id});let w=s.blocks[f];a[f]={...y,id:f,pageId:d.id,...w?.pageId===d.id&&w.parentId?{parentId:w.parentId}:{}}}c.push({...d,rootBlockIds:Iw(u,m)})}let l={version:"2.0",pages:c,...s.design?{design:s.design}:{},...s.connections?{connections:s.connections.map((g)=>({...g}))}:{},blocks:a};if(r.strict===!0&&e.version!=="2.0")i.push({missingType:"spec:version",elementKey:"spec",reason:"invalid-spec",context:"Native Spec version must be 2.0",code:"spec:version",path:"version"});let p=Tw(l);return{spec:l,gaps:i,warnings:n,...p.length>0?{operatorUsage:p}:{}}}import{readFileSync as Dw}from"node:fs";var vl=["auto","user","override"];function Kr(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!t)return{meta:"",body:e.trim()};return{meta:(t[1]??"").trim(),body:(t[2]??"").trim()}}function zr(e){let{meta:t}=Kr(e);if(!t)throw Error("design-md file is missing YAML frontmatter");let r=Ge(t);if(!r||typeof r!=="object")throw Error("design-md frontmatter must be a YAML object");if(typeof r.id!=="string"||!r.id)throw Error("design-md frontmatter must include a non-empty 'id' field");let n=typeof r.title==="string"?r.title.trim():"",i=typeof r.name==="string"?r.name.trim():"",o=n||i;if(!o)throw Error("design-md frontmatter must include a non-empty 'title' or 'name' field");if(typeof r.category!=="string"||!r.category)throw Error("design-md frontmatter must include a non-empty 'category' field");let s={id:r.id,title:o,category:r.category,tags:Array.isArray(r.tags)?r.tags:[],origin:typeof r.origin==="string"?r.origin:"local"};if(i)s.name=i;if(typeof r.version==="string"&&r.version.trim())s.version=r.version.trim();if(typeof r.sourceUrl==="string")s.sourceUrl=r.sourceUrl;if(Array.isArray(r.exemptRules)){let a=r.exemptRules.filter((c)=>typeof c==="string"&&c.trim().length>0);if(a.length>0)s.exemptRules=a.map((c)=>c.trim())}if(Array.isArray(r.extractedTokens))s.extractedTokens=r.extractedTokens;if(typeof r.layer==="string")if(vl.includes(r.layer))s.layer=r.layer;else console.warn(`[design-md] ignoring invalid layer "${r.layer}" on id="${s.id}"; expected one of ${vl.join("|")}`);return s}var Ow=[{pattern:/`?(--[\w-]+)`?\s*:\s*([#\w()%., ]+)/g,group:"css-var"},{pattern:/`?([\w-]+(?:Color|Bg|Text|Border|Shadow|Radius|Font|Size|Space))`?\s*[=:]\s*["']?([^"'\n,]+)["']?/gi,group:"token"}];function Mi(e){let t=new Set,r=[];for(let{pattern:n,group:i}of Ow){let o=new RegExp(n.source,n.flags),s;while((s=o.exec(e))!==null){let a=(s[1]??"").trim(),c=(s[2]??"").trim(),l=`${a}:${c}`;if(!t.has(l))t.add(l),r.push({name:a,value:c,group:i})}}return r}function It(e){let t=Dw(e,"utf-8"),{body:r}=Kr(t),n=zr(t),i=n.extractedTokens??Mi(r),o={id:n.id,title:n.title,category:n.category,tags:n.tags??[],origin:n.origin??"local",body:r,filePath:e};if(n.sourceUrl)o.sourceUrl=n.sourceUrl;if(n.exemptRules)o.exemptRules=n.exemptRules;if(n.layer)o.layer=n.layer;if(i.length>0)o.extractedTokens=i;return o}import{fileURLToPath as Lw}from"node:url";import{existsSync as Nw,readdirSync as _w}from"node:fs";import{join as Mw}from"node:path";var wl=Lw(new URL("../content",import.meta.url));function Wr(e=wl){if(!Nw(e))return[];let t=[];for(let r of _w(e).sort()){if(r.startsWith("_")||!r.endsWith(".design.md"))continue;try{t.push(It(Mw(e,r)))}catch(n){console.warn(`[design-md] skipping seed ${r}: ${n.message}`)}}return t}function Fw(e){return e==="quality"?"blocking":"advisory"}var Uw=["streamline your","empower your","supercharge your","unlock the power","best-in-class","enterprise-grade","next-generation","cutting-edge","revolutionize","game-changer","game changer","future-proof","seamless experience","drive growth","harness the power","take it to the next level","world-class","state-of-the-art","robust solution","powerful platform","effortlessly","seamlessly integrate","elevate your","transform your"],jw=["Inter","Roboto","Geist","Fraunces","Plus Jakarta","Space Grotesk"];function ae(e,t){let r=e.match(t);return r?r.length:0}var Vw=[{id:"marketing-buzzword",category:"slop",severity:"P2",message:"Marketing buzzwords read as AI filler — prefer concrete, specific copy.",detect:(e)=>{let t=e.toLowerCase();return Uw.reduce((r,n)=>r+(t.includes(n)?1:0),0)}},{id:"em-dash-overuse",category:"slop",severity:"P3",message:"Em-dash overuse (≥5) is a strong AI-writing tell.",detect:(e)=>{let t=ae(e,/[—]|--(?=\S)/g);return t>=5?t-4:0}},{id:"aphoristic-cadence",category:"slop",severity:"P2",message:'Manufactured-contrast cadence ("Not an X. Just Y.") is a recognizable AI pattern.',detect:(e)=>{let t=ae(e,/\bNot\s+(?:an?|just)\b[^.?!]*[.?!]/gi),r=ae(e,/\b[A-Z][^.?!]*\.\s+(?:No|Just)\s+[a-z]/g),n=t+r;return n>=3?n:0}},{id:"numbered-section-markers",category:"slop",severity:"P3",message:"Numbered section scaffolding (01 / 02 / 03) is an overused AI layout tell.",detect:(e)=>{let t=e.match(/\b(0[1-9]|1[0-2])\b/g)??[],r=new Set(t);if(r.size<3)return 0;let n=[...r].map(Number).sort((o,s)=>o-s);return n.some((o,s)=>s>0&&o-n[s-1]===1)?r.size:0}}],Hw=[{id:"gradient-text",category:"slop",severity:"P2",message:"Gradient text (bg-clip-text + transparent) is a classic AI hero tell.",detect:(e)=>ae(e,/bg-clip-text[^"']*text-transparent|text-transparent[^"']*bg-clip-text|-webkit-background-clip\s*:\s*text/gi)},{id:"ai-color-palette",category:"slop",severity:"P2",message:"Purple/violet gradient palette is the most recognizable AI color tell.",detect:(e)=>ae(e,/(from|via|to)-(purple|violet|fuchsia|indigo)-\d{3}|linear-gradient\([^)]*(?:#(?:8b5cf6|a855f7|7c3aed|6366f1))/gi)},{id:"side-tab",category:"slop",severity:"P2",message:"Thick colored side-border on a card (border-l-4 + accent) is the single most recognizable AI card tell.",detect:(e)=>ae(e,/border-l-(4|8)\s+border-(purple|violet|indigo|blue|primary)/gi)},{id:"overused-font",category:"slop",severity:"P3",message:"Over-represented font (Inter/Geist/…) without a brand reason reads as default AI styling.",detect:(e)=>jw.reduce((t,r)=>t+(new RegExp(`font-family[^;"']*${r}`,"i").test(e)?1:0),0)},{id:"emoji-icon",category:"slop",severity:"P2",message:"Emoji used as a heading/list/button icon is a stock AI tell — use a real icon or nothing.",detect:(e)=>ae(e,/<(?:h[1-6]|li|button|summary|th)\b[^>]*>\s*(?:<[^>]+>\s*)*\p{Extended_Pictographic}/giu)},{id:"github-dark-glow",category:"slop",severity:"P3",message:"Flat #0D1117 background with a neon cyan/violet glow is the default AI dark-mode look.",detect:(e)=>/#0d1117/i.test(e)&&/(?:box-shadow|drop-shadow|text-shadow)[^;"']*(?:#06b6d4|#22d3ee|#00f0ff|#a78bfa|#8b5cf6|cyan|violet)/i.test(e)?1:0},{id:"tiny-text",category:"quality",severity:"P1",message:"Body text below ~14px (text-[10px]/[11px]/[12px]) harms readability and accessibility.",detect:(e)=>ae(e,/text-\[(?:8|9|10|11|12)px\]|font-size\s*:\s*(?:8|9|10|11|12)px/gi)},{id:"gray-on-color",category:"quality",severity:"P1",message:"Gray text on a colored fill commonly fails WCAG contrast.",detect:(e)=>ae(e,/bg-(?:primary|blue|indigo|violet|purple)-\d{3}[^"']*text-(?:gray|slate|zinc|neutral)-\d{3}/gi)}],kl={P0:0.3,P1:0.15,P2:0.08,P3:0.04};function Gw(e){if(e>=0.9)return"A";if(e>=0.8)return"B";if(e>=0.65)return"C";if(e>=0.5)return"D";return"F"}var Rl="title|text|label|content|description|heading|subtitle|placeholder|body|caption|name",HP=new RegExp(`["']?\\b(?:${Rl})["']?\\s*:\\s*["']([^"'\\n]*)["']`,"gi"),GP=new RegExp(`^\\s*-?\\s*(?:${Rl})\\s*:\\s*([^\\s"'{\\[][^\\n]*)$`,"gim");function xl(e){let t=e.text??e.html??"",r=e.html??e.text??"",n=new Set(e.exempt??[]),i=[],o=(a,c)=>{for(let l of a){let p=Fw(l.category);if(p==="advisory"&&n.has(l.id))continue;let g=l.detect(c);if(g>0)i.push({ruleId:l.id,category:l.category,severity:l.severity,level:p,message:l.message,count:g})}};o(Vw,t),o(Hw,r);let s=1;for(let a of i){let c=Math.min(kl[a.severity]*(1+(a.count-1)/3),kl[a.severity]*2);s-=c}return s=Math.max(0,Math.min(1,s)),{score:s,grade:Gw(s),findings:i,blocked:i.some((a)=>a.level==="blocking")}}import{readdirSync as Kw,readFileSync as zw,statSync as Ww}from"node:fs";import{basename as Yw,join as Jw}from"node:path";var Qw="0.1.0";function Il(e){let{dir:t}=e,r;try{r=Kw(t)}catch{return[]}let n=e.defaultVersion??Qw,i=e.defaultLevel??"L4",o=e.defaultCategory??"template",s=[];for(let a of r){if(!/\.ya?ml$/i.test(a))continue;let c=Jw(t,a);try{if(!Ww(c).isFile())continue}catch{continue}let l=zw(c,"utf8");if(!l.trim())continue;let p=Yw(a).replace(/\.ya?ml$/i,""),g=Xw(p),d=Zw(p),u=ek(l)??`${d} template`;s.push({name:g,version:n,title:d,description:u,yaml:l,absolutePath:c,templateContract:{name:g,description:u,level:i,category:o,keywords:[g,p.toLowerCase(),"uibot-template",...e.extraKeywords??[]],composedFrom:tk(l)}})}return s.sort((a,c)=>a.name.localeCompare(c.name))}function Bi(e){let t=new Map;for(let r of e)for(let n of Il(r)){let i=t.get(n.name);if(i)throw Error(`duplicate template source name "${n.name}": ${i.absolutePath} and ${n.absolutePath}`);t.set(n.name,n)}return[...t.values()].sort((r,n)=>r.name.localeCompare(n.name))}function Xw(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function Zw(e){return e.replace(/[-_]+/g," ").replace(/\b\w/g,(t)=>t.toUpperCase())}function ek(e){return(e.match(/^\s*title:\s*["']?(.+?)["']?\s*$/m)??e.match(/^\s*-\s*id:.*\n\s*path:.*\n\s*title:\s*["']?(.+?)["']?\s*$/m))?.[1]?.trim()}function tk(e){let t=new Set;for(let r of e.matchAll(/^\s*-\s*type:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}for(let r of e.matchAll(/^\s*template:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}return[...t].sort()}var oT=new Set(Vs),sT=new Set(js);var nk=/^(unknown|unlicensed|none|n\/?a)$/i;function $i(e){let t=e?.trim();if(!t||nk.test(t))return;return t}var ik="uibot.resource.index.v1";class ze extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceIndexError"}}function G(e,t){return e<t?-1:e>t?1:0}function M(e){return e.normalize("NFKC").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim().replace(/\s+/g," ")}function ok(e){let t=M(e).replace(/ /g,"-");if(!t)throw new ze("invalid-resource-source-id",e);return t}function ce(e,t){return`${e}:${ok(t)}`}function Yr(e){let t=new Map;for(let r of e){let n=r?.trim();if(!n)continue;let i=M(n);if(!i||t.has(i))continue;t.set(i,n)}return[...t.entries()].sort(([r],[n])=>G(r,n)).map(([,r])=>r)}function At(e){return{level:"declared",maturity:"experimental",checks:{source:"declared",license:e?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"},evidence:[]}}function sk(e){let t=$i(e.license);return{type:e.type,id:e.id,...e.version?{version:e.version}:{},...e.url?{url:e.url}:{},...t?{license:t}:{}}}function Et(e){return{id:e.id,kind:e.kind,title:e.title,description:e.description,...e.category?{category:e.category}:{},tags:Yr(e.tags),aliases:Yr(e.aliases),capabilities:Yr(e.capabilities),dependencies:[...new Set(e.dependencies)].sort(G),source:sk(e.source),receipt:e.receipt}}function ak(e){return(e.body.split(/\r?\n/).map((r)=>r.replace(/^#+\s*/,"").trim()).find(Boolean)??e.title).slice(0,240)}function ck(e){return Object.freeze(e.tags),Object.freeze(e.aliases),Object.freeze(e.capabilities),Object.freeze(e.dependencies),Object.freeze(e.source),Object.freeze(e.receipt.checks),Object.freeze(e.receipt.evidence),Object.freeze(e.receipt),Object.freeze(e)}function lk(e){let t=new Map;for(let r of Object.keys(e).sort(G)){let n=e[r];if(!n)continue;let i=ce("component",r);for(let o of Yr([r,n.name])){let s=M(o),a=t.get(s)??[];if(!a.includes(i))a.push(i);t.set(s,a.sort(G))}}return t}function uk(e,t,r){let n=r.get(M(e))??[];if(n.length===0)throw new ze("dangling-resource-dependency",`${t} -> ${ce("component",e)}`);if(n.length>1)throw new ze("ambiguous-resource-dependency",`${t} -> ${e}: ${n.join(",")}`);return n[0]}function dk(e,t,r,n){let i=e.startsWith("template:")?e.slice(9):e;if(Object.hasOwn(n,i))return ce("template",i);return uk(e,t,r)}function Pt(e,t,r){return $i(r?.[e]??t)}function Al(e){return Object.entries(e).filter(([,t])=>t.level==="L4").sort(([t],[r])=>G(t,r)).map(([t,r])=>({id:`${t}-example`,title:`${r.name} Example`,description:r.description,category:r.category,tags:r.keywords,aliases:[`${t} example`,`${r.name} example`],capabilities:["example:template"],dependencies:[ce("template",t)]}))}function El(e){let t=e.components??{},r=e.templates??{},n=e.designGuides??[],i=e.examples??[],o=e.skills??[],s=e.licenses,a=lk(t),c=[];for(let u of Object.keys(t).sort(G)){let m=t[u];if(!m)continue;let f=ce("component",u),y=Pt(f,void 0,s);c.push(Et({id:f,kind:"component",title:m.name,description:m.description,category:m.category,tags:m.tags??[],aliases:[u,m.name],capabilities:["catalog:component"],dependencies:[],source:{type:"catalog",id:u,...y?{license:y}:{}},receipt:At(Boolean(y))}))}for(let u of Object.keys(r).sort(G)){let m=r[u];if(!m)continue;let f=ce("template",u),y=Pt(f,void 0,s);c.push(Et({id:f,kind:"template",title:m.name,description:m.description,category:m.category,tags:m.keywords,aliases:[u,m.name],capabilities:[],dependencies:(m.composedFrom??[]).map((S)=>dk(S,f,a,r)),source:{type:"template-contract",id:u,...y?{license:y}:{}},receipt:At(Boolean(y))}))}for(let u of[...n].sort((m,f)=>G(m.id,f.id))){let m=ce("design-guide",u.id),f=Pt(m,void 0,s);c.push(Et({id:m,kind:"design-guide",title:u.title,description:ak(u),category:u.category,tags:u.tags,aliases:[u.id,u.title],capabilities:["designMd:source"],dependencies:[],source:{type:"design-md",id:u.id,...u.sourceUrl?{url:u.sourceUrl}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}for(let u of[...i].sort((m,f)=>G(m.id,f.id))){let m=ce("example",u.id),f=Pt(m,u.license,s);c.push(Et({id:m,kind:"example",title:u.title,description:u.description,...u.category?{category:u.category}:{},tags:u.tags??[],aliases:[u.id,u.title,...u.aliases??[]],capabilities:u.capabilities??[],dependencies:u.dependencies??[],source:{type:"example",id:u.id,...u.version?{version:u.version}:{},...u.sourceUrl?{url:u.sourceUrl}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}for(let u of[...o].sort((m,f)=>G(m.id,f.id))){let m=ce("skill",u.id),f=Pt(m,void 0,s);c.push(Et({id:m,kind:"skill",title:u.title,description:u.description?.trim()||u.title,tags:[...u.tags??[],...u.triggers??[]],aliases:[u.id,u.title,...u.triggers??[]],capabilities:["skill:definition"],dependencies:[],source:{type:"skill",id:u.id,...u.version?{version:u.version}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}c.sort((u,m)=>G(u.id,m.id));let l=new Set;for(let u of c){if(l.has(u.id))throw new ze("duplicate-resource-id",u.id);l.add(u.id)}for(let u of c)for(let m of u.dependencies)if(!l.has(m))throw new ze("dangling-resource-dependency",`${u.id} -> ${m}`);let p=new Map;for(let u of c)for(let m of u.aliases){let f=M(m);if(!f)continue;let y=p.get(f)??new Set;y.add(u.id),p.set(f,y)}let g=Object.freeze(Object.fromEntries([...p.entries()].sort(([u],[m])=>G(u,m)).map(([u,m])=>[u,Object.freeze([...m].sort(G))]))),d=Object.freeze(c.map(ck));return Object.freeze({schemaVersion:ik,resources:d,aliases:g})}var pk=[["data table","data grid","datatable","table","表格","数据表","数据表格"],["button","action button","按钮","操作按钮"],["dashboard","admin dashboard","仪表盘","后台","管理后台"],["kanban","kanban board","看板","任务看板"],["form","input form","表单","输入表单"],["navigation","nav","sidebar","导航","侧边栏"]],gk=Object.freeze(pk.map((e)=>Object.freeze([...e]))),Pl=new Map;for(let e of gk){let t=Object.freeze([...new Set(e.map(M).filter(Boolean))].sort());for(let r of t)Pl.set(r,t)}function qi(e){let t=M(e);return Pl.get(t)??Object.freeze([t])}class ve extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceQueryError"}}var Vi=Object.freeze({"exact-id":1000,"exact-title":900,alias:800,tag:600,capability:500,category:400,token:200,fuzzy:100}),fk=Object.freeze(Object.keys(Vi)),Tl=new Map(fk.map((e,t)=>[e,t])),Ol=new Map([["component",0],["template",1],["design-guide",2],["example",3],["skill",4]]);function K(e,t){return e<t?-1:e>t?1:0}function Dl(e){return new Set((e??[]).map(M).filter(Boolean))}function Fi(e,t){let r=Dl(t);if(r.size===0)return!0;let n=Dl(e);return[...r].some((i)=>n.has(i))}function mk(e,t){if(t.kinds?.length&&!t.kinds.includes(e.kind))return!1;if(!Fi(e.tags,t.tags))return!1;if(!Fi(e.category?[e.category]:[],t.categories))return!1;if(!Fi(e.capabilities,t.capabilities))return!1;if(t.maturities?.length&&!t.maturities.includes(e.receipt.maturity))return!1;return!0}function yk(e){return Boolean(e.kinds?.length||e.tags?.length||e.categories?.length||e.capabilities?.length||e.maturities?.length)}function le(e,t,r,n=Vi[t]){if(e.some((i)=>i.code===t&&i.value===r))return;e.push({code:t,value:r,score:n})}function Ui(e,t){return e.find((r)=>M(r)===t)}function ji(e){return[e.id,e.title,...e.aliases,...e.tags,...e.category?[e.category]:[],...e.capabilities]}function hk(e,t,r){if(Math.abs(e.length-t.length)>r)return r+1;let n=Array.from({length:t.length+1},(i,o)=>o);for(let i=1;i<=e.length;i+=1){let o=[i],s=i;for(let a=1;a<=t.length;a+=1){let c=(n[a-1]??r+1)+(e[i-1]===t[a-1]?0:1),l=Math.min((n[a]??r+1)+1,(o[a-1]??r+1)+1,c);o.push(l),s=Math.min(s,l)}if(s>r)return r+1;n=o}return n[t.length]??r+1}function bk(e,t){let r=M(t),n=[];if(M(e.id)===r)le(n,"exact-id",e.id);if(M(e.title)===r)le(n,"exact-title",e.title);let i=Ui(e.aliases,r);if(i)le(n,"alias",i);let o=Ui(e.tags,r);if(o)le(n,"tag",o);let s=Ui(e.capabilities,r);if(s)le(n,"capability",s);if(e.category&&M(e.category)===r)le(n,"category",e.category);if(!i){let l=qi(r).filter((g)=>g!==r),p=new Set(ji(e).map(M));if(l.some((g)=>p.has(g)))le(n,"alias",t.trim())}let a=r.split(" ").filter(Boolean),c=M(ji(e).join(" "));if(a.length>0&&a.every((l)=>c.includes(l)))le(n,"token",t.trim());if(n.length===0&&r.length>=4){let l;for(let p of ji(e)){let g=M(p);if(g.length<4)continue;let d=hk(r,g,2);if(d<=2&&(!l||d<l.distance||d===l.distance&&K(p,l.value)<0))l={value:p,distance:d}}if(l)le(n,"fuzzy",l.value,Vi.fuzzy-l.distance)}return n.sort((l,p)=>{if(l.score!==p.score)return p.score-l.score;return(Tl.get(l.code)??99)-(Tl.get(p.code)??99)||K(l.value,p.value)})}function Ll(e,t,r){if(t.has(r))return[r];let n=M(r),i=e.aliases[n];if(i?.length)return[...i];let o=new Set;for(let s of qi(n))for(let a of e.aliases[s]??[])o.add(a);return[...o].sort(K)}function Nl(e,t){return new ve("resource-alias-ambiguous",`${e.trim()}: ${t.join(",")}`)}function _l(e){let t=new Map(e.resources.map((n)=>[n.id,n]));function r(n){let i=n.trim(),o=Ll(e,t,i);if(o.length===0)throw new ve("resource-not-found",i);if(o.length>1)throw Nl(i,o);let s=o[0],a=s?t.get(s):void 0;if(!a)throw new ve("resource-not-found",i);return a}return Object.freeze({manifest:()=>e,search(n){let i=n.text?.trim()??"";if(!i&&!yk(n))throw new ve("resource-query-empty","text or filter is required");if(n.limit!==void 0&&(!Number.isInteger(n.limit)||n.limit<=0))throw new ve("resource-query-invalid-limit",String(n.limit));let o=e.resources.filter((s)=>mk(s,n)).map((s)=>{let a=i?bk(s,i):[];return{resource:s,score:a.reduce((c,l)=>c+l.score,0),reasons:a}}).filter((s)=>!i||s.reasons.length>0).sort((s,a)=>a.score-s.score||K(s.resource.id,a.resource.id));return n.limit===void 0?o:o.slice(0,n.limit)},get:r,build(n){if(n.length===0||n.every((d)=>!d.trim()))throw new ve("resource-query-empty","at least one build root is required");let i=[],o=new Set;for(let d of n){let u=d.trim(),m=Ll(e,t,u);if(m.length===0)i.push({id:u,reason:"missing-resource"});else if(m.length>1)throw Nl(u,m);else{let f=m[0];if(f)o.add(f)}}let s=new Set,a=new Set,c=new Set,l=[],p=[],g=(d,u)=>{if(s.has(d))return;if(a.has(d)){i.push({id:d,...u?{requiredBy:u}:{},reason:"dependency-cycle"});return}let m=t.get(d);if(!m){i.push({id:d,...u?{requiredBy:u}:{},reason:"missing-resource"});return}a.add(d),c.add(d);let f=[...m.dependencies].sort((y,S)=>{let w=t.get(y),k=t.get(S);return(Ol.get(w?.kind??"")??99)-(Ol.get(k?.kind??"")??99)||K(y,S)});for(let y of f)p.push({from:d,to:y,relation:"depends-on"}),g(y,d);a.delete(d),s.add(d),l.push(d)};for(let d of[...o].sort(K))g(d);return{roots:[...o].sort(K),nodes:[...c].sort(K).map((d)=>{let u=t.get(d);if(!u)throw new ve("resource-not-found",d);return{id:d,kind:u.kind,maturity:u.receipt.maturity}}),edges:p.sort((d,u)=>K(d.from,u.from)||K(d.to,u.to)),order:l,gaps:i.sort((d,u)=>K(d.id,u.id)||K(d.requiredBy??"",u.requiredBy??"")||K(d.reason,u.reason))}}})}function Ul(){return{listCatalog:()=>[...wk],getDesignMd:(e)=>{let t=Vl();if(!e)return t.map(({body:r,...n})=>n);return t.find((r)=>r.id===e)??null},listTemplates:()=>Hi().map((e)=>({name:e.name,title:e.title,description:e.description,level:e.templateContract.level,category:e.templateContract.category,composedFrom:e.templateContract.composedFrom??[]}))}}async function jl(e){let t={};if(e.spec!==void 0){let r=typeof e.spec==="string"?_i(e.spec):e.spec;if(typeof r!=="object"||r===null||!Array.isArray(r.pages))throw Error("spec must be a UIBot Spec object with a pages array");let i=await Sl(r,{components:{...Yt,...Jt},actions:{},templates:{}},{templates:Sk()});t.spec={ok:i.gaps.length===0,gaps:i.gaps,warnings:i.warnings}}if(e.html!==void 0){let r=xl({html:e.html});t.html={ok:!r.blocked,...r}}return t}function Ck(){let e=["./resources/templates","./resources/shells","../../../examples/templates","../../../examples/shells"].map((i)=>Fl(new URL(i,import.meta.url))),t=[],r=new Set,n=new Set;for(let i of e){let o=i.endsWith("shells")?"shells":"templates";if(!ql(i)||r.has(i)||n.has(o))continue;if(n.add(o),r.add(i),i.endsWith("/shells")||i.endsWith("\\shells"))t.push({dir:i,defaultLevel:"L3",defaultCategory:"feature",extraKeywords:["sidebar","app-shell","shell"]});else t.push({dir:i})}return t}var Ml,Bl,$l;function Hi(){return Ml??=Bi(Ck()),Ml}function Sk(){return Bl??=Object.fromEntries(Hi().map((e)=>[e.name,_i(e.yaml)])),Bl}function Vl(){let e=Fl(new URL("./resources/design-md",import.meta.url));return $l??=ql(e)?Wr(e):Wr(),$l}var Jr;function Hl(){if(Jr)return Jr;let e=Object.fromEntries(Hi().map((t)=>[t.name,t.templateContract]));return Jr=_l(El({components:{...Yt,...Jt},templates:e,designGuides:Vl(),examples:Al(e)})),Jr}function vk(){let e=new Map;for(let t of[...Object.values(Yt),...Object.values(Jt)]){if(e.has(t.name))throw Error(`Duplicate catalog block name '${t.name}' across the shadcn and studio catalogs`);e.set(t.name,t)}return[...e.values()].sort((t,r)=>t.name.localeCompare(r.name))}var wk=Object.freeze(vk());var Ek="This uibot-mcp process has no Hub service wired, so component generation and task status are unavailable. Embed it with createUIBotMcpServer({ service, discovery }) to enable those tools.";function Pk(){return{requestComponent:()=>Promise.reject(Error(Ek)),getTask:()=>{return},listTasks:()=>[],getTaskStatus:()=>{return}}}function Tk(e,t){let r=Object.fromEntries(Object.entries(t??{}).filter(([,n])=>n!=null));return{...e,...r}}function Ok(e={}){let t=Ws({service:e.service??Pk(),serviceAvailable:e.service!=null,discovery:Tk(Ul(),e.discovery),resourceQuery:e.resourceQuery??Hl(),validate:e.validate??jl}),r=new Rk({name:"uibot",version:"0.1.0"},{capabilities:{tools:{}}});return r.setRequestHandler(Ak,()=>({tools:t.listTools()})),r.setRequestHandler(Ik,async(n)=>{let i=n.params.arguments??{};try{let o=await t.callTool(n.params.name,i);return{content:Ys(o.content),...o.isError?{isError:!0}:{}}}catch(o){return{content:[{type:"text",text:o instanceof Error?o.message:String(o)}],isError:!0}}}),r}function Dk(e=process.argv[1],t=import.meta.url){if(!e)return!1;try{return Gl(kk(t))===Gl(e)}catch{return!1}}async function Lk(){let e=Ok();await e.connect(new xk);for(let t of["SIGINT","SIGTERM"])process.on(t,()=>{e.close().finally(()=>process.exit(0))})}if(Dk())Lk().catch((e)=>{console.error(e),process.exit(1)});export{Ok as createUIBotMcpServer,Dk as isEntryPoint,Lk as main};
138
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Br(e),r=He(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Br(e),r=He(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}fv.Parser=Xc});var nl=h(function(kv){var Zc=mi(),yv=yt(),wt=ht(),hv=xn(),bv=E(),Cv=xi(),el=Ii();function tl(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Cv.LineCounter||null,prettyErrors:t}}function Sv(e,t={}){let{lineCounter:r,prettyErrors:n}=tl(t),i=new el.Parser(r?.addNewLine),o=new Zc.Composer(t),s=Array.from(o.compose(i.parse(e)));if(n&&r)for(let a of s)a.errors.forEach(wt.prettifyError(e,r)),a.warnings.forEach(wt.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function rl(e,t={}){let{lineCounter:r,prettyErrors:n}=tl(t),i=new el.Parser(r?.addNewLine),o=new Zc.Composer(t),s=null;for(let a of o.compose(i.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new wt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&r)s.errors.forEach(wt.prettifyError(e,r)),s.warnings.forEach(wt.prettifyError(e,r));return s}function vv(e,t,r){let n=void 0;if(typeof t==="function")n=t;else if(r===void 0&&t&&typeof t==="object")r=t;let i=rl(e,r);if(!i)return null;if(i.warnings.forEach((o)=>hv.warn(i.options.logLevel,o)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:n},r))}function wv(e,t,r){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let i=Math.round(r);r=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=r??t??{};if(!i)return}if(bv.isDocument(e)&&!n)return e.toString(r);return new yv.Document(e,n,r).toString(r)}kv.parse=vv;kv.parseAllDocuments=Sv;kv.parseDocument=rl;kv.stringify=wv});import{realpathSync as Gl}from"node:fs";import{fileURLToPath as kk}from"node:url";import{Server as Rk}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as xk}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as Ik,ListToolsRequestSchema as Ak}from"@modelcontextprotocol/sdk/types.js";var ig=Xl(Fs(),1);var Us=["SetState","ResetState","Request","Link","Validate","DisplayMessage","Login","Logout","CallMethod"],fn={SetState:{name:"SetState",description:"Set a page state path to an evaluated declarative value",params:{path:{type:"string"},value:{description:"Literal or supported PropValue expression"}},generation:{evaluatedParams:["value"],prerequisites:["Declare the state path on the same page"],example:{action:"SetState",params:{path:"open",value:{_not:{_state:"open"}}}}}},ResetState:{name:"ResetState",description:"Restore paths from the supplied initial map; missing values become null",params:{paths:{type:"array",items:{type:"string"}},initial:{type:"object"}},generation:{evaluatedParams:[],prerequisites:["Supply literal initial values; omitting paths resets keys in initial"],example:{action:"ResetState",params:{paths:["open"],initial:{open:!1}}}}},Request:{name:"Request",description:"Execute a configured connection request",params:{connectionId:{type:"string"},request:{type:"object"},loadingPath:{type:"string"},responsePath:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:["connectionId","request"],prerequisites:["Host must inject the declared connection driver and secrets; Studio local Spec preview does not"],example:{action:"Request",params:{connectionId:"projects",request:{id:"list",connectionId:"projects",payload:{operation:"FindAll",resource:"projects"}},responsePath:"rows"}}}},Link:{name:"Link",description:"Emit navigation to a literal URL or page path",params:{path:{type:"string"},url:{type:"string"},target:{enum:["_self","_blank"]}},generation:{evaluatedParams:[],prerequisites:["Host handles navigation; local page paths must exist"],example:{action:"Link",params:{path:"/details"}}}},Validate:{name:"Validate",description:"Emit form validation event; does not itself throw for invalid fields",params:{formId:{type:"string"},errorPath:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host form:validate listener; prefer native required controls and Form.Submit"],example:{action:"Validate",params:{formId:"contact"}}}},DisplayMessage:{name:"DisplayMessage",description:"Emit an evaluated message for the host to display",params:{message:{description:"Literal or supported PropValue expression"},level:{enum:["info","success","warning","error"]},duration:{type:"number"}},generation:{evaluatedParams:["message"],prerequisites:["Requires host message:display listener"],example:{action:"DisplayMessage",params:{message:"Saved locally",level:"success"}}}},Login:{name:"Login",description:"Set a supplied local session user or request external login",params:{user:{type:"object"},provider:{type:"string"}},generation:{evaluatedParams:[],prerequisites:["Requires host session/auth; setting a local user is not server authentication"],example:{action:"Login",params:{provider:"configured-provider"}}}},Logout:{name:"Logout",description:"Clear the local session and emit auth:logout",params:{},generation:{evaluatedParams:[],prerequisites:["Host owns server session invalidation"],example:{action:"Logout",params:{}}}},CallMethod:{name:"CallMethod",description:"Emit a call to an existing block method",params:{blockId:{type:"string"},method:{type:"string"},args:{type:"array"}},generation:{evaluatedParams:["args"],prerequisites:["Requires an explicitly documented installed block method/listener; never invent a method"],example:{action:"CallMethod",params:{blockId:"documented-block",method:"documented-method",args:[]}}}}};var lg={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},Ex=Array.from(new Set(Object.values(lg).flat()));var mn=["component","template","design-guide","example","skill"],Ht=["experimental","candidate","recommended"];var js=["missing","declared","verified","external-consumer"],Vs=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure","packed-install","typecheck","browser"],Gt=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])})]);var zs=["resource-mcp-invalid-argument","resource-query-failed"];function Kt(e,t){return`Tool '${e}' is not wired in this build: no '${t}' discovery provider was supplied. `+`This is not an empty result — supply a 'discovery.${t}' provider to enable it.`}function Hs(e){return`Tool '${e}' is not wired in this build: no Hub service was supplied. Supply a service to enable component requests and task status.`}function ug(e){if(e.status==="ready")return{status:"ready",artifact:e.artifact};return{status:e.status,taskId:e.taskId,pollUrl:e.pollUrl}}function dg(e){switch(e.status){case"ready":return{taskId:e.taskId,status:"ready",artifact:e.artifact};case"failed":return{taskId:e.taskId,status:"failed",error:e.error};case"pending":case"running":return{taskId:e.taskId,status:e.status,...typeof e.progress==="number"?{progress:e.progress}:{}}}}function te(e){return{content:[{type:"json",json:e}]}}function j(e){return{content:[{type:"text",text:e}],isError:!0}}function yn(e,t){return{content:[{type:"json",json:{error:{code:e,detail:t}}}],isError:!0}}var Wt="uibot_resource_";function pg(e){return`${Wt}${e}`}function Gs(e,t){let r;if(e==="resource-kind")r={type:"string",enum:[...mn]};else if(e==="resource-maturity")r={type:"string",enum:[...Ht]};else if(e==="positive-integer")r={type:"integer",minimum:1};else r={type:"string"};return t?{type:"array",items:r}:r}function gg(){return Gt.map((e)=>{let t={},r=[];for(let n of e.positionals)if(t[n.property]=Gs(n.type,"variadic"in n&&n.variadic===!0),n.required)r.push(n.property);for(let n of e.options)t[n.property]=Gs(n.type,"multiple"in n&&n.multiple===!0);return{name:pg(e.name),description:e.summary,inputSchema:{type:"object",properties:t,additionalProperties:!1,...r.length?{required:r}:{}}}})}class ie extends Error{detail;code=zs[0];constructor(e){super(e);this.detail=e;this.name="ResourceMcpArgumentError"}}function zt(e,t){let r=new Set(t),n=Object.keys(e).find((i)=>!r.has(i));if(n)throw new ie(`unsupported argument: ${n}`)}function Ks(e,t){let r=e[t];if(r===void 0)return;if(typeof r!=="string"||!r.trim())throw new ie(`${t} must be a non-empty string`);return r}function Le(e,t,r){let n=e[t];if(n===void 0)return;if(!Array.isArray(n)||n.length===0||n.some((i)=>typeof i!=="string"||!i.trim()))throw new ie(`${t} must be a non-empty string array`);if(r){let i=n.find((o)=>!r.includes(o));if(i)throw new ie(`${t} contains unsupported value: ${i}`)}return n}function fg(e){if(e instanceof ie)return yn(e.code,e.detail);if(e&&typeof e==="object"){let t=e;if(typeof t.code==="string"){let r=typeof t.detail==="string"?t.detail:typeof t.message==="string"?t.message:t.code;return yn(t.code,r)}}return yn(zs[1],"resource query callback failed")}async function mg(e,t,r){try{if(e==="manifest")return zt(t,[]),te({data:{index:await r.manifest()}});if(e==="search"){zt(t,["text","kinds","tags","categories","capabilities","maturities","limit"]);let i=Ks(t,"text"),o=Le(t,"kinds",mn),s=Le(t,"tags"),a=Le(t,"categories"),c=Le(t,"capabilities"),l=Le(t,"maturities",Ht),p=t.limit;if(p!==void 0&&(typeof p!=="number"||!Number.isInteger(p)||p<=0))throw new ie("limit must be a positive integer");let g={...i?{text:i}:{},...o?{kinds:o}:{},...s?{tags:s}:{},...a?{categories:a}:{},...c?{capabilities:c}:{},...l?{maturities:l}:{},...typeof p==="number"?{limit:p}:{}};return te({data:{matches:await r.search(g)}})}if(e==="get"){zt(t,["id"]);let i=Ks(t,"id");if(!i)throw new ie("id must be a non-empty string");return te({data:{resource:await r.get(i)}})}zt(t,["roots"]);let n=Le(t,"roots");if(!n)throw new ie("roots must be a non-empty string array");return te({data:{plan:await r.build(n)}})}catch(n){return fg(n)}}function Ws(e){let t=[{name:"uibot_request_component",description:"Request a missing component from the UIBot Hub runtime.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Component name"},context:{type:"string",description:"Optional usage context"},requestedBy:{type:"string",description:"Requester identifier"},priority:{type:"string",enum:["low","normal","high"]}},required:["name"]}},{name:"uibot_get_task_status",description:"Read the status of a Hub task.",inputSchema:{type:"object",properties:{taskId:{type:"string",description:"Hub task identifier"}},required:["taskId"]}},{name:"uibot_list_catalog",description:"List catalog components available to agents (read-only discovery). Returns name/description/category entries.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Optional substring filter on name/description"}}}},{name:"uibot_get_design_md",description:"Get design-md entries (read-only). Omit id to list summaries; provide id for one full entry.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Optional design-md id"}}}},{name:"uibot_list_templates",description:"List installable UIBot templates (read-only discovery).",inputSchema:{type:"object",properties:{query:{type:"string",description:"Optional substring filter"}}}},{name:"uibot_validate",description:"Validate a generated artifact. Pass `spec` (UIBot Spec object, or JSON/YAML text) to compile it against the catalog and get missing-component gaps and warnings; pass `html` to run the design-quality rules. Fix every gap before handing the result on.",inputSchema:{type:"object",properties:{spec:{description:"UIBot Spec object, or its JSON/YAML text"},html:{type:"string",description:"Generated HTML document"}}}},...gg()];return{listTools(){return t.filter((r)=>{if(r.name==="uibot_request_component")return e.serviceAvailable!==!1;if(r.name==="uibot_get_task_status")return e.serviceAvailable!==!1;if(r.name==="uibot_list_catalog")return e.discovery?.listCatalog!=null;if(r.name==="uibot_get_design_md")return e.discovery?.getDesignMd!=null;if(r.name==="uibot_list_templates")return e.discovery?.listTemplates!=null;if(r.name==="uibot_validate")return e.validate!=null;if(r.name.startsWith(Wt))return e.resourceQuery!=null;return!0})},async callTool(r,n){if(r.startsWith(Wt)){let i=r.slice(Wt.length);if(!Gt.some((s)=>s.name===i))return j(`Unknown tool: ${r}`);if(!e.resourceQuery)return j(Kt(r,"resourceQuery"));return mg(i,n,e.resourceQuery)}if(r==="uibot_request_component"){if(e.serviceAvailable===!1)return j(Hs(r));let i=typeof n.name==="string"?n.name:"";if(!i)return j("Field 'name' is required");let o=await e.service.requestComponent({name:i,...typeof n.context==="string"?{context:n.context}:{},...typeof n.requestedBy==="string"?{requestedBy:n.requestedBy}:{},...n.priority==="low"||n.priority==="normal"||n.priority==="high"?{priority:n.priority}:{}});return te(ug(o))}if(r==="uibot_get_task_status"){if(e.serviceAvailable===!1)return j(Hs(r));let i=typeof n.taskId==="string"?n.taskId:"";if(!i)return j("Field 'taskId' is required");let o=e.service.getTaskStatus(i);return o?te(dg(o)):j("Task not found")}if(r==="uibot_list_catalog"){let i=e.discovery?.listCatalog;if(!i)return j(Kt(r,"listCatalog"));let o=await i(),s=Array.isArray(o)?o:[],a=typeof n.query==="string"?n.query.toLowerCase():"",c=a?s.filter((l)=>JSON.stringify(l).toLowerCase().includes(a)):s;return te({items:c,count:c.length})}if(r==="uibot_get_design_md"){let i=e.discovery?.getDesignMd;if(!i)return j(Kt(r,"getDesignMd"));let o=typeof n.id==="string"?n.id:void 0,s=await i(o)??(o?null:[]);return te({id:o??null,data:s})}if(r==="uibot_list_templates"){let i=e.discovery?.listTemplates;if(!i)return j(Kt(r,"listTemplates"));let o=await i(),s=Array.isArray(o)?o:[],a=typeof n.query==="string"?n.query.toLowerCase():"",c=a?s.filter((l)=>JSON.stringify(l).toLowerCase().includes(a)):s;return te({items:c,count:c.length})}if(r==="uibot_validate"){if(!e.validate)return j(`Tool '${r}' is not wired in this build: no 'validate' provider was supplied.`);let i=typeof n.html==="string"?n.html:void 0;if(n.spec===void 0&&i===void 0)return j("Provide 'spec' or 'html'");try{return te(await e.validate({...n.spec===void 0?{}:{spec:n.spec},...i===void 0?{}:{html:i}}))}catch(o){return j(o instanceof Error?o.message:String(o))}}return j(`Unknown tool: ${r}`)}}}function Ys(e){return e.map((t)=>t.type==="text"?{type:"text",text:t.text}:{type:"text",text:t.json===void 0?"null":JSON.stringify(t.json,null,2)})}import{existsSync as ql}from"node:fs";import{fileURLToPath as Fl}from"node:url";var Yt={AppNavigation:{name:"AppNavigation",tags:["navigation"],description:"Workspace navigation with configured groups, brand and account",category:"composite",level:"L2",props:{activePath:{type:"string"},brand:{type:"string"},logoSrc:{type:"string",description:"Optional brand image URL; preserve its aspect ratio"},subtitle:{type:"string"},groups:{type:"array"},workspaces:{type:"array"},userName:{type:"string"},email:{type:"string"},initials:{type:"string"},profileHref:{type:"string"}},events:{onNavigate:{description:"Serializable values in event.values"}}},Field:{name:"Field",tags:["form"],description:"Accessible controlled or local form field; native validation and scalar event values",category:"composite",level:"L2",props:{kind:{type:"string"},label:{type:"string"},name:{type:"string"},value:{description:"String, boolean, or string array according to kind"},defaultValue:{description:"Initial string, boolean, or string array"},options:{type:"array"},description:{type:"string"},error:{type:"string"},required:{type:"boolean"},disabled:{type:"boolean"},placeholder:{type:"string"},rows:{type:"number"},length:{type:"number"},autoComplete:{type:"string"}},events:{onChange:{description:"Serializable values in event.values"}}},StatCard:{name:"StatCard",tags:["metric"],description:"Metric with label, value and supporting text",category:"composite",level:"L2",props:{label:{type:"string"},value:{type:"string"},description:{type:"string"},icon:{type:"string"}},events:{}},BarChart:{name:"BarChart",tags:["chart"],description:"Accessible deterministic bar series with visible labels and hover values",category:"composite",level:"L2",props:{label:{type:"string"},data:{type:"array"},height:{type:"number"},prefix:{type:"string"}},events:{}},AvatarList:{name:"AvatarList",tags:["list"],description:"Compact people and activity list",category:"composite",level:"L2",props:{items:{type:"array"}},events:{}},IntegrationGrid:{name:"IntegrationGrid",tags:["data"],description:"Searchable integrations with explicit capability availability",category:"composite",level:"L2",props:{configurations:{type:"array"},configurable:{type:"boolean"},items:{type:"array"},pending:{type:"boolean"},error:{type:"string"}},events:{onConfigure:{description:"Workspace configuration intent and existing record version"},onAction:{description:"Serializable values in event.values"}}},ChatPanel:{name:"ChatPanel",tags:["interactive"],description:"Conversation selector and controlled message composition",category:"composite",level:"L2",props:{draft:{type:"string"},currentUserId:{type:"string"},conversations:{type:"array"},messages:{type:"array"},selectedId:{type:"string"},pending:{type:"boolean"},canSend:{type:"boolean"},error:{type:"string"}},events:{onDraftChange:{description:"Draft text in event.value; clear only after confirmed persistence"},onSelect:{description:"Serializable values in event.values"},onSend:{description:"Serializable values in event.values"}}},DataTable:{name:"DataTable",description:"Configurable record table with search, facets, sorting, stable selection and pagination. Server mode emits query intent without filtering current-page rows.",category:"composite",level:"L2",tags:["table","records","admin"],props:{rows:{type:"array"},columns:{type:"array"},filters:{type:"array"},actions:{type:"array"},bulkActions:{type:"array"},rowKey:{type:"string",default:"id"},searchKeys:{type:"array"},selectedIds:{type:"array"},view:{description:"Controlled TableView object or JSON-encoded URL view"},pageSize:{type:"number",default:10},server:{type:"boolean"},total:{type:"number"},hasNextPage:{type:"boolean"},loading:{type:"boolean"},error:{type:"string"},minWidth:{type:"number"},searchPlaceholder:{type:"string"},label:{type:"string"},selectable:{type:"boolean"},emptyText:{type:"string"}},events:{onViewChange:{description:"Query intent in event.values: search, filters JSON, sort, descending, page, pageSize"},onSelectionChange:{description:"Stable ids in event.values.ids"},onRowAction:{description:"event.values.id and action"},onBulkAction:{description:"event.values.ids and action"}}},Box:{name:"Box",description:"Flex container for composing layout. Use as a row or column spacer between other blocks.",category:"primitive",level:"L1",tags:["container","layout"],props:{direction:{type:"string",enum:["col","row"],default:"col",description:"Flex direction"},gap:{type:"string",enum:["none","xs","sm","md","lg","xl"],default:"md"},padding:{type:"string",enum:["none","xs","sm","md","lg","xl"]},align:{type:"string",enum:["start","center","end","stretch"]},justify:{type:"string",enum:["start","center","end","between","around"]},wrap:{type:"boolean",default:!1},full:{type:"boolean",default:!1}},usageScenarios:["Horizontal row of action buttons","Vertical stack of form fields","Two-column grid using two Box[direction=row] with flex-1 children"],constraints:["Do not use Box as a semantic section; prefer Card or PageLayout for major layout regions"]},PageLayout:{name:"PageLayout",description:"Top-level page scaffold: sticky header, optional sidebar, scrollable main area, optional footer.",category:"composite",level:"L2",tags:["page","layout"],props:{appearance:{type:"string",enum:["default","admin"]},routes:{type:"array"},headerLinks:{type:"array"},accountLinks:{type:"array"},tokens:{type:"object",description:"Admin frame sidebar/surface/foreground/accent/accent-foreground/border/font and primary/primary-foreground CSS tokens"},theme:{type:"string"},font:{type:"string"},direction:{type:"string"},initials:{type:"string"},title:{type:"string",description:"App or page title shown in the sticky header"},variant:{type:"string",enum:["sidebar","inset","floating"],default:"sidebar",description:"Frame: flush sidebar, inset main, or floating sidebar card"},collapsible:{type:"string",enum:["none","icon","offcanvas"],default:"none",description:"How the sidebar collapses; default none keeps v2.40 width"}},events:{onThemeChange:{description:"Selected theme in event.value"}},slots:{headerActions:{description:"Buttons or links placed in the top-right of the header"},sidebar:{description:"Left sidebar content, e.g. PageSiderMenu"},footer:{description:"Bottom footer strip"}},usageScenarios:["Admin dashboard shell","Settings page with left navigation","Landing page with header and main content"],constraints:["Use at most one PageLayout per page","Do not nest PageLayout inside another PageLayout"]},Card:{name:"Card",description:"Surface container with rounded border and optional header (title + description + actions slot).",category:"composite",level:"L2",tags:["card","surface"],props:{title:{type:"string",description:"Card heading"},description:{type:"string",description:"Supporting subtitle text"}},slots:{actions:{description:"Action buttons rendered in the top-right of the card header"},default:{description:"Card body content"}},usageScenarios:["Stats overview section","User profile panel","Settings form container"],constraints:["Avoid nesting Card directly inside another Card"]},Tabs:{name:"Tabs",description:"Tab switcher. Each child maps to the tab at the same index. Supports up to 6 tabs.",category:"composite",level:"L2",tags:["tabs","navigation"],props:{variant:{type:"string",enum:["underline","segmented"]},disabledTabs:{type:"array",items:{type:"integer"}},value:{type:"integer"},tabs:{type:"array",items:{type:"string"},description:"Tab label list, e.g. [Overview, Details, Activity]"},defaultTab:{type:"integer",default:0,description:"0-based index of the initially active tab"}},usageScenarios:["Split view of Overview / Settings / Logs","Mobile-friendly section switcher"],constraints:["Children count must equal tabs array length","Do not use more than 6 tabs"]},Drawer:{name:"Drawer",description:"Off-canvas side panel for secondary context (filters, details, comments). Rendered inline in preview.",category:"composite",level:"L2",tags:["drawer","overlay"],events:{onClose:{description:"Close requested; set controlled open false"}},props:{open:{type:"boolean"},pending:{type:"boolean"},title:{type:"string"}},usageScenarios:["Filter panel for a table","Item detail side sheet"],constraints:["Drawer is always visible in static preview — use conditionally in production via state"]},Modal:{name:"Modal",description:"Centered overlay dialog for focused tasks or confirmations. Rendered inline in preview.",category:"composite",level:"L2",tags:["modal","overlay"],events:{onClose:{description:"Close requested; set controlled open false"}},props:{open:{type:"boolean"},pending:{type:"boolean"},title:{type:"string"},description:{type:"string"}},usageScenarios:["Create / edit form dialog","Image preview lightbox"],constraints:["Modal is always visible in static preview — drive open/close state from actions in production"]},Divider:{name:"Divider",description:"Thin horizontal (default) or vertical separator line.",category:"primitive",level:"L1",tags:["separator"],props:{orientation:{type:"string",enum:["horizontal","vertical"],default:"horizontal"}},usageScenarios:["Visual break between form sections","Vertical separator between two columns"],constraints:[]},PageSiderMenu:{name:"PageSiderMenu",description:"Vertical sidebar navigation. Place MenuLink or MenuGroup blocks as children. Usually placed in the PageLayout sidebar slot.",category:"composite",level:"L2",tags:["sidebar","nav"],props:{title:{type:"string",description:"Section heading above menu items"}},slots:{header:{description:"Workspace switcher or brand above the menu list"},footer:{description:"User card or secondary links below the menu list"}},usageScenarios:["Admin left nav (Dashboard, Users, Settings)","Docs section navigation"],constraints:["Always use as a sibling inside PageLayout sidebar slot; do not place in main content area"]},MenuGroup:{name:"MenuGroup",description:"Labeled group of MenuLink items inside PageSiderMenu.",category:"composite",level:"L2",tags:["sidebar","nav"],props:{title:{type:"string",description:"Group heading shown above the links"}},usageScenarios:["Platform vs Workspace nav groups","Settings section grouping"],constraints:["Must be a direct child of PageSiderMenu"]},MenuLink:{name:"MenuLink",description:"Single navigation item inside a PageSiderMenu. Renders as an anchor with optional icon and badge.",category:"primitive",level:"L1",tags:["nav","link"],props:{label:{type:"string"},href:{type:"string"},icon:{type:"string",description:"Emoji or Unicode glyph"},badge:{type:"string",description:"Count or label shown on the right"},active:{type:"boolean",default:!1}},usageScenarios:["Dashboard menu item","Settings section link with unread badge"],constraints:["Must be a direct child of PageSiderMenu or MenuGroup"]},Link:{name:"Link",description:"Inline hyperlink. Variants: default (blue underline), muted (gray), button (filled CTA), outline (bordered CTA).",category:"primitive",level:"L1",tags:["link"],props:{label:{type:"string"},href:{type:"string"},variant:{type:"string",enum:["default","muted","button","outline"],default:"default"},target:{type:"string",enum:["_self","_blank"],default:"_self"},className:{type:"string",description:"Extra utility classes appended to the variant chrome."}},usageScenarios:["Inline 'Read more' link in a paragraph","CTA button-style link in a hero section"],constraints:[]},Breadcrumb:{name:"Breadcrumb",description:"Hierarchical page path trail. Pass an items array of {label, href?}.",category:"composite",level:"L2",tags:["breadcrumb","nav"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},href:{type:"string"}}},description:"Path segments"}},usageScenarios:["Page location context in an admin CRUD view","Multi-step wizard progress"],constraints:[]},List:{name:"List",description:"Unordered list of child blocks. Use with divided or compact for different visual densities.",category:"composite",level:"L2",tags:["list"],props:{divided:{type:"boolean",default:!1,description:"Add hairline dividers between items"},compact:{type:"boolean",default:!1},label:{type:"string",description:"ARIA label"}},usageScenarios:["Recent activity feed","Search result list"],constraints:[]},Table:{name:"Table",description:"Data grid with typed columns and row data. Columns define keys and display labels.",category:"composite",level:"L2",tags:["table","grid","data"],props:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"},align:{type:"string",enum:["left","center","right"]}}},description:"[{key, label, align?}]"},rows:{type:"array",items:{type:"object"},description:"Array of data objects keyed to column.key"},emptyText:{type:"string",default:"No data"},striped:{type:"boolean",default:!0},caption:{type:"string"}},usageScenarios:["User management list","Order history table","API endpoint catalog"],constraints:["rows entries must have keys matching column.key; missing keys render empty string","Avoid more than 8 columns"]},Stat:{name:"Stat",description:"KPI metric card: large value, label, optional trend arrow, and change string.",category:"primitive",level:"L2",tags:["stat","kpi","metric"],props:{label:{type:"string"},value:{type:"string",description:"Main metric value, e.g. 1,234 or $12k"},change:{type:"string",description:'Change label, e.g. "+12% vs last month"'},trend:{type:"string",enum:["up","down"]},description:{type:"string",description:"Secondary helper text"}},usageScenarios:["Dashboard KPI row (4 Stat blocks side-by-side in a Box[direction=row])","Single revenue metric in a Card"],constraints:["Do not put detailed charts inside a Stat; use Stat only for a single number + context"]},Markdown:{name:"Markdown",description:"Renders Markdown source into HTML. Supports # headings, **bold**, *italic*, `code`, and - lists.",category:"primitive",level:"L1",tags:["text","markdown","content"],props:{content:{type:"string",description:"Markdown source text"}},usageScenarios:["Documentation sections","Feature descriptions on a landing page","Release notes"],constraints:["No HTML injection; only Markdown syntax is parsed"]},Heading:{name:"Heading",description:"Semantic heading tag h1–h6 with size automatically mapped to the level.",category:"primitive",level:"L1",tags:["text","heading","typography"],props:{text:{type:"string"},level:{type:"integer",default:2,description:"1=largest, 6=smallest"},muted:{type:"boolean",default:!1,description:"Render in muted-foreground"}},usageScenarios:["Section title above a Table or Card","Hero headline on a landing page"],constraints:["Use only one h1 per page"]},Paragraph:{name:"Paragraph",description:"Body text block. Use size='lg' for lead copy, size='sm' for captions.",category:"primitive",level:"L1",tags:["text","typography"],props:{text:{type:"string"},size:{type:"string",enum:["sm","md","lg"],default:"md"},muted:{type:"boolean",default:!1}},usageScenarios:["Feature description below a Heading","Helper caption below a form field"],constraints:[]},Form:{name:"Form",description:"Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.",category:"composite",level:"L2",tags:["form","input"],props:{idempotent:{type:"boolean",description:"Emit a stable event.value idempotency key while retrying unchanged form values"},pending:{type:"boolean"},label:{type:"string"},layout:{type:"string",enum:["vertical","horizontal"],default:"vertical"}},events:{onChange:{description:"Bubbled native field changes with { type, name, value, checked }."},onSubmit:{description:"Runs after native submission is prevented.",payload:{type:"object",description:"{ type: 'submit', values: Record<string, value> }"}}},usageScenarios:["Create / edit entity form","Login form","Search filter form"],constraints:["Always include exactly one Form.Submit as the last child","Do not nest forms inside forms"]},"Form.Input":{name:"Form.Input",description:"Single-line text field. Supports text, email, password, number, tel, url, date types.",category:"primitive",level:"L1",tags:["form","input"],props:{name:{type:"string",description:"Field identifier (must be unique in the form)"},label:{type:"string"},type:{type:"string",enum:["text","email","password","number","tel","url","date","search"],default:"text"},placeholder:{type:"string"},helpText:{type:"string"},error:{type:"string"},required:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Email address field in a login form","Search bar with type=search","Price input with type=number"],constraints:["name prop is required and must be unique within the parent Form"]},"Form.Select":{name:"Form.Select",description:"Dropdown select field with an options array [{value, label}].",category:"primitive",level:"L1",tags:["form","select"],props:{name:{type:"string"},label:{type:"string"},options:{type:"array",items:{type:"object",properties:{value:{type:"string"},label:{type:"string"}}},description:"[{value, label}]"},placeholder:{type:"string"},required:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Role selector (Admin/Editor/Viewer)","Status filter dropdown"],constraints:[]},"Form.TextArea":{name:"Form.TextArea",description:"Multi-line text input. Use for descriptions, messages, or any free-form long text.",category:"primitive",level:"L1",tags:["form","textarea"],props:{name:{type:"string"},label:{type:"string"},placeholder:{type:"string"},rows:{type:"integer",default:4},helpText:{type:"string"},required:{type:"boolean",default:!1},value:{type:"string",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value }."}},usageScenarios:["Bio / description field on a profile form","Message body in a contact form"],constraints:[]},"Form.Checkbox":{name:"Form.Checkbox",description:"Single boolean checkbox with optional description beneath the label.",category:"primitive",level:"L1",tags:["form","checkbox"],props:{name:{type:"string"},label:{type:"string"},description:{type:"string"},checked:{type:"boolean",description:"Supports {_bindState: 'path'} for two-way state."}},events:{onChange:{description:"Runs with { type, name, value, checked }."}},usageScenarios:["Terms & conditions consent","Opt-in notification preference"],constraints:[]},"Form.Submit":{name:"Form.Submit",description:"Form submit button. Use variant=destructive for irreversible actions.",category:"primitive",level:"L1",tags:["form","button"],props:{label:{type:"string",default:"Submit"},variant:{type:"string",enum:["default","destructive","outline","ghost"],default:"default"},full:{type:"boolean",default:!1}},events:{onClick:{description:"Runs with a plain click payload before the parent form submits."}},usageScenarios:["Save button at the bottom of a form","Delete action with variant=destructive"],constraints:["Must be inside a Form block"]},Button:{name:"Button",description:"Standalone action button. Six visual variants and five sizes. Does not submit forms — use Form.Submit for that.",category:"primitive",level:"L1",tags:["button","action"],props:{label:{type:"string"},variant:{type:"string",enum:["default","destructive","outline","secondary","ghost","link"],default:"default"},size:{type:"string",enum:["xs","sm","default","lg","icon"],default:"default"},full:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1}},events:{onClick:{description:"Runs with a plain click payload."}},usageScenarios:["Primary CTA on a hero section","Row of outline action buttons in a Card actions slot","Ghost icon button in a toolbar"],constraints:["Use Form.Submit, not Button[type=submit], inside a Form","Do not place more than 3 primary (default) buttons on the same view"]},Toast:{name:"Toast",description:"Alert banner (info, success, warning, error); placement top-right floats it as a dismissible corner notice.",category:"primitive",level:"L1",tags:["toast","alert","notification"],props:{message:{type:"string"},title:{type:"string"},level:{type:"string",enum:["info","success","warning","error"],default:"info"},closeable:{type:"boolean",default:!0},placement:{type:"string",enum:["inline","top-right"],default:"inline"},duration:{type:"number",description:"Auto-dismiss after ms"}},usageScenarios:["Success message after form submit","Sample-data notice (top-right)"],constraints:["Keep floating notices to a title and one or two short lines"]},Dialog:{name:"Dialog",description:"Confirmation dialog with title, description, and optional cancel/confirm buttons. Rendered inline in preview.",category:"composite",level:"L2",tags:["dialog","modal","confirm"],props:{title:{type:"string"},description:{type:"string"},cancelLabel:{type:"string"},confirmLabel:{type:"string"},confirmVariant:{type:"string",enum:["default","destructive","outline"],default:"default"}},usageScenarios:["Delete confirmation prompt","Unsaved changes warning before navigation"],constraints:["Dialog is always visible in static preview — drive open/close state via actions in production"]},PanelHeader:{name:"PanelHeader",description:"Section title with optional eyebrow, description and an `actions` slot for buttons or links.",category:"primitive",level:"L1",tags:["header","section","title"],props:{eyebrow:{type:"string"},title:{type:"string"},description:{type:"string"}},slots:{actions:{description:"Buttons or links aligned to the right of the title"}},usageScenarios:["Title and helper text above a table","Panel header with a Refresh button"],constraints:["Use Heading for in-flow headings that need an explicit level"]},EmptyState:{name:"EmptyState",description:"Empty or recoverable status panel (role=status) with title, message and an optional action button.",category:"primitive",level:"L1",tags:["empty","status","placeholder"],props:{title:{type:"string"},message:{type:"string"},description:{type:"string",description:"Alias of message"},actionLabel:{type:"string",description:"Renders an action button when set"}},events:{onClick:{description:"Action button click; onAction is accepted as an alias."}},usageScenarios:["No results after filtering, with a Clear filters action"],constraints:["Use Alert for errors that need immediate attention"]},FactList:{name:"FactList",description:"Key/value fact list (dl). Pass `items` or FactRow children. Not a KPI card; use StatCard for metrics.",category:"composite",level:"L1",tags:["facts","key-value","details"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},code:{type:"boolean"},href:{type:"string"},hrefSection:{type:"string"}}}}},usageScenarios:["Provider detail: base URL, model, revision"],constraints:["Items render as plain rows or links; use FactRow children for onClick"]},FactRow:{name:"FactRow",description:"One fact row inside FactList. `code` renders the value monospaced; `href` / `hrefSection` (-> #section) render a link; onClick makes the value a button.",category:"primitive",level:"L1",tags:["facts","key-value"],props:{label:{type:"string"},value:{type:"string"},code:{type:"boolean",default:!1},href:{type:"string"},hrefSection:{type:"string"}},events:{onClick:{description:"Runs with a plain click payload."}},constraints:["Place inside FactList"]},Alert:{name:"Alert",description:"Inline alert with icon, title and description. destructive uses role=alert; other variants role=status. Status is conveyed by icon and hidden label text, not colour alone.",category:"primitive",level:"L1",tags:["alert","notice","feedback"],props:{variant:{type:"string",enum:["default","destructive","warning","success"],default:"default"},title:{type:"string"},description:{type:"string"},message:{type:"string",description:"Alias of description"}},usageScenarios:["Guardrail notice","Save succeeded","Request failed"]},Badge:{name:"Badge",description:"Small status label. Text is the status; colour is only reinforcement. Children or `label` provide the text.",category:"primitive",level:"L1",tags:["badge","status","label"],props:{variant:{type:"string",enum:["default","secondary","outline","success","warning","destructive"],default:"default"},label:{type:"string"}},usageScenarios:["Provider state: Active / Disabled","Row status in a table"]},Switch:{name:"Switch",description:"Controlled boolean switch (role=switch) with accessible label. Supports _bindState on checked; onChange carries event.checked.",category:"primitive",level:"L1",tags:["switch","toggle","form"],props:{label:{type:"string"},checked:{type:"boolean",default:!1},disabled:{type:"boolean",default:!1}},events:{onChange:{description:"Runs with { type: 'change', checked }"}},usageScenarios:["Enable or disable a provider","Feature flag toggle"],constraints:["Always set label so the control has an accessible name"]},Skeleton:{name:"Skeleton",description:"Animated loading placeholder. Three presets: lines (text), card (avatar + lines), table (header + rows).",category:"primitive",level:"L1",tags:["skeleton","loading","placeholder"],props:{lines:{type:"integer",default:3,description:"Number of skeleton rows (for lines and table types)"},type:{type:"string",enum:["lines","card","table"],default:"lines"}},usageScenarios:["Loading state while fetching table data","Card placeholder during profile load"],constraints:["Replace with real content once data loads; do not keep Skeleton visible indefinitely"]}};var Jt={Grid:{name:"Grid",description:"Declarative grid layout. Maps cols/gap/responsive props to Tailwind grid classes; children become grid cells directly.",category:"primitive",level:"L1",tags:["layout","grid","container"],props:{cols:{enum:["1","2","3","4","5","6","auto",1,2,3,4,5,6],default:"auto",description:"Column count, or 'auto' for auto-fit minmax(220px,1fr)"},gap:{type:"string",enum:["none","xs","sm","md","lg","xl"],default:"md"},responsive:{type:"boolean",default:!1,description:"Use a mobile-first ladder (grid-cols-1 → sm:2 → lg:N) instead of a fixed column count"},align:{type:"string",enum:["start","center","end","stretch"]},justify:{type:"string",enum:["start","center","end","between","around"]}},usageScenarios:["4-up Stat dashboard row (cols=4)","Responsive card gallery (cols=3, responsive=true)","Two-column form layout (cols=2)"],constraints:["Grid children become grid cells directly; do not wrap each child in a Box","Use cols='auto' when the number of children is dynamic"]},StatGrid:{name:"StatGrid",description:"Responsive grid of KPI cards. Prefers child Stat blocks; falls back to inline rendering of an items array when there are no children.",category:"composite",level:"L2",tags:["stat","kpi","dashboard","grid"],props:{cols:{type:"string",enum:["1","2","3","4","auto"],default:"auto"},items:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},change:{type:"string"},trend:{type:"string",enum:["up","down"]},description:{type:"string"}}},description:"Inline KPI items used when no Stat children are provided"}},usageScenarios:["Overview dashboard KPI row","Operations metrics summary above a table"],constraints:["Provide either Stat children or items, not both — children win when present"]},TrendChart:{name:"TrendChart",description:"Pure-SVG line / area chart with no third-party dependency. Draws one polyline per series on a shared vertical scale. Alias: LineChart.",category:"composite",level:"L2",tags:["chart","trend","line","svg"],props:{title:{type:"string"},series:{type:"array",items:{type:"object",properties:{name:{type:"string"},points:{type:"array",items:{type:"number"}},area:{type:"boolean",default:!1}}},description:"[{name, points:number[], area?}]"},labels:{type:"array",items:{type:"string"},description:"Optional x-axis labels"},width:{type:"integer",default:480},height:{type:"integer",default:160}},usageScenarios:["Evolution score trend over versions","Daily active users line chart"],constraints:["Keep each series under ~200 points; larger inputs produce heavy SVG DOM"]},LineChart:{name:"LineChart",description:"Alias of TrendChart — pure-SVG multi-series line / area chart.",category:"composite",level:"L2",tags:["chart","line","svg"],props:{title:{type:"string"},series:{type:"array",items:{type:"object",properties:{name:{type:"string"},points:{type:"array",items:{type:"number"}},area:{type:"boolean"}}}},width:{type:"integer",default:480},height:{type:"integer",default:160}},usageScenarios:["Same as TrendChart; use whichever name reads better in the spec"],constraints:["Identical implementation to TrendChart"]},KanbanBoard:{name:"KanbanBoard",description:"Horizontal kanban board: columns as swimlanes, cards grouped by their column id. Read-only display.",category:"composite",level:"L3",tags:["kanban","board","operations"],props:{columns:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"}}},description:"[{id, title}] swimlane definitions"},cards:{type:"array",items:{type:"object",properties:{id:{type:"string"},column:{type:"string"},title:{type:"string"},subtitle:{type:"string"},badge:{type:"string"}}},description:"[{id, column, title, subtitle?, badge?}] — column must match a column id"}},usageScenarios:["Operations task board (Todo / In progress / Done)","Release pipeline stages"],constraints:["Each card.column must reference an existing column.id, else the card is dropped","Up to 4 columns fit the container as an equal-width grid (no scrollbar); 5+ columns switch to a horizontal scroll strip"]},Matrix:{name:"Matrix",description:"Two-dimensional intensity grid (heatmap). Cell intensities are 0..1 and map to a color-mix of the primary token via inline style. Alias: Heatmap.",category:"composite",level:"L3",tags:["matrix","heatmap","grid","governance"],props:{caption:{type:"string"},rows:{type:"array",items:{type:"string"},description:"Row labels"},cols:{type:"array",items:{type:"string"},description:"Column labels"},cells:{type:"array",items:{type:"array",items:{type:"number"}},description:"rows×cols grid of intensities in [0,1]"},showValues:{type:"boolean",default:!1,description:"Print the numeric value in each cell"}},usageScenarios:["Governance capability coverage matrix","Risk heatmap (likelihood × impact)"],constraints:["Intensities are single-polar 0..1; negative / diverging scales are not supported","cells should be rows.length × cols.length; missing cells render as 0"]},Heatmap:{name:"Heatmap",description:"Alias of Matrix — two-dimensional 0..1 intensity grid.",category:"composite",level:"L3",tags:["heatmap","matrix","grid"],props:{caption:{type:"string"},rows:{type:"array",items:{type:"string"}},cols:{type:"array",items:{type:"string"}},cells:{type:"array",items:{type:"array",items:{type:"number"}}},showValues:{type:"boolean",default:!1}},usageScenarios:["Same as Matrix"],constraints:["Identical implementation to Matrix"]},DiagnosticsList:{name:"DiagnosticsList",description:"Levelled diagnostics list with a coloured left bar and glyph per severity (info / warn / error).",category:"composite",level:"L2",tags:["diagnostics","list","status","overview"],props:{items:{type:"array",items:{type:"object",properties:{level:{type:"string",enum:["info","warn","error"]},title:{type:"string"},detail:{type:"string"}}},description:"[{level, title, detail?}]"}},usageScenarios:["Overview page diagnostics slot","Spec validation results list"],constraints:["level defaults to 'info' when omitted or unrecognised"]},TimelineList:{name:"TimelineList",description:"Vertical timeline with a left rail and a status dot per item (ok / warn / error).",category:"composite",level:"L2",tags:["timeline","activity","operations"],props:{items:{type:"array",items:{type:"object",properties:{time:{type:"string"},title:{type:"string"},desc:{type:"string"},status:{type:"string",enum:["ok","warn","error"]}}},description:"[{time, title, desc?, status?}]"}},usageScenarios:["Operations event timeline","Deployment / audit history"],constraints:["status defaults to 'ok' when omitted"]},SearchableTable:{name:"SearchableTable",description:"Table with a built-in search box. Typing dispatches SetState onto searchKey and filters the resolved rows (case-insensitive substring across all columns).",category:"feature",level:"L3",tags:["table","search","interactive","data"],props:{columns:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"},align:{type:"string",enum:["left","center","right"]}}}},rows:{type:"array",items:{type:"object"},description:"Row objects keyed to column.key"},searchKey:{type:"string",default:"search",description:"State path the search query writes to"},placeholder:{type:"string",default:"Search…"},emptyText:{type:"string",default:"No matching rows",description:"Copy shown when the filtered row set is empty"}},usageScenarios:["Searchable plugins / catalog list in studio","User management table with live filtering"],constraints:["Requires a live host (dispatch) for the search box to update host state; client-side filtering still works on already-resolved rows"]},SplitMasterDetail:{name:"SplitMasterDetail",description:"Master/detail split: a selectable left list and a right detail pane. Clicking an item dispatches SetState onto selectKey; the detail slot (or children) renders the right pane.",category:"feature",level:"L3",tags:["split","master-detail","interactive","layout"],props:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"},subtitle:{type:"string"}}},description:"[{id, title, subtitle?}] left-list entries"},selectKey:{type:"string",default:"selectedId",description:"State path the selected id writes to"}},slots:{detail:{description:"Right-pane content; usually host-composed from the selected item via _find"}},usageScenarios:["Skills list → skill detail","Agents directory → agent inspector"],constraints:["Selection defaults to the first item's id until the host updates selectKey"]},DetailField:{name:"DetailField",description:"Label + value display row, for use inside a detail pane.",category:"primitive",level:"L1",tags:["detail","field","display"],props:{label:{type:"string"},value:{type:"string",description:"Any scalar; rendered as '—' when empty"},inline:{type:"boolean",default:!1,description:"Render label and value on one line"}},usageScenarios:["Field row inside a SplitMasterDetail detail pane","Read-only record summary"],constraints:["Use for scalar values; for structured data prefer KeyValueGrid"]},BadgeGroup:{name:"BadgeGroup",description:"Horizontal group of status badges. Items may be plain strings or {label, tone}.",category:"composite",level:"L1",tags:["badge","status","tags"],props:{items:{type:"array",items:{type:"object",properties:{label:{type:"string"},tone:{type:"string",enum:["default","success","warning","error","info"]}}},description:"Array of strings or [{label, tone?}]"}},usageScenarios:["Status / tag chips on a list row","Capability flags on an agent card"],constraints:["tone defaults to 'default' when omitted or unrecognised"]},KeyValueGrid:{name:"KeyValueGrid",description:"Compact key/value grid for metadata. Accepts an items array or a plain record object.",category:"composite",level:"L1",tags:["key-value","metadata","grid","display"],props:{items:{type:"array",items:{type:"object",properties:{key:{type:"string"},value:{type:"string"}}},description:"[{key, value}] pairs (or pass a plain object as `data`)"},cols:{enum:["1","2","3",1,2,3],default:"2"}},usageScenarios:["Model metadata panel (provider, context, pricing)","Request / response header summary"],constraints:["Values are stringified for display; pass pre-formatted strings for control"]},Hero:{name:"Hero",description:"Asymmetric editorial hero: serif display title (with optional italic emphasis word), mono eyebrow with amber dot, warm radial-glow + blueprint dot-grid backdrop, grain overlay, staggered reveal, and primary/secondary CTAs. An optional right-side visual renders via the `aside` slot or children.",category:"presentation",level:"L3",tags:["hero","marketing","landing","editorial"],props:{eyebrow:{type:"string",description:"Mono uppercase kicker above the title"},title:{type:"string",description:"Serif display headline"},titleEmphasis:{type:"string",description:"Optional trailing word rendered italic + amber for emphasis"},subtitle:{type:"string",description:"Supporting lead paragraph"},primaryCta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"},secondaryCta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — outline button"},note:{type:"string",description:"Small mono note under the CTAs"}},slots:{aside:{description:"Right-pane visual (e.g. a rendered spec preview); hidden on mobile"}},usageScenarios:["Studio landing-page hero introducing 'AI writes the spec, the platform renders the UI'","Product launch hero with a spec snippet preview on the right"],constraints:["CTA props are {label, href}; href defaults to '#' when omitted","Use titleEmphasis for a single emphasis word, not the whole title"]},BrowserFrame:{name:"BrowserFrame",description:"Product-screenshot window shell: frames its `content` slot (or children) in a precise browser/app chrome — three traffic-light dots + a mono title/address bar — with a hairline border, long soft shadow, and an optional 3D tilt. Used to present a live-rendered UI as a product-shot visual (dogfood) instead of a static screenshot.",category:"presentation",level:"L2",tags:["frame","browser","window","screenshot","marketing"],props:{title:{type:"string",description:"Address/title shown in the window chrome (defaults to 'app.uibot.studio')"},variant:{type:"string",enum:["flat","tilt"],default:"flat",description:"'tilt' adds a subtle 3D perspective tilt for a product-shot feel"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the chrome address bar wash (0 amber · 1 teal · 2 rose · 3 indigo)"}},slots:{content:{description:"The UI rendered inside the frame; usually a real dashboard composed from data blocks"}},usageScenarios:["Hero visual framing a live-rendered mini dashboard as the product shot","Showcase row of small frames each rendering a different UI from the same engine"],constraints:["Frames the `content` slot, falling back to children; supply real spec blocks to render a live UI","Decorative chrome only — it does not add browser behaviour (no real address bar)"]},SectionHeader:{name:"SectionHeader",description:"Editorial section header: oversized mono section number (e.g. '01'), mono eyebrow, serif title, and a lead paragraph. Sets the rhythm between page sections.",category:"presentation",level:"L2",tags:["section","header","marketing","editorial"],props:{sectionNo:{type:"string",description:"Oversized mono numeral, e.g. '01'"},eyebrow:{type:"string",description:"Mono uppercase kicker"},title:{type:"string",description:"Serif section title"},lead:{type:"string",description:"Lead / intro paragraph"}},usageScenarios:["Numbered section dividers on a landing page (01 Features, 02 How it works)","Editorial chapter header above a FeatureGrid"],constraints:["sectionNo is display text; any string works (e.g. '01', 'A', '§1')"]},FeatureGrid:{name:"FeatureGrid",description:"Responsive grid of hairline feature cards with hover lift. Renders an `items` array (icon name + title + desc) into FeatureCards, or lays out FeatureCard children directly.",category:"presentation",level:"L2",tags:["features","grid","cards","marketing"],props:{cols:{type:"string",enum:["2","3","4"],default:"3"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string",description:"lucide icon name (sparkles, zap, layers, code, cpu, workflow, gauge, shield, wand, boxes)"},title:{type:"string"},desc:{type:"string"}}},description:"[{icon, title, desc}] feature entries"}},usageScenarios:["Three-up feature highlights under a SectionHeader","Capability grid (declarative spec, gap recovery, plugin catalog)"],constraints:["icon is a lucide name mapped to a built-in inline SVG; unknown names fall back to a dot","Provide either items or FeatureCard children — children win when present"]},FeatureCard:{name:"FeatureCard",description:"Single hairline feature card: inline-SVG icon, serif title, body copy, and optional children. Designed to sit inside a FeatureGrid but works standalone.",category:"presentation",level:"L1",tags:["feature","card","marketing"],props:{icon:{type:"string",description:"lucide icon name (see FeatureGrid)"},title:{type:"string"},desc:{type:"string"}},usageScenarios:["A single emphasised feature beside a screenshot","Composed children inside a FeatureGrid for custom card bodies"],constraints:["icon resolves against the built-in inline-SVG set; unknown → dot fallback"]},CodeShowcase:{name:"CodeShowcase",description:"Mono code panel with window chrome (three dots) and line numbers, used to showcase a UIBot YAML/JSON spec. Pure CSS, no syntax-highlighter dependency.",category:"presentation",level:"L2",tags:["code","spec","showcase","marketing"],props:{title:{type:"string",description:"Filename / label shown in the window chrome"},code:{type:"string",description:"Raw code string; newline-separated, rendered with line numbers"},caption:{type:"string",description:"Caption under the panel"}},usageScenarios:["Show an example UIBot YAML spec on the landing page","Before/after spec snippet in a docs section"],constraints:["code is plain text rendered verbatim with line numbers; no highlighting/escaping beyond React's default"]},CtaBand:{name:"CtaBand",description:"Inverted ink-black call-to-action band with grain overlay and a single amber CTA. Closes a landing page with high contrast.",category:"presentation",level:"L2",tags:["cta","band","marketing","conversion"],props:{title:{type:"string",description:"Serif headline"},subtitle:{type:"string",description:"Supporting line"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"}},usageScenarios:["Final 'Start building' band at the bottom of the landing page","Newsletter / docs CTA between sections"],constraints:["Single CTA by design; cta.href defaults to '#' when omitted"]},Faq:{name:"Faq",description:"Editorial accordion FAQ built on native <details>/<summary> — fully functional with zero JS / state wiring. Optional eyebrow/title/lead header; rows carry a mono index numeral, a hairline plus-mark that rotates 45° into a close-mark on open, and a grid-rows expand transition.",category:"presentation",level:"L2",tags:["faq","accordion","marketing","content"],props:{eyebrow:{type:"string",description:"Optional mono overline above the title (accent colored)"},title:{type:"string",description:"Optional serif heading above the list"},lead:{type:"string",description:"Optional muted intro line under the title"},defaultOpenFirst:{type:"boolean",description:"When true, the first row renders open on mount"},items:{type:"array",items:{type:"object",properties:{q:{type:"string"},a:{type:"string"}}},description:"[{q, a}] question/answer pairs; rows with an empty q are dropped"}},usageScenarios:["Pricing / product FAQ section on a landing page","Docs 'common questions' block"],constraints:["Uses native <details> so multiple rows can be open at once; no single-open behaviour","Answers render as plain text; pass pre-formatted strings"]},TeamGrid:{name:"TeamGrid",description:"Grid of team-member cards. Each shows an avatar (image when `avatar` is a URL, otherwise tinted initials), name, mono role and optional bio. Hairline cards with hover lift.",category:"presentation",level:"L2",tags:["team","people","grid","marketing"],props:{columns:{type:"string",enum:["2","3","4"],default:"3"},members:{type:"array",items:{type:"object",properties:{name:{type:"string"},role:{type:"string"},bio:{type:"string"},avatar:{type:"string",description:"Image URL, or short text/emoji shown as the avatar; falls back to initials"}}},description:"[{name, role?, bio?, avatar?}] — members with an empty name are dropped"}},usageScenarios:["About page 'meet the team' grid","Advisors / contributors showcase"],constraints:["avatar is treated as an image when it looks like a URL (http(s):/data:/leading slash); otherwise rendered as text","Initials are derived from the name when no avatar is given"]},Steps:{name:"Steps",description:"'How it works' steps with oversized mono numerals. variant 'numbered' (default) is a responsive card row; variant 'connected' is a vertical rail with a connecting line between numbered dots.",category:"presentation",level:"L2",tags:["steps","how-it-works","process","marketing"],props:{variant:{type:"string",enum:["numbered","connected"],default:"numbered",description:"'numbered' = card row with big numerals; 'connected' = vertical rail with a line"},steps:{type:"array",items:{type:"object",properties:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"Optional lucide icon name; replaces the numeral in the 'connected' dot"}}},description:"[{title, desc?, icon?}] in sequence order; steps with an empty title are dropped"}},usageScenarios:["Three-step onboarding ('Describe → Generate → Render')","Connected setup sequence in docs"],constraints:["Numbering is automatic (01, 02, …) from array order","icon only affects the 'connected' variant's dot; the numbered variant always shows the numeral","Numbered variant derives its column count from the step count (clamped 2–4), so 4 steps fill one row"]},BentoGrid:{name:"BentoGrid",description:"Asymmetric bento layout. Lays BentoCell children, or an `items` array, onto a CSS grid whose base column count is `cols`; cells opt into col/row spans to break the rhythm into a mixed-size mosaic. Hairline cards, per-cell accent tone.",category:"presentation",level:"L3",tags:["bento","grid","layout","marketing"],props:{cols:{type:"string",enum:["2","3","4","6"],default:"3",description:"Base column count of the grid (cells may span fewer/more)"},gap:{type:"string",enum:["none","sm","md","lg"],default:"md"},items:{type:"array",items:{type:"object",properties:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"lucide icon name"},tone:{type:"integer",description:"Accent-hue index 0–3 (amber/teal/rose/indigo)"},span:{type:"object",properties:{col:{type:"integer"},row:{type:"integer"}},description:"Cell span; col 1–4, row 1–3"}}},description:"Inline cells used when no BentoCell children are provided"}},usageScenarios:["Feature mosaic where one tile is hero-sized (span col 2) and the rest are small","Capability bento mixing tall and wide tiles"],constraints:["Provide either BentoCell children or items — children win when present","span.col is clamped to 1–4 and span.row to 1–3 via static class maps (no purge risk)"]},BentoCell:{name:"BentoCell",description:"A single bento tile, usable standalone inside a BentoGrid. Reads span.col / span.row and maps them to static span classes so the cell can be as wide/tall as the mosaic needs. Optional icon/title/desc plus composed children.",category:"presentation",level:"L1",tags:["bento","cell","card","marketing"],props:{title:{type:"string"},desc:{type:"string"},icon:{type:"string",description:"lucide icon name"},tone:{type:"integer",description:"Accent-hue index 0–3 (amber/teal/rose/indigo)"},span:{type:"object",properties:{col:{type:"integer"},row:{type:"integer"}},description:"{col?, row?} — col clamped 1–4, row clamped 1–3"}},usageScenarios:["A hero tile (span col 2, row 2) holding a rendered preview inside a BentoGrid","Custom-bodied bento tile composed from child blocks"],constraints:["Spans are clamped 1–4 (col) / 1–3 (row) and emitted as static classes","Designed to sit inside a BentoGrid; standalone it renders as a lone card"]},Callout:{name:"Callout",description:"Emphasis callout panel: a tinted box (semantic or brand colour) with an icon, optional title and body. color-mix against the chosen token keeps the wash subtle and legible in light and dark.",category:"presentation",level:"L1",tags:["callout","note","alert","marketing"],props:{variant:{type:"string",enum:["info","success","warn","accent"],default:"info",description:"Colour/role: info (indigo) · success (green) · warn (amber) · accent (brand amber)"},title:{type:"string",description:"Emphasised lead line, coloured to the variant"},body:{type:"string",description:"Supporting paragraph"},icon:{type:"string",description:"Optional lucide icon name; defaults to a sensible glyph per variant"}},usageScenarios:["Inline 'Note' / 'Tip' block inside docs or a landing section","Success confirmation or warning banner above content"],constraints:["variant falls back to 'info' when omitted or unrecognised","icon defaults per variant (info→info, success→check, warn→alert, accent→sparkles)"]},PricingTable:{name:"PricingTable",description:"Responsive 2–4 column pricing grid of hairline cards. The `highlighted` plan gets an amber border + 'Popular' badge + solid amber CTA; others use an outline CTA. Features list with amber check glyphs. CTAs are {label, href} anchors.",category:"presentation",level:"L3",tags:["pricing","plans","marketing","conversion"],props:{plans:{type:"array",items:{type:"object",properties:{name:{type:"string"},price:{type:"string",description:"Display price, e.g. '$29' or 'Free'"},period:{type:"string",description:"Billing period suffix, e.g. '/mo'"},description:{type:"string",description:"Short plan summary line"},features:{type:"array",items:{type:"string"},description:"Bullet feature list"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber when highlighted, else outline"},highlighted:{type:"boolean",default:!1,description:"Mark the featured/popular plan"}}},description:"[{name, price, period?, description?, features[], cta{label,href}, highlighted?}]"},billingNote:{type:"string",description:"Mono note under the grid, e.g. 'Billed annually · cancel anytime'"}},usageScenarios:["Three-tier SaaS pricing section (Starter / Pro / Enterprise)","Two-up free-vs-paid comparison with a highlighted paid plan"],constraints:["Column count is derived from plans.length, clamped to 2–4","CTA props are {label, href}; href defaults to '#'","Mark at most one plan highlighted for a clear focal point"]},Testimonials:{name:"Testimonials",description:"Grid of testimonial cards (hairline `.mkt-card`, hover lift): optional star rating, serif italic pull-quote, and an initials avatar token + author + role. `columns` (1–3) controls the grid; avatar tints cycle the four accents.",category:"presentation",level:"L2",tags:["testimonials","social-proof","marketing","quotes"],props:{items:{type:"array",items:{type:"object",properties:{quote:{type:"string"},author:{type:"string"},role:{type:"string",description:"Author title / company"},avatar:{type:"string",description:"Explicit avatar token; defaults to author initials"},rating:{type:"integer",description:"Optional 1–5 star rating"}}},description:"[{quote, author, role?, avatar?, rating?}]"},columns:{type:"string",enum:["1","2","3"],description:"Grid column count (defaults from item count)"}},usageScenarios:["Three-up customer quote wall under a SectionHeader","Single highlighted testimonial beside a feature"],constraints:["avatar defaults to first-letter initials of author; no external images","rating is clamped to 0–5 and omitted when absent"]},LogoCloud:{name:"LogoCloud",description:"A single grayscale 'trusted by' logo strip. With no external images each logo is a mono wordmark (initials for long names); the row is dimmed/desaturated and lifts to full foreground on hover. Optional mono `label` above the row.",category:"presentation",level:"L1",tags:["logos","social-proof","marketing","brands"],props:{label:{type:"string",description:"Eyebrow above the row, e.g. 'Trusted by teams at'"},logos:{type:"array",items:{type:"object",properties:{name:{type:"string"}}},description:"Array of strings or [{name}] — rendered as mono wordmarks/initials"}},usageScenarios:["Logo strip directly under the hero for social proof","Press/partner row between sections"],constraints:["Text-only wordmarks — no external logo images are loaded","Names longer than 14 chars collapse to initials"]},StatBand:{name:"StatBand",description:"Big-number statistics band: oversized serif values with mono labels, divided by hairline rules. `tone` switches the surface — plain, muted (soft card panel) or inverse (ink-black panel with warm amber→rose glow + grain).",category:"presentation",level:"L2",tags:["stats","metrics","marketing","band"],props:{stats:{type:"array",items:{type:"object",properties:{value:{type:"string",description:"Big display value, e.g. '99.9%' or '12k+'"},label:{type:"string"},sub:{type:"string",description:"Optional sub-label under the metric"}}},description:"[{value, label, sub?}]"},tone:{type:"string",enum:["plain","muted","inverse"],default:"plain",description:"Surface treatment: plain (transparent) · muted (card panel) · inverse (ink-black glow panel)"}},usageScenarios:["Four-up headline metrics band (uptime / users / latency / saved)","Inverse-tone impact band between marketing sections"],constraints:["Column count derives from stats.length, clamped to 1–4","Values are display strings; pre-format numbers/units yourself"]},Newsletter:{name:"Newsletter",description:"Email-capture band: serif title + supporting line, then a token-styled email input beside a CTA anchor. Presentational — the input is decorative and the CTA navigates via {label, href}; wire real submission at the host.",category:"presentation",level:"L2",tags:["newsletter","subscribe","marketing","email"],props:{title:{type:"string",description:"Serif headline"},subtitle:{type:"string",description:"Supporting line under the title"},placeholder:{type:"string",default:"you@example.com",description:"Email input placeholder"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber submit button (defaults to 'Subscribe' / '#')"}},usageScenarios:["End-of-page 'Stay in the loop' email signup","Docs/blog newsletter band between content sections"],constraints:["Input is decorative; the form action points at cta.href — handle real submission upstream","Single email field + single CTA by design"]},Banner:{name:"Banner",description:"Slim full-width announcement bar: optional icon + message, an inline CTA link and a decorative dismiss '×'. `tone` picks one of the four brand accents; `solid` fills the strip with the accent instead of a soft tint.",category:"presentation",level:"L1",tags:["banner","announcement","marketing","notice"],props:{message:{type:"string",description:"Announcement text"},icon:{type:"string",description:"lucide icon name (defaults to 'sparkles')"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index (0 amber · 1 teal · 2 rose · 3 indigo)"},solid:{type:"boolean",default:!1,description:"Fill the strip with the accent colour"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — inline mono link on the right"},dismissible:{type:"boolean",default:!0,description:"Show the decorative × (presentational only)"}},usageScenarios:["Top-of-page launch/announcement strip above the hero","Soft-tint 'new docs available' notice between sections"],constraints:["The dismiss × is decorative — wire real dismissal at the host","tone is 0–3; CTA href defaults to '#'"]},FeatureSplit:{name:"FeatureSplit",description:"Alternating two-column feature section: an editorial text column (eyebrow, serif title, body, bulleted benefits, optional CTA) beside a visual column. The visual renders the `visual` slot (or children) — e.g. a BrowserFrame — falling back to a tinted blueprint placeholder. `reverse` flips the column order for an alternating page rhythm.",category:"presentation",level:"L3",tags:["feature","split","two-column","marketing"],props:{eyebrow:{type:"string",description:"Mono uppercase kicker"},title:{type:"string",description:"Serif feature title"},body:{type:"string",description:"Supporting paragraph"},bullets:{type:"array",items:{type:"object",properties:{icon:{type:"string"},text:{type:"string"}}},description:"Array of strings or [{icon?, text}] benefit rows"},cta:{type:"object",properties:{label:{type:"string"},href:{type:"string"}},description:"{label, href} — solid amber button"},reverse:{type:"boolean",default:!1,description:"Place the visual on the left"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the bullet chips / placeholder"}},slots:{visual:{description:"Right-pane visual (BrowserFrame, rendered preview, image); falls back to children then a placeholder"}},usageScenarios:["Alternating feature rows down a landing page (reverse every other)","Text + live BrowserFrame preview feature block"],constraints:["Provide a visual slot/children for the right pane; otherwise a tinted placeholder renders","bullets accept strings or {icon?, text}; CTA href defaults to '#'"]},ComparisonTable:{name:"ComparisonTable",description:"Feature comparison table across products/plans. The header lists columns (a `highlighted` column gets an amber-washed spine); each row pairs a feature label with one value per column — booleans render as amber check / muted cross glyphs, strings render verbatim. Horizontally scrollable on small screens.",category:"presentation",level:"L3",tags:["comparison","table","pricing","marketing"],props:{featureLabel:{type:"string",description:"Header label for the feature column (often blank)"},columns:{type:"array",items:{type:"object",properties:{name:{type:"string"},highlighted:{type:"boolean"}}},description:"Array of strings or [{name, highlighted?}] — column headers"},rows:{type:"array",items:{type:"object",properties:{feature:{type:"string"},values:{type:"array",items:{},description:"One value per column (boolean → ✓/✗, string → verbatim)"}}},description:"[{feature, values[]}] — values align positionally with columns"}},usageScenarios:["Plan feature comparison (Free / Pro / Enterprise) with a highlighted column","Product-vs-competitor capability matrix"],constraints:["values align by index with columns; missing/falsey values render as a muted cross","Booleans (or 'yes'/'no'/'true'/'false') become glyphs; other strings render verbatim"]},Roadmap:{name:"Roadmap",description:"Product roadmap / milestone timeline. A vertical rail with one node per milestone; node state drives the dot — a filled amber check for 'done', an amber ring + rocket for 'active', an outline flag for 'planned'. A marketing roadmap (distinct from the operational TimelineList activity log).",category:"presentation",level:"L2",tags:["roadmap","milestones","timeline","marketing"],props:{milestones:{type:"array",items:{type:"object",properties:{date:{type:"string",description:"Quarter/date label, e.g. 'Q3 2026'"},title:{type:"string"},desc:{type:"string"},state:{type:"string",enum:["done","active","planned"]}}},description:"[{date?, title, desc?, state?}] in sequence order"}},usageScenarios:["Public product roadmap section (shipped / in progress / planned)","Launch sequence with dated milestones"],constraints:["state defaults to 'planned' when omitted or unrecognised","milestones with an empty title are dropped"]},StatHighlight:{name:"StatHighlight",description:"Single big-number spotlight: an oversized serif value with an optional trend delta (up = amber, down = rose), a mono label and supporting copy. Draws the eye to one headline metric (distinct from StatBand's multi-stat row).",category:"presentation",level:"L1",tags:["stat","metric","highlight","marketing"],props:{value:{type:"string",description:"Big display value, e.g. '99.9%' or '12k+'"},label:{type:"string",description:"Mono uppercase label under the value"},body:{type:"string",description:"Supporting paragraph"},delta:{type:"string",description:"Trend delta pill text, e.g. '+12%'"},trend:{type:"string",enum:["up","down"],default:"up",description:"Delta direction: up (amber, arrow up) or down (rose, arrow down)"}},usageScenarios:["Centered headline metric between two content sections","Single KPI spotlight with a growth delta"],constraints:["Values/deltas are display strings; pre-format numbers/units yourself","trend only affects the delta pill colour/arrow; omit delta to hide the pill"]},IconList:{name:"IconList",description:"Benefit / checklist list with icons. Each item shows a tinted icon chip, a title and optional supporting line, laid into a 1–3 column grid; tints cycle the four accents. Lighter-weight than FeatureGrid (no card material) — for inline benefit/checklist runs.",category:"presentation",level:"L1",tags:["benefits","checklist","list","marketing"],props:{columns:{type:"string",enum:["1","2","3"],default:"2"},icon:{type:"string",description:"Default lucide icon for items without their own (defaults to 'check')"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string"},title:{type:"string"},desc:{type:"string"}}},description:"Array of strings or [{icon?, title, desc?}]"}},usageScenarios:["Two-column 'what's included' benefit list","Checklist of capabilities under a SectionHeader"],constraints:["items accept plain strings (→ title only) or {icon?, title, desc?}","icon falls back to the block-level `icon` (default 'check'); unknown names → dot"]},Footer:{name:"Footer",description:"Multi-column marketing footer: a brand block (serif wordmark + tagline) beside grouped link columns, with a bottom rule carrying a copyright line and small print. Pure layout off theme tokens.",category:"presentation",level:"L2",tags:["footer","navigation","marketing","layout"],props:{brand:{type:"string",description:"Brand wordmark (serif display under .marketing)"},tagline:{type:"string",description:"Short brand tagline under the wordmark"},groups:{type:"array",items:{type:"object",properties:{title:{type:"string"},links:{type:"array",items:{type:"object",properties:{label:{type:"string"},href:{type:"string"}}}}}},description:"[{title, links:[{label, href}]}] link columns"},copyright:{type:"string",description:"Bottom-left copyright line"},note:{type:"string",description:"Bottom-right mono small print"}},usageScenarios:["Site-wide marketing footer with Product / Company / Legal columns","Compact footer with brand + a single link group"],constraints:["link href defaults to '#' when omitted; empty groups/links are dropped","The bottom rule only renders when copyright or note is provided"]},AccordionList:{name:"AccordionList",description:"General-purpose content accordion on native <details>/<summary> — fully functional with zero JS. Each row is a standalone hairline card with an optional leading icon chip, a title and a body. `defaultOpenFirst` opens the first row. (Faq is the divided-single-card Q&A variant.)",category:"presentation",level:"L2",tags:["accordion","details","content","marketing"],props:{title:{type:"string",description:"Optional serif heading above the list"},defaultOpenFirst:{type:"boolean",default:!1,description:"Open the first row by default"},items:{type:"array",items:{type:"object",properties:{icon:{type:"string",description:"Optional lucide icon for the row chip"},title:{type:"string"},body:{type:"string"}}},description:"[{icon?, title, body}] — rows with an empty title are dropped"}},usageScenarios:["Expandable feature explainers (icon + title + body) on a landing page","Docs 'details' sections with one card per topic"],constraints:["Uses native <details> so multiple rows can be open at once (no single-open behaviour)","Bodies render as plain text; pass pre-formatted strings"]},MetricCard:{name:"MetricCard",description:"KPI metric card with an inline pure-SVG sparkline: a mono label, a big value, a trend delta pill (up = amber, down = rose) and a sparkline drawn from a `points` series — no chart dependency. A `.mkt-card` with hover lift; `tone` selects the accent. Designed to sit in a Grid/StatGrid for a metrics row.",category:"presentation",level:"L2",tags:["metric","kpi","sparkline","card","dashboard"],props:{label:{type:"string",description:"Mono uppercase metric label"},value:{type:"string",description:"Big display value"},delta:{type:"string",description:"Trend delta pill, e.g. '+8.2%'"},trend:{type:"string",enum:["up","down"],default:"up",description:"Delta direction: up (amber) or down (rose)"},tone:{type:"string",enum:["0","1","2","3"],default:"0",description:"Accent-hue index for the sparkline stroke/fill"},points:{type:"array",items:{type:"number"},description:"Numeric series for the inline sparkline (auto-scaled)"}},usageScenarios:["Four-up KPI metrics row inside a Grid (revenue / users / latency / churn)","Single highlighted metric with a trend sparkline"],constraints:["points are auto-scaled to the card's min/max; keep series small (~<60 points)","value/delta are display strings; the sparkline is hidden when points is empty"]},GalleryGrid:{name:"GalleryGrid",description:"Caption gallery grid. Lays image tiles (or, with no `src`, a tinted blueprint placeholder) onto a 2–4 column responsive grid; a tile may opt into `wide` to span two columns for a mixed-rhythm mosaic. Captions sit on a gradient scrim over each tile. Hairline framing, hover lift — no external images required.",category:"presentation",level:"L2",tags:["gallery","images","grid","marketing"],props:{columns:{type:"string",enum:["2","3","4"],default:"3"},items:{type:"array",items:{type:"object",properties:{src:{type:"string",description:"Image URL; omit for a tinted placeholder"},caption:{type:"string",description:"Caption shown over a gradient scrim"},tone:{type:"integer",description:"Accent-hue index 0–3 for the placeholder"},wide:{type:"boolean",description:"Span two columns"}}},description:"[{src?, caption?, tone?, wide?}] gallery tiles"}},usageScenarios:["Screenshot gallery with a wide hero tile and smaller supporting tiles","Placeholder-driven layout mock before real imagery exists"],constraints:["src is treated as an image when it looks like a URL (http(s):/data:/leading slash); otherwise a placeholder renders","wide spans two columns from the sm breakpoint up"]}};var Ev=mi(),Pv=yt(),Tv=Zn(),Ai=ht(),Ov=rt(),Se=E(),Dv=me(),Lv=O(),Nv=he(),_v=be(),cE=_r(),Mv=Ri(),Bv=xi(),$v=Ii(),qr=nl(),il=et();var qv=Ev.Composer,Fv=Pv.Document,Uv=Tv.Schema,{YAMLError:jv,YAMLParseError:Vv,YAMLWarning:Hv}=Ai,Gv=Ov.Alias,{isAlias:Kv,isCollection:zv,isDocument:Wv,isMap:Yv,isNode:Jv,isPair:Qv,isScalar:Xv,isSeq:Zv}=Se,ew=Dv.Pair,tw=Lv.Scalar,rw=Nv.YAMLMap,nw=_v.YAMLSeq;var iw=Mv.Lexer,ow=Bv.LineCounter,sw=$v.Parser,{parse:Ge,parseAllDocuments:aw,parseDocument:cw,stringify:lw}=qr,{visit:uw,visitAsync:dw}=il;class H extends Error{code;details;constructor(e,t,r){super(t);this.name="CompileSpecError",this.code=e,this.details=r}}function pw(e,t){let r=Object.hasOwn(t,e)?t[e]:void 0;if(!r)throw new H("unknown-template",`unknown template "${e}"`,{template:e});let n=r.pages[0]?.blocks[0];if(!n||n.type!=="PageLayout")throw new H("invalid-shell-root",`template "${e}" root is not PageLayout`,{template:e});return n}function Fr(e,t,r,n){let i=e;if(e.template){if(r.has(e.template))throw new H("template-cycle",`template cycle at "${e.template}"`,{template:e.template});let o=pw(e.template,t),s=new Set(r);s.add(e.template);let a={...o.slots,...e.slots};if(n&&!e.slots?.sidebar)delete a.sidebar;let c=e.children??o.children,l=e.events??o.events,p=e.visible??o.visible;return i={...o,...e.id?{id:e.id}:{},props:{...o.props,...e.props},slots:a,...c?{children:c}:{},...l?{events:l}:{},...p!==void 0?{visible:p}:{}},Fr(i,t,s,n)}return{...i,...i.children?{children:i.children.map((o)=>Fr(o,t,r,n))}:{},...i.slots?{slots:Object.fromEntries(Object.entries(i.slots).map(([o,s])=>[o,s.map((a)=>Fr(a,t,r,n))]))}:{}}}function gw(e){let t=(r)=>{if(r.template)return!0;if(r.children?.some(t))return!0;return Object.values(r.slots??{}).some((n)=>n.some(t))};return e.pages.some((r)=>r.blocks.some(t))}function ol(e,t){return e.map((r)=>{if("children"in r&&Array.isArray(r.children))return{type:"MenuGroup",props:{title:r.label},children:ol(r.children,t)};let n=r,i={label:n.label,href:n.path};if(n.icon)i.icon=n.icon;if(n.path===t)i.active=!0;return{type:"MenuLink",props:i}})}function fw(e){let t=e.menus?.items;if(!t?.length)return e;return{...e,pages:e.pages.map((r)=>({...r,blocks:r.blocks.map((n)=>{if(n.type!=="PageLayout")return n;if(n.slots?.sidebar?.length)return n;return{...n,slots:{...n.slots,sidebar:[{type:"PageSiderMenu",props:{title:r.title??n.props?.title??"Menu"},children:ol(t,r.path)}]}}})}))}}function Ei(e,t={}){let r=Boolean(e.menus?.items?.length),n=gw(e)?{...e,pages:e.pages.map((i)=>({...i,blocks:i.blocks.map((o)=>Fr(o,t,new Set,r))}))}:e;return fw(n)}function mw(e){let t=new Map,r=new Map,n=new Map,i=(o,s)=>{if(o.id!==void 0){if(n.has(o.id)){let a=n.get(o.id);throw new H("duplicate-block-id",`Block id "${o.id}" is declared more than once`,{blockId:o.id,firstPageId:a,pageId:s})}n.set(o.id,s)}for(let a of o.children??[])i(a,s);for(let a of Object.values(o.slots??{}))for(let c of a)i(c,s)};return e.pages.forEach((o,s)=>{let a=t.get(o.id);if(a!==void 0)throw new H("duplicate-page-id",`Page id "${o.id}" is declared more than once`,{pageId:o.id,firstIndex:a,pageIndex:s});if(t.set(o.id,s),r.has(o.path)){let c=r.get(o.path);throw new H("duplicate-page-path",`Page path "${o.path}" is declared more than once`,{path:o.path,firstPageId:c,pageId:o.id})}r.set(o.path,o.id);for(let c of o.blocks)i(c,o.id)}),new Set(n.keys())}function yw(e,t,r){while(!0){let n=t.counter++,i=r?`${r}_${n}`:`${e}_${n}`;if(!t.reservedIds.has(i)&&!t.assignedIds.has(i))return i}}function Pi(e,t,r,n,i,o){let s=e.id??yw(t,n,o??i);if(n.assignedIds.has(s))throw new H("duplicate-block-id",`Block id "${s}" is declared more than once`,{blockId:s,pageId:t});n.assignedIds.add(s);let a=(e.children??[]).map((p)=>Pi(p,t,r,n,s,s)),c={};for(let[p,g]of Object.entries(e.slots??{}))c[p]=g.map((d)=>Pi(d,t,r,n,s,`${s}_${p}`));let l={id:s,pageId:t,type:e.type,...i?{parentId:i}:{},...e.props?{props:e.props}:{},...a.length?{children:a}:{},...Object.keys(c).length?{slots:c}:{},...e.events?{events:e.events}:{},...e.visible!==void 0?{visible:e.visible}:{},...e.template?{template:e.template}:{},...e.variant?{variant:e.variant}:{}};return r[s]=l,s}function Ti(e,t={}){e=Ei(e,t);let n={counter:0,reservedIds:mw(e),assignedIds:new Set},i=Object.create(null);return{version:"2.0",pages:e.pages.map((s)=>{let a=[];for(let c of s.blocks)a.push(Pi(c,s.id,i,n));return{id:s.id,path:s.path,...s.title?{title:s.title}:{},rootBlockIds:a,...s.state?{state:s.state}:{},...s.auth?{auth:s.auth}:{},...s.lifecycle?{lifecycle:s.lifecycle}:{},...s.computed?{computed:s.computed}:{},...s.urlState?{urlState:s.urlState}:{}}}),...e.design?{design:e.design}:{},...e.connections?{connections:e.connections.map((s)=>({...s}))}:{},blocks:i}}var kt=[{id:"_state",generation:{syntax:"page-state path",positions:["props","computed","action-value","visible"],example:{_state:"open"},prerequisite:"Declare the path on the same page"},bucket:"client",description:"Reads a value from the page state store"},{id:"_bindState",generation:{syntax:"page-state path",positions:["binding"],example:{_bindState:"name"},prerequisite:"Only installed controls implementing two-way binding"},bucket:"client",description:"Two-way state binding (read + write)"},{id:"_payload",generation:{syntax:"payload field",positions:["request-context"],example:{_payload:"name"},prerequisite:"Caller must supply request payload; ordinary preview props have no payload"},bucket:"client",description:"Request payload field"},{id:"_event",generation:{syntax:"event field",positions:["action-value"],example:{_event:"value"},prerequisite:"Only within an event action; permitted fields: type,name,value,checked,values"},bucket:"client",description:"Event payload field (e.g. form submit value)"},{id:"_global",generation:{syntax:"host-global field",positions:["host-context"],example:{_global:"configuredValue"},prerequisite:"Host-dependent and excluded from ordinary creation; no secrets"},bucket:"client",description:"Global (window) property access"},{id:"_if",generation:{syntax:"[condition, then, else]",positions:["props","computed","action-value"],example:{_if:[{_state:"open"},"Open","Closed"]}},bucket:"client",description:"Conditional ternary: [condition, then, else]"},{id:"_eq",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_eq:[{_state:"status"},"Active"]}},bucket:"client",description:"Equality: [a, b] → a === b"},{id:"_ne",generation:{syntax:"[a, b]",positions:["props","computed","action-value","visible","predicate"],example:{_ne:[{_state:"status"},"Active"]}},bucket:"client",description:"Inequality: [a, b] → a !== b"},{id:"_contains",generation:{syntax:"[haystack, needle]",positions:["props","computed","action-value","visible","predicate"],example:{_contains:[{_state:"name"},"orion"]}},bucket:"client",description:"Case-insensitive substring match: [haystack, needle] → haystack contains needle (empty needle → true)"},{id:"_gt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gt:[{_state:"count"},0]}},bucket:"client",description:"Greater-than for finite numbers: [a, b] → a > b. Non-numbers are false"},{id:"_lt",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lt:[{_state:"count"},10]}},bucket:"client",description:"Less-than for finite numbers: [a, b] → a < b. Non-numbers are false"},{id:"_gte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_gte:[{_state:"count"},0]}},bucket:"client",description:"Greater-or-equal for finite numbers: [a, b] → a >= b. Non-numbers are false"},{id:"_lte",generation:{syntax:"[finite-number, finite-number]",positions:["props","computed","action-value","visible","predicate"],example:{_lte:[{_state:"count"},10]}},bucket:"client",description:"Less-or-equal for finite numbers: [a, b] → a <= b. Non-numbers are false"},{id:"_in",generation:{syntax:"[value, array]",positions:["props","computed","action-value","visible","predicate"],example:{_in:[{_state:"status"},["Active","Draft"]]}},bucket:"client",description:"Membership: [value, array] → array includes value"},{id:"_not",generation:{syntax:"condition",positions:["props","computed","action-value","visible","predicate"],example:{_not:{_state:"open"}}},bucket:"client",description:"Logical NOT"},{id:"_and",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_and:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical AND over a list of conditions"},{id:"_or",generation:{syntax:"[condition, ...]",positions:["props","computed","action-value","visible","predicate"],example:{_or:[{_state:"ready"},{_state:"open"}]}},bucket:"client",description:"Logical OR over a list of conditions"},{id:"_user",generation:{syntax:"session user field",positions:["props","computed","action-value"],example:{_user:"name"},prerequisite:"Requires injected host session; no server ACL guarantee"},bucket:"client",description:"Current session user field (client-visible)"},{id:"_item",generation:{syntax:"item field or empty string",positions:["predicate","loop-props"],example:{_item:"name"},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list item in a loop scope"},{id:"_index",generation:{syntax:"ignored scalar marker",positions:["predicate","loop-props"],example:{_index:0},prerequisite:"Only inside a declared loop or filter/find predicate"},bucket:"client",description:"Current list index in a loop scope"},{id:"_array.length",generation:{syntax:"array expression",positions:["props","computed","action-value"],example:{"_array.length":{_state:"rows"}}},bucket:"client",description:"Array length"},{id:"_string.concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{"_string.concat":["Hello ",{_state:"name"}]}},bucket:"client",description:"String concatenation over a list"},{id:"_number.add",generation:{syntax:"[left, right] (finite numbers)",positions:["action-value"],example:{"_number.add":[{_state:"count"},1]},prerequisite:"Both operands must evaluate to finite numbers or the action fails and writes nothing; use it in SetState value for counters (e.g. SetState count = count + 1), never for strings or arrays"},bucket:"client",description:"Finite number addition: [left, right] → left + right. Throws on non-number, non-finite or overflowing operands (no coercion, no fallback to 0)"},{id:"_computed",generation:{syntax:"computed name",positions:["props","computed","action-value","visible"],example:{_computed:"filtered"},prerequisite:"Declare page computed expression"},bucket:"client",description:"Reads a derived (computed) state value by name from the __computed namespace"},{id:"_filter",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_filter:[{_state:"rows"},{_eq:[{_item:"status"},"Active"]}]}},bucket:"client",description:"Filters an array: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_find",generation:{syntax:"[array, predicate]",positions:["props","computed","action-value"],example:{_find:[{_state:"rows"},{_eq:[{_item:"name"},"Orion"]}]}},bucket:"client",description:"Finds the first matching element: [arrayExpr, predExpr] with { _item, _index } scope"},{id:"_len",generation:{syntax:"array/string/object expression",positions:["props","computed","action-value"],example:{_len:{_state:"rows"}}},bucket:"client",description:"Length of an array, string, or object (0 if empty)"},{id:"_concat",generation:{syntax:"[value, ...]",positions:["props","computed","action-value"],example:{_concat:[[1],[2]]},prerequisite:"Concatenation is not numeric addition"},bucket:"client",description:"Concatenates a list: arrays are joined, otherwise values are string-concatenated"},{id:"_count",generation:{syntax:"array or [array, predicate?]",positions:["props","computed","action-value"],example:{_count:[{_state:"rows"}]}},bucket:"client",description:"Count of an array, or of elements matching a predicate: [array, predicate?]"},{id:"_groupCount",generation:{syntax:"[array, field]",positions:["props","computed","action-value"],example:{_groupCount:[{_state:"rows"},"status"]}},bucket:"client",description:"Counts array items by a field in one pass: [array, field] → { value: count }"},{id:"_sort",generation:{syntax:"[array, {by, order?, rank?}]",positions:["props","computed","action-value"],example:{_sort:[{_state:"rows"},{by:"name",order:"asc"}]}},bucket:"client",description:"Stable sort: [array, { by, order?: asc|desc, rank?: { field: values[] } }]. rank is enum order"},{id:"_js",generation:{syntax:"disabled",positions:[],example:{_js:"disabled"},prerequisite:"Arbitrary code execution is disabled; permissions do not enable it",disabled:!0},bucket:"client",description:"Legacy JS expression; execution is always disabled"}],Ur=new Set(kt.map((e)=>e.id));var sl=new Set(Us),hw=new Map(kt.map((e)=>[e.id,e])),ll=new Set(["array","boolean","integer","null","number","object","string"]),ul=new Set(["default","description","enum","items","properties","required","type"]);function al(e){if(!e)return[];return Object.keys(e)}function bw(e){if(!e||e.type!=="array")return;let t=e.items;if(!t||typeof t!=="object"||t.type!=="object"||!t.properties)return;return new Set(Object.keys(t.properties))}function Oi(e,t,r){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let[n,i]of e.entries())Oi(i,`${t}[${n}]`,r);return}for(let[n,i]of Object.entries(e)){let o=t?`${t}.${n}`:n;r(n,i,o),Oi(i,o,r)}}function jr(e,t,r,n,i,o,s,a){Oi(n,i,(c,l,p)=>{if((c==="_state"||c==="_bindState")&&typeof l==="string"){let g=l.split("."),d=g[0]??"";if(d==="__computed"){let u=g[1]??"";if(!s.has(u))e.push({code:"refs:computed-declared",message:`${t}: _computed "${u}" is not declared`,elementKey:r,path:p});return}if(!o.has(d))e.push({code:"refs:state-declared",message:`${t}: _state "${d}" is not declared in state`,elementKey:r,path:p})}if(c==="_computed"&&typeof l==="string"&&!s.has(l))e.push({code:"refs:computed-declared",message:`${t}: _computed "${l}" is not declared`,elementKey:r,path:p});if(c==="_item"&&typeof l==="string"&&l!==""&&a&&!a.has(l))e.push({code:"item:field-exists",message:`${t}: _item "${l}" is not in the item schema`,elementKey:r,path:p})})}function U(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Rt(e){return U(e)&&Object.keys(e).some((t)=>t.startsWith("_"))}var cl=new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_not","_and","_or"]);function Cw(e,t){if(new Set(["_eq","_ne","_contains","_gt","_lt","_gte","_lte","_in","_filter","_find","_groupCount","_sort","_number.add"]).has(e)){if(!Array.isArray(t)||t.length!==2)return!1;if(e==="_groupCount")return typeof t[1]==="string";if(e==="_sort"){let n=t[1];if(!U(n))return!1;if(!(typeof n.by==="string"&&n.by.length>0||Array.isArray(n.by)&&n.by.length>0&&n.by.every((o)=>typeof o==="string"&&o.length>0)))return!1;if(n.order!==void 0&&n.order!=="asc"&&n.order!=="desc")return!1;if(n.rank!==void 0&&(!U(n.rank)||Object.values(n.rank).some((o)=>!Array.isArray(o))))return!1;return Object.keys(n).every((o)=>["by","order","rank"].includes(o))}return!0}if(e==="_if")return Array.isArray(t)&&t.length===3;if(e==="_and"||e==="_or")return Array.isArray(t)&&t.length>0;if(e==="_string.concat"||e==="_concat")return Array.isArray(t)&&t.length>0;if(e==="_count")return!Array.isArray(t)||t.length===1||t.length===2;if(e==="_index")return typeof t==="number"&&Number.isFinite(t);if(["_state","_bindState","_computed","_event","_global","_payload","_user"].includes(e))return typeof t==="string"&&t.length>0;if(e==="_item")return typeof t==="string";return!0}function dl(e){return e.enum===void 0||Array.isArray(e.enum)&&e.enum.length>0&&e.enum.every((t)=>t===null||typeof t==="string"||typeof t==="boolean"||typeof t==="number"&&Number.isFinite(t))}function Pe(e,t,r,n,i,o){if(r==="predicate"&&(!Rt(e)||!cl.has(Object.keys(e)[0]??"")))return n.push({code:"props:expression",message:`${i}: predicate must be a supported expression node`,elementKey:o,path:t}),!1;if(e===void 0)return n.push({code:"props:expression",message:`${i}: value is not part of the supported serialized expression syntax`,elementKey:o,path:t}),!1;if(Array.isArray(e))return e.reduce((d,u,m)=>Pe(u,`${t}[${m}]`,r,n,i,o)&&d,!0);if(!U(e)){if(typeof e==="number"&&!Number.isFinite(e)||e!==null&&!["string","number","boolean"].includes(typeof e))return n.push({code:"props:expression",message:`${i}: value is not part of the supported serialized expression syntax`,elementKey:o,path:t}),!1;return e===null||["string","number","boolean"].includes(typeof e)}let s=Object.keys(e).filter((d)=>d.startsWith("_"));if(s.length===0)return Object.entries(e).reduce((d,[u,m])=>Pe(m,`${t}.${u}`,r,n,i,o)&&d,!0);let a=s[0]??"",c=hw.get(a),l=`${t}.${a}`;if(s.length!==1||Object.keys(e).length!==1||!c)return n.push({code:"props:expression",message:`${i}: expression shape is not supported`,elementKey:o,path:l}),!1;if(c.generation?.disabled||!c.generation?.positions.includes(r)&&!(r==="props"&&c.generation?.positions.includes("binding"))&&!(r==="predicate-value"&&c.generation?.positions.some((d)=>["props","computed","predicate"].includes(d))))return n.push({code:"props:expression",message:`${i}: expression is not supported in this value position`,elementKey:o,path:l}),!1;let p=e[a];if(!Cw(a,p))return n.push({code:"props:expression",message:`${i}: expression operand shape is not supported`,elementKey:o,path:l}),!1;let g=(d)=>Rt(d)||Array.isArray(d);if(["_filter","_find","_groupCount","_sort"].includes(a)&&!g(Array.isArray(p)?p[0]:void 0)||a==="_in"&&!g(Array.isArray(p)?p[1]:void 0))return n.push({code:"props:expression",message:`${i}: expression array operand has an unsupported literal shape`,elementKey:o,path:l}),!1;if(a==="_count"&&(Array.isArray(p)?!g(p[0]):!g(p))||a==="_array.length"&&!g(p))return n.push({code:"props:expression",message:`${i}: expression array operand has an unsupported literal shape`,elementKey:o,path:l}),!1;if(["_gt","_lt","_gte","_lte"].includes(a)&&Array.isArray(p)){if(p.some((u)=>!Rt(u)&&(typeof u!=="number"||!Number.isFinite(u))))return n.push({code:"props:expression",message:`${i}: numeric comparison literals must be finite numbers`,elementKey:o,path:l}),!1}if(Array.isArray(p))return p.reduce((d,u,m)=>{let f=r;if((["_filter","_find"].includes(a)||a==="_count")&&m===1)f="predicate";else if(r==="predicate"||r==="predicate-value"){if(f=cl.has(a)?"predicate-value":r,r==="predicate"&&["_and","_or"].includes(a))f="predicate"}return Pe(u,`${l}[${m}]`,f,n,i,o)&&d},!0);if(U(p))return Pe(p,l,r==="predicate"&&a==="_not"?"predicate-value":r,n,i,o);return!0}function Di(e,t,r,n,i,o,s){let a=(g)=>s==="props"?`props:${g}`:`actions:params-${g}`;if(Object.keys(t).filter((g)=>!ul.has(g)).length>0){n.push({code:"schema:unsupported",message:`${i}: schema contains unsupported constraints`,elementKey:o,path:r});return}if(t.type!==void 0&&!ll.has(t.type)){n.push({code:"schema:unsupported",message:`${i}: schema type is not supported`,elementKey:o,path:r});return}if(!dl(t)){n.push({code:"schema:unsupported",message:`${i}: schema enum is not supported`,elementKey:o,path:r});return}if(t.required!==void 0&&(!Array.isArray(t.required)||t.required.some((g)=>typeof g!=="string"))){n.push({code:"schema:unsupported",message:`${i}: schema required list is not supported`,elementKey:o,path:r});return}if(t.items!==void 0&&(t.type!=="array"||!U(t.items))){n.push({code:"schema:unsupported",message:`${i}: schema items must describe an array`,elementKey:o,path:r});return}if(t.properties!==void 0&&(t.type!=="object"||!U(t.properties))){n.push({code:"schema:unsupported",message:`${i}: schema properties must describe an object`,elementKey:o,path:r});return}if(t.required?.length&&t.type!=="object"){n.push({code:"schema:unsupported",message:`${i}: schema required list is only supported for objects`,elementKey:o,path:r});return}if(Rt(e))return;let l=t.type;if(!(l===void 0||l==="null"&&e===null||l==="string"&&typeof e==="string"||l==="boolean"&&typeof e==="boolean"||l==="number"&&typeof e==="number"&&Number.isFinite(e)||l==="integer"&&typeof e==="number"&&Number.isInteger(e)||l==="array"&&Array.isArray(e)||l==="object"&&U(e))){n.push({code:a("type"),message:`${i}: value does not match the declared type`,elementKey:o,path:r});return}if(t.enum&&!t.enum.some((g)=>Object.is(g,e)))n.push({code:a("enum"),message:`${i}: value is outside the declared enum`,elementKey:o,path:r});if(l==="object"&&U(e)){for(let g of t.required??[])if(!Object.hasOwn(e,g))n.push({code:a("required"),message:`${i}: required object field is missing`,elementKey:o,path:`${r}.${g}`});for(let[g,d]of Object.entries(t.properties??{}))if(Object.hasOwn(e,g))Di(e[g],d,`${r}.${g}`,n,i,o,s)}if(l==="array"&&Array.isArray(e)&&t.items)e.forEach((g,d)=>{Di(g,t.items,`${r}[${d}]`,n,i,o,s)})}function pl(e,t,r,n,i,o,s){if(!r)return;for(let[a,c]of Object.entries(r)){let l=`${n}.${a}`;if(Li(c,l,e,i,o)&&t&&Object.hasOwn(t,a))Di(t[a],c,l,e,i,o,s)}}function gl(e,t,r,n,i,o,s={}){for(let[a,c]of Object.entries(t??{})){let l=n==="action-value"&&!s.evaluatedParams?.has(a)?"action-literal":n;Pe(c,`${r}.${a}`,l,e,i,o)}}function Li(e,t,r,n,i){if(Object.keys(e).some((s)=>!ul.has(s))||e.type!==void 0&&!ll.has(e.type)||!dl(e)||e.required!==void 0&&(!Array.isArray(e.required)||e.required.some((s)=>typeof s!=="string"))||e.items!==void 0&&(e.type!=="array"||!U(e.items))||e.properties!==void 0&&(e.type!=="object"||!U(e.properties))||Boolean(e.required?.length)&&e.type!=="object")return r.push({code:"schema:unsupported",message:`${n}: schema contains unsupported constraints`,elementKey:i,path:t}),!1;for(let[s,a]of Object.entries(e.properties??{}))if(!Li(a,`${t}.${s}`,r,n,i))return!1;if(e.items&&!Li(e.items,`${t}[]`,r,n,i))return!1;return!0}function Vr(e,t,r,n,i,o,s){if(!Array.isArray(n)){if(s)e.push({code:"actions:chain",message:`${t}: action chain must be an array`,elementKey:r,path:i});return}for(let[a,c]of n.entries()){if(!U(c)){if(s)e.push({code:"actions:chain",message:`${t}: action step must be an object`,elementKey:r,path:`${i}[${a}]`});continue}let l=c.action,p=`${i}[${a}]`;if(s&&(typeof l!=="string"||l.length===0))e.push({code:"actions:chain",message:`${t}: action step needs an action name`,elementKey:r,path:`${p}.action`});if(typeof l==="string"&&!sl.has(l)&&!Object.hasOwn(o.actions??{},l))e.push({code:"actions:registered",message:`${t}: action "${l}" is not in the catalog. Registered actions: ${[...sl,...Object.keys(o.actions??{})].join(", ")}. No equivalent is guaranteed: preserve the requirement and report unsupported behavior instead of disabling it.`,elementKey:r,path:`${p}.action`});if(s&&typeof l==="string"){let g=Object.hasOwn(o.actions??{},l)?o.actions[l]:Object.hasOwn(fn,l)?fn[l]:void 0,d=c.params;if(d!==void 0&&!U(d))e.push({code:"actions:chain",message:`${t}: action params must be an object`,elementKey:r,path:`${p}.params`});else{if(U(d))gl(e,d,`${p}.params`,"action-value",t,r,{evaluatedParams:new Set(g?.generation?.evaluatedParams??[])});if(g)pl(e,U(d)?d:void 0,g.params,`${p}.params`,t,r,"actions:params")}}if(Object.hasOwn(c,"onSuccess"))Vr(e,t,r,c.onSuccess,`${p}.onSuccess`,o,s);if(Object.hasOwn(c,"onError"))Vr(e,t,r,c.onError,`${p}.onError`,o,s)}}function fl(e,t,r=!1){let n=[],i=new Set([...al(e.state),...e.connectionIds??[]]),o=new Set(al(e.computed)),s=e.pageId??e.root;if(e.computed)for(let[a,c]of Object.entries(e.computed)){if(r)Pe(c,`computed.${a}`,"computed",n,`${s}.computed`,s);jr(n,`${s}.computed`,s,c,`computed.${a}`,i,o,Sw(e,t))}if(e.urlState)for(let[a,c]of Object.entries(e.urlState)){if(!i.has(a))n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" is not declared in state`,elementKey:s,path:`urlState.${a}`});if(!c||typeof c.param!=="string"||c.param.length===0)n.push({code:"refs:url-state-declared",message:`${s}: urlState "${a}" needs a param name`,elementKey:s,path:`urlState.${a}.param`})}for(let[a,c]of Object.entries(e.elements)){let l=Object.hasOwn(t.components,c.type)?t.components[c.type]:void 0;if(!l)continue;let p=`${s}/${a}`,g=ml(l.props);if(r)gl(n,c.props,"props","props",p,a);if(c.visible!==null&&typeof c.visible==="object"){let d=Object.keys(c.visible);if(Array.isArray(c.visible)||d.length!==1||!d[0]?.startsWith("_"))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression, not a literal record`,elementKey:a,path:"visible"})}if(r&&c.visible!==void 0)if(typeof c.visible!=="boolean"&&!Rt(c.visible))n.push({code:"visibility:expression",message:`${p}: visible must be a boolean or an operator expression`,elementKey:a,path:"visible"});else Pe(c.visible,"visible","visible",n,p,a);if(jr(n,p,a,c.props,"props",i,o,g),jr(n,p,a,c.visible,"visible",i,o,g),jr(n,p,a,c.events,"events",i,o,g),l.props){let d=new Set(Object.keys(l.props));for(let u of Object.keys(c.props??{}))if(!d.has(u))n.push({code:"props:declared",message:`${p}: prop "${u}" is not declared on ${c.type}`,elementKey:a,path:`props.${u}`});if(r)pl(n,c.props,l.props,"props",p,a,"props")}if(l.events){let d=new Set(Object.keys(l.events));for(let[u,m]of Object.entries(c.events??{})){if(!d.has(u))n.push({code:"events:declared",message:`${p}: event "${u}" is not declared on ${c.type}`,elementKey:a,path:`events.${u}`});Vr(n,p,a,m,`events.${u}`,t,r)}}else for(let[d,u]of Object.entries(c.events??{}))Vr(n,p,a,u,`events.${d}`,t,r)}return n.map((a)=>({...a,path:a.elementKey===s?`${s}/${a.path}`:`${s}/${a.elementKey}/${a.path}`}))}function ml(e){let t=new Set;for(let r of Object.values(e??{})){let n=bw(r);if(!n)continue;for(let i of n)t.add(i)}return t.size>0?t:void 0}function Sw(e,t){let r=new Set;for(let n of Object.values(e.elements)){let i=Object.hasOwn(t.components,n.type)?t.components[n.type]:void 0,o=ml(i?.props);if(!o)continue;for(let s of o)r.add(s)}return r.size>0?r:void 0}function yl(e){return e.map((t)=>({code:t.code,message:t.message,elementKey:t.elementKey,path:t.path}))}var hl=[{id:"_request",bucket:"server",description:"Executes a connection request server-side and injects the result"},{id:"_secret",bucket:"server",description:"Reads a server-side secret value; never transmitted to the client"}],Hr=new Set(hl.map((e)=>e.id));function Gr(e){if(!e||typeof e!=="object"||Array.isArray(e))return e;let t=e;if(typeof t.version==="number")return{...t,version:Number.isInteger(t.version)?t.version.toFixed(1):String(t.version)};return t}function Ni(e){return{...e,...e.props?{props:{...e.props}}:{},...e.children?{children:[...e.children]}:{},...e.slots?{slots:{...e.slots}}:{},...e.events?{events:{...e.events}}:{}}}function bl(e){return{...e,...e.roots?{roots:[...e.roots]}:{},...e.state?{state:{...e.state}}:{},elements:Object.fromEntries(Object.entries(e.elements).map(([t,r])=>[t,Ni(r)]))}}function ww(e){return e.type==="compiler:operator"}function kw(e){return e.type==="compiler:validator"}class xt{operators;validators;constructor(e={}){let t=(e.capabilities??[]).filter(ww).map((n)=>n.contribution),r=(e.capabilities??[]).filter(kw).map((n)=>n.contribution);this.operators=[...e.operators??[],...t],this.validators=[...e.validators??[],...r]}merge(e){if(e instanceof xt)return new xt({operators:[...this.operators,...e.operators],validators:[...this.validators,...e.validators]});return new xt({operators:[...this.operators,...e.operators??[]],validators:[...this.validators,...e.validators??[]],...e.capabilities?{capabilities:e.capabilities}:{}})}}function Rw(e={}){return new xt(e)}function _i(e,t={}){let r=t.format??"auto";if(r==="json")return Gr(JSON.parse(e));if(r==="yaml")return Gr(Ge(e));let n=e.trim();if(n.startsWith("{")||n.startsWith("["))return Gr(JSON.parse(n));return Gr(Ge(e))}function xw(e,t,r){let n=e.pages.find((s)=>s.id===t),i=[...n?.rootBlockIds??[]],o=Object.fromEntries(Object.entries(e.blocks).filter(([,s])=>s.pageId===t).map(([s,a])=>{let{id:c,pageId:l,parentId:p,...g}=a;return[s,Ni(g)]}));if(r&&i.length===0){let s=e.blocks.__empty__?`__empty__:${t}`:"__empty__";i.push(s),o[s]={type:"Empty"}}return{version:e.version,root:i[0]??"__empty__",roots:i,pageId:t,...n?.state?{state:n.state}:{},...n?.computed?{computed:n.computed}:{},...n?.urlState?{urlState:n.urlState}:{},...e.connections?{connectionIds:e.connections.map((s)=>s.id)}:{},elements:o}}function Iw(e,t){let r=[...t.roots??e.roots??[]];if(r.length>0&&t.root!==e.root)r[0]=t.root;else if(r.length===0&&t.elements[t.root])r.push(t.root);return r}async function Aw(e,t,r,n){let i=bl(e);for(let o of r.operators){let s={spec:i,catalog:t,warnings:n,getElement(c){return i.elements[c]},updateElement(c,l){i={...i,elements:{...i.elements,[c]:Ni(l)}}},addWarning(c){n.push(c)}},a=await o.apply(s);if(a)i=bl(a)}return i}function Cl(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ew(e,t,r,n,i){let o=Object.entries(e.elements);for(let a of e.roots?.length?e.roots:[e.root])if(!e.elements[a])r.push({code:"missing-root",message:`Root element "${a}" is missing from the elements map`,elementKey:a});for(let[a,c]of o){if(!(Cl(t.components,c.type)??Cl(t.templates,c.type)))n.push({missingType:c.type,elementKey:a,reason:c.template?"missing-template":"missing-component",context:`Element ${a} references ${c.type}`,path:`blocks.${a}.type`});for(let p of c.children??[])if(!e.elements[p])r.push({code:"dangling-child",message:`Element "${a}" references missing child "${p}"`,elementKey:a})}let s=fl(e,t,i);if(i){for(let a of s)n.push({missingType:a.code,elementKey:a.elementKey,reason:"invalid-spec",context:a.message,code:a.code,path:a.path});return}r.push(...yl(s))}async function Pw(e,t,r,n,i){for(let o of r.validators){let s={spec:e,catalog:t,warnings:n,gaps:i,addWarning(a){n.push(a)},addGap(a){i.push(a)}};await o.validate(s)}}function Ke(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let r of e)Ke(r,t);return}for(let[r,n]of Object.entries(e)){if(r.startsWith("_"))t.add(r);Ke(n,t)}}function Tw(e){let t=new Map;for(let[n,i]of Object.entries(e.blocks)){let o=new Set;Ke(i.props,o),Ke(i.visible,o);for(let s of o){let a=t.get(s)??new Set;a.add(n),t.set(s,a)}}for(let n of e.pages){let i=new Set;Ke(n.computed,i),Ke(n.lifecycle,i);for(let o of i){let s=t.get(o)??new Set;s.add(n.id),t.set(o,s)}}let r=[];for(let[n,i]of t){let o=Ur.has(n)?"client":Hr.has(n)?"server":n==="_ref"?"build":"shared";r.push({operatorId:n,bucket:o,blockIds:[...i]})}return r}async function Sl(e,t,r={}){let n=[],i=[],o=r.registry??Rw(),s=Ti(e,r.templates),a=Object.create(null),c=[];for(let[g,d]of s.pages.entries()){let u=xw(s,d.id,g===0),m=await Aw(u,t,o,n);Ew(m,t,n,i,r.strict===!0),await Pw(m,t,o,n,i);for(let[f,y]of Object.entries(m.elements)){let S=a[f];if(S)throw new H("duplicate-block-id",`Compiler output block id "${f}" conflicts across pages`,{blockId:f,firstPageId:S.pageId,pageId:d.id});let w=s.blocks[f];a[f]={...y,id:f,pageId:d.id,...w?.pageId===d.id&&w.parentId?{parentId:w.parentId}:{}}}c.push({...d,rootBlockIds:Iw(u,m)})}let l={version:"2.0",pages:c,...s.design?{design:s.design}:{},...s.connections?{connections:s.connections.map((g)=>({...g}))}:{},blocks:a};if(r.strict===!0&&e.version!=="2.0")i.push({missingType:"spec:version",elementKey:"spec",reason:"invalid-spec",context:"Native Spec version must be 2.0",code:"spec:version",path:"version"});let p=Tw(l);return{spec:l,gaps:i,warnings:n,...p.length>0?{operatorUsage:p}:{}}}import{readFileSync as Dw}from"node:fs";var vl=["auto","user","override"];function Kr(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!t)return{meta:"",body:e.trim()};return{meta:(t[1]??"").trim(),body:(t[2]??"").trim()}}function zr(e){let{meta:t}=Kr(e);if(!t)throw Error("design-md file is missing YAML frontmatter");let r=Ge(t);if(!r||typeof r!=="object")throw Error("design-md frontmatter must be a YAML object");if(typeof r.id!=="string"||!r.id)throw Error("design-md frontmatter must include a non-empty 'id' field");let n=typeof r.title==="string"?r.title.trim():"",i=typeof r.name==="string"?r.name.trim():"",o=n||i;if(!o)throw Error("design-md frontmatter must include a non-empty 'title' or 'name' field");if(typeof r.category!=="string"||!r.category)throw Error("design-md frontmatter must include a non-empty 'category' field");let s={id:r.id,title:o,category:r.category,tags:Array.isArray(r.tags)?r.tags:[],origin:typeof r.origin==="string"?r.origin:"local"};if(i)s.name=i;if(typeof r.version==="string"&&r.version.trim())s.version=r.version.trim();if(typeof r.sourceUrl==="string")s.sourceUrl=r.sourceUrl;if(Array.isArray(r.exemptRules)){let a=r.exemptRules.filter((c)=>typeof c==="string"&&c.trim().length>0);if(a.length>0)s.exemptRules=a.map((c)=>c.trim())}if(Array.isArray(r.extractedTokens))s.extractedTokens=r.extractedTokens;if(typeof r.layer==="string")if(vl.includes(r.layer))s.layer=r.layer;else console.warn(`[design-md] ignoring invalid layer "${r.layer}" on id="${s.id}"; expected one of ${vl.join("|")}`);return s}var Ow=[{pattern:/`?(--[\w-]+)`?\s*:\s*([#\w()%., ]+)/g,group:"css-var"},{pattern:/`?([\w-]+(?:Color|Bg|Text|Border|Shadow|Radius|Font|Size|Space))`?\s*[=:]\s*["']?([^"'\n,]+)["']?/gi,group:"token"}];function Mi(e){let t=new Set,r=[];for(let{pattern:n,group:i}of Ow){let o=new RegExp(n.source,n.flags),s;while((s=o.exec(e))!==null){let a=(s[1]??"").trim(),c=(s[2]??"").trim(),l=`${a}:${c}`;if(!t.has(l))t.add(l),r.push({name:a,value:c,group:i})}}return r}function It(e){let t=Dw(e,"utf-8"),{body:r}=Kr(t),n=zr(t),i=n.extractedTokens??Mi(r),o={id:n.id,title:n.title,category:n.category,tags:n.tags??[],origin:n.origin??"local",body:r,filePath:e};if(n.sourceUrl)o.sourceUrl=n.sourceUrl;if(n.exemptRules)o.exemptRules=n.exemptRules;if(n.layer)o.layer=n.layer;if(i.length>0)o.extractedTokens=i;return o}import{fileURLToPath as Lw}from"node:url";import{existsSync as Nw,readdirSync as _w}from"node:fs";import{join as Mw}from"node:path";var wl=Lw(new URL("../content",import.meta.url));function Wr(e=wl){if(!Nw(e))return[];let t=[];for(let r of _w(e).sort()){if(r.startsWith("_")||!r.endsWith(".design.md"))continue;try{t.push(It(Mw(e,r)))}catch(n){console.warn(`[design-md] skipping seed ${r}: ${n.message}`)}}return t}function Fw(e){return e==="quality"?"blocking":"advisory"}var Uw=["streamline your","empower your","supercharge your","unlock the power","best-in-class","enterprise-grade","next-generation","cutting-edge","revolutionize","game-changer","game changer","future-proof","seamless experience","drive growth","harness the power","take it to the next level","world-class","state-of-the-art","robust solution","powerful platform","effortlessly","seamlessly integrate","elevate your","transform your"],jw=["Inter","Roboto","Geist","Fraunces","Plus Jakarta","Space Grotesk"];function ae(e,t){let r=e.match(t);return r?r.length:0}var Vw=[{id:"marketing-buzzword",category:"slop",severity:"P2",message:"Marketing buzzwords read as AI filler — prefer concrete, specific copy.",detect:(e)=>{let t=e.toLowerCase();return Uw.reduce((r,n)=>r+(t.includes(n)?1:0),0)}},{id:"em-dash-overuse",category:"slop",severity:"P3",message:"Em-dash overuse (≥5) is a strong AI-writing tell.",detect:(e)=>{let t=ae(e,/[—]|--(?=\S)/g);return t>=5?t-4:0}},{id:"aphoristic-cadence",category:"slop",severity:"P2",message:'Manufactured-contrast cadence ("Not an X. Just Y.") is a recognizable AI pattern.',detect:(e)=>{let t=ae(e,/\bNot\s+(?:an?|just)\b[^.?!]*[.?!]/gi),r=ae(e,/\b[A-Z][^.?!]*\.\s+(?:No|Just)\s+[a-z]/g),n=t+r;return n>=3?n:0}},{id:"numbered-section-markers",category:"slop",severity:"P3",message:"Numbered section scaffolding (01 / 02 / 03) is an overused AI layout tell.",detect:(e)=>{let t=e.match(/\b(0[1-9]|1[0-2])\b/g)??[],r=new Set(t);if(r.size<3)return 0;let n=[...r].map(Number).sort((o,s)=>o-s);return n.some((o,s)=>s>0&&o-n[s-1]===1)?r.size:0}}],Hw=[{id:"gradient-text",category:"slop",severity:"P2",message:"Gradient text (bg-clip-text + transparent) is a classic AI hero tell.",detect:(e)=>ae(e,/bg-clip-text[^"']*text-transparent|text-transparent[^"']*bg-clip-text|-webkit-background-clip\s*:\s*text/gi)},{id:"ai-color-palette",category:"slop",severity:"P2",message:"Purple/violet gradient palette is the most recognizable AI color tell.",detect:(e)=>ae(e,/(from|via|to)-(purple|violet|fuchsia|indigo)-\d{3}|linear-gradient\([^)]*(?:#(?:8b5cf6|a855f7|7c3aed|6366f1))/gi)},{id:"side-tab",category:"slop",severity:"P2",message:"Thick colored side-border on a card (border-l-4 + accent) is the single most recognizable AI card tell.",detect:(e)=>ae(e,/border-l-(4|8)\s+border-(purple|violet|indigo|blue|primary)/gi)},{id:"overused-font",category:"slop",severity:"P3",message:"Over-represented font (Inter/Geist/…) without a brand reason reads as default AI styling.",detect:(e)=>jw.reduce((t,r)=>t+(new RegExp(`font-family[^;"']*${r}`,"i").test(e)?1:0),0)},{id:"emoji-icon",category:"slop",severity:"P2",message:"Emoji used as a heading/list/button icon is a stock AI tell — use a real icon or nothing.",detect:(e)=>ae(e,/<(?:h[1-6]|li|button|summary|th)\b[^>]*>\s*(?:<[^>]+>\s*)*\p{Extended_Pictographic}/giu)},{id:"github-dark-glow",category:"slop",severity:"P3",message:"Flat #0D1117 background with a neon cyan/violet glow is the default AI dark-mode look.",detect:(e)=>/#0d1117/i.test(e)&&/(?:box-shadow|drop-shadow|text-shadow)[^;"']*(?:#06b6d4|#22d3ee|#00f0ff|#a78bfa|#8b5cf6|cyan|violet)/i.test(e)?1:0},{id:"tiny-text",category:"quality",severity:"P1",message:"Body text below ~14px (text-[10px]/[11px]/[12px]) harms readability and accessibility.",detect:(e)=>ae(e,/text-\[(?:8|9|10|11|12)px\]|font-size\s*:\s*(?:8|9|10|11|12)px/gi)},{id:"gray-on-color",category:"quality",severity:"P1",message:"Gray text on a colored fill commonly fails WCAG contrast.",detect:(e)=>ae(e,/bg-(?:primary|blue|indigo|violet|purple)-\d{3}[^"']*text-(?:gray|slate|zinc|neutral)-\d{3}/gi)}],kl={P0:0.3,P1:0.15,P2:0.08,P3:0.04};function Gw(e){if(e>=0.9)return"A";if(e>=0.8)return"B";if(e>=0.65)return"C";if(e>=0.5)return"D";return"F"}var Rl="title|text|label|content|description|heading|subtitle|placeholder|body|caption|name",KP=new RegExp(`["']?\\b(?:${Rl})["']?\\s*:\\s*["']([^"'\\n]*)["']`,"gi"),zP=new RegExp(`^\\s*-?\\s*(?:${Rl})\\s*:\\s*([^\\s"'{\\[][^\\n]*)$`,"gim");function xl(e){let t=e.text??e.html??"",r=e.html??e.text??"",n=new Set(e.exempt??[]),i=[],o=(a,c)=>{for(let l of a){let p=Fw(l.category);if(p==="advisory"&&n.has(l.id))continue;let g=l.detect(c);if(g>0)i.push({ruleId:l.id,category:l.category,severity:l.severity,level:p,message:l.message,count:g})}};o(Vw,t),o(Hw,r);let s=1;for(let a of i){let c=Math.min(kl[a.severity]*(1+(a.count-1)/3),kl[a.severity]*2);s-=c}return s=Math.max(0,Math.min(1,s)),{score:s,grade:Gw(s),findings:i,blocked:i.some((a)=>a.level==="blocking")}}import{readdirSync as Kw,readFileSync as zw,statSync as Ww}from"node:fs";import{basename as Yw,join as Jw}from"node:path";var Qw="0.1.0";function Il(e){let{dir:t}=e,r;try{r=Kw(t)}catch{return[]}let n=e.defaultVersion??Qw,i=e.defaultLevel??"L4",o=e.defaultCategory??"template",s=[];for(let a of r){if(!/\.ya?ml$/i.test(a))continue;let c=Jw(t,a);try{if(!Ww(c).isFile())continue}catch{continue}let l=zw(c,"utf8");if(!l.trim())continue;let p=Yw(a).replace(/\.ya?ml$/i,""),g=Xw(p),d=Zw(p),u=ek(l)??`${d} template`;s.push({name:g,version:n,title:d,description:u,yaml:l,absolutePath:c,templateContract:{name:g,description:u,level:i,category:o,keywords:[g,p.toLowerCase(),"uibot-template",...e.extraKeywords??[]],composedFrom:tk(l)}})}return s.sort((a,c)=>a.name.localeCompare(c.name))}function Bi(e){let t=new Map;for(let r of e)for(let n of Il(r)){let i=t.get(n.name);if(i)throw Error(`duplicate template source name "${n.name}": ${i.absolutePath} and ${n.absolutePath}`);t.set(n.name,n)}return[...t.values()].sort((r,n)=>r.name.localeCompare(n.name))}function Xw(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function Zw(e){return e.replace(/[-_]+/g," ").replace(/\b\w/g,(t)=>t.toUpperCase())}function ek(e){return(e.match(/^\s*title:\s*["']?(.+?)["']?\s*$/m)??e.match(/^\s*-\s*id:.*\n\s*path:.*\n\s*title:\s*["']?(.+?)["']?\s*$/m))?.[1]?.trim()}function tk(e){let t=new Set;for(let r of e.matchAll(/^\s*-\s*type:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}for(let r of e.matchAll(/^\s*template:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}return[...t].sort()}var aT=new Set(Vs),cT=new Set(js);var nk=/^(unknown|unlicensed|none|n\/?a)$/i;function $i(e){let t=e?.trim();if(!t||nk.test(t))return;return t}var ik="uibot.resource.index.v1";class ze extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceIndexError"}}function G(e,t){return e<t?-1:e>t?1:0}function M(e){return e.normalize("NFKC").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim().replace(/\s+/g," ")}function ok(e){let t=M(e).replace(/ /g,"-");if(!t)throw new ze("invalid-resource-source-id",e);return t}function ce(e,t){return`${e}:${ok(t)}`}function Yr(e){let t=new Map;for(let r of e){let n=r?.trim();if(!n)continue;let i=M(n);if(!i||t.has(i))continue;t.set(i,n)}return[...t.entries()].sort(([r],[n])=>G(r,n)).map(([,r])=>r)}function At(e){return{level:"declared",maturity:"experimental",checks:{source:"declared",license:e?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"},evidence:[]}}function sk(e){let t=$i(e.license);return{type:e.type,id:e.id,...e.version?{version:e.version}:{},...e.url?{url:e.url}:{},...t?{license:t}:{}}}function Et(e){return{id:e.id,kind:e.kind,title:e.title,description:e.description,...e.category?{category:e.category}:{},tags:Yr(e.tags),aliases:Yr(e.aliases),capabilities:Yr(e.capabilities),dependencies:[...new Set(e.dependencies)].sort(G),source:sk(e.source),receipt:e.receipt}}function ak(e){return(e.body.split(/\r?\n/).map((r)=>r.replace(/^#+\s*/,"").trim()).find(Boolean)??e.title).slice(0,240)}function ck(e){return Object.freeze(e.tags),Object.freeze(e.aliases),Object.freeze(e.capabilities),Object.freeze(e.dependencies),Object.freeze(e.source),Object.freeze(e.receipt.checks),Object.freeze(e.receipt.evidence),Object.freeze(e.receipt),Object.freeze(e)}function lk(e){let t=new Map;for(let r of Object.keys(e).sort(G)){let n=e[r];if(!n)continue;let i=ce("component",r);for(let o of Yr([r,n.name])){let s=M(o),a=t.get(s)??[];if(!a.includes(i))a.push(i);t.set(s,a.sort(G))}}return t}function uk(e,t,r){let n=r.get(M(e))??[];if(n.length===0)throw new ze("dangling-resource-dependency",`${t} -> ${ce("component",e)}`);if(n.length>1)throw new ze("ambiguous-resource-dependency",`${t} -> ${e}: ${n.join(",")}`);return n[0]}function dk(e,t,r,n){let i=e.startsWith("template:")?e.slice(9):e;if(Object.hasOwn(n,i))return ce("template",i);return uk(e,t,r)}function Pt(e,t,r){return $i(r?.[e]??t)}function Al(e){return Object.entries(e).filter(([,t])=>t.level==="L4").sort(([t],[r])=>G(t,r)).map(([t,r])=>({id:`${t}-example`,title:`${r.name} Example`,description:r.description,category:r.category,tags:r.keywords,aliases:[`${t} example`,`${r.name} example`],capabilities:["example:template"],dependencies:[ce("template",t)]}))}function El(e){let t=e.components??{},r=e.templates??{},n=e.designGuides??[],i=e.examples??[],o=e.skills??[],s=e.licenses,a=lk(t),c=[];for(let u of Object.keys(t).sort(G)){let m=t[u];if(!m)continue;let f=ce("component",u),y=Pt(f,void 0,s);c.push(Et({id:f,kind:"component",title:m.name,description:m.description,category:m.category,tags:m.tags??[],aliases:[u,m.name],capabilities:["catalog:component"],dependencies:[],source:{type:"catalog",id:u,...y?{license:y}:{}},receipt:At(Boolean(y))}))}for(let u of Object.keys(r).sort(G)){let m=r[u];if(!m)continue;let f=ce("template",u),y=Pt(f,void 0,s);c.push(Et({id:f,kind:"template",title:m.name,description:m.description,category:m.category,tags:m.keywords,aliases:[u,m.name],capabilities:[],dependencies:(m.composedFrom??[]).map((S)=>dk(S,f,a,r)),source:{type:"template-contract",id:u,...y?{license:y}:{}},receipt:At(Boolean(y))}))}for(let u of[...n].sort((m,f)=>G(m.id,f.id))){let m=ce("design-guide",u.id),f=Pt(m,void 0,s);c.push(Et({id:m,kind:"design-guide",title:u.title,description:ak(u),category:u.category,tags:u.tags,aliases:[u.id,u.title],capabilities:["designMd:source"],dependencies:[],source:{type:"design-md",id:u.id,...u.sourceUrl?{url:u.sourceUrl}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}for(let u of[...i].sort((m,f)=>G(m.id,f.id))){let m=ce("example",u.id),f=Pt(m,u.license,s);c.push(Et({id:m,kind:"example",title:u.title,description:u.description,...u.category?{category:u.category}:{},tags:u.tags??[],aliases:[u.id,u.title,...u.aliases??[]],capabilities:u.capabilities??[],dependencies:u.dependencies??[],source:{type:"example",id:u.id,...u.version?{version:u.version}:{},...u.sourceUrl?{url:u.sourceUrl}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}for(let u of[...o].sort((m,f)=>G(m.id,f.id))){let m=ce("skill",u.id),f=Pt(m,void 0,s);c.push(Et({id:m,kind:"skill",title:u.title,description:u.description?.trim()||u.title,tags:[...u.tags??[],...u.triggers??[]],aliases:[u.id,u.title,...u.triggers??[]],capabilities:["skill:definition"],dependencies:[],source:{type:"skill",id:u.id,...u.version?{version:u.version}:{},...f?{license:f}:{}},receipt:At(Boolean(f))}))}c.sort((u,m)=>G(u.id,m.id));let l=new Set;for(let u of c){if(l.has(u.id))throw new ze("duplicate-resource-id",u.id);l.add(u.id)}for(let u of c)for(let m of u.dependencies)if(!l.has(m))throw new ze("dangling-resource-dependency",`${u.id} -> ${m}`);let p=new Map;for(let u of c)for(let m of u.aliases){let f=M(m);if(!f)continue;let y=p.get(f)??new Set;y.add(u.id),p.set(f,y)}let g=Object.freeze(Object.fromEntries([...p.entries()].sort(([u],[m])=>G(u,m)).map(([u,m])=>[u,Object.freeze([...m].sort(G))]))),d=Object.freeze(c.map(ck));return Object.freeze({schemaVersion:ik,resources:d,aliases:g})}var pk=[["data table","data grid","datatable","table","表格","数据表","数据表格"],["button","action button","按钮","操作按钮"],["dashboard","admin dashboard","仪表盘","后台","管理后台"],["kanban","kanban board","看板","任务看板"],["form","input form","表单","输入表单"],["navigation","nav","sidebar","导航","侧边栏"]],gk=Object.freeze(pk.map((e)=>Object.freeze([...e]))),Pl=new Map;for(let e of gk){let t=Object.freeze([...new Set(e.map(M).filter(Boolean))].sort());for(let r of t)Pl.set(r,t)}function qi(e){let t=M(e);return Pl.get(t)??Object.freeze([t])}class ve extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceQueryError"}}var Vi=Object.freeze({"exact-id":1000,"exact-title":900,alias:800,tag:600,capability:500,category:400,token:200,fuzzy:100}),fk=Object.freeze(Object.keys(Vi)),Tl=new Map(fk.map((e,t)=>[e,t])),Ol=new Map([["component",0],["template",1],["design-guide",2],["example",3],["skill",4]]);function K(e,t){return e<t?-1:e>t?1:0}function Dl(e){return new Set((e??[]).map(M).filter(Boolean))}function Fi(e,t){let r=Dl(t);if(r.size===0)return!0;let n=Dl(e);return[...r].some((i)=>n.has(i))}function mk(e,t){if(t.kinds?.length&&!t.kinds.includes(e.kind))return!1;if(!Fi(e.tags,t.tags))return!1;if(!Fi(e.category?[e.category]:[],t.categories))return!1;if(!Fi(e.capabilities,t.capabilities))return!1;if(t.maturities?.length&&!t.maturities.includes(e.receipt.maturity))return!1;return!0}function yk(e){return Boolean(e.kinds?.length||e.tags?.length||e.categories?.length||e.capabilities?.length||e.maturities?.length)}function le(e,t,r,n=Vi[t]){if(e.some((i)=>i.code===t&&i.value===r))return;e.push({code:t,value:r,score:n})}function Ui(e,t){return e.find((r)=>M(r)===t)}function ji(e){return[e.id,e.title,...e.aliases,...e.tags,...e.category?[e.category]:[],...e.capabilities]}function hk(e,t,r){if(Math.abs(e.length-t.length)>r)return r+1;let n=Array.from({length:t.length+1},(i,o)=>o);for(let i=1;i<=e.length;i+=1){let o=[i],s=i;for(let a=1;a<=t.length;a+=1){let c=(n[a-1]??r+1)+(e[i-1]===t[a-1]?0:1),l=Math.min((n[a]??r+1)+1,(o[a-1]??r+1)+1,c);o.push(l),s=Math.min(s,l)}if(s>r)return r+1;n=o}return n[t.length]??r+1}function bk(e,t){let r=M(t),n=[];if(M(e.id)===r)le(n,"exact-id",e.id);if(M(e.title)===r)le(n,"exact-title",e.title);let i=Ui(e.aliases,r);if(i)le(n,"alias",i);let o=Ui(e.tags,r);if(o)le(n,"tag",o);let s=Ui(e.capabilities,r);if(s)le(n,"capability",s);if(e.category&&M(e.category)===r)le(n,"category",e.category);if(!i){let l=qi(r).filter((g)=>g!==r),p=new Set(ji(e).map(M));if(l.some((g)=>p.has(g)))le(n,"alias",t.trim())}let a=r.split(" ").filter(Boolean),c=M(ji(e).join(" "));if(a.length>0&&a.every((l)=>c.includes(l)))le(n,"token",t.trim());if(n.length===0&&r.length>=4){let l;for(let p of ji(e)){let g=M(p);if(g.length<4)continue;let d=hk(r,g,2);if(d<=2&&(!l||d<l.distance||d===l.distance&&K(p,l.value)<0))l={value:p,distance:d}}if(l)le(n,"fuzzy",l.value,Vi.fuzzy-l.distance)}return n.sort((l,p)=>{if(l.score!==p.score)return p.score-l.score;return(Tl.get(l.code)??99)-(Tl.get(p.code)??99)||K(l.value,p.value)})}function Ll(e,t,r){if(t.has(r))return[r];let n=M(r),i=e.aliases[n];if(i?.length)return[...i];let o=new Set;for(let s of qi(n))for(let a of e.aliases[s]??[])o.add(a);return[...o].sort(K)}function Nl(e,t){return new ve("resource-alias-ambiguous",`${e.trim()}: ${t.join(",")}`)}function _l(e){let t=new Map(e.resources.map((n)=>[n.id,n]));function r(n){let i=n.trim(),o=Ll(e,t,i);if(o.length===0)throw new ve("resource-not-found",i);if(o.length>1)throw Nl(i,o);let s=o[0],a=s?t.get(s):void 0;if(!a)throw new ve("resource-not-found",i);return a}return Object.freeze({manifest:()=>e,search(n){let i=n.text?.trim()??"";if(!i&&!yk(n))throw new ve("resource-query-empty","text or filter is required");if(n.limit!==void 0&&(!Number.isInteger(n.limit)||n.limit<=0))throw new ve("resource-query-invalid-limit",String(n.limit));let o=e.resources.filter((s)=>mk(s,n)).map((s)=>{let a=i?bk(s,i):[];return{resource:s,score:a.reduce((c,l)=>c+l.score,0),reasons:a}}).filter((s)=>!i||s.reasons.length>0).sort((s,a)=>a.score-s.score||K(s.resource.id,a.resource.id));return n.limit===void 0?o:o.slice(0,n.limit)},get:r,build(n){if(n.length===0||n.every((d)=>!d.trim()))throw new ve("resource-query-empty","at least one build root is required");let i=[],o=new Set;for(let d of n){let u=d.trim(),m=Ll(e,t,u);if(m.length===0)i.push({id:u,reason:"missing-resource"});else if(m.length>1)throw Nl(u,m);else{let f=m[0];if(f)o.add(f)}}let s=new Set,a=new Set,c=new Set,l=[],p=[],g=(d,u)=>{if(s.has(d))return;if(a.has(d)){i.push({id:d,...u?{requiredBy:u}:{},reason:"dependency-cycle"});return}let m=t.get(d);if(!m){i.push({id:d,...u?{requiredBy:u}:{},reason:"missing-resource"});return}a.add(d),c.add(d);let f=[...m.dependencies].sort((y,S)=>{let w=t.get(y),k=t.get(S);return(Ol.get(w?.kind??"")??99)-(Ol.get(k?.kind??"")??99)||K(y,S)});for(let y of f)p.push({from:d,to:y,relation:"depends-on"}),g(y,d);a.delete(d),s.add(d),l.push(d)};for(let d of[...o].sort(K))g(d);return{roots:[...o].sort(K),nodes:[...c].sort(K).map((d)=>{let u=t.get(d);if(!u)throw new ve("resource-not-found",d);return{id:d,kind:u.kind,maturity:u.receipt.maturity}}),edges:p.sort((d,u)=>K(d.from,u.from)||K(d.to,u.to)),order:l,gaps:i.sort((d,u)=>K(d.id,u.id)||K(d.requiredBy??"",u.requiredBy??"")||K(d.reason,u.reason))}}})}function Ul(){return{listCatalog:()=>[...wk],getDesignMd:(e)=>{let t=Vl();if(!e)return t.map(({body:r,...n})=>n);return t.find((r)=>r.id===e)??null},listTemplates:()=>Hi().map((e)=>({name:e.name,title:e.title,description:e.description,level:e.templateContract.level,category:e.templateContract.category,composedFrom:e.templateContract.composedFrom??[]}))}}async function jl(e){let t={};if(e.spec!==void 0){let r=typeof e.spec==="string"?_i(e.spec):e.spec;if(typeof r!=="object"||r===null||!Array.isArray(r.pages))throw Error("spec must be a UIBot Spec object with a pages array");let i=await Sl(r,{components:{...Yt,...Jt},actions:{},templates:{}},{templates:Sk()});t.spec={ok:i.gaps.length===0,gaps:i.gaps,warnings:i.warnings}}if(e.html!==void 0){let r=xl({html:e.html});t.html={ok:!r.blocked,...r}}return t}function Ck(){let e=["./resources/templates","./resources/shells","../../../examples/templates","../../../examples/shells"].map((i)=>Fl(new URL(i,import.meta.url))),t=[],r=new Set,n=new Set;for(let i of e){let o=i.endsWith("shells")?"shells":"templates";if(!ql(i)||r.has(i)||n.has(o))continue;if(n.add(o),r.add(i),i.endsWith("/shells")||i.endsWith("\\shells"))t.push({dir:i,defaultLevel:"L3",defaultCategory:"feature",extraKeywords:["sidebar","app-shell","shell"]});else t.push({dir:i})}return t}var Ml,Bl,$l;function Hi(){return Ml??=Bi(Ck()),Ml}function Sk(){return Bl??=Object.fromEntries(Hi().map((e)=>[e.name,_i(e.yaml)])),Bl}function Vl(){let e=Fl(new URL("./resources/design-md",import.meta.url));return $l??=ql(e)?Wr(e):Wr(),$l}var Jr;function Hl(){if(Jr)return Jr;let e=Object.fromEntries(Hi().map((t)=>[t.name,t.templateContract]));return Jr=_l(El({components:{...Yt,...Jt},templates:e,designGuides:Vl(),examples:Al(e)})),Jr}function vk(){let e=new Map;for(let t of[...Object.values(Yt),...Object.values(Jt)]){if(e.has(t.name))throw Error(`Duplicate catalog block name '${t.name}' across the shadcn and studio catalogs`);e.set(t.name,t)}return[...e.values()].sort((t,r)=>t.name.localeCompare(r.name))}var wk=Object.freeze(vk());var Ek="This uibot-mcp process has no Hub service wired, so component generation and task status are unavailable. Embed it with createUIBotMcpServer({ service, discovery }) to enable those tools.";function Pk(){return{requestComponent:()=>Promise.reject(Error(Ek)),getTask:()=>{return},listTasks:()=>[],getTaskStatus:()=>{return}}}function Tk(e,t){let r=Object.fromEntries(Object.entries(t??{}).filter(([,n])=>n!=null));return{...e,...r}}function Ok(e={}){let t=Ws({service:e.service??Pk(),serviceAvailable:e.service!=null,discovery:Tk(Ul(),e.discovery),resourceQuery:e.resourceQuery??Hl(),validate:e.validate??jl}),r=new Rk({name:"uibot",version:"0.1.0"},{capabilities:{tools:{}}});return r.setRequestHandler(Ak,()=>({tools:t.listTools()})),r.setRequestHandler(Ik,async(n)=>{let i=n.params.arguments??{};try{let o=await t.callTool(n.params.name,i);return{content:Ys(o.content),...o.isError?{isError:!0}:{}}}catch(o){return{content:[{type:"text",text:o instanceof Error?o.message:String(o)}],isError:!0}}}),r}function Dk(e=process.argv[1],t=import.meta.url){if(!e)return!1;try{return Gl(kk(t))===Gl(e)}catch{return!1}}async function Lk(){let e=Ok();await e.connect(new xk);for(let t of["SIGINT","SIGTERM"])process.on(t,()=>{e.close().finally(()=>process.exit(0))})}if(Dk())Lk().catch((e)=>{console.error(e),process.exit(1)});export{Ok as createUIBotMcpServer,Dk as isEntryPoint,Lk as main};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibot/mcp-server",
3
- "version": "0.3.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,13 +29,13 @@
29
29
  "test": "bun test"
30
30
  },
31
31
  "devDependencies": {
32
- "@uibot/blocks-shadcn": "^0.3.0",
33
- "@uibot/blocks-studio": "^0.3.0",
34
- "@uibot/compiler": "^0.3.0",
35
- "@uibot/contracts": "^0.3.0",
36
- "@uibot/design-md": "^0.3.0",
37
- "@uibot/evaluation": "^0.3.0",
38
- "@uibot/hub-runtime": "^0.3.0",
39
- "@uibot/registry": "^0.3.0"
32
+ "@uibot/blocks-shadcn": "^0.6.0",
33
+ "@uibot/blocks-studio": "^0.6.0",
34
+ "@uibot/compiler": "^0.6.0",
35
+ "@uibot/contracts": "^0.6.0",
36
+ "@uibot/design-md": "^0.6.0",
37
+ "@uibot/evaluation": "^0.6.0",
38
+ "@uibot/hub-runtime": "^0.6.0",
39
+ "@uibot/registry": "^0.6.0"
40
40
  }
41
41
  }