aktion-runtime 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/dist/aktion.iife.js +34 -34
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +1823 -1644
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +34 -34
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/node/compile-BUw0GAvN.cjs +491 -0
- package/dist/node/compile-BUw0GAvN.cjs.map +1 -0
- package/dist/node/compile-DxttTzo8.js +492 -0
- package/dist/node/compile-DxttTzo8.js.map +1 -0
- package/dist/node/compiler.cjs +11 -0
- package/dist/node/compiler.cjs.map +1 -0
- package/dist/node/compiler.js +11 -0
- package/dist/node/compiler.js.map +1 -0
- package/dist/node/index-8OvnOYPI.js +14070 -0
- package/dist/node/index-8OvnOYPI.js.map +1 -0
- package/dist/node/index-DBgA3bHQ.cjs +14069 -0
- package/dist/node/index-DBgA3bHQ.cjs.map +1 -0
- package/dist/node/language.cjs +1244 -0
- package/dist/node/language.cjs.map +1 -0
- package/dist/node/language.js +1244 -0
- package/dist/node/language.js.map +1 -0
- package/dist/node/vite.cjs +65 -0
- package/dist/node/vite.cjs.map +1 -0
- package/dist/node/vite.js +65 -0
- package/dist/node/vite.js.map +1 -0
- package/dist/types/aktion-modules.d.ts +22 -0
- package/dist/types/compiler/compile.d.ts +54 -0
- package/dist/types/compiler/emit.d.ts +15 -0
- package/dist/types/compiler/index.d.ts +14 -0
- package/dist/types/compiler/linker.d.ts +27 -0
- package/dist/types/compiler/runtime.d.ts +63 -0
- package/dist/types/compiler/sourcemap.d.ts +40 -0
- package/dist/types/element.d.ts +36 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/language-api.d.ts +15 -0
- package/dist/types/parser/types.d.ts +38 -1
- package/dist/types/plugin/index.d.ts +10 -0
- package/dist/types/plugin/vite.d.ts +21 -0
- package/package.json +36 -5
package/dist/aktion.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(P,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(P=typeof globalThis<"u"?globalThis:P||self,pe(P.Aktion={}))})(this,function(P){"use strict";var
|
|
1
|
+
(function(P,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(P=typeof globalThis<"u"?globalThis:P||self,pe(P.Aktion={}))})(this,function(P){"use strict";var Nf=Object.defineProperty;var Mf=(P,pe,We)=>pe in P?Nf(P,pe,{enumerable:!0,configurable:!0,writable:!0,value:We}):P[pe]=We;var j=(P,pe,We)=>Mf(P,typeof pe!="symbol"?pe+"":pe,We);const pe=new Set(["function","import","export","if","else","switch","case","break","continue","for","while","do","of","in","let","var","const","await","async","return","default","try","catch","finally","throw","new","typeof","instanceof","delete","void"]),We=new Set(["(",")","[","]","{","}",",",":","?","."]),zi={true:"Boolean",false:"Boolean",null:"Null"};function Gr(t){const e=[];let r=0,a=1,n=1;const i=(u=0)=>t[r+u],o=(u,c,m,d)=>{e.push({type:u,value:c,line:m,column:d})},s=()=>{const u=t[r];return r+=1,u===`
|
|
2
2
|
`?(a+=1,n=1):n+=1,u};for(;r<t.length;){const u=i();if(u===void 0)break;if(u===`
|
|
3
3
|
`){const h=a,b=n;s(),o("Newline",`
|
|
4
4
|
`,h,b);continue}if(u===" "||u===" "||u==="\r"){s();continue}if(u==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
`;break;case"t":y+=" ";break;case"r":y+="\r";break;case"\\":y+="\\";break;case'"':y+='"';break;case"'":y+="'";break;case"`":y+="`";break;default:y+=x??""}continue}if(i()===`
|
|
7
7
|
`)break;y+=s()}i()===h&&s(),o("String",y,b,v);continue}if(u==="`"){const h=a,b=n;s();const v=[];let y="",x=!1;for(;r<t.length&&i()!=="`";){if(i()==="\\"&&i(1)!==void 0){s();const w=s();switch(w){case"n":y+=`
|
|
8
8
|
`;break;case"t":y+=" ";break;case"r":y+="\r";break;case"\\":y+="\\";break;case'"':y+='"';break;case"'":y+="'";break;case"`":y+="`";break;case"$":y+="$";break;default:y+=w??""}continue}if(i()==="$"&&i(1)==="{"){v.push({kind:"str",text:y}),y="";const w=a,k=n;s(),s();let A=1,S="";for(;r<t.length&&A>0;){const $=i();if($===void 0)break;if($==="`"){for(S+=s();r<t.length&&i()!=="`";){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}S+=s()}i()==="`"&&(S+=s());continue}if($==='"'||$==="'"){const M=$;for(S+=s();r<t.length&&i()!==M;){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}if(i()===`
|
|
9
|
-
`)break;S+=s()}i()===M&&(S+=s());continue}if($==="{"){A+=1,S+=s();continue}if($==="}"){if(A-=1,A===0){s();break}S+=s();continue}S+=s()}v.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}y+=s()}if(i()==="`"&&s(),v.push({kind:"str",text:y}),!x){o("String",y,h,b);continue}e.push({type:"TemplateString",value:"",line:h,column:b,parts:v});continue}const c=e[e.length-1],m=!c||c.type==="Newline"||c.type==="Semicolon"||c.type==="Operator"||c.type==="Punctuation"&&(c.value==="("||c.value==="["||c.value===","||c.value===":"||c.value==="?"||c.value==="{");if(et(u)||u==="-"&&et(i(1)??"")&&m){const h=a,b=n;let v="";u==="-"&&(v+=s());let y=!1;for(;r<t.length;){const x=i()??"";if(et(x)){v+=s();continue}if(x==="."&&!y&&et(i(1)??"")){y=!0,v+=s();continue}break}o("Number",v,h,b);continue}if(u==="@"){const h=new Error("Legacy `@name(...)` builtins are removed. Use `$util.<name>(...)` or the equivalent native JavaScript instead (e.g. `arr.length` for `$util.count(arr)`).");throw h.line=a,h.column=n,h}if(u==="$"){const h=a,b=n;if(s(),i()==="$"){const y=new Error('Legacy "$$x" persistent reference is removed. Reactive state is declared with "$x = value" and referenced as "$x".');throw y.line=h,y.column=b,y}let v="";for(;r<t.length&&qr(i()??"");)v+=s();o("StateIdentifier",v,h,b);continue}if(Wr(u)){const h=a,b=n;let v="";for(;r<t.length&&qr(i()??"");)v+=s();const y=Ii[v];y==="Boolean"?o("Boolean",v,h,b):y==="Null"?o("Null",v,h,b):pe.has(v)?o("Keyword",v,h,b):o("Identifier",v,h,b);continue}if(u==="."&&i(1)==="."&&i(2)==="."){const h=a,b=n;s(),s(),s(),o("Operator","...",h,b);continue}const d=u+(i(1)??""),f=d+(i(2)??""),g=f+(i(3)??"");if(g===">>>="){const h=a,b=n;s(),s(),s(),s(),o("Operator",g,h,b);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const h=a,b=n;s(),s(),s(),o("Operator",f,h,b);continue}if(d==="=="||d==="!="||d===">="||d==="<="||d==="&&"||d==="||"||d==="??"||d==="?."||d==="->"||d==="=>"||d==="**"||d==="%="||d==="+="||d==="-="||d==="*="||d==="/="||d==="++"||d==="--"||d==="<<"||d===">>"||d==="&="||d==="|="||d==="^="){const h=a,b=n;s(),s(),o("Operator",d,h,b);continue}if("+-*/%!=<>&|^~".includes(u)){const h=a,b=n;s(),o("Operator",u,h,b);continue}if(We.has(u)){const h=a,b=n;s(),o("Punctuation",u,h,b);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function et(t){return t>="0"&&t<="9"}function Wr(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function qr(t){return Wr(t)||et(t)}function $e(t){const e=Vr(t),r=new Fi(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=ht(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function ht(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return Ri(t);if(r.type==="Keyword")switch(r.value){case"function":return Yr(t);case"await":return Di(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),Yr(t);break}case"return":return Bi(t);case"let":case"const":case"var":return Jr(t);case"if":return ca(t);case"switch":return Gi(t);case"for":return Ki(t);case"while":return Xi(t);case"do":return Ji(t);case"break":return Zi(t);case"continue":return Qi(t);case"throw":return eo(t);case"try":return to(t)}const a=t.snapshot();if(Li(t))try{return Oi(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return zi(t)}function Li(t){const e=t.peek();if(e.type!=="Identifier"&&e.type!=="StateIdentifier")return!1;const r=t.peek(1);return r.type==="Operator"&&r.value==="="}function zi(t){const e=t.peek();let r=_(t);const a=t.peek();if(a.type==="Operator"&&Gr(a.value)){if(Kr(r)){t.consume();const n=_(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,n,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}}}}else a.type==="Operator"&&(a.value==="++"||a.value==="--")&&Kr(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}});return ae(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function Gr(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function Kr(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function Yr(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=Xr(t),i=Ee(t);return ae(t),r?{kind:"HookDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}:a.value.length>0&&a.value[0]>="A"&&a.value[0]<="Z"?{kind:"ComponentDeclaration",name:a.value,params:n,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:a.value,params:n,optimistic:!1,body:i,loc:{line:e.line,column:e.column}}}function Xr(t){t.expect("Punctuation","(");const e=[];if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){z(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const a=t.peek();if(!r&&a.type==="Punctuation"&&(a.value==="{"||a.value==="[")){const n=Wt(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=_(t));const o={name:"",pattern:n};i&&(o.defaultValue=i),e.push(o)}else if(a.type==="Identifier"||a.type==="Keyword"){const n=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=_(t));const o={name:n.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${a.type} "${a.value}"`,line:a.line,column:a.column};if(z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(r)throw{message:"Rest parameter `...name` must be the final parameter.",line:t.peek().line,column:t.peek().column};if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function Ri(t){const e=t.consume();t.expect("Punctuation","("),z(t);const r=_(t);let a;r.kind==="Lambda"?a=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:a={kind:"Block",body:[]};const n=[];let i;if(z(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)Ei(t,n,s=>{i=s}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t));t.expect("Punctuation","]")}else _(t);z(t),t.expect("Punctuation",")"),ae(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:n,body:a,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function Ei(t,e,r){const a=t.peek();if(a.type==="StateIdentifier"){t.consume();let n=a.value;for(;t.peek().type==="Punctuation"&&t.peek().value===".";){const i=t.peek(1);if(i.type!=="Identifier"&&i.type!=="Keyword")break;t.consume(),t.consume(),n+="."+i.value}e.push({kind:"state",name:n});return}if(a.type==="String"){t.consume();const n=a.value;if(n==="mount"||n==="unmount"){e.push({kind:"lifecycle",name:n});return}const i=n.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=n.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=n.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${n}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:a.line,column:a.column}}throw{message:`Unexpected ${a.type} "${a.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:a.line,column:a.column}}function Jr(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return ji(t,e);let a="",n=!1;if(r.type==="StateIdentifier")a=t.consume().value,n=!0;else if(r.type==="Identifier")a=t.consume().value;else throw{message:`Expected identifier after "${e.value}", got ${r.type} "${r.value}"`,line:r.line,column:r.column};t.expect("Operator","=");const i=_(t);return ae(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function ji(t,e){const r=Wt(t);t.expect("Operator","=");const a=_(t);return ae(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function Wt(t){const r=t.consume().value==="["?"array":"object",a=[];if(r==="array"){for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){a.push({name:""}),t.consume(),z(t);continue}let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=_(t));const s={name:i.value};if(n&&(s.rest=!0),o&&(s.defaultValue=o),a.push(s),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","]")}else{for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o=i.value,s;if(!n&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const m=t.expect("Identifier");s=i.value,o=m.value}let u;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),u=_(t));const c={name:o};if(s&&(c.sourceKey=s),n&&(c.rest=!0),u&&(c.defaultValue=u),a.push(c),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function Ee(t){const e=t.expect("Punctuation","{"),r=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=ht(t);a&&r.push(a),z(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function qe(t){if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return Ee(t);const e=t.peek(),r=ht(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function Di(t){const e=t.expect("Keyword","await"),r=_(t);return ae(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function Bi(t){const e=t.expect("Keyword","return");let r;const a=t.peek();return a.type!=="Newline"&&a.type!=="Semicolon"&&!(a.type==="Punctuation"&&a.value==="}")&&(r=_(t)),ae(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class Fi{constructor(e){D(this,"index",0);this.tokens=e}isEnd(){return this.peek().type==="EOF"}peek(e=0){return this.tokens[this.index+e]??{type:"EOF",value:"",line:0,column:0}}consume(){const e=this.tokens[this.index]??{type:"EOF",value:"",line:0,column:0};return this.index+=1,e}match(e,r){const a=this.peek();return a.type!==e||r!==void 0&&a.value!==r?!1:(this.consume(),!0)}expect(e,r){const a=this.peek();if(a.type!==e||r!==void 0&&a.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${a.type} "${a.value}"`,line:a.line,column:a.column};return this.consume()}recoverToNextLine(){for(;!this.isEnd()&&this.peek().type!=="Newline"&&this.peek().type!=="Semicolon";)this.consume();(this.peek().type==="Newline"||this.peek().type==="Semicolon")&&this.consume()}snapshot(){return this.index}restore(e){this.index=e}}function Oi(t){const e=t.peek();let r="",a=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,a=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const n=t.expect("Operator","="),i=_(t);return ae(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function _(t){return Ui(t)}function _i(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function ue(t,e){const{token:r,skipped:a}=_i(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function Ui(t){const e=Hi(t);if(ue(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),z(t);const r=_(t);z(t),t.expect("Punctuation",":"),z(t);const a=_(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function Hi(t){let e=Zr(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;z(t);const a=Zr(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Zr(t){let e=Qr(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),z(t);const r=Qr(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Qr(t){let e=ea(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),z(t);const r=ea(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function ea(t){let e=ta(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),z(t);const r=ta(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function ta(t){let e=ra(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),z(t);const r=ra(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function ra(t){let e=aa(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;z(t);const a=aa(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function aa(t){let e=qt(t);for(;;){if(ue(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;z(t);const a=qt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(ue(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;z(t);const a=qt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function qt(t){let e=na(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;z(t);const a=na(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function na(t){let e=ia(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;z(t);const a=ia(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ia(t){let e=Gt(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;z(t);const a=Gt(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Gt(t){const e=tt(t);if(ue(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),z(t);const r=Gt(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function tt(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=tt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="await")return t.consume(),{kind:"BuiltinCall",name:"__rui_await__",arguments:[tt(t)],loc:{line:e.line,column:e.column}};if(e.type==="Operator"&&(e.value==="++"||e.value==="--"))return t.consume(),{kind:"BuiltinCall",name:"__rui_prefix__",arguments:[tt(t),{kind:"Literal",value:e.value}],loc:{line:e.line,column:e.column}};if(e.type==="Keyword"&&(e.value==="typeof"||e.value==="void"||e.value==="delete")){t.consume();const r=tt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=sa(t),a=[];if(r.kind==="Call")a=r.arguments,r={kind:"Identifier",name:r.callee,loc:r.loc};else{for(;;){const i=t.peek();if(i.type==="Punctuation"&&i.value==="."){t.consume();const o=t.consume();if(o.type!=="Identifier"&&o.type!=="Keyword")throw{message:`Expected Identifier but got ${o.type} "${o.value}"`,line:o.line,column:o.column};r={kind:"Member",object:r,property:o.value};continue}if(i.type==="Punctuation"&&i.value==="["){t.consume();const o=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Te(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return oa(t,n)}return Vi(t)}function Vi(t){const e=Wi(t),r=t.peek();return r.type==="Operator"&&(r.value==="++"||r.value==="--")?(t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}):e}function Wi(t){return oa(t,sa(t))}function oa(t,e){let r=e;for(;;){ue(t,n=>n.type==="Punctuation"&&n.value==="."||n.type==="Operator"&&n.value==="?.");const a=t.peek();if(a.type==="Punctuation"&&a.value==="."){t.consume();const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Te(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value};continue}if(a.type==="Operator"&&a.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const n=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const n=Te(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,optional:!0,loc:{line:a.line,column:a.column}}}else{const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Te(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,optional:!0,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value,optional:!0}}continue}if(a.type==="Punctuation"&&a.value==="["){t.consume();const n=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Te(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function sa(t){const e=t.peek();if(e.type==="Keyword"&&(e.value==="if"||e.value==="for"||e.value==="switch"||e.value==="while"||e.value==="try")){const r=e.value==="if"?"Use the ternary operator (`cond ? a : b`) when you need a value.":e.value==="for"?"Use `arr.map(x => …)` (or `.filter`, `.reduce`, …) to collect bodies into an array.":e.value==="switch"?"Use chained ternaries, an object lookup, or wrap the switch inside a `function`.":`Use the ${e.value} statement inside a function / effect body.`,a={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw a.__definitive=!0,a}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),a=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&a.type==="Punctuation"&&a.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=Xr(t),s=Ee(t);return{kind:"Lambda",params:o,body:s,loc:{line:i.line,column:i.column}}}}if(e.value==="function"||e.value==="let"||e.value==="const"||e.value==="var"||e.value==="of"||e.value==="in"||e.value==="case"||e.value==="break"||e.value==="continue"||e.value==="default"){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}}if(e.type==="Number")return t.consume(),{kind:"Literal",value:Number(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],a=[],n=[];let i="",o=!1;const s=()=>{a.push(i),i="",o=!1};for(const u of r){if(u.kind==="str"){i+=u.text,o=!0;continue}o?s():a.push("");const m=$e(`__rui_tmpl__ = ${u.source}`).statements[0];m&&m.kind==="Assignment"?n.push(m.expression):n.push({kind:"Literal",value:""})}for((o||a.length===0)&&a.push(i);a.length<=n.length;)a.push("");return{kind:"Template",quasis:a,expressions:n,loc:{line:e.line,column:e.column}}}if(e.type==="Boolean")return t.consume(),{kind:"Literal",value:e.value==="true"};if(e.type==="Null")return t.consume(),{kind:"Literal",value:null};if(e.type==="StateIdentifier")return e.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="("?(t.consume(),qi(t,e)):(t.consume(),{kind:"StateRef",name:e.value});if(e.type==="Identifier"){if(t.consume(),t.peek().type==="Operator"&&t.peek().value==="=>"){t.consume();const r=ua(t);return{kind:"Lambda",params:[{name:e.value}],body:r,loc:{line:e.line,column:e.column}}}if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}if(e.type==="Punctuation"&&e.value==="["){t.consume();const r=Te(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=ao(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=ro(t);if(a)return a;t.restore(r),t.consume();const n=_(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function qi(t,e){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Te(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(la(t)),z(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(la(t)),z(t);return z(t),e}function la(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:_(t),loc:{line:e.line,column:e.column}}}return _(t)}function ca(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(t);let n;return z(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),z(t),t.peek().type==="Keyword"&&t.peek().value==="if"?n=ca(t):n=qe(t)),ae(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function Gi(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const a=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),n=_(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),n=null;else throw{message:`Expected "case" or "default" in switch body, got ${t.peek().type} "${t.peek().value}"`,line:t.peek().line,column:t.peek().column};t.expect("Punctuation",":"),z(t);const i=[];for(;!t.isEnd()&&!(t.peek().type==="Keyword"&&(t.peek().value==="case"||t.peek().value==="default"))&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const o=ht(t);o&&i.push(o),z(t)}a.push({test:n,body:i}),z(t)}return t.expect("Punctuation","}"),ae(t),{kind:"SwitchStatement",discriminant:r,cases:a,loc:{line:e.line,column:e.column}}}function Ki(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),z(t);const r=t.snapshot();let a="for-of";{let c=1,m=0;for(;;){const d=t.peek(m);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")c+=1;else if(d.type==="Punctuation"&&d.value===")"){if(c-=1,c===0)break}else if(c===1&&d.type==="Semicolon"){a="classic";break}else if(c===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(c===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}m+=1}}if(t.restore(r),a==="classic")return Yi(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),z(t);let n,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),n=t.expect("Identifier").value,t.expect("Punctuation",","),i=t.expect("Identifier").value,t.expect("Punctuation","]");else if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const c=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)c.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=c}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=_(t);t.expect("Punctuation",")");const u=qe(t);return ae(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:u,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:u,loc:{line:e.line,column:e.column}}}function Yi(t,e){let r;if(t.peek().type!=="Semicolon")if(t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")){const o=Jr(t);o.kind==="Assignment"&&(r=o),z(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:_(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),z(t)}else t.expect("Semicolon"),z(t);let a;t.peek().type!=="Semicolon"&&(a=_(t)),t.expect("Semicolon"),z(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=da(t)),t.expect("Punctuation",")");const i=qe(t);return ae(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function Xi(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(t);return ae(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function Ji(t){const e=t.expect("Keyword","do"),r=qe(t);z(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=_(t);return t.expect("Punctuation",")"),ae(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function Zi(t){const e=t.expect("Keyword","break");return ae(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function Qi(t){const e=t.expect("Keyword","continue");return ae(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function eo(t){const e=t.expect("Keyword","throw"),r=_(t);return ae(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function to(t){const e=t.expect("Keyword","try"),r=Ee(t);let a,n,i;return z(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(a=t.consume().value),t.expect("Punctuation",")")),n=Ee(t),z(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=Ee(t)),ae(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function ro(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){z(t);let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.peek();if(!n&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=Wt(t)}catch{return null}const u={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{u.defaultValue=_(t)}catch{return null}}if(r.push(u),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}if(i.type!=="Identifier")return null;t.consume();const o={name:i.value};if(n&&(o.rest=!0),!n&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=_(t)}catch{return null}}if(r.push(o),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(n)return null;t.consume();continue}break}if(z(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const a=ua(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function ua(t){return z(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?Ee(t):da(t)}function da(t){const e=_(t),r=t.peek();if(r.type==="Operator"){if(Gr(r.value)){t.consume();const a=_(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,a,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}if(r.value==="++"||r.value==="--")return t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}return e}function ao(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){z(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const u=_(t);if(e.push({key:"",value:u,spread:!0}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let a,n;if(r.type==="Punctuation"&&r.value==="[")t.consume(),z(t),n=_(t),z(t),t.expect("Punctuation","]"),a="";else if(r.type==="Number")a=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")a=t.consume().value;else throw{message:`Expected object key, got ${r.type} "${r.value}"`,line:r.line,column:r.column};const i=t.peek();let o;!n&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:a,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=_(t));const s={key:a,value:o};if(n&&(s.computedKey=n),e.push(s),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),z(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return z(t),e}function z(t){for(;t.match("Newline")||t.match("Semicolon"););}function ae(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function no(t){const e=$e(t);return pa(t,e)}function pa(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const u=s.loc?.line??0;if(r.has(u)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(m=>m.line)),u=oo(t,s);i=u.before,o=u.after;const c=a.findIndex(m=>(m.loc?.line??0)>=s);if(c>=0)for(const m of a.splice(c))n.push(m)}return{committedSource:i,draftingSource:o,committedBindings:a.map(ma).filter(s=>s!==null),uncommittedBindings:n.map(ma).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function io(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const a of e)if(!r.has(a))return!1;return!0}function ma(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function oo(t,e){if(e<=1)return{before:"",after:t};let r=0,a=1;for(;r<t.length&&a<e;)t[r]===`
|
|
10
|
-
`&&(a+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}function
|
|
9
|
+
`)break;S+=s()}i()===M&&(S+=s());continue}if($==="{"){A+=1,S+=s();continue}if($==="}"){if(A-=1,A===0){s();break}S+=s();continue}S+=s()}v.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}y+=s()}if(i()==="`"&&s(),v.push({kind:"str",text:y}),!x){o("String",y,h,b);continue}e.push({type:"TemplateString",value:"",line:h,column:b,parts:v});continue}const c=e[e.length-1],m=!c||c.type==="Newline"||c.type==="Semicolon"||c.type==="Operator"||c.type==="Punctuation"&&(c.value==="("||c.value==="["||c.value===","||c.value===":"||c.value==="?"||c.value==="{");if(et(u)||u==="-"&&et(i(1)??"")&&m){const h=a,b=n;let v="";u==="-"&&(v+=s());let y=!1;for(;r<t.length;){const x=i()??"";if(et(x)){v+=s();continue}if(x==="."&&!y&&et(i(1)??"")){y=!0,v+=s();continue}break}o("Number",v,h,b);continue}if(u==="@"){const h=new Error("Legacy `@name(...)` builtins are removed. Use `$util.<name>(...)` or the equivalent native JavaScript instead (e.g. `arr.length` for `$util.count(arr)`).");throw h.line=a,h.column=n,h}if(u==="$"){const h=a,b=n;if(s(),i()==="$"){const y=new Error('Legacy "$$x" persistent reference is removed. Reactive state is declared with "$x = value" and referenced as "$x".');throw y.line=h,y.column=b,y}let v="";for(;r<t.length&&Yr(i()??"");)v+=s();o("StateIdentifier",v,h,b);continue}if(Kr(u)){const h=a,b=n;let v="";for(;r<t.length&&Yr(i()??"");)v+=s();const y=zi[v];y==="Boolean"?o("Boolean",v,h,b):y==="Null"?o("Null",v,h,b):pe.has(v)?o("Keyword",v,h,b):o("Identifier",v,h,b);continue}if(u==="."&&i(1)==="."&&i(2)==="."){const h=a,b=n;s(),s(),s(),o("Operator","...",h,b);continue}const d=u+(i(1)??""),f=d+(i(2)??""),g=f+(i(3)??"");if(g===">>>="){const h=a,b=n;s(),s(),s(),s(),o("Operator",g,h,b);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const h=a,b=n;s(),s(),s(),o("Operator",f,h,b);continue}if(d==="=="||d==="!="||d===">="||d==="<="||d==="&&"||d==="||"||d==="??"||d==="?."||d==="->"||d==="=>"||d==="**"||d==="%="||d==="+="||d==="-="||d==="*="||d==="/="||d==="++"||d==="--"||d==="<<"||d===">>"||d==="&="||d==="|="||d==="^="){const h=a,b=n;s(),s(),o("Operator",d,h,b);continue}if("+-*/%!=<>&|^~".includes(u)){const h=a,b=n;s(),o("Operator",u,h,b);continue}if(We.has(u)){const h=a,b=n;s(),o("Punctuation",u,h,b);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function et(t){return t>="0"&&t<="9"}function Kr(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function Yr(t){return Kr(t)||et(t)}function Ce(t){const e=Gr(t),r=new Ui(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=ht(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function ht(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return ji(t);if(r.type==="Keyword")switch(r.value){case"function":return bt(t);case"import":return Hi(t);case"export":return Vi(t);case"await":return Oi(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),bt(t);break}case"return":return _i(t);case"let":case"const":case"var":return qt(t);case"if":return pa(t);case"switch":return Ji(t);case"for":return Zi(t);case"while":return eo(t);case"do":return to(t);case"break":return ro(t);case"continue":return ao(t);case"throw":return no(t);case"try":return io(t)}const a=t.snapshot();if(Xr(t))try{return ea(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return Di(t)}function Xr(t){const e=t.peek();if(e.type!=="Identifier"&&e.type!=="StateIdentifier")return!1;const r=t.peek(1);return r.type==="Operator"&&r.value==="="}function Di(t){const e=t.peek();let r=_(t);const a=t.peek();if(a.type==="Operator"&&Jr(a.value)){if(Zr(r)){t.consume();const n=_(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,n,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}}}}else a.type==="Operator"&&(a.value==="++"||a.value==="--")&&Zr(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:a.value}],loc:{line:a.line,column:a.column}});return re(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function Jr(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function Zr(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function bt(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=Qr(t),i=ze(t);return re(t),r?{kind:"HookDeclaration",name:a.value,params:n,body:i,loc:{line:e.line,column:e.column}}:a.value.length>0&&a.value[0]>="A"&&a.value[0]<="Z"?{kind:"ComponentDeclaration",name:a.value,params:n,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:a.value,params:n,optimistic:!1,body:i,loc:{line:e.line,column:e.column}}}function Qr(t){t.expect("Punctuation","(");const e=[];if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){R(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const a=t.peek();if(!r&&a.type==="Punctuation"&&(a.value==="{"||a.value==="[")){const n=Gt(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=_(t));const o={name:"",pattern:n};i&&(o.defaultValue=i),e.push(o)}else if(a.type==="Identifier"||a.type==="Keyword"){const n=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=_(t));const o={name:n.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${a.type} "${a.value}"`,line:a.line,column:a.column};if(R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(r)throw{message:"Rest parameter `...name` must be the final parameter.",line:t.peek().line,column:t.peek().column};if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function ji(t){const e=t.consume();t.expect("Punctuation","("),R(t);const r=_(t);let a;r.kind==="Lambda"?a=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:a={kind:"Block",body:[]};const n=[];let i;if(R(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)Bi(t,n,s=>{i=s}),R(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),R(t));t.expect("Punctuation","]")}else _(t);R(t),t.expect("Punctuation",")"),re(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:n,body:a,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function Bi(t,e,r){const a=t.peek();if(a.type==="StateIdentifier"){t.consume();let n=a.value;for(;t.peek().type==="Punctuation"&&t.peek().value===".";){const i=t.peek(1);if(i.type!=="Identifier"&&i.type!=="Keyword")break;t.consume(),t.consume(),n+="."+i.value}e.push({kind:"state",name:n});return}if(a.type==="String"){t.consume();const n=a.value;if(n==="mount"||n==="unmount"){e.push({kind:"lifecycle",name:n});return}const i=n.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=n.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=n.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${n}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:a.line,column:a.column}}throw{message:`Unexpected ${a.type} "${a.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:a.line,column:a.column}}function qt(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return Fi(t,e);let a="",n=!1;if(r.type==="StateIdentifier")a=t.consume().value,n=!0;else if(r.type==="Identifier")a=t.consume().value;else throw{message:`Expected identifier after "${e.value}", got ${r.type} "${r.value}"`,line:r.line,column:r.column};t.expect("Operator","=");const i=_(t);return re(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function Fi(t,e){const r=Gt(t);t.expect("Operator","=");const a=_(t);return re(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function Gt(t){const r=t.consume().value==="["?"array":"object",a=[];if(r==="array"){for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){a.push({name:""}),t.consume(),R(t);continue}let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=_(t));const s={name:i.value};if(n&&(s.rest=!0),o&&(s.defaultValue=o),a.push(s),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),R(t);continue}break}t.expect("Punctuation","]")}else{for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.expect("Identifier");let o=i.value,s;if(!n&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const m=t.expect("Identifier");s=i.value,o=m.value}let u;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),u=_(t));const c={name:o};if(s&&(c.sourceKey=s),n&&(c.rest=!0),u&&(c.defaultValue=u),a.push(c),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),R(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function ze(t){const e=t.expect("Punctuation","{"),r=[];for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=ht(t);a&&r.push(a),R(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function qe(t){if(R(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return ze(t);const e=t.peek(),r=ht(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function Oi(t){const e=t.expect("Keyword","await"),r=_(t);return re(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function _i(t){const e=t.expect("Keyword","return");let r;const a=t.peek();return a.type!=="Newline"&&a.type!=="Semicolon"&&!(a.type==="Punctuation"&&a.value==="}")&&(r=_(t)),re(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class Ui{constructor(e){j(this,"index",0);this.tokens=e}isEnd(){return this.peek().type==="EOF"}peek(e=0){return this.tokens[this.index+e]??{type:"EOF",value:"",line:0,column:0}}consume(){const e=this.tokens[this.index]??{type:"EOF",value:"",line:0,column:0};return this.index+=1,e}match(e,r){const a=this.peek();return a.type!==e||r!==void 0&&a.value!==r?!1:(this.consume(),!0)}expect(e,r){const a=this.peek();if(a.type!==e||r!==void 0&&a.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${a.type} "${a.value}"`,line:a.line,column:a.column};return this.consume()}recoverToNextLine(){for(;!this.isEnd()&&this.peek().type!=="Newline"&&this.peek().type!=="Semicolon";)this.consume();(this.peek().type==="Newline"||this.peek().type==="Semicolon")&&this.consume()}snapshot(){return this.index}restore(e){this.index=e}}function ea(t){const e=t.peek();let r="",a=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,a=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const n=t.expect("Operator","="),i=_(t);return re(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function Hi(t){const e=t.expect("Keyword","import");t.expect("Punctuation","{");const r=[];for(;!t.isEnd()&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const i=t.peek();let o,s=!1;if(i.type==="StateIdentifier")o=t.consume().value,s=!0;else if(i.type==="Identifier")o=t.consume().value;else throw{message:`Expected an import name, got ${i.type} "${i.value}"`,line:i.line,column:i.column};let u=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const c=t.peek();let m=!1;if(c.type==="StateIdentifier")u=t.consume().value,m=!0;else if(c.type==="Identifier")u=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${c.type} "${c.value}"`,line:c.line,column:c.column};if(m!==s)throw{message:"A `$state` import must keep its `$` across `as` (e.g. `{ $x as $y }`); a non-state import must not gain one.",line:c.line,column:c.column}}if(r.push(s?{imported:o,local:u,isState:!0}:{imported:o,local:u}),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}t.expect("Punctuation","}");const a=t.peek();if(!(a.type==="Identifier"&&a.value==="from"))throw{message:`Expected \`from\` after import specifiers, got ${a.type} "${a.value}"`,line:a.line,column:a.column};t.consume();const n=t.expect("String");return re(t),{kind:"Import",specifiers:r,source:n.value,loc:{line:e.line,column:e.column}}}function Vi(t){const e=t.expect("Keyword","export"),r=t.peek();if(r.type==="Punctuation"&&r.value==="{")throw{message:"`export { … }` lists are not supported yet — use inline `export <declaration>` (e.g. `export function Foo() {…}`, `export $count = 0`).",line:r.line,column:r.column};let a;if(r.type==="Keyword"&&r.value==="function")a=bt(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),a=bt(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(a=qt(t),a&&a.kind==="DestructureStatement")throw{message:"`export` of a destructuring declaration is not supported — export named bindings individually.",line:r.line,column:r.column}}else if(Xr(t))a=ea(t);else throw{message:"`export` must be followed by a declaration or assignment (`export function …`, `export let x = …`, `export $state = …`).",line:r.line,column:r.column};if(a&&(a.kind==="Assignment"||a.kind==="ComponentDeclaration"||a.kind==="ActionDeclaration"||a.kind==="HookDeclaration"))return a.exported=!0,a;throw{message:"`export` must be followed by a declaration or assignment.",line:e.line,column:e.column}}function _(t){return qi(t)}function Wi(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function ue(t,e){const{token:r,skipped:a}=Wi(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function qi(t){const e=Gi(t);if(ue(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),R(t);const r=_(t);R(t),t.expect("Punctuation",":"),R(t);const a=_(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function Gi(t){let e=ta(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;R(t);const a=ta(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ta(t){let e=ra(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),R(t);const r=ra(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function ra(t){let e=aa(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),R(t);const r=aa(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function aa(t){let e=na(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),R(t);const r=na(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function na(t){let e=ia(t);for(;ue(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),R(t);const r=ia(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function ia(t){let e=oa(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;R(t);const a=oa(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function oa(t){let e=Kt(t);for(;;){if(ue(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;R(t);const a=Kt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(ue(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;R(t);const a=Kt(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function Kt(t){let e=sa(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;R(t);const a=sa(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function sa(t){let e=la(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;R(t);const a=la(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function la(t){let e=Yt(t);for(;ue(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;R(t);const a=Yt(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function Yt(t){const e=tt(t);if(ue(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),R(t);const r=Yt(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function tt(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=tt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="await")return t.consume(),{kind:"BuiltinCall",name:"__rui_await__",arguments:[tt(t)],loc:{line:e.line,column:e.column}};if(e.type==="Operator"&&(e.value==="++"||e.value==="--"))return t.consume(),{kind:"BuiltinCall",name:"__rui_prefix__",arguments:[tt(t),{kind:"Literal",value:e.value}],loc:{line:e.line,column:e.column}};if(e.type==="Keyword"&&(e.value==="typeof"||e.value==="void"||e.value==="delete")){t.consume();const r=tt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=ua(t),a=[];if(r.kind==="Call")a=r.arguments,r={kind:"Identifier",name:r.callee,loc:r.loc};else{for(;;){const i=t.peek();if(i.type==="Punctuation"&&i.value==="."){t.consume();const o=t.consume();if(o.type!=="Identifier"&&o.type!=="Keyword")throw{message:`Expected Identifier but got ${o.type} "${o.value}"`,line:o.line,column:o.column};r={kind:"Member",object:r,property:o.value};continue}if(i.type==="Punctuation"&&i.value==="["){t.consume();const o=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Te(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return ca(t,n)}return Ki(t)}function Ki(t){const e=Yi(t),r=t.peek();return r.type==="Operator"&&(r.value==="++"||r.value==="--")?(t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}):e}function Yi(t){return ca(t,ua(t))}function ca(t,e){let r=e;for(;;){ue(t,n=>n.type==="Punctuation"&&n.value==="."||n.type==="Operator"&&n.value==="?.");const a=t.peek();if(a.type==="Punctuation"&&a.value==="."){t.consume();const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Te(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value};continue}if(a.type==="Operator"&&a.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const n=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const n=Te(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,optional:!0,loc:{line:a.line,column:a.column}}}else{const n=t.consume();if(n.type!=="Identifier"&&n.type!=="Keyword")throw{message:`Expected Identifier but got ${n.type} "${n.value}"`,line:n.line,column:n.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Te(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:n.value,arguments:o,optional:!0,loc:{line:n.line,column:n.column}};continue}r={kind:"Member",object:r,property:n.value,optional:!0}}continue}if(a.type==="Punctuation"&&a.value==="["){t.consume();const n=_(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Te(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function ua(t){const e=t.peek();if(e.type==="Keyword"&&(e.value==="if"||e.value==="for"||e.value==="switch"||e.value==="while"||e.value==="try")){const r=e.value==="if"?"Use the ternary operator (`cond ? a : b`) when you need a value.":e.value==="for"?"Use `arr.map(x => …)` (or `.filter`, `.reduce`, …) to collect bodies into an array.":e.value==="switch"?"Use chained ternaries, an object lookup, or wrap the switch inside a `function`.":`Use the ${e.value} statement inside a function / effect body.`,a={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw a.__definitive=!0,a}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),a=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&a.type==="Punctuation"&&a.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=Qr(t),s=ze(t);return{kind:"Lambda",params:o,body:s,loc:{line:i.line,column:i.column}}}}if(e.value==="function"||e.value==="let"||e.value==="const"||e.value==="var"||e.value==="of"||e.value==="in"||e.value==="case"||e.value==="break"||e.value==="continue"||e.value==="default"){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}}if(e.type==="Number")return t.consume(),{kind:"Literal",value:Number(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],a=[],n=[];let i="",o=!1;const s=()=>{a.push(i),i="",o=!1};for(const u of r){if(u.kind==="str"){i+=u.text,o=!0;continue}o?s():a.push("");const m=Ce(`__rui_tmpl__ = ${u.source}`).statements[0];m&&m.kind==="Assignment"?n.push(m.expression):n.push({kind:"Literal",value:""})}for((o||a.length===0)&&a.push(i);a.length<=n.length;)a.push("");return{kind:"Template",quasis:a,expressions:n,loc:{line:e.line,column:e.column}}}if(e.type==="Boolean")return t.consume(),{kind:"Literal",value:e.value==="true"};if(e.type==="Null")return t.consume(),{kind:"Literal",value:null};if(e.type==="StateIdentifier")return e.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="("?(t.consume(),Xi(t,e)):(t.consume(),{kind:"StateRef",name:e.value});if(e.type==="Identifier"){if(t.consume(),t.peek().type==="Operator"&&t.peek().value==="=>"){t.consume();const r=ma(t);return{kind:"Lambda",params:[{name:e.value}],body:r,loc:{line:e.line,column:e.column}}}if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}return{kind:"Identifier",name:e.value,loc:{line:e.line,column:e.column}}}if(e.type==="Punctuation"&&e.value==="["){t.consume();const r=Te(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=so(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=oo(t);if(a)return a;t.restore(r),t.consume();const n=_(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function Xi(t,e){t.consume();const r=Te(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Te(t){const e=[];if(R(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(da(t)),R(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),R(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(da(t)),R(t);return R(t),e}function da(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:_(t),loc:{line:e.line,column:e.column}}}return _(t)}function pa(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(t);let n;return R(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),R(t),t.peek().type==="Keyword"&&t.peek().value==="if"?n=pa(t):n=qe(t)),re(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function Ji(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const a=[];for(R(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let n=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),n=_(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),n=null;else throw{message:`Expected "case" or "default" in switch body, got ${t.peek().type} "${t.peek().value}"`,line:t.peek().line,column:t.peek().column};t.expect("Punctuation",":"),R(t);const i=[];for(;!t.isEnd()&&!(t.peek().type==="Keyword"&&(t.peek().value==="case"||t.peek().value==="default"))&&!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const o=ht(t);o&&i.push(o),R(t)}a.push({test:n,body:i}),R(t)}return t.expect("Punctuation","}"),re(t),{kind:"SwitchStatement",discriminant:r,cases:a,loc:{line:e.line,column:e.column}}}function Zi(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),R(t);const r=t.snapshot();let a="for-of";{let c=1,m=0;for(;;){const d=t.peek(m);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")c+=1;else if(d.type==="Punctuation"&&d.value===")"){if(c-=1,c===0)break}else if(c===1&&d.type==="Semicolon"){a="classic";break}else if(c===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(c===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}m+=1}}if(t.restore(r),a==="classic")return Qi(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),R(t);let n,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),n=t.expect("Identifier").value,t.expect("Punctuation",","),i=t.expect("Identifier").value,t.expect("Punctuation","]");else if(t.peek().type==="Punctuation"&&t.peek().value==="{"){t.consume();const c=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)c.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=c}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=_(t);t.expect("Punctuation",")");const u=qe(t);return re(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:u,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:u,loc:{line:e.line,column:e.column}}}function Qi(t,e){let r;if(t.peek().type!=="Semicolon")if(t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")){const o=qt(t);o.kind==="Assignment"&&(r=o),R(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:_(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),R(t)}else t.expect("Semicolon"),R(t);let a;t.peek().type!=="Semicolon"&&(a=_(t)),t.expect("Semicolon"),R(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=fa(t)),t.expect("Punctuation",")");const i=qe(t);return re(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function eo(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=_(t);t.expect("Punctuation",")");const a=qe(t);return re(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function to(t){const e=t.expect("Keyword","do"),r=qe(t);R(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=_(t);return t.expect("Punctuation",")"),re(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function ro(t){const e=t.expect("Keyword","break");return re(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function ao(t){const e=t.expect("Keyword","continue");return re(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function no(t){const e=t.expect("Keyword","throw"),r=_(t);return re(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function io(t){const e=t.expect("Keyword","try"),r=ze(t);let a,n,i;return R(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(a=t.consume().value),t.expect("Punctuation",")")),n=ze(t),R(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=ze(t)),re(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function oo(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){R(t);let n=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),n=!0);const i=t.peek();if(!n&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=Gt(t)}catch{return null}const u={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{u.defaultValue=_(t)}catch{return null}}if(r.push(u),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}if(i.type!=="Identifier")return null;t.consume();const o={name:i.value};if(n&&(o.rest=!0),!n&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=_(t)}catch{return null}}if(r.push(o),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(n)return null;t.consume();continue}break}if(R(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const a=ma(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function ma(t){return R(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?ze(t):fa(t)}function fa(t){const e=_(t),r=t.peek();if(r.type==="Operator"){if(Jr(r.value)){t.consume();const a=_(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,a,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}if(r.value==="++"||r.value==="--")return t.consume(),{kind:"BuiltinCall",name:"__rui_postfix__",arguments:[e,{kind:"Literal",value:r.value}],loc:{line:r.line,column:r.column}}}return e}function so(t){const e=[];if(R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){R(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const u=_(t);if(e.push({key:"",value:u,spread:!0}),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let a,n;if(r.type==="Punctuation"&&r.value==="[")t.consume(),R(t),n=_(t),R(t),t.expect("Punctuation","]"),a="";else if(r.type==="Number")a=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")a=t.consume().value;else throw{message:`Expected object key, got ${r.type} "${r.value}"`,line:r.line,column:r.column};const i=t.peek();let o;!n&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:a,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=_(t));const s={key:a,value:o};if(n&&(s.computedKey=n),e.push(s),R(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),R(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return R(t),e}function R(t){for(;t.match("Newline")||t.match("Semicolon"););}function re(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function lo(t){const e=Ce(t);return ga(t,e)}function ga(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const u=s.loc?.line??0;if(r.has(u)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(m=>m.line)),u=uo(t,s);i=u.before,o=u.after;const c=a.findIndex(m=>(m.loc?.line??0)>=s);if(c>=0)for(const m of a.splice(c))n.push(m)}return{committedSource:i,draftingSource:o,committedBindings:a.map(ha).filter(s=>s!==null),uncommittedBindings:n.map(ha).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function co(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const a of e)if(!r.has(a))return!1;return!0}function ha(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function uo(t,e){if(e<=1)return{before:"",after:t};let r=0,a=1;for(;r<t.length&&a<e;)t[r]===`
|
|
10
|
+
`&&(a+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}const Xt=1;function ba(t){if(!t||typeof t!="object")return!1;const e=t;return e.__aktionCompiled===Xt&&typeof e.source=="string"&&typeof e.path=="string"&&!!e.program&&Array.isArray(e.program.statements)}function po(t){return t}function mo(t,e={}){const r=Ce(t);return{__aktionCompiled:Xt,program:r,source:t,path:e.path??"<inline>"}}function fo(t,e){const r=[],a={};let n=t;for(const i of e){if(i.kind==="patch"){a[i.target]=i.value;continue}const o=go(n,i);n=o.programText,o.warning&&r.push(o.warning)}return{programText:n,stateUpdates:a,warnings:r}}function go(t,e){const r=Ce(t);if(r.errors.length>0)return{programText:t,warning:`delta(${e.kind}): source did not parse cleanly (${r.errors[0].message}); op skipped`};switch(e.kind){case"new":{const a=Ce(e.source);if(a.errors.length>0||a.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${va(e.source)}" — op skipped`};const n=t.endsWith(`
|
|
11
11
|
`)?"":`
|
|
12
12
|
`;return{programText:t+n+e.source.trim()+`
|
|
13
|
-
`}}case"delete":{const a=
|
|
13
|
+
`}}case"delete":{const a=Jt(r,e.binding);return a<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:Zt(t,r,a,null)}}case"replace":{const a=Jt(r,e.binding);return a<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:Ce(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:Zt(t,r,a,`${e.binding} = ${e.source.trim()}`)}}case"append":{const a=Jt(r,e.binding);if(a<0)return{programText:t,warning:`delta(append): binding "${e.binding}" not found — op skipped`};const n=r.statements[a];if(n.kind!=="Assignment"||n.expression.kind!=="Array")return{programText:t,warning:`delta(append): binding "${e.binding}" is not an array literal — op skipped`};const i=Ce(`__rui_delta_item__ = ${e.item}`),o=i.statements[0];if(i.errors.length>0||!o||o.kind!=="Assignment")return{programText:t,warning:`delta(append): could not parse item "${va(e.item)}" — op skipped`};const s=n.expression.elements,u=`${e.binding} = [${[...s.map(me),e.item.trim()].join(", ")}]`;return{programText:Zt(t,r,a,u)}}}}function Jt(t,e){return t.statements.findIndex(r=>ho(r)===e)}function ho(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function Zt(t,e,r,a){const n=t.split(`
|
|
14
14
|
`),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,u=o?(o.loc?.line??n.length+1)-1:n.length,c=n.slice(0,s),m=n.slice(u);return a===null?[...c,...m].join(`
|
|
15
15
|
`):[...c,a,...m].join(`
|
|
16
|
-
`)}function me(t){switch(t.kind){case"Literal":return typeof t.value=="string"?`"${t.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:String(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Call":return`${t.callee}(${t.arguments.map(me).join(", ")})`;case"MethodCall":return`${me(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(me).join(", ")})`;case"Array":return`[${t.elements.map(me).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${me(e.value)}`:`${e.key}: ${me(e.value)}`).join(", ")} }`;case"Member":{const e=me(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${me(t.computed)}]`:e}case"Binary":return`${me(t.left)} ${t.operator} ${me(t.right)}`;case"Template":{const e=[];for(let r=0;r<t.quasis.length;r+=1)e.push(t.quasis[r]??""),r<t.expressions.length&&(e.push("${"),e.push(me(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function fa(t){return t.length>40?`${t.slice(0,37)}...`:t}const ga=new WeakMap;function uo(t){let e=ga.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);ga.set(t.components,e)}return e}function ha(t,e){const r=new Map;for(const a of t.components)r.set(a.name,a);for(const a of e.components)r.set(a.name,a);return{root:e.root??t.root,components:[...r.values()],componentGroups:t.componentGroups}}function Ne(t,e){return uo(t).get(e)}function Xt(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function Jt(t){const e=Xt(t);return e>=0?t.props[e]:void 0}function ba(t){for(const e of t){const r=e.props.filter(a=>a.positional===!0);if(r.length>1){const a=r.map(n=>n.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${a}). Aktion 0.5 §19.1 allows at most one.`)}}}function va(t,e){const r={};return t.props.forEach((a,n)=>{n<e.length&&(r[a.name]=e[n])}),r}function po(t,e){const r=$e(t),a=Zt(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function Zt(t,e){const r=[];for(const a of t.statements)se(a,e,r);return r}function se(t,e,r){switch(t.kind){case"Assignment":H(t.expression,e,r);return;case"ExpressionStatement":H(t.expression,e,r);return;case"ComponentDeclaration":case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const a of t.body.body)se(a,e,r);return;case"Return":t.argument&&H(t.argument,e,r);return;case"Await":H(t.argument,e,r);return;case"IfStatement":H(t.test,e,r);for(const a of t.consequent.body)se(a,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")se(t.alternate,e,r);else for(const a of t.alternate.body)se(a,e,r);return;case"SwitchStatement":H(t.discriminant,e,r);for(const a of t.cases){a.test&&H(a.test,e,r);for(const n of a.body)se(n,e,r)}return;case"ForOfStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForClassicStatement":t.init&&se(t.init,e,r),t.test&&H(t.test,e,r),t.update&&H(t.update,e,r);for(const a of t.body.body)se(a,e,r);return;case"WhileStatement":case"DoWhileStatement":H(t.test,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForInStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"DestructureStatement":H(t.expression,e,r);for(const a of t.bindings)a.defaultValue&&H(a.defaultValue,e,r);return;case"TryStatement":for(const a of t.block.body)se(a,e,r);if(t.catchBlock)for(const a of t.catchBlock.body)se(a,e,r);if(t.finallyBlock)for(const a of t.finallyBlock.body)se(a,e,r);return;case"ThrowStatement":H(t.argument,e,r);return;default:return}}function H(t,e,r){if(t)switch(t.kind){case"Call":{fo(t,e,r);for(const a of t.arguments)H(a,e,r);return}case"MethodCall":{H(t.object,e,r);for(const a of t.arguments)H(a,e,r);return}case"BuiltinCall":{for(const a of t.arguments)H(a,e,r);return}case"Array":for(const a of t.elements)H(a,e,r);return;case"Object":for(const a of t.properties)H(a.value,e,r);return;case"Template":for(const a of t.expressions)H(a,e,r);return;case"Binary":H(t.left,e,r),H(t.right,e,r);return;case"Unary":H(t.argument,e,r);return;case"Ternary":H(t.test,e,r),H(t.consequent,e,r),H(t.alternate,e,r);return;case"Member":H(t.object,e,r),t.computed&&H(t.computed,e,r);return;case"Spread":H(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&ya(t,r),H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"New":H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const a of t.body.body)se(a,e,r);else H(t.body,e,r);return;case"Block":for(const a of t.body)se(a,e,r);return;default:return}}const mo={Script:'Script("id", body, deps?) is not supported. Use `$effect(() => { … }, [deps])` (see §9 — effect declarations).',Action:'Action([@Set, @Run, …]) payloads are removed in 0.5. Use `function name() { … }` declarations and reference them by name (e.g. `Button("Save", { action: save })`) — see §10.',Routes:'Routes(items, default?) is removed in 0.5. Use `pages = $router({ "/": Home(), default: NotFound() })` (see §12 — outlet-first router).',Route:'Route(path, content) is only valid inside a v1 `Routes(...)` outlet, which has been removed. Use `"/path": content` arms inside a `$router({ … })` call (see §12).',Query:'Query("name", args, placeholder, refreshSec?) is removed in 0.5. Declare a top-level `query <Name>(args) { url, method, … }` block and bind it with `$query foo = <Name>(args)` (see §11.2).',Mutation:'Mutation("name", args) is removed in 0.5. Declare a top-level `mutation <Name>(args) { url, method, body, … }` block and bind it with `$mutation save = <Name>` (see §11.3).',NavLinkRoute:'NavLinkRoute is removed in 0.5. Use `NavLink(label, { to: "/path" })` (see §12 — Outlet-first router).',useInstanceState:"useInstanceState(...) is removed in 0.5. Declare per-instance state inside the component body with `$state name = init` — identity is content-addressed (§13)."};function fo(t,e,r){const a=mo[t.callee];if(a){r.push({message:`${t.callee}(...) — ${a}`,line:t.loc?.line??0,column:t.loc?.column??0});return}if(t.callee==="Theme"){ya(t,r);return}const n=Ne(e,t.callee);if(!n)return;const i=new Set;for(const d of n.props)if(i.add(d.name),d.aliases)for(const f of d.aliases)i.add(f);i.add("key");const o=t.arguments;let s=-1;for(let d=o.length-1;d>=0;d-=1)if(o[d].kind==="Object"){s=d;break}const u=s>=0?o[s]:null,c=[];for(let d=0;d<o.length;d++)d!==s&&c.push(o[d]);if(c.length>1){const f=Jt(n)?.name??"(none)",g=go(o,u),h=n.props.filter(v=>v.name!==f&&!g.has(v.name)).slice(0,c.length-1).map(v=>v.name),b=h.length>0?h.map(v=>`${v}: …`).join(", "):"use a trailing { prop: value } object";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${f}" prop). The extra ${c.length-1} positional argument(s) must be passed inside a trailing object: ${b}. Multi-positional calls are removed.`,line:t.loc?.line??0,column:t.loc?.column??0})}const m=[];if(u)for(const d of u.properties)d.spread||m.push({name:d.key,value:d.value,loc:d.value.loc??u.loc});for(const d of m){if(!i.has(d.name)){r.push({message:`Unknown prop "${d.name}" on <${t.callee}>. Known props: ${n.props.map(g=>g.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0});continue}const f=n.props.find(g=>g.name===d.name||(g.aliases?.includes(d.name)??!1));if(f?.enum&&d.value.kind==="Literal"&&typeof d.value.value=="string"){const g=d.value.value;f.enum.includes(g)||r.push({message:`<${t.callee}> ${d.name}="${g}" — must be one of ${f.enum.map(h=>`"${h}"`).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}}}function go(t,e){const r=new Set;if(e)for(const a of e.properties)a.spread||r.add(a.key);return r}const ho=new Set(["colors","radius","font","motion","elevation"]),bo=new Set(["name","direction"]);function ya(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||ho.has(a.key)||bo.has(a.key))continue;const n=vo(a.key),i=a.key.startsWith("--")?`$theme({"${a.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`:`$theme({${a.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${n}.`;e.push({message:i,line:t.loc?.line??0,column:t.loc?.column??0})}}function vo(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"},{prefix:"motion",group:"motion"},{prefix:"elevation",group:"elevation"}];for(const{prefix:r,group:a}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const n=t.slice(r.length),i=n.charAt(0).toLowerCase()+n.slice(1);return`$theme({ ${a}: { ${i}: ... } })`}return"$theme({ colors: {...}, radius: {...}, font: {...}, motion: {...}, elevation: {...} })"}const bt={name:"aktion",atoms:["true","false","null","undefined"],keywords:["function","if","else","switch","case","break","continue","for","while","do","of","in","let","var","const","await","async","return","default","try","catch","finally","throw","new","typeof","instanceof","delete","void","aktion","route"],operators:["+","-","*","/","%","!","=","<",">","?",":",".",","],operatorsLong:["...","==","!=",">=","<=","&&","||","??","?."],brackets:[{open:"(",close:")"},{open:"[",close:"]"},{open:"{",close:"}"}],comments:{line:"//",blockStart:"/*",blockEnd:"*/"},strings:{singleLineQuotes:['"',"'"],multiLineQuote:"`"},identifier:{start:/[A-Za-z_]/,part:/[A-Za-z0-9_]/},sigils:{state:"$"}},xa={aktion:{summary:"Reserved entry-point binding — the root of the rendered UI tree.",syntax:"aktion = Component(...)",example:'aktion = Stack([Heading("Hi"), Text("Welcome")])'},route:{summary:"Reactive router handle — exposes path, params, query, and navigate().",syntax:"route.path · route.params · route.query · route.navigate(path)",example:'Button("Home", () => route.navigate("/"))'},$emit:{summary:"Dispatch a custom DOM event from the host element.",syntax:'$emit("event-name", detail)',example:'Button("Save", () => $emit("saved", { id: $id }))'},function:{summary:"Declare a component or action — first-letter case does not matter.",syntax:"function name(params) { ... }",example:"function Greeting(name) {\n return Text(`Hello ${name}`)\n}"},$effect:{summary:"Run a side-effect when dependencies change (timers, fetch, analytics).",syntax:"$effect(() => { ... }, [deps])",example:`$effect(() => {
|
|
16
|
+
`)}function me(t){switch(t.kind){case"Literal":return typeof t.value=="string"?`"${t.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:String(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Call":return`${t.callee}(${t.arguments.map(me).join(", ")})`;case"MethodCall":return`${me(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(me).join(", ")})`;case"Array":return`[${t.elements.map(me).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${me(e.value)}`:`${e.key}: ${me(e.value)}`).join(", ")} }`;case"Member":{const e=me(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${me(t.computed)}]`:e}case"Binary":return`${me(t.left)} ${t.operator} ${me(t.right)}`;case"Template":{const e=[];for(let r=0;r<t.quasis.length;r+=1)e.push(t.quasis[r]??""),r<t.expressions.length&&(e.push("${"),e.push(me(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function va(t){return t.length>40?`${t.slice(0,37)}...`:t}const ya=new WeakMap;function bo(t){let e=ya.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);ya.set(t.components,e)}return e}function xa(t,e){const r=new Map;for(const a of t.components)r.set(a.name,a);for(const a of e.components)r.set(a.name,a);return{root:e.root??t.root,components:[...r.values()],componentGroups:t.componentGroups}}function Ne(t,e){return bo(t).get(e)}function Qt(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function er(t){const e=Qt(t);return e>=0?t.props[e]:void 0}function wa(t){for(const e of t){const r=e.props.filter(a=>a.positional===!0);if(r.length>1){const a=r.map(n=>n.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${a}). Aktion 0.5 §19.1 allows at most one.`)}}}function ka(t,e){const r={};return t.props.forEach((a,n)=>{n<e.length&&(r[a.name]=e[n])}),r}function vo(t,e){const r=Ce(t),a=tr(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function tr(t,e){const r=[];for(const a of t.statements)se(a,e,r);return r}function se(t,e,r){switch(t.kind){case"Assignment":H(t.expression,e,r);return;case"ExpressionStatement":H(t.expression,e,r);return;case"ComponentDeclaration":case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const a of t.body.body)se(a,e,r);return;case"Return":t.argument&&H(t.argument,e,r);return;case"Await":H(t.argument,e,r);return;case"IfStatement":H(t.test,e,r);for(const a of t.consequent.body)se(a,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")se(t.alternate,e,r);else for(const a of t.alternate.body)se(a,e,r);return;case"SwitchStatement":H(t.discriminant,e,r);for(const a of t.cases){a.test&&H(a.test,e,r);for(const n of a.body)se(n,e,r)}return;case"ForOfStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForClassicStatement":t.init&&se(t.init,e,r),t.test&&H(t.test,e,r),t.update&&H(t.update,e,r);for(const a of t.body.body)se(a,e,r);return;case"WhileStatement":case"DoWhileStatement":H(t.test,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForInStatement":H(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"DestructureStatement":H(t.expression,e,r);for(const a of t.bindings)a.defaultValue&&H(a.defaultValue,e,r);return;case"TryStatement":for(const a of t.block.body)se(a,e,r);if(t.catchBlock)for(const a of t.catchBlock.body)se(a,e,r);if(t.finallyBlock)for(const a of t.finallyBlock.body)se(a,e,r);return;case"ThrowStatement":H(t.argument,e,r);return;default:return}}function H(t,e,r){if(t)switch(t.kind){case"Call":{xo(t,e,r);for(const a of t.arguments)H(a,e,r);return}case"MethodCall":{H(t.object,e,r);for(const a of t.arguments)H(a,e,r);return}case"BuiltinCall":{for(const a of t.arguments)H(a,e,r);return}case"Array":for(const a of t.elements)H(a,e,r);return;case"Object":for(const a of t.properties)H(a.value,e,r);return;case"Template":for(const a of t.expressions)H(a,e,r);return;case"Binary":H(t.left,e,r),H(t.right,e,r);return;case"Unary":H(t.argument,e,r);return;case"Ternary":H(t.test,e,r),H(t.consequent,e,r),H(t.alternate,e,r);return;case"Member":H(t.object,e,r),t.computed&&H(t.computed,e,r);return;case"Spread":H(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&Sa(t,r),H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"New":H(t.callee,e,r);for(const a of t.arguments)H(a,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const a of t.body.body)se(a,e,r);else H(t.body,e,r);return;case"Block":for(const a of t.body)se(a,e,r);return;default:return}}const yo={Script:'Script("id", body, deps?) is not supported. Use `$effect(() => { … }, [deps])` (see §9 — effect declarations).',Action:'Action([@Set, @Run, …]) payloads are removed in 0.5. Use `function name() { … }` declarations and reference them by name (e.g. `Button("Save", { action: save })`) — see §10.',Routes:'Routes(items, default?) is removed in 0.5. Use `pages = $router({ "/": Home(), default: NotFound() })` (see §12 — outlet-first router).',Route:'Route(path, content) is only valid inside a v1 `Routes(...)` outlet, which has been removed. Use `"/path": content` arms inside a `$router({ … })` call (see §12).',Query:'Query("name", args, placeholder, refreshSec?) is removed in 0.5. Declare a top-level `query <Name>(args) { url, method, … }` block and bind it with `$query foo = <Name>(args)` (see §11.2).',Mutation:'Mutation("name", args) is removed in 0.5. Declare a top-level `mutation <Name>(args) { url, method, body, … }` block and bind it with `$mutation save = <Name>` (see §11.3).',NavLinkRoute:'NavLinkRoute is removed in 0.5. Use `NavLink(label, { to: "/path" })` (see §12 — Outlet-first router).',useInstanceState:"useInstanceState(...) is removed in 0.5. Declare per-instance state inside the component body with `$state name = init` — identity is content-addressed (§13)."};function xo(t,e,r){const a=yo[t.callee];if(a){r.push({message:`${t.callee}(...) — ${a}`,line:t.loc?.line??0,column:t.loc?.column??0});return}if(t.callee==="Theme"){Sa(t,r);return}const n=Ne(e,t.callee);if(!n)return;const i=new Set;for(const d of n.props)if(i.add(d.name),d.aliases)for(const f of d.aliases)i.add(f);i.add("key");const o=t.arguments;let s=-1;for(let d=o.length-1;d>=0;d-=1)if(o[d].kind==="Object"){s=d;break}const u=s>=0?o[s]:null,c=[];for(let d=0;d<o.length;d++)d!==s&&c.push(o[d]);if(c.length>1){const f=er(n)?.name??"(none)",g=wo(o,u),h=n.props.filter(v=>v.name!==f&&!g.has(v.name)).slice(0,c.length-1).map(v=>v.name),b=h.length>0?h.map(v=>`${v}: …`).join(", "):"use a trailing { prop: value } object";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${f}" prop). The extra ${c.length-1} positional argument(s) must be passed inside a trailing object: ${b}. Multi-positional calls are removed.`,line:t.loc?.line??0,column:t.loc?.column??0})}const m=[];if(u)for(const d of u.properties)d.spread||m.push({name:d.key,value:d.value,loc:d.value.loc??u.loc});for(const d of m){if(!i.has(d.name)){r.push({message:`Unknown prop "${d.name}" on <${t.callee}>. Known props: ${n.props.map(g=>g.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0});continue}const f=n.props.find(g=>g.name===d.name||(g.aliases?.includes(d.name)??!1));if(f?.enum&&d.value.kind==="Literal"&&typeof d.value.value=="string"){const g=d.value.value;f.enum.includes(g)||r.push({message:`<${t.callee}> ${d.name}="${g}" — must be one of ${f.enum.map(h=>`"${h}"`).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}}}function wo(t,e){const r=new Set;if(e)for(const a of e.properties)a.spread||r.add(a.key);return r}const ko=new Set(["colors","radius","font","motion","elevation"]),So=new Set(["name","direction"]);function Sa(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||ko.has(a.key)||So.has(a.key))continue;const n=Co(a.key),i=a.key.startsWith("--")?`$theme({"${a.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`:`$theme({${a.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${n}.`;e.push({message:i,line:t.loc?.line??0,column:t.loc?.column??0})}}function Co(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"},{prefix:"motion",group:"motion"},{prefix:"elevation",group:"elevation"}];for(const{prefix:r,group:a}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const n=t.slice(r.length),i=n.charAt(0).toLowerCase()+n.slice(1);return`$theme({ ${a}: { ${i}: ... } })`}return"$theme({ colors: {...}, radius: {...}, font: {...}, motion: {...}, elevation: {...} })"}const vt={name:"aktion",atoms:["true","false","null","undefined"],keywords:["function","if","else","switch","case","break","continue","for","while","do","of","in","let","var","const","await","async","return","default","try","catch","finally","throw","new","typeof","instanceof","delete","void","aktion","route"],operators:["+","-","*","/","%","!","=","<",">","?",":",".",","],operatorsLong:["...","==","!=",">=","<=","&&","||","??","?."],brackets:[{open:"(",close:")"},{open:"[",close:"]"},{open:"{",close:"}"}],comments:{line:"//",blockStart:"/*",blockEnd:"*/"},strings:{singleLineQuotes:['"',"'"],multiLineQuote:"`"},identifier:{start:/[A-Za-z_]/,part:/[A-Za-z0-9_]/},sigils:{state:"$"}},Ca={aktion:{summary:"Reserved entry-point binding — the root of the rendered UI tree.",syntax:"aktion = Component(...)",example:'aktion = Stack([Heading("Hi"), Text("Welcome")])'},route:{summary:"Reactive router handle — exposes path, params, query, and navigate().",syntax:"route.path · route.params · route.query · route.navigate(path)",example:'Button("Home", () => route.navigate("/"))'},$emit:{summary:"Dispatch a custom DOM event from the host element.",syntax:'$emit("event-name", detail)',example:'Button("Save", () => $emit("saved", { id: $id }))'},function:{summary:"Declare a component or action — first-letter case does not matter.",syntax:"function name(params) { ... }",example:"function Greeting(name) {\n return Text(`Hello ${name}`)\n}"},$effect:{summary:"Run a side-effect when dependencies change (timers, fetch, analytics).",syntax:"$effect(() => { ... }, [deps])",example:`$effect(() => {
|
|
17
17
|
$now = $util.now()
|
|
18
18
|
}, ["every(1000)"])`},if:{summary:"Conditional statement — run a block when a condition is truthy.",syntax:"if (condition) { ... } else { ... }",example:`if (!$user) {
|
|
19
19
|
return Spinner()
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
risky()
|
|
37
37
|
} catch (e) {
|
|
38
38
|
log(e)
|
|
39
|
-
}`},catch:{summary:"Handle an error thrown inside the preceding `try` block.",syntax:"catch (error) { ... }",example:"catch (e) { $error = e }"},finally:{summary:"Run cleanup after `try` / `catch`, regardless of outcome.",syntax:"finally { ... }",example:"finally { $loading = false }"},throw:{summary:"Raise an error — caught by an enclosing `try` / `catch`.",syntax:"throw value",example:'throw "invalid state"'},new:{summary:"Construct an instance of a host class (Date, Map, Set, …).",syntax:"new Constructor(args)",example:"let now = new Date()"},typeof:{summary:`Return a string naming a value's type ("number", "string", …).`,syntax:"typeof value",example:'if (typeof x === "number") { ... }'},instanceof:{summary:"Test whether a value is an instance of a constructor.",syntax:"value instanceof Constructor",example:"if (d instanceof Date) { ... }"},delete:{summary:"Remove a property from an object.",syntax:"delete obj.prop",example:"delete $form.draft"},void:{summary:"Evaluate an expression and yield `undefined`.",syntax:"void expression",example:"void sideEffect()"}};function wa(t=bt){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=d=>({...d}),a=new Set(t.atoms),n=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,u=new Set([...t.operators.join(""),..."=<>!&|"]),c=(d,f)=>{for(;!d.eol();){const g=d.next();if(!g)return;if(g==="\\"){d.next();continue}if(g===f)return}};return{startState:e,copyState:r,token:(d,f)=>{if(f.inBacktick){for(;!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return f.inBacktick=!1,"string"}return"string"}if(f.inBlockComment){for(;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";d.next()}return"comment"}if(d.eatWhile(/[ \t]/))return null;if(d.match(t.comments.line,!0))return d.skipToEnd(),"comment";if(d.match(t.comments.blockStart,!0)){for(f.inBlockComment=!0;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";d.next()}return"comment"}const g=d.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const h=g;return d.next(),c(d,h),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return"string"}return f.inBacktick=!0,"string"}if(g>="0"&&g<="9"&&d.match(s,!0)||g==="-"&&d.match(/^-\d+(?:\.\d+)?/,!1)&&d.match(s,!0))return"number";if(g===t.sigils.state)return d.next(),d.peek()===t.sigils.state&&d.next(),d.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(g)){if(d.match(i,!0))return"component";const b=d.match(o,!0);if(b){const v=b[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const h of t.operatorsLong)if(d.match(h,!0))return"operator";return g==="."?(d.next(),d.peek()&&t.identifier.start.test(d.peek())?(d.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(g)?(d.next(),"punctuation"):u.has(g)?(d.next(),"operator"):(d.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const ka={comment:"comment",string:"string",number:"number",atom:"atom",keyword:"keyword",state:"variableName.special",component:"typeName",identifier:"variableName",loopvar:"variableName.local",property:"propertyName",operator:"operator",punctuation:null},Sa={},Ca=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function $a(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Ta(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Qt(t,e){if(t.has(e))return!0;for(const r of t)if(Ta(r,e))return!0;return!1}function vt(t,e){for(const r of e)if(Qt(t,r))return!0;return!1}class Aa{constructor(){D(this,"values",new Map);D(this,"defaults",new Map);D(this,"subscribers",new Set);D(this,"pendingChanges",new Set);D(this,"flushScheduled",!1);D(this,"rendering",!1);D(this,"renderWriteOccurred",!1)}declare(e,r){this.defaults.set(e,r),this.values.has(e)||this.values.set(e,r)}has(e){return this.values.has(e)}get(e){return this.values.get(e)}set(e,r){this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}enqueueChange(e){if(this.rendering){this.renderWriteOccurred=!0;return}this.pendingChanges.add(e),this.scheduleFlush()}beginRenderPass(){this.rendering=!0,this.renderWriteOccurred=!1}isRendering(){return this.rendering}endRenderPass(){this.rendering=!1;const e=this.renderWriteOccurred;return this.renderWriteOccurred=!1,e}setPath(e,r,a){if(r.length===0){this.set(e,a);return}const n=this.values.get(e),i=rt(n,r,0,a);this.values.set(e,i),this.enqueueChange($a(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,a)=>{e[a]=r}),e}hydrate(e){for(const[r,a]of Object.entries(e))this.values.set(r,a)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const a=this.defaults.get(r);this.values.get(r)!==a&&(this.values.set(r,a),this.enqueueChange(r))}}resetAll(){for(const[e,r]of this.defaults.entries())this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}rebind(e){this.values.clear(),this.defaults.clear(),this.pendingChanges.clear();for(const[r,a]of e)this.defaults.set(r,a),this.values.set(r,a)}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){if(this.flushScheduled=!1,this.pendingChanges.size===0)return;const e=new Set(this.pendingChanges);this.pendingChanges.clear();for(const r of[...this.subscribers])r(e)}}function rt(t,e,r,a){if(r>=e.length)return a;const n=e[r],i=n!==""&&!Number.isNaN(Number(n))?Number(n):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=rt(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=rt(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=rt(void 0,e,r+1,a),s}const o={};return o[n]=rt(void 0,e,r+1,a),o}const Na=Symbol("aktion.httpResource");function Ma(t){return typeof t=="object"&&t!==null&&t[Na]===!0}class Pa{constructor(){D(this,"interceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};if(this.interceptors.onRequest)try{r=await this.interceptors.onRequest(r)}catch(n){throw this.interceptors.onError?.(n,r),n}const a=async()=>{const n=new AbortController,i=typeof fetch=="function"?fetch:null;if(!i)throw new Error("`fetch` is not available in this environment");const o={...r.init,method:r.method,headers:r.headers,signal:r.signal??n.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(o.body=yo(r.body,r.headers));const s=await i(r.url,o),u={};s.headers.forEach((d,f)=>{u[f]=d});const c=u["content-type"]??"";let m;return s.status===204||r.method==="HEAD"?m=null:c.includes("application/json")?m=await s.json().catch(()=>null):m=await s.text().catch(()=>""),{status:s.status,headers:u,body:m}};try{let n=await a();if(this.interceptors.onResponse){let i=!1;const o=async()=>i?n:(i=!0,a());n=await this.interceptors.onResponse(n,o)}return n}catch(n){throw this.interceptors.onError?.(n,r),n}}}function yo(t,e){if(t==null)return"";if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer||typeof FormData<"u"&&t instanceof FormData||typeof URLSearchParams<"u"&&t instanceof URLSearchParams)return t;!e["content-type"]&&!e["Content-Type"]&&(e["Content-Type"]="application/json");try{return JSON.stringify(t)}catch{return String(t)}}const xo=new Set(["url","method","headers","body","query","signal"]);function wo(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",a=typeof e.method=="string"?e.method.toUpperCase():"GET",n={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[u,c]of Object.entries(e.headers))c!=null&&(n[u]=String(c));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const u=new URLSearchParams;for(const[m,d]of Object.entries(e.query))d!=null&&u.append(m,String(d));const c=u.toString();c&&(i+=(i.includes("?")?"&":"?")+c)}const o={};for(const[u,c]of Object.entries(e))xo.has(u)||(o[u]=c);const s={url:i,method:a,headers:n,body:e.body};return Object.keys(o).length>0&&(s.init=o),e.signal instanceof AbortSignal&&(s.signal=e.signal),s}function Ia(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{n+=1,a&&a.abort(),a=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,Na,{value:!0,enumerable:!1,writable:!1});let a=null,n=0;const i=()=>e.notify?.(),o=async()=>{const s=n+=1;a&&a.abort(),a=new AbortController;const u=a;if(r.state=r.data===void 0?"loading":"stale",r.loading=!0,i(),!e.http){r.error={message:"http runtime not available"},r.state="error",r.loading=!1,i();return}try{const c=wo(t);c.url=e.http.resolveUrl(c.url),c.signal=u.signal;const m=await e.http.request(c);if(s!==n)return;m.status>=200&&m.status<300?(r.data=m.body,r.state="data",r.error=void 0):(r.error={status:m.status,body:m.body},r.state="error"),r.status=m.status,r.headers=m.headers,r.lastUpdated=Date.now()}catch(c){if(s!==n||c?.name==="AbortError")return;r.error=c,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(c){console.error("[aktion] Http onDone callback threw",c)}}};return o(),r}function La(t={}){const e=ko(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,u){if(typeof s!="string"||!s)return"";const c=e[s];let m;return c&&(a&&typeof c[a]=="string"?m=c[a]:r&&typeof c[r]=="string"&&(m=c[r])),m===void 0?s:So(m,u)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function ko(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){if(!a||typeof a!="object"||Array.isArray(a))continue;const n={};for(const[i,o]of Object.entries(a))typeof o=="string"&&(n[i]=o);e[r]=n}return e}function So(t,e){return e?t.replace(/\{([^}]+)\}/g,(r,a)=>{const n=e[a.trim()];return n==null?"":String(n)}):t}const W=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,le=t=>Array.isArray(t)?t:[],za=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Ra=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return W(e)>W(r);case"<":return W(e)<W(r);case">=":return W(e)>=W(r);case"<=":return W(e)<=W(r);case"contains":{const a=String(e??"").toLowerCase(),n=String(r??"").toLowerCase();return a.includes(n)}default:return!1}},Ge=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const a of e.split("."))if(r&&typeof r=="object")r=r[a];else return;return r}return t[e]}},je=t=>{if(t instanceof Date)return t;if(typeof t=="number")return new Date(t);if(typeof t=="string"&&t.trim()!==""){if(!Number.isNaN(Number(t))&&/^-?\d+$/.test(t.trim()))return new Date(Number(t));const e=new Date(t);if(!Number.isNaN(e.getTime()))return e}return new Date},Co=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$o=["January","February","March","April","May","June","July","August","September","October","November","December"],To=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ao=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],No=(t,e)=>{const r=(s,u=2)=>String(s).padStart(u,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,$o[t.getMonth()]],[/MMM/g,Co[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,Ao[t.getDay()]],[/ddd/g,To[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(a)],[/hh/g,r(n)],[/mm/g,r(t.getMinutes())],[/ss/g,r(t.getSeconds())],[/\bM\b/g,String(t.getMonth()+1)],[/\bD\b/g,String(t.getDate())],[/\bH\b/g,String(a)],[/\bh\b/g,String(n)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,a>=12?"PM":"AM"],[/a/g,a>=12?"pm":"am"]];let o=e;for(const[s,u]of i)o=o.replace(s,u);return o},Mo=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,u=7*s,c=30*s,m=365*s;let d,f;return a<i?n?"in a moment":"just now":(a<o?(d=Math.round(a/i),f="m"):a<s?(d=Math.round(a/o),f="h"):a<u?(d=Math.round(a/s),f="d"):a<c?(d=Math.round(a/u),f="w"):a<m?(d=Math.round(a/c),f="mo"):(d=Math.round(a/m),f="y"),n?`in ${d}${f}`:`${d}${f} ago`)},Po=(t,e,r)=>{if(za(e)){const n={};return typeof e.currency=="string"&&(n.currency=e.currency),typeof e.locale=="string"&&(n.locale=e.locale),typeof e.decimals=="number"&&(n.decimals=e.decimals),n}const a={};return t==="currency"?(typeof e=="string"&&e.length>0&&(a.currency=e),typeof r=="string"&&r.length>0&&(a.locale=r)):typeof e=="string"&&e.length>0&&(a.locale=e),a},Io=(t,e)=>{const a=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(a.length===0)return"";if(e==="snake")return a.join("_");if(e==="kebab")return a.join("-");const n=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?a.map(n).join(""):a[0]+a.slice(1).map(n).join("")},Lo={count:t=>le(t).length,sum:t=>le(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=le(t);return e.length===0?0:e.reduce((r,a)=>r+W(a),0)/e.length},min:t=>{const e=le(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=le(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>le(t)[0]??null,last:t=>{const e=le(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",a)=>le(t).filter(n=>Ra(r,Ge(n,String(e)),a)),find:(t,e="",r="==",a)=>le(t).find(n=>Ra(r,Ge(n,String(e)),a))??null,sort:(t,e="",r="asc")=>{const a=[...le(t)],n=String(r).toLowerCase()==="desc"?-1:1;return a.sort((i,o)=>{const s=Ge(i,String(e)),u=Ge(o,String(e));return typeof s=="number"&&typeof u=="number"?(s-u)*n:String(s??"").localeCompare(String(u??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of le(t)){const n=String(Ge(a,String(e))??"");(r[n]??(r[n]=[])).push(a)}return r},slice:(t,e,r)=>{const a=le(t);return a.slice(e??0,r??a.length)},unique:(t,e)=>{const r=le(t);if(!e)return Array.from(new Set(r));const a=new Set,n=[];for(const i of r){const o=Ge(i,e);a.has(o)||(a.add(o),n.push(i))}return n},reverse:t=>[...le(t)].reverse(),range:(t,e,r)=>{const a=W(t),n=W(e),i=r===void 0?n>=a?1:-1:W(r);if(i===0)return[a];const o=Math.abs(n-a),s=Math.floor(o/Math.abs(i))+1;if(s>yt)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${yt}).`);const u=[];if(i>0)for(let c=a;c<=n;c+=i)u.push(c);else for(let c=a;c>=n;c+=i)u.push(c);return u},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>yt)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${yt}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!za(t))return{};const r=le(e).map(n=>String(n??"")),a={};for(const n of r)n in t&&(a[n]=t[n]);return a},format:(t,e="number",r,a)=>{const n=W(t),i=String(e),o=Po(i,r,a),s={};i==="currency"?(s.style="currency",s.currency=o.currency||"USD"):i==="percent"?(s.style="percent",o.decimals===void 0&&(s.maximumFractionDigits=2)):i==="compact"?s.notation="compact":s.style="decimal",o.decimals!==void 0&&(s.minimumFractionDigits=o.decimals,s.maximumFractionDigits=o.decimals);try{return new Intl.NumberFormat(o.locale||void 0,s).format(n)}catch{return i==="currency"?n.toFixed(o.decimals??2):String(n)}},formatDate:(t,e="MMM D")=>{const r=je(t),a=String(e);switch(a){case"relative":return Mo(r);case"date":return r.toLocaleDateString();case"time":return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});case"datetime":return r.toLocaleString();case"iso":return r.toISOString();default:return No(r,a)}},plural:(t,e,r)=>{const a=W(t),n=String(e??""),i=r===void 0?n+"s":String(r??"");return`${a} ${a===1?n:i}`},capitalize:t=>{const e=String(t??"");return e.length===0?"":e.charAt(0).toUpperCase()+e.slice(1)},lowercase:t=>String(t??"").toLowerCase(),uppercase:t=>String(t??"").toUpperCase(),titlecase:t=>String(t??"").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),case:(t,e="camel")=>{const r=String(e).toLowerCase();return Io(t,r==="snake"||r==="kebab"||r==="pascal"||r==="camel"?r:"camel")},now:()=>Date.now(),today:()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},addDays:(t,e)=>{const r=je(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=je(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=je(t),a=je(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=je(t),r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return r.setUTCDate(r.getUTCDate()-r.getUTCDay()),r.toISOString()},endOfMonth:t=>{const e=je(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>le(t).map(r=>r==null?"":String(r)).join(String(e)),split:(t,e=",")=>String(t??"").split(String(e)),trim:t=>String(t??"").trim(),replace:(t,e,r="")=>String(t??"").split(String(e??"")).join(String(r??"")),substring:(t,e,r)=>{const a=String(t??"");return a.substring(W(e),r===void 0?a.length:W(r))},startsWith:(t,e)=>String(t??"").startsWith(String(e??"")),endsWith:(t,e)=>String(t??"").endsWith(String(e??"")),contains:(t,e)=>String(t??"").includes(String(e??"")),match:(t,e)=>{try{return new RegExp(String(e??"")).test(String(t??""))}catch{return!1}},round:(t,e=0)=>{const r=Math.pow(10,W(e));return Math.round(W(t)*r)/r},floor:t=>Math.floor(W(t)),ceil:t=>Math.ceil(W(t)),abs:t=>Math.abs(W(t)),clamp:(t,e,r)=>Math.min(Math.max(W(t),W(e)),W(r)),pow:(t,e)=>Math.pow(W(t),W(e)),sqrt:t=>Math.sqrt(W(t)),random:()=>Math.random(),log:t=>Math.log(W(t))},yt=1e5;function De(t){if(!t)return"/";let e=String(t);e.startsWith("#")&&(e=e.slice(1));const r=e.indexOf("?");return r>=0&&(e=e.slice(0,r)),e=e.replace(/\/{2,}/g,"/"),!e||e==="/"?"/":(e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function Ea(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=De(t),a=De(e),n=r==="/"?[]:r.slice(1).split("/"),i=a==="/"?[]:a.slice(1).split("/"),o={};let s=!1;for(let u=0;u<n.length;u+=1){const c=n[u];if(c==="*"){s=!0;const d=i.slice(u).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const m=i[u];if(m===void 0)return{matched:!1,params:{}};if(c.startsWith(":")){const d=c.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(m);continue}if(c!==m)return{matched:!1,params:{}}}return!s&&i.length>n.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}class ja{constructor(e={}){D(this,"currentPath");D(this,"currentParams",{});D(this,"currentPattern",null);D(this,"enabled",!1);D(this,"hashListener",null);D(this,"listeners",new Set);D(this,"defaultPath");D(this,"settingHash",!1);this.defaultPath=De(e.defaultPath??"/"),this.currentPath=this.defaultPath}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=a=>{if(this.settingHash)return;const n=De(window.location.hash);this.setPath(n,a)},r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r,e("init")}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&window.removeEventListener("hashchange",this.hashListener),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,zo(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=De(e);if(r!==this.currentPath){if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{window.location.hash="#"+r}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(r,"navigate");return}this.setPath(r,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const a=De(e);if(a===this.currentPath)return;const n=this.currentPath;this.currentPath=a,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:a,previousPath:n,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function zo(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}const Me=(t,e)=>{try{return t()}catch{return e}},Da=t=>{if(typeof t=="string")return t;if(t===null)return"null";if(t===void 0)return"";try{return JSON.stringify(t)}catch{return String(t)}},Ba=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},Fa=t=>({set:(e,r)=>Me(()=>{const a=t();return a?(a.setItem(String(e),Da(r)),!0):!1},!1),get:e=>Me(()=>{const r=t();return r?Ba(r.getItem(String(e))):null},null),remove:e=>Me(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>Me(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),Ro=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,Eo=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,xt=()=>typeof globalThis>"u"?null:globalThis.document??null,jo=t=>{if(t==null)return null;if(t instanceof Date)return t.toUTCString();if(typeof t=="string"){const e=new Date(t);return Number.isNaN(e.getTime())?null:e.toUTCString()}if(typeof t=="number"&&Number.isFinite(t)){const e=new Date;return e.setTime(e.getTime()+t*864e5),e.toUTCString()}return null},er=(t={})=>{const e=[],r=jo(t.expires);if(r&&e.push(`expires=${r}`),typeof t.maxAge=="number"&&Number.isFinite(t.maxAge)&&e.push(`max-age=${Math.floor(t.maxAge)}`),e.push(`path=${t.path??"/"}`),t.domain&&e.push(`domain=${t.domain}`),t.secure&&e.push("secure"),t.sameSite){const a=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${a}`)}return e.length===0?"":`; ${e.join("; ")}`},Oa=()=>{const t=xt();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const a of r.split(";")){const n=a.trim();if(!n)continue;const i=n.indexOf("=");if(i<0){e[decodeURIComponent(n)]="";continue}const o=decodeURIComponent(n.slice(0,i)),s=decodeURIComponent(n.slice(i+1));e[o]=s}return e},Do={set:(t,e,r)=>Me(()=>{const a=xt();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(Da(e));return a.cookie=`${n}=${i}${er(r)}`,!0},!1),get:t=>Me(()=>{const r=Oa()[String(t)];return r===void 0?null:Ba(r)},null),remove:(t,e)=>Me(()=>{const r=xt();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${er(n)}`,!0},!1),clear:()=>Me(()=>{const t=xt();if(!t)return!1;const e=Oa();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${er({expires:new Date(0),maxAge:0})}`}return!0},!1)},at=Fa(Ro),Bo=Fa(Eo),tr={set:at.set,get:at.get,remove:at.remove,clear:at.clear,local:at,session:Bo,cookies:Do},Fo=["log","error","warn","info","debug"],Oo=()=>typeof globalThis>"u"?null:globalThis.console??null,_o=t=>(...e)=>{const r=Oo();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},_a=Fo.reduce((t,e)=>(t[e]=_o(e),t),{}),nt={Math,JSON,Object,Array,Number,String,Boolean,Date,Map,Set,WeakMap,WeakSet,RegExp,Symbol,Promise,Error,TypeError,RangeError,Infinity:1/0,NaN:NaN,undefined:void 0,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,structuredClone:typeof structuredClone=="function"?structuredClone:void 0},rr={util:Lo,console:_a,storage:tr};function Ua(t){if(typeof globalThis>"u")return{found:!1,value:void 0};if(t in Object.prototype)return{found:!1,value:void 0};const e=globalThis;return t in e?{found:!0,value:e[t]}:{found:!1,value:void 0}}const wt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Pe extends Error{constructor(r,a,n){super(Uo(r,a,n));D(this,"kind");D(this,"limit");D(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=a,this.source=n}}function Uo(t,e,r){switch(t){case"component-depth":return`[aktion] runtime aborted at ${r}: component recursion exceeded ${e} levels — check for a component that calls itself directly or transitively.`;case"iterations":return`[aktion] runtime aborted at ${r}: exceeded ${e} total loop iterations in a single render — narrow the iterable or split the loop.`;case"array-length":return`[aktion] runtime aborted at ${r}: array length would exceed ${e} elements.`}}function Ha(t={}){return{componentDepthLimit:t.componentDepthLimit??wt.componentDepthLimit,iterationLimit:t.iterationLimit??wt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??wt.arrayLengthLimit,componentDepth:0,iterations:0}}function ar(t){t.iterations=0,t.componentDepth=0}function it(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Pe("iterations",t.iterationLimit,r)}function nr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Pe("component-depth",r.componentDepthLimit,`component "${e}"`)}function ir(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const Va=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),Wa=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),kt=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function or(t,e={}){const r={state:t,bindings:new Map,expressions:new Map,trackedState:new Set,loopVars:new Map,mutableBindings:new Map,stateAliases:[],router:e.router,library:e.library,componentDecls:new Map,effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,actionRunner:e.actionRunner,notify:e.notify,onEmit:e.onEmit,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??Ha()};return r.disposers.push(()=>{for(const a of r.timers.timeouts)clearTimeout(a);for(const a of r.timers.intervals)clearInterval(a);r.timers.timeouts.clear(),r.timers.intervals.clear()}),r}function sr(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function qa(t){t.mutableBindings.clear()}function xe(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const n=t.stateAliases[r].get(e);if(n!==void 0)return n}return e}function St(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const n=a.computed.value;if(typeof n!="string"&&typeof n!="number")return null;r.unshift(String(n))}else if(a.property)r.unshift(a.property);else return null;a=a.object}return a.kind!=="StateRef"?null:{name:xe(e,a.name),path:r}}function Ct(t,e){if(t.kind==="StateRef")return xe(e,t.name);if(t.kind==="Member"){const r=St(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=en(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function Ga(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=Tt(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)lr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!Ka(r.expression))continue;const a=N(r.expression,e);e.state.set(r.identifier,a)}Wo(t,e),Vo(t,e)}const Ho=8;function Vo(t,e){const r=[],a=o=>{const s=new Set,u=e.trackedState;e.trackedState=s;try{const c=N(o.expr,e);e.state.set(o.name,c)}finally{e.trackedState=u}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||$t(o.expression)||Ka(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),a(s)}if(r.length===0)return;let n=!1;const i=e.state.subscribe(o=>{if(!n){n=!0;try{const s=new Set(o);for(let u=0;u<Ho;u+=1){let c=!1;for(const m of r){if(!vt(s,m.deps))continue;const f=e.state.get(m.name);a(m),e.state.get(m.name)!==f&&(s.add(m.name),c=!0)}if(!c)break}}finally{n=!1}}});e.disposers.push(i)}function $t(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&$t(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&$t(e.value));case"Template":return t.expressions.length===0;default:return!1}}function Ka(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function lr(t,e){switch(t.kind){case"ComponentDeclaration":{e.componentDecls.set(t.name,t),e.actionDecls.set(t.name,{kind:"ActionDeclaration",name:t.name,params:t.params,optimistic:!1,body:t.body,loc:t.loc});return}case"EffectDeclaration":e.effectDecls.set(t.name,t);return;case"ActionDeclaration":e.actionDecls.set(t.name,t);return;case"HookDeclaration":e.hookDecls.set(t.name,t);return;case"Await":case"Return":case"ExpressionStatement":return;case"Assignment":{if(t.isState)return;e.expressions.set(t.identifier,t.expression);const r=t.expression;e.bindings.set(t.identifier,()=>N(r,e));return}}}function Ya(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ExpressionStatement":case"ThrowStatement":return!0;default:return!1}}function Wo(t,e){let r=!1;for(const a of t.statements)if(Ya(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&$t(a.expression)&&e.state.set(a.identifier,Tt(a.expression));for(const a of t.statements)if(Ya(a))try{At(a,e)}catch(n){if(n instanceof we||n instanceof Ce||n instanceof Ie)continue;if(n instanceof Pe)throw n;console.error("[aktion] top-level statement threw",n)}}}function qo(t,e,r){const a=t[0];if(!a||a.kind!=="Object")return console.error('[aktion] $router expects an object literal of route arms (e.g. `$router({ "/": Home(), default: NotFound() })`).',r),e.router?.setActiveMatch(null,{}),null;const n=Ts(e);let i=null;for(const o of a.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const u=Ea(s,n);if(u.matched)return Xa(s,o.value,u.params,e)}return i?Xa(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function Xa(t,e,r,a){const n=a.loopVars.get("params"),i=a.loopVars.has("params");a.loopVars.set("params",r);try{const o=N(e,a);return a.router?.setActiveMatch(t,r),o}finally{i?a.loopVars.set("params",n):a.loopVars.delete("params")}}function Tt(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Tt(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Tt(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function N(t,e){switch(t.kind){case"Literal":return t.value;case"Identifier":{if(e.loopVars.has(t.name))return e.loopVars.get(t.name);if(e.mutableBindings.has(t.name))return e.mutableBindings.get(t.name);if(t.name==="route")return e.trackedState.add("route"),e.router?As(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const o=r();return e.mutableBindings.set(t.name,o),o}const a=e.actionDecls.get(t.name);if(a)return vs(a,e);const n=e.componentDecls.get(t.name);if(n)return ys(n);if(Object.prototype.hasOwnProperty.call(nt,t.name))return nt[t.name];if(e.library&&Ne(e.library,t.name))return xs(t.name);const i=Ua(t.name);return i.found?i.value:null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(rr,t.name))return rr[t.name];const r=xe(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const a of t.elements){if(a.kind==="Spread"){const n=N(a.argument,e);if(Array.isArray(n))for(const i of n)r.push(i);else if(n!=null&&typeof n=="string")for(const i of n)r.push(i);continue}r.push(N(a,e))}return r}case"Object":{const r={};for(const a of t.properties){if(a.spread){const i=N(a.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const n=a.computedKey?String(N(a.computedKey,e)??""):a.key;r[n]=N(a.value,e)}return r}case"Member":{if(ts(t))return rs(t,e);const r=as(t,e);if(r)return ns(t,e,r);const a=N(t.object,e);if(t.optional&&a==null)return;if(t.computed){const n=N(t.computed,e);return dr(a,n)}return pr(a,t.property??"")}case"Unary":{if(t.operator==="delete"){const a=t.argument;if(a.kind==="Member"&&a.property){const n=N(a.object,e);if(n&&typeof n=="object")try{return delete n[a.property],!0}catch{return!1}}return!1}const r=N(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-O(r);case"+":return+O(r);case"~":return~oe(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return cs(t.operator,t.left,t.right,e);case"Ternary":{const r=N(t.test,e);return N(r?t.consequent:t.alternate,e)}case"Call":return ds(t.callee,t.arguments,e,t.loc);case"MethodCall":return us(t,e);case"Invoke":return os(t,e);case"New":return ss(t,e);case"BuiltinCall":return ws(t.name,t.arguments,e);case"Template":return ls(t.quasis,t.expressions,e);case"Spread":return N(t.argument,e);case"Block":return cr(t,e,{});case"Lambda":{const r=t.params,a=t.body,n=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),u=e.stateAliases.slice();e.loopVars.clear();for(const[d,f]of i)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of n)e.stateAliases.push(d);const c=[],m=(d,f)=>{c.push({name:d,had:e.loopVars.has(d),prev:e.loopVars.get(d)}),e.loopVars.set(d,f)};for(let d=0;d<r.length;d+=1){const f=r[d];let g=o[d];if(g===void 0&&f.defaultValue&&(g=N(f.defaultValue,e)),f.pattern){for(const h of ot(f.pattern,g,e))m(h.name,h.value);continue}m(f.name,g)}try{return N(a,e)}finally{for(const d of c)d.had?e.loopVars.set(d.name,d.prev):e.loopVars.delete(d.name);e.loopVars.clear();for(const[d,f]of s)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of u)e.stateAliases.push(d)}}}default:return null}}class we{constructor(){D(this,"kind","break")}}class Ce{constructor(){D(this,"kind","continue")}}class Ie{constructor(e){D(this,"kind","return");this.value=e}}function Ja(t,e){if(N(t.test,e)){ke(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){Ja(t.alternate,e);return}t.alternate.kind==="Block"&&ke(t.alternate.body,e)}}function Go(t,e){const r=N(t.discriminant,e);let a=!1;try{for(const n of t.cases)a||(n.test===null||N(n.test,e)===r)&&(a=!0),a&&ke(n.body,e)}catch(n){if(n instanceof we)return;throw n}}function Ko(t,e){const r=N(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,u=t.destructure??[],c=u.map(m=>({name:m,had:e.loopVars.has(m),value:e.loopVars.get(m)}));try{let m=0;const d=(Array.isArray(r),r);for(const f of d){it(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,m);for(const g of u){const h=f&&typeof f=="object"?f[g]:void 0;e.loopVars.set(g,h)}try{ke(t.body.body,e)}catch(g){if(g instanceof Ce){m+=1;continue}if(g instanceof we)return;throw g}m+=1}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const m of c)m.had?e.loopVars.set(m.name,m.value):e.loopVars.delete(m.name)}}function Yo(t,e){for(t.init&&Nt(t.init,e);!(t.test&&!N(t.test,e));){it(e.budget,1,"`for` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof Ce)){if(r instanceof we)return;throw r}}t.update&&N(t.update,e)}}function Xo(t,e){for(;N(t.test,e);){it(e.budget,1,"`while` loop");try{ke(t.body.body,e)}catch(r){if(r instanceof Ce)continue;if(r instanceof we)return;throw r}}}function Jo(t,e){for(;;){it(e.budget,1,"`do…while` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof Ce)){if(r instanceof we)return;throw r}}if(!N(t.test,e))break}}function Zo(t,e){const r=N(t.expression,e),a=ot({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function ot(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const u of t.bindings){if(u.rest){a.push({name:u.name,value:o.slice(s)}),s=o.length;continue}let c=o[s];c===void 0&&u.defaultValue&&(c=N(u.defaultValue,r)),u.name!==""&&a.push({name:u.name,value:c}),s+=1}return a}const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const c={};for(const[m,d]of Object.entries(n))i.has(m)||(c[m]=d);a.push({name:o.name,value:c});continue}const s=o.sourceKey??o.name;i.add(s);let u=n[s];u===void 0&&o.defaultValue&&(u=N(o.defaultValue,r)),a.push({name:o.name,value:u})}return a}function Qo(t,e){const r=N(t.iterable,e);if(r==null||typeof r!="object")return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item);try{for(const i in r){it(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{ke(t.body.body,e)}catch(o){if(o instanceof Ce)continue;if(o instanceof we)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function es(t,e){try{ke(t.block.body,e)}catch(r){if(r instanceof we||r instanceof Ce||r instanceof Ie)throw r;if(t.catchBlock){const a=t.catchParam,n=a?e.loopVars.has(a):!1,i=a?e.loopVars.get(a):void 0;a&&e.loopVars.set(a,r);try{ke(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&ke(t.finallyBlock.body,e)}}function ke(t,e){for(const r of t)Nt(r,e)}function At(t,e){Nt(t,e)}function Nt(t,e){switch(t.kind){case"ExpressionStatement":N(t.expression,e);return;case"Assignment":{const r=N(t.expression,e);if(t.identifier)if(t.isState){const a=xe(e,t.identifier);e.state.set(a,r)}else e.bindings.has(t.identifier)&&!e.loopVars.has(t.identifier)?e.mutableBindings.set(t.identifier,r):e.loopVars.set(t.identifier,r);return}case"IfStatement":Ja(t,e);return;case"SwitchStatement":Go(t,e);return;case"ForOfStatement":Ko(t,e);return;case"ForClassicStatement":Yo(t,e);return;case"ForInStatement":Qo(t,e);return;case"WhileStatement":Xo(t,e);return;case"DoWhileStatement":Jo(t,e);return;case"DestructureStatement":Zo(t,e);return;case"TryStatement":es(t,e);return;case"BreakStatement":throw new we;case"ContinueStatement":throw new Ce;case"ThrowStatement":throw N(t.argument,e);case"Return":{const r=t.argument?N(t.argument,e):void 0;throw new Ie(r)}case"Await":N(t.argument,e);return;default:return}}function ts(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&Object.prototype.hasOwnProperty.call(rr,e.name)?!1:e.kind==="StateRef"}function rs(t,e){const r=Za(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=xe(e,a.name);return Qa(r,n,e)}function Za(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function Qa(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,u=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(u=String(s))):s=N(o.computed,r):(s=o.property??"",u=o.property??"");const c=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&u!==null&&c?n.push(u):i=!1,a=o.computed?dr(a,s):pr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function as(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=N(r,e);return kt(a)?a:null}function ns(t,e,r){const a=Za(t),n=a[0];if(n&&n.computed===void 0&&n.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,n.property)){let i=r.__methods[n.property];for(let o=1;o<a.length;o+=1){const s=a[o];s.computed?i=dr(i,N(s.computed,e)):i=pr(i,s.property??"")}return i}return Qa(a,r.__atom,e)}function is(t,e,r){const a=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,n=e.stores.get(a);if(n)return n;const i=t[0]?N(t[0],e):{},o={},s={};if(i&&typeof i=="object"&&!Array.isArray(i))for(const[d,f]of Object.entries(i))typeof f=="function"?s[d]=f:o[d]=f;const u=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(u,o);const c={},m={__kind:"Store",__atom:u,__methods:c};for(const[d,f]of Object.entries(s))c[d]=(...g)=>f(m,...g);return e.stores.set(a,m),m}function en(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const i=a.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(a.property)r.unshift(a.property);else return null;a=a.object}if(a.kind!=="Identifier")return null;const n=N(a,e);return kt(n)?{atom:n.__atom,path:r}:null}function os(t,e){if(t.callee.kind==="StateRef"){const n=t.callee.name;if(n==="state")return gs(t.arguments,e,t.loc);if(n==="memo")return hs(t.arguments,e,t.loc);switch(n){case"store":return is(t.arguments,e,t.loc);case"router":return qo(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Ia(o?N(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:Ps(o?N(o,e):null)}}case"i18n":{const o=t.arguments[0],s=o?N(o,e):null,u=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return La(u)}case"emit":{const o=t.arguments[0]?String(N(t.arguments[0],e)):"",s=t.arguments[1]?N(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&N(t.arguments[0],e),tr}const i=e.hookDecls.get(n);if(i)return bs(i,t.arguments,e)}const r=N(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return r.apply(void 0,a)}catch(n){return console.error("[aktion] call expression threw",n),null}}function ss(t,e){const r=N(t.callee,e);if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return Reflect.construct(r,a)}catch(n){return console.error("[aktion] `new` threw",n),null}}function cr(t,e,r){let a=null;const n=[];try{for(const i of t.body)switch(i.kind){case"ExpressionStatement":a=N(i.expression,e);continue;case"Assignment":{if(i.isState&&i.identifier){const s=xe(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const c=N(i.expression,e);e.state.declare(s,c),a=c;continue}const u=N(i.expression,e);e.state.set(s,u),a=u;continue}const o=N(i.expression,e);e.bindings.has(i.identifier)&&!e.loopVars.has(i.identifier)?e.mutableBindings.set(i.identifier,o):(e.loopVars.has(i.identifier)||n.push(i.identifier),e.loopVars.set(i.identifier,o)),a=o;continue}case"Return":return a=i.argument?N(i.argument,e):void 0,a;case"ThrowStatement":throw N(i.argument,e);case"EffectDeclaration":{const o=e.componentEffectStack[e.componentEffectStack.length-1];o?o.push({decl:i,capturedAliases:e.stateAliases.map(s=>new Map(s)),capturedLoopVars:new Map(e.loopVars)}):lr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":lr(i,e);continue;case"Await":continue;case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"DestructureStatement":Nt(i,e);continue}}catch(i){if(i instanceof Ie)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function ls(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=mr(N(e[n],r)),a+=t[n+1]??"";return a}function cs(t,e,r,a){if(t==="&&"){const o=N(e,a);return o&&N(r,a)}if(t==="||"){const o=N(e,a);return o||N(r,a)}if(t==="??"){const o=N(e,a);return o??N(r,a)}const n=N(e,a),i=N(r,a);switch(t){case"+":return typeof n=="string"||typeof i=="string"?mr(n)+mr(i):O(n)+O(i);case"-":return O(n)-O(i);case"*":return O(n)*O(i);case"/":{const o=O(i);return o===0?0:O(n)/o}case"%":{const o=O(i);return o===0?0:O(n)%o}case"**":return O(n)**O(i);case"==":case"===":return n===i;case"!=":case"!==":return n!==i;case">":return O(n)>O(i);case"<":return O(n)<O(i);case">=":return O(n)>=O(i);case"<=":return O(n)<=O(i);case"&":return oe(n)&oe(i);case"|":return oe(n)|oe(i);case"^":return oe(n)^oe(i);case"<<":return oe(n)<<(Le(i)&31);case">>":return oe(n)>>(Le(i)&31);case">>>":return Le(n)>>>(Le(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return n instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(n)in i}catch{return!1}}default:return null}}function oe(t){return O(t)|0}function Le(t){return O(t)>>>0}function us(t,e){const r=N(t.object,e);if(r==null)return t.optional?void 0:null;const a=kt(r)?r.__methods[t.method]:r[t.method];if(typeof a!="function")return null;const n=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=N(o.argument,e);if(Array.isArray(s))for(const u of s)n.push(u);continue}n.push(N(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Pe)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function ds(t,e,r,a){const n=r.componentDecls.get(t);if(n)return ms(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(h=>N(h,r));return rn(i,g,r)}if(t==="setTimeout"||t==="setInterval")return ks(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?N(e[0],r):void 0;g!=null&&(t==="clearTimeout"?(clearTimeout(g),r.timers.timeouts.delete(g)):(clearInterval(g),r.timers.intervals.delete(g)));return}const o=r.loopVars.get(t);if(typeof o=="function"){const g=e.map(h=>N(h,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const h=e.map(b=>N(b,r));return g(...h)}}if(Object.prototype.hasOwnProperty.call(nt,t)&&typeof nt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ne(r.library,t))){const g=nt[t],h=[];for(const b of e){if(b.kind==="Spread"){const v=N(b.argument,r);if(Array.isArray(v))for(const y of v)h.push(y);continue}h.push(N(b,r))}try{return g(...h)}catch(b){return console.error(`[aktion] global "${t}" threw`,b),null}}if(r.library&&!Ne(r.library,t)){const g=Ua(t);if(g.found&&typeof g.value=="function"){const h=g.value,b=[];for(const v of e){if(v.kind==="Spread"){const y=N(v.argument,r);if(Array.isArray(y))for(const x of y)b.push(x);continue}b.push(N(v,r))}try{return h(...b)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ne(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let u;const c=[...e];if(c.length>0){const g=c[c.length-1];if(g.kind==="Object"){const h=g.properties.find(b=>!b.spread&&b.key==="key");if(h){u=N(h.value,r);const b=g.properties.filter(v=>v!==h);b.length>0?c[c.length-1]={...g,properties:b}:c.pop()}}}const{args:m,argMeta:d}=ps(r,t,c);return{__kind:"Component",name:t,args:m,argMeta:d,explicitKey:u,source:a}}function ps(t,e,r){const a=t.library?Ne(t.library,e):void 0;if(!a){const f=r.map(h=>N(h,t)),g=r.map(h=>{const b=Ct(h,t);return b!==null?{stateRef:b}:{}});return{args:f,argMeta:g}}const n=new Map;a.props.forEach((f,g)=>{if(n.set(f.name,g),f.aliases)for(const h of f.aliases)n.has(h)||n.set(h,g)});const i=Xt(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let u=-1;for(let f=r.length-1;f>=0;f-=1)if(r[f].kind==="Object"){u=f;break}for(let f=0;f<r.length;f+=1){if(f===u)continue;const g=r[f];s.push({expr:g,value:N(g,t)})}if(u>=0){const f=r[u];if(f.kind==="Object")for(const g of f.properties){if(g.spread)continue;const h=n.get(g.key);if(h===void 0)continue;const b=N(g.value,t);o[h].value=b,o[h].filled=!0;const v=Ct(g.value,t);v!==null&&(o[h].meta={stateRef:v})}}if(s.length>0&&i>=0&&!o[i].filled){const{expr:f,value:g}=s.shift();o[i].value=g,o[i].filled=!0;const h=Ct(f,t);h!==null&&(o[i].meta={stateRef:h})}let c=0;for(const{expr:f,value:g}of s){for(;c<a.props.length&&o[c].filled;)c+=1;if(c>=a.props.length)break;o[c].value=g,o[c].filled=!0;const h=Ct(f,t);h!==null&&(o[c].meta={stateRef:h}),c+=1}const m=o.map(f=>f.value),d=o.map(f=>f.meta);for(;m.length>0&&m[m.length-1]===void 0;)m.pop(),d.pop();return{args:m,argMeta:d}}function ms(t,e,r,a){const n=[],i={};let o,s=-1;for(let h=e.length-1;h>=0;h-=1)if(e[h].kind==="Object"){s=h;break}let u=s>=0?e[s]:null,c=!1;if(u&&u.kind==="Object"){const h=new Set(t.params.map(b=>b.name));for(const b of u.properties)if(!b.spread&&(b.key==="key"||h.has(b.key))){c=!0;break}}c||(s=-1,u=null);for(let h=0;h<e.length;h+=1)h!==s&&n.push(e[h]);if(u&&u.kind==="Object")for(const h of u.properties)h.spread||(h.key==="key"?o=h.value:i[h.key]=h.value);const m=n.map(h=>h.kind==="Spread"?N(h.argument,r):N(h,r)),d=[];for(let h=0;h<n.length;h+=1){const b=n[h],v=m[h];if(b.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const f={};for(const[h,b]of Object.entries(i))f[h]=N(b,r);const g=o?N(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:f,explicitKey:g,source:a}}function tn(t,e,r){const{decl:a,positional:n,named:i}=t,o=[],s=(f,g)=>{o.push({name:f,had:e.loopVars.has(f),prev:e.loopVars.get(f)}),e.loopVars.set(f,g)};for(let f=0;f<a.params.length;f+=1){const g=a.params[f];if(g.pattern){let b=n[f];b===void 0&&g.defaultValue&&(b=N(g.defaultValue,e));for(const v of ot(g.pattern,b,e))s(v.name,v.value);continue}let h;i[g.name]!==void 0?h=i[g.name]:n[f]!==void 0?h=n[f]:g.defaultValue?h=N(g.defaultValue,e):h=void 0,s(g.name,h)}if(n.length>a.params.length){const f=n.slice(a.params.length),g=f.length===1?f[0]:f;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}if(a.slots.length>0){const f={};for(const g of a.slots)i[g]!==void 0&&(f[g]=i[g]);o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",f)}const u=new Map;for(const f of a.body.body)if(f.kind==="Assignment"&&f.isState){const g=`${r}:${f.identifier}`;u.set(f.identifier,g)}e.stateAliases.push(u);const c=[];e.componentEffectStack.push(c);const m=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:cr(a.body,e,{stateAsDeclaration:!0}),effects:c,hooks:d.cursor}}finally{e.hookScope=m,e.componentEffectStack.pop(),e.stateAliases.pop();for(const f of o)f.had?e.loopVars.set(f.name,f.prev):e.loopVars.delete(f.name)}}function rn(t,e,r){return an(t.params,t.body,e,r)}function an(t,e,r,a){const n=[],i=(o,s)=>{n.push({name:o,had:a.loopVars.has(o),prev:a.loopVars.get(o)}),a.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let u=r[o];if(u===void 0&&s.defaultValue&&(u=N(s.defaultValue,a)),s.pattern){for(const c of ot(s.pattern,u,a))i(c.name,c.value);continue}i(s.name,u)}try{return cr(e,a,{stateAsDeclaration:a.state.isRendering()})}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}function nn(t){const e=t.hookScope;if(!e)return null;let r=t.hookStore.get(e.instanceKey);return r||(r=[],t.hookStore.set(e.instanceKey,r)),r}function fs(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function gs(t,e,r){const a=nn(e);if(!a)return sn("state",r),[t[0]?N(t[0],e):void 0,()=>{}];const n=e.hookScope.cursor++;let i=a[n];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?N(t[0],e):void 0},a[n]=i);const o=i,s=u=>{const c=typeof u=="function"?u(o.value):u;Object.is(c,o.value)||(o.value=c,e.notify?.())};return[o.value,s]}function hs(t,e,r){const a=t[0],n=t[1],i=()=>{const f=a?N(a,e):void 0;return typeof f=="function"?f():f},o=nn(e);if(!o)return sn("memo",r),i();const s=e.hookScope.cursor++,u=n?N(n,e):void 0,c=Array.isArray(u)?u:void 0,m=o[s];if(m&&m.kind==="memo"&&c&&m.deps&&fs(m.deps,c))return m.value;const d=i();return o[s]={kind:"memo",deps:c,value:d},d}function bs(t,e,r){const a=[];for(const n of e){if(n.kind==="Spread"){const i=N(n.argument,r);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,r))}return an(t.params,t.body,a,r)}let on=!1;function sn(t,e){on||(on=!0,console.error(`[aktion] $${t}(...) was called outside a component render. Hooks may only be called at the top level of a component body or another $hook.`,e))}function ln(t,e){t.hookStore.delete(e)}function vs(t,e){const r=e.stateAliases.map(n=>new Map(n)),a=new Map(e.loopVars);return(...n)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,u]of a)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return rn(t,n,e)}finally{e.loopVars.clear();for(const[s,u]of i)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function ys(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function xs(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function ws(t,e,r){if(t==="__rui_assign__")return Ss(e,r);if(t==="__rui_postfix__")return Cs(e,r);if(t==="__rui_prefix__")return $s(e,r);if(t==="__rui_await__")return e[0]?N(e[0],r):void 0;const a=Sa[t];if(!a)return null;const n=e.map(i=>N(i,r));return a(n)}function ze(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:O(e)+O(r);case"-=":return O(e)-O(r);case"*=":return O(e)*O(r);case"/=":{const a=O(r);return a===0?0:O(e)/a}case"%=":{const a=O(r);return a===0?0:O(e)%a}case"**=":return O(e)**O(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return oe(e)&oe(r);case"|=":return oe(e)|oe(r);case"^=":return oe(e)^oe(r);case"<<=":return oe(e)<<(Le(r)&31);case">>=":return oe(e)>>(Le(r)&31);case">>>=":return Le(e)>>>(Le(r)&31);default:return r}}function ks(t,e,r){const a=e[0]?N(e[0],r):null;if(typeof a!="function")return null;const n=a,i=e[1]?O(N(e[1],r)):0,o=[];for(let c=2;c<e.length;c+=1)o.push(N(e[c],r));const s=()=>{try{n(...o)}catch(c){console.error(`[aktion] ${t} callback threw`,c)}finally{r.notify?.()}};if(t==="setTimeout"){const c=setTimeout(()=>{r.timers.timeouts.delete(c),s()},i);return r.timers.timeouts.add(c),c}const u=setInterval(s,i);return r.timers.intervals.add(u),u}function Ss(t,e){const[r,a,n]=t;if(!r||!a)return null;const i=n&&n.kind==="Literal"?String(n.value??"="):"=",o=N(a,e);if(r.kind==="StateRef"){const s=xe(e,r.name),u=e.state.get(s),c=ze(i,u,o);return e.state.set(s,c),c}if(r.kind==="Member"){const s=St(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&Ma(d)){let h=d;for(let b=0;b<s.path.length-1;b+=1)h=h?.[s.path[b]];if(h&&typeof h=="object"){const b=s.path[s.path.length-1],v=h[b],y=ze(i,v,o);return h[b]=y,e.notify?.(),y}}const f=ur(d,s.path),g=ze(i,f,o);return e.state.setPath(s.name,s.path,g),g}const u=en(r,e);if(u){const d=ur(e.state.get(u.atom),u.path),f=ze(i,d,o);return e.state.setPath(u.atom,u.path,f),f}const c=N(r.object,e),m=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(c&&typeof c=="object"&&m!=null){const d=c[String(m)],f=ze(i,d,o);return c[String(m)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const m=e.loopVars.get(s),d=ze(i,m,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=ze(i,m,o);return e.mutableBindings.set(s,d),d}const u=e.loopVars.get(s),c=ze(i,u,o);return e.loopVars.set(s,c),c}return o}function ur(t,e){let r=t;for(const a of e){if(r==null)return;if(Array.isArray(r)){const n=Number(a);r=Number.isNaN(n)?void 0:r[n];continue}if(typeof r=="object"){r=r[a];continue}return}return r}function cn(t,e,r){const[a,n]=t;if(!a)return null;const o=(n&&n.kind==="Literal"?String(n.value??"++"):"++")==="--"?-1:1;if(a.kind==="StateRef"){const s=xe(e,a.name),u=O(e.state.get(s)),c=u+o;return e.state.set(s,c),r==="prefix"?c:u}if(a.kind==="Member"){const s=St(a,e);if(s){const u=O(ur(e.state.get(s.name),s.path)),c=u+o;return e.state.setPath(s.name,s.path,c),r==="prefix"?c:u}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const m=O(e.loopVars.get(s)),d=m+o;return e.loopVars.set(s,d),r==="prefix"?d:m}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=O(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=m+o;return e.mutableBindings.set(s,d),r==="prefix"?d:m}const u=O(e.loopVars.get(s)),c=u+o;return e.loopVars.set(s,c),r==="prefix"?c:u}return null}function Cs(t,e){return cn(t,e,"postfix")}function $s(t,e){return cn(t,e,"prefix")}function Ts(t){if(t.trackedState.add("route"),t.router)return t.router.getPath();if(t.state.has("route")){const e=t.state.get("route");if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"&&"path"in e){const r=e.path;if(typeof r=="string"&&r)return r}}return"/"}function As(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof globalThis<"u"&&globalThis.location){const i=globalThis.location?.search??"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function dr(t,e){if(t!=null){if(Array.isArray(t)){const r=un(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=un(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function un(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t)))r=Number(t);else return null;return r<0&&(r=e+r),r<0||r>=e?null:r}function pr(t,e){if(t!=null){if(Array.isArray(t)){switch(e){case"length":return t.length;case"first":return t[0]??null;case"last":return t.length===0?null:t[t.length-1]}return t.map(r=>{if(r&&typeof r=="object")return r[e]})}if(typeof t=="string"&&e==="length")return t.length;if(typeof t=="object")return t[e]}}function O(t){if(typeof t=="number")return t;if(typeof t=="string"){if(t.trim()==="")return 0;const e=Number(t);return Number.isNaN(e)?0:e}return typeof t=="boolean"&&t?1:0}const Ns=new Set(["colors","radius","font","motion","elevation"]),Ms=new Set(["name","direction"]);function Ps(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[a,n]of Object.entries(r))if(n!=null&&!Ms.has(a)&&Ns.has(a)&&n&&typeof n=="object"&&!Array.isArray(n)){const i=a==="colors"?"color":a;for(const[o,s]of Object.entries(n)){if(s==null)continue;const u=i+Is(o);e[u]=Ls(s)}}return e}function Is(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Ls(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function mr(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(typeof t=="object"&&t!==null){const e=t.toString;if(typeof e=="function"&&e!==Object.prototype.toString){const r=e.call(t);if(typeof r=="string")return r}}try{return JSON.stringify(t)}catch{return String(t)}}function dn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const fr="::",zs=new Map;class pn{constructor(e){D(this,"mounted",new Map);D(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const a=new Set(e.map(n=>n.name));for(const n of[...this.mounted.keys()])n.includes(fr)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],zs)}syncInstanceEffects(e,r,a){const n=`${e}${fr}`,i=new Set(r.map(o=>`${n}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(n)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${n}${o.decl.name}`,u=this.mounted.get(s);if(u){u.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${fr}`;for(const a of[...this.mounted.keys()])a.startsWith(r)&&this.unmount(a)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,a,n,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:a,capturedAliases:n,capturedLoopVars:i};this.mounted.set(e,o);const u=Rs(()=>{for(const f of o.cleanups.splice(0))try{f()}catch(g){fn(e,g)}try{mn(r,a(),o,this.options)}catch(f){console.error(`[aktion] effect "${e}" failed`,f)}finally{this.options.notify()}},r.rateLimit,o);let c=!1,m=!1,d=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(c=!0),f.name==="unmount"&&(m=!0);break;case"every":{d=!0;const g=setInterval(u,f.intervalMs);o.intervals.push(g);break}case"state":{const g=js(f.name,n),h=this.options.state.subscribe(b=>{Qt(b,g)&&u()});o.unsubscribers.push(h);break}}(r.triggers.length===0||c||!d&&!m&&r.triggers.every(f=>f.kind==="state"))&&u()}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const n of r.intervals)clearInterval(n);for(const n of r.unsubscribers)try{n()}catch{}for(const n of r.cleanups)try{n()}catch(i){fn(e,i)}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount"))try{mn(r.decl,r.ctxRef(),r,this.options)}catch(n){console.error(`[aktion] effect "${e}" unmount body threw`,n)}}}function Rs(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let i=null;const o=()=>{i&&(clearTimeout(i),i=null)};return r.cleanups.push(o),()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,t()},e.ms)}}let a=0,n=null;return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),()=>{const i=Date.now(),o=i-a;o>=e.ms?(a=i,t()):n||(n=setTimeout(()=>{n=null,a=Date.now(),t()},e.ms-o))}}function mn(t,e,r,a){const n=r.capturedAliases.length>0?e.stateAliases.slice():null;if(n){e.stateAliases.length=0;for(const o of r.capturedAliases)e.stateAliases.push(new Map(o))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[o,s]of r.capturedLoopVars)e.loopVars.set(o,s)}try{for(const o of t.body.body)Es(o,e,r,a)}finally{if(n){e.stateAliases.length=0;for(const o of n)e.stateAliases.push(o)}if(i){e.loopVars.clear();for(const[o,s]of i)e.loopVars.set(o,s)}}}function Es(t,e,r,a){switch(t.kind){case"ExpressionStatement":{const n=t.expression;if(n.kind==="Call"&&n.callee==="cleanup"){const i=n.arguments[0]?N(n.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(dn(n)){const i=n.arguments,o=i[0]?String(N(i[0],e)):"",s=i[1]?N(i[1],e):void 0;a.onEmit?.(o,s);return}return N(n,e)}case"Assignment":{const n=N(t.expression,e);if(t.identifier&&t.identifier!==""){const i=xe(e,t.identifier);e.state.set(i,n)}return n}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":At(t,e);return;default:return}}function fn(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function js(t,e){const r=t.indexOf("."),a=r<0?t:t.slice(0,r),n=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(a);if(o!==void 0)return o+n}return t}class gn{constructor(e){this.options=e}async run(e,r,a){const n=[];for(let o=0;o<e.params.length;o+=1){const s=e.params[o],u=r[o];n.push({name:s.name,had:a.loopVars.has(s.name),prev:a.loopVars.get(s.name)}),a.loopVars.set(s.name,u)}const i=e.optimistic?Ds(this.options.state):null;try{let o;try{for(const s of e.body.body)o=await this.runStatement(s,a)}catch(s){if(s instanceof Ie)return this.options.notify(),s.value;throw s}return this.options.notify(),o}catch(o){if(o instanceof we||o instanceof Ce){console.error(`[aktion] action "${e.name}" — \`${o.kind}\` outside a loop.`);return}throw i&&(Bs(this.options.state,i),this.options.notify()),console.error(`[aktion] action "${e.name}" failed`,o),o}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}async runStatement(e,r){switch(e.kind){case"ExpressionStatement":{const a=e.expression;if(dn(a)){const i=a.arguments,o=i[0]?String(N(i[0],r)):"",s=i[1]?N(i[1],r):void 0;this.options.onEmit?.(o,s);return}const n=N(a,r);return await Mt(n)}case"Await":{const a=N(e.argument,r);return await Mt(a)}case"Assignment":{const a=await Mt(N(e.expression,r));if(e.identifier)if(e.isState){const n=xe(r,e.identifier);this.options.state.set(n,a)}else r.loopVars.set(e.identifier,a);return a}case"Return":{if(!e.argument)throw new Ie(void 0);const a=await Mt(N(e.argument,r));throw new Ie(a)}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":At(e,r);return;default:return}}}async function Mt(t){return t&&typeof t.then=="function"?await t:t}function Ds(t){const e=new Map;for(const[r,a]of t.entries())e.set(r,a);return e}function Bs(t,e){for(const[r,a]of e)t.set(r,a)}const Fs="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",hn="6.7.2",bn="data-rui-font-awesome",Os=new Set(["solid","regular","brands"]),vn="solid";function _s(t){typeof document<"u"&&yn(document.head,document),yn(t,t.ownerDocument??document)}function yn(t,e){if(Us()||t.querySelector(`link[${bn}="${hn}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=Fs,a.setAttribute(bn,hn);try{t.appendChild(a)}catch{}}function Us(){return typeof globalThis.happyDOM<"u"}function gr(t){if(typeof t!="string")return[];const e=Vs(t).trim();if(!e)return[];if(!qs(e))return[];const[r,a]=Ws(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const Hs=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Vs(t){return t.replace(Hs,"")}function Ws(t){const e=t.indexOf(":");if(e===-1)return[vn,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return Os.has(r)?[r,a]:[vn,a||t]}function qs(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const Gs=["xs","sm","md","lg","xl"];function l(t,e,r){const a=document.createElement(t);if(e)for(const[n,i]of Object.entries(e))i==null||i===!1||(n==="class"?a.setAttribute("class",String(i)):n==="html"?a.innerHTML=String(i):i===!0?a.setAttribute(n,""):a.setAttribute(n,String(i)));if(r)for(const n of r)n!=null&&a.append(typeof n=="string"?document.createTextNode(n):n);return a}function C(t){return Array.isArray(t)?t:t==null?[]:[t]}function p(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function T(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function L(t,e=0){if(typeof t=="number")return t;if(typeof t=="string"&&t.trim()!==""){const r=Number(t);if(!Number.isNaN(r))return r}return e}const Ke=["base","sm","md","lg","xl"];function fe(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let a=!1;for(const[n,i]of e)Ke.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const Ks=/["'\\\n\r<>;{}]/g;function Ys(t){return t?t.replace(Ks,"").trim():""}const Xs=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function te(t,e){const r=(p(t)??"").trim();return!r||r.length>64||!Xs.test(r)?e:r}const Js=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function Zs(t){const e=p(t).trim();return!e||e.length>64||!Js.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Qs=new Set(["http","https","mailto","tel"]);function Ye(t,e="#"){const r=p(t).trim();if(!r)return e;const a=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!a||a.startsWith("//"))return e;if(a.startsWith("#")||a.startsWith("/")||a.startsWith("?")||a.startsWith("."))return a;const n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(a);if(!n)return a;const i=n[1].toLowerCase();return Qs.has(i)?a:e}const el=new Set(["http","https","data","blob"]);function ne(t){const e=p(t).trim();if(!e)return"";const r=e.replace(/[\u0000-\u001F\u007F]/g,"");if(!r||r.startsWith("//"))return"";if(r.startsWith("/")||r.startsWith(".")||r.startsWith("?")||r.startsWith("#"))return r;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!a)return r;const n=a[1].toLowerCase();return!el.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function tl(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function hr(t,e,r,a,n,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,a)}catch(c){console.error("[aktion] Col render() threw",c),s=null}const u=c=>{tl(c)?t.append(n.renderNode(c)):c!=null&&t.append(document.createTextNode(i(c,o)))};if(Array.isArray(s))for(const c of s)u(c);else u(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const c=m=>m.target?.closest("input,button,a,label,select,textarea")?!1:(m.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=m=>{c(m)},t.onkeydown=m=>{m.key!=="Enter"&&m.key!==" "||c(m)&&m.preventDefault()}}}function E(t,e={}){const r=p(t);if(!r)return null;const a=e.color?Zs(e.color):"",n=a?`color:${a};`:null,i=gr(r),o=["rui-icon",e.className].filter(Boolean).join(" ");return i.length===0?l("span",{class:o,"data-icon-size":e.size??null,style:n},[r]):l("i",{class:`${o} ${i.join(" ")}`,"data-icon-size":e.size??null,style:n,"aria-hidden":"true"})}const st=12,rl={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},al={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function nl(t){return rl[t]??"stretch"}function il(t){return al[t]??"flex-start"}function xn(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Be(t,e,r){for(const a of Ke){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function ol(t,e,r,a){for(const n of Ke){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function wn(t,e,r,a){const n=fe(t);if(n.kind==="single"){const i=n.value?String(n.value):a.defaultToken;r[a.attrName]=i;return}r[a.attrName]="responsive",r[a.responsiveFlag]="true",ol(e,n,a.cssVarPrefix,a.mapper)}function sl(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function ll(t){const e=fe(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const cl={name:"StackItem",description:"Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one child so it can `grow` to fill leftover space, `shrink`, set a `basis`, override `alignSelf`, or change visual `order` — the building block for asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), saveButton])` (input expands, button hugs).",props:[{name:"child",type:"Node",description:"Child node to wrap"},{name:"grow",type:"number",optional:!0,description:"flex-grow (0 or 1 typical)"},{name:"shrink",type:"number",optional:!0,description:"flex-shrink (0 or 1 typical)"},{name:"basis",type:"string",optional:!0,description:"flex-basis (`auto`, `0`, or CSS length)"},{name:"alignSelf",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Per-item cross-axis alignment"},{name:"order",type:"number",optional:!0,description:"Visual order override"},{name:"minWidth",type:"string",optional:!0,description:"CSS min-width"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a={class:"rui-stack-item"},n=[];e.grow!==void 0&&e.grow!==null&&(a["data-grow"]=String(L(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(L(e.shrink,1)));const i=p(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${te(i,i)}`);const o=p(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const m=L(e.order,0);a["data-order"]=String(m),n.push(`order:${m}`)}const s=p(e.minWidth);s&&n.push(`min-width:${te(s,s)}`);const u=p(e.maxWidth);u&&n.push(`max-width:${te(u,u)}`),n.length>0&&(a.style=n.join(";"));const c=l("div",a);return c.append(r.renderNode(e.child)),c}};function br(t,e,r,a,n){const i=fe(t),o=fe(a.gap),s=fe(a.padding),u=T(a.reverse),c={class:"rui-stack","data-wrap":T(a.wrap)?"true":null,"data-reverse":u?"true":null,"data-uniform":e?"true":"false","data-inline":T(a.inline)?"true":null},m=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";c["data-direction"]=xn(g,u)}else{c["data-direction"]="responsive",c["data-responsive-dir"]="true";for(const g of Ke){const h=i.values[g];h&&m.push(`--rui-stack-dir-${g}:${xn(String(h),u)}`)}}o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-stack-gap")),wn(a.align,m,c,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:nl}),wn(a.justify,m,c,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:il});const d=p(a.alignContent);if(d&&(c["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(c["data-padding"]=g)}else c["data-padding"]="responsive",c["data-responsive-padding"]="true",Be(m,s,"--rui-stack-padding");m.length>0&&(c.style=m.join(";"));const f=l("div",c);for(const g of C(a.children))f.append(n.renderNode(g));return f}const ul={name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},vr={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},yr={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},xr={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},wr={name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."},kr={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},kn={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},dl={name:"Row",description:"Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",props:[{name:"children",type:"Node[]",description:"Children laid out left → right"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Horizontal spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of children (default `center`). May be a responsive map."},{...vr},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...yr},{...xr},{...wr},{...kr},{...kn}],render:(t,e,r)=>br("row",T(e.grow),"center",e,r)},pl={name:"Column",description:"Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",props:[{name:"children",type:"Node[]",description:"Children laid out top → bottom"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Vertical spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of children (default `stretch`). May be a responsive map."},{...vr},{...yr},{...xr},{...wr},{...kr}],render:(t,e,r)=>br("column",!1,"stretch",e,r)},ml={name:"Stack",description:'Low-level flex container with a configurable, optionally responsive `direction`. Reach for `Row` or `Column` first — they are clearer for fixed-direction layouts. Use `Stack` when the direction itself must change across breakpoints, e.g. `direction: {base: "column", md: "row"}` for a sidebar that stacks on mobile. `gap`, `align`, `justify`, and `padding` also accept responsive maps. NOTE: a `row` Stack grows its children equally by default (`uniform=true`); set `uniform=false` for natural widths (this is `Row`\'s default).',props:[{name:"children",type:"Node[]",description:"Child components to stack"},{name:"direction",type:"string | object",optional:!0,enum:["column","row"],description:'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.'},{...ul},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...vr},{...kn},{...yr},{...xr},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...kr},{...wr}],render:(t,e,r)=>{const n=ll(e)==="row",i=e.uniform===void 0?n:T(e.uniform,n);return br(e.direction,i,"stretch",e,r)}},fl={name:"Center",description:'Centers its children on both axes — the easy way to drop a spinner, an empty state, a hero call-to-action, or a modal body into the middle of a region. Give it `minHeight` (e.g. `"60vh"`) to center vertically inside a tall area, or `axis` to center on only one axis. Multiple children stack in a column and are centered as a group.',props:[{name:"children",type:"Node[]",description:"Content to center"},{name:"axis",type:"string",optional:!0,enum:["both","horizontal","vertical"],description:"Which axis to center on (default both)"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between stacked children (default `m`)"},{name:"padding",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token"},{name:"inline",type:"boolean",optional:!0,description:"Shrink to fit content instead of filling the available width"}],render:(t,e,r)=>{const a={class:"rui-center","data-axis":p(e.axis,"both"),"data-gap":p(e.gap,"m"),"data-inline":T(e.inline)?"true":null},n=p(e.padding);n&&(a["data-padding"]=n);const i=[],o=p(e.minHeight);o&&i.push(`min-height:${te(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const u of C(e.children))s.append(r.renderNode(u));return s}},gl={name:"Card",description:"Vertical card container.",props:[{name:"children",type:"Node[]",description:"Card contents"},{name:"variant",type:"string",optional:!0,enum:["default","outlined","elevated"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-card","data-variant":p(e.variant,"default")});for(const n of C(e.children))a.append(r.renderNode(n));return a}},hl={name:"CardHeader",description:"Card header with title and optional subtitle.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0}],render:(t,e)=>{const r=l("header",{class:"rui-card-header"});r.append(l("h3",{class:"rui-card-title"},[p(e.title)]));const a=p(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},bl={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=l("footer",{class:"rui-card-footer"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},vl={name:"Separator",description:"Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",props:[{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"]},{name:"label",type:"string",optional:!0,description:"Optional label rendered in the middle (horizontal only)"},{name:"decorative",type:"boolean",optional:!0,description:"Hides the separator from assistive tech when true (default)"}],render:(t,e)=>{const r=p(e.orientation,"horizontal"),a=T(e.decorative,!0),n=p(e.label);return n&&r==="horizontal"?l("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r},[l("span",{class:"rui-separator-line"}),l("span",{class:"rui-separator-label"},[n]),l("span",{class:"rui-separator-line"})]):l("div",{class:"rui-separator","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r})}},Sn=(t,e,r=!1)=>{const a=l("li",{class:"rui-steps-item","data-active":r?"true":"false"});return a.append(l("div",{class:"rui-steps-title"},[t])),e&&a.append(l("div",{class:"rui-steps-details"},[e])),a},yl={name:"Steps",description:"Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",props:[{name:"items",type:"object[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-steps"});for(const n of C(e.items)){if(n&&typeof n=="object"&&n.__kind==="Component"){a.append(r.renderNode(n));continue}if(n&&typeof n=="object"){const i=n;a.append(Sn(p(i.title),p(i.details),T(i.active)));continue}a.append(Sn(p(n),""))}return a}},xl={name:"TabItem",description:"Single tab definition (used inside Tabs). Add `badge` for a count chip in the tab trigger, and `icon` for a leading Font Awesome icon.",props:[{name:"value",type:"string",description:"Stable identifier for the tab"},{name:"label",type:"string",description:"Display label"},{name:"children",type:"Node[]",description:"Tab content"},{name:"badge",type:"string",optional:!0,description:"Trailing chip rendered in the tab trigger (count / status)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tab-content",role:"tabpanel","data-value":p(e.value),"data-active":"false"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},wl={name:"Tabs",description:'Tabbed container. Children must be TabItem components. Supports `orientation="vertical"` for sidebar-style tabs and built-in keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to react when the user switches tabs (called with the new tab\'s value).',props:[{name:"items",type:"TabItem[]",description:"Tab definitions"},{name:"defaultValue",type:"string",optional:!0,description:"Initially active tab value"},{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"],description:"Layout direction (default `horizontal`)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-activated tab value when the user switches tabs"}],render:(t,e,r)=>{const a=C(e.items),n=p(e.orientation,"horizontal"),i=l("div",{class:"rui-tabs","data-orientation":n}),o=l("div",{class:"rui-tab-list",role:"tablist","aria-orientation":n}),s=l("div",{class:"rui-tab-panels"});let u=p(e.defaultValue);if(!u&&a.length>0){const f=a[0];u=p(f?.args?.[0],"tab-0")}const c=r.useInstanceState("activeTab",u);p(e.defaultValue)&&p(e.defaultValue)!==u&&c.set(p(e.defaultValue)),new Set(a.map((f,g)=>p(f.args?.[0],`tab-${g}`))).has(c.get())||c.set(u);const d=(f,g)=>{const h=c.get();c.set(f);const b=g.closest(".rui-tabs");b&&(b.querySelectorAll(".rui-tab-trigger").forEach(v=>{const y=v.getAttribute("data-value")===f;v.setAttribute("aria-selected",y?"true":"false"),v.tabIndex=y?0:-1}),b.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===f?"true":"false")})),h!==f&&r.invoke(e.onChange,f)};return a.forEach((f,g)=>{const h=f,b=p(h.args?.[0],`tab-${g}`),v=p(h.args?.[1],`Tab ${g+1}`),y=p(h.args?.[3]),x=p(h.args?.[4]),w=b===c.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":b,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),A=x?kl(x):null;A&&k.append(A),k.append(l("span",{class:"rui-tab-trigger-label"},[v])),y&&k.append(l("span",{class:"rui-tab-trigger-badge"},[y])),k.onclick=$=>{const M=$.currentTarget??$.target;d(b,M)},k.onkeydown=$=>{const M=$,I=n!=="vertical",R=I?M.key==="ArrowRight":M.key==="ArrowDown",j=I?M.key==="ArrowLeft":M.key==="ArrowUp";if(!R&&!j&&M.key!=="Home"&&M.key!=="End")return;M.preventDefault();const K=M.currentTarget??M.target,F=K.closest(".rui-tab-list");if(!F)return;const U=Array.from(F.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(K);let Z=J;M.key==="Home"?Z=0:M.key==="End"?Z=U.length-1:R?Z=(J+1)%U.length:j&&(Z=(J-1+U.length)%U.length);const de=U[Z];if(!de)return;de.focus();const Se=de.getAttribute("data-value")??"";Se&&d(Se,de)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",b),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function kl(t){return E(t,{className:"rui-tab-trigger-icon"})}const Sl={name:"AccordionItem",description:"Single accordion section.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"open",type:"boolean",optional:!0},{name:"showArrow",type:"boolean",optional:!0,description:"Show a chevron icon on the right (default false). Inherits from parent Accordion when unset."}],render:(t,e,r)=>{const a=e.showArrow!==void 0&&e.showArrow!==null,n=l("details",{class:"rui-accordion-item","data-show-arrow":a?T(e.showArrow)?"true":"false":null});T(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[p(e.title)])),i.append(l("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),n.append(i);const o=l("div",{class:"rui-accordion-body"});for(const s of C(e.children))o.append(r.renderNode(s));return n.append(o),n}},Cl={name:"Accordion",description:"Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",props:[{name:"items",type:"AccordionItem[]"},{name:"showArrow",type:"boolean",optional:!0,description:"Show chevron icon on every item (default false)."}],render:(t,e,r)=>{const a=l("div",{class:"rui-accordion","data-show-arrow":T(e.showArrow)?"true":"false"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Pt=t=>Math.max(1,Math.min(st,Math.round(t)));function Sr(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,a]=e.split("/"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return Pt(Math.round(st*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:Pt(L(t,12))}function $l(t){const e=p(t.minChildWidth)||p(t.minItemWidth);return te(e||"220px","220px")}const Tl={name:"GridItem",description:'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',props:[{name:"child",type:"Node",description:"Child node to place in the grid"},{name:"span",type:"number | string",optional:!0,description:'Columns to span (1–12) or fraction like "1/2", "1/3"'},{name:"offset",type:"number",optional:!0,description:"Empty columns before this item (0–11)"},{name:"spanAt",type:"object",optional:!0,description:"Responsive span map `{sm: 12, md: 6, lg: 4}`"}],render:(t,e,r)=>{const a=Sr(e.span??12),n=fe(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(st-1,Math.round(L(e.offset,0)))),o={class:"rui-grid-item","data-span":String(a)},s=[`--rui-grid-item-span:${a}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),n.kind==="responsive"){o["data-responsive-span"]="true";for(const c of Ke){const m=n.values[c];if(m!==void 0){const d=Sr(m);s.push(`--rui-grid-item-span-${c}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const c=Sr(n.value);s.push(`--rui-grid-item-span:${c}`),o["data-span"]=String(c)}o.style=s.join(";");const u=l("div",o);return u.append(r.renderNode(e.child)),u}},Al={name:"Box",description:"Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",props:[{name:"children",type:"Node[]"},{name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Outer margin. May be a responsive map."},{name:"border",type:"string",optional:!0,enum:["none","subtle","default"],description:"Border preset (default none)"},{name:"background",type:"string",optional:!0,enum:["none","surface","muted","primary","success","warning","danger","info"],description:"Semantic background token"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a=fe(e.padding),n=fe(e.margin),i={class:"rui-box","data-border":p(e.border,"none"),"data-background":p(e.background,"none")},o=[],s=p(e.maxWidth);if(s&&o.push(`max-width:${te(s,s)}`),a.kind==="single"){const c=a.value?String(a.value):null;c&&(i["data-padding"]=c)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Be(o,a,"--rui-box-padding");if(n.kind==="single"){const c=n.value?String(n.value):null;c&&(i["data-margin"]=c)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Be(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const u=l("div",i);for(const c of C(e.children))u.append(r.renderNode(c));return u}},Cn={name:"Grid",description:'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',props:[{name:"children",type:"Node[]"},{name:"columns",type:"number | object",optional:!0,description:"Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Gap on both axes (default `m`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Column gap override. May be a responsive map."},{name:"minChildWidth",type:"string",optional:!0,aliases:["minItemWidth"],description:'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.'},{name:"alignItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of items within their cells"},{name:"justifyItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of items within their cells"},{name:"dense",type:"boolean",optional:!0,description:"Dense auto-flow packing — let later items backfill earlier gaps"}],render:(t,e,r)=>{const a=C(e.children),n=a.some(v=>sl(v,"GridItem")),i=fe(e.columns),o=fe(e.gap),s=fe(e.rowGap),u=fe(e.columnGap),c={class:"rui-grid"},m=[];let d=!1,f=!1;if(i.kind==="single"){const v=i.value===null?0:L(i.value,0),y=v>0?Pt(v):0;if(y===st?d=!0:y>0&&(f=!0),y>0){c["data-columns"]=String(y);const x=p(e.minChildWidth)||p(e.minItemWidth);x&&(c["data-min-child-width"]="true",m.push(`--rui-grid-min-child:${te(x,"220px")}`))}else m.push(`--rui-grid-min-item:${$l(e)}`)}else{c["data-responsive-cols"]="true";for(const v of Ke){const y=i.values[v];if(y===void 0)continue;const x=Pt(L(y,0));x===st?d=!0:x>0&&(f=!0),m.push(`--rui-grid-cols-${v}:${x}`)}}n&&!f&&(d=!0),d&&(c["data-grid-mode"]="12"),o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-grid-gap")),s.kind==="single"&&s.value?c["data-row-gap"]=String(s.value):s.kind==="responsive"&&(c["data-row-gap"]="responsive",c["data-responsive-row-gap"]="true",Be(m,s,"--rui-grid-row-gap")),u.kind==="single"&&u.value?c["data-column-gap"]=String(u.value):u.kind==="responsive"&&(c["data-column-gap"]="responsive",c["data-responsive-column-gap"]="true",Be(m,u,"--rui-grid-column-gap"));const g=p(e.alignItems);g&&(c["data-align-items"]=g);const h=p(e.justifyItems);h&&(c["data-justify-items"]=h),T(e.dense)&&(c["data-dense"]="true"),m.length>0&&(c.style=m.join(";"));const b=l("div",c);for(const v of a)b.append(r.renderNode(v));return b}},Nl={name:"AspectRatio",description:"Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",props:[{name:"ratio",type:"string",description:"`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`"},{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=Ml(p(e.ratio,"16:9")),n=l("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const i of C(e.children))n.append(r.renderNode(i));return n}};function Ml(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i!==0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Pl={name:"ScrollArea",description:"Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",props:[{name:"children",type:"Node[]"},{name:"maxHeight",type:"string",optional:!0,aliases:["height"],description:"CSS height (default 320px)"},{name:"direction",type:"string",optional:!0,enum:["vertical","horizontal","both"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-scroll-area","data-direction":p(e.direction,"vertical"),style:`max-height:${te(e.maxHeight,"320px")};`});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Il={name:"Modal",description:"Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"Width preset (default `md`)"},{name:"footer",type:"Node[]",optional:!0,description:"Footer slot — typically a row of action Buttons"},{name:"closable",type:"boolean",optional:!0,description:"Render the header × button (default true)"},{name:"closeOnBackdrop",type:"boolean",optional:!0,description:"Close when the overlay is clicked (default false)"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the modal is closed (× button or backdrop)"}],render:(t,e,r)=>{const a=p(e.size,"md"),n=e.closable===void 0?!0:T(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":T(e.open)?"true":"false"}),o=l("div",{class:"rui-modal",role:"dialog","aria-modal":"true","data-size":a}),s=l("header",{class:"rui-modal-header"});s.append(l("h3",{class:"rui-modal-title"},[p(e.title)]));const u=t.argMeta?.[1]?.stateRef,c=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};if(n){const f=l("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);f.onclick=g=>{g.stopPropagation(),c()},s.append(f)}o.append(s);const m=l("div",{class:"rui-modal-body"});for(const f of C(e.children))m.append(r.renderNode(f));o.append(m);const d=C(e.footer);if(d.length>0){const f=l("footer",{class:"rui-modal-footer"});for(const g of d)f.append(r.renderNode(g));o.append(f)}return i.append(o),T(e.closeOnBackdrop)&&(i.onclick=f=>{f.target===i&&c()}),i}},Ll=["solid","regular","brands"],It=["xs","sm","md","lg","xl"],zl=["default","neutral","primary","success","warning","danger","info"];function Cr(t,e="md"){const r=p(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":It.includes(r)?r:e:e}const Rl={name:"Icon",description:'Single Font Awesome icon. `name` is the FA name without the `fa-` prefix (e.g. `"house"`, `"chart-line"`). Use `variant` for non-solid styles (`regular`/`brands`) or prefix the name (`"regular:star"`). `color` accepts any CSS colour (`"#00ff00"`, `"tomato"`, `"var(--rui-color-primary)"`).',props:[{name:"name",type:"string",description:"FA name without the fa- prefix"},{name:"variant",type:"string",optional:!0,enum:Ll},{name:"size",type:"string",optional:!0,enum:Gs},{name:"color",type:"string",optional:!0,description:"CSS colour applied to the glyph (hex, named, rgb()/hsl(), or var(--token))"}],render:(t,e)=>{const r=p(e.name),a=p(e.variant,""),n=p(e.size,"md"),i=p(e.color,""),o=a?`${a}:${r}`:r,s=E(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},El=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function jl(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const $n=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:El},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations applied to the rendered element (e.g. "font-size: 16px; font-weight: bold; color: #000;").'}],Tn=(t,e)=>{const r=p(e.variant,"body"),a=p(e.tone,"default"),n=jl(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[p(e.value)])},Dl={name:"Text",description:'Renders plain text with a typographic variant. Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:$n,render:Tn},Bl={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:$n,render:Tn},Fl={name:"Image",description:"Inline image. `ratio` constrains the box to a fixed aspect ratio (e.g. `16:9`, `1:1`) so callers do not need an outer `AspectRatio`. `fit` controls how the image fills that box. When `src` is missing or unsafe the component renders a placeholder (or `fallback` text/icon).",props:[{name:"src",type:"string"},{name:"alt",type:"string",optional:!0},{name:"caption",type:"string",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio shorthand (e.g. `16:9`, `1:1`, `4:3`)"},{name:"fit",type:"string",optional:!0,enum:["cover","contain","fill","none","scale-down"],description:"object-fit value (default `cover`)"},{name:"fallback",type:"string",optional:!0,description:"Text label or Font Awesome icon shown when src is missing/unsafe"}],render:(t,e)=>{const r=l("figure",{class:"rui-image","data-fit":p(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Ol(p(e.ratio))};`:null}),a=ne(e.src);if(a)r.append(l("img",{src:a,alt:p(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=p(e.fallback);if(o){const s=E(o,{className:"rui-image-fallback-icon"});s?i.append(s):i.append(l("span",{class:"rui-image-fallback-text"},[o]))}r.append(i)}const n=p(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function Ol(t){if(!t)return"auto";if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const An=["neutral","primary","success","warning","danger","info"],_l={name:"Badge",description:"Small pill-style tag for status, counts, categories. Accepts an optional leading `icon` and a `size`.",props:[{name:"label",type:"string",positional:!0},{name:"tone",type:"string",optional:!0,enum:An,aliases:["variant"],description:"Visual tone"},{name:"icon",type:"string",optional:!0,description:'Optional Font Awesome icon name (e.g. "star")'},{name:"size",type:"string",optional:!0,enum:It}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Cr(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=E(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=p(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},Ul={name:"BadgeList",description:"Cluster of Badge pills rendered from an array of strings.",props:[{name:"labels",type:"string[]",positional:!0,description:"Array of badge labels"},{name:"tone",type:"string",optional:!0,enum:An,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:It}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Cr(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of C(e.labels)){const o=p(i);if(!o)continue;const s=l("span",{class:"rui-badge","data-variant":r,"data-size":a});s.append(l("span",{class:"rui-badge-label"},[o])),n.append(s)}return n}},Hl={name:"Callout",description:"Highlighted callout banner with variant, title, description, and leading icon. Pass `compact: true` for a one-line inline-note rendering.",props:[{name:"tone",type:"string",optional:!0,enum:["neutral","info","success","warning","danger","error"],aliases:["variant"]},{name:"title",type:"string",positional:!0,required:!0},{name:"description",type:"string",optional:!0,aliases:["text"],description:"Body text"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"compact",type:"boolean",optional:!0,description:"Render with the dense, one-line note shape."}],render:(t,e)=>{const r=p(e.tone,"info"),a=T(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=p(e.icon)||ql(r),o=E(i,{className:"rui-callout-icon"});o&&n.append(o);const s=l("div",{class:"rui-callout-body"});s.append(l("div",{class:"rui-callout-title"},[p(e.title)]));const u=p(e.description);return u&&s.append(l("div",{class:"rui-callout-description"},[u])),n.append(s),n}},Vl={name:"CodeBlock",description:'Read-only code block with a language label and a copy-to-clipboard button. Pass `showLineNumbers=true` to render a gutter; `highlightLines` accepts a string like `"3-5,8"` to emphasise specific lines.',props:[{name:"language",type:"string",optional:!0,description:"Display label (e.g. ts, bash)"},{name:"codeString",type:"string",positional:!0,required:!0,aliases:["code"],description:"Raw source text"},{name:"showLineNumbers",type:"boolean",optional:!0,description:"Render a left-side line-number gutter"},{name:"highlightLines",type:"string",optional:!0,aliases:["highlight"],description:'Highlight ranges, e.g. "3-5,8"'},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"}],render:(t,e)=>{const r=p(e.language),a=p(e.codeString),n=T(e.showLineNumbers),i=Wl(p(e.highlightLines)),o=e.copy===void 0?!0:T(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const c=l("div",{class:"rui-code-block-head"});if(r&&c.append(l("span",{class:"rui-code-block-language"},[r])),o){const m=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=E("copy",{className:"rui-code-block-copy-icon"});d&&m.append(d),m.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),m.onclick=f=>{const g=f.currentTarget??f.target,b=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(b).catch(()=>{});const x=g.querySelector(".rui-code-block-copy-label");if(x){const w=x.textContent??"Copy";x.textContent="Copied",setTimeout(()=>{x.textContent=w},1500)}},c.append(m)}s.append(c)}const u=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const c=a.split(/\r?\n/),m=l("code",{});c.forEach((d,f)=>{const g=f+1,h=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&h.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),h.append(l("span",{class:"rui-code-block-code"},[d])),m.append(h)}),u.append(m)}else u.append(l("code",{},[a]));return s.append(u),s}};function Wl(t){const e=new Set;if(!t)return e;for(const r of t.split(",")){const a=r.trim();if(a)if(a.includes("-")){const n=a.split("-").map(s=>Number(s.trim())),i=n[0]??NaN,o=n[1]??NaN;if(Number.isFinite(i)&&Number.isFinite(o)&&i<=o)for(let s=i;s<=o;s+=1)e.add(s)}else{const n=Number(a);Number.isFinite(n)&&e.add(n)}}return e}function ql(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":case"error":return"circle-xmark";case"info":return"circle-info";default:return"circle-info"}}const Gl={name:"Skeleton",description:"Loading placeholder. Pass a `variant` for common shapes — `paragraph` (default), `card`, `table-row`, `avatar`, `image` — or use `shape` / `width` / `height` to build a custom one. All variants use a shimmer animation that respects `prefers-reduced-motion`.",props:[{name:"variant",type:"string",optional:!0,enum:["paragraph","card","table-row","avatar","image"]},{name:"lines",type:"number",optional:!0,aliases:["count"],description:"Lines for the `paragraph` variant (default 3)"},{name:"height",type:"number | string",optional:!0,description:"Line height in px (paragraph) or CSS height for custom shape"},{name:"shape",type:"string",optional:!0,enum:["rect","circle"],description:"Force a primitive shape (rect/circle)"},{name:"width",type:"string",optional:!0,description:"CSS width for shape-only skeletons"}],render:(t,e)=>{const r=p(e.variant),a=p(e.shape);if(a)return Kl(a,e);if(r&&r!=="paragraph")return Yl(r,e);const n=Number(e.lines),i=Math.max(1,Math.min(50,Number.isFinite(n)?Math.floor(n):3)),o=Number(e.height),s=Number.isFinite(o)&&o>0?Math.min(200,Math.floor(o)):12,u=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let c=0;c<i;c+=1)u.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return u}};function Kl(t,e){const r=te(p(e.width),"100%"),a=p(e.height),n=a?te(a,"16px"):t==="circle"?r:"16px";return l("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${n};`})}function Yl(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=te(p(e.width),"40px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${a};height:${a};`})),r}case"image":{const a=te(p(e.width),"100%"),n=te(p(e.height),"160px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${a};height:${n};`})),r}case"card":return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:60%;"})),r;case"table-row":{const a=Math.max(1,Math.min(8,Math.floor(Number(e.lines??4)))),n=l("div",{class:"rui-skeleton-row"});for(let i=0;i<a;i+=1)n.append(l("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(n),r}default:return r}}const Xl={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (``), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=p(e.content),a=tc(r);return l("div",{class:"rui-markdown",html:a})}},Jl={name:"Container",description:"Centered, max-width content wrapper. Use when a page is wider than comfortable reading width — landing pages, marketing sections, long documents. Picks a sensible default max-width per size; pass `maxWidth` to override with any CSS value.",props:[{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)"},{name:"maxWidth",type:"string",optional:!0,description:"Custom CSS max-width (overrides `size`)"},{name:"padding",type:"string",optional:!0,enum:["none","s","m","l"],description:"Horizontal padding (default m)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-container","data-size":p(e.size,"lg"),"data-padding":p(e.padding,"m"),style:e.maxWidth?`max-width:${te(e.maxWidth,"auto")};`:null});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Zl={name:"Spacer",description:'Explicit space element for fine layout control. By default acts as a flex spacer that pushes following content to the far edge (use inside `Stack(direction="row")`). Pass `size` to render a fixed vertical/horizontal gap instead.',props:[{name:"size",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Fixed gap; omit to flex-grow"},{name:"flex",type:"boolean",optional:!0,description:"Flex-grow even when size is set (default true when size omitted)"}],render:(t,e)=>{const r=p(e.size),a=e.flex===void 0?!r:T(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},Ql={name:"Spinner",description:"Indeterminate inline loader. Use for tiny loading states inside buttons, toolbars, table cells, or chat bubbles where `Skeleton` and `Progress(indeterminate=true)` are too heavy. Pass `label` to render an inline caption beside the spinner (also announced via `aria-label`).",props:[{name:"size",type:"string",optional:!0,enum:It,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:zl,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=Cr(e.size,"md"),a=p(e.tone,"primary"),n=p(e.label),i=l("span",{class:"rui-spinner","data-size":r,"data-tone":a,role:"status","aria-live":"polite","aria-label":n||"Loading"});return i.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),n&&i.append(l("span",{class:"rui-spinner-label"},[n])),i}},ec={name:"Quote",description:"Inline pull-quote with optional citation. Lighter than `Testimonial` — use inside articles, blog posts, marketing sections, or anywhere you need to highlight a sentence without the full quote/author/role + rating shape.",props:[{name:"text",type:"string"},{name:"cite",type:"string",optional:!0,aliases:["attribution","author"],description:"Attribution text shown below the quote"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=l("figure",{class:"rui-quote","data-tone":p(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[p(e.text)]));const a=p(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function tc(t){const e=g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",u=[];const c=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},m=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(u.join(`
|
|
40
|
-
`))}</code></pre>`),u=[],s="",o=!1};for(const g of r){const h=/^```\s*(.*)$/.exec(g.trim());if(o){if(h){d();continue}u.push(g);continue}if(h){c(),m(),o=!0,s=h[1]??"";continue}const b=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(b){c(),m();const w=b[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${f(e(b[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){c(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${f(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&m();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){m(),n!=="ul"&&(c(),a.push("<ul>"),n="ul"),a.push(`<li>${f(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){m(),n!=="ol"&&(c(),a.push("<ol>"),n="ol"),a.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(g.trim()===""){c(),m();continue}c(),m(),a.push(`<p>${f(e(g))}</p>`)}return o&&d(),c(),m(),a.join("");function f(g){let h=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(b,v,y)=>{const x=ne(y);return x?`<img class="rui-markdown-image" src="${Lt(x)}" alt="${v}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${v}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(b,v,y)=>`<a class="rui-link" href="${Nn(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,b=>`<a class="rui-link" href="${Nn(b)}" target="_blank" rel="noopener noreferrer">${b}</a>`),h}}function Nn(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return Lt(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return Lt(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?Lt(e):"#"}function Lt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function lt(t,e,r){const a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=ne(t);if(n){const i=l("img",{src:n,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ct(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(e)]));return a}function ct(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(a=>a.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const zt=new WeakMap;function Xe(t){const{liveRoot:e,onDismiss:r}=t,a=zt.get(e);a&&a.dispose();const n=e.getRootNode();let i=!1;const o=d=>{const f=d.target;f&&e.contains(f)||(m.dispose(),r())},s=d=>{d.key==="Escape"&&(m.dispose(),r())},u=e.ownerDocument;let c=null;if(u&&typeof MutationObserver<"u"){c=new MutationObserver(()=>{e.isConnected||m.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&c.observe(d,{childList:!0,subtree:!0})}const m={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),c?.disconnect(),zt.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),zt.set(e,m),m}function Ae(t){if(!t)return;const e=zt.get(t);e&&e.dispose()}const rc=[{match:/\b(revenue|sales|sale|income|payment|charges?|invoices?|billing)\b/i,icon:"sack-dollar"},{match:/\b(profit|earnings?|margin|roi)\b/i,icon:"chart-line"},{match:/\b(customers?|clients?|users?|members?|people|accounts?)\b/i,icon:"users"},{match:/\b(visitors?|sessions?|traffic|page-?views?|impressions?)\b/i,icon:"chart-line"},{match:/\b(orders?|carts?|purchases?|transactions?)\b/i,icon:"cart-shopping"},{match:/\b(products?|inventory|sku|stock|items?)\b/i,icon:"box"},{match:/\b(subscriptions?|plans?|tiers?|pricing)\b/i,icon:"credit-card"},{match:/\b(emails?|messages?|inbox|threads?|mail)\b/i,icon:"envelope"},{match:/\b(notifications?|alerts?|reminders?)\b/i,icon:"bell"},{match:/\b(growth|trend|increase|up)\b/i,icon:"arrow-trend-up"},{match:/\b(decline|drop|down|decrease|loss)\b/i,icon:"arrow-trend-down"},{match:/\b(reports?|analytics|insights?|dashboards?|metrics?|stats?|kpis?)\b/i,icon:"chart-pie"},{match:/\b(charts?|graphs?)\b/i,icon:"chart-column"},{match:/\b(tasks?|todos?|backlog|kanban|sprint)\b/i,icon:"list-check"},{match:/\b(projects?|workspaces?)\b/i,icon:"folder-open"},{match:/\b(files?|folders?|documents?|docs?|attachments?)\b/i,icon:"folder-open"},{match:/\b(images?|photos?|gallery|albums?)\b/i,icon:"image"},{match:/\b(videos?|clips?|recordings?)\b/i,icon:"video"},{match:/\b(audio|music|podcasts?|sounds?)\b/i,icon:"music"},{match:/\b(calendars?|schedule|events?|meetings?|appointments?)\b/i,icon:"calendar-days"},{match:/\b(comments?|replies|feedback|reviews?|ratings?)\b/i,icon:"comments"},{match:/\b(settings?|preferences?|config|configuration|options?)\b/i,icon:"gear"},{match:/\b(security|privacy|password|locks?|secure)\b/i,icon:"shield-halved"},{match:/\b(api|integrations?|webhooks?|connections?)\b/i,icon:"plug"},{match:/\b(database|storage|backups?|servers?)\b/i,icon:"database"},{match:/\b(speed|performance|latency|response\s?time)\b/i,icon:"gauge-high"},{match:/\b(uptime|availability|status|health)\b/i,icon:"heart-pulse"},{match:/\b(errors?|bugs?|failures?|exceptions?|incidents?)\b/i,icon:"circle-exclamation"},{match:/\b(success|complete|done|approved)\b/i,icon:"circle-check"},{match:/\b(warnings?|caution)\b/i,icon:"triangle-exclamation"},{match:/\b(search|results?|queries)\b/i,icon:"magnifying-glass"},{match:/\b(downloads?|exports?)\b/i,icon:"download"},{match:/\b(uploads?|imports?)\b/i,icon:"upload"},{match:/\b(time|hours?|duration|elapsed)\b/i,icon:"clock"},{match:/\b(locations?|maps?|addresses?|countries?|regions?)\b/i,icon:"location-dot"},{match:/\b(stars?|favourites?|favorites?|highlights?)\b/i,icon:"star"},{match:/\b(trophy|awards?|achievements?|badges?|gold)\b/i,icon:"trophy"},{match:/\b(targets?|goals?|objectives?|quotas?)\b/i,icon:"bullseye"},{match:/\b(teams?|departments?|orgs?|organisations?|organizations?)\b/i,icon:"people-group"},{match:/\b(tickets?|issues?|bugs?|requests?)\b/i,icon:"ticket"},{match:/\b(deploys?|builds?|releases?|versions?)\b/i,icon:"rocket"}];function Mn(t){if(!t)return null;for(const e of rc)if(e.match.test(t))return e.icon;return null}const ac={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function nc(t){return t?ac[t.toLowerCase()]??null:null}function ic(t,e="shapes"){const r=t.trim()||"anon";return`https://api.dicebear.com/9.x/${/^[a-z0-9-]+$/i.test(e)?e:"shapes"}/svg?seed=${encodeURIComponent(r)}`}function Pn(t){return C(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=p(n.args[0]);return{value:i,label:p(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=p(n.value);return{value:i,label:p(n.label,i)}}}const a=p(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function Je(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=l("span",{class:"rui-wrapper-fragment"});for(const a of e)a!=null&&r.append(typeof a=="string"?document.createTextNode(a):t.renderNode(a));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function Rt(t,e){return l("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function oc(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const sc=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function lc(t){return(Array.isArray(t)?t.map(r=>p(r)):p(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&sc.test(r))}const cc={name:"OnClick",description:"Make any component clickable. Wraps the child in a transparent span and dispatches `onClick(event)` when the user clicks or taps anywhere inside it. Use to attach click behaviour to components that do not expose an `action` / `onClick` prop (cards, list rows, media tiles, custom layouts).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component (or array of components) to wrap"},{name:"onClick",type:"callable",required:!0,aliases:["action","onclick"],description:"Callable invoked on click / tap. Receives the native MouseEvent."},{name:"disabled",type:"boolean",optional:!0,description:"Skip firing the handler while truthy"},{name:"stopPropagation",type:"boolean",optional:!0,description:"Call event.stopPropagation() after invoking the handler (default false)"}],render:(t,e,r)=>{const a=Rt("rui-on-click",{role:"button",tabindex:"0"});a.append(Je(r,e.child));const n=T(e.disabled),i=T(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const u=s;(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(u))}),a}},uc=[{prop:"enter",event:"mouseenter"},{prop:"leave",event:"mouseleave"},{prop:"hover",event:"mouseover"},{prop:"move",event:"mousemove"},{prop:"down",event:"mousedown"},{prop:"up",event:"mouseup"},{prop:"click",event:"click"},{prop:"doubleClick",event:"dblclick"},{prop:"contextMenu",event:"contextmenu"},{prop:"scroll",event:"scroll"},{prop:"wheel",event:"wheel"},{prop:"drag",event:"drag"},{prop:"drop",event:"drop"},{prop:"dragStart",event:"dragstart"},{prop:"dragEnd",event:"dragend"},{prop:"dragEnter",event:"dragenter"},{prop:"dragLeave",event:"dragleave"},{prop:"dragOver",event:"dragover"}],dc={name:"OnMouse",description:"Attach any combination of mouse / pointer / drag listeners to a component. Pass only the props you need — unused events install no listener so the wrapper is essentially free. Each handler receives the native MouseEvent / DragEvent / WheelEvent. Use for hover tracking, custom drag-and-drop, context menus, scroll-aware UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component to wrap"},{name:"enter",type:"callable",optional:!0,description:"Fired when the pointer enters the element (mouseenter)"},{name:"leave",type:"callable",optional:!0,description:"Fired when the pointer leaves the element (mouseleave)"},{name:"hover",type:"callable",optional:!0,description:"Fired on every mouseover inside the element"},{name:"move",type:"callable",optional:!0,description:"Fired on every mousemove inside the element"},{name:"down",type:"callable",optional:!0,description:"Fired on mousedown"},{name:"up",type:"callable",optional:!0,description:"Fired on mouseup"},{name:"click",type:"callable",optional:!0,description:"Fired on click / tap"},{name:"doubleClick",type:"callable",optional:!0,description:"Fired on double-click"},{name:"contextMenu",type:"callable",optional:!0,description:"Fired on right-click (contextmenu)"},{name:"scroll",type:"callable",optional:!0,description:"Fired when an inner element scrolls"},{name:"wheel",type:"callable",optional:!0,description:"Fired on mouse-wheel / trackpad scroll"},{name:"drag",type:"callable",optional:!0,description:"Fired while the element is being dragged"},{name:"drop",type:"callable",optional:!0,description:"Fired when something is dropped onto the element"},{name:"dragStart",type:"callable",optional:!0,description:"Fired when a drag begins"},{name:"dragEnd",type:"callable",optional:!0,description:"Fired when a drag ends"},{name:"dragEnter",type:"callable",optional:!0,description:"Fired when a drag enters the element"},{name:"dragLeave",type:"callable",optional:!0,description:"Fired when a drag leaves the element"},{name:"dragOver",type:"callable",optional:!0,description:"Fired while something is dragged over the element. Call `event.preventDefault()` to make the element a valid drop target."},{name:"draggable",type:"boolean",optional:!0,description:'Make the wrapper itself draggable (sets `draggable="true"`)'},{name:"passiveScroll",type:"boolean",optional:!0,description:"Register scroll/wheel listeners as passive (default true for better scroll performance)"}],render:(t,e,r)=>{const a=Rt("rui-on-mouse");T(e.draggable)&&a.setAttribute("draggable","true"),a.append(Je(r,e.child));const n=e.passiveScroll===void 0?!0:T(e.passiveScroll);for(const{prop:i,event:o}of uc){const s=e[i];if(s==null)continue;const c=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,m=>{r.invoke(s,m)},c)}return a}},pc=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],mc={name:"OnKeyboard",description:'Attach keyboard listeners to a component. Pass any combination of `onKeyDown`, `onKeyUp`, and `onKeyPress`; each handler receives the native KeyboardEvent. Use for keyboard shortcuts, navigation, and custom focusable widgets. The wrapper is focusable by default (tabindex="0") so it can be reached via Tab; pass `focusable=false` to disable when the child is already focusable.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onKeyDown",type:"callable",optional:!0,aliases:["onkeydown"],description:"Fired on keydown"},{name:"onKeyUp",type:"callable",optional:!0,aliases:["onkeyup"],description:"Fired on keyup"},{name:"onKeyPress",type:"callable",optional:!0,aliases:["onkeypress"],description:"Fired on keypress"},{name:"focusable",type:"boolean",optional:!0,description:"Make the wrapper focusable via Tab (default true)"}],render:(t,e,r)=>{const a=e.focusable===void 0?!0:T(e.focusable),n=Rt("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(Je(r,e.child));for(const{prop:i,event:o}of pc){const s=e[i];s!=null&&n.addEventListener(o,u=>{r.invoke(s,u)})}return n}},fc={name:"OnFocus",description:"Attach focus / blur listeners to a component. Use to track input focus rings, custom focus indicators, or autosave-on-blur flows. Listens on the capture phase so blur from descendants is observed.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Fired when focus enters the element or any descendant"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Fired when focus leaves the element and all descendants"}],render:(t,e,r)=>{const a=Rt("rui-on-focus");return a.append(Je(r,e.child)),e.onFocus!=null&&a.addEventListener("focusin",n=>r.invoke(e.onFocus,n)),e.onBlur!=null&&a.addEventListener("focusout",n=>r.invoke(e.onBlur,n)),a}},gc={name:"OnIntersect",description:"Observe whether a component is visible in the viewport (or a scroll container) using IntersectionObserver. Fires `onEnter` the first time the wrapped element becomes visible, `onLeave` when it leaves, and `onChange({visible, ratio})` for every transition. Use for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onEnter",type:"callable",optional:!0,description:"Fired when the element enters the viewport"},{name:"onLeave",type:"callable",optional:!0,description:"Fired when the element leaves the viewport"},{name:"onChange",type:"callable",optional:!0,description:"Fired with `{visible, ratio}` on every transition"},{name:"threshold",type:"number",optional:!0,description:"Visible-ratio threshold 0–1 (default 0.05)"},{name:"rootMargin",type:"string",optional:!0,description:'CSS-length root margin (e.g. "0px 0px -64px 0px")'},{name:"once",type:"boolean",optional:!0,description:"Disconnect after the first entry (default false)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});a.append(Je(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,L(e.threshold,.05))),o=p(e.rootMargin),s=T(e.once);let u=null;const c=new n(m=>{for(const d of m){const f=d.isIntersecting;if(f!==u&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,d),!f&&u===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),u=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:d.intersectionRatio}),s&&f){c.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return c.observe(a),r.registerDisposer(()=>c.disconnect()),a}};function hc(t,e){return e==null?[]:typeof e=="string"?[document.createTextNode(e)]:Array.isArray(e)?e.filter(r=>r!=null).map(r=>typeof r=="string"?document.createTextNode(r):t.renderNode(r)):[t.renderNode(e)]}const In={name:"Link",description:'Anchor link. Accepts either a plain string label or a wrapped component as its positional child. Pass `to` for client-side router navigation (no page reload) or `href` for a regular anchor. `external: true` opens the link in a new tab with `rel="noopener noreferrer"`. Use to make any component clickable as a link — cards, icons, badges, list rows.',props:[{name:"label",type:"string | Node",positional:!0,required:!0,aliases:["child","children"],description:"Visible text OR a wrapped component"},{name:"to",type:"string",optional:!0,description:"Router path (preferred). Navigates via the runtime router on click."},{name:"href",type:"string",optional:!0,description:"Standard anchor href. Used when `to` is omitted."},{name:"external",type:"boolean",optional:!0,description:'Open in a new tab (`target="_blank"`, `rel="noopener noreferrer"`)'},{name:"variant",type:"string",optional:!0,enum:["default","subtle"]}],render:(t,e,r)=>{const a=p(e.to),n=T(e.external),i=a||p(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:Ye(i,"#"):Ye(e.href,"#"),s=p(e.variant,"default"),u=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const c of hc(r,e.label))u.append(c);return a&&!n&&u.addEventListener("click",c=>{c.defaultPrevented||c.button===0&&(c.metaKey||c.ctrlKey||c.shiftKey||c.altKey||(c.preventDefault(),r.router.navigate(a)))}),u}},bc={name:"Css",description:"Apply raw CSS class names and / or an inline style string to a wrapped component. The styling is merged onto the rendered child's DOM element — no extra wrapper element is added unless the child is plain text (in which case the styling lands on a wrapping span). Reach for `Css` only when the component's own props cannot express the styling (use `Box`/`Stack`/`Grid` props for layout, `Theme` for tokens, `Styles` + selector classes for sweeping changes).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations (e.g. "padding: 16px; background: #eef;")'},{name:"class",type:"string | string[]",optional:!0,aliases:["className","classes"],description:"Class name (space-separated string or array). Tokens must match `[A-Za-z_][A-Za-z0-9_-:/]*`."}],render:(t,e,r)=>{const a=Je(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=lc(e.class);for(const s of i)n.classList.add(s);const o=oc(e.style);if(o){const s=n.getAttribute("style");n.setAttribute("style",s?`${s};${o}`:o)}return n}};function ie(t,e,r,a){if(e==null)return;const n=a.event??"change";t.addEventListener(n,()=>{r.invoke(e,a.getValue(t))})}const vc=["primary","secondary","ghost","danger"],yc=["xs","sm","md","lg","xl","small","normal","large"],xc=["text","email","password","number","tel","url","date"];function wc(t){const e=p(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}const kc={name:"Button",description:"Clickable button. `onClick` (a callable) runs when the user presses the button. The legacy `action` prop is an alias and is still accepted.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked when the button is clicked"},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:vc},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:yc,description:"Canonical `xs|sm|md|lg|xl` (legacy `small|normal|large` still accepted)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"iconPosition",type:"string",optional:!0,enum:["leading","trailing"],description:"Icon placement (default leading)"},{name:"iconOnly",type:"boolean",optional:!0,description:"Hide the label visually (keeps aria-label)"},{name:"loading",type:"boolean",optional:!0,description:"Show spinner and disable interaction"},{name:"fullWidth",type:"boolean",optional:!0},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.loading),n=T(e.iconOnly),i=p(e.iconPosition,"leading"),o=p(e.label),s=l("button",{class:"rui-button",type:p(e.type,"button"),"data-variant":p(e.variant,"primary"),"data-size":wc(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":T(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:T(e.disabled)||a?"":null}),u=l("span",{class:"rui-button-label"},[o]),c=E(e.icon,{className:"rui-button-icon"}),d=(a?E("spinner",{className:"rui-button-spinner"}):null)??c;return n?d&&s.append(d):i==="trailing"?(s.append(u),d&&s.append(d)):(d&&s.append(d),s.append(u)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},Sc={name:"Buttons",description:"Group of buttons laid out horizontally or vertically.",props:[{name:"items",type:"Button[]"},{name:"direction",type:"string",optional:!0,enum:["row","column"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-buttons","data-direction":p(e.direction,"row")});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Cc={name:"Input",description:"Text input field. Pass a $variable as `value` for two-way binding. `onChange(value)` fires on every keystroke with the current string.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:xc},{name:"validations",type:"any",optional:!0,description:"Array or object of validation hints"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("input",{class:"rui-input",id:p(e.id),name:p(e.id),type:p(e.type,"text"),placeholder:p(e.placeholder),value:p(e.value)});return Fe(a,t,4,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),Uc(a,e.validations),a}},$c={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("textarea",{class:"rui-textarea",id:p(e.id),name:p(e.id),placeholder:p(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=p(e.value),Fe(a,t,3,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},Tc={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:p(e.value)},[p(e.label)])},Ac={name:"Select",description:"Dropdown select. Pass a `$variable` as `value` for two-way binding. Set `searchable: true` for a combobox-style filter UI on long option lists. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"label",type:"string",optional:!0},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"any",optional:!0},{name:"searchable",type:"boolean",optional:!0,description:"Render as a filterable combobox"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{if(T(e.searchable))return _c(t,e,r);const a=l("select",{class:"rui-select",id:p(e.id),name:p(e.id)}),n=p(e.placeholder);n&&a.append(l("option",{value:"",disabled:"",selected:""},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a.value=p(e.value),Fe(a,t,4,r),ie(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},Nc={name:"Checkbox",description:"Boolean checkbox. `onChange(checked)` fires with the new boolean state.",props:[{name:"id",type:"string"},{name:"label",type:"string"},{name:"value",type:"boolean",optional:!0,aliases:["checked"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=l("label",{class:"rui-checkbox"}),n=T(e.value),i=l("input",{type:"checkbox",id:p(e.id),name:p(e.id),checked:n?"":null});return i.checked=n,Fe(i,t,2,r),ie(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[p(e.label)])),a}},Mc={name:"CheckBoxItem",description:"Single option inside a CheckBoxGroup.",props:[{name:"label",type:"string"},{name:"name",type:"string",description:"Key inside the group's value object"},{name:"description",type:"string",optional:!0},{name:"defaultChecked",type:"boolean",optional:!0,aliases:["checked"]}],render:(t,e)=>{const r=p(e.name),a=p(e.label),n=p(e.description),i=T(e.defaultChecked),o=l("label",{class:"rui-checkbox-item","data-name":r}),s=l("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const u=l("div",{class:"rui-checkbox-item-text"});return u.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&u.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,u),o}},Pc={name:"CheckBoxGroup",description:"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding. `onChange(value)` fires with the full updated object.",props:[{name:"name",type:"string",description:"Group identifier"},{name:"items",type:"CheckBoxItem[]"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated `{name: checked}` object when any item toggles"}],render:(t,e,r)=>{const a=p(e.name),n=l("div",{class:"rui-checkbox-group",role:"group","data-name":a}),i=C(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((c,m)=>{const d=p(c.args?.[0]),f=p(c.args?.[1],`${a}-${m}`),g=p(c.args?.[2]),h=T(c.args?.[3]),b=`${a}-${f}`,v=l("label",{class:"rui-checkbox-item",for:b}),y=f in o?!!o[f]:h,x=l("input",{type:"checkbox",id:b,name:f,checked:y?"":null}),w=l("div",{class:"rui-checkbox-item-text"});w.append(l("div",{class:"rui-checkbox-item-label"},[d])),g&&w.append(l("div",{class:"rui-checkbox-item-description"},[g])),v.append(x,w),n.append(v)});const s=t.argMeta?.[2]?.stateRef,u=c=>{const m={};return c.querySelectorAll('input[type="checkbox"]').forEach(d=>{m[d.name]=d.checked}),m};return s&&r.bindState(n,s,{event:"change",getValue:u}),ie(n,e.onChange,r,{event:"change",getValue:c=>u(c)}),n}},Ic={name:"Radio",description:"Radio button group. `onChange(value)` fires with the newly-selected option value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected radio value"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of C(e.items)){const o=p(i.args?.[0]),s=p(i.args?.[1],o),u=`${a}-${o}`,c=l("label",{class:"rui-radio",for:u}),m=p(e.value)===o,d=l("input",{type:"radio",id:u,name:a,value:o,checked:m?"":null});d.checked=m,Fe(d,t,2,r),ie(d,e.onChange,r,{event:"change",getValue:f=>f.value}),c.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(c)}return n}},Lc={name:"FormControl",description:"Labeled wrapper around a single form field.",props:[{name:"label",type:"string"},{name:"field",type:"Node",aliases:["control"]},{name:"hint",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-form-control"});a.append(l("label",{class:"rui-form-label"},[p(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=p(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},Ln={name:"SearchBar",description:"Pre-styled search input with a leading magnifying-glass icon, optional trailing submit button, and optional keyboard-shortcut hint. Pass a `$variable` as `value` for two-way binding. Use anywhere a user needs to filter content — toolbars, command bars, lists, headers.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"shortcut",type:"string",optional:!0,description:'Keyboard hint chip on the right (e.g. "/")'},{name:"onSubmit",type:"callable",optional:!0,aliases:["action","onClick"],description:"Optional submit callable; clicking the trailing button or pressing Enter invokes it"},{name:"submitLabel",type:"string",optional:!0,description:'Label for the trailing submit button (default "Search"). Omitted when no action is provided.'},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current query on every keystroke"}],render:(t,e,r)=>{const a=l("form",{class:"rui-search-bar",role:"search"});a.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const n=E("magnifying-glass",{className:"rui-search-bar-icon"})??l("span",{class:"rui-search-bar-icon","aria-hidden":"true"});a.append(n);const i=l("input",{class:"rui-search-bar-input",id:p(e.id),name:p(e.id),type:"search",placeholder:p(e.placeholder,"Search…"),value:p(e.value),autocomplete:"off"});Fe(i,t,2,r),ie(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=p(e.shortcut);if(o&&a.append(l("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=l("button",{type:"submit",class:"rui-search-bar-submit"},[p(e.submitLabel,"Search")]);a.append(s)}return a}},zc={name:"Form",description:'Form container. Children FormControls render in order; buttons render at the bottom. Provide `onSubmit` to handle form submission (invoked when the user presses Enter on a focused input or clicks a `type="submit"` Button inside the form).',props:[{name:"id",type:"string"},{name:"buttons",type:"Buttons | Button"},{name:"fields",type:"FormControl[]"},{name:"onSubmit",type:"callable",optional:!0,aliases:["onsubmit"],description:"Called when the form is submitted (Enter key or submit button)"}],render:(t,e,r)=>{const a=l("form",{class:"rui-form",id:p(e.id)});a.onsubmit=n=>{n.preventDefault(),r.invoke(e.onSubmit)};for(const n of C(e.fields))a.append(r.renderNode(n));if(e.buttons){const n=l("div",{class:"rui-form-actions"});n.append(r.renderNode(e.buttons)),a.append(n)}return a}},Rc={name:"Slider",description:"Range slider for selecting a single numeric value between `min` and `max`. Pass a `$variable` as `value` for two-way binding. Useful for filters, settings (volume, brightness), and parameter tuning.",props:[{name:"id",type:"string"},{name:"min",type:"number",optional:!0,description:"Default 0"},{name:"max",type:"number",optional:!0,description:"Default 100"},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Render the current numeric value beside the slider"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number as the user drags"}],render:(t,e,r)=>{const a=p(e.id),n=L(e.min,0),i=L(e.max,100),o=L(e.step,1),s=L(e.value,n),u=l("div",{class:"rui-slider","data-disabled":T(e.disabled)?"true":"false"}),c=p(e.label),m=T(e.showValue);if(c||m){const g=l("div",{class:"rui-slider-head"});c&&g.append(l("label",{class:"rui-slider-label",for:a},[c])),m&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),u.append(g)}const d=l("input",{type:"range",class:"rui-slider-input",id:a,name:a,min:String(n),max:String(i),step:String(o),value:String(s),disabled:T(e.disabled)?"":null});d.oninput=g=>{const h=g.currentTarget;if(!h)return;const v=h.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=h.value)};const f=t.argMeta?.[4]?.stateRef;return f&&r.bindState(d,f,{event:"input",getValue:g=>Number(g.value)}),ie(d,e.onChange,r,{event:"input",getValue:g=>Number(g.value)}),u.append(d),u}},Ec={name:"NumberInput",description:'Numeric input with paired increment/decrement buttons. Use for quantity steppers, integer settings, and any field where a `<input type="number">` plus +/- controls is friendlier than the native spinner. Pass a `$variable` as `value` for two-way binding.',props:[{name:"id",type:"string"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number (or null when blank)"}],render:(t,e,r)=>{const a=p(e.id),n=L(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?L(e.min,0):Number.NEGATIVE_INFINITY,u=o?L(e.max,0):Number.POSITIVE_INFINITY,c=T(e.disabled),m=l("div",{class:"rui-number-input","data-disabled":c?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:c?"":null},["−"]),f=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:p(e.value),placeholder:p(e.placeholder),min:i?String(s):null,max:o?String(u):null,step:String(n),disabled:c?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:c?"":null},["+"]),h=t.argMeta?.[1]?.stateRef,b=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};h&&r.bindState(f,h,{event:"input",getValue:b}),ie(f,e.onChange,r,{event:"input",getValue:b});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const A=Number(k.value),S=Number.isFinite(A)?A:0,$=Oc(S+x,s,u);k.value=String($),k.dispatchEvent(new Event("input",{bubbles:!0}))};return d.onclick=y=>v(y.currentTarget??y.target,-n),g.onclick=y=>v(y.currentTarget??y.target,n),m.append(d,f,g),m}},jc={name:"DatePicker",description:'Date picker that wraps the native `<input type="date">` with consistent styling. Pass a `$variable` as `value` for two-way binding. Use `min`/`max` to bound the selectable range.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date (YYYY-MM-DD); typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest ISO date"},{name:"max",type:"string",optional:!0,description:"Latest ISO date"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO date string when the picker changes"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-date-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-date-picker-label",for:a},[i]));const o=l("input",{type:"date",class:"rui-date-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,placeholder:p(e.placeholder),disabled:T(e.disabled)?"":null});return Fe(o,t,1,r),ie(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},Dc={name:"FileUpload",description:'Styled file picker. Renders a click/drop area with a leading icon, label, and helper text. Files cannot round-trip through `$variables` (they are not serialisable), so pass a callable as `action` to handle the picked files via `ctx.query("#id").files`.',props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0,description:'Primary label (default "Choose a file")'},{name:"hint",type:"string",optional:!0,description:"Secondary helper text"},{name:"accept",type:"string",optional:!0,description:"Comma-separated MIME types or extensions"},{name:"multiple",type:"boolean",optional:!0},{name:"onSelect",type:"callable",optional:!0,aliases:["action","onChange"],description:"Callable fired with the FileList when files are picked"},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon (default "cloud-arrow-up")'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=p(e.id),n=T(e.disabled),i=l("div",{class:"rui-file-upload","data-disabled":n?"true":"false"}),o=l("label",{class:"rui-file-upload-dropzone",for:a}),s=E(p(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const u=l("div",{class:"rui-file-upload-text"});u.append(l("div",{class:"rui-file-upload-label"},[p(e.label,"Choose a file")]));const c=p(e.hint);c&&u.append(l("div",{class:"rui-file-upload-hint"},[c])),o.append(u);const m=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:p(e.accept)||null,multiple:T(e.multiple)?"":null,disabled:n?"":null});o.append(m),i.append(o);const d=(f,g)=>g.includes("image")||f.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(f.name);return m.onchange=f=>{const g=f.currentTarget;r.invoke(e.onSelect,g.files);const h=g.closest(".rui-file-upload");if(!h)return;const b=g.files,v=h.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!b||b.length===0)return;const y=p(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(b).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const A=URL.createObjectURL(w),S=l("img",{src:A,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(A),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),h.append(x)},i}},zn={name:"Combobox",description:"Searchable single-select dropdown — type to filter, click an option to choose. Use instead of `Select` when the list is long enough that scanning is faster than scrolling (countries, currencies, repos, users). Pass a `$variable` as `value` for two-way binding; the selected option's `value` is written to state on pick.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"string",optional:!0,description:"Bound selected value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:'Text shown when no items match the filter (default "No matches")'},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=p(e.id),n=Pn(e.items),i=p(e.value),o=n.find(S=>S.value===i)?.label??i,s=p(e.placeholder,"Select…"),u=p(e.emptyLabel,"No matches"),c=T(e.disabled),m=T(e.open),d=r.useInstanceState("open",m),f=r.useInstanceState("filter",""),g=d.get(),h=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":c?"true":"false"}),b=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:c?"":null});b.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=E("chevron-down",{className:"rui-combobox-chevron"});v&&b.append(v),h.append(b);const y=l("div",{class:"rui-combobox-panel",role:"listbox"}),x=l("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:f.get()});y.append(x);const w=l("div",{class:"rui-combobox-list"});y.append(w);const k=(S,$)=>{S.replaceChildren();const M=$.trim().toLowerCase(),I=M===""?n:n.filter(R=>R.label.toLowerCase().includes(M)||R.value.toLowerCase().includes(M));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[u]));return}for(const R of I){const j=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":R.value,"aria-selected":R.value===i?"true":"false"},[R.label]);j.onclick=K=>{K.stopPropagation(),A(K.currentTarget,R.value)},S.append(j)}},A=(S,$)=>{const M=t.argMeta?.[2]?.stateRef;M&&r.setState(M,$),r.invoke(e.onChange,$),d.set(!1),f.set("");const I=S.closest(".rui-combobox");I?.setAttribute("data-open","false"),I?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ae(I)};return k(w,f.get()),x.oninput=S=>{const $=S.currentTarget;f.set($.value);const M=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");M&&k(M,$.value)},x.onkeydown=S=>{const $=S;if($.key!=="Enter")return;$.preventDefault();const R=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),j=R?.getAttribute("data-value");j!=null&&R&&A(R,j)},b.onclick=S=>{if(c)return;S.stopPropagation();const $=!d.get();d.set($);const M=S.currentTarget.closest(".rui-combobox");if(M?.setAttribute("data-open",$?"true":"false"),M?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!M){if(!$){Ae(M);return}setTimeout(()=>x.focus(),0),Xe({liveRoot:M,onDismiss:()=>{d.set(!1),f.set(""),M.setAttribute("data-open","false"),M.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(y),h}},Bc={name:"MultiSelect",description:"Multi-option searchable dropdown. Type to filter, click an option to add/remove it from the bound array. Renders the selected options as removable chips inside the trigger. Pass a `$variable` (array of values) as `value` for two-way binding.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"any[]",optional:!0,description:"Bound array of selected values (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no items match the filter"},{name:"max",type:"number",optional:!0,description:"Maximum number of selections"},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of selected values"}],render:(t,e,r)=>{const a=p(e.id),n=Pn(e.items),i=p(e.placeholder,"Select…"),o=p(e.emptyLabel,"No matches"),s=T(e.disabled),u=Math.max(0,Math.floor(Number(e.max??0))),c=Array.isArray(e.value)?e.value.map(I=>p(I)).filter(Boolean):[],m=new Set(c),d=t.argMeta?.[2]?.stateRef,f=T(e.open),g=r.useInstanceState("open",f),h=r.useInstanceState("filter",""),b=g.get(),v=l("div",{class:"rui-multiselect","data-open":b?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":b?"true":"false",disabled:s?"":null}),x=l("span",{class:"rui-multiselect-chips"}),w=I=>{d&&r.setState(d,I),r.invoke(e.onChange,I)};if(c.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of c){const R=n.find(F=>F.value===I)?.label??I,j=l("span",{class:"rui-multiselect-chip","data-value":I});j.append(l("span",{class:"rui-multiselect-chip-label"},[R]));const K=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${R}`},["×"]);K.onclick=F=>{F.stopPropagation();const U=c.filter(J=>J!==I);w(U)},j.append(K),x.append(j)}y.append(x);const k=E("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const A=l("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=l("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:h.get()});A.append(S);const $=l("div",{class:"rui-multiselect-list"});A.append($);const M=(I,R)=>{I.replaceChildren();const j=R.trim().toLowerCase(),K=j===""?n:n.filter(F=>F.label.toLowerCase().includes(j)||F.value.toLowerCase().includes(j));if(K.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const F of K){const U=m.has(F.value),J=!U&&u>0&&c.length>=u,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":F.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),de=l("span",{class:"rui-multiselect-option-check"}),Se=E(U?"check":"",{className:"rui-multiselect-option-check-icon"});Se&&de.append(Se),Z.append(de),Z.append(l("span",{class:"rui-multiselect-option-label"},[F.label])),Z.onclick=ft=>{if(ft.stopPropagation(),J)return;const He=U?c.filter(Ur=>Ur!==F.value):[...c,F.value];w(He)},I.append(Z)}};return M($,h.get()),S.oninput=I=>{const R=I.currentTarget;h.set(R.value);const j=R.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");j&&M(j,R.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const R=!g.get();g.set(R);const j=I.currentTarget.closest(".rui-multiselect");if(j?.setAttribute("data-open",R?"true":"false"),j?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",R?"true":"false"),!!j){if(!R){Ae(j);return}setTimeout(()=>S.focus(),0),Xe({liveRoot:j,onDismiss:()=>{g.set(!1),h.set(""),j.setAttribute("data-open","false"),j.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(A),v}},Fc={name:"DateRangePicker",description:"Paired date inputs with a single label, sharing the same min/max range. Pass `$variable` references for both `from` and `to` to two-way-bind a date range (ISO `YYYY-MM-DD` strings).",props:[{name:"id",type:"string"},{name:"from",type:"string",optional:!0,description:"ISO date start; typically $variable"},{name:"to",type:"string",optional:!0,description:"ISO date end; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest selectable ISO date"},{name:"max",type:"string",optional:!0,description:"Latest selectable ISO date"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with `{from, to}` whenever either endpoint changes"}],render:(t,e,r)=>{const a=p(e.id),n=`${a}-from`,i=`${a}-to`,o=p(e.min),s=p(e.max),u=T(e.disabled),c=l("div",{class:"rui-date-range-picker","data-disabled":u?"true":"false"}),m=p(e.label);m&&c.append(l("label",{class:"rui-date-range-picker-label",for:n},[m]));const d=l("div",{class:"rui-date-range-picker-row"}),f=l("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:p(e.from),min:o||null,max:s||null,disabled:u?"":null,"data-role":"from"});d.append(f),d.append(l("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const g=l("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:p(e.to),min:o||null,max:s||null,disabled:u?"":null,"data-role":"to"});d.append(g),c.append(d);const h=t.argMeta?.[1]?.stateRef,b=t.argMeta?.[2]?.stateRef;if(h&&r.bindState(f,h),b&&r.bindState(g,b),e.onChange!=null){const v=y=>{const x=y.closest(".rui-date-range-picker"),w=x?.querySelector('.rui-date-range-picker-input[data-role="from"]')?.value??"",k=x?.querySelector('.rui-date-range-picker-input[data-role="to"]')?.value??"";return{from:w,to:k}};f.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget))),g.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget)))}return c}};function Oc(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function _c(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const n=zn.render({...t,argMeta:a},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return n.classList.add("rui-select-searchable"),n}function Fe(t,e,r,a){const n=e.argMeta?.[r]?.stateRef;if(n){if(t instanceof HTMLInputElement&&t.type==="checkbox"){a.bindState(t,n,{event:"change",getValue:i=>i.checked});return}a.bindState(t,n)}}function Uc(t,e){if(!e)return;const r=Array.isArray(e)?e.map(a=>String(a)):typeof e=="object"?Object.entries(e).map(([a,n])=>n?`${a}:${n}`:a):[];for(const a of r)a==="required"?t.required=!0:a.startsWith("minLength:")?t.minLength=Number(a.slice(10))||0:a.startsWith("maxLength:")?t.maxLength=Number(a.slice(10))||0:a==="email"&&(t.type="email")}const Re=["default","primary","success","warning","danger","info"],Oe=(t,e)=>{const r=C(t);if(r.length===0)return null;const a=l("div",{class:"rui-pattern-actions"});for(const n of r)a.append(e.renderNode(n));return a},Hc=[{match:/\bbeta\b/i,label:"Beta"},{match:/\b(early\s?access|preview)\b/i,label:"Preview"},{match:/\b(introduc(?:ing|e)|launch(?:ed|ing)?|announcing)\b/i,label:"Introducing"},{match:/\b(welcome\b|get(?:ting)?\s?started)/i,label:"Welcome"},{match:/\b(new\b|whats\s?new|now\b)/i,label:"What's new"},{match:/\bfree\b/i,label:"Free trial"},{match:/\bupgrade\b/i,label:"Upgrade"},{match:/\b(sale|discount|deal)\b/i,label:"Limited time"}];function Vc(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Hc)if(a.match.test(r))return a.label;return""}const Wc={name:"Hero",description:'Eye-catching landing/marketing header with eyebrow tag, title, subtitle, optional bullet highlights, and primary/secondary CTA buttons. Use `layout="cover"` with `imageSrc` for an image-backed hero band (pass `height` and optional `caption`). Default layout shows an optional side illustration.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"primary",type:"Button",optional:!0,description:"Primary CTA — pass a Button(...)"},{name:"secondary",type:"Button",optional:!0,description:"Secondary CTA — pass a Button(...)"},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase tag above the title"},{name:"highlights",type:"string[]",optional:!0,description:"Bullet items rendered as tag pills"},{name:"imageSrc",type:"string",optional:!0,description:"Illustration or cover background when layout=cover"},{name:"caption",type:"string",optional:!0,description:"Small caption above CTAs (cover layout)"},{name:"height",type:"string",optional:!0,description:"Min-height for cover layout (default 280px)"},{name:"actions",type:"Node[]",optional:!0,description:"CTA row (cover layout; alternative to primary/secondary)"},{name:"layout",type:"string",optional:!0,enum:["default","cover"],description:"default = text-first; cover = image-backed band"},{name:"tone",type:"string",optional:!0,enum:Re,description:"Accent tone"}],render:(t,e,r)=>{const a=p(e.layout,"default"),n=p(e.title),i=p(e.subtitle),s=p(e.eyebrow)||Vc(n,i),u=p(e.tone,"primary");if(a==="cover"){const h=Ys(p(e.imageSrc)),b=te(p(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":u,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${h}");min-height:${b};`}),y=l("div",{class:"rui-cover-body"});s&&y.append(l("span",{class:"rui-cover-eyebrow"},[s])),y.append(l("h1",{class:"rui-cover-title"},[n])),i&&y.append(l("p",{class:"rui-cover-subtitle"},[i]));const x=p(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=Oe(e.actions,r);if(w)w.classList.add("rui-cover-actions"),y.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const A=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)A.append(r.renderNode(S));y.append(A)}}return v.append(y),v}const c=ne(e.imageSrc),m=l("section",{class:"rui-hero","data-tone":u,"data-has-image":c?"true":"false"}),d=l("div",{class:"rui-hero-body"});s&&d.append(l("span",{class:"rui-hero-eyebrow"},[s])),d.append(l("h1",{class:"rui-hero-title"},[n])),i&&d.append(l("p",{class:"rui-hero-subtitle"},[i]));const f=C(e.highlights);if(f.length>0){const h=l("div",{class:"rui-hero-highlights"});for(const b of f){const v=p(b);v&&h.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(h)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const h=l("div",{class:"rui-hero-ctas"});for(const b of g)h.append(r.renderNode(b));d.append(h)}if(m.append(d),c){const h=l("div",{class:"rui-hero-media"});h.append(l("img",{src:c,alt:"",loading:"lazy"})),m.append(h)}return m}},qc={name:"PageHeader",description:'Page-level header with breadcrumbs, title, subtitle, status tag, and a right-aligned actions row. The canonical first child for any dashboard, settings, or detail page — replaces ad-hoc Stack+Header+Buttons stitching. If `breadcrumbs` is omitted the component auto-derives `["Home", title]` so the page never lacks a trail. Pass `breadcrumbs=false` to opt out.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"breadcrumbs",type:"string[] | Breadcrumb | false",optional:!0,description:"Array of strings, a Breadcrumb(...) node, or `false` to suppress the auto-derived trail"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / NavLinks shown on the right"},{name:"status",type:"Badge",optional:!0,aliases:["badge"],description:"Optional Badge(...) rendered next to the title"}],render:(t,e,r)=>{const a=l("header",{class:"rui-page-header"}),n=p(e.title);let i=e.breadcrumbs;if(i==null?n&&(i=["Home",n]):(i===!1||i==="false")&&(i=null),i){const d=l("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((f,g)=>{g>0&&d.append(l("span",{class:"rui-page-header-crumb-sep"},["/"])),d.append(l("span",{class:"rui-page-header-crumb"},[p(f)]))}):d.append(r.renderNode(i)),a.append(d)}const o=l("div",{class:"rui-page-header-title-row"}),s=l("div",{class:"rui-page-header-title-block"}),u=l("div",{class:"rui-page-header-title-line"});u.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&u.append(r.renderNode(e.status)),s.append(u);const c=p(e.subtitle);c&&s.append(l("p",{class:"rui-page-header-subtitle"},[c])),o.append(s);const m=Oe(e.actions,r);return m&&(m.classList.add("rui-page-header-actions"),o.append(m)),a.append(o),a}},Gc={name:"EmptyState",description:"Zero-state placeholder for empty lists, searches, dashboards. Renders a centered icon (or illustration), title, description, and either a single `action` Button or an `actions` row (primary + secondary). Always preferable to an empty Card with raw text.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon name (defaults to "inbox")'},{name:"illustration",type:"string",optional:!0,description:"Image URL — takes precedence over `icon` when provided"},{name:"action",type:"Button",optional:!0,description:"Single CTA (legacy slot)"},{name:"actions",type:"Node[]",optional:!0,description:"Row of CTA Buttons / Links — preferred over `action` for primary + secondary affordances"}],render:(t,e,r)=>{const a=l("div",{class:"rui-empty-state"}),n=ne(e.illustration);if(n)a.append(l("img",{class:"rui-empty-state-illustration",src:n,alt:"",loading:"lazy"}));else{const s=p(e.title),u=p(e.description),c=p(e.icon)||Mn(`${s} ${u}`)||"inbox",m=E(c,{className:"rui-empty-state-icon"});m&&a.append(m)}a.append(l("h3",{class:"rui-empty-state-title"},[p(e.title)]));const i=p(e.description);i&&a.append(l("p",{class:"rui-empty-state-description"},[i]));const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-empty-state-actions"});for(const u of o)s.append(r.renderNode(u));a.append(s)}else if(e.action){const s=l("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),a.append(s)}return a}},Kc={name:"TimelineItem",description:"Single event on a Timeline.",props:[{name:"title",type:"string"},{name:"time",type:"string",optional:!0,description:"Display label (ISO, relative, etc.)"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered inside the marker"},{name:"tone",type:"string",optional:!0,enum:Re}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":p(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=E(e.icon);n&&a.append(n),r.append(a);const i=l("div",{class:"rui-timeline-body"}),o=l("div",{class:"rui-timeline-head"});o.append(l("span",{class:"rui-timeline-title"},[p(e.title)]));const s=p(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const u=p(e.description);return u&&i.append(l("div",{class:"rui-timeline-description"},[u])),r.append(i),r}},Yc={name:"Timeline",description:"Vertical event timeline. Children must be TimelineItem entries. Ideal for activity feeds, changelogs, and process flows.",props:[{name:"items",type:"TimelineItem[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-timeline"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Xc={name:"FeatureItem",description:"Single tile on a FeatureGrid.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"tone",type:"string",optional:!0,enum:Re}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":p(e.tone,"primary")}),a=p(e.icon,"sparkles"),n=E(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[p(e.title)]));const i=p(e.description);return i&&r.append(l("p",{class:"rui-feature-description"},[i])),r}},Jc={name:"FeatureGrid",description:"Responsive grid of FeatureItem tiles (typically 2–3 columns). Use to highlight product capabilities or page categories.",props:[{name:"items",type:"FeatureItem[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Number(e.columns??"auto"))),n=l("div",{class:"rui-feature-grid","data-columns":a>0?String(a):null});for(const i of C(e.items))n.append(r.renderNode(i));return n}},Zc={name:"Testimonial",description:"Quote card with author, role, and optional avatar.",props:[{name:"quote",type:"string"},{name:"author",type:"string",aliases:["name"]},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"rating",type:"number",optional:!0,description:"0–5 stars"}],render:(t,e)=>{const r=l("figure",{class:"rui-testimonial"}),a=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(a>0){const u=l("div",{class:"rui-testimonial-rating"});for(let c=0;c<5;c+=1){const m=c<a,d=E(m?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&u.append(d)}r.append(u)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[p(e.quote)]));const n=l("figcaption",{class:"rui-testimonial-author"}),i=ne(e.avatarSrc);i&&n.append(l("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=l("div",{class:"rui-testimonial-meta"});o.append(l("div",{class:"rui-testimonial-name"},[p(e.author)]));const s=p(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},Qc={name:"ProfileCard",description:"Compact profile/user card with avatar, name, role, optional bio, social tags, and a row of action buttons. Use for team rosters, contributor lists, and contact panels.",props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar image src; falls back to initials"},{name:"bio",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"actions",type:"Node[]",optional:!0,description:"Buttons to render at the bottom"}],render:(t,e,r)=>{const a=l("div",{class:"rui-profile-card"}),n=l("div",{class:"rui-profile-card-header"});n.append(lt(p(e.avatarSrc),p(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[p(e.name)]));const o=p(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=p(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const u=C(e.tags);if(u.length>0){const m=l("div",{class:"rui-profile-card-tags"});for(const d of u){const f=p(d);f&&m.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[f])]))}a.append(m)}const c=Oe(e.actions,r);return c&&(c.classList.add("rui-profile-card-actions"),a.append(c)),a}},eu={name:"Comment",description:"Single comment / message bubble. Renders avatar, author, timestamp, body, and an optional row of toolbar buttons (reply, like, …).",props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=l("article",{class:"rui-comment"});a.append(lt(p(e.avatarSrc),p(e.author),"md"));const n=l("div",{class:"rui-comment-body"}),i=l("header",{class:"rui-comment-header"});i.append(l("span",{class:"rui-comment-author"},[p(e.author)]));const o=p(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[p(e.body)]));const s=Oe(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},tu={name:"Banner",description:"Full-width announcement banner. Use at the top of a page for promos, release notes, or downtime notices. For inline notices prefer Callout or Alert.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"action",type:"Button",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"},{name:"tone",type:"string",optional:!0,enum:Re}],render:(t,e,r)=>{const a=p(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=p(e.icon)||nc(a)||"",o=E(i,{className:"rui-banner-icon"});o&&n.append(o);const s=l("div",{class:"rui-banner-body"});s.append(l("strong",{class:"rui-banner-title"},[p(e.title)]));const u=p(e.message);if(u&&s.append(l("span",{class:"rui-banner-message"},[u])),n.append(s),e.action){const c=l("div",{class:"rui-banner-action"});c.append(r.renderNode(e.action)),n.append(c)}return n}},ru={name:"KanbanCard",description:"Single card on a Kanban board.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"assignee",type:"string",optional:!0,description:"Name shown next to avatar initials"},{name:"tone",type:"string",optional:!0,enum:Re},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown beside the title"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Optional callable fired when the card is clicked"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-card","data-tone":p(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=c=>{const m=c;(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=E(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(p(e.title))),a.append(n);const o=p(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=C(e.tags);if(s.length>0){const c=l("div",{class:"rui-kanban-card-tags"});for(const m of s){const d=p(m);d&&c.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(c)}const u=p(e.assignee);if(u){const c=l("footer",{class:"rui-kanban-card-footer"});c.append(lt("",u,"sm")),c.append(l("span",{class:"rui-kanban-card-assignee"},[u])),a.append(c)}return a}},au={name:"KanbanColumn",description:"Single column inside a KanbanBoard. Children must be KanbanCard entries.",props:[{name:"title",type:"string"},{name:"items",type:"KanbanCard[]",aliases:["cards"]},{name:"tone",type:"string",optional:!0,enum:Re,description:"Header accent tone"}],render:(t,e,r)=>{const a=C(e.items),n=l("section",{class:"rui-kanban-column","data-tone":p(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[p(e.title)])),i.append(l("span",{class:"rui-kanban-column-count"},[String(a.length)])),n.append(i);const o=l("div",{class:"rui-kanban-column-body"});for(const s of a)o.append(r.renderNode(s));return a.length===0&&o.append(l("div",{class:"rui-kanban-column-empty"},["No items"])),n.append(o),n}},nu={name:"KanbanBoard",description:"Horizontal Kanban board. Children must be KanbanColumn entries. The board scrolls horizontally on narrow viewports so columns stay readable.",props:[{name:"columns",type:"KanbanColumn[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-board"});for(const n of C(e.columns))a.append(r.renderNode(n));return a}},iu={name:"SectionHeader",description:"Compact section header for the top of a Card or panel. Renders a small eyebrow, a title, an optional subtitle, an optional status Tag/Badge, and a right-aligned actions row. Use this inside a Card to introduce a section instead of a bare `CardHeader`.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase label above the title"},{name:"status",type:"Badge | Tag",optional:!0,aliases:["badge"]},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links shown on the right"}],render:(t,e,r)=>{const a=l("header",{class:"rui-section-header"}),n=l("div",{class:"rui-section-header-left"}),i=p(e.eyebrow);i&&n.append(l("span",{class:"rui-section-header-eyebrow"},[i]));const o=l("div",{class:"rui-section-header-title-line"});o.append(l("h3",{class:"rui-section-header-title"},[p(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=p(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const u=Oe(e.actions,r);return u&&(u.classList.add("rui-section-header-actions"),a.append(u)),a}},ou={name:"Toolbar",description:"Horizontal toolbar for filters, search, view modes, and primary actions. Left/center/right slots wrap onto separate rows on narrow viewports so the bar never overflows. Pass `searchable: true` to auto-mount a SearchBar in the left slot (bind `searchValue` to a `$variable`). Use ABOVE a Table, List, Grid, or Kanban view — never replace `PageHeader` with it.",props:[{name:"left",type:"Node[]",optional:!0,description:"Filters / search inputs / chips"},{name:"right",type:"Node[]",optional:!0,description:"Primary action buttons"},{name:"center",type:"Node[]",optional:!0,description:"Centered controls (e.g. SegmentedControl, search bar)"},{name:"searchable",type:"boolean",optional:!0,description:"Auto-mount a SearchBar at the start of the left slot"},{name:"searchPlaceholder",type:"string",optional:!0,description:"Placeholder for the auto-mounted SearchBar"},{name:"searchValue",type:"string",optional:!0,description:"$variable bound to the auto-mounted SearchBar"}],render:(t,e,r)=>{const a=C(e.center),n=l("div",{class:"rui-toolbar","data-has-center":a.length>0?"true":"false"}),i=l("div",{class:"rui-toolbar-side rui-toolbar-left"});T(e.searchable)&&i.append(Ln.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:p(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of C(e.left))i.append(r.renderNode(s));if(n.append(i),a.length>0){const s=l("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const u of a)s.append(r.renderNode(u));n.append(s)}const o=l("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of C(e.right))o.append(r.renderNode(s));return n.append(o),n}},su={name:"SidebarItem",description:"Single navigation item inside a Sidebar. Pass `active=true` to mark as the current page, a `to` path to navigate via the runtime router on click, an `onClick` callable for arbitrary click handling, or an optional `badge` (string/number) for a trailing chip. `to` and `onClick` can coexist — `onClick` is invoked AFTER the router navigates so authors can do extra work (analytics, side-effects).",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered before the label"},{name:"active",type:"boolean",optional:!0,description:"Mark this item as the current page. When `to` is provided and `active` is omitted, the item auto-detects the active state from the current router path."},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"to",type:"string",optional:!0,description:'Router path to navigate to on click (e.g. "/", "/orders"). Uses the runtime router — no full page reload.'},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked on click. Runs in addition to `to`-based navigation."}],render:(t,e,r)=>{const a=p(e.to),n=e.active!==void 0&&e.active!==null,i=a?r.router.getPath():"",o=a?a==="/"?i==="/":i===a?!0:i.startsWith(a+"/"):!1,s=n?T(e.active):o,u=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),c=E(e.icon,{className:"rui-sidebar-item-icon"});c&&u.append(c),u.append(l("span",{class:"rui-sidebar-item-label"},[p(e.label)]));const m=p(e.badge);return m&&u.append(l("span",{class:"rui-sidebar-item-badge"},[m])),(a||e.onClick!=null)&&(u.onclick=d=>{if(a){const f=d;if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey)return;r.router.navigate(a)}e.onClick!=null&&r.invoke(e.onClick)}),u}},lu={name:"SidebarSection",description:"Grouping inside a Sidebar — small uppercase label followed by SidebarItem entries. Use this to chunk a long sidebar into sections.",props:[{name:"label",type:"string"},{name:"items",type:"SidebarItem[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-sidebar-section"}),n=p(e.label);n&&a.append(l("div",{class:"rui-sidebar-section-label"},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a}},cu={name:"Sidebar",description:"Vertical app navigation panel. Supports a brand header, navigation items (`SidebarItem` or `SidebarSection`), an optional footer, and a `collapsed` mode that hides labels to leave just an icon rail. Use inside `AppShell` for SaaS-style left navigation.",props:[{name:"items",type:"(SidebarItem | SidebarSection)[]"},{name:"brand",type:"string",optional:!0,description:"Product name / workspace label at the top"},{name:"tagline",type:"string",optional:!0},{name:"footer",type:"Node[]",optional:!0,description:"Footer block (Avatar + name, upgrade CTA, …)"},{name:"collapsed",type:"boolean",optional:!0,description:"Render as an icon-only rail (hides labels/badges)"}],render:(t,e,r)=>{const a=T(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=p(e.brand),o=p(e.tagline);if(i||o){const c=l("div",{class:"rui-sidebar-header"});i&&c.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&c.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(c)}const s=l("nav",{class:"rui-sidebar-body"});for(const c of C(e.items))s.append(r.renderNode(c));n.append(s);const u=C(e.footer);if(u.length>0){const c=l("div",{class:"rui-sidebar-footer"});for(const m of u)c.append(r.renderNode(m));n.append(c)}return n}},uu={name:"AppShell",description:"Canonical SaaS application shell: optional top bar, fixed left Sidebar, and scrollable main content. Reach for this whenever a response represents a full product surface (dashboard with nav, settings + sections, admin panels). Pass `collapsible=true` to render a hamburger that turns the sidebar into a slide-over drawer on narrow viewports.",props:[{name:"sidebar",type:"Sidebar",description:"Pass a Sidebar(...) node"},{name:"content",type:"Node[]",description:"Main content (typically starts with a PageHeader)"},{name:"topbar",type:"Node[]",optional:!0,description:"Optional thin top bar above the content"},{name:"collapsible",type:"boolean",optional:!0,description:"Show a hamburger that toggles the sidebar drawer on mobile"},{name:"sidebarOpen",type:"boolean",optional:!0,description:"$variable controlling whether the mobile drawer is open"}],render:(t,e,r)=>{const a=T(e.collapsible),n=T(e.sidebarOpen),i=l("div",{class:"rui-app-shell"});a&&(i.dataset.collapsible="true"),n&&(i.dataset.sidebarOpen="true");const o=l("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),a){const m=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});m.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(m)}const s=l("div",{class:"rui-app-shell-main"}),u=C(e.topbar);if(u.length>0||a){const m=l("div",{class:"rui-app-shell-topbar"});if(a){const d=l("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});d.append(E("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),m.append(d)}for(const d of u)m.append(r.renderNode(d));s.append(m)}const c=l("div",{class:"rui-app-shell-content"});for(const m of C(e.content))c.append(r.renderNode(m));return s.append(c),i.append(s),i}},du={name:"SplitView",description:"Two-pane master/detail layout — a narrow primary pane on the left, wider detail pane on the right. Collapses to a single column on narrow viewports. Use for inboxes, file browsers, contact lists.",props:[{name:"primary",type:"Node[]",description:"Master pane content (list, filters)"},{name:"detail",type:"Node[]",aliases:["secondary"],description:"Detail pane content (selected item, empty state)"},{name:"primaryWidth",type:"string",optional:!0,aliases:["splitAt"],description:"CSS width for the primary pane (default 320px)"}],render:(t,e,r)=>{const a=te(p(e.primaryWidth),"320px"),n=l("div",{class:"rui-split-view",style:`--rui-split-primary:${a}`}),i=l("div",{class:"rui-split-view-primary"});for(const s of C(e.primary))i.append(r.renderNode(s));const o=l("div",{class:"rui-split-view-detail"});for(const s of C(e.detail))o.append(r.renderNode(s));return n.append(i,o),n}},pu={name:"DescriptionItem",description:"Single row inside a DescriptionList. Renders a small uppercase label on the left and a value (string or arbitrary Node) on the right.",props:[{name:"label",type:"string"},{name:"value",type:"Node | string"},{name:"icon",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-description-item"}),n=l("dt",{class:"rui-description-label"}),i=E(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(p(e.label)));const o=l("dd",{class:"rui-description-value"});return e.value&&typeof e.value=="object"&&e.value.__kind==="Component"?o.append(r.renderNode(e.value)):o.append(document.createTextNode(p(e.value))),a.append(n,o),a}},mu={name:"DescriptionList",description:"Compact key/value summary for detail pages — replaces a row of `Text`s with a properly aligned `<dl>`. Children must be DescriptionItem entries. Two columns by default on wide viewports.",props:[{name:"items",type:"DescriptionItem[]"},{name:"columns",type:"number",optional:!0,description:"1 or 2 (default 2)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),n=l("dl",{class:"rui-description-list","data-columns":String(a)});for(const i of C(e.items))n.append(r.renderNode(i));return n}},fu={name:"StatusDot",description:"Inline status pip + label. Use for compact health/state indicators in toolbars, sidebars, lists, and table cells.",props:[{name:"label",type:"string"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]},{name:"pulse",type:"boolean",optional:!0,description:"Animate the dot for 'live' state"}],render:(t,e)=>{const r=l("span",{class:"rui-status-dot","data-tone":p(e.tone,"success"),"data-pulse":T(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[p(e.label)])),r}},gu={name:"PricingCard",description:"Single pricing tier card with plan name, price, billing period, description, bullet features, and a CTA button. Mark one tier as `featured=true` to highlight it (raises the card, adds a ribbon).",props:[{name:"plan",type:"string",description:"Tier name (e.g. 'Pro')"},{name:"price",type:"string",description:"Display price (e.g. '$29')"},{name:"period",type:"string",optional:!0,description:"Billing period (e.g. '/mo')"},{name:"description",type:"string",optional:!0},{name:"features",type:"string[]",optional:!0,description:"Bullet list of included features"},{name:"action",type:"Button",optional:!0,aliases:["cta"],description:"Primary CTA — pass a Button(...)"},{name:"badge",type:"string",optional:!0,description:"Eyebrow / badge above the plan name"},{name:"featured",type:"boolean",optional:!0,aliases:["highlighted"]}],render:(t,e,r)=>{const a=T(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=p(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[p(e.plan)]));const o=p(e.description);o&&n.append(l("p",{class:"rui-pricing-card-description"},[o]));const s=l("div",{class:"rui-pricing-card-price-row"});s.append(l("span",{class:"rui-pricing-card-price"},[p(e.price)]));const u=p(e.period);u&&s.append(l("span",{class:"rui-pricing-card-period"},[u])),n.append(s);const c=C(e.features);if(c.length>0){const m=l("ul",{class:"rui-pricing-card-features"});for(const d of c){const f=p(d);if(!f)continue;const g=E("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});m.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(f)]))}n.append(m)}if(e.action){const m=l("div",{class:"rui-pricing-card-action"});m.append(r.renderNode(e.action)),n.append(m)}return n}},hu={name:"PricingTable",description:"Responsive grid of PricingCard tiers. Items size uniformly across a row and wrap onto multiple rows on narrow viewports. Use as the centerpiece of any pricing or upgrade page.",props:[{name:"tiers",type:"PricingCard[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),n=l("div",{class:"rui-pricing-table","data-columns":a>0?String(a):null});for(const i of C(e.tiers))n.append(r.renderNode(i));return n}},bu={name:"MediaCard",description:'Card with a media (image) header followed by title, body, optional tags, footer meta, and an actions row. Use for article previews, product cards, project highlights, gallery items — anywhere a Card needs a leading image. Orient with `orientation="horizontal"` for side-by-side media + content on wide viewports.',props:[{name:"title",type:"string"},{name:"imageSrc",type:"string",optional:!0,aliases:["src","image"],description:"Image URL (omit to render a neutral placeholder)"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0,description:"Tag pill labels"},{name:"meta",type:"string",optional:!0,description:"Footer meta line (author · date · category)"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links rendered at the bottom"},{name:"badge",type:"string | Badge",optional:!0,description:"Eyebrow string or Badge node shown over the image"},{name:"orientation",type:"string",optional:!0,enum:["vertical","horizontal"]},{name:"ratio",type:"string",optional:!0,description:"Media aspect ratio (default 16:9 vertical, 4:3 horizontal)"}],render:(t,e,r)=>{const a=p(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=vu(p(e.ratio,a==="horizontal"?"4:3":"16:9")),o=l("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ne(e.imageSrc);if(s)o.append(l("img",{src:s,alt:p(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=E("image",{className:"rui-media-card-placeholder"})??l("span",{class:"rui-media-card-placeholder"});o.append(g)}if(e.badge){const g=l("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?g.append(document.createTextNode(p(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const u=l("div",{class:"rui-media-card-body"});u.append(l("h3",{class:"rui-media-card-title"},[p(e.title)]));const c=p(e.description);c&&u.append(l("p",{class:"rui-media-card-description"},[c]));const m=C(e.tags);if(m.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const h of m){const b=p(h);b&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[b])]))}u.append(g)}const d=p(e.meta);d&&u.append(l("p",{class:"rui-media-card-meta"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),u.append(f)),n.append(u),n}};function vu(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function $r(t,e="primary"){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg");if(i.setAttribute("class","rui-sparkline"),i.setAttribute("data-tone",e),i.setAttribute("viewBox","0 0 80 24"),i.setAttribute("width",String(80)),i.setAttribute("height",String(24)),i.setAttribute("aria-hidden","true"),t.length<2)return i;const o=Math.min(...t),s=Math.max(...t),u=s-o||1,c=80/(t.length-1),d=t.map((b,v)=>{const y=v*c,x=2+(s-b)/u*20;return[y,x]}).map(([b,v],y)=>`${y===0?"M":"L"}${b.toFixed(1)},${v.toFixed(1)}`).join(" "),f=`${d} L80,24 L0,24 Z`,g=document.createElementNS(n,"path");g.setAttribute("d",f),g.setAttribute("class","rui-sparkline-area"),i.appendChild(g);const h=document.createElementNS(n,"path");return h.setAttribute("d",d),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),i.appendChild(h),i}const yu={name:"Stats",description:'KPI strip or grid. Pass `items` as `{label, value, hint?, tone?, spark?}` objects for strip layout, or as `StatCard(...)` nodes when `layout="grid"`.',props:[{name:"items",type:"object[] | StatCard[]",description:"Stat objects or StatCard nodes when layout=grid"},{name:"layout",type:"string",optional:!0,enum:["strip","grid"],description:"strip = horizontal row; grid = responsive Grid"},{name:"columns",type:"number",optional:!0,description:"Preferred column count for grid layout (1–6)"},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:"Strip alignment (layout=strip only)"}],render:(t,e,r)=>{const a=C(e.items),n=a.some(u=>u&&typeof u=="object"&&u.__kind==="Component");if(p(e.layout,n?"grid":"strip")==="grid"){const u=e.columns?Math.max(1,Math.min(6,Math.floor(L(e.columns)))):0,c=Cn.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:u>0?u:"auto",gap:"m"},r);return c.classList.add("rui-metric-grid"),c}const o=p(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const u of a){const c=u??{},m=p(c.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":m});d.append(l("div",{class:"rui-stats-label"},[p(c.label)]));const f=l("div",{class:"rui-stats-value-row"});f.append(l("div",{class:"rui-stats-value"},[p(c.value)]));const g=C(c.spark).map(b=>Number(b)).filter(b=>Number.isFinite(b));g.length>1&&f.append($r(g,m)),d.append(f);const h=p(c.hint);h&&d.append(l("div",{class:"rui-stats-hint"},[h])),s.append(d)}return s}},xu={name:"Tile",description:"Compact icon + label + optional value tile. Smaller and denser than `StatCard`, ideal for menu grids, quick-action panels, category directories, and category filters. Pair with `Grid` for uniform rows.",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"value",type:"string",optional:!0,description:"Secondary value rendered next to/under the label"},{name:"description",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:Re},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",i=l(a?"button":"div",{type:a?"button":null,class:"rui-tile","data-tone":p(e.tone,"default")}),o=E(e.icon,{className:"rui-tile-icon"});o&&i.append(o);const s=l("div",{class:"rui-tile-body"});s.append(l("div",{class:"rui-tile-label"},[p(e.label)]));const u=p(e.value);u&&s.append(l("div",{class:"rui-tile-value"},[u]));const c=p(e.description);return c&&s.append(l("div",{class:"rui-tile-description"},[c])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},Rn={name:"Notification",description:"Inline notification card with title, message, time, optional avatar, and dismiss/action buttons. Use inside notification panels, inboxes, or activity drawers — for top-of-page announcements prefer `Banner`.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar URL (alternative to `icon`)"},{name:"tone",type:"string",optional:!0,enum:Re},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=T(e.unread),n=l("article",{class:"rui-notification","data-tone":p(e.tone,"default"),"data-unread":a?"true":"false"}),i=p(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(lt(i,p(e.title),"md"));else{const g=E(p(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),u=l("header",{class:"rui-notification-head"}),c=l("span",{class:"rui-notification-title-wrap"});a&&c.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),c.append(l("span",{class:"rui-notification-title"},[p(e.title)])),u.append(c);const m=p(e.time);m&&u.append(l("span",{class:"rui-notification-time"},[m])),s.append(u);const d=p(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),n.append(s),n}},wu={name:"PersonChip",description:'Inline avatar + name + optional role/meta pill. Use anywhere a person needs to be referenced compactly: table cells, list rows, comments, kanban cards, sidebar footers. Pair multiple chips with `Stack(direction="row", wrap=true)` for assignee lists.',props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0,description:"Sub-line below the name (role, email, handle, …)"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",n=a?"button":"div",i=p(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=l(n,{type:a?"button":null,class:"rui-person-chip","data-size":i}),u=l("span",{class:"rui-person-chip-avatar"});u.append(lt(p(e.avatarSrc),p(e.name),o));const c=p(e.status);c&&u.append(l("span",{class:"rui-person-chip-status","data-status":c})),s.append(u);const m=l("div",{class:"rui-person-chip-meta"});m.append(l("span",{class:"rui-person-chip-name"},[p(e.name)]));const d=p(e.role);return d&&m.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(m),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},En=["left","center","right"],ku={name:"Col",description:'Single column inside a Table or DataGrid. Use `align` for per-column text alignment, `format` for cell rendering (`text|number|currency|date`). `values` may be plain values OR an array of component nodes — e.g. `Col("Status", rows.map(r => Badge(r.status)))` or `Col("Actions", rows.map(r => Button("Edit")))` — each component renders directly in its cell. Pass `render: (value, index) => …` for the same effect when you prefer to keep `values` as the raw row data (return a component, string, or array). Pass `onClick: (value, index) => …` to make the whole cell clickable (pointer + keyboard). `sortable` and `filterable` only take effect inside `DataGrid` (Table ignores them).',props:[{name:"header",type:"string"},{name:"values",type:"any[]",description:"Column values. Plain values are formatted as text; component nodes (e.g. `rows.map(r => Badge(r.status))`) render directly. You can also pass the full row array and map each cell with `render`."},{name:"format",type:"string",optional:!0,enum:["text","number","currency","date"]},{name:"align",type:"string",optional:!0,enum:En,description:"Per-column horizontal alignment"},{name:"sortable",type:"boolean",optional:!0,description:"DataGrid: enable click-to-sort on this column"},{name:"filterable",type:"boolean",optional:!0,description:"DataGrid: enable a per-column filter chip"},{name:"render",type:"callable",optional:!0,aliases:["cell"],description:"`(value, index) => Component | string | array` — map each cell to arbitrary content (buttons, badges, links)."},{name:"onClick",type:"callable",optional:!0,aliases:["onclick","cellClick"],description:"`(value, index) => void` — fired when a cell in this column is clicked or activated via keyboard."}],render:(t,e)=>{const r=l("div",{class:"rui-col"});return r.append(l("strong",{},[p(e.header)])),r}},Su={name:"Table",description:'Tabular data view. Children must be Col components. `density="compact"` tightens row padding for dense data, `striped=true` zebra-stripes the rows, and `sticky=true` pins the header row when the table scrolls. The empty-state row uses `emptyLabel` when set.',props:[{name:"columns",type:"Col[]"},{name:"caption",type:"string",optional:!0,aliases:["title"]},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"],description:"Row padding (default `comfortable`)"},{name:"striped",type:"boolean",optional:!0,description:"Zebra-stripe alternating rows"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the header row when the table scrolls"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when the table has no rows (default `No data`)"}],render:(t,e,r)=>{const a=C(e.columns),n=p(e.density,"comfortable"),i=T(e.striped),o=T(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),u=l("table",{class:"rui-table"}),c=p(e.caption);c&&u.append(l("caption",{class:"rui-table-caption"},[c]));const m=a.map(w=>{const k=p(w.args?.[3],"");return En.includes(k)?k:""}),d=l("thead"),f=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],A=l("th",{"data-align":m[w]||null},[p(k.args?.[0])]);f.append(A)}d.append(f),u.append(d);const g=l("tbody"),h=a.map(w=>C(w.args?.[1])),b=a.map(w=>p(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...h.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");h.forEach((A,S)=>{const $=b[S]??"text",M=m[S],I=l("td",{"data-format":$,"data-align":M||null});hr(I,{format:$,render:v[S],onClick:y[S]},A[w],w,r,Iu),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=p(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return u.append(g),s.append(u),s}},Cu={name:"ListItem",description:"Single list item with optional title and description.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0,aliases:["meta"]},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-list-item"}),a=E(e.icon,{className:"rui-list-icon"});a&&r.append(a);const n=l("div",{class:"rui-list-text"});n.append(l("div",{class:"rui-list-title"},[p(e.title)]));const i=p(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},$u={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of C(e.items))n.append(r.renderNode(i));return n}},Tu={name:"StatCard",description:"Single KPI card with label, value, optional delta, optional icon, and optional inline sparkline (`spark=[…numbers]`). Use inside `Stats` for a uniform KPI strip.",props:[{name:"label",type:"string"},{name:"value",type:"string"},{name:"trend",type:"string",optional:!0,enum:["up","down","flat"]},{name:"delta",type:"string",optional:!0,description:"Change vs previous period"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a chip beside the label"},{name:"spark",type:"number[]",optional:!0,description:"Optional inline sparkline values"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=p(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=p(e.label),o=p(e.icon)||Mn(i)||"",s=E(o,{className:"rui-stat-icon"});s&&n.append(s),n.append(l("div",{class:"rui-stat-label"},[i])),a.append(n),a.append(l("div",{class:"rui-stat-value"},[p(e.value)]));const u=p(e.delta),c=p(e.trend);(u||c)&&a.append(l("div",{class:"rui-stat-trend","data-trend":c||"flat"},[u||Pu(c)]));const m=C(e.spark).map(d=>L(d));if(m.length>1){const d=l("div",{class:"rui-stat-spark"});d.append($r(m,r==="default"?"primary":r)),a.append(d)}return a}},Au={name:"Sparkline",description:"Tiny inline trend chart for KPIs, table cells, and dashboards. Renders an SVG line with a soft fill — use anywhere you would otherwise reach for `LineChart` but a single value series should stay inline with surrounding text.",props:[{name:"values",type:"number[]"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=p(e.tone,"primary"),a=C(e.values).map(i=>L(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append($r(a,r)),n}},Nu={name:"TreeNode",description:"Single node in a Tree view. When `children` is provided the node renders as an expandable branch with a chevron; otherwise it renders as a leaf. `onClick` fires on click. Use `active=true` to highlight the current selection.",props:[{name:"label",type:"string"},{name:"children",type:"TreeNode[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon shown before the label"},{name:"expanded",type:"boolean",optional:!0,description:"Whether the branch is open by default"},{name:"active",type:"boolean",optional:!0,aliases:["selected"],description:"Highlights the row as the current selection"},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired when the row is clicked"}],render:(t,e,r)=>{const a=C(e.children),n=a.length>0,i=T(e.expanded),o=T(e.active),s=typeof e.onClick=="function",u=l(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":n?i?"true":"false":null});if(n){const h=E("chevron-right",{className:"rui-tree-node-chevron"});h&&u.append(h)}else u.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const c=E(e.icon,{className:"rui-tree-node-icon"});c&&u.append(c),u.append(l("span",{class:"rui-tree-node-label"},[p(e.label)]));const m=p(e.badge);if(m&&u.append(l("span",{class:"rui-tree-node-badge"},[m])),s&&(u.onclick=()=>r.invoke(e.onClick)),!n)return u;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const f=l("summary",{class:"rui-tree-node-summary"});f.append(u),s&&(f.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),d.append(f);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const h of a)g.append(r.renderNode(h));return d.append(g),d}},Mu={name:"Tree",description:"Hierarchical tree view. Children must be TreeNode entries. Use for file browsers, nested navigation, category pickers, and any parent/child structure with arbitrary depth.",props:[{name:"items",type:"TreeNode[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tree",role:"tree"});for(const n of C(e.items))a.append(r.renderNode(n));return a}};function Pu(t){return t==="up"?"▲":t==="down"?"▼":"—"}function Iu(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Tr=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],Ze=t=>Tr[t%Tr.length]??Tr[0],Lu={name:"Series",description:"Named data series for charts. Used inside BarChart, LineChart, PieChart.",props:[{name:"name",type:"string"},{name:"values",type:"number[]"}],render:(t,e)=>l("span",{class:"rui-series","data-name":p(e.name)})},jn=t=>t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}}),zu={name:"BarChart",description:"Vertical bar chart. `labels` define the x-axis, `series` define grouped bars.",props:[{name:"labels",type:"string[]"},{name:"series",type:"Series[]"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=C(e.labels).map(y=>p(y)),a=jn(C(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});p(e.title)&&n.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,u=Bn(r,o-40-12),c={left:40,right:12,top:12,bottom:u.bottomPadding},m=o-c.left-c.right,d=s-c.top-c.bottom,f=Ar(o,s);On(f,c,m,d,i);const g=r.length,h=m/Math.max(g,1),b=a.length,v=h*.7/Math.max(b,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const A=w/i*d,S=c.left+k*h+h*.15+x*v,$=c.top+d-A,M=ge("rect",{x:String(S),y:String($),width:String(Math.max(v-2,1)),height:String(A),fill:Ze(x),rx:"2"});M.append(ge("title",{},[`${y.name}: ${w}`])),f.append(M)})}),Fn(f,r,c,m,d,u,y=>c.left+(y+.5)*h),n.append(f),a.length>0&&n.append(Nr(a)),n}},Ru={name:"LineChart",description:'Line chart. `labels` define the x-axis, each Series is a line. As a shortcut you can pass `data=[{x: "Jan", revenue: 12, signups: 4}, …]` and the labels + series will be derived automatically (one line per non-`x` key). Use `data` when the dataset is already row-shaped; use `series` when you have explicit Series objects.',props:[{name:"labels",type:"string[]",optional:!0},{name:"series",type:"Series[]",optional:!0},{name:"data",type:"{x: string, [key: string]: number}[]",optional:!0,description:"Row-shaped data — labels and series are auto-derived"},{name:"title",type:"string",optional:!0},{name:"filled",type:"boolean",optional:!0,description:"Fill the area beneath each line (area-chart style)"},{name:"stacked",type:"boolean",optional:!0,description:"Stack series when filled=true"}],render:(t,e)=>{let r=C(e.labels).map($=>p($)),a=jn(C(e.series));const n=C(e.data);if(n.length>0&&(r.length===0||a.length===0)){const $=[],M=new Map;for(const I of n){const R=I;if(!(!R||typeof R!="object")){$.push(p(R.x??R.label??""));for(const[j,K]of Object.entries(R)){if(j==="x"||j==="label")continue;const F=L(K);Number.isNaN(F)||(M.has(j)||M.set(j,[]),M.get(j).push(F))}}}r.length===0&&(r=$),a.length===0&&(a=[...M.entries()].map(([I,R])=>({name:I,values:R})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map($=>$.values.length),1),u=a.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let M=0;a.forEach((I,R)=>{M+=I.values[$]??0,u[R][$]=M})}const c=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});p(e.title)&&c.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const m=i&&o?u.flat():a.flatMap($=>$.values),d=Math.max(1,...m),f=i&&o?0:Math.min(0,...m),g=640,h=240,b=Bn(r,g-40-12),v={left:40,right:12,top:12,bottom:b.bottomPadding},y=g-v.left-v.right,x=h-v.top-v.bottom,w=Ar(g,h);On(w,v,y,x,d,f);const k=Math.max(r.length-1,1),A=y/k,S=$=>v.left+$*(y/Math.max(s-1,1));return a.forEach(($,M)=>{const I=i&&o?u[M]:$.values,R=i&&o&&M>0?u[M-1]:null,j=I.map((F,U)=>{const J=S(U),Z=v.top+x-(F-f)/(d-f||1)*x;return[J,Z]});if(i&&j.length>0){let F=j.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(R){const U=R.map((J,Z)=>{const de=S(Z),Se=v.top+x-(J-f)/(d-f||1)*x;return[de,Se]});F+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=j[0],J=j[j.length-1];F+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ge("path",{d:F,fill:Ze(M),"fill-opacity":"0.2",stroke:"none"}))}const K=j.map(([F,U],J)=>`${J===0?"M":"L"}${F.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ge("path",{d:K,fill:"none",stroke:Ze(M),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&j.forEach(([F,U])=>{w.append(ge("circle",{cx:String(F),cy:String(U),r:"3",fill:Ze(M)}))})}),Fn(w,r,v,y,x,b,$=>v.left+$*A),c.append(w),a.length>0&&c.append(Nr(a)),c}},Eu={name:"PieChart",description:'Pie / Donut chart. Each segment maps to a label/value pair. Numeric labels are rendered on every segment by default — set `showValues: false` to hide them, or `valueFormat: "percent"` to show the share instead of the raw value.',props:[{name:"labels",type:"string[]"},{name:"values",type:"number[]"},{name:"title",type:"string",optional:!0},{name:"showValues",type:"boolean",optional:!0,description:"Render numeric labels on each slice (default true)"},{name:"valueFormat",type:"string",optional:!0,enum:["value","percent","both"],description:'How to format the on-segment label (default "value")'}],render:(t,e)=>{const r=C(e.labels).map(b=>p(b)),a=C(e.values).map(b=>L(b)),n=e.showValues==null?!0:T(e.showValues),i=p(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=a.reduce((b,v)=>b+(v>0?v:0),0)||1,c=Ar(240,240),m=120,d=120,f=90,g=.05;let h=-Math.PI/2;return a.forEach((b,v)=>{const y=b>0?b:0,x=y/u,w=x*Math.PI*2,k=h+w,A=w>Math.PI?1:0,S=m+f*Math.cos(h),$=d+f*Math.sin(h),M=m+f*Math.cos(k),I=d+f*Math.sin(k),R=`M${m},${d} L${S},${$} A${f},${f} 0 ${A} 1 ${M},${I} Z`,j=ge("path",{d:R,fill:Ze(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(j.append(ge("title",{},[`${r[v]??""}: ${b} (${(x*100).toFixed(1)}%)`])),c.append(j),n&&y>0&&x>=g){const K=h+w/2,F=f*.62,U=m+F*Math.cos(K),J=d+F*Math.sin(K),Z=ju(b,x,o),de=ge("text",{x:String(U),y:String(J),class:"rui-pie-chart-value","text-anchor":"middle","dominant-baseline":"central","paint-order":"stroke",stroke:"rgba(15, 23, 42, 0.55)","stroke-width":"3","stroke-linejoin":"round",fill:"#fff"},[Z]);c.append(de)}h=k}),s.append(c),s.append(Nr(r.map((b,v)=>({name:b,values:[a[v]??0]})))),s}};function ju(t,e,r){const a=`${Math.round(e*100)}%`,n=Du(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function Du(t){if(!Number.isFinite(t))return String(t);const e=Math.abs(t);return e>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:Number.isInteger(t)?String(t):t.toFixed(1)}const Bu=7,Dn=12;function Bn(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),a=t.reduce((o,s)=>Math.max(o,s.length),0);if(a*Bu+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<Dn?Math.max(1,Math.ceil(Dn/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function Fu(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Fn(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((u,c)=>{if(c%i.step!==0)return;const m=o(c),d=Fu(u,i.maxChars),f={x:String(m),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${m}, ${s})`);const g=ge("text",f,[d]);d!==u&&g.append(ge("title",{},[u])),t.append(g)})}function Ar(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ge(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function On(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ge("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ge("text",{x:String(e.left-6),y:String(c+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}function Nr(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${Ze(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Ou={name:"SectionBlock",description:"Titled chat block with a description and child content.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"description",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("section",{class:"rui-section-block"});a.append(l("h3",{class:"rui-section-block-title"},[p(e.title)]));const n=p(e.description);n&&a.append(l("p",{class:"rui-section-block-description"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},_u={name:"ListBlock",description:"Chat-styled list with bullets, useful for steps or summaries.",props:[{name:"items",type:"string[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e)=>{const r=T(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of C(e.items))a.append(l("li",{},[p(n)]));return a}},Uu={name:"FollowUpBlock",description:'Suggested follow-up prompts shown as buttons. Each item dispatches its label as an assistant message (equivalent to `emit "assistant-message" { message }`).',props:[{name:"items",type:"FollowUpItem[]",description:"Array of FollowUpItem(label, message?), {label, message} objects, or plain strings"},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-follow-up"}),n=p(e.title,"You can also ask");n&&a.append(l("div",{class:"rui-follow-up-title"},[n]));const i=l("div",{class:"rui-follow-up-list"});for(const o of C(e.items))i.append(Hu(o,r));return a.append(i),a}},Hu=(t,e)=>{const{label:r,message:a}=Vu(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},Vu=t=>{if(typeof t=="string")return{label:t,message:t};if(t&&typeof t=="object"){const r=t;if(r.__kind==="Component"&&Array.isArray(r.args)){const i=p(r.args[0]),o=p(r.args[1],i);return{label:i,message:o}}const a=p(r.label),n=p(r.message,a);return{label:a,message:n}}const e=p(t);return{label:e,message:e}},Wu={name:"FollowUpItem",description:"Single follow-up item.",props:[{name:"label",type:"string"},{name:"message",type:"string",optional:!0,description:"Defaults to label"}],render:(t,e,r)=>{const a=p(e.label),n=p(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},qu={name:"ActionLink",description:"Inline link that runs an action when clicked instead of navigating.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",aliases:["action","onclick"]}],render:(t,e,r)=>{const a=l("a",{class:"rui-action-link",href:"#",role:"button"},[p(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},_n=["sm","md","lg","xl"],Un={name:"Avatar",description:'User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.',props:[{name:"name",type:"string",description:"Used for alt text + initials fallback"},{name:"src",type:"string",optional:!0,description:"Image URL"},{name:"size",type:"string",optional:!0,enum:_n},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:["initials","dicebear"],description:"How to render when `src` is missing (default: dicebear illustration; pass `initials` for the two-letter pill)"}],render:(t,e)=>{const r=p(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=p(e.name),i=p(e.fallback,"dicebear"),o=ne(e.src),s=!o&&i==="dicebear"&&n?ne(ic(n)):"",u=o||s;if(u){const m=l("img",{src:u,alt:n,loading:"lazy"});m.onerror=d=>{const f=d;(f.currentTarget??f.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ct(n)]))},a.append(m)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(n)]));const c=p(e.status);return c&&a.append(l("span",{class:"rui-avatar-status","data-status":c})),a}},Gu={name:"AvatarGroup",description:"Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.",props:[{name:"items",type:"Avatar[]",description:"Avatar(...) nodes or {name, src} objects"},{name:"max",type:"number",optional:!0,description:"Maximum avatars to show (default 4)"},{name:"size",type:"string",optional:!0,enum:_n}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=p(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,u=l("div",{class:"rui-avatar-group","data-size":i});for(const c of o){if(c&&typeof c=="object"&&c.__kind==="Component"){u.append(r.renderNode(c));continue}const m=c,d=typeof m=="string"?m:p((m??{}).name),f=typeof m=="string"?"":p((m??{}).src);u.append(Un.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:f,size:i},r))}return s>0&&u.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),u}},Ku={name:"Progress",description:"Linear progress bar. `value` is clamped between 0 and `max` (default 100). `indeterminate=true` renders a looping animation when the total is unknown. Provide `segments` to render a segmented progress strip (steps in an onboarding flow), or `buffered` for a secondary buffer indicator (downloads, video buffering).",props:[{name:"value",type:"number",optional:!0,description:"Current progress; ignored when indeterminate"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:"Shown above the bar"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"indeterminate",type:"boolean",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Show the numeric value on the right"},{name:"segments",type:"number",optional:!0,description:"Render N equal segments (filled by current step)"},{name:"buffered",type:"number",optional:!0,description:"Secondary value (0..max) drawn behind the bar"}],render:(t,e)=>{const r=Math.max(1,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(L(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,L(e.buffered,0))):null,u=l("div",{class:"rui-progress","data-tone":p(e.tone,"primary")}),c=p(e.label),m=T(e.showValue);if(c||m){const f=l("div",{class:"rui-progress-head"});if(f.append(l("span",{class:"rui-progress-label"},[c])),m&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;f.append(l("span",{class:"rui-progress-value"},[g]))}u.append(f)}if(o>0&&!a){const f=l("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(n/r*o)))}),g=Math.min(o,Math.round(n/r*o));for(let h=0;h<o;h+=1)f.append(l("span",{class:"rui-progress-segment","data-filled":h<g?"true":"false"}));return u.append(f),u}const d=l("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":a?null:String(n),"data-indeterminate":a?"true":"false"});if(s!==null){const f=Math.round(s/r*100);d.append(l("div",{class:"rui-progress-buffer",style:`width:${f}%`,"aria-hidden":"true"}))}return d.append(l("div",{class:"rui-progress-bar",style:a?"":`width:${i}%`})),u.append(d),u}},Yu={name:"Switch",description:"Compact on/off toggle. Pass a `$variable` as `value` for two-way binding — prefer Switch over Checkbox when the control represents a setting. `onChange(checked)` fires with the new boolean.",props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0},{name:"value",type:"boolean",optional:!0,aliases:["checked"],description:"Bound value (typically $variable)"},{name:"description",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=p(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":T(e.disabled)?"true":"false"}),i=T(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:T(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),u=t.argMeta?.[2]?.stateRef;u&&r.bindState(o,u,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const c=p(e.label),m=p(e.description);if(n.append(o,s),c||m){const d=l("span",{class:"rui-switch-meta"});c&&d.append(l("span",{class:"rui-switch-label"},[c])),m&&d.append(l("span",{class:"rui-switch-description"},[m])),n.append(d)}return n}},Xu={name:"ToggleGroup",description:"Group of mutually-exclusive Toggle-style buttons (single-select). Items are `[value, label]` arrays, `{value, label, icon?}` objects, or plain strings (used for both value and label). Pass a `$variable` as `value` for two-way binding. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"any[]"},{name:"value",type:"any",optional:!0},{name:"variant",type:"string",optional:!0,enum:["default","outline"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=p(e.value),n=p(e.variant,"outline"),i=p(e.size,"md"),o=l("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":n,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const u of C(e.items)){const{value:c,label:m,icon:d}=Ju(u),f=c===a,g=l("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":f?"true":"false","data-variant":n,"data-size":i,"data-state":f?"on":"off","data-value":c}),h=E(d,{className:"rui-toggle-icon"});h&&g.append(h),g.append(l("span",{class:"rui-toggle-label"},[m])),g.onclick=()=>{s&&r.setState(s,c),r.invoke(e.onChange,c)},o.append(g)}return o}};function Ju(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:p(t[0]),label:p(t[1],p(t[0])),icon:p(t[2])};if(t&&typeof t=="object"){const e=t,r=p(e.value);return{value:r,label:p(e.label,r),icon:p(e.icon)}}return{value:"",label:"",icon:""}}const Zu={name:"Tooltip",description:"Wraps a trigger node and shows `label` text when the user hovers or focuses it. Pure CSS — no JS needed. The tooltip hides on click/touch (so it does not stay stuck on touch devices) and supports `top|bottom|left|right` placement. Use for short hints (≤6 words); reach for HoverCard when you need rich content.",props:[{name:"label",type:"string"},{name:"trigger",type:"Node",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]}],render:(t,e,r)=>{const a=p(e.side,"top"),n=l("span",{class:"rui-tooltip","data-side":a,tabindex:"0"});n.append(l("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=l("span",{class:"rui-tooltip-content",role:"tooltip"},[p(e.label)]);return i.append(l("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),n.append(i),n.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===n||n.contains(document.activeElement))&&document.activeElement?.blur?.()})}),n}},Qu={name:"HoverCard",description:"Wraps a trigger node and reveals a card with rich content on hover/focus. Use for previewing a referenced item (profile, link target, definition).",props:[{name:"trigger",type:"Node"},{name:"content",type:"Node[]",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]},{name:"open",type:"boolean",optional:!0,description:"Force the card open (otherwise reveal on hover/focus)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-hover-card","data-side":p(e.side,"bottom"),"data-open":T(e.open)?"true":null,tabindex:"0"});a.append(l("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const n=l("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of C(e.content))n.append(r.renderNode(i));return a.append(n),a}},Mr={star:{full:"star",half:"star-half-stroke",empty:"regular:star"},heart:{full:"heart",half:"heart",empty:"regular:heart"},thumb:{full:"thumbs-up",half:"thumbs-up",empty:"regular:thumbs-up"},fire:{full:"fire",half:"fire",empty:"regular:fire"},bolt:{full:"bolt",half:"bolt",empty:"regular:bolt"}},ed={name:"Rating",description:"Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive=true` and a `$variable` as `value` to let users rate something; with `halfStep=true` clicking the left half of a star sets a fractional value. `icon` swaps the glyph family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom Font Awesome name.",props:[{name:"value",type:"number",description:"0–max; can be a $variable when interactive"},{name:"max",type:"number",optional:!0,description:"Maximum number of stars (default 5)"},{name:"label",type:"string",optional:!0,description:'Inline text shown after the stars (e.g. "4.2 of 5")'},{name:"count",type:"number",optional:!0,description:"Review/voter count rendered in parentheses"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"interactive",type:"boolean",optional:!0,description:"Allow clicking a star to set the value"},{name:"readonly",type:"boolean",optional:!0,description:"Force read-only (overrides `interactive`)"},{name:"halfStep",type:"boolean",optional:!0,description:"Allow half-star resolution when interactive"},{name:"icon",type:"string",optional:!0,description:"Icon family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any FA name"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new rating when the user clicks a star (interactive mode)"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.max,5))),n=Math.max(0,Math.min(a,L(e.value,0))),i=p(e.size,"md"),o=T(e.interactive)&&!T(e.readonly),s=T(e.halfStep),u=t.argMeta?.[0]?.stateRef,c=td(p(e.icon)),m=l("div",{class:"rui-rating","data-size":i,"data-interactive":o&&u?"true":"false","data-half-step":o&&u&&s?"true":"false",role:"img","aria-label":`${n} of ${a}`}),d=l("span",{class:"rui-rating-stars"});for(let h=1;h<=a;h+=1){const b=Math.max(0,Math.min(1,n-(h-1))),v=b>=1?c.full:b>0?c.half:c.empty,y=gr(v).join(" "),x=l(o&&u?"button":"span",{class:`rui-rating-star ${y}`.trim(),type:o&&u?"button":null,"data-fill":b>=1?"full":b>0?"half":"empty","aria-label":o&&u?`Rate ${h}`:null,"aria-hidden":o&&u?null:"true"});if(o&&u){const w=h,k=h-.5;x.onclick=A=>{let S=w;if(s){const $=A,I=($.currentTarget??$.target).getBoundingClientRect();I.width>0&&$.clientX-I.left<I.width/2&&(S=k)}r.setState(u,S),r.invoke(e.onChange,S)}}d.append(x)}m.append(d);const f=p(e.label);f&&m.append(l("span",{class:"rui-rating-label"},[f]));const g=e.count!=null?L(e.count,0):null;return g!==null&&g>0&&m.append(l("span",{class:"rui-rating-count"},[`(${g.toLocaleString()})`])),m}};function td(t){const e=t.trim().toLowerCase();return e?Mr[e]?Mr[e]:{full:e,half:e,empty:`regular:${e}`}:Mr.star}const rd={name:"ProgressRing",description:"Circular progress indicator. Use for KPIs, quotas, completion rings, and any metric better shown as a circle than a bar. Renders the value (or a custom label) inside the ring.",props:[{name:"value",type:"number",optional:!0,description:"Current value (ignored when indeterminate)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:'Text shown inside the ring (default "{percent}%")'},{name:"caption",type:"string",optional:!0,aliases:["description"],description:"Small caption rendered under the ring"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"indeterminate",type:"boolean",optional:!0}],render:(t,e)=>{const r=Math.max(1,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=p(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,u=o==="lg"?10:o==="sm"?6:8,c=(s-u)/2,m=2*Math.PI*c,d=a?m*.65:m*(1-i/100),f=l("div",{class:"rui-progress-ring","data-tone":p(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",b=document.createElementNS(h,"svg");b.setAttribute("width",String(s)),b.setAttribute("height",String(s)),b.setAttribute("viewBox",`0 0 ${s} ${s}`),b.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(c)),v.setAttribute("stroke-width",String(u)),v.setAttribute("fill","none"),b.appendChild(v);const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(c)),y.setAttribute("stroke-width",String(u)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(m)),y.setAttribute("stroke-dashoffset",String(d)),b.appendChild(y),g.append(b);const x=p(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=E(x,{className:"rui-progress-ring-icon"});k&&gr(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),f.append(g);const A=p(e.caption);return A&&f.append(l("span",{class:"rui-progress-ring-caption"},[A])),f}},ad={name:"ChatBubble",description:'Single chat-style message bubble with author, time, and body. Use for conversation threads, agent transcripts, support chats, and any message-style UI. Set `from="me"` (or any non-empty author) for the active speaker — the bubble aligns to the right with a primary tint. `from="agent"` (default) renders as the canonical incoming bubble on the left.',props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"from",type:"string",optional:!0,enum:["agent","me","system"],aliases:["role"],description:"Lane (default agent)"},{name:"status",type:"string",optional:!0,enum:["sending","sent","delivered","read","error"]}],render:(t,e)=>{const r=p(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(Hn(p(e.avatarSrc),p(e.author)));const n=l("div",{class:"rui-chat-bubble-bubble"}),i=l("header",{class:"rui-chat-bubble-head"});i.append(l("span",{class:"rui-chat-bubble-author"},[p(e.author)]));const o=p(e.time);o&&i.append(l("span",{class:"rui-chat-bubble-time"},[o])),n.append(i),n.append(l("p",{class:"rui-chat-bubble-body"},[p(e.body)]));const s=p(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(Hn(p(e.avatarSrc),p(e.author))),a}};function Hn(t,e){const r=l("span",{class:"rui-chat-bubble-avatar"}),a=ne(t);return a?r.append(l("img",{src:a,alt:e,loading:"lazy"})):r.append(l("span",{class:"rui-chat-bubble-fallback"},[ct(e)])),r}const nd={name:"Kbd",description:"Renders a keyboard shortcut chip (e.g. `Cmd+K`). Pass a single label, or multiple labels as an array to render a `key + key + …` combo.",props:[{name:"keys",type:"string | string[]"},{name:"size",type:"string",optional:!0,enum:["sm","md"]}],render:(t,e)=>{const r=p(e.size,"md"),a=l("span",{class:"rui-kbd-group","data-size":r});return(Array.isArray(e.keys)?e.keys:[e.keys]).forEach((i,o)=>{const s=p(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},id={name:"Popover",description:"Click-triggered popup with arbitrary rich content. Use when HoverCard's hover trigger is too eager and Modal/Sheet is too heavy — perfect for filter panels, color pickers, share menus, and small settings flyouts. The trigger stays visible while the popover is open — clicking it again, clicking outside, pressing Escape, or clicking the built-in × button all close it.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (Button, Avatar, IconButton, …). The trigger remains visible while the popover is open."},{name:"content",type:"Node[]",aliases:["children"],description:"Body rendered inside the popover"},{name:"title",type:"string",optional:!0,description:"Optional bold heading rendered above the content"},{name:"side",type:"string",optional:!0,enum:["bottom","top","left","right"],aliases:["placement"],description:'Where the popover opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:'Alignment along the trigger edge (default "start")'},{name:"width",type:"string",optional:!0,description:'CSS width for the popover panel (default "280px")'},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the popover"}],render:(t,e,r)=>{const a=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=te(e.width,""),s=l("div",{class:"rui-popover","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(e.align,"start")}),u=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});u.append(r.renderNode(e.trigger)),s.append(u);const c=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),m=l("div",{class:"rui-popover-header"}),d=p(e.title);m.append(d?l("div",{class:"rui-popover-title"},[d]):l("span",{class:"rui-popover-title-spacer"}));const f=l("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);f.onclick=g=>{g.stopPropagation(),Et(f,!1,n)},m.append(f),c.append(m);for(const g of C(e.content))c.append(r.renderNode(g));return s.append(c),u.onclick=g=>{g.stopPropagation();const h=g.currentTarget??g.target,b=!n.get(),v=Et(h,b,n);b&&v&&Vn(v,n)},u.onkeydown=g=>{const h=g,b=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const v=!n.get(),y=Et(b,v,n);v&&y&&Vn(y,n)}else h.key==="Escape"&&n.get()&&(h.preventDefault(),Et(b,!1,n))},s}},Et=(t,e,r)=>{r.set(e);const a=t.closest(".rui-popover");if(!a)return null;a.setAttribute("data-open",e?"true":"false");const n=a.querySelector(".rui-popover-trigger");return n?.setAttribute("aria-expanded",e?"true":"false"),n?.setAttribute("data-state",e?"open":"closed"),e||Ae(a),a},Vn=(t,e)=>{Xe({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false");const r=t.querySelector(".rui-popover-trigger");r?.setAttribute("aria-expanded","false"),r?.setAttribute("data-state","closed")}})},od={name:"Toast",description:"Single transient notification card. Always shows a close (×) button that removes the toast from the DOM (and fires `onClose` if set). Pass `duration` (ms) to auto-dismiss, or `position` for a standalone one-off toast (the renderer will pin it to the viewport corner so you do not have to wrap a single notification in `Stack(...)`). Use `Toasts` for grouped stacks; prefer `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"],description:'Visual accent (default "default")'},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name (default picked from tone)"},{name:"duration",type:"number",optional:!0,description:"Auto-dismiss after N milliseconds (e.g. 4000). Omit to keep the toast until the user closes it."},{name:"action",type:"Button",optional:!0,description:"Optional inline `Button` action shown above the message"},{name:"onClose",type:"callable",optional:!0,description:"Callable invoked when the toast is dismissed (× button, auto-dismiss, or programmatic)"},{name:"position",type:"string",optional:!0,enum:["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const a=p(e.tone,"default"),n=p(e.position),i=l("div",{class:n?"rui-toast rui-toast-standalone":"rui-toast",role:"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":n||null}),o=p(e.icon)||sd(a),s=E(o,{className:"rui-toast-icon"});s&&i.append(s);const u=l("div",{class:"rui-toast-body"});u.append(l("div",{class:"rui-toast-title"},[p(e.title)]));const c=p(e.message);if(c&&u.append(l("div",{class:"rui-toast-message"},[c])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),u.append(x)}i.append(u);const m=r.useInstanceState("dismissed",!1),d=r.useInstanceState("timer",null),f=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},g=()=>{const x=d.get();x!==null&&(clearTimeout(x),d.set(null))},h=r.useInstanceState("removal-timer",null),b=x=>{if(m.get())return;m.set(!0),g();const w=f(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{h.set(null),w.remove()},180);h.set(k),r.registerDisposer(()=>{const A=h.get();A!==null&&(clearTimeout(A),h.set(null))},"exit-animation-timer"),r.invoke(e.onClose)},v=l("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);v.onclick=x=>{x.stopPropagation(),b(x.currentTarget??x.target)},i.append(v);const y=L(e.duration,0);if(y>0&&d.get()===null&&!m.get()){const x=setTimeout(()=>{d.set(null),!m.get()&&i.isConnected&&b()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return m.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function sd(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":return"circle-xmark";case"primary":return"bell";case"info":return"circle-info";default:return"circle-info"}}const Wn={name:"BreadcrumbItem",description:"Single item inside a Breadcrumb trail. Provide `href` for a link, omit it for the current/leaf page (rendered with emphasis).",props:[{name:"label",type:"string"},{name:"href",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-breadcrumb-item"}),a=p(e.label),n=p(e.href),i=n?Ye(n):"",o=[],s=E(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(l("span",{class:"rui-breadcrumb-label"},[a])),i)r.append(l("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const u=l("span",{class:"rui-breadcrumb-current"});for(const c of o)c&&u.append(typeof c=="string"?document.createTextNode(c):c);r.append(u)}return r}},ld={name:"Breadcrumb",description:"Trail of links showing the user's location. Children may be BreadcrumbItem(label, href?) nodes OR plain strings (the last string is treated as the current page).",props:[{name:"items",type:"BreadcrumbItem[] | string[]"},{name:"separator",type:"string",optional:!0,description:"Default `/`"}],render:(t,e,r)=>{const a=C(e.items),n=p(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,u)=>{if(u>0&&o.append(l("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[n])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const c=p(s),m=u===a.length-1;o.append(Wn.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:c,href:m?"":"#"},r))}),i.append(o),i}},cd=[10,20,50,100],ud={name:"Pagination",description:'Page navigator with Prev/Next, page numbers, and ellipses. Pass a `$variable` as `page` for two-way binding — clicking a page button sets that state to the new (1-indexed) value. Add `total` to render a "Showing N–M of T" summary, pass `$variable` as `perPage` to expose a per-page selector, or set `compact: true` to drop the page-number row for tight toolbars.',props:[{name:"page",type:"number",description:"Current page (1-indexed); typically a $variable"},{name:"totalPages",type:"number",aliases:["pages"]},{name:"siblings",type:"number",optional:!0,description:"Number of page links shown around the current page (default 1)"},{name:"total",type:"number",optional:!0,description:'Total record count — enables the "Showing N–M of T" summary'},{name:"perPage",type:"number",optional:!0,description:"Bind a `$variable` to expose a per-page selector"},{name:"perPageOptions",type:"number[]",optional:!0,description:"Override the per-page choices (default 10/20/50/100)"},{name:"compact",type:"boolean",optional:!0,description:"Hide page numbers — keep Prev / Next only"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(L(e.page,1)))),i=Math.max(0,Math.floor(L(e.siblings,1))),o=T(e.compact),s=t.argMeta?.[0]?.stateRef,u=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),c=b=>{if(!s)return;const v=Math.max(1,Math.min(a,b));v!==n&&r.setState(s,v)},m=e.total!=null?Math.max(0,Math.floor(L(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(L(e.perPage,0))):null;if(m!==null&&d&&d>0){const b=m===0?0:(n-1)*d+1,v=Math.min(m,n*d);u.append(l("span",{class:"rui-pagination-summary"},[m===0?"No results":`Showing ${b.toLocaleString()}–${v.toLocaleString()} of ${m.toLocaleString()}`]))}else m!==null&&u.append(l("span",{class:"rui-pagination-summary"},[`${m.toLocaleString()} result${m===1?"":"s"}`]));const f=l("div",{class:"rui-pagination-buttons"}),g=(b,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[b]);const x=l("button",{type:"button",class:"rui-pagination-button","data-active":y.active?"true":"false","aria-current":y.active?"page":null,"aria-label":y.ariaLabel??null,disabled:y.disabled?"":null},[b]);return!y.disabled&&!y.active&&(x.onclick=()=>c(v)),x};if(f.append(g("‹",n-1,{disabled:n<=1,ariaLabel:"Previous page"})),o)f.append(l("span",{class:"rui-pagination-current"},[`${n} / ${a}`]));else{const b=dd(n,a,i);for(const v of b)v==="…"?f.append(g("…",0,{ellipsis:!0})):f.append(g(String(v),v,{active:v===n}))}f.append(g("›",n+1,{disabled:n>=a,ariaLabel:"Next page"})),u.append(f);const h=t.argMeta?.[4]?.stateRef;if(d&&(h||C(e.perPageOptions).length>0)){const b=C(e.perPageOptions).length>0?C(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(cd),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of b){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}h&&r.bindState(y,h,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),u.append(v)}return u}};function dd(t,e,r){const a=[],n=(u,c)=>{for(let m=u;m<=c;m+=1)a.push(m)},i=r*2+5;if(e<=i)return n(1,e),a;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return a.push(1),o>2&&a.push("…"),n(o,s),s<e-1&&a.push("…"),a.push(e),a}const pd={name:"NavbarItem",description:"Single link inside a Navbar's main item slot. Renders as an inline anchor / button — pass `to` for a router-aware link, `href` for an external link, or `onClick` for a click handler. `active=true` highlights the current page.",props:[{name:"label",type:"string"},{name:"to",type:"string",optional:!0,description:"Internal route (consumes the built-in router)"},{name:"href",type:"string",optional:!0,description:"External href; opens in a new tab when set with `external=true`"},{name:"icon",type:"string",optional:!0},{name:"active",type:"boolean",optional:!0},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired on click (alternative to `to`/`href`)"},{name:"external",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=p(e.label),n=e.icon,i=T(e.active),o=p(e.to),s=Ye(e.href,""),u=T(e.external),c=o||s?"a":"button",m=l(c,{class:"rui-navbar-item",type:c==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:u&&s?"_blank":null,rel:u&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=E(n,{className:"rui-navbar-item-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?m.onclick=f=>{if(f.defaultPrevented)return;const g=f;g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(f.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(m.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),m}},md={name:"Navbar",description:"Top navigation bar with a brand on the left, primary nav items in the middle, and a right-aligned actions slot (user avatar, DropdownMenu, CTA buttons, …). Use `sticky=true` to pin it to the top of the page. The canonical companion of `Sidebar` for product surfaces; prefer Navbar for marketing/docs pages without a sidebar.",props:[{name:"brand",type:"string | Node",optional:!0,description:"Workspace/product name (string) or a node (e.g. logo Image)"},{name:"items",type:"NavbarItem[]",optional:!0,description:"Center navigation items"},{name:"actions",type:"Node[]",optional:!0,description:"Right-side controls (Buttons, Avatar, DropdownMenu, …)"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the bar to the top of the viewport"},{name:"variant",type:"string",optional:!0,enum:["default","transparent"],description:"Visual variant"}],render:(t,e,r)=>{const a=l("nav",{class:"rui-navbar","data-sticky":T(e.sticky)?"true":"false","data-variant":p(e.variant,"default"),"aria-label":"Primary"}),n=e.brand;if(n!=null&&n!==""){const s=l("div",{class:"rui-navbar-brand"});typeof n=="string"?s.append(document.createTextNode(n)):s.append(r.renderNode(n)),a.append(s)}const i=C(e.items);if(i.length>0){const s=l("div",{class:"rui-navbar-items"});for(const u of i)s.append(r.renderNode(u));a.append(s)}const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const u of o)s.append(r.renderNode(u));a.append(s)}return a}},fd=["bottom","top","left","right"],gd=["start","center","end"],hd=["default","danger"],jt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-dropdown-menu");return a?(a.setAttribute("data-open",e?"true":"false"),a.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||Ae(a),a):null},qn=(t,e)=>{Xe({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Pr=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},bd={name:"DropdownMenu",description:"Click-triggered dropdown menu. Click the trigger to toggle, click a MenuItem to run its action and close, click outside or press Escape to close without acting. Children must be MenuItem, MenuSeparator, or MenuLabel entries.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (typically a Button or Avatar)"},{name:"items",type:"(MenuItem | MenuSeparator | MenuLabel)[]"},{name:"side",type:"string",optional:!0,enum:fd,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:gd,description:'How the menu aligns along the trigger edge (default "start")'},{name:"label",type:"string",optional:!0,description:"Optional ARIA label for the menu"},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the menu"}],render:(t,e,r)=>{const a=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(e.align,"start")}),s=l("span",{class:"rui-dropdown-menu-trigger","data-state":i?"open":"closed","aria-haspopup":"menu","aria-expanded":i?"true":"false",tabindex:"0"});s.append(r.renderNode(e.trigger)),s.onclick=c=>{c.stopPropagation();const m=c.currentTarget??c.target,d=!n.get(),f=jt(m,d,n);d&&f&&qn(f,n)},s.onkeydown=c=>{const m=c,d=m.currentTarget??m.target;if(m.key==="Enter"||m.key===" "){m.preventDefault();const f=!n.get(),g=jt(d,f,n);f&&g&&qn(g,n);return}m.key==="Escape"&&n.get()&&(m.preventDefault(),jt(d,!1,n))},o.append(s);const u=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":p(e.label)||null});for(const c of C(e.items)){if(Pr(c,"MenuItem")){const m=c.args??[],d=p(m[0]),f=m[1],g=m[2],h=p(m[3]),b=p(m[4],"default"),v=T(m[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":b,disabled:v?"":null}),x=E(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),h&&y.append(l("span",{class:"rui-menu-item-shortcut"},[h])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;jt(k,!1,n),r.invoke(f)}),u.append(y);continue}if(Pr(c,"MenuSeparator")){u.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Pr(c,"MenuLabel")){const m=p((c.args??[])[0]);u.append(l("div",{class:"rui-menu-label"},[m]));continue}u.append(r.renderNode(c))}return o.append(u),o}},vd={name:"MenuItem",description:"Single item inside a DropdownMenu. Renders a button-style row with an optional leading icon and trailing keyboard-shortcut hint. `onClick` (legacy: `action`) runs when clicked; the menu closes automatically afterwards.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable to execute on click"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown before the label"},{name:"shortcut",type:"string",optional:!0,description:'Trailing keyboard-shortcut hint (e.g. "⌘ K")'},{name:"variant",type:"string",optional:!0,enum:hd,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":p(e.variant,"default"),disabled:a?"":null}),i=E(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[p(e.label)]));const o=p(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},yd={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},xd={name:"MenuLabel",description:'Small uppercase section header inside a DropdownMenu. Use to group related MenuItems (e.g. "Account", "Workspace", "Danger zone").',props:[{name:"label",type:"string"}],render:(t,e)=>l("div",{class:"rui-menu-label"},[p(e.label)])},wd=["left","center","right"];function kd(t){return C(t).map((e,r)=>{const a=e.args??[],n=p(a[0]);return{header:n,values:C(a[1]),format:p(a[2],"text"),align:wd.includes(p(a[3]))?p(a[3]):"",sortable:T(a[4]),filterable:T(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function Gn(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return L(t,0)-L(e,0);if(r==="date"){const a=new Date(p(t)).getTime(),n=new Date(p(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return p(t).localeCompare(p(e))}function Dt(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Sd={name:"DataGrid",description:"Advanced data table with sortable headers, per-column filter chips, row selection (checkboxes), sticky header / first column, optional pagination, an optional bulk-action toolbar slot, and click-to-act rows. Columns are Col(header, values, format?, align?, sortable?, filterable?) entries. Bind `$sort` (`{key, direction}` object), `$selectedIds` (string[]), and `$page` (number) for full reactivity. Use INSTEAD of `Table` when you need any of those interactions.",props:[{name:"columns",type:"Col[]",description:"Columns; pass sortable=true / filterable=true on each Col."},{name:"rowIds",type:"any[]",optional:!0,description:"Stable id per row (used by `selectedIds`); defaults to row index."},{name:"caption",type:"string",optional:!0},{name:"sort",type:"object",optional:!0,description:"`{key, direction}` — pass a $variable for two-way binding"},{name:"selectedIds",type:"any[]",optional:!0,description:"Array of selected row ids — bind a $variable"},{name:"selectable",type:"boolean",optional:!0,description:"Render leading selection checkboxes"},{name:"page",type:"number",optional:!0,description:"1-indexed current page — bind a $variable"},{name:"perPage",type:"number",optional:!0,description:"Page size (default 20)"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no rows match (default `No results`)"},{name:"onRowClick",type:"callable",optional:!0,aliases:["rowAction"],description:"Callable fired when a row is clicked. Receives the row index."},{name:"toolbar",type:"Node[]",optional:!0,description:"Bulk-action toolbar shown above the table when any rows are selected"},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"]},{name:"striped",type:"boolean",optional:!0},{name:"stickyHeader",type:"boolean",optional:!0,description:"Pin the header row (default true)"},{name:"stickyFirstColumn",type:"boolean",optional:!0,description:"Pin the first column horizontally"}],render:(t,e,r)=>{const a=kd(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=C(e.rowIds),o=B=>p(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,u=p(s?.key),c=p(s?.direction,"asc")==="desc"?"desc":"asc",m=C(e.selectedIds).map(B=>p(B)),d=new Set(m),f=T(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:T(e.stickyHeader),h=T(e.stickyFirstColumn),b=p(e.density,"comfortable"),v=T(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let q=!0;for(const Y of a){if(!Y.filterable)continue;const G=(x[Y.key]??"").trim().toLowerCase();if(!G)continue;const re=Y.values[B];if(!Dt(re,Y.format).toLowerCase().includes(G)){q=!1;break}}q&&w.push(B)}if(u){const B=a.find(q=>q.key===u);B&&B.sortable&&w.sort((q,Y)=>{const G=Gn(B.values[q],B.values[Y],B.format);return c==="desc"?-G:G})}const k=w.length,A=Math.max(1,Math.floor(L(e.perPage,20))),S=Math.max(1,Math.ceil(k/A)),$=Math.max(1,Math.floor(L(e.page,1))),M=Math.min($,S),I=w.slice((M-1)*A,M*A),R=l("div",{class:"rui-data-grid","data-density":b,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":h?"true":"false"}),j=t.argMeta?.[3]?.stateRef,K=t.argMeta?.[4]?.stateRef,F=t.argMeta?.[6]?.stateRef,U=C(e.toolbar);if(m.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${m.length} selected`]));const q=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)q.append(r.renderNode(Y));B.append(q),R.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),de=p(e.caption);de&&Z.append(l("caption",{class:"rui-data-grid-caption"},[de]));const Se=l("thead"),ft=l("tr");if(f){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),q=I.length>0&&I.every(G=>d.has(o(G))),Y=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:q?"":null});K&&(Y.onclick=G=>{const re=G.currentTarget,ee=new Set(m);for(const X of I){const Q=o(X);re.checked?ee.add(Q):ee.delete(Q)}r.setState(K,Array.from(ee))}),B.append(Y),ft.append(B)}if(a.forEach((B,q)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===u?"true":null,"data-first":q===0?"true":null});if(B.sortable&&j){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const re=B.key===u?c==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=E(re,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===u&&c==="asc"?"desc":"asc";r.setState(j,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));ft.append(Y)}),Se.append(ft),a.some(B=>B.filterable)){const B=l("tr",{class:"rui-data-grid-filter-row"});f&&B.append(l("td",{class:"rui-data-grid-cell-select"})),a.forEach(q=>{const Y=l("td");if(q.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${q.header}`,value:x[q.key]??""});G.oninput=re=>{const ee=re.currentTarget,X={...y.get(),[q.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");wf(Q)},Y.append(G)}B.append(Y)}),Se.append(B)}Z.append(Se);const He=l("tbody");Z.append(He);const Ur=B=>{if(He.replaceChildren(),B.length===0){const q=l("tr"),Y=(f?1:0)+Math.max(a.length,1);q.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),He.append(q);return}for(const q of B){const Y=o(q),G=d.has(Y),re=l("tr",{"data-selected":G?"true":null});if(f){const ee=l("td",{class:"rui-data-grid-cell-select"}),X=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:G?"":null});K&&(X.onclick=Q=>{Q.stopPropagation();const ve=Q.currentTarget,ye=new Set(m);ve.checked?ye.add(Y):ye.delete(Y),r.setState(K,Array.from(ye))}),ee.append(X),re.append(ee)}a.forEach((ee,X)=>{const Q=l("td",{"data-format":ee.format,"data-align":ee.align||null,"data-first":X===0?"true":null});hr(Q,ee,ee.values[q],q,r,Dt),re.append(Q)}),typeof e.onRowClick=="function"&&(re.setAttribute("data-clickable","true"),re.onclick=ee=>{ee.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,q)}),He.append(re)}},wf=B=>{const q=B??He,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const ve of a){if(!ve.filterable)continue;const ye=(Y[ve.key]??"").trim().toLowerCase();if(!ye)continue;const gt=ve.values[X];if(!Dt(gt,ve.format).toLowerCase().includes(ye)){Q=!1;break}}Q&&G.push(X)}if(u){const X=a.find(Q=>Q.key===u);X&&X.sortable&&G.sort((Q,ve)=>{const ye=Gn(X.values[Q],X.values[ve],X.format);return c==="desc"?-ye:ye})}const re=G.slice((M-1)*A,M*A);(X=>{X.replaceChildren();for(const Q of re){const ve=o(Q),ye=d.has(ve),gt=l("tr",{"data-selected":ye?"true":null});if(f){const Ve=l("td",{class:"rui-data-grid-cell-select"}),Hr=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:ye?"":null});Ve.append(Hr),gt.append(Ve)}a.forEach((Ve,Hr)=>{const Pi=l("td",{"data-format":Ve.format,"data-align":Ve.align||null,"data-first":Hr===0?"true":null});hr(Pi,Ve,Ve.values[Q],Q,r,Dt),gt.append(Pi)}),X.append(gt)}if(re.length===0){const Q=l("tr"),ve=(f?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(ve),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),X.append(Q)}})(q)};if(Ur(I),J.append(Z),R.append(J),k>A){const B=l("div",{class:"rui-data-grid-footer"}),q=k===0?0:(M-1)*A+1,Y=Math.min(k,M*A);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${q}–${Y} of ${k}`]));const G=l("div",{class:"rui-data-grid-footer-buttons"}),re=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M<=1?"":null},["‹ Prev"]),ee=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M>=S?"":null},["Next ›"]);F&&(re.onclick=()=>{M<=1||r.setState(F,M-1)},ee.onclick=()=>{M>=S||r.setState(F,M+1)}),G.append(re),G.append(l("span",{class:"rui-data-grid-page-current"},[`${M} / ${S}`])),G.append(ee),B.append(G),R.append(B)}return R}};function Cd(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r,n=p(a.date);n&&e.push({date:n,title:p(a.title),tone:p(a.tone,"primary"),time:p(a.time)})}return e}function Kn(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-n),r}function Yn(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${a}`}const $d={name:"CalendarView",description:"Full-month or week calendar grid for scheduling apps — distinct from the form-input `DatePicker`. Pass events as an array of `{date: 'YYYY-MM-DD', title, tone?, time?}` objects. Bind `value` to a `$variable` for the selected date (ISO string). Use `view=\"week\"` for a single-week strip. `firstDay=1` (Monday) matches most business apps.",props:[{name:"value",type:"string",optional:!0,description:"Selected ISO date (YYYY-MM-DD); bind a $variable"},{name:"month",type:"string",optional:!0,description:"Reference month — ISO date or YYYY-MM (defaults to today)"},{name:"events",type:"object[]",optional:!0,description:"Array of {date, title, tone?, time?} objects"},{name:"view",type:"string",optional:!0,enum:["month","week"]},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday, 1=Monday (default 1)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a day is clicked; receives the ISO date string"}],render:(t,e,r)=>{const a=p(e.view,"month"),n=Cd(e.events),i=p(e.value),o=p(e.month,i),s=new Date;let u=new Date(NaN);if(o){const A=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(A)u=new Date(Number(A[1]),Number(A[2])-1,A[3]?Number(A[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(u=S)}}Number.isNaN(u.getTime())&&(u=s);const c=(L(e.firstDay,1)%7+7)%7,m=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const A of n){const S=A.date.slice(0,10),$=d.get(S)??[];$.push(A),d.set(S,$)}const f=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),h=l("div",{class:"rui-calendar-header"}),b=u.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(l("div",{class:"rui-calendar-title"},[b])),g.append(h);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let A=0;A<7;A+=1){const S=y[(c+A)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const A=m?new Date(m):u,S=Kn(A,c);for(let $=0;$<7;$+=1){const M=new Date(S);M.setDate(S.getDate()+$),x.push({date:M,inMonth:M.getMonth()===u.getMonth()})}}else{const A=new Date(u.getFullYear(),u.getMonth(),1),S=new Date(u.getFullYear(),u.getMonth()+1,0),$=Kn(A,c),M=Math.ceil((S.getDate()+(A.getDay()-c+7)%7)/7)*7;for(let I=0;I<M;I+=1){const R=new Date($);R.setDate($.getDate()+I),x.push({date:R,inMonth:R.getMonth()===u.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=Yn(s);for(const A of x){const S=Yn(A.date),$=S===k,M=S===m,I=d.get(S)??[],R=l("button",{type:"button",class:"rui-calendar-day","data-in-month":A.inMonth?"true":"false","data-today":$?"true":"false","data-selected":M?"true":"false","aria-label":A.date.toDateString()});if(R.append(l("span",{class:"rui-calendar-daynumber"},[String(A.date.getDate())])),I.length>0){const j=l("div",{class:"rui-calendar-day-events"}),K=I.slice(0,3);for(const F of K){const U=l("span",{class:"rui-calendar-event","data-tone":F.tone??"primary",title:F.time?`${F.time} — ${F.title}`:F.title},[F.title]);j.append(U)}I.length>3&&j.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),R.append(j)}R.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(R)}return g.append(w),g}};function Td(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:p(a.title),description:p(a.description),actor:p(a.actor),avatarSrc:p(a.avatarSrc),time:p(a.time),icon:p(a.icon),tone:p(a.tone,"default"),meta:p(a.meta)})}return e}function Ad(t,e,r){const a=l("ol",{class:t,"data-variant":r});for(const n of e){const i=l("li",{class:`${t}-item`,"data-tone":n.tone}),o=l("span",{class:`${t}-marker`}),s=E(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const u=l("div",{class:`${t}-body`}),c=l("div",{class:`${t}-head`});n.actor&&c.append(l("span",{class:`${t}-actor`},[n.actor])),c.append(l("span",{class:`${t}-title`},[n.title])),n.time&&c.append(l("span",{class:`${t}-time`},[n.time])),u.append(c),n.description&&u.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&u.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(u),a.append(i)}return a}const Nd={name:"ActivityLog",description:'Purpose-built feed of user/system activity. Each entry has `actor`, `title`, `description?`, `time?`, `icon?`, `tone?`, and optional `meta` (IP, browser, request id). Use `variant="audit"` for monospace security/admin trails. Pass items as `{actor, title, description, time, icon, tone, avatarSrc, meta}` objects.',props:[{name:"items",type:"object[]"},{name:"variant",type:"string",optional:!0,enum:["default","audit"],description:"audit = monospace voice with meta column"}],render:(t,e)=>{const r=p(e.variant,"default");return Ad(r==="audit"?"rui-audit-trail":"rui-activity-log",Td(e.items),r)}},Md={name:"ComparisonTable",description:"Feature/spec comparison table — generic counterpart of `PricingTable`. Pass `columns` (e.g. plan/product names) and `rows` of `{label, values}` where `values` aligns 1-to-1 with `columns`. Each value can be a boolean (✓/—), a string, or a node.",props:[{name:"columns",type:"string[]",description:"Column headers"},{name:"rows",type:"object[]",description:"Array of {label, values, hint?, group?} entries"},{name:"highlightColumn",type:"number",optional:!0,description:"0-indexed column to visually emphasise"}],render:(t,e,r)=>{const a=C(e.columns).map(f=>p(f)),n=C(e.rows).map(f=>{const g=f??{};return{label:p(g.label),values:C(g.values),hint:p(g.hint),group:p(g.group)}}),i=Math.floor(L(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),u=l("thead"),c=l("tr");c.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((f,g)=>{c.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[f]))}),u.append(c),s.append(u);const m=l("tbody");let d="";for(const f of n){if(f.group&&f.group!==d){d=f.group;const b=l("tr",{class:"rui-comparison-table-group"});b.append(l("td",{colspan:String(a.length+1)},[f.group])),m.append(b)}const g=l("tr"),h=l("td",{class:"rui-comparison-table-feature"});h.append(l("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&h.append(l("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),g.append(h);for(let b=0;b<a.length;b+=1){const v=f.values[b],y=l("td",{"data-highlight":b===i?"true":null});if(v===!0){const x=E("circle-check",{className:"rui-comparison-yes"});x?y.append(x):y.textContent="✓"}else v===!1||v===null||v===void 0?y.append(l("span",{class:"rui-comparison-no"},["—"])):v&&typeof v=="object"&&v.__kind==="Component"?y.append(r.renderNode(v)):y.textContent=p(v);g.append(y)}m.append(g)}return s.append(m),o.append(s),o}},Pd={name:"InfiniteList",description:"Vertical list that fires `onLoadMore` when the user scrolls near the bottom. Pass already-rendered child nodes as `items`; wire `onLoadMore` to an `action` that awaits a `$mutation` or `$query` (e.g. `await loadMore.invoke()`) and appends to the bound state. Use `loading=true` to show the spinner row, `hasMore=false` to suppress further loads.",props:[{name:"items",type:"Node[]",description:"Already-rendered child nodes"},{name:"onLoadMore",type:"callable",optional:!0,description:"Callable fired when the sentinel scrolls into view"},{name:"loading",type:"boolean",optional:!0},{name:"hasMore",type:"boolean",optional:!0,description:"Default true — set false to hide the sentinel"},{name:"loaderLabel",type:"string",optional:!0,description:"Label rendered while loading (default `Loading…`)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-infinite-list"}),n=l("div",{class:"rui-infinite-list-body"});for(const s of C(e.items))n.append(r.renderNode(s));a.append(n);const i=e.hasMore===void 0?!0:T(e.hasMore),o=T(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const u=E("spinner",{className:"rui-infinite-list-spin"});u&&s.append(u),s.append(l("span",{},[p(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const u=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);u.onclick=()=>r.invoke(e.onLoadMore),s.append(u)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const u=e.onLoadMore,c=new IntersectionObserver(m=>{for(const d of m)if(d.isIntersecting){r.invoke(u);break}});c.observe(s),r.registerDisposer(()=>c.disconnect(),"infinite-observer")}}return a}},Id=/^(https?:|blob:|data:(audio|video)\/)/i;function Bt(t){const e=p(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":Id.test(e)?e:"":""}const Ld={name:"VideoPlayer",description:"Themed native `<video>` wrapper. Pass a `src` URL (or `sources` array for multi-codec fallback) and optional `poster`. Standard controls are visible by default; pass `autoplay`, `loop`, `muted`, or `controls=false` to override. Use for product demos, tutorials, and any inline video.",props:[{name:"src",type:"string",optional:!0,description:"Video URL (mp4 / webm / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"poster",type:"string",optional:!0,description:"Thumbnail image URL shown before playback"},{name:"caption",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"muted",type:"boolean",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio (default 16:9)"}],render:(t,e)=>{const r=l("figure",{class:"rui-video-player"}),a=Ir(p(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:T(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,muted:T(e.muted)?"":null,poster:ne(e.poster)||null,playsinline:"",preload:"metadata"}),s=C(e.sources);if(s.length>0)for(const c of s){if(!c||typeof c!="object")continue;const m=c,d=Bt(m.src);d&&o.append(l("source",{src:d,type:p(m.type)||null}))}else{const c=Bt(e.src);c&&o.setAttribute("src",c)}n.append(o),r.append(n);const u=p(e.caption);return u&&r.append(l("figcaption",{class:"rui-video-player-caption"},[u])),r}},zd={name:"AudioPlayer",description:"Themed native `<audio>` wrapper with a title, optional artist, and standard transport controls. Pass `src` (or `sources`) plus a `title` so the bar still looks like a player when the controls bar is hidden. Use for podcasts, voice notes, and demo audio.",props:[{name:"src",type:"string",optional:!0,description:"Audio URL (mp3 / ogg / wav / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"title",type:"string",optional:!0},{name:"artist",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"icon",type:"string",optional:!0,description:"Leading icon (default `music`)"}],render:(t,e)=>{const r=l("div",{class:"rui-audio-player"}),a=l("div",{class:"rui-audio-player-meta"}),n=E(p(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=p(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=p(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const u=e.controls===void 0?!0:T(e.controls),c=l("audio",{class:"rui-audio-player-audio",controls:u?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,preload:"metadata"}),m=C(e.sources);if(m.length>0)for(const d of m){if(!d||typeof d!="object")continue;const f=d,g=Bt(f.src);g&&c.append(l("source",{src:g,type:p(f.type)||null}))}else{const d=Bt(e.src);d&&c.setAttribute("src",d)}return r.append(c),r}};function Rd(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ne(t);return r?l("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=ne(r.src);if(a){const n=l("figure",{class:"rui-carousel-figure"});n.append(l("img",{src:a,alt:p(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=p(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const Ed={name:"Carousel",description:"Horizontal slider with prev/next buttons and dot navigation. Each child slide takes full width. Slides may be Component nodes (Image, Card, MediaCard, …), URL strings, or plain `{src, alt, caption?}` image objects — bare image objects are auto-wrapped into a captioned figure. Use for image galleries, onboarding carousels, hero banners, and product image strips. The active slide is preserved across re-renders via instance state.",props:[{name:"items",type:"Node[]",description:"Slide nodes, image URLs, or {src, alt, caption?} objects"},{name:"activeIndex",type:"number",optional:!0,description:"0-indexed initial slide (default 0)"},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio of the frame (default `16:9`)"},{name:"showDots",type:"boolean",optional:!0,description:"Show indicator dots (default true)"},{name:"showArrows",type:"boolean",optional:!0,description:"Show prev/next arrows (default true)"}],render:(t,e,r)=>{const a=C(e.items),n=a.length,i=Math.max(0,Math.min(Math.max(n-1,0),Math.floor(L(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const u=e.showDots===void 0?!0:T(e.showDots),c=e.showArrows===void 0?!0:T(e.showArrows),m=Ir(p(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),f=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${m};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(b=>{const v=l("div",{class:"rui-carousel-slide"}),y=Rd(b,r);y&&v.append(y),g.append(v)}),f.append(g);const h=(b,v)=>{const y=(v%n+n)%n;o.set(y);const x=b.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,A)=>{k.setAttribute("data-active",A===y?"true":"false")})};if(c&&n>1){const b=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=E("chevron-left");v&&b.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=E("chevron-right");x&&y.append(x),b.onclick=w=>h(w.currentTarget,o.get()-1),y.onclick=w=>h(w.currentTarget,o.get()+1),f.append(b,y)}if(d.append(f),u&&n>1){const b=l("div",{class:"rui-carousel-dots"});a.forEach((v,y)=>{const x=l("button",{type:"button",class:"rui-carousel-dot","data-active":y===s?"true":"false","aria-label":`Go to slide ${y+1}`});x.onclick=w=>h(w.currentTarget,y),b.append(x)}),d.append(b)}return d}},jd={name:"Gallery",description:"Responsive image grid. Pass items as plain URL strings, `{src, alt, caption?}` objects, or `Image(...)` nodes. When `onSelect` is provided each tile becomes a button; bind it through an Action that opens a `Lightbox`.",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"},{name:"ratio",type:"string",optional:!0,description:"Per-tile aspect ratio (default `1:1`)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a tile is clicked"}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Ir(p(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,u)=>{const{src:c,alt:m,caption:d}=Xn(s),f=ne(c),g=typeof e.onSelect=="function",h=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(u)});if(f)h.append(l("img",{src:f,alt:m,loading:"lazy"}));else{const b=E("image",{className:"rui-gallery-placeholder"});b&&h.append(b)}d&&h.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(h.onclick=()=>r.invoke(e.onSelect,u,s)),o.append(h)}),o}};function Xn(t){if(typeof t=="string")return{src:t,alt:"",caption:""};if(t&&typeof t=="object"){const e=t;return e.__kind==="Component"&&Array.isArray(e.args)?{src:p(e.args[0]),alt:p(e.args[1]),caption:p(e.args[2])}:{src:p(e.src),alt:p(e.alt),caption:p(e.caption)}}return{src:"",alt:"",caption:""}}const Dd={name:"Lightbox",description:"Image overlay. When you bind a `$variable` to `open` you control it explicitly; without one, Lightbox renders a clickable thumbnail of the current image that opens the overlay on click (and uses internal state for next/prev). Pass `items` (string URLs or `{src, alt, caption?}` objects). Clicking the backdrop or × closes; arrows step through the array.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Open/closed; bind a $variable to control externally"},{name:"index",type:"number",optional:!0,description:"0-indexed current image; typically a $variable"}],render:(t,e,r)=>{const a=C(e.items).map($=>Xn($)).filter($=>ne($.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),u=r.useInstanceState("index",0),c=o?T(e.open):s.get(),m=i?Math.floor(L(e.index,0)):u.get(),d=n===0?0:(m%n+n)%n,f=$=>{o?r.setState(o,$):s.set($)},g=$=>{i?r.setState(i,$):u.set($)},h=()=>f(!1),b=$=>{n!==0&&g(((d+$)%n+n)%n)},v=l("div",{class:"rui-lightbox-root"});if(!o&&n>0){const $=a[d],M=l("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const I=ne($.src);I&&M.append(l("img",{src:I,alt:$.alt,loading:"lazy"}))}M.onclick=I=>{I.stopPropagation(),f(!0)},v.append(M)}const y=l("div",{class:"rui-lightbox-overlay","data-open":c?"true":"false"});if(v.append(y),!c||n===0)return v;const x=a[d];if(!x)return v;const w=ne(x.src);y.onclick=$=>{$.target===y&&h()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),A=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(A.onclick=h,k.append(A),n>1){const $=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),M=E("chevron-left");M&&$.append(M),$.onclick=()=>b(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),R=E("chevron-right");R&&I.append(R),I.onclick=()=>b(1),k.append($,I)}const S=l("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(l("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(l("div",{class:"rui-lightbox-caption"},[x.caption])),n>1&&k.append(l("div",{class:"rui-lightbox-counter"},[`${d+1} / ${n}`])),y.append(k),v}};function Bd(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=L(e.lat??e.latitude,NaN),a=L(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(a))return{lat:r,lng:a}}if(Array.isArray(t)&&t.length>=2){const e=L(t[0],NaN),r=L(t[1],NaN);if(Number.isFinite(e)&&Number.isFinite(r))return{lat:e,lng:r}}if(typeof t=="string"){const e=t.split(",").map(r=>Number(r.trim()));if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]))return{lat:e[0],lng:e[1]}}return null}const Fd={name:"Map",description:"Static map view centered on a lat/lng coordinate. Renders an OpenStreetMap embed inside an `<iframe>` (no external JS, no API key). Pass `lat` and `lng` as bare numbers; `zoom` controls the level (1–18, default 13). Optional `markers` array adds map pins (rendered as a labelled list alongside the map). Use for store locators, address cards, itinerary previews.",props:[{name:"lat",type:"number",description:"Latitude of the map center"},{name:"lng",type:"number",description:"Longitude of the map center"},{name:"zoom",type:"number",optional:!0,description:"1–18 (default 13)"},{name:"markers",type:"object[]",optional:!0,description:"Array of {lat, lng, label?} markers (informational; rendered alongside the map)"},{name:"height",type:"string",optional:!0,description:"CSS height (default 320px)"},{name:"caption",type:"string",optional:!0}],render:(t,e)=>{const r=l("figure",{class:"rui-map"}),a=te(e.height,"320px"),n=l("div",{class:"rui-map-frame",style:`height:${a};`}),i=L(e.lat,NaN),o=L(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){n.append(l("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(n);const b=p(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}const u=Math.max(1,Math.min(18,Math.floor(L(e.zoom,13)))),c=1/Math.pow(2,u-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-c,s.lat-c/2,s.lng+c,s.lat+c/2].join(",")}&layer=mapnik&marker=${s.lat},${s.lng}`,f=l("iframe",{class:"rui-map-iframe",src:d,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});n.append(f),r.append(n);const g=C(e.markers).map(b=>{const v=Bd(b),y=b&&typeof b=="object"?p(b.label):"";return v?{...v,label:y}:null}).filter(b=>b!==null);if(g.length>0){const b=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=E("location-dot",{className:"rui-map-marker-icon"});x&&y.append(x),y.append(l("span",{class:"rui-map-marker-label"},[v.label||`${v.lat.toFixed(4)}, ${v.lng.toFixed(4)}`])),b.append(y)}r.append(b)}const h=p(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),r}};function Ir(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Od=[{command:"bold",icon:"bold",label:"Bold"},{command:"italic",icon:"italic",label:"Italic"},{command:"underline",icon:"underline",label:"Underline"},{command:"strikeThrough",icon:"strikethrough",label:"Strikethrough"},{command:"formatBlock",icon:"heading",label:"Heading",block:"h2"},{command:"formatBlock",icon:"quote-left",label:"Quote",block:"blockquote"},{command:"insertUnorderedList",icon:"list-ul",label:"Bullet list"},{command:"insertOrderedList",icon:"list-ol",label:"Numbered list"},{command:"createLink",icon:"link",label:"Link"}],_d={name:"RichTextEditor",description:"Rich-text WYSIWYG editor for CMS, email, and comment surfaces. Renders a small toolbar (bold / italic / underline / strikethrough / headings / lists / quote / link) above a `contenteditable` region. Pass `$variable` as `value` for two-way binding — the HTML body is written back to state on every edit. Provide `placeholder` for the empty-state prompt.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound HTML body (typically $variable)"},{name:"placeholder",type:"string",optional:!0,description:"Empty-state prompt"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 160px)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current HTML on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.placeholder,"Start writing…"),i=T(e.disabled),o=l("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=l("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const g of Od){const h=l("button",{type:"button",class:"rui-rich-text-tool","data-command":g.command,"data-block":g.block??null,"aria-label":g.label,title:g.label,disabled:i?"":null}),b=E(g.icon);b&&h.append(b),h.onmousedown=v=>v.preventDefault(),h.onclick=v=>{const x=v.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(g.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else g.command==="formatBlock"&&g.block?document.execCommand("formatBlock",!1,g.block):document.execCommand(g.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(h)}o.append(s);const u=p(e.value)||"",c=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,m=l("div",{class:"rui-rich-text-content",id:a,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":n,"data-placeholder":n,"data-empty":c(u)?"true":"false",style:`min-height:${p(e.minHeight,"160px")};`,html:u}),d=g=>{g.setAttribute("data-empty",c(g.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(m,f,{event:"input",getValue:g=>{const h=g;return d(h),h.innerHTML}}):m.oninput=g=>{const h=g.currentTarget??g.target;d(h)},m.onblur=g=>{const h=g.currentTarget??g.target;d(h)},ie(m,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(m),o}},Ud={name:"CodeEditor",description:"Lightweight, dependency-free code editor. Pairs a styled textarea with a synchronised line-number gutter — no syntax highlighting, but the editor stays a single rendered node so it works inside Shadow DOM. Use for dev tooling, snippet editing, prompt playgrounds. Pass a `$variable` as `value` for two-way binding. For read-only rendering with highlights prefer `CodeBlock`.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound source text (typically $variable)"},{name:"language",type:"string",optional:!0,enum:["text","javascript","typescript","json","html","css","bash","python","sql","markdown"],description:"Language label shown on the header (default `text`)"},{name:"placeholder",type:"string",optional:!0},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 200px)"},{name:"tabSize",type:"number",optional:!0,description:"Spaces per Tab (default 2)"},{name:"showGutter",type:"boolean",optional:!0,description:"Show line-number gutter (default true)"},{name:"readonly",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current source on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.value),i=p(e.language,"text"),o=e.showGutter===void 0?!0:T(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(L(e.tabSize,2)))),u=T(e.readonly),c=p(e.minHeight,"200px"),m=l("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),d=l("div",{class:"rui-code-editor-head"});d.append(l("span",{class:"rui-code-editor-language"},[i])),m.append(d);const f=l("div",{class:"rui-code-editor-body",style:`min-height:${c};`}),g=l("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((y=>{g.replaceChildren();const x=y.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)g.append(l("span",{class:"rui-code-editor-line"},[String(k)]))})(n),f.append(g));const b=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:p(e.placeholder),readonly:u?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});b.value=n,b.oninput=y=>{const x=y.currentTarget;if(!o)return;const k=x.closest(".rui-code-editor")?.querySelector(".rui-code-editor-gutter");if(!k)return;k.replaceChildren();const A=x.value.split(/\r?\n/),S=Math.max(1,A.length);for(let $=1;$<=S;$+=1)k.append(l("span",{class:"rui-code-editor-line"},[String($)]))},b.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,A=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(A),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!u&&r.bindState(b,v,{event:"input",getValue:y=>y.value}),u||ie(b,e.onChange,r,{event:"input",getValue:y=>y.value}),f.append(b),m.append(f),m}};function Hd(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const a=e.args;return{label:p(a[0]),action:a[1],icon:p(a[2]),shortcut:p(a[3]),variant:p(a[4],"default"),disabled:T(a[5]),separator:!1}}if(e.__kind==="Component"&&e.name==="MenuSeparator")return{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0};const r=t;return r.separator?{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0}:{label:p(r.label),action:r.action,icon:p(r.icon),shortcut:p(r.shortcut),variant:p(r.variant,"default"),disabled:T(r.disabled),separator:!1}}return null}const Vd={name:"ContextMenu",description:"Right-click (or long-press) menu that attaches to a child node. Wraps `target` and shows the menu at the pointer when the user right-clicks anywhere inside it. Items are `MenuItem(...)` nodes, `MenuSeparator()` entries, or `{label, action, icon?, shortcut?, variant?, disabled?, separator?}` objects. Use on table rows, tree nodes, kanban cards, file browser entries.",props:[{name:"target",type:"Node",description:"Child node the menu is bound to"},{name:"items",type:"any[]",description:"MenuItem nodes or {label, action} objects"},{name:"label",type:"string",optional:!0,description:"ARIA label for the menu"}],render:(t,e,r)=>{const a=l("div",{class:"rui-context-menu"}),n=l("div",{class:"rui-context-menu-target"});n.append(r.renderNode(e.target)),a.append(n);const i=l("div",{class:"rui-context-menu-pop",role:"menu","aria-label":p(e.label)||null,"data-open":"false"}),o=C(e.items).map(Hd).filter(c=>c!==null);for(const c of o){if(c.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const m=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":c.variant,disabled:c.disabled?"":null}),d=E(c.icon,{className:"rui-menu-item-icon"});d&&m.append(d),m.append(l("span",{class:"rui-menu-item-label"},[c.label])),c.shortcut&&m.append(l("span",{class:"rui-menu-item-shortcut"},[c.shortcut])),c.disabled||(m.onclick=()=>{r.invoke(c.action),i.setAttribute("data-open","false")}),i.append(m)}a.append(i);const s=()=>i.setAttribute("data-open","false"),u=(c,m)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,f=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),h=g?c-g.left:c,b=g?m-g.top:m;f.style.left=`${h}px`,f.style.top=`${b}px`,f.setAttribute("data-open","true");const v=y=>{y.target&&f.contains(y.target)||(f.setAttribute("data-open","false"),document.removeEventListener("click",v,!0),document.removeEventListener("contextmenu",v,!0))};setTimeout(()=>{document.addEventListener("click",v,!0),document.addEventListener("contextmenu",v,!0)},0)};return n.oncontextmenu=c=>{c.preventDefault(),u(c.clientX,c.clientY)},n.onkeydown=c=>{const m=c;if(m.key==="ContextMenu"||m.shiftKey&&m.key==="F10"){m.preventDefault();const f=m.currentTarget.getBoundingClientRect();u(f.left,f.top+f.height)}m.key==="Escape"&&s()},a}},Wd=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function ut(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(a=>a+a).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const qd={name:"ColorPicker",description:'Hex / RGB color form control with preset swatches. Pairs a native `<input type="color">` chip with a hex text input and a row of preset swatches. Pass a `$variable` as `value` (hex string, e.g. `"#6366f1"`) for two-way binding. Use for theme builders, label color pickers, and any "pick a color" surface.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound hex value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"swatches",type:"string[]",optional:!0,description:"Preset hex colors (default to a 12-color palette)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected hex string"}],render:(t,e,r)=>{const a=p(e.id),n=ut(p(e.value))||p(e.value,"#000000"),i=T(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=p(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const u=l("div",{class:"rui-color-picker-row"}),c=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:ut(n)||"#000000",disabled:i?"":null}),m=l("input",{type:"text",class:"rui-color-picker-hex",value:n,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),d=l("div",{class:"rui-color-picker-swatches"}),f=C(e.swatches).map(b=>p(b)).filter(Boolean),g=f.length>0?f:Wd;for(const b of g){const v=ut(b)||b,y=l("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${v}`,"aria-label":v,title:v,"data-active":v.toLowerCase()===n.toLowerCase()?"true":"false"});y.onclick=()=>{c.value=ut(v)||c.value,m.value=v,c.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const h=t.argMeta?.[1]?.stateRef;return h&&!i&&(r.bindState(c,h,{event:"input",getValue:b=>b.value}),c.addEventListener("input",()=>{m.value=c.value}),m.oninput=()=>{const b=ut(m.value);b&&(c.value=b,c.dispatchEvent(new Event("input",{bubbles:!0})))}),i||ie(c,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(c,m),o.append(u,d),o}},Lr=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],_e=t=>Lr[t%Lr.length]??Lr[0];function Gd(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}})}function Ft(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ce(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function Jn(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${_e(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const Kd={name:"Gauge",description:"Half-doughnut gauge indicator for a single value between `min` and `max`. The inner value is auto-formatted from the value (override via `label`). Pass `caption`, `tone`, and `size` for visual treatment. Use for KPI thresholds (uptime %, score, capacity, NPS, page-speed).",props:[{name:"value",type:"number"},{name:"min",type:"number",optional:!0,description:"Lower bound (default 0)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"caption",type:"string",optional:!0,description:"Small caption below the gauge"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"label",type:"string",optional:!0,description:"Inner label override (defaults to auto-formatted value)"}],render:(t,e)=>{const r=L(e.min,0),a=Math.max(r+1,L(e.max,100)),n=Math.max(r,Math.min(a,L(e.value,r))),i=(n-r)/(a-r),o=p(e.tone,"primary"),s=p(e.size,"md"),u=s==="lg"?220:s==="sm"?140:180,c=u/2,m=s==="lg"?18:s==="sm"?10:14,d=c-m,f=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=Ft(u,c+m+4),h=c,b=c,v=h-d,y=b,x=h+d,w=b;if(g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(m),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,M=h-d*Math.cos($),I=b-d*Math.sin($);g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${M.toFixed(2)},${I.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${_e(0)})`,"stroke-width":String(m),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(g);const k=Yd(n,r,a),A=p(e.label)||k;f.append(l("div",{class:"rui-gauge-value"},[A]));const S=p(e.caption);return S&&f.append(l("div",{class:"rui-gauge-caption"},[S])),f}};function Yd(t,e,r){return e===0&&r===100?t%1===0?`${t}%`:`${t.toFixed(1)}%`:Math.abs(t)>=1e3?Math.round(t).toLocaleString():t%1===0?String(t):t.toFixed(t<10?2:1)}const Xd={name:"Heatmap",description:"Color-intensity matrix grid (calendar-style or correlation-style). Pass `xLabels`, `yLabels`, and a `values` array of arrays (rows × columns). Each cell's color intensity scales with the value relative to the global max. Use for activity heatmaps, schedule density, correlation matrices.",props:[{name:"xLabels",type:"string[]"},{name:"yLabels",type:"string[]"},{name:"values",type:"number[][]",description:"Matrix indexed by row (y), then column (x)"},{name:"title",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=C(e.xLabels).map(m=>p(m)),a=C(e.yLabels).map(m=>p(m)),n=C(e.values).map(m=>C(m).map(d=>L(d,0))),i=p(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=l("div",{class:"rui-heatmap-table"}),c=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const m of r)c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[m]));return u.append(c),n.forEach((m,d)=>{const f=l("div",{class:"rui-heatmap-row"});f.append(l("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[d]??String(d+1)])),m.forEach((g,h)=>{const b=o>0?g/o:0,v=l("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${_e(0)}) ${Math.round(b*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),f.append(v)}),u.append(f)}),s.append(u),s}},Jd={name:"RadarChart",description:"Polygon chart with one axis per category. Use for skill maps, scorecards, capability comparisons, and any multi-dimensional snapshot. Each Series renders as a filled polygon — overlapping is expected for comparisons.",props:[{name:"axes",type:"string[]",description:"Category labels — one per radial axis"},{name:"series",type:"Series[]"},{name:"max",type:"number",optional:!0,description:"Outer ring value (default = max across series)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=C(e.axes).map(g=>p(g)),a=Gd(C(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});p(e.title)&&i.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const o=Math.max(1,L(e.max,a.flatMap(g=>g.values).reduce((g,h)=>Math.max(g,h),1))),s=280,u=s/2,c=s/2,m=s/2-24,d=Ft(s,s),f=4;for(let g=1;g<=f;g+=1){const h=m/f*g,b=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;b.push(`${(u+h*Math.cos(y)).toFixed(1)},${(c+h*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:b.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let g=0;g<n;g+=1){const h=Math.PI*2*g/n-Math.PI/2,b=u+m*Math.cos(h),v=c+m*Math.sin(h);d.append(ce("line",{x1:String(u),y1:String(c),x2:b.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=u+(m+16)*Math.cos(h),x=c+(m+16)*Math.sin(h);d.append(ce("text",{x:y.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[g]??""]))}return a.forEach((g,h)=>{const b=[];for(let v=0;v<n;v+=1){const y=g.values[v]??0,x=Math.max(0,Math.min(1,y/o)),w=Math.PI*2*v/n-Math.PI/2,k=u+m*x*Math.cos(w),A=c+m*x*Math.sin(w);b.push(`${k.toFixed(1)},${A.toFixed(1)}`)}d.append(ce("polygon",{points:b.join(" "),fill:_e(h),"fill-opacity":"0.2",stroke:_e(h),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(Jn(a)),i}};function Zd(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:L(o[0],0),y:L(o[1],0),label:p(o[2])};if(o&&typeof o=="object"){const s=o;return{x:L(s.x,0),y:L(s.y,0),label:p(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const Qd={name:"ScatterChart",description:'XY scatter plot — one dot per data point, optionally grouped by series. Pass each `Series(name, points)` with points as `{x, y, label?}` objects or `[x, y, label?]` tuples. Use for correlations, distributions, and "price vs. rating" style charts.',props:[{name:"series",type:"Series[]"},{name:"xLabel",type:"string",optional:!0},{name:"yLabel",type:"string",optional:!0},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=Zd(C(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,u=i-o.top-o.bottom,c=r.flatMap(k=>k.points);if(c.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const m=c.map(k=>k.x),d=c.map(k=>k.y),f=Math.min(...m),g=Math.max(...m),h=Math.min(...d),b=Math.max(...d),v=g-f||1,y=b-h||1,x=Ft(n,i);if(Qn(x,o,s,u,b,h),x.append(ce("line",{x1:String(o.left),y1:String(o.top+u),x2:String(o.left+s),y2:String(o.top+u),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,A)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/v*s,M=o.top+u-(S.y-h)/y*u,I=ce("circle",{cx:$.toFixed(1),cy:M.toFixed(1),r:"7",fill:_e(A),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),p(e.xLabel)&&x.append(ce("text",{x:String(o.left+s/2),y:String(i-6),"text-anchor":"middle",class:"rui-chart-label","font-size":"14","font-weight":"500"},[p(e.xLabel)])),p(e.yLabel)){const A=o.top+u/2;x.append(ce("text",{x:String(14),y:String(A),"text-anchor":"middle",transform:`rotate(-90, 14, ${A})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[p(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(A=>A.y)}));return w.length>0&&a.append(Jn(w)),a}},ep={name:"Histogram",description:"Frequency distribution from raw numeric values. Pass `values` directly (the component bins them automatically) or pre-computed `bins` of `{label, count}` objects. Use for response-time histograms, score distributions, age buckets.",props:[{name:"values",type:"number[]",optional:!0,description:"Raw observations (binned automatically)"},{name:"bins",type:"object[]",optional:!0,description:"Pre-computed {label, count} entries (overrides `values`)"},{name:"binCount",type:"number",optional:!0,description:"Number of bins when computing from `values` (default 10)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{let r=[];if(Array.isArray(e.bins)&&e.bins.length>0)r=e.bins.map(f=>{const g=f??{};return{label:p(g.label),count:L(g.count,0)}});else{const f=C(e.values).map(g=>L(g,NaN)).filter(g=>Number.isFinite(g));if(f.length>0){const g=Math.max(2,Math.min(50,Math.floor(L(e.binCount,10)))),h=Math.min(...f),y=(Math.max(...f)-h||1)/g,x=new Array(g).fill(0);for(const w of f){let k=Math.floor((w-h)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const A=h+k*y,S=A+y;return{label:`${Zn(A)}–${Zn(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(e.title)])),r.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No data"])),a;const n=640,i=240,o={left:40,right:12,top:16,bottom:50},s=n-o.left-o.right,u=i-o.top-o.bottom,c=Math.max(1,...r.map(f=>f.count)),m=s/r.length,d=Ft(n,i);return Qn(d,o,s,u,c),r.forEach((f,g)=>{const h=o.left+g*m+m*.1,b=m*.8,v=f.count/c*u,y=o.top+u-v,x=ce("rect",{x:h.toFixed(1),y:y.toFixed(1),width:b.toFixed(1),height:v.toFixed(1),fill:_e(0),rx:"2"});x.append(ce("title",{},[`${f.label}: ${f.count}`])),d.append(x),d.append(ce("text",{x:(h+b/2).toFixed(1),y:String(o.top+u+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),a.append(d),a}};function Zn(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function Qn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(c+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}const tp=["numeric","alphanumeric"];function rp(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),u=[];for(let d=0;d<e;d+=1){const f=l("input",{class:"rui-pin-input-slot",id:d===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${d+1}`,value:a.charAt(d)||"",disabled:n?"":null});u.push(f),s.append(f)}const c=d=>{const f=d.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):u},m=d=>c(d).map(f=>f.value).join("").slice(0,e);return u.forEach((d,f)=>{d.oninput=g=>{const h=g.currentTarget,b=c(h);let v=h.value;if(r==="numeric"?v=v.replace(/\D/g,""):v=v.replace(/[^A-Za-z0-9]/g,""),v.length>1){const y=v.split("");y.slice(0,e-f).forEach((w,k)=>{const A=b[f+k];A&&(A.value=w)});const x=Math.min(f+y.length,e-1);b[x]?.focus()}else h.value=v,v&&f<e-1&&b[f+1]?.focus();o?.(m(h))},d.onkeydown=g=>{const h=g,b=h.currentTarget,v=c(b);if(h.key==="Backspace"&&!b.value&&f>0){h.preventDefault(),v[f-1]?.focus();const y=v[f-1];y&&(y.value=""),o?.(m(b))}else h.key==="ArrowLeft"&&f>0?(h.preventDefault(),v[f-1]?.focus()):h.key==="ArrowRight"&&f<e-1&&(h.preventDefault(),v[f+1]?.focus())}}),s}const ap={name:"PinInput",description:'Per-digit PIN entry. Auto-advances focus as the user types and supports paste. Pass a `$variable` as `value` for two-way binding (the bound value is the joined string). Use `type="numeric"` for PINs / 2FA codes, `"alphanumeric"` for invite codes.',props:[{name:"id",type:"string"},{name:"length",type:"number",optional:!0,description:"Number of slots (default 4)"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"type",type:"string",optional:!0,enum:tp},{name:"mask",type:"boolean",optional:!0,description:"Render slots as `<input type=password>`"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current joined string on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=Math.max(1,Math.min(12,Math.floor(L(e.length,4)))),i=p(e.type,"numeric"),o=p(e.value),s=T(e.disabled),u=T(e.mask),c=t.argMeta?.[2]?.stateRef;return rp(a,n,i,o,s,u,m=>{c&&r.setState(c,m),r.invoke(e.onChange,m)})}};function np(t){if(!t)return{score:0,label:""};let e=0;return t.length>=8&&(e+=1),t.length>=12&&(e+=1),/[A-Z]/.test(t)&&/[a-z]/.test(t)&&(e+=1),/[0-9]/.test(t)&&(e+=1),/[^A-Za-z0-9]/.test(t)&&(e+=1),e=Math.min(4,e),{score:e,label:["Too short","Weak","Fair","Good","Strong"][e]??""}}const ip={name:"PasswordInput",description:"Password input with a show/hide toggle and an optional strength meter. Pass a `$variable` as `value` for two-way binding. Set `strengthMeter=true` to render a 4-step indicator and label.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"strengthMeter",type:"boolean",optional:!0,aliases:["showStrength"]},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=T(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),u=p(e.label);u&&s.append(l("label",{class:"rui-password-input-label",for:a},[u]));const c=l("div",{class:"rui-password-input-row"}),m=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:p(e.placeholder),value:p(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=E(i?"eye-slash":"eye");f&&d.append(f),d.onclick=h=>{h.preventDefault();const b=!n.get();n.set(b);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=b?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(m,g,{event:"input",getValue:h=>h.value}),ie(m,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(m),c.append(d),s.append(c),T(e.strengthMeter)){const h=np(p(e.value)),b=l("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let y=0;y<4;y+=1)b.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<h.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(b),h.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[h.label])),s.append(v)}return s}},op={name:"TagInput",description:"Tag/chip input — type a value, press Enter (or comma) to commit, click × on a chip to remove. Pass a `$variable` (array of strings) as `value` for two-way binding. Use for keywords, recipients, labels, skills, allowlists.",props:[{name:"id",type:"string"},{name:"value",type:"string[]",optional:!0,description:"Bound array of tag values"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"max",type:"number",optional:!0,description:"Maximum number of tags"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of tags whenever one is added or removed"}],render:(t,e,r)=>{const a=p(e.id),n=C(e.value).map(f=>p(f)).filter(Boolean),i=Math.max(0,Math.floor(L(e.max,0))),o=T(e.disabled),s=t.argMeta?.[1]?.stateRef,u=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},c=p(e.label),m=l("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const f of n){const g=l("span",{class:"rui-tag-input-chip"});g.append(l("span",{},[f]));const h=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);h.onclick=()=>u(n.filter(b=>b!==f)),g.append(h),m.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:p(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=f=>{const g=f,h=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const b=h.value.trim();if(!b||i>0&&n.length>=i)return;if(n.includes(b)){h.value="";return}u([...n,b]),h.value=""}else g.key==="Backspace"&&h.value===""&&n.length>0&&(g.preventDefault(),u(n.slice(0,-1)))},m.append(d),c){const f=l("div",{class:"rui-tag-input-wrapper"});return f.append(l("label",{class:"rui-tag-input-label",for:a},[c])),f.append(m),f}return m}};function sp(t){return C(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=p(r.label??r.name??r.value??r.id);return{value:p(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const lp={name:"MentionInput",description:"Multi-line input with inline @-mention suggestions. Typing `@` opens a popover listing the provided `people` (filtered by what follows). Selecting an option inserts `@label` into the text. Pass a `$variable` as `value` for two-way binding. Use for comments, task notes, chat composers.",props:[{name:"id",type:"string"},{name:"people",type:"any[]",description:"Available mentions: strings or {value, label} objects"},{name:"value",type:"string",optional:!0,description:"Bound text (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0,description:"TextArea rows (default 3)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current text on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=sp(e.people),i=T(e.disabled),o=l("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=l("textarea",{class:"rui-mention-input-field",id:a,name:a,rows:String(Math.max(2,Math.floor(L(e.rows,3)))),placeholder:p(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=p(e.value);const u=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),c=r.useInstanceState("activeIndex",0),m=r.useInstanceState("matches",[]),d=r.useInstanceState("query",null),f=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,g=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-field")??null,h=(x,w)=>{const k=x.value,A=x.selectionStart??k.length,S=k.slice(0,A),$=S.lastIndexOf("@");if($===-1)return;const M=k.slice(A),I=`@${w.value} `,R=S.slice(0,$)+I+M;x.value=R;const j=$+I.length;x.selectionStart=x.selectionEnd=j,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},b=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),m.set([]);return}const k=w.toLowerCase(),S=n.filter(M=>M.label.toLowerCase().includes(k)||M.value.toLowerCase().includes(k)).slice(0,6);if(m.set(S),S.length===0){x.setAttribute("data-open","false");return}const $=Math.min(c.get(),S.length-1);c.set($),x.setAttribute("data-open","true"),S.forEach((M,I)=>{const R=l("button",{type:"button",class:"rui-mention-input-option","data-value":M.value,"data-active":I===$?"true":"false"});R.append(l("span",{class:"rui-mention-input-option-label"},[M.label])),M.value&&M.value!==M.label&&R.append(l("span",{class:"rui-mention-input-option-handle"},[`@${M.value}`])),R.onmousedown=j=>j.preventDefault(),R.onclick=j=>{const K=j.currentTarget,F=g(K),U=f(K);F&&h(F,M),d.set(null),U&&b(U,null)},x.append(R)})},v=x=>{const w=f(x);if(!w)return;const k=x.selectionStart??x.value.length,A=x.value.slice(0,k),S=/@([\w-]*)$/.exec(A),$=S?S[1]??"":null;d.set($),b(w,$)},y=t.argMeta?.[2]?.stateRef;return y?r.bindState(s,y,{event:"input",getValue:x=>{const w=x;return v(w),w.value}}):s.oninput=x=>{v(x.currentTarget)},ie(s,e.onChange,r,{event:"input",getValue:x=>x.value}),s.onkeydown=x=>{const w=x.currentTarget,k=f(w);if(!k||k.getAttribute("data-open")!=="true")return;const A=m.get();if(A.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(c.get()+1)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(c.get()-1+A.length)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=A[c.get()];S&&(h(w,S),d.set(null),b(k,null))}else x.key==="Escape"&&(d.set(null),b(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);d.set(null),k&&b(k,null)},120)},o.append(s),o.append(u),b(u,d.get()),o}},cp={name:"TimePicker",description:'Time-of-day picker that wraps `<input type="time">`. Pass a `$variable` as `value` for two-way binding (HH:MM 24-hour). Set `step` to constrain to specific increments (e.g. 900 for 15-minute buckets).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"HH:MM value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new HH:MM string when the user picks a time"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-time-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-time-picker-label",for:a},[i]));const o=l("input",{type:"time",class:"rui-time-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}},up={name:"DateTimePicker",description:'Combined date + time picker — wraps `<input type="datetime-local">`. Pass a `$variable` as `value` for two-way binding (ISO `YYYY-MM-DDTHH:MM`).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date-time value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO `YYYY-MM-DDTHH:MM` string"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-datetime-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-datetime-picker-label",for:a},[i]));const o=l("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}};function ei(t,e){if(!e)return t;let r="",a=0;const n=String(t??"");for(const i of e){if(a>=n.length)break;if(i==="9"){for(;a<n.length&&!/\d/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else if(i==="A"){for(;a<n.length&&!/[a-zA-Z]/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else i==="*"?(r+=n[a],a+=1):(r+=i,n[a]===i&&(a+=1))}return r}const dp={name:"MaskedInput",description:'Text input with an inline mask — `9` matches a digit, `A` matches a letter, `*` matches any character, every other character is a fixed delimiter. Useful for phone numbers, postal codes, credit cards. Pass `mask` (e.g. `"(999) 999-9999"`) and a `$variable` as `value`.',props:[{name:"id",type:"string"},{name:"mask",type:"string",description:"Mask pattern"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the masked value on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.mask),i=T(e.disabled),o=ei(p(e.value),n),s=p(e.label),u=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:p(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});u.value=o;const c=t.argMeta?.[2]?.stateRef,m=d=>{const f=d.value,g=ei(f,n);if(g===f)return g;const h=d.selectionStart??g.length;d.value=g;const b=Math.min(g.length,h);try{d.setSelectionRange(b,b)}catch{}return g};if(c?r.bindState(u,c,{event:"input",getValue:d=>m(d)}):u.oninput=d=>{m(d.currentTarget??d.target)},ie(u,e.onChange,r,{event:"input",getValue:d=>d.value}),s){const d=l("div",{class:"rui-masked-input-wrapper"});return d.append(l("label",{class:"rui-masked-input-label",for:a},[s])),d.append(u),d}return u}},pp={name:"FormSection",description:"Semantic grouping for related form fields — renders a small heading (`label`), optional helper paragraph, and stacks the children with consistent spacing. Use INSTEAD of wrapping fields in `Card` + `SectionHeader` by hand. Pair with `FieldSet` when the group is a true `<fieldset>` (radio sets, checkbox groups).",props:[{name:"label",type:"string",aliases:["title"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["description"],description:"Description rendered below the label"}],render:(t,e,r)=>{const a=l("section",{class:"rui-form-section"}),n=l("header",{class:"rui-form-section-header"});n.append(l("h3",{class:"rui-form-section-label"},[p(e.label)]));const i=p(e.helper);i&&n.append(l("p",{class:"rui-form-section-helper"},[i])),a.append(n);const o=l("div",{class:"rui-form-section-body"});for(const s of C(e.children))o.append(r.renderNode(s));return a.append(o),a}},mp={name:"FieldSet",description:"Native `<fieldset>`/`<legend>` wrapper for accessible grouping of related controls. Use when assistive tech should announce the wrapper (radio sets, checkbox groups). For purely visual grouping prefer `FormSection`.",props:[{name:"legend",type:"string",aliases:["title","label"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["hint","description"]},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("fieldset",{class:"rui-fieldset",disabled:T(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[p(e.legend)]));const n=p(e.helper);n&&a.append(l("p",{class:"rui-fieldset-helper"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},fp={name:"ValidationSummary",description:"Aggregate error list rendered at the top of a form. Pass `errors` as `{label?, message, field?}` objects or plain strings. Pair with individual field hints via `FormControl(hint=...)`.",props:[{name:"errors",type:"any[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Please fix the following:")'},{name:"tone",type:"string",optional:!0,enum:["danger","warning"]}],render:(t,e)=>{const r=C(e.errors).map(u=>{if(!u)return null;if(typeof u=="string")return{label:"",message:u,field:""};if(typeof u=="object"){const c=u;return{label:p(c.label),message:p(c.message??c.error),field:p(c.field)}}return null}).filter(u=>u!==null&&u.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=p(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=E(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(p(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const u of r){const c=l("li",{class:"rui-validation-summary-item"});u.label&&c.append(l("strong",{},[`${u.label}: `])),c.append(document.createTextNode(u.message)),s.append(c)}return n.append(s),n}};function gp(t){return C(t).map(e=>{if(!e||typeof e!="object")return{title:p(e),details:"",content:null};const r=e;return{title:p(r.title),details:p(r.details),content:r.content??null}})}const hp={name:"MultiStepForm",description:'Multi-step / wizard form composite. Renders a `Steps` indicator, the active step\'s `content`, and Prev/Next buttons that drive a `$variable` for the current 0-indexed step. Use INSTEAD of hand-rolling `Steps` + content + manual prev/next wiring. The submit button is rendered on the final step (override via `submitLabel`). Step indicator direction defaults to `column` (stacked next to the content); set `stepsLayout: "row"` for a classic horizontal stepper.',props:[{name:"steps",type:"object[]",description:"Array of {title, details?, content} step objects"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"onSubmit",type:"callable",optional:!0,description:"Callable fired when the user clicks Submit on the final step"},{name:"prevLabel",type:"string",optional:!0,description:'Default "Back"'},{name:"nextLabel",type:"string",optional:!0,description:'Default "Continue"'},{name:"submitLabel",type:"string",optional:!0,description:'Default "Submit" (final step)'},{name:"stepsLayout",type:"string",optional:!0,enum:["column","row"],aliases:["layout","stepsDirection"],description:'Direction of the steps indicator (default "column")'}],render:(t,e,r)=>{const a=gp(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(L(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=p(e.stepsLayout,"column").toLowerCase(),u=s==="row"||s==="horizontal"?"row":"column",c=l("div",{class:"rui-multi-step-form","data-layout":u}),m=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":u});a.forEach((x,w)=>{const k=l("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(l("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(l("div",{class:"rui-steps-details"},[x.details])),m.append(k)}),c.append(m);const d=l("div",{class:"rui-multi-step-form-body"}),f=a[i];f&&f.content&&d.append(r.renderNode(f.content)),c.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),h=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[p(e.prevLabel,"Back")]);o&&i>0&&(h.onclick=()=>r.setState(o,i-1));const b=i>=n-1,v=b?p(e.submitLabel,"Submit"):p(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{b?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(h),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),c.append(g),c}};function bp(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),message:p(r.message),time:p(r.time),icon:p(r.icon),tone:p(r.tone,"default"),unread:T(r.unread),avatarSrc:p(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const vp={name:"InboxPanel",description:"Grouped notification list — entries are grouped into Unread/Earlier sections, with a count chip on each group header. Pass `items` as `{title, message, time, icon?, tone?, unread?, avatarSrc?, onClick?}` objects (`action` is also accepted as an alias). Pair with a `SectionHeader` for the panel title (the component does not render its own title to avoid duplication). Use for top-bar notification trays, activity drawers, and alert center pages.",props:[{name:"items",type:"object[]"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when there are no notifications"},{name:"onMarkAllRead",type:"callable",optional:!0,description:'Callable fired by the "Mark all as read" button'}],render:(t,e,r)=>{const a=bp(e.items),n=a.filter(u=>u.unread),i=a.filter(u=>!u.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const u=l("div",{class:"rui-inbox-panel-toolbar"}),c=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);c.onclick=()=>r.invoke(e.onMarkAllRead),u.append(c),o.append(u)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[p(e.emptyLabel,"You're all caught up.")])),o;const s=(u,c)=>{if(c.length===0)return;const m=l("section",{class:"rui-inbox-panel-group"}),d=l("header",{class:"rui-inbox-panel-group-head"});d.append(l("span",{class:"rui-inbox-panel-group-label"},[u])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(c.length)])),m.append(d);for(const f of c){const g=Rn.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:f.title,message:f.message,time:f.time,icon:f.icon,tone:f.tone,avatarSrc:f.avatarSrc,unread:f.unread},r);typeof f.onClick=="function"&&(g.setAttribute("data-clickable","true"),g.onclick=()=>r.invoke(f.onClick)),m.append(g)}o.append(m)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function yp(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),description:p(r.description),done:T(r.done),onClick:r.onClick??r.action,cta:p(r.cta,"Start")}}).filter(e=>e!==null)}const xp={name:"OnboardingChecklist",description:'Step-by-step product checklist with completion progress at the top. Pass `items` as `{title, description?, done?, onClick?, cta?}` objects (`action` is also accepted as an alias). The progress percentage is computed automatically from `done`. Use on first-run dashboards, empty workspaces, and "complete your profile" surfaces.',props:[{name:"items",type:"object[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Getting started")'},{name:"subtitle",type:"string",optional:!0}],render:(t,e,r)=>{const a=yp(e.items),n=a.filter(d=>d.done).length,i=Math.max(1,a.length),o=Math.round(n/i*100),s=l("div",{class:"rui-onboarding-checklist"}),u=l("header",{class:"rui-onboarding-checklist-header"});u.append(l("h3",{class:"rui-onboarding-checklist-title"},[p(e.title,"Getting started")]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[c])),u.append(l("div",{class:"rui-onboarding-checklist-progress"},[l("div",{class:"rui-onboarding-checklist-bar"},[l("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),l("span",{class:"rui-onboarding-checklist-meta"},[`${n}/${a.length} complete`])])),s.append(u);const m=l("ol",{class:"rui-onboarding-checklist-list"});for(const d of a){const f=l("li",{class:"rui-onboarding-checklist-item","data-done":d.done?"true":"false"}),g=l("span",{class:"rui-onboarding-checklist-marker"}),h=E(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&g.append(h),f.append(g);const b=l("div",{class:"rui-onboarding-checklist-body"});if(b.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&b.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),f.append(b),!d.done&&typeof d.onClick=="function"){const v=l("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[d.cta]);v.onclick=()=>r.invoke(d.onClick),f.append(v)}m.append(f)}return s.append(m),s}};function ti(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=E(t.iconName,{className:t.iconClass});a&&e.append(a)}t.title&&e.append(l("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(l("p",{class:`rui-${t.klass}-description`},[t.description]));const r=C(t.actions);if(r.length>0){const a=l("div",{class:`rui-${t.klass}-actions`});for(const n of r)a.append(t.helpers.renderNode(n));e.append(a)}return e}const wp={name:"LoadingState",description:"Full-card loading state — large spinner + title + description. Use while a query is in flight or while a long-running tool runs. For tiny inline loaders prefer `Spinner`; for skeleton placeholders prefer `Skeleton`.",props:[{name:"title",type:"string",optional:!0,description:'Default "Loading…"'},{name:"description",type:"string",optional:!0}],render:(t,e)=>{const r=l("div",{class:"rui-loading-state"}),a=l("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});a.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(a),r.append(l("h3",{class:"rui-loading-state-title"},[p(e.title,"Loading…")]));const n=p(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},kp={name:"ErrorState",description:"Full-card error placeholder. Pairs a danger icon with title, description, and a row of recovery actions (Retry / Contact support / Go home). Pass `actions` as Button(...) entries.",props:[{name:"title",type:"string",optional:!0,description:'Default "Something went wrong"'},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon (default `circle-exclamation`)"}],render:(t,e,r)=>ti({klass:"error-state",iconName:p(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:p(e.title,"Something went wrong"),description:p(e.description),actions:e.actions,helpers:r})},Sp={name:"SuccessState",description:'Full-card success placeholder. Use for confirmation screens ("Order placed", "Payment succeeded", "Account verified") at the end of a flow. Pass `actions` for follow-up CTAs.',props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Default `circle-check`"}],render:(t,e,r)=>ti({klass:"success-state",iconName:p(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:p(e.title),description:p(e.description),actions:e.actions,helpers:r})},Cp={name:"Tour",description:"Product-tour controller — renders the current step's title, description, and a Prev/Next/Skip row. Bind `current` to a `$variable` (0-indexed). Pass `steps` as `{title, description, target?}` objects; the optional `target` is a CSS selector that renders alongside the step for designers to reference.",props:[{name:"steps",type:"object[]"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"open",type:"boolean",optional:!0,description:"Whether the tour is visible"},{name:"onComplete",type:"callable",optional:!0}],render:(t,e,r)=>{const a=C(e.steps).map(v=>{if(!v||typeof v!="object")return{title:p(v),description:"",target:""};const y=v;return{title:p(y.title),description:p(y.description),target:p(y.target)}}),n=e.open===void 0?!0:T(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(L(e.current,0)))),s=t.argMeta?.[1]?.stateRef,u=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return u;const c=a[o];if(!c)return u;const m=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});m.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),m.append(l("h3",{class:"rui-tour-title"},[c.title])),c.description&&m.append(l("p",{class:"rui-tour-description"},[c.description])),c.target&&m.append(l("div",{class:"rui-tour-target"},[`Target: ${c.target}`]));const d=l("div",{class:"rui-tour-footer"}),f=l("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);f.onclick=()=>r.invoke(e.onComplete);const g=l("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(g.onclick=()=>r.setState(s,o-1));const h=o>=i-1,b=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return b.onclick=()=>{h?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(f,g,b),m.append(d),u.append(m),u}},$p={name:"Spotlight",description:'Single-step product highlight — a dimmed full-page overlay with a ring around the focused area and a small explainer card. Use for one-off feature reveals ("Try the new commands menu"). Bind `open` to a `$variable` to dismiss.',props:[{name:"title",type:"string"},{name:"open",type:"boolean",optional:!0,description:"Whether the spotlight is visible — typically a $variable (default true)"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0,aliases:["action"]}],render:(t,e,r)=>{const a=e.open===void 0?!0:T(e.open),n=l("div",{class:"rui-spotlight","data-open":a?"true":"false"});if(!a)return n;const i=l("div",{class:"rui-spotlight-card"});i.append(l("h3",{class:"rui-spotlight-title"},[p(e.title)]));const o=p(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=C(e.actions);if(s.length>0){const c=l("div",{class:"rui-spotlight-actions"});for(const m of s)c.append(r.renderNode(m));i.append(c)}const u=t.argMeta?.[1]?.stateRef;return u&&(n.onclick=c=>{c.target===n&&r.setState(u,!1)}),n.append(i),n}},Tp={name:"Sticky",description:"Wraps content in a `position: sticky` container so it pins to the top (or bottom) of the nearest scrollable ancestor. Use for toolbar action rows above tables, in-page navs, status banners.",props:[{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["top","bottom"]},{name:"offset",type:"string",optional:!0,description:"CSS offset (default 0)"},{name:"zIndex",type:"number",optional:!0,description:"Z-index (default 10)"}],render:(t,e,r)=>{const a=p(e.side,"top"),n=te(e.offset,"0"),i=Math.max(0,Math.floor(L(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const u of C(e.children))s.append(r.renderNode(u));return s}},Ap={name:"ResizablePanels",description:"Two-pane horizontal split with a draggable divider. The user can drag the divider to resize the primary pane; defaults respect the starting width. Use for code editors, file browsers, master/detail layouts that need user-controllable proportions.",props:[{name:"primary",type:"Node[]"},{name:"secondary",type:"Node[]"},{name:"initialPrimaryWidth",type:"string",optional:!0,description:"CSS width for the primary pane (default 40%)"},{name:"minPrimaryWidth",type:"string",optional:!0,description:"Min width (default 240px)"}],render:(t,e,r)=>{const a=te(e.initialPrimaryWidth,"40%"),n=te(e.minPrimaryWidth,"240px"),i=l("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${a};--rui-resizable-min:${n};`}),o=l("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const c of C(e.primary))o.append(r.renderNode(c));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),u=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const c of C(e.secondary))u.append(r.renderNode(c));return i.append(o,s,u),s.onpointerdown=c=>{const m=c,d=m.currentTarget;d.setPointerCapture(m.pointerId);const f=d.closest(".rui-resizable-panels");if(!f)return;const g=f.getBoundingClientRect(),h=v=>{const y=(v.clientX-g.left)/g.width*100,x=Math.max(15,Math.min(85,y));f.style.setProperty("--rui-resizable-primary",`${x}%`)},b=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",h),d.removeEventListener("pointerup",b)};d.addEventListener("pointermove",h),d.addEventListener("pointerup",b)},i}},Np={name:"MasonryGrid",description:"Pinterest-style column grid. Children flow into columns that reflow on viewport changes. Use for galleries, social-style feeds, and mixed-height card walls. Prefer `Grid` when children should share the same height per row.",props:[{name:"items",type:"Node[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default 3)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"]}],render:(t,e,r)=>{const a=Math.max(1,Math.min(6,Math.floor(L(e.columns,3)))),n=p(e.gap,"m"),i=l("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":n});for(const o of C(e.items))i.append(r.renderNode(o));return i}},Mp={name:"Drawer",description:"Side drawer overlay shown when `open` is true. Pass a `$variable` as `open` to control it. Choose `side` for slide direction (default right). `onClose` fires whenever the drawer is dismissed (× button or backdrop click).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["right","left","top","bottom"]},{name:"footer",type:"Node[]",optional:!0,description:"Optional footer actions row"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the drawer is dismissed"}],render:(t,e,r)=>{const a=T(e.open),n=p(e.side,"right"),i=l("div",{class:"rui-sheet-overlay","data-open":a?"true":"false","data-side":n}),o=l("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":n}),s=l("header",{class:"rui-sheet-header"});s.append(l("h3",{class:"rui-sheet-title"},[p(e.title)]));const u=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),c=t.argMeta?.[1]?.stateRef,m=()=>{c&&r.setState(c,!1),r.invoke(e.onClose)};u.onclick=m,i.onclick=g=>{g.target===i&&m()},s.append(u),o.append(s);const d=l("div",{class:"rui-sheet-body"});for(const g of C(e.children))d.append(r.renderNode(g));o.append(d);const f=C(e.footer);if(f.length>0){const g=l("footer",{class:"rui-sheet-footer"});for(const h of f)g.append(r.renderNode(h));o.append(g)}return i.append(o),i}},Pp={name:"TopBar",description:'Compact header strip that pairs a title (or breadcrumb) with search and action slots. Use INSTEAD of hand-rolling a `Stack(direction="row")` above a page. For full SaaS shells use `Navbar` (links) or `AppShell` (sidebar + topbar + content).',props:[{name:"title",type:"string",optional:!0},{name:"subtitle",type:"string",optional:!0},{name:"left",type:"Node[]",optional:!0,aliases:["badges"],description:"Leading slot (breadcrumbs, brand, status, badges)"},{name:"center",type:"Node[]",optional:!0,aliases:["search"],description:"Centered slot (search bar, segmented control)"},{name:"right",type:"Node[]",optional:!0,aliases:["actions"],description:"Trailing slot (actions, avatar)"},{name:"sticky",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("header",{class:"rui-topbar","data-sticky":T(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=p(e.title);if(i){const u=l("div",{class:"rui-topbar-title-block"});u.append(l("h2",{class:"rui-topbar-title"},[i]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-topbar-subtitle"},[c])),n.append(u)}for(const u of C(e.left))n.append(r.renderNode(u));a.append(n);const o=C(e.center);if(o.length>0){const u=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const c of o)u.append(r.renderNode(c));a.append(u)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const u of C(e.right))s.append(r.renderNode(u));return a.append(s),a}},Ip={name:"Theme",description:"Apply a partial theme on top of the base theme. Pass an object of token → value pairs (colors, fonts, radii, spacing, button styling). Assigning the result to a top-level binding (conventionally `theme`) lets the runtime detect it and write the tokens to the host as CSS custom properties — the rest of the rendered UI picks them up instantly.",props:[{name:"tokens",type:"any",description:"Object literal of theme tokens. Keys must match `ThemeTokens` (e.g. colorPrimary, colorBg, fontFamily, fontFamilyHeading, fontSizeBase, radiusMd, radiusButton, borderWidth, shadowMd, buttonFontWeight, …). Unknown keys are ignored."}],render:()=>document.createDocumentFragment()},Lp={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` when the current path matches `to` (set `exact=true` to require exact equality instead of prefix matching).',props:[{name:"label",type:"string",description:"Visible link text."},{name:"to",type:"string",description:'Target route path, e.g. "/about".'},{name:"variant",type:"string",optional:!0,enum:["default","primary","ghost","pill"],description:"Visual variant."},{name:"exact",type:"boolean",optional:!0,description:"Match the current path exactly (default: prefix match)."},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label."}],render:(t,e,r)=>{const a=p(e.label,""),n=p(e.to,"/"),i=p(e.variant,"default"),o=T(e.exact,!1),s=r.router,u=s.getPath(),c=u?o?u===n:n==="/"?u==="/":u===n?!0:u.startsWith(n+"/"):!1,m=l("a",{class:"rui-nav-link","data-variant":i,"data-active":c?"true":"false",href:"#"+(n.startsWith("/")?n:"/"+n)}),d=E(e.icon,{className:"rui-nav-link-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-nav-link-label"},[a])),m.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(n)))},m}},zp=["primary","secondary","ghost","danger"],Rp=["xs","sm","md","lg","xl","small","normal","large"];function Ep(t){const e=p(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}function jp(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n)}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Ot(t){return C(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Dp(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n),group:p(a.group)||void 0,shortcut:p(a.shortcut)||void 0,action:a.action}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function ri(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.name??a.label);return{name:n,label:p(a.label,n),type:p(a.type,"text")||"text"}}const r=p(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Bp(t){return Ot(t).map((e,r)=>({id:p(e.id,`task-${r}`),label:p(e.label??e.name,`Task ${r+1}`),start:p(e.start),end:p(e.end),progress:e.progress!=null?L(e.progress,0):void 0}))}function Ue(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Fp(t,e){const r=t.split(`
|
|
39
|
+
}`},catch:{summary:"Handle an error thrown inside the preceding `try` block.",syntax:"catch (error) { ... }",example:"catch (e) { $error = e }"},finally:{summary:"Run cleanup after `try` / `catch`, regardless of outcome.",syntax:"finally { ... }",example:"finally { $loading = false }"},throw:{summary:"Raise an error — caught by an enclosing `try` / `catch`.",syntax:"throw value",example:'throw "invalid state"'},new:{summary:"Construct an instance of a host class (Date, Map, Set, …).",syntax:"new Constructor(args)",example:"let now = new Date()"},typeof:{summary:`Return a string naming a value's type ("number", "string", …).`,syntax:"typeof value",example:'if (typeof x === "number") { ... }'},instanceof:{summary:"Test whether a value is an instance of a constructor.",syntax:"value instanceof Constructor",example:"if (d instanceof Date) { ... }"},delete:{summary:"Remove a property from an object.",syntax:"delete obj.prop",example:"delete $form.draft"},void:{summary:"Evaluate an expression and yield `undefined`.",syntax:"void expression",example:"void sideEffect()"}};function $a(t=vt){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=d=>({...d}),a=new Set(t.atoms),n=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,u=new Set([...t.operators.join(""),..."=<>!&|"]),c=(d,f)=>{for(;!d.eol();){const g=d.next();if(!g)return;if(g==="\\"){d.next();continue}if(g===f)return}};return{startState:e,copyState:r,token:(d,f)=>{if(f.inBacktick){for(;!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return f.inBacktick=!1,"string"}return"string"}if(f.inBlockComment){for(;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";d.next()}return"comment"}if(d.eatWhile(/[ \t]/))return null;if(d.match(t.comments.line,!0))return d.skipToEnd(),"comment";if(d.match(t.comments.blockStart,!0)){for(f.inBlockComment=!0;!d.eol();){if(d.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";d.next()}return"comment"}const g=d.peek();if(g==null)return null;if(t.strings.singleLineQuotes.includes(g)){const h=g;return d.next(),c(d,h),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const h=d.next();if(h==="\\"){d.next();continue}if(h==="`")return"string"}return f.inBacktick=!0,"string"}if(g>="0"&&g<="9"&&d.match(s,!0)||g==="-"&&d.match(/^-\d+(?:\.\d+)?/,!1)&&d.match(s,!0))return"number";if(g===t.sigils.state)return d.next(),d.peek()===t.sigils.state&&d.next(),d.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(g)){if(d.match(i,!0))return"component";const b=d.match(o,!0);if(b){const v=b[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const h of t.operatorsLong)if(d.match(h,!0))return"operator";return g==="."?(d.next(),d.peek()&&t.identifier.start.test(d.peek())?(d.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(g)?(d.next(),"punctuation"):u.has(g)?(d.next(),"operator"):(d.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const Ta={comment:"comment",string:"string",number:"number",atom:"atom",keyword:"keyword",state:"variableName.special",component:"typeName",identifier:"variableName",loopvar:"variableName.local",property:"propertyName",operator:"operator",punctuation:null},Aa={},Na=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function Ma(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Pa(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function rr(t,e){if(t.has(e))return!0;for(const r of t)if(Pa(r,e))return!0;return!1}function yt(t,e){for(const r of e)if(rr(t,r))return!0;return!1}class Ia{constructor(){j(this,"values",new Map);j(this,"defaults",new Map);j(this,"subscribers",new Set);j(this,"pendingChanges",new Set);j(this,"flushScheduled",!1);j(this,"rendering",!1);j(this,"renderWriteOccurred",!1)}declare(e,r){this.defaults.set(e,r),this.values.has(e)||this.values.set(e,r)}has(e){return this.values.has(e)}get(e){return this.values.get(e)}set(e,r){this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}enqueueChange(e){if(this.rendering){this.renderWriteOccurred=!0;return}this.pendingChanges.add(e),this.scheduleFlush()}beginRenderPass(){this.rendering=!0,this.renderWriteOccurred=!1}isRendering(){return this.rendering}endRenderPass(){this.rendering=!1;const e=this.renderWriteOccurred;return this.renderWriteOccurred=!1,e}setPath(e,r,a){if(r.length===0){this.set(e,a);return}const n=this.values.get(e),i=rt(n,r,0,a);this.values.set(e,i),this.enqueueChange(Ma(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,a)=>{e[a]=r}),e}hydrate(e){for(const[r,a]of Object.entries(e))this.values.set(r,a)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const a=this.defaults.get(r);this.values.get(r)!==a&&(this.values.set(r,a),this.enqueueChange(r))}}resetAll(){for(const[e,r]of this.defaults.entries())this.values.get(e)!==r&&(this.values.set(e,r),this.enqueueChange(e))}rebind(e){this.values.clear(),this.defaults.clear(),this.pendingChanges.clear();for(const[r,a]of e)this.defaults.set(r,a),this.values.set(r,a)}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){if(this.flushScheduled=!1,this.pendingChanges.size===0)return;const e=new Set(this.pendingChanges);this.pendingChanges.clear();for(const r of[...this.subscribers])r(e)}}function rt(t,e,r,a){if(r>=e.length)return a;const n=e[r],i=n!==""&&!Number.isNaN(Number(n))?Number(n):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=rt(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=rt(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=rt(void 0,e,r+1,a),s}const o={};return o[n]=rt(void 0,e,r+1,a),o}const La=Symbol("aktion.httpResource");function Ra(t){return typeof t=="object"&&t!==null&&t[La]===!0}class Ea{constructor(){j(this,"interceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};if(this.interceptors.onRequest)try{r=await this.interceptors.onRequest(r)}catch(n){throw this.interceptors.onError?.(n,r),n}const a=async()=>{const n=new AbortController,i=typeof fetch=="function"?fetch:null;if(!i)throw new Error("`fetch` is not available in this environment");const o={...r.init,method:r.method,headers:r.headers,signal:r.signal??n.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(o.body=$o(r.body,r.headers));const s=await i(r.url,o),u={};s.headers.forEach((d,f)=>{u[f]=d});const c=u["content-type"]??"";let m;return s.status===204||r.method==="HEAD"?m=null:c.includes("application/json")?m=await s.json().catch(()=>null):m=await s.text().catch(()=>""),{status:s.status,headers:u,body:m}};try{let n=await a();if(this.interceptors.onResponse){let i=!1;const o=async()=>i?n:(i=!0,a());n=await this.interceptors.onResponse(n,o)}return n}catch(n){throw this.interceptors.onError?.(n,r),n}}}function $o(t,e){if(t==null)return"";if(typeof t=="string"||t instanceof Blob||t instanceof ArrayBuffer||typeof FormData<"u"&&t instanceof FormData||typeof URLSearchParams<"u"&&t instanceof URLSearchParams)return t;!e["content-type"]&&!e["Content-Type"]&&(e["Content-Type"]="application/json");try{return JSON.stringify(t)}catch{return String(t)}}const To=new Set(["url","method","headers","body","query","signal"]);function Ao(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",a=typeof e.method=="string"?e.method.toUpperCase():"GET",n={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[u,c]of Object.entries(e.headers))c!=null&&(n[u]=String(c));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const u=new URLSearchParams;for(const[m,d]of Object.entries(e.query))d!=null&&u.append(m,String(d));const c=u.toString();c&&(i+=(i.includes("?")?"&":"?")+c)}const o={};for(const[u,c]of Object.entries(e))To.has(u)||(o[u]=c);const s={url:i,method:a,headers:n,body:e.body};return Object.keys(o).length>0&&(s.init=o),e.signal instanceof AbortSignal&&(s.signal=e.signal),s}function za(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{n+=1,a&&a.abort(),a=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,La,{value:!0,enumerable:!1,writable:!1});let a=null,n=0;const i=()=>e.notify?.(),o=async()=>{const s=n+=1;a&&a.abort(),a=new AbortController;const u=a;if(r.state=r.data===void 0?"loading":"stale",r.loading=!0,i(),!e.http){r.error={message:"http runtime not available"},r.state="error",r.loading=!1,i();return}try{const c=Ao(t);c.url=e.http.resolveUrl(c.url),c.signal=u.signal;const m=await e.http.request(c);if(s!==n)return;m.status>=200&&m.status<300?(r.data=m.body,r.state="data",r.error=void 0):(r.error={status:m.status,body:m.body},r.state="error"),r.status=m.status,r.headers=m.headers,r.lastUpdated=Date.now()}catch(c){if(s!==n||c?.name==="AbortError")return;r.error=c,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(c){console.error("[aktion] Http onDone callback threw",c)}}};return o(),r}function Da(t={}){const e=No(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,u){if(typeof s!="string"||!s)return"";const c=e[s];let m;return c&&(a&&typeof c[a]=="string"?m=c[a]:r&&typeof c[r]=="string"&&(m=c[r])),m===void 0?s:Mo(m,u)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function No(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){if(!a||typeof a!="object"||Array.isArray(a))continue;const n={};for(const[i,o]of Object.entries(a))typeof o=="string"&&(n[i]=o);e[r]=n}return e}function Mo(t,e){return e?t.replace(/\{([^}]+)\}/g,(r,a)=>{const n=e[a.trim()];return n==null?"":String(n)}):t}const W=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,le=t=>Array.isArray(t)?t:[],ja=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Ba=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return W(e)>W(r);case"<":return W(e)<W(r);case">=":return W(e)>=W(r);case"<=":return W(e)<=W(r);case"contains":{const a=String(e??"").toLowerCase(),n=String(r??"").toLowerCase();return a.includes(n)}default:return!1}},Ge=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const a of e.split("."))if(r&&typeof r=="object")r=r[a];else return;return r}return t[e]}},De=t=>{if(t instanceof Date)return t;if(typeof t=="number")return new Date(t);if(typeof t=="string"&&t.trim()!==""){if(!Number.isNaN(Number(t))&&/^-?\d+$/.test(t.trim()))return new Date(Number(t));const e=new Date(t);if(!Number.isNaN(e.getTime()))return e}return new Date},Po=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Io=["January","February","March","April","May","June","July","August","September","October","November","December"],Lo=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ro=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Eo=(t,e)=>{const r=(s,u=2)=>String(s).padStart(u,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,Io[t.getMonth()]],[/MMM/g,Po[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,Ro[t.getDay()]],[/ddd/g,Lo[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(a)],[/hh/g,r(n)],[/mm/g,r(t.getMinutes())],[/ss/g,r(t.getSeconds())],[/\bM\b/g,String(t.getMonth()+1)],[/\bD\b/g,String(t.getDate())],[/\bH\b/g,String(a)],[/\bh\b/g,String(n)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,a>=12?"PM":"AM"],[/a/g,a>=12?"pm":"am"]];let o=e;for(const[s,u]of i)o=o.replace(s,u);return o},zo=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,u=7*s,c=30*s,m=365*s;let d,f;return a<i?n?"in a moment":"just now":(a<o?(d=Math.round(a/i),f="m"):a<s?(d=Math.round(a/o),f="h"):a<u?(d=Math.round(a/s),f="d"):a<c?(d=Math.round(a/u),f="w"):a<m?(d=Math.round(a/c),f="mo"):(d=Math.round(a/m),f="y"),n?`in ${d}${f}`:`${d}${f} ago`)},Do=(t,e,r)=>{if(ja(e)){const n={};return typeof e.currency=="string"&&(n.currency=e.currency),typeof e.locale=="string"&&(n.locale=e.locale),typeof e.decimals=="number"&&(n.decimals=e.decimals),n}const a={};return t==="currency"?(typeof e=="string"&&e.length>0&&(a.currency=e),typeof r=="string"&&r.length>0&&(a.locale=r)):typeof e=="string"&&e.length>0&&(a.locale=e),a},jo=(t,e)=>{const a=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(a.length===0)return"";if(e==="snake")return a.join("_");if(e==="kebab")return a.join("-");const n=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?a.map(n).join(""):a[0]+a.slice(1).map(n).join("")},Bo={count:t=>le(t).length,sum:t=>le(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=le(t);return e.length===0?0:e.reduce((r,a)=>r+W(a),0)/e.length},min:t=>{const e=le(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=le(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>le(t)[0]??null,last:t=>{const e=le(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",a)=>le(t).filter(n=>Ba(r,Ge(n,String(e)),a)),find:(t,e="",r="==",a)=>le(t).find(n=>Ba(r,Ge(n,String(e)),a))??null,sort:(t,e="",r="asc")=>{const a=[...le(t)],n=String(r).toLowerCase()==="desc"?-1:1;return a.sort((i,o)=>{const s=Ge(i,String(e)),u=Ge(o,String(e));return typeof s=="number"&&typeof u=="number"?(s-u)*n:String(s??"").localeCompare(String(u??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of le(t)){const n=String(Ge(a,String(e))??"");(r[n]??(r[n]=[])).push(a)}return r},slice:(t,e,r)=>{const a=le(t);return a.slice(e??0,r??a.length)},unique:(t,e)=>{const r=le(t);if(!e)return Array.from(new Set(r));const a=new Set,n=[];for(const i of r){const o=Ge(i,e);a.has(o)||(a.add(o),n.push(i))}return n},reverse:t=>[...le(t)].reverse(),range:(t,e,r)=>{const a=W(t),n=W(e),i=r===void 0?n>=a?1:-1:W(r);if(i===0)return[a];const o=Math.abs(n-a),s=Math.floor(o/Math.abs(i))+1;if(s>xt)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${xt}).`);const u=[];if(i>0)for(let c=a;c<=n;c+=i)u.push(c);else for(let c=a;c>=n;c+=i)u.push(c);return u},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>xt)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${xt}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!ja(t))return{};const r=le(e).map(n=>String(n??"")),a={};for(const n of r)n in t&&(a[n]=t[n]);return a},format:(t,e="number",r,a)=>{const n=W(t),i=String(e),o=Do(i,r,a),s={};i==="currency"?(s.style="currency",s.currency=o.currency||"USD"):i==="percent"?(s.style="percent",o.decimals===void 0&&(s.maximumFractionDigits=2)):i==="compact"?s.notation="compact":s.style="decimal",o.decimals!==void 0&&(s.minimumFractionDigits=o.decimals,s.maximumFractionDigits=o.decimals);try{return new Intl.NumberFormat(o.locale||void 0,s).format(n)}catch{return i==="currency"?n.toFixed(o.decimals??2):String(n)}},formatDate:(t,e="MMM D")=>{const r=De(t),a=String(e);switch(a){case"relative":return zo(r);case"date":return r.toLocaleDateString();case"time":return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});case"datetime":return r.toLocaleString();case"iso":return r.toISOString();default:return Eo(r,a)}},plural:(t,e,r)=>{const a=W(t),n=String(e??""),i=r===void 0?n+"s":String(r??"");return`${a} ${a===1?n:i}`},capitalize:t=>{const e=String(t??"");return e.length===0?"":e.charAt(0).toUpperCase()+e.slice(1)},lowercase:t=>String(t??"").toLowerCase(),uppercase:t=>String(t??"").toUpperCase(),titlecase:t=>String(t??"").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "),case:(t,e="camel")=>{const r=String(e).toLowerCase();return jo(t,r==="snake"||r==="kebab"||r==="pascal"||r==="camel"?r:"camel")},now:()=>Date.now(),today:()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},addDays:(t,e)=>{const r=De(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=De(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=De(t),a=De(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=De(t),r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return r.setUTCDate(r.getUTCDate()-r.getUTCDay()),r.toISOString()},endOfMonth:t=>{const e=De(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>le(t).map(r=>r==null?"":String(r)).join(String(e)),split:(t,e=",")=>String(t??"").split(String(e)),trim:t=>String(t??"").trim(),replace:(t,e,r="")=>String(t??"").split(String(e??"")).join(String(r??"")),substring:(t,e,r)=>{const a=String(t??"");return a.substring(W(e),r===void 0?a.length:W(r))},startsWith:(t,e)=>String(t??"").startsWith(String(e??"")),endsWith:(t,e)=>String(t??"").endsWith(String(e??"")),contains:(t,e)=>String(t??"").includes(String(e??"")),match:(t,e)=>{try{return new RegExp(String(e??"")).test(String(t??""))}catch{return!1}},round:(t,e=0)=>{const r=Math.pow(10,W(e));return Math.round(W(t)*r)/r},floor:t=>Math.floor(W(t)),ceil:t=>Math.ceil(W(t)),abs:t=>Math.abs(W(t)),clamp:(t,e,r)=>Math.min(Math.max(W(t),W(e)),W(r)),pow:(t,e)=>Math.pow(W(t),W(e)),sqrt:t=>Math.sqrt(W(t)),random:()=>Math.random(),log:t=>Math.log(W(t))},xt=1e5;function je(t){if(!t)return"/";let e=String(t);e.startsWith("#")&&(e=e.slice(1));const r=e.indexOf("?");return r>=0&&(e=e.slice(0,r)),e=e.replace(/\/{2,}/g,"/"),!e||e==="/"?"/":(e.startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function Fa(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=je(t),a=je(e),n=r==="/"?[]:r.slice(1).split("/"),i=a==="/"?[]:a.slice(1).split("/"),o={};let s=!1;for(let u=0;u<n.length;u+=1){const c=n[u];if(c==="*"){s=!0;const d=i.slice(u).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const m=i[u];if(m===void 0)return{matched:!1,params:{}};if(c.startsWith(":")){const d=c.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(m);continue}if(c!==m)return{matched:!1,params:{}}}return!s&&i.length>n.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}class Oa{constructor(e={}){j(this,"currentPath");j(this,"currentParams",{});j(this,"currentPattern",null);j(this,"enabled",!1);j(this,"hashListener",null);j(this,"listeners",new Set);j(this,"defaultPath");j(this,"settingHash",!1);this.defaultPath=je(e.defaultPath??"/"),this.currentPath=this.defaultPath}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=a=>{if(this.settingHash)return;const n=je(window.location.hash);this.setPath(n,a)},r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r,e("init")}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&window.removeEventListener("hashchange",this.hashListener),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,Fo(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=je(e);if(r!==this.currentPath){if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{window.location.hash="#"+r}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(r,"navigate");return}this.setPath(r,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const a=je(e);if(a===this.currentPath)return;const n=this.currentPath;this.currentPath=a,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:a,previousPath:n,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function Fo(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}const Me=(t,e)=>{try{return t()}catch{return e}},_a=t=>{if(typeof t=="string")return t;if(t===null)return"null";if(t===void 0)return"";try{return JSON.stringify(t)}catch{return String(t)}},Ua=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},Ha=t=>({set:(e,r)=>Me(()=>{const a=t();return a?(a.setItem(String(e),_a(r)),!0):!1},!1),get:e=>Me(()=>{const r=t();return r?Ua(r.getItem(String(e))):null},null),remove:e=>Me(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>Me(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),Oo=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,_o=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,wt=()=>typeof globalThis>"u"?null:globalThis.document??null,Uo=t=>{if(t==null)return null;if(t instanceof Date)return t.toUTCString();if(typeof t=="string"){const e=new Date(t);return Number.isNaN(e.getTime())?null:e.toUTCString()}if(typeof t=="number"&&Number.isFinite(t)){const e=new Date;return e.setTime(e.getTime()+t*864e5),e.toUTCString()}return null},ar=(t={})=>{const e=[],r=Uo(t.expires);if(r&&e.push(`expires=${r}`),typeof t.maxAge=="number"&&Number.isFinite(t.maxAge)&&e.push(`max-age=${Math.floor(t.maxAge)}`),e.push(`path=${t.path??"/"}`),t.domain&&e.push(`domain=${t.domain}`),t.secure&&e.push("secure"),t.sameSite){const a=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${a}`)}return e.length===0?"":`; ${e.join("; ")}`},Va=()=>{const t=wt();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const a of r.split(";")){const n=a.trim();if(!n)continue;const i=n.indexOf("=");if(i<0){e[decodeURIComponent(n)]="";continue}const o=decodeURIComponent(n.slice(0,i)),s=decodeURIComponent(n.slice(i+1));e[o]=s}return e},Ho={set:(t,e,r)=>Me(()=>{const a=wt();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(_a(e));return a.cookie=`${n}=${i}${ar(r)}`,!0},!1),get:t=>Me(()=>{const r=Va()[String(t)];return r===void 0?null:Ua(r)},null),remove:(t,e)=>Me(()=>{const r=wt();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${ar(n)}`,!0},!1),clear:()=>Me(()=>{const t=wt();if(!t)return!1;const e=Va();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${ar({expires:new Date(0),maxAge:0})}`}return!0},!1)},at=Ha(Oo),Vo=Ha(_o),nr={set:at.set,get:at.get,remove:at.remove,clear:at.clear,local:at,session:Vo,cookies:Ho},Wo=["log","error","warn","info","debug"],qo=()=>typeof globalThis>"u"?null:globalThis.console??null,Go=t=>(...e)=>{const r=qo();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},Wa=Wo.reduce((t,e)=>(t[e]=Go(e),t),{}),nt={Math,JSON,Object,Array,Number,String,Boolean,Date,Map,Set,WeakMap,WeakSet,RegExp,Symbol,Promise,Error,TypeError,RangeError,Infinity:1/0,NaN:NaN,undefined:void 0,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,structuredClone:typeof structuredClone=="function"?structuredClone:void 0},ir={util:Bo,console:Wa,storage:nr};function qa(t){if(typeof globalThis>"u")return{found:!1,value:void 0};if(t in Object.prototype)return{found:!1,value:void 0};const e=globalThis;return t in e?{found:!0,value:e[t]}:{found:!1,value:void 0}}const kt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Pe extends Error{constructor(r,a,n){super(Ko(r,a,n));j(this,"kind");j(this,"limit");j(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=a,this.source=n}}function Ko(t,e,r){switch(t){case"component-depth":return`[aktion] runtime aborted at ${r}: component recursion exceeded ${e} levels — check for a component that calls itself directly or transitively.`;case"iterations":return`[aktion] runtime aborted at ${r}: exceeded ${e} total loop iterations in a single render — narrow the iterable or split the loop.`;case"array-length":return`[aktion] runtime aborted at ${r}: array length would exceed ${e} elements.`}}function Ga(t={}){return{componentDepthLimit:t.componentDepthLimit??kt.componentDepthLimit,iterationLimit:t.iterationLimit??kt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??kt.arrayLengthLimit,componentDepth:0,iterations:0}}function or(t){t.iterations=0,t.componentDepth=0}function it(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Pe("iterations",t.iterationLimit,r)}function sr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Pe("component-depth",r.componentDepthLimit,`component "${e}"`)}function lr(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const Ka=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),Ya=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),St=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function cr(t,e={}){const r={state:t,bindings:new Map,expressions:new Map,trackedState:new Set,loopVars:new Map,mutableBindings:new Map,stateAliases:[],router:e.router,library:e.library,componentDecls:new Map,effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,actionRunner:e.actionRunner,notify:e.notify,onEmit:e.onEmit,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??Ga()};return r.disposers.push(()=>{for(const a of r.timers.timeouts)clearTimeout(a);for(const a of r.timers.intervals)clearInterval(a);r.timers.timeouts.clear(),r.timers.intervals.clear()}),r}function ur(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function Xa(t){t.mutableBindings.clear()}function xe(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const n=t.stateAliases[r].get(e);if(n!==void 0)return n}return e}function Ct(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const n=a.computed.value;if(typeof n!="string"&&typeof n!="number")return null;r.unshift(String(n))}else if(a.property)r.unshift(a.property);else return null;a=a.object}return a.kind!=="StateRef"?null:{name:xe(e,a.name),path:r}}function $t(t,e){if(t.kind==="StateRef")return xe(e,t.name);if(t.kind==="Member"){const r=Ct(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=nn(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function Ja(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=At(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)dr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!Za(r.expression))continue;const a=N(r.expression,e);e.state.set(r.identifier,a)}Jo(t,e),Xo(t,e)}const Yo=8;function Xo(t,e){const r=[],a=o=>{const s=new Set,u=e.trackedState;e.trackedState=s;try{const c=N(o.expr,e);e.state.set(o.name,c)}finally{e.trackedState=u}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||Tt(o.expression)||Za(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),a(s)}if(r.length===0)return;let n=!1;const i=e.state.subscribe(o=>{if(!n){n=!0;try{const s=new Set(o);for(let u=0;u<Yo;u+=1){let c=!1;for(const m of r){if(!yt(s,m.deps))continue;const f=e.state.get(m.name);a(m),e.state.get(m.name)!==f&&(s.add(m.name),c=!0)}if(!c)break}}finally{n=!1}}});e.disposers.push(i)}function Tt(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&Tt(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&Tt(e.value));case"Template":return t.expressions.length===0;default:return!1}}function Za(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function dr(t,e){switch(t.kind){case"ComponentDeclaration":{e.componentDecls.set(t.name,t),e.actionDecls.set(t.name,{kind:"ActionDeclaration",name:t.name,params:t.params,optimistic:!1,body:t.body,loc:t.loc});return}case"EffectDeclaration":e.effectDecls.set(t.name,t);return;case"ActionDeclaration":e.actionDecls.set(t.name,t);return;case"HookDeclaration":e.hookDecls.set(t.name,t);return;case"Await":case"Return":case"ExpressionStatement":return;case"Import":return;case"Assignment":{if(t.isState)return;e.expressions.set(t.identifier,t.expression);const r=t.expression;e.bindings.set(t.identifier,()=>N(r,e));return}}}function Qa(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ExpressionStatement":case"ThrowStatement":return!0;default:return!1}}function Jo(t,e){let r=!1;for(const a of t.statements)if(Qa(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&Tt(a.expression)&&e.state.set(a.identifier,At(a.expression));for(const a of t.statements)if(Qa(a))try{Nt(a,e)}catch(n){if(n instanceof we||n instanceof $e||n instanceof Ie)continue;if(n instanceof Pe)throw n;console.error("[aktion] top-level statement threw",n)}}}function Zo(t,e,r){const a=t[0];if(!a||a.kind!=="Object")return console.error('[aktion] $router expects an object literal of route arms (e.g. `$router({ "/": Home(), default: NotFound() })`).',r),e.router?.setActiveMatch(null,{}),null;const n=Ls(e);let i=null;for(const o of a.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const u=Fa(s,n);if(u.matched)return en(s,o.value,u.params,e)}return i?en(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function en(t,e,r,a){const n=a.loopVars.get("params"),i=a.loopVars.has("params");a.loopVars.set("params",r);try{const o=N(e,a);return a.router?.setActiveMatch(t,r),o}finally{i?a.loopVars.set("params",n):a.loopVars.delete("params")}}function At(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(At(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=At(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function N(t,e){switch(t.kind){case"Literal":return t.value;case"Identifier":{if(e.loopVars.has(t.name))return e.loopVars.get(t.name);if(e.mutableBindings.has(t.name))return e.mutableBindings.get(t.name);if(t.name==="route")return e.trackedState.add("route"),e.router?Rs(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const o=r();return e.mutableBindings.set(t.name,o),o}const a=e.actionDecls.get(t.name);if(a)return Cs(a,e);const n=e.componentDecls.get(t.name);if(n)return $s(n);if(Object.prototype.hasOwnProperty.call(nt,t.name))return nt[t.name];if(e.library&&Ne(e.library,t.name))return Ts(t.name);const i=qa(t.name);return i.found?i.value:null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(ir,t.name))return ir[t.name];const r=xe(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const a of t.elements){if(a.kind==="Spread"){const n=N(a.argument,e);if(Array.isArray(n))for(const i of n)r.push(i);else if(n!=null&&typeof n=="string")for(const i of n)r.push(i);continue}r.push(N(a,e))}return r}case"Object":{const r={};for(const a of t.properties){if(a.spread){const i=N(a.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const n=a.computedKey?String(N(a.computedKey,e)??""):a.key;r[n]=N(a.value,e)}return r}case"Member":{if(ss(t))return ls(t,e);const r=cs(t,e);if(r)return us(t,e,r);const a=N(t.object,e);if(t.optional&&a==null)return;if(t.computed){const n=N(t.computed,e);return fr(a,n)}return gr(a,t.property??"")}case"Unary":{if(t.operator==="delete"){const a=t.argument;if(a.kind==="Member"&&a.property){const n=N(a.object,e);if(n&&typeof n=="object")try{return delete n[a.property],!0}catch{return!1}}return!1}const r=N(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-O(r);case"+":return+O(r);case"~":return~oe(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return gs(t.operator,t.left,t.right,e);case"Ternary":{const r=N(t.test,e);return N(r?t.consequent:t.alternate,e)}case"Call":return bs(t.callee,t.arguments,e,t.loc);case"MethodCall":return hs(t,e);case"Invoke":return ps(t,e);case"New":return ms(t,e);case"BuiltinCall":return As(t.name,t.arguments,e);case"Template":return fs(t.quasis,t.expressions,e);case"Spread":return N(t.argument,e);case"Block":return pr(t,e,{});case"Lambda":{const r=t.params,a=t.body,n=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),u=e.stateAliases.slice();e.loopVars.clear();for(const[d,f]of i)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of n)e.stateAliases.push(d);const c=[],m=(d,f)=>{c.push({name:d,had:e.loopVars.has(d),prev:e.loopVars.get(d)}),e.loopVars.set(d,f)};for(let d=0;d<r.length;d+=1){const f=r[d];let g=o[d];if(g===void 0&&f.defaultValue&&(g=N(f.defaultValue,e)),f.pattern){for(const h of ot(f.pattern,g,e))m(h.name,h.value);continue}m(f.name,g)}try{return N(a,e)}finally{for(const d of c)d.had?e.loopVars.set(d.name,d.prev):e.loopVars.delete(d.name);e.loopVars.clear();for(const[d,f]of s)e.loopVars.set(d,f);e.stateAliases.length=0;for(const d of u)e.stateAliases.push(d)}}}default:return null}}class we{constructor(){j(this,"kind","break")}}class $e{constructor(){j(this,"kind","continue")}}class Ie{constructor(e){j(this,"kind","return");this.value=e}}function tn(t,e){if(N(t.test,e)){ke(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){tn(t.alternate,e);return}t.alternate.kind==="Block"&&ke(t.alternate.body,e)}}function Qo(t,e){const r=N(t.discriminant,e);let a=!1;try{for(const n of t.cases)a||(n.test===null||N(n.test,e)===r)&&(a=!0),a&&ke(n.body,e)}catch(n){if(n instanceof we)return;throw n}}function es(t,e){const r=N(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,u=t.destructure??[],c=u.map(m=>({name:m,had:e.loopVars.has(m),value:e.loopVars.get(m)}));try{let m=0;const d=(Array.isArray(r),r);for(const f of d){it(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,m);for(const g of u){const h=f&&typeof f=="object"?f[g]:void 0;e.loopVars.set(g,h)}try{ke(t.body.body,e)}catch(g){if(g instanceof $e){m+=1;continue}if(g instanceof we)return;throw g}m+=1}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const m of c)m.had?e.loopVars.set(m.name,m.value):e.loopVars.delete(m.name)}}function ts(t,e){for(t.init&&Mt(t.init,e);!(t.test&&!N(t.test,e));){it(e.budget,1,"`for` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof $e)){if(r instanceof we)return;throw r}}t.update&&N(t.update,e)}}function rs(t,e){for(;N(t.test,e);){it(e.budget,1,"`while` loop");try{ke(t.body.body,e)}catch(r){if(r instanceof $e)continue;if(r instanceof we)return;throw r}}}function as(t,e){for(;;){it(e.budget,1,"`do…while` loop");try{ke(t.body.body,e)}catch(r){if(!(r instanceof $e)){if(r instanceof we)return;throw r}}if(!N(t.test,e))break}}function ns(t,e){const r=N(t.expression,e),a=ot({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function ot(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const u of t.bindings){if(u.rest){a.push({name:u.name,value:o.slice(s)}),s=o.length;continue}let c=o[s];c===void 0&&u.defaultValue&&(c=N(u.defaultValue,r)),u.name!==""&&a.push({name:u.name,value:c}),s+=1}return a}const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const c={};for(const[m,d]of Object.entries(n))i.has(m)||(c[m]=d);a.push({name:o.name,value:c});continue}const s=o.sourceKey??o.name;i.add(s);let u=n[s];u===void 0&&o.defaultValue&&(u=N(o.defaultValue,r)),a.push({name:o.name,value:u})}return a}function is(t,e){const r=N(t.iterable,e);if(r==null||typeof r!="object")return;const a=e.loopVars.has(t.item),n=e.loopVars.get(t.item);try{for(const i in r){it(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{ke(t.body.body,e)}catch(o){if(o instanceof $e)continue;if(o instanceof we)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function os(t,e){try{ke(t.block.body,e)}catch(r){if(r instanceof we||r instanceof $e||r instanceof Ie)throw r;if(t.catchBlock){const a=t.catchParam,n=a?e.loopVars.has(a):!1,i=a?e.loopVars.get(a):void 0;a&&e.loopVars.set(a,r);try{ke(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&ke(t.finallyBlock.body,e)}}function ke(t,e){for(const r of t)Mt(r,e)}function Nt(t,e){Mt(t,e)}function Mt(t,e){switch(t.kind){case"ExpressionStatement":N(t.expression,e);return;case"Assignment":{const r=N(t.expression,e);if(t.identifier)if(t.isState){const a=xe(e,t.identifier);e.state.set(a,r)}else e.bindings.has(t.identifier)&&!e.loopVars.has(t.identifier)?e.mutableBindings.set(t.identifier,r):e.loopVars.set(t.identifier,r);return}case"IfStatement":tn(t,e);return;case"SwitchStatement":Qo(t,e);return;case"ForOfStatement":es(t,e);return;case"ForClassicStatement":ts(t,e);return;case"ForInStatement":is(t,e);return;case"WhileStatement":rs(t,e);return;case"DoWhileStatement":as(t,e);return;case"DestructureStatement":ns(t,e);return;case"TryStatement":os(t,e);return;case"BreakStatement":throw new we;case"ContinueStatement":throw new $e;case"ThrowStatement":throw N(t.argument,e);case"Return":{const r=t.argument?N(t.argument,e):void 0;throw new Ie(r)}case"Await":N(t.argument,e);return;default:return}}function ss(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&Object.prototype.hasOwnProperty.call(ir,e.name)?!1:e.kind==="StateRef"}function ls(t,e){const r=rn(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=xe(e,a.name);return an(r,n,e)}function rn(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function an(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,u=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(u=String(s))):s=N(o.computed,r):(s=o.property??"",u=o.property??"");const c=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&u!==null&&c?n.push(u):i=!1,a=o.computed?fr(a,s):gr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function cs(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=N(r,e);return St(a)?a:null}function us(t,e,r){const a=rn(t),n=a[0];if(n&&n.computed===void 0&&n.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,n.property)){let i=r.__methods[n.property];for(let o=1;o<a.length;o+=1){const s=a[o];s.computed?i=fr(i,N(s.computed,e)):i=gr(i,s.property??"")}return i}return an(a,r.__atom,e)}function ds(t,e,r){const a=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,n=e.stores.get(a);if(n)return n;const i=t[0]?N(t[0],e):{},o={},s={};if(i&&typeof i=="object"&&!Array.isArray(i))for(const[d,f]of Object.entries(i))typeof f=="function"?s[d]=f:o[d]=f;const u=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(u,o);const c={},m={__kind:"Store",__atom:u,__methods:c};for(const[d,f]of Object.entries(s))c[d]=(...g)=>f(m,...g);return e.stores.set(a,m),m}function nn(t,e){const r=[];let a=t;for(;a.kind==="Member";){if(a.computed){if(a.computed.kind!=="Literal")return null;const i=a.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(a.property)r.unshift(a.property);else return null;a=a.object}if(a.kind!=="Identifier")return null;const n=N(a,e);return St(n)?{atom:n.__atom,path:r}:null}function ps(t,e){if(t.callee.kind==="StateRef"){const n=t.callee.name;if(n==="state")return ws(t.arguments,e,t.loc);if(n==="memo")return ks(t.arguments,e,t.loc);switch(n){case"store":return ds(t.arguments,e,t.loc);case"router":return Zo(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return za(o?N(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:Ds(o?N(o,e):null)}}case"i18n":{const o=t.arguments[0],s=o?N(o,e):null,u=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return Da(u)}case"emit":{const o=t.arguments[0]?String(N(t.arguments[0],e)):"",s=t.arguments[1]?N(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&N(t.arguments[0],e),nr}const i=e.hookDecls.get(n);if(i)return Ss(i,t.arguments,e)}const r=N(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return r.apply(void 0,a)}catch(n){return console.error("[aktion] call expression threw",n),null}}function ms(t,e){const r=N(t.callee,e);if(typeof r!="function")return null;const a=[];for(const n of t.arguments){if(n.kind==="Spread"){const i=N(n.argument,e);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,e))}try{return Reflect.construct(r,a)}catch(n){return console.error("[aktion] `new` threw",n),null}}function pr(t,e,r){let a=null;const n=[];try{for(const i of t.body)switch(i.kind){case"ExpressionStatement":a=N(i.expression,e);continue;case"Assignment":{if(i.isState&&i.identifier){const s=xe(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const c=N(i.expression,e);e.state.declare(s,c),a=c;continue}const u=N(i.expression,e);e.state.set(s,u),a=u;continue}const o=N(i.expression,e);e.bindings.has(i.identifier)&&!e.loopVars.has(i.identifier)?e.mutableBindings.set(i.identifier,o):(e.loopVars.has(i.identifier)||n.push(i.identifier),e.loopVars.set(i.identifier,o)),a=o;continue}case"Return":return a=i.argument?N(i.argument,e):void 0,a;case"ThrowStatement":throw N(i.argument,e);case"EffectDeclaration":{const o=e.componentEffectStack[e.componentEffectStack.length-1];o?o.push({decl:i,capturedAliases:e.stateAliases.map(s=>new Map(s)),capturedLoopVars:new Map(e.loopVars)}):dr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":dr(i,e);continue;case"Await":continue;case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"DestructureStatement":Mt(i,e);continue}}catch(i){if(i instanceof Ie)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function fs(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=hr(N(e[n],r)),a+=t[n+1]??"";return a}function gs(t,e,r,a){if(t==="&&"){const o=N(e,a);return o&&N(r,a)}if(t==="||"){const o=N(e,a);return o||N(r,a)}if(t==="??"){const o=N(e,a);return o??N(r,a)}const n=N(e,a),i=N(r,a);switch(t){case"+":return typeof n=="string"||typeof i=="string"?hr(n)+hr(i):O(n)+O(i);case"-":return O(n)-O(i);case"*":return O(n)*O(i);case"/":{const o=O(i);return o===0?0:O(n)/o}case"%":{const o=O(i);return o===0?0:O(n)%o}case"**":return O(n)**O(i);case"==":case"===":return n===i;case"!=":case"!==":return n!==i;case">":return O(n)>O(i);case"<":return O(n)<O(i);case">=":return O(n)>=O(i);case"<=":return O(n)<=O(i);case"&":return oe(n)&oe(i);case"|":return oe(n)|oe(i);case"^":return oe(n)^oe(i);case"<<":return oe(n)<<(Le(i)&31);case">>":return oe(n)>>(Le(i)&31);case">>>":return Le(n)>>>(Le(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return n instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(n)in i}catch{return!1}}default:return null}}function oe(t){return O(t)|0}function Le(t){return O(t)>>>0}function hs(t,e){const r=N(t.object,e);if(r==null)return t.optional?void 0:null;const a=St(r)?r.__methods[t.method]:r[t.method];if(typeof a!="function")return null;const n=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=N(o.argument,e);if(Array.isArray(s))for(const u of s)n.push(u);continue}n.push(N(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Pe)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function bs(t,e,r,a){const n=r.componentDecls.get(t);if(n)return ys(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(h=>N(h,r));return sn(i,g,r)}if(t==="setTimeout"||t==="setInterval")return Ns(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?N(e[0],r):void 0;g!=null&&(t==="clearTimeout"?(clearTimeout(g),r.timers.timeouts.delete(g)):(clearInterval(g),r.timers.intervals.delete(g)));return}const o=r.loopVars.get(t);if(typeof o=="function"){const g=e.map(h=>N(h,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const h=e.map(b=>N(b,r));return g(...h)}}if(Object.prototype.hasOwnProperty.call(nt,t)&&typeof nt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ne(r.library,t))){const g=nt[t],h=[];for(const b of e){if(b.kind==="Spread"){const v=N(b.argument,r);if(Array.isArray(v))for(const y of v)h.push(y);continue}h.push(N(b,r))}try{return g(...h)}catch(b){return console.error(`[aktion] global "${t}" threw`,b),null}}if(r.library&&!Ne(r.library,t)){const g=qa(t);if(g.found&&typeof g.value=="function"){const h=g.value,b=[];for(const v of e){if(v.kind==="Spread"){const y=N(v.argument,r);if(Array.isArray(y))for(const x of y)b.push(x);continue}b.push(N(v,r))}try{return h(...b)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ne(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let u;const c=[...e];if(c.length>0){const g=c[c.length-1];if(g.kind==="Object"){const h=g.properties.find(b=>!b.spread&&b.key==="key");if(h){u=N(h.value,r);const b=g.properties.filter(v=>v!==h);b.length>0?c[c.length-1]={...g,properties:b}:c.pop()}}}const{args:m,argMeta:d}=vs(r,t,c);return{__kind:"Component",name:t,args:m,argMeta:d,explicitKey:u,source:a}}function vs(t,e,r){const a=t.library?Ne(t.library,e):void 0;if(!a){const f=r.map(h=>N(h,t)),g=r.map(h=>{const b=$t(h,t);return b!==null?{stateRef:b}:{}});return{args:f,argMeta:g}}const n=new Map;a.props.forEach((f,g)=>{if(n.set(f.name,g),f.aliases)for(const h of f.aliases)n.has(h)||n.set(h,g)});const i=Qt(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let u=-1;for(let f=r.length-1;f>=0;f-=1)if(r[f].kind==="Object"){u=f;break}for(let f=0;f<r.length;f+=1){if(f===u)continue;const g=r[f];s.push({expr:g,value:N(g,t)})}if(u>=0){const f=r[u];if(f.kind==="Object")for(const g of f.properties){if(g.spread)continue;const h=n.get(g.key);if(h===void 0)continue;const b=N(g.value,t);o[h].value=b,o[h].filled=!0;const v=$t(g.value,t);v!==null&&(o[h].meta={stateRef:v})}}if(s.length>0&&i>=0&&!o[i].filled){const{expr:f,value:g}=s.shift();o[i].value=g,o[i].filled=!0;const h=$t(f,t);h!==null&&(o[i].meta={stateRef:h})}let c=0;for(const{expr:f,value:g}of s){for(;c<a.props.length&&o[c].filled;)c+=1;if(c>=a.props.length)break;o[c].value=g,o[c].filled=!0;const h=$t(f,t);h!==null&&(o[c].meta={stateRef:h}),c+=1}const m=o.map(f=>f.value),d=o.map(f=>f.meta);for(;m.length>0&&m[m.length-1]===void 0;)m.pop(),d.pop();return{args:m,argMeta:d}}function ys(t,e,r,a){const n=[],i={};let o,s=-1;for(let h=e.length-1;h>=0;h-=1)if(e[h].kind==="Object"){s=h;break}let u=s>=0?e[s]:null,c=!1;if(u&&u.kind==="Object"){const h=new Set(t.params.map(b=>b.name));for(const b of u.properties)if(!b.spread&&(b.key==="key"||h.has(b.key))){c=!0;break}}c||(s=-1,u=null);for(let h=0;h<e.length;h+=1)h!==s&&n.push(e[h]);if(u&&u.kind==="Object")for(const h of u.properties)h.spread||(h.key==="key"?o=h.value:i[h.key]=h.value);const m=n.map(h=>h.kind==="Spread"?N(h.argument,r):N(h,r)),d=[];for(let h=0;h<n.length;h+=1){const b=n[h],v=m[h];if(b.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const f={};for(const[h,b]of Object.entries(i))f[h]=N(b,r);const g=o?N(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:f,explicitKey:g,source:a}}function on(t,e,r){const{decl:a,positional:n,named:i}=t,o=[],s=(f,g)=>{o.push({name:f,had:e.loopVars.has(f),prev:e.loopVars.get(f)}),e.loopVars.set(f,g)};for(let f=0;f<a.params.length;f+=1){const g=a.params[f];if(g.pattern){let b=n[f];b===void 0&&g.defaultValue&&(b=N(g.defaultValue,e));for(const v of ot(g.pattern,b,e))s(v.name,v.value);continue}let h;i[g.name]!==void 0?h=i[g.name]:n[f]!==void 0?h=n[f]:g.defaultValue?h=N(g.defaultValue,e):h=void 0,s(g.name,h)}if(n.length>a.params.length){const f=n.slice(a.params.length),g=f.length===1?f[0]:f;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}if(a.slots.length>0){const f={};for(const g of a.slots)i[g]!==void 0&&(f[g]=i[g]);o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",f)}const u=new Map;for(const f of a.body.body)if(f.kind==="Assignment"&&f.isState){const g=`${r}:${f.identifier}`;u.set(f.identifier,g)}e.stateAliases.push(u);const c=[];e.componentEffectStack.push(c);const m=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:pr(a.body,e,{stateAsDeclaration:!0}),effects:c,hooks:d.cursor}}finally{e.hookScope=m,e.componentEffectStack.pop(),e.stateAliases.pop();for(const f of o)f.had?e.loopVars.set(f.name,f.prev):e.loopVars.delete(f.name)}}function sn(t,e,r){return ln(t.params,t.body,e,r)}function ln(t,e,r,a){const n=[],i=(o,s)=>{n.push({name:o,had:a.loopVars.has(o),prev:a.loopVars.get(o)}),a.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let u=r[o];if(u===void 0&&s.defaultValue&&(u=N(s.defaultValue,a)),s.pattern){for(const c of ot(s.pattern,u,a))i(c.name,c.value);continue}i(s.name,u)}try{return pr(e,a,{stateAsDeclaration:a.state.isRendering()})}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}function cn(t){const e=t.hookScope;if(!e)return null;let r=t.hookStore.get(e.instanceKey);return r||(r=[],t.hookStore.set(e.instanceKey,r)),r}function xs(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function ws(t,e,r){const a=cn(e);if(!a)return dn("state",r),[t[0]?N(t[0],e):void 0,()=>{}];const n=e.hookScope.cursor++;let i=a[n];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?N(t[0],e):void 0},a[n]=i);const o=i,s=u=>{const c=typeof u=="function"?u(o.value):u;Object.is(c,o.value)||(o.value=c,e.notify?.())};return[o.value,s]}function ks(t,e,r){const a=t[0],n=t[1],i=()=>{const f=a?N(a,e):void 0;return typeof f=="function"?f():f},o=cn(e);if(!o)return dn("memo",r),i();const s=e.hookScope.cursor++,u=n?N(n,e):void 0,c=Array.isArray(u)?u:void 0,m=o[s];if(m&&m.kind==="memo"&&c&&m.deps&&xs(m.deps,c))return m.value;const d=i();return o[s]={kind:"memo",deps:c,value:d},d}function Ss(t,e,r){const a=[];for(const n of e){if(n.kind==="Spread"){const i=N(n.argument,r);if(Array.isArray(i))for(const o of i)a.push(o);continue}a.push(N(n,r))}return ln(t.params,t.body,a,r)}let un=!1;function dn(t,e){un||(un=!0,console.error(`[aktion] $${t}(...) was called outside a component render. Hooks may only be called at the top level of a component body or another $hook.`,e))}function pn(t,e){t.hookStore.delete(e)}function Cs(t,e){const r=e.stateAliases.map(n=>new Map(n)),a=new Map(e.loopVars);return(...n)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,u]of a)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return sn(t,n,e)}finally{e.loopVars.clear();for(const[s,u]of i)e.loopVars.set(s,u);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function $s(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function Ts(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function As(t,e,r){if(t==="__rui_assign__")return Ms(e,r);if(t==="__rui_postfix__")return Ps(e,r);if(t==="__rui_prefix__")return Is(e,r);if(t==="__rui_await__")return e[0]?N(e[0],r):void 0;const a=Aa[t];if(!a)return null;const n=e.map(i=>N(i,r));return a(n)}function Re(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:O(e)+O(r);case"-=":return O(e)-O(r);case"*=":return O(e)*O(r);case"/=":{const a=O(r);return a===0?0:O(e)/a}case"%=":{const a=O(r);return a===0?0:O(e)%a}case"**=":return O(e)**O(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return oe(e)&oe(r);case"|=":return oe(e)|oe(r);case"^=":return oe(e)^oe(r);case"<<=":return oe(e)<<(Le(r)&31);case">>=":return oe(e)>>(Le(r)&31);case">>>=":return Le(e)>>>(Le(r)&31);default:return r}}function Ns(t,e,r){const a=e[0]?N(e[0],r):null;if(typeof a!="function")return null;const n=a,i=e[1]?O(N(e[1],r)):0,o=[];for(let c=2;c<e.length;c+=1)o.push(N(e[c],r));const s=()=>{try{n(...o)}catch(c){console.error(`[aktion] ${t} callback threw`,c)}finally{r.notify?.()}};if(t==="setTimeout"){const c=setTimeout(()=>{r.timers.timeouts.delete(c),s()},i);return r.timers.timeouts.add(c),c}const u=setInterval(s,i);return r.timers.intervals.add(u),u}function Ms(t,e){const[r,a,n]=t;if(!r||!a)return null;const i=n&&n.kind==="Literal"?String(n.value??"="):"=",o=N(a,e);if(r.kind==="StateRef"){const s=xe(e,r.name),u=e.state.get(s),c=Re(i,u,o);return e.state.set(s,c),c}if(r.kind==="Member"){const s=Ct(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&Ra(d)){let h=d;for(let b=0;b<s.path.length-1;b+=1)h=h?.[s.path[b]];if(h&&typeof h=="object"){const b=s.path[s.path.length-1],v=h[b],y=Re(i,v,o);return h[b]=y,e.notify?.(),y}}const f=mr(d,s.path),g=Re(i,f,o);return e.state.setPath(s.name,s.path,g),g}const u=nn(r,e);if(u){const d=mr(e.state.get(u.atom),u.path),f=Re(i,d,o);return e.state.setPath(u.atom,u.path,f),f}const c=N(r.object,e),m=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(c&&typeof c=="object"&&m!=null){const d=c[String(m)],f=Re(i,d,o);return c[String(m)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const m=e.loopVars.get(s),d=Re(i,m,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=Re(i,m,o);return e.mutableBindings.set(s,d),d}const u=e.loopVars.get(s),c=Re(i,u,o);return e.loopVars.set(s,c),c}return o}function mr(t,e){let r=t;for(const a of e){if(r==null)return;if(Array.isArray(r)){const n=Number(a);r=Number.isNaN(n)?void 0:r[n];continue}if(typeof r=="object"){r=r[a];continue}return}return r}function mn(t,e,r){const[a,n]=t;if(!a)return null;const o=(n&&n.kind==="Literal"?String(n.value??"++"):"++")==="--"?-1:1;if(a.kind==="StateRef"){const s=xe(e,a.name),u=O(e.state.get(s)),c=u+o;return e.state.set(s,c),r==="prefix"?c:u}if(a.kind==="Member"){const s=Ct(a,e);if(s){const u=O(mr(e.state.get(s.name),s.path)),c=u+o;return e.state.setPath(s.name,s.path,c),r==="prefix"?c:u}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const m=O(e.loopVars.get(s)),d=m+o;return e.loopVars.set(s,d),r==="prefix"?d:m}if(e.bindings.has(s)||e.mutableBindings.has(s)){const m=O(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=m+o;return e.mutableBindings.set(s,d),r==="prefix"?d:m}const u=O(e.loopVars.get(s)),c=u+o;return e.loopVars.set(s,c),r==="prefix"?c:u}return null}function Ps(t,e){return mn(t,e,"postfix")}function Is(t,e){return mn(t,e,"prefix")}function Ls(t){if(t.trackedState.add("route"),t.router)return t.router.getPath();if(t.state.has("route")){const e=t.state.get("route");if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"&&"path"in e){const r=e.path;if(typeof r=="string"&&r)return r}}return"/"}function Rs(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof globalThis<"u"&&globalThis.location){const i=globalThis.location?.search??"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function fr(t,e){if(t!=null){if(Array.isArray(t)){const r=fn(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=fn(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function fn(t,e){let r;if(typeof t=="number")r=t;else if(typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t)))r=Number(t);else return null;return r<0&&(r=e+r),r<0||r>=e?null:r}function gr(t,e){if(t!=null){if(Array.isArray(t)){switch(e){case"length":return t.length;case"first":return t[0]??null;case"last":return t.length===0?null:t[t.length-1]}return t.map(r=>{if(r&&typeof r=="object")return r[e]})}if(typeof t=="string"&&e==="length")return t.length;if(typeof t=="object")return t[e]}}function O(t){if(typeof t=="number")return t;if(typeof t=="string"){if(t.trim()==="")return 0;const e=Number(t);return Number.isNaN(e)?0:e}return typeof t=="boolean"&&t?1:0}const Es=new Set(["colors","radius","font","motion","elevation"]),zs=new Set(["name","direction"]);function Ds(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[a,n]of Object.entries(r))if(n!=null&&!zs.has(a)&&Es.has(a)&&n&&typeof n=="object"&&!Array.isArray(n)){const i=a==="colors"?"color":a;for(const[o,s]of Object.entries(n)){if(s==null)continue;const u=i+js(o);e[u]=Bs(s)}}return e}function js(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function Bs(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function hr(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(typeof t=="object"&&t!==null){const e=t.toString;if(typeof e=="function"&&e!==Object.prototype.toString){const r=e.call(t);if(typeof r=="string")return r}}try{return JSON.stringify(t)}catch{return String(t)}}function gn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const br="::",Fs=new Map;class hn{constructor(e){j(this,"mounted",new Map);j(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const a=new Set(e.map(n=>n.name));for(const n of[...this.mounted.keys()])n.includes(br)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],Fs)}syncInstanceEffects(e,r,a){const n=`${e}${br}`,i=new Set(r.map(o=>`${n}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(n)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${n}${o.decl.name}`,u=this.mounted.get(s);if(u){u.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${br}`;for(const a of[...this.mounted.keys()])a.startsWith(r)&&this.unmount(a)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,a,n,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:a,capturedAliases:n,capturedLoopVars:i};this.mounted.set(e,o);const u=Os(()=>{for(const f of o.cleanups.splice(0))try{f()}catch(g){vn(e,g)}try{bn(r,a(),o,this.options)}catch(f){console.error(`[aktion] effect "${e}" failed`,f)}finally{this.options.notify()}},r.rateLimit,o);let c=!1,m=!1,d=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(c=!0),f.name==="unmount"&&(m=!0);break;case"every":{d=!0;const g=setInterval(u,f.intervalMs);o.intervals.push(g);break}case"state":{const g=Us(f.name,n),h=this.options.state.subscribe(b=>{rr(b,g)&&u()});o.unsubscribers.push(h);break}}(r.triggers.length===0||c||!d&&!m&&r.triggers.every(f=>f.kind==="state"))&&u()}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const n of r.intervals)clearInterval(n);for(const n of r.unsubscribers)try{n()}catch{}for(const n of r.cleanups)try{n()}catch(i){vn(e,i)}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount"))try{bn(r.decl,r.ctxRef(),r,this.options)}catch(n){console.error(`[aktion] effect "${e}" unmount body threw`,n)}}}function Os(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let i=null;const o=()=>{i&&(clearTimeout(i),i=null)};return r.cleanups.push(o),()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=null,t()},e.ms)}}let a=0,n=null;return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),()=>{const i=Date.now(),o=i-a;o>=e.ms?(a=i,t()):n||(n=setTimeout(()=>{n=null,a=Date.now(),t()},e.ms-o))}}function bn(t,e,r,a){const n=r.capturedAliases.length>0?e.stateAliases.slice():null;if(n){e.stateAliases.length=0;for(const o of r.capturedAliases)e.stateAliases.push(new Map(o))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[o,s]of r.capturedLoopVars)e.loopVars.set(o,s)}try{for(const o of t.body.body)_s(o,e,r,a)}finally{if(n){e.stateAliases.length=0;for(const o of n)e.stateAliases.push(o)}if(i){e.loopVars.clear();for(const[o,s]of i)e.loopVars.set(o,s)}}}function _s(t,e,r,a){switch(t.kind){case"ExpressionStatement":{const n=t.expression;if(n.kind==="Call"&&n.callee==="cleanup"){const i=n.arguments[0]?N(n.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(gn(n)){const i=n.arguments,o=i[0]?String(N(i[0],e)):"",s=i[1]?N(i[1],e):void 0;a.onEmit?.(o,s);return}return N(n,e)}case"Assignment":{const n=N(t.expression,e);if(t.identifier&&t.identifier!==""){const i=xe(e,t.identifier);e.state.set(i,n)}return n}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":Nt(t,e);return;default:return}}function vn(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function Us(t,e){const r=t.indexOf("."),a=r<0?t:t.slice(0,r),n=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(a);if(o!==void 0)return o+n}return t}class yn{constructor(e){this.options=e}async run(e,r,a){const n=[];for(let o=0;o<e.params.length;o+=1){const s=e.params[o],u=r[o];n.push({name:s.name,had:a.loopVars.has(s.name),prev:a.loopVars.get(s.name)}),a.loopVars.set(s.name,u)}const i=e.optimistic?Hs(this.options.state):null;try{let o;try{for(const s of e.body.body)o=await this.runStatement(s,a)}catch(s){if(s instanceof Ie)return this.options.notify(),s.value;throw s}return this.options.notify(),o}catch(o){if(o instanceof we||o instanceof $e){console.error(`[aktion] action "${e.name}" — \`${o.kind}\` outside a loop.`);return}throw i&&(Vs(this.options.state,i),this.options.notify()),console.error(`[aktion] action "${e.name}" failed`,o),o}finally{for(const o of n)o.had?a.loopVars.set(o.name,o.prev):a.loopVars.delete(o.name)}}async runStatement(e,r){switch(e.kind){case"ExpressionStatement":{const a=e.expression;if(gn(a)){const i=a.arguments,o=i[0]?String(N(i[0],r)):"",s=i[1]?N(i[1],r):void 0;this.options.onEmit?.(o,s);return}const n=N(a,r);return await Pt(n)}case"Await":{const a=N(e.argument,r);return await Pt(a)}case"Assignment":{const a=await Pt(N(e.expression,r));if(e.identifier)if(e.isState){const n=xe(r,e.identifier);this.options.state.set(n,a)}else r.loopVars.set(e.identifier,a);return a}case"Return":{if(!e.argument)throw new Ie(void 0);const a=await Pt(N(e.argument,r));throw new Ie(a)}case"IfStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"SwitchStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"BreakStatement":case"ContinueStatement":case"ThrowStatement":case"DestructureStatement":Nt(e,r);return;default:return}}}async function Pt(t){return t&&typeof t.then=="function"?await t:t}function Hs(t){const e=new Map;for(const[r,a]of t.entries())e.set(r,a);return e}function Vs(t,e){for(const[r,a]of e)t.set(r,a)}const Ws="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",xn="6.7.2",wn="data-rui-font-awesome",qs=new Set(["solid","regular","brands"]),kn="solid";function Gs(t){typeof document<"u"&&Sn(document.head,document),Sn(t,t.ownerDocument??document)}function Sn(t,e){if(Ks()||t.querySelector(`link[${wn}="${xn}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=Ws,a.setAttribute(wn,xn);try{t.appendChild(a)}catch{}}function Ks(){return typeof globalThis.happyDOM<"u"}function vr(t){if(typeof t!="string")return[];const e=Xs(t).trim();if(!e)return[];if(!Zs(e))return[];const[r,a]=Js(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const Ys=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Xs(t){return t.replace(Ys,"")}function Js(t){const e=t.indexOf(":");if(e===-1)return[kn,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return qs.has(r)?[r,a]:[kn,a||t]}function Zs(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const Qs=["xs","sm","md","lg","xl"];function l(t,e,r){const a=document.createElement(t);if(e)for(const[n,i]of Object.entries(e))i==null||i===!1||(n==="class"?a.setAttribute("class",String(i)):n==="html"?a.innerHTML=String(i):i===!0?a.setAttribute(n,""):a.setAttribute(n,String(i)));if(r)for(const n of r)n!=null&&a.append(typeof n=="string"?document.createTextNode(n):n);return a}function C(t){return Array.isArray(t)?t:t==null?[]:[t]}function p(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function T(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function L(t,e=0){if(typeof t=="number")return t;if(typeof t=="string"&&t.trim()!==""){const r=Number(t);if(!Number.isNaN(r))return r}return e}const Ke=["base","sm","md","lg","xl"];function fe(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let a=!1;for(const[n,i]of e)Ke.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const el=/["'\\\n\r<>;{}]/g;function tl(t){return t?t.replace(el,"").trim():""}const rl=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function te(t,e){const r=(p(t)??"").trim();return!r||r.length>64||!rl.test(r)?e:r}const al=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function nl(t){const e=p(t).trim();return!e||e.length>64||!al.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const il=new Set(["http","https","mailto","tel"]);function Ye(t,e="#"){const r=p(t).trim();if(!r)return e;const a=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!a||a.startsWith("//"))return e;if(a.startsWith("#")||a.startsWith("/")||a.startsWith("?")||a.startsWith("."))return a;const n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(a);if(!n)return a;const i=n[1].toLowerCase();return il.has(i)?a:e}const ol=new Set(["http","https","data","blob"]);function ne(t){const e=p(t).trim();if(!e)return"";const r=e.replace(/[\u0000-\u001F\u007F]/g,"");if(!r||r.startsWith("//"))return"";if(r.startsWith("/")||r.startsWith(".")||r.startsWith("?")||r.startsWith("#"))return r;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!a)return r;const n=a[1].toLowerCase();return!ol.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function sl(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function yr(t,e,r,a,n,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,a)}catch(c){console.error("[aktion] Col render() threw",c),s=null}const u=c=>{sl(c)?t.append(n.renderNode(c)):c!=null&&t.append(document.createTextNode(i(c,o)))};if(Array.isArray(s))for(const c of s)u(c);else u(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const c=m=>m.target?.closest("input,button,a,label,select,textarea")?!1:(m.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=m=>{c(m)},t.onkeydown=m=>{m.key!=="Enter"&&m.key!==" "||c(m)&&m.preventDefault()}}}function z(t,e={}){const r=p(t);if(!r)return null;const a=e.color?nl(e.color):"",n=a?`color:${a};`:null,i=vr(r),o=["rui-icon",e.className].filter(Boolean).join(" ");return i.length===0?l("span",{class:o,"data-icon-size":e.size??null,style:n},[r]):l("i",{class:`${o} ${i.join(" ")}`,"data-icon-size":e.size??null,style:n,"aria-hidden":"true"})}const st=12,ll={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},cl={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function ul(t){return ll[t]??"stretch"}function dl(t){return cl[t]??"flex-start"}function Cn(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Be(t,e,r){for(const a of Ke){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function pl(t,e,r,a){for(const n of Ke){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function $n(t,e,r,a){const n=fe(t);if(n.kind==="single"){const i=n.value?String(n.value):a.defaultToken;r[a.attrName]=i;return}r[a.attrName]="responsive",r[a.responsiveFlag]="true",pl(e,n,a.cssVarPrefix,a.mapper)}function ml(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function fl(t){const e=fe(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const gl={name:"StackItem",description:"Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one child so it can `grow` to fill leftover space, `shrink`, set a `basis`, override `alignSelf`, or change visual `order` — the building block for asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), saveButton])` (input expands, button hugs).",props:[{name:"child",type:"Node",description:"Child node to wrap"},{name:"grow",type:"number",optional:!0,description:"flex-grow (0 or 1 typical)"},{name:"shrink",type:"number",optional:!0,description:"flex-shrink (0 or 1 typical)"},{name:"basis",type:"string",optional:!0,description:"flex-basis (`auto`, `0`, or CSS length)"},{name:"alignSelf",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Per-item cross-axis alignment"},{name:"order",type:"number",optional:!0,description:"Visual order override"},{name:"minWidth",type:"string",optional:!0,description:"CSS min-width"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a={class:"rui-stack-item"},n=[];e.grow!==void 0&&e.grow!==null&&(a["data-grow"]=String(L(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(L(e.shrink,1)));const i=p(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${te(i,i)}`);const o=p(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const m=L(e.order,0);a["data-order"]=String(m),n.push(`order:${m}`)}const s=p(e.minWidth);s&&n.push(`min-width:${te(s,s)}`);const u=p(e.maxWidth);u&&n.push(`max-width:${te(u,u)}`),n.length>0&&(a.style=n.join(";"));const c=l("div",a);return c.append(r.renderNode(e.child)),c}};function xr(t,e,r,a,n){const i=fe(t),o=fe(a.gap),s=fe(a.padding),u=T(a.reverse),c={class:"rui-stack","data-wrap":T(a.wrap)?"true":null,"data-reverse":u?"true":null,"data-uniform":e?"true":"false","data-inline":T(a.inline)?"true":null},m=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";c["data-direction"]=Cn(g,u)}else{c["data-direction"]="responsive",c["data-responsive-dir"]="true";for(const g of Ke){const h=i.values[g];h&&m.push(`--rui-stack-dir-${g}:${Cn(String(h),u)}`)}}o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-stack-gap")),$n(a.align,m,c,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:ul}),$n(a.justify,m,c,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:dl});const d=p(a.alignContent);if(d&&(c["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(c["data-padding"]=g)}else c["data-padding"]="responsive",c["data-responsive-padding"]="true",Be(m,s,"--rui-stack-padding");m.length>0&&(c.style=m.join(";"));const f=l("div",c);for(const g of C(a.children))f.append(n.renderNode(g));return f}const hl={name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},wr={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},kr={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},Sr={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},Cr={name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."},$r={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},Tn={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},bl={name:"Row",description:"Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",props:[{name:"children",type:"Node[]",description:"Children laid out left → right"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Horizontal spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of children (default `center`). May be a responsive map."},{...wr},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...kr},{...Sr},{...Cr},{...$r},{...Tn}],render:(t,e,r)=>xr("row",T(e.grow),"center",e,r)},vl={name:"Column",description:"Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",props:[{name:"children",type:"Node[]",description:"Children laid out top → bottom"},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Vertical spacing between children (default `m`). May be a responsive map."},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of children (default `stretch`). May be a responsive map."},{...wr},{...kr},{...Sr},{...Cr},{...$r}],render:(t,e,r)=>xr("column",!1,"stretch",e,r)},yl={name:"Stack",description:'Low-level flex container with a configurable, optionally responsive `direction`. Reach for `Row` or `Column` first — they are clearer for fixed-direction layouts. Use `Stack` when the direction itself must change across breakpoints, e.g. `direction: {base: "column", md: "row"}` for a sidebar that stacks on mobile. `gap`, `align`, `justify`, and `padding` also accept responsive maps. NOTE: a `row` Stack grows its children equally by default (`uniform=true`); set `uniform=false` for natural widths (this is `Row`\'s default).',props:[{name:"children",type:"Node[]",description:"Child components to stack"},{name:"direction",type:"string | object",optional:!0,enum:["column","row"],description:'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.'},{...hl},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...wr},{...Tn},{...kr},{...Sr},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...$r},{...Cr}],render:(t,e,r)=>{const n=fl(e)==="row",i=e.uniform===void 0?n:T(e.uniform,n);return xr(e.direction,i,"stretch",e,r)}},xl={name:"Center",description:'Centers its children on both axes — the easy way to drop a spinner, an empty state, a hero call-to-action, or a modal body into the middle of a region. Give it `minHeight` (e.g. `"60vh"`) to center vertically inside a tall area, or `axis` to center on only one axis. Multiple children stack in a column and are centered as a group.',props:[{name:"children",type:"Node[]",description:"Content to center"},{name:"axis",type:"string",optional:!0,enum:["both","horizontal","vertical"],description:"Which axis to center on (default both)"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between stacked children (default `m`)"},{name:"padding",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token"},{name:"inline",type:"boolean",optional:!0,description:"Shrink to fit content instead of filling the available width"}],render:(t,e,r)=>{const a={class:"rui-center","data-axis":p(e.axis,"both"),"data-gap":p(e.gap,"m"),"data-inline":T(e.inline)?"true":null},n=p(e.padding);n&&(a["data-padding"]=n);const i=[],o=p(e.minHeight);o&&i.push(`min-height:${te(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const u of C(e.children))s.append(r.renderNode(u));return s}},wl={name:"Card",description:"Vertical card container.",props:[{name:"children",type:"Node[]",description:"Card contents"},{name:"variant",type:"string",optional:!0,enum:["default","outlined","elevated"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-card","data-variant":p(e.variant,"default")});for(const n of C(e.children))a.append(r.renderNode(n));return a}},kl={name:"CardHeader",description:"Card header with title and optional subtitle.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0}],render:(t,e)=>{const r=l("header",{class:"rui-card-header"});r.append(l("h3",{class:"rui-card-title"},[p(e.title)]));const a=p(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},Sl={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=l("footer",{class:"rui-card-footer"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Cl={name:"Separator",description:"Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",props:[{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"]},{name:"label",type:"string",optional:!0,description:"Optional label rendered in the middle (horizontal only)"},{name:"decorative",type:"boolean",optional:!0,description:"Hides the separator from assistive tech when true (default)"}],render:(t,e)=>{const r=p(e.orientation,"horizontal"),a=T(e.decorative,!0),n=p(e.label);return n&&r==="horizontal"?l("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r},[l("span",{class:"rui-separator-line"}),l("span",{class:"rui-separator-label"},[n]),l("span",{class:"rui-separator-line"})]):l("div",{class:"rui-separator","data-orientation":r,role:a?"presentation":"separator","aria-orientation":a?null:r})}},An=(t,e,r=!1)=>{const a=l("li",{class:"rui-steps-item","data-active":r?"true":"false"});return a.append(l("div",{class:"rui-steps-title"},[t])),e&&a.append(l("div",{class:"rui-steps-details"},[e])),a},$l={name:"Steps",description:"Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",props:[{name:"items",type:"object[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-steps"});for(const n of C(e.items)){if(n&&typeof n=="object"&&n.__kind==="Component"){a.append(r.renderNode(n));continue}if(n&&typeof n=="object"){const i=n;a.append(An(p(i.title),p(i.details),T(i.active)));continue}a.append(An(p(n),""))}return a}},Tl={name:"TabItem",description:"Single tab definition (used inside Tabs). Add `badge` for a count chip in the tab trigger, and `icon` for a leading Font Awesome icon.",props:[{name:"value",type:"string",description:"Stable identifier for the tab"},{name:"label",type:"string",description:"Display label"},{name:"children",type:"Node[]",description:"Tab content"},{name:"badge",type:"string",optional:!0,description:"Trailing chip rendered in the tab trigger (count / status)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tab-content",role:"tabpanel","data-value":p(e.value),"data-active":"false"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},Al={name:"Tabs",description:'Tabbed container. Children must be TabItem components. Supports `orientation="vertical"` for sidebar-style tabs and built-in keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to react when the user switches tabs (called with the new tab\'s value).',props:[{name:"items",type:"TabItem[]",description:"Tab definitions"},{name:"defaultValue",type:"string",optional:!0,description:"Initially active tab value"},{name:"orientation",type:"string",optional:!0,enum:["horizontal","vertical"],description:"Layout direction (default `horizontal`)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-activated tab value when the user switches tabs"}],render:(t,e,r)=>{const a=C(e.items),n=p(e.orientation,"horizontal"),i=l("div",{class:"rui-tabs","data-orientation":n}),o=l("div",{class:"rui-tab-list",role:"tablist","aria-orientation":n}),s=l("div",{class:"rui-tab-panels"});let u=p(e.defaultValue);if(!u&&a.length>0){const f=a[0];u=p(f?.args?.[0],"tab-0")}const c=r.useInstanceState("activeTab",u);p(e.defaultValue)&&p(e.defaultValue)!==u&&c.set(p(e.defaultValue)),new Set(a.map((f,g)=>p(f.args?.[0],`tab-${g}`))).has(c.get())||c.set(u);const d=(f,g)=>{const h=c.get();c.set(f);const b=g.closest(".rui-tabs");b&&(b.querySelectorAll(".rui-tab-trigger").forEach(v=>{const y=v.getAttribute("data-value")===f;v.setAttribute("aria-selected",y?"true":"false"),v.tabIndex=y?0:-1}),b.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===f?"true":"false")})),h!==f&&r.invoke(e.onChange,f)};return a.forEach((f,g)=>{const h=f,b=p(h.args?.[0],`tab-${g}`),v=p(h.args?.[1],`Tab ${g+1}`),y=p(h.args?.[3]),x=p(h.args?.[4]),w=b===c.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":b,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),A=x?Nl(x):null;A&&k.append(A),k.append(l("span",{class:"rui-tab-trigger-label"},[v])),y&&k.append(l("span",{class:"rui-tab-trigger-badge"},[y])),k.onclick=$=>{const M=$.currentTarget??$.target;d(b,M)},k.onkeydown=$=>{const M=$,I=n!=="vertical",E=I?M.key==="ArrowRight":M.key==="ArrowDown",D=I?M.key==="ArrowLeft":M.key==="ArrowUp";if(!E&&!D&&M.key!=="Home"&&M.key!=="End")return;M.preventDefault();const K=M.currentTarget??M.target,F=K.closest(".rui-tab-list");if(!F)return;const U=Array.from(F.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(K);let Z=J;M.key==="Home"?Z=0:M.key==="End"?Z=U.length-1:E?Z=(J+1)%U.length:D&&(Z=(J-1+U.length)%U.length);const de=U[Z];if(!de)return;de.focus();const Se=de.getAttribute("data-value")??"";Se&&d(Se,de)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",b),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function Nl(t){return z(t,{className:"rui-tab-trigger-icon"})}const Ml={name:"AccordionItem",description:"Single accordion section.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"open",type:"boolean",optional:!0},{name:"showArrow",type:"boolean",optional:!0,description:"Show a chevron icon on the right (default false). Inherits from parent Accordion when unset."}],render:(t,e,r)=>{const a=e.showArrow!==void 0&&e.showArrow!==null,n=l("details",{class:"rui-accordion-item","data-show-arrow":a?T(e.showArrow)?"true":"false":null});T(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[p(e.title)])),i.append(l("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),n.append(i);const o=l("div",{class:"rui-accordion-body"});for(const s of C(e.children))o.append(r.renderNode(s));return n.append(o),n}},Pl={name:"Accordion",description:"Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",props:[{name:"items",type:"AccordionItem[]"},{name:"showArrow",type:"boolean",optional:!0,description:"Show chevron icon on every item (default false)."}],render:(t,e,r)=>{const a=l("div",{class:"rui-accordion","data-show-arrow":T(e.showArrow)?"true":"false"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},It=t=>Math.max(1,Math.min(st,Math.round(t)));function Tr(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,a]=e.split("/"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return It(Math.round(st*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:It(L(t,12))}function Il(t){const e=p(t.minChildWidth)||p(t.minItemWidth);return te(e||"220px","220px")}const Ll={name:"GridItem",description:'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',props:[{name:"child",type:"Node",description:"Child node to place in the grid"},{name:"span",type:"number | string",optional:!0,description:'Columns to span (1–12) or fraction like "1/2", "1/3"'},{name:"offset",type:"number",optional:!0,description:"Empty columns before this item (0–11)"},{name:"spanAt",type:"object",optional:!0,description:"Responsive span map `{sm: 12, md: 6, lg: 4}`"}],render:(t,e,r)=>{const a=Tr(e.span??12),n=fe(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(st-1,Math.round(L(e.offset,0)))),o={class:"rui-grid-item","data-span":String(a)},s=[`--rui-grid-item-span:${a}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),n.kind==="responsive"){o["data-responsive-span"]="true";for(const c of Ke){const m=n.values[c];if(m!==void 0){const d=Tr(m);s.push(`--rui-grid-item-span-${c}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const c=Tr(n.value);s.push(`--rui-grid-item-span:${c}`),o["data-span"]=String(c)}o.style=s.join(";");const u=l("div",o);return u.append(r.renderNode(e.child)),u}},Rl={name:"Box",description:"Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",props:[{name:"children",type:"Node[]"},{name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Outer margin. May be a responsive map."},{name:"border",type:"string",optional:!0,enum:["none","subtle","default"],description:"Border preset (default none)"},{name:"background",type:"string",optional:!0,enum:["none","surface","muted","primary","success","warning","danger","info"],description:"Semantic background token"},{name:"maxWidth",type:"string",optional:!0,description:"CSS max-width"}],render:(t,e,r)=>{const a=fe(e.padding),n=fe(e.margin),i={class:"rui-box","data-border":p(e.border,"none"),"data-background":p(e.background,"none")},o=[],s=p(e.maxWidth);if(s&&o.push(`max-width:${te(s,s)}`),a.kind==="single"){const c=a.value?String(a.value):null;c&&(i["data-padding"]=c)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Be(o,a,"--rui-box-padding");if(n.kind==="single"){const c=n.value?String(n.value):null;c&&(i["data-margin"]=c)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Be(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const u=l("div",i);for(const c of C(e.children))u.append(r.renderNode(c));return u}},Nn={name:"Grid",description:'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',props:[{name:"children",type:"Node[]"},{name:"columns",type:"number | object",optional:!0,description:"Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`."},{name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Gap on both axes (default `m`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Column gap override. May be a responsive map."},{name:"minChildWidth",type:"string",optional:!0,aliases:["minItemWidth"],description:'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.'},{name:"alignItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Vertical alignment of items within their cells"},{name:"justifyItems",type:"string",optional:!0,enum:["start","center","end","stretch"],description:"Horizontal alignment of items within their cells"},{name:"dense",type:"boolean",optional:!0,description:"Dense auto-flow packing — let later items backfill earlier gaps"}],render:(t,e,r)=>{const a=C(e.children),n=a.some(v=>ml(v,"GridItem")),i=fe(e.columns),o=fe(e.gap),s=fe(e.rowGap),u=fe(e.columnGap),c={class:"rui-grid"},m=[];let d=!1,f=!1;if(i.kind==="single"){const v=i.value===null?0:L(i.value,0),y=v>0?It(v):0;if(y===st?d=!0:y>0&&(f=!0),y>0){c["data-columns"]=String(y);const x=p(e.minChildWidth)||p(e.minItemWidth);x&&(c["data-min-child-width"]="true",m.push(`--rui-grid-min-child:${te(x,"220px")}`))}else m.push(`--rui-grid-min-item:${Il(e)}`)}else{c["data-responsive-cols"]="true";for(const v of Ke){const y=i.values[v];if(y===void 0)continue;const x=It(L(y,0));x===st?d=!0:x>0&&(f=!0),m.push(`--rui-grid-cols-${v}:${x}`)}}n&&!f&&(d=!0),d&&(c["data-grid-mode"]="12"),o.kind==="single"?c["data-gap"]=o.value?String(o.value):"m":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",Be(m,o,"--rui-grid-gap")),s.kind==="single"&&s.value?c["data-row-gap"]=String(s.value):s.kind==="responsive"&&(c["data-row-gap"]="responsive",c["data-responsive-row-gap"]="true",Be(m,s,"--rui-grid-row-gap")),u.kind==="single"&&u.value?c["data-column-gap"]=String(u.value):u.kind==="responsive"&&(c["data-column-gap"]="responsive",c["data-responsive-column-gap"]="true",Be(m,u,"--rui-grid-column-gap"));const g=p(e.alignItems);g&&(c["data-align-items"]=g);const h=p(e.justifyItems);h&&(c["data-justify-items"]=h),T(e.dense)&&(c["data-dense"]="true"),m.length>0&&(c.style=m.join(";"));const b=l("div",c);for(const v of a)b.append(r.renderNode(v));return b}},El={name:"AspectRatio",description:"Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",props:[{name:"ratio",type:"string",description:"`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`"},{name:"children",type:"Node[]"}],render:(t,e,r)=>{const a=zl(p(e.ratio,"16:9")),n=l("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${a};`});for(const i of C(e.children))n.append(r.renderNode(i));return n}};function zl(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i!==0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Dl={name:"ScrollArea",description:"Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",props:[{name:"children",type:"Node[]"},{name:"maxHeight",type:"string",optional:!0,aliases:["height"],description:"CSS height (default 320px)"},{name:"direction",type:"string",optional:!0,enum:["vertical","horizontal","both"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-scroll-area","data-direction":p(e.direction,"vertical"),style:`max-height:${te(e.maxHeight,"320px")};`});for(const n of C(e.children))a.append(r.renderNode(n));return a}},jl={name:"Modal",description:"Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"Width preset (default `md`)"},{name:"footer",type:"Node[]",optional:!0,description:"Footer slot — typically a row of action Buttons"},{name:"closable",type:"boolean",optional:!0,description:"Render the header × button (default true)"},{name:"closeOnBackdrop",type:"boolean",optional:!0,description:"Close when the overlay is clicked (default false)"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the modal is closed (× button or backdrop)"}],render:(t,e,r)=>{const a=p(e.size,"md"),n=e.closable===void 0?!0:T(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":T(e.open)?"true":"false"}),o=l("div",{class:"rui-modal",role:"dialog","aria-modal":"true","data-size":a}),s=l("header",{class:"rui-modal-header"});s.append(l("h3",{class:"rui-modal-title"},[p(e.title)]));const u=t.argMeta?.[1]?.stateRef,c=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};if(n){const f=l("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);f.onclick=g=>{g.stopPropagation(),c()},s.append(f)}o.append(s);const m=l("div",{class:"rui-modal-body"});for(const f of C(e.children))m.append(r.renderNode(f));o.append(m);const d=C(e.footer);if(d.length>0){const f=l("footer",{class:"rui-modal-footer"});for(const g of d)f.append(r.renderNode(g));o.append(f)}return i.append(o),T(e.closeOnBackdrop)&&(i.onclick=f=>{f.target===i&&c()}),i}},Bl=["solid","regular","brands"],Lt=["xs","sm","md","lg","xl"],Fl=["default","neutral","primary","success","warning","danger","info"];function Ar(t,e="md"){const r=p(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":Lt.includes(r)?r:e:e}const Ol={name:"Icon",description:'Single Font Awesome icon. `name` is the FA name without the `fa-` prefix (e.g. `"house"`, `"chart-line"`). Use `variant` for non-solid styles (`regular`/`brands`) or prefix the name (`"regular:star"`). `color` accepts any CSS colour (`"#00ff00"`, `"tomato"`, `"var(--rui-color-primary)"`).',props:[{name:"name",type:"string",description:"FA name without the fa- prefix"},{name:"variant",type:"string",optional:!0,enum:Bl},{name:"size",type:"string",optional:!0,enum:Qs},{name:"color",type:"string",optional:!0,description:"CSS colour applied to the glyph (hex, named, rgb()/hsl(), or var(--token))"}],render:(t,e)=>{const r=p(e.name),a=p(e.variant,""),n=p(e.size,"md"),i=p(e.color,""),o=a?`${a}:${r}`:r,s=z(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},_l=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function Ul(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const Mn=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:_l},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations applied to the rendered element (e.g. "font-size: 16px; font-weight: bold; color: #000;").'}],Pn=(t,e)=>{const r=p(e.variant,"body"),a=p(e.tone,"default"),n=Ul(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[p(e.value)])},Hl={name:"Text",description:'Renders plain text with a typographic variant. Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:Mn,render:Pn},Vl={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:Mn,render:Pn},Wl={name:"Image",description:"Inline image. `ratio` constrains the box to a fixed aspect ratio (e.g. `16:9`, `1:1`) so callers do not need an outer `AspectRatio`. `fit` controls how the image fills that box. When `src` is missing or unsafe the component renders a placeholder (or `fallback` text/icon).",props:[{name:"src",type:"string"},{name:"alt",type:"string",optional:!0},{name:"caption",type:"string",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio shorthand (e.g. `16:9`, `1:1`, `4:3`)"},{name:"fit",type:"string",optional:!0,enum:["cover","contain","fill","none","scale-down"],description:"object-fit value (default `cover`)"},{name:"fallback",type:"string",optional:!0,description:"Text label or Font Awesome icon shown when src is missing/unsafe"}],render:(t,e)=>{const r=l("figure",{class:"rui-image","data-fit":p(e.fit,"cover"),style:e.ratio?`aspect-ratio:${ql(p(e.ratio))};`:null}),a=ne(e.src);if(a)r.append(l("img",{src:a,alt:p(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=p(e.fallback);if(o){const s=z(o,{className:"rui-image-fallback-icon"});s?i.append(s):i.append(l("span",{class:"rui-image-fallback-text"},[o]))}r.append(i)}const n=p(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function ql(t){if(!t)return"auto";if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const In=["neutral","primary","success","warning","danger","info"],Gl={name:"Badge",description:"Small pill-style tag for status, counts, categories. Accepts an optional leading `icon` and a `size`.",props:[{name:"label",type:"string",positional:!0},{name:"tone",type:"string",optional:!0,enum:In,aliases:["variant"],description:"Visual tone"},{name:"icon",type:"string",optional:!0,description:'Optional Font Awesome icon name (e.g. "star")'},{name:"size",type:"string",optional:!0,enum:Lt}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Ar(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=z(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=p(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},Kl={name:"BadgeList",description:"Cluster of Badge pills rendered from an array of strings.",props:[{name:"labels",type:"string[]",positional:!0,description:"Array of badge labels"},{name:"tone",type:"string",optional:!0,enum:In,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:Lt}],render:(t,e)=>{const r=p(e.tone,"neutral"),a=Ar(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of C(e.labels)){const o=p(i);if(!o)continue;const s=l("span",{class:"rui-badge","data-variant":r,"data-size":a});s.append(l("span",{class:"rui-badge-label"},[o])),n.append(s)}return n}},Yl={name:"Callout",description:"Highlighted callout banner with variant, title, description, and leading icon. Pass `compact: true` for a one-line inline-note rendering.",props:[{name:"tone",type:"string",optional:!0,enum:["neutral","info","success","warning","danger","error"],aliases:["variant"]},{name:"title",type:"string",positional:!0,required:!0},{name:"description",type:"string",optional:!0,aliases:["text"],description:"Body text"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"compact",type:"boolean",optional:!0,description:"Render with the dense, one-line note shape."}],render:(t,e)=>{const r=p(e.tone,"info"),a=T(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=p(e.icon)||Zl(r),o=z(i,{className:"rui-callout-icon"});o&&n.append(o);const s=l("div",{class:"rui-callout-body"});s.append(l("div",{class:"rui-callout-title"},[p(e.title)]));const u=p(e.description);return u&&s.append(l("div",{class:"rui-callout-description"},[u])),n.append(s),n}},Xl={name:"CodeBlock",description:'Read-only code block with a language label and a copy-to-clipboard button. Pass `showLineNumbers=true` to render a gutter; `highlightLines` accepts a string like `"3-5,8"` to emphasise specific lines.',props:[{name:"language",type:"string",optional:!0,description:"Display label (e.g. ts, bash)"},{name:"codeString",type:"string",positional:!0,required:!0,aliases:["code"],description:"Raw source text"},{name:"showLineNumbers",type:"boolean",optional:!0,description:"Render a left-side line-number gutter"},{name:"highlightLines",type:"string",optional:!0,aliases:["highlight"],description:'Highlight ranges, e.g. "3-5,8"'},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"}],render:(t,e)=>{const r=p(e.language),a=p(e.codeString),n=T(e.showLineNumbers),i=Jl(p(e.highlightLines)),o=e.copy===void 0?!0:T(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const c=l("div",{class:"rui-code-block-head"});if(r&&c.append(l("span",{class:"rui-code-block-language"},[r])),o){const m=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=z("copy",{className:"rui-code-block-copy-icon"});d&&m.append(d),m.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),m.onclick=f=>{const g=f.currentTarget??f.target,b=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(b).catch(()=>{});const x=g.querySelector(".rui-code-block-copy-label");if(x){const w=x.textContent??"Copy";x.textContent="Copied",setTimeout(()=>{x.textContent=w},1500)}},c.append(m)}s.append(c)}const u=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const c=a.split(/\r?\n/),m=l("code",{});c.forEach((d,f)=>{const g=f+1,h=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&h.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),h.append(l("span",{class:"rui-code-block-code"},[d])),m.append(h)}),u.append(m)}else u.append(l("code",{},[a]));return s.append(u),s}};function Jl(t){const e=new Set;if(!t)return e;for(const r of t.split(",")){const a=r.trim();if(a)if(a.includes("-")){const n=a.split("-").map(s=>Number(s.trim())),i=n[0]??NaN,o=n[1]??NaN;if(Number.isFinite(i)&&Number.isFinite(o)&&i<=o)for(let s=i;s<=o;s+=1)e.add(s)}else{const n=Number(a);Number.isFinite(n)&&e.add(n)}}return e}function Zl(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":case"error":return"circle-xmark";case"info":return"circle-info";default:return"circle-info"}}const Ql={name:"Skeleton",description:"Loading placeholder. Pass a `variant` for common shapes — `paragraph` (default), `card`, `table-row`, `avatar`, `image` — or use `shape` / `width` / `height` to build a custom one. All variants use a shimmer animation that respects `prefers-reduced-motion`.",props:[{name:"variant",type:"string",optional:!0,enum:["paragraph","card","table-row","avatar","image"]},{name:"lines",type:"number",optional:!0,aliases:["count"],description:"Lines for the `paragraph` variant (default 3)"},{name:"height",type:"number | string",optional:!0,description:"Line height in px (paragraph) or CSS height for custom shape"},{name:"shape",type:"string",optional:!0,enum:["rect","circle"],description:"Force a primitive shape (rect/circle)"},{name:"width",type:"string",optional:!0,description:"CSS width for shape-only skeletons"}],render:(t,e)=>{const r=p(e.variant),a=p(e.shape);if(a)return ec(a,e);if(r&&r!=="paragraph")return tc(r,e);const n=Number(e.lines),i=Math.max(1,Math.min(50,Number.isFinite(n)?Math.floor(n):3)),o=Number(e.height),s=Number.isFinite(o)&&o>0?Math.min(200,Math.floor(o)):12,u=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let c=0;c<i;c+=1)u.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return u}};function ec(t,e){const r=te(p(e.width),"100%"),a=p(e.height),n=a?te(a,"16px"):t==="circle"?r:"16px";return l("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${n};`})}function tc(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=te(p(e.width),"40px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${a};height:${a};`})),r}case"image":{const a=te(p(e.width),"100%"),n=te(p(e.height),"160px");return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${a};height:${n};`})),r}case"card":return r.append(l("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(l("div",{class:"rui-skeleton-line",style:"height:12px;width:60%;"})),r;case"table-row":{const a=Math.max(1,Math.min(8,Math.floor(Number(e.lines??4)))),n=l("div",{class:"rui-skeleton-row"});for(let i=0;i<a;i+=1)n.append(l("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(n),r}default:return r}}const rc={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (``), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=p(e.content),a=sc(r);return l("div",{class:"rui-markdown",html:a})}},ac={name:"Container",description:"Centered, max-width content wrapper. Use when a page is wider than comfortable reading width — landing pages, marketing sections, long documents. Picks a sensible default max-width per size; pass `maxWidth` to override with any CSS value.",props:[{name:"children",type:"Node[]"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg","xl","full"],description:"sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)"},{name:"maxWidth",type:"string",optional:!0,description:"Custom CSS max-width (overrides `size`)"},{name:"padding",type:"string",optional:!0,enum:["none","s","m","l"],description:"Horizontal padding (default m)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-container","data-size":p(e.size,"lg"),"data-padding":p(e.padding,"m"),style:e.maxWidth?`max-width:${te(e.maxWidth,"auto")};`:null});for(const n of C(e.children))a.append(r.renderNode(n));return a}},nc={name:"Spacer",description:'Explicit space element for fine layout control. By default acts as a flex spacer that pushes following content to the far edge (use inside `Stack(direction="row")`). Pass `size` to render a fixed vertical/horizontal gap instead.',props:[{name:"size",type:"string",optional:!0,enum:["xs","s","m","l","xl"],description:"Fixed gap; omit to flex-grow"},{name:"flex",type:"boolean",optional:!0,description:"Flex-grow even when size is set (default true when size omitted)"}],render:(t,e)=>{const r=p(e.size),a=e.flex===void 0?!r:T(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},ic={name:"Spinner",description:"Indeterminate inline loader. Use for tiny loading states inside buttons, toolbars, table cells, or chat bubbles where `Skeleton` and `Progress(indeterminate=true)` are too heavy. Pass `label` to render an inline caption beside the spinner (also announced via `aria-label`).",props:[{name:"size",type:"string",optional:!0,enum:Lt,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:Fl,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=Ar(e.size,"md"),a=p(e.tone,"primary"),n=p(e.label),i=l("span",{class:"rui-spinner","data-size":r,"data-tone":a,role:"status","aria-live":"polite","aria-label":n||"Loading"});return i.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),n&&i.append(l("span",{class:"rui-spinner-label"},[n])),i}},oc={name:"Quote",description:"Inline pull-quote with optional citation. Lighter than `Testimonial` — use inside articles, blog posts, marketing sections, or anywhere you need to highlight a sentence without the full quote/author/role + rating shape.",props:[{name:"text",type:"string"},{name:"cite",type:"string",optional:!0,aliases:["attribution","author"],description:"Attribution text shown below the quote"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=l("figure",{class:"rui-quote","data-tone":p(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[p(e.text)]));const a=p(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function sc(t){const e=g=>g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",u=[];const c=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},m=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(u.join(`
|
|
40
|
+
`))}</code></pre>`),u=[],s="",o=!1};for(const g of r){const h=/^```\s*(.*)$/.exec(g.trim());if(o){if(h){d();continue}u.push(g);continue}if(h){c(),m(),o=!0,s=h[1]??"";continue}const b=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(b){c(),m();const w=b[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${f(e(b[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){c(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${f(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&m();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){m(),n!=="ul"&&(c(),a.push("<ul>"),n="ul"),a.push(`<li>${f(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){m(),n!=="ol"&&(c(),a.push("<ol>"),n="ol"),a.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(g.trim()===""){c(),m();continue}c(),m(),a.push(`<p>${f(e(g))}</p>`)}return o&&d(),c(),m(),a.join("");function f(g){let h=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(b,v,y)=>{const x=ne(y);return x?`<img class="rui-markdown-image" src="${Rt(x)}" alt="${v}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${v}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(b,v,y)=>`<a class="rui-link" href="${Ln(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,b=>`<a class="rui-link" href="${Ln(b)}" target="_blank" rel="noopener noreferrer">${b}</a>`),h}}function Ln(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return Rt(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return Rt(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?Rt(e):"#"}function Rt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function lt(t,e,r){const a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=ne(t);if(n){const i=l("img",{src:n,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ct(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(e)]));return a}function ct(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(a=>a.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const Et=new WeakMap;function Xe(t){const{liveRoot:e,onDismiss:r}=t,a=Et.get(e);a&&a.dispose();const n=e.getRootNode();let i=!1;const o=d=>{const f=d.target;f&&e.contains(f)||(m.dispose(),r())},s=d=>{d.key==="Escape"&&(m.dispose(),r())},u=e.ownerDocument;let c=null;if(u&&typeof MutationObserver<"u"){c=new MutationObserver(()=>{e.isConnected||m.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&c.observe(d,{childList:!0,subtree:!0})}const m={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),c?.disconnect(),Et.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),Et.set(e,m),m}function Ae(t){if(!t)return;const e=Et.get(t);e&&e.dispose()}const lc=[{match:/\b(revenue|sales|sale|income|payment|charges?|invoices?|billing)\b/i,icon:"sack-dollar"},{match:/\b(profit|earnings?|margin|roi)\b/i,icon:"chart-line"},{match:/\b(customers?|clients?|users?|members?|people|accounts?)\b/i,icon:"users"},{match:/\b(visitors?|sessions?|traffic|page-?views?|impressions?)\b/i,icon:"chart-line"},{match:/\b(orders?|carts?|purchases?|transactions?)\b/i,icon:"cart-shopping"},{match:/\b(products?|inventory|sku|stock|items?)\b/i,icon:"box"},{match:/\b(subscriptions?|plans?|tiers?|pricing)\b/i,icon:"credit-card"},{match:/\b(emails?|messages?|inbox|threads?|mail)\b/i,icon:"envelope"},{match:/\b(notifications?|alerts?|reminders?)\b/i,icon:"bell"},{match:/\b(growth|trend|increase|up)\b/i,icon:"arrow-trend-up"},{match:/\b(decline|drop|down|decrease|loss)\b/i,icon:"arrow-trend-down"},{match:/\b(reports?|analytics|insights?|dashboards?|metrics?|stats?|kpis?)\b/i,icon:"chart-pie"},{match:/\b(charts?|graphs?)\b/i,icon:"chart-column"},{match:/\b(tasks?|todos?|backlog|kanban|sprint)\b/i,icon:"list-check"},{match:/\b(projects?|workspaces?)\b/i,icon:"folder-open"},{match:/\b(files?|folders?|documents?|docs?|attachments?)\b/i,icon:"folder-open"},{match:/\b(images?|photos?|gallery|albums?)\b/i,icon:"image"},{match:/\b(videos?|clips?|recordings?)\b/i,icon:"video"},{match:/\b(audio|music|podcasts?|sounds?)\b/i,icon:"music"},{match:/\b(calendars?|schedule|events?|meetings?|appointments?)\b/i,icon:"calendar-days"},{match:/\b(comments?|replies|feedback|reviews?|ratings?)\b/i,icon:"comments"},{match:/\b(settings?|preferences?|config|configuration|options?)\b/i,icon:"gear"},{match:/\b(security|privacy|password|locks?|secure)\b/i,icon:"shield-halved"},{match:/\b(api|integrations?|webhooks?|connections?)\b/i,icon:"plug"},{match:/\b(database|storage|backups?|servers?)\b/i,icon:"database"},{match:/\b(speed|performance|latency|response\s?time)\b/i,icon:"gauge-high"},{match:/\b(uptime|availability|status|health)\b/i,icon:"heart-pulse"},{match:/\b(errors?|bugs?|failures?|exceptions?|incidents?)\b/i,icon:"circle-exclamation"},{match:/\b(success|complete|done|approved)\b/i,icon:"circle-check"},{match:/\b(warnings?|caution)\b/i,icon:"triangle-exclamation"},{match:/\b(search|results?|queries)\b/i,icon:"magnifying-glass"},{match:/\b(downloads?|exports?)\b/i,icon:"download"},{match:/\b(uploads?|imports?)\b/i,icon:"upload"},{match:/\b(time|hours?|duration|elapsed)\b/i,icon:"clock"},{match:/\b(locations?|maps?|addresses?|countries?|regions?)\b/i,icon:"location-dot"},{match:/\b(stars?|favourites?|favorites?|highlights?)\b/i,icon:"star"},{match:/\b(trophy|awards?|achievements?|badges?|gold)\b/i,icon:"trophy"},{match:/\b(targets?|goals?|objectives?|quotas?)\b/i,icon:"bullseye"},{match:/\b(teams?|departments?|orgs?|organisations?|organizations?)\b/i,icon:"people-group"},{match:/\b(tickets?|issues?|bugs?|requests?)\b/i,icon:"ticket"},{match:/\b(deploys?|builds?|releases?|versions?)\b/i,icon:"rocket"}];function Rn(t){if(!t)return null;for(const e of lc)if(e.match.test(t))return e.icon;return null}const cc={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function uc(t){return t?cc[t.toLowerCase()]??null:null}function dc(t,e="shapes"){const r=t.trim()||"anon";return`https://api.dicebear.com/9.x/${/^[a-z0-9-]+$/i.test(e)?e:"shapes"}/svg?seed=${encodeURIComponent(r)}`}function En(t){return C(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=p(n.args[0]);return{value:i,label:p(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=p(n.value);return{value:i,label:p(n.label,i)}}}const a=p(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function Je(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=l("span",{class:"rui-wrapper-fragment"});for(const a of e)a!=null&&r.append(typeof a=="string"?document.createTextNode(a):t.renderNode(a));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function zt(t,e){return l("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function pc(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const mc=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function fc(t){return(Array.isArray(t)?t.map(r=>p(r)):p(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&mc.test(r))}const gc={name:"OnClick",description:"Make any component clickable. Wraps the child in a transparent span and dispatches `onClick(event)` when the user clicks or taps anywhere inside it. Use to attach click behaviour to components that do not expose an `action` / `onClick` prop (cards, list rows, media tiles, custom layouts).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component (or array of components) to wrap"},{name:"onClick",type:"callable",required:!0,aliases:["action","onclick"],description:"Callable invoked on click / tap. Receives the native MouseEvent."},{name:"disabled",type:"boolean",optional:!0,description:"Skip firing the handler while truthy"},{name:"stopPropagation",type:"boolean",optional:!0,description:"Call event.stopPropagation() after invoking the handler (default false)"}],render:(t,e,r)=>{const a=zt("rui-on-click",{role:"button",tabindex:"0"});a.append(Je(r,e.child));const n=T(e.disabled),i=T(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const u=s;(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(u))}),a}},hc=[{prop:"enter",event:"mouseenter"},{prop:"leave",event:"mouseleave"},{prop:"hover",event:"mouseover"},{prop:"move",event:"mousemove"},{prop:"down",event:"mousedown"},{prop:"up",event:"mouseup"},{prop:"click",event:"click"},{prop:"doubleClick",event:"dblclick"},{prop:"contextMenu",event:"contextmenu"},{prop:"scroll",event:"scroll"},{prop:"wheel",event:"wheel"},{prop:"drag",event:"drag"},{prop:"drop",event:"drop"},{prop:"dragStart",event:"dragstart"},{prop:"dragEnd",event:"dragend"},{prop:"dragEnter",event:"dragenter"},{prop:"dragLeave",event:"dragleave"},{prop:"dragOver",event:"dragover"}],bc={name:"OnMouse",description:"Attach any combination of mouse / pointer / drag listeners to a component. Pass only the props you need — unused events install no listener so the wrapper is essentially free. Each handler receives the native MouseEvent / DragEvent / WheelEvent. Use for hover tracking, custom drag-and-drop, context menus, scroll-aware UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"],description:"Component to wrap"},{name:"enter",type:"callable",optional:!0,description:"Fired when the pointer enters the element (mouseenter)"},{name:"leave",type:"callable",optional:!0,description:"Fired when the pointer leaves the element (mouseleave)"},{name:"hover",type:"callable",optional:!0,description:"Fired on every mouseover inside the element"},{name:"move",type:"callable",optional:!0,description:"Fired on every mousemove inside the element"},{name:"down",type:"callable",optional:!0,description:"Fired on mousedown"},{name:"up",type:"callable",optional:!0,description:"Fired on mouseup"},{name:"click",type:"callable",optional:!0,description:"Fired on click / tap"},{name:"doubleClick",type:"callable",optional:!0,description:"Fired on double-click"},{name:"contextMenu",type:"callable",optional:!0,description:"Fired on right-click (contextmenu)"},{name:"scroll",type:"callable",optional:!0,description:"Fired when an inner element scrolls"},{name:"wheel",type:"callable",optional:!0,description:"Fired on mouse-wheel / trackpad scroll"},{name:"drag",type:"callable",optional:!0,description:"Fired while the element is being dragged"},{name:"drop",type:"callable",optional:!0,description:"Fired when something is dropped onto the element"},{name:"dragStart",type:"callable",optional:!0,description:"Fired when a drag begins"},{name:"dragEnd",type:"callable",optional:!0,description:"Fired when a drag ends"},{name:"dragEnter",type:"callable",optional:!0,description:"Fired when a drag enters the element"},{name:"dragLeave",type:"callable",optional:!0,description:"Fired when a drag leaves the element"},{name:"dragOver",type:"callable",optional:!0,description:"Fired while something is dragged over the element. Call `event.preventDefault()` to make the element a valid drop target."},{name:"draggable",type:"boolean",optional:!0,description:'Make the wrapper itself draggable (sets `draggable="true"`)'},{name:"passiveScroll",type:"boolean",optional:!0,description:"Register scroll/wheel listeners as passive (default true for better scroll performance)"}],render:(t,e,r)=>{const a=zt("rui-on-mouse");T(e.draggable)&&a.setAttribute("draggable","true"),a.append(Je(r,e.child));const n=e.passiveScroll===void 0?!0:T(e.passiveScroll);for(const{prop:i,event:o}of hc){const s=e[i];if(s==null)continue;const c=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,m=>{r.invoke(s,m)},c)}return a}},vc=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],yc={name:"OnKeyboard",description:'Attach keyboard listeners to a component. Pass any combination of `onKeyDown`, `onKeyUp`, and `onKeyPress`; each handler receives the native KeyboardEvent. Use for keyboard shortcuts, navigation, and custom focusable widgets. The wrapper is focusable by default (tabindex="0") so it can be reached via Tab; pass `focusable=false` to disable when the child is already focusable.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onKeyDown",type:"callable",optional:!0,aliases:["onkeydown"],description:"Fired on keydown"},{name:"onKeyUp",type:"callable",optional:!0,aliases:["onkeyup"],description:"Fired on keyup"},{name:"onKeyPress",type:"callable",optional:!0,aliases:["onkeypress"],description:"Fired on keypress"},{name:"focusable",type:"boolean",optional:!0,description:"Make the wrapper focusable via Tab (default true)"}],render:(t,e,r)=>{const a=e.focusable===void 0?!0:T(e.focusable),n=zt("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(Je(r,e.child));for(const{prop:i,event:o}of vc){const s=e[i];s!=null&&n.addEventListener(o,u=>{r.invoke(s,u)})}return n}},xc={name:"OnFocus",description:"Attach focus / blur listeners to a component. Use to track input focus rings, custom focus indicators, or autosave-on-blur flows. Listens on the capture phase so blur from descendants is observed.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Fired when focus enters the element or any descendant"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Fired when focus leaves the element and all descendants"}],render:(t,e,r)=>{const a=zt("rui-on-focus");return a.append(Je(r,e.child)),e.onFocus!=null&&a.addEventListener("focusin",n=>r.invoke(e.onFocus,n)),e.onBlur!=null&&a.addEventListener("focusout",n=>r.invoke(e.onBlur,n)),a}},wc={name:"OnIntersect",description:"Observe whether a component is visible in the viewport (or a scroll container) using IntersectionObserver. Fires `onEnter` the first time the wrapped element becomes visible, `onLeave` when it leaves, and `onChange({visible, ratio})` for every transition. Use for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onEnter",type:"callable",optional:!0,description:"Fired when the element enters the viewport"},{name:"onLeave",type:"callable",optional:!0,description:"Fired when the element leaves the viewport"},{name:"onChange",type:"callable",optional:!0,description:"Fired with `{visible, ratio}` on every transition"},{name:"threshold",type:"number",optional:!0,description:"Visible-ratio threshold 0–1 (default 0.05)"},{name:"rootMargin",type:"string",optional:!0,description:'CSS-length root margin (e.g. "0px 0px -64px 0px")'},{name:"once",type:"boolean",optional:!0,description:"Disconnect after the first entry (default false)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});a.append(Je(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,L(e.threshold,.05))),o=p(e.rootMargin),s=T(e.once);let u=null;const c=new n(m=>{for(const d of m){const f=d.isIntersecting;if(f!==u&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,d),!f&&u===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),u=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:d.intersectionRatio}),s&&f){c.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return c.observe(a),r.registerDisposer(()=>c.disconnect()),a}};function kc(t,e){return e==null?[]:typeof e=="string"?[document.createTextNode(e)]:Array.isArray(e)?e.filter(r=>r!=null).map(r=>typeof r=="string"?document.createTextNode(r):t.renderNode(r)):[t.renderNode(e)]}const zn={name:"Link",description:'Anchor link. Accepts either a plain string label or a wrapped component as its positional child. Pass `to` for client-side router navigation (no page reload) or `href` for a regular anchor. `external: true` opens the link in a new tab with `rel="noopener noreferrer"`. Use to make any component clickable as a link — cards, icons, badges, list rows.',props:[{name:"label",type:"string | Node",positional:!0,required:!0,aliases:["child","children"],description:"Visible text OR a wrapped component"},{name:"to",type:"string",optional:!0,description:"Router path (preferred). Navigates via the runtime router on click."},{name:"href",type:"string",optional:!0,description:"Standard anchor href. Used when `to` is omitted."},{name:"external",type:"boolean",optional:!0,description:'Open in a new tab (`target="_blank"`, `rel="noopener noreferrer"`)'},{name:"variant",type:"string",optional:!0,enum:["default","subtle"]}],render:(t,e,r)=>{const a=p(e.to),n=T(e.external),i=a||p(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:Ye(i,"#"):Ye(e.href,"#"),s=p(e.variant,"default"),u=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const c of kc(r,e.label))u.append(c);return a&&!n&&u.addEventListener("click",c=>{c.defaultPrevented||c.button===0&&(c.metaKey||c.ctrlKey||c.shiftKey||c.altKey||(c.preventDefault(),r.router.navigate(a)))}),u}},Sc={name:"Css",description:"Apply raw CSS class names and / or an inline style string to a wrapped component. The styling is merged onto the rendered child's DOM element — no extra wrapper element is added unless the child is plain text (in which case the styling lands on a wrapping span). Reach for `Css` only when the component's own props cannot express the styling (use `Box`/`Stack`/`Grid` props for layout, `Theme` for tokens, `Styles` + selector classes for sweeping changes).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"style",type:"string",optional:!0,description:'Inline CSS declarations (e.g. "padding: 16px; background: #eef;")'},{name:"class",type:"string | string[]",optional:!0,aliases:["className","classes"],description:"Class name (space-separated string or array). Tokens must match `[A-Za-z_][A-Za-z0-9_-:/]*`."}],render:(t,e,r)=>{const a=Je(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=fc(e.class);for(const s of i)n.classList.add(s);const o=pc(e.style);if(o){const s=n.getAttribute("style");n.setAttribute("style",s?`${s};${o}`:o)}return n}};function ie(t,e,r,a){if(e==null)return;const n=a.event??"change";t.addEventListener(n,()=>{r.invoke(e,a.getValue(t))})}const Cc=["primary","secondary","ghost","danger"],$c=["xs","sm","md","lg","xl","small","normal","large"],Tc=["text","email","password","number","tel","url","date"];function Ac(t){const e=p(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}const Nc={name:"Button",description:"Clickable button. `onClick` (a callable) runs when the user presses the button. The legacy `action` prop is an alias and is still accepted.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked when the button is clicked"},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:Cc},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:$c,description:"Canonical `xs|sm|md|lg|xl` (legacy `small|normal|large` still accepted)"},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"},{name:"iconPosition",type:"string",optional:!0,enum:["leading","trailing"],description:"Icon placement (default leading)"},{name:"iconOnly",type:"boolean",optional:!0,description:"Hide the label visually (keeps aria-label)"},{name:"loading",type:"boolean",optional:!0,description:"Show spinner and disable interaction"},{name:"fullWidth",type:"boolean",optional:!0},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.loading),n=T(e.iconOnly),i=p(e.iconPosition,"leading"),o=p(e.label),s=l("button",{class:"rui-button",type:p(e.type,"button"),"data-variant":p(e.variant,"primary"),"data-size":Ac(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":T(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:T(e.disabled)||a?"":null}),u=l("span",{class:"rui-button-label"},[o]),c=z(e.icon,{className:"rui-button-icon"}),d=(a?z("spinner",{className:"rui-button-spinner"}):null)??c;return n?d&&s.append(d):i==="trailing"?(s.append(u),d&&s.append(d)):(d&&s.append(d),s.append(u)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},Mc={name:"Buttons",description:"Group of buttons laid out horizontally or vertically.",props:[{name:"items",type:"Button[]"},{name:"direction",type:"string",optional:!0,enum:["row","column"]}],render:(t,e,r)=>{const a=l("div",{class:"rui-buttons","data-direction":p(e.direction,"row")});for(const n of C(e.items))a.append(r.renderNode(n));return a}},Pc={name:"Input",description:"Text input field. Pass a $variable as `value` for two-way binding. `onChange(value)` fires on every keystroke with the current string.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:Tc},{name:"validations",type:"any",optional:!0,description:"Array or object of validation hints"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("input",{class:"rui-input",id:p(e.id),name:p(e.id),type:p(e.type,"text"),placeholder:p(e.placeholder),value:p(e.value)});return Fe(a,t,4,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),Kc(a,e.validations),a}},Ic={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=l("textarea",{class:"rui-textarea",id:p(e.id),name:p(e.id),placeholder:p(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=p(e.value),Fe(a,t,3,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},Lc={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:p(e.value)},[p(e.label)])},Rc={name:"Select",description:"Dropdown select. Pass a `$variable` as `value` for two-way binding. Set `searchable: true` for a combobox-style filter UI on long option lists. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"label",type:"string",optional:!0},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"any",optional:!0},{name:"searchable",type:"boolean",optional:!0,description:"Render as a filterable combobox"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{if(T(e.searchable))return Gc(t,e,r);const a=l("select",{class:"rui-select",id:p(e.id),name:p(e.id)}),n=p(e.placeholder);n&&a.append(l("option",{value:"",disabled:"",selected:""},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a.value=p(e.value),Fe(a,t,4,r),ie(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},Ec={name:"Checkbox",description:"Boolean checkbox. `onChange(checked)` fires with the new boolean state.",props:[{name:"id",type:"string"},{name:"label",type:"string"},{name:"value",type:"boolean",optional:!0,aliases:["checked"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=l("label",{class:"rui-checkbox"}),n=T(e.value),i=l("input",{type:"checkbox",id:p(e.id),name:p(e.id),checked:n?"":null});return i.checked=n,Fe(i,t,2,r),ie(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[p(e.label)])),a}},zc={name:"CheckBoxItem",description:"Single option inside a CheckBoxGroup.",props:[{name:"label",type:"string"},{name:"name",type:"string",description:"Key inside the group's value object"},{name:"description",type:"string",optional:!0},{name:"defaultChecked",type:"boolean",optional:!0,aliases:["checked"]}],render:(t,e)=>{const r=p(e.name),a=p(e.label),n=p(e.description),i=T(e.defaultChecked),o=l("label",{class:"rui-checkbox-item","data-name":r}),s=l("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const u=l("div",{class:"rui-checkbox-item-text"});return u.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&u.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,u),o}},Dc={name:"CheckBoxGroup",description:"Group of checkboxes. Value is an object keyed by item name. Pass a `$variable` for two-way binding. `onChange(value)` fires with the full updated object.",props:[{name:"name",type:"string",description:"Group identifier"},{name:"items",type:"CheckBoxItem[]"},{name:"value",type:"any",optional:!0,description:"Bound value (typically $variable)"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated `{name: checked}` object when any item toggles"}],render:(t,e,r)=>{const a=p(e.name),n=l("div",{class:"rui-checkbox-group",role:"group","data-name":a}),i=C(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((c,m)=>{const d=p(c.args?.[0]),f=p(c.args?.[1],`${a}-${m}`),g=p(c.args?.[2]),h=T(c.args?.[3]),b=`${a}-${f}`,v=l("label",{class:"rui-checkbox-item",for:b}),y=f in o?!!o[f]:h,x=l("input",{type:"checkbox",id:b,name:f,checked:y?"":null}),w=l("div",{class:"rui-checkbox-item-text"});w.append(l("div",{class:"rui-checkbox-item-label"},[d])),g&&w.append(l("div",{class:"rui-checkbox-item-description"},[g])),v.append(x,w),n.append(v)});const s=t.argMeta?.[2]?.stateRef,u=c=>{const m={};return c.querySelectorAll('input[type="checkbox"]').forEach(d=>{m[d.name]=d.checked}),m};return s&&r.bindState(n,s,{event:"change",getValue:u}),ie(n,e.onChange,r,{event:"change",getValue:c=>u(c)}),n}},jc={name:"Radio",description:"Radio button group. `onChange(value)` fires with the newly-selected option value.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]"},{name:"value",type:"any",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected radio value"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of C(e.items)){const o=p(i.args?.[0]),s=p(i.args?.[1],o),u=`${a}-${o}`,c=l("label",{class:"rui-radio",for:u}),m=p(e.value)===o,d=l("input",{type:"radio",id:u,name:a,value:o,checked:m?"":null});d.checked=m,Fe(d,t,2,r),ie(d,e.onChange,r,{event:"change",getValue:f=>f.value}),c.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(c)}return n}},Bc={name:"FormControl",description:"Labeled wrapper around a single form field.",props:[{name:"label",type:"string"},{name:"field",type:"Node",aliases:["control"]},{name:"hint",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-form-control"});a.append(l("label",{class:"rui-form-label"},[p(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=p(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},Dn={name:"SearchBar",description:"Pre-styled search input with a leading magnifying-glass icon, optional trailing submit button, and optional keyboard-shortcut hint. Pass a `$variable` as `value` for two-way binding. Use anywhere a user needs to filter content — toolbars, command bars, lists, headers.",props:[{name:"id",type:"string"},{name:"placeholder",type:"string",optional:!0},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"shortcut",type:"string",optional:!0,description:'Keyboard hint chip on the right (e.g. "/")'},{name:"onSubmit",type:"callable",optional:!0,aliases:["action","onClick"],description:"Optional submit callable; clicking the trailing button or pressing Enter invokes it"},{name:"submitLabel",type:"string",optional:!0,description:'Label for the trailing submit button (default "Search"). Omitted when no action is provided.'},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current query on every keystroke"}],render:(t,e,r)=>{const a=l("form",{class:"rui-search-bar",role:"search"});a.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const n=z("magnifying-glass",{className:"rui-search-bar-icon"})??l("span",{class:"rui-search-bar-icon","aria-hidden":"true"});a.append(n);const i=l("input",{class:"rui-search-bar-input",id:p(e.id),name:p(e.id),type:"search",placeholder:p(e.placeholder,"Search…"),value:p(e.value),autocomplete:"off"});Fe(i,t,2,r),ie(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=p(e.shortcut);if(o&&a.append(l("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=l("button",{type:"submit",class:"rui-search-bar-submit"},[p(e.submitLabel,"Search")]);a.append(s)}return a}},Fc={name:"Form",description:'Form container. Children FormControls render in order; buttons render at the bottom. Provide `onSubmit` to handle form submission (invoked when the user presses Enter on a focused input or clicks a `type="submit"` Button inside the form).',props:[{name:"id",type:"string"},{name:"buttons",type:"Buttons | Button"},{name:"fields",type:"FormControl[]"},{name:"onSubmit",type:"callable",optional:!0,aliases:["onsubmit"],description:"Called when the form is submitted (Enter key or submit button)"}],render:(t,e,r)=>{const a=l("form",{class:"rui-form",id:p(e.id)});a.onsubmit=n=>{n.preventDefault(),r.invoke(e.onSubmit)};for(const n of C(e.fields))a.append(r.renderNode(n));if(e.buttons){const n=l("div",{class:"rui-form-actions"});n.append(r.renderNode(e.buttons)),a.append(n)}return a}},Oc={name:"Slider",description:"Range slider for selecting a single numeric value between `min` and `max`. Pass a `$variable` as `value` for two-way binding. Useful for filters, settings (volume, brightness), and parameter tuning.",props:[{name:"id",type:"string"},{name:"min",type:"number",optional:!0,description:"Default 0"},{name:"max",type:"number",optional:!0,description:"Default 100"},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Render the current numeric value beside the slider"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number as the user drags"}],render:(t,e,r)=>{const a=p(e.id),n=L(e.min,0),i=L(e.max,100),o=L(e.step,1),s=L(e.value,n),u=l("div",{class:"rui-slider","data-disabled":T(e.disabled)?"true":"false"}),c=p(e.label),m=T(e.showValue);if(c||m){const g=l("div",{class:"rui-slider-head"});c&&g.append(l("label",{class:"rui-slider-label",for:a},[c])),m&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),u.append(g)}const d=l("input",{type:"range",class:"rui-slider-input",id:a,name:a,min:String(n),max:String(i),step:String(o),value:String(s),disabled:T(e.disabled)?"":null});d.oninput=g=>{const h=g.currentTarget;if(!h)return;const v=h.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=h.value)};const f=t.argMeta?.[4]?.stateRef;return f&&r.bindState(d,f,{event:"input",getValue:g=>Number(g.value)}),ie(d,e.onChange,r,{event:"input",getValue:g=>Number(g.value)}),u.append(d),u}},_c={name:"NumberInput",description:'Numeric input with paired increment/decrement buttons. Use for quantity steppers, integer settings, and any field where a `<input type="number">` plus +/- controls is friendlier than the native spinner. Pass a `$variable` as `value` for two-way binding.',props:[{name:"id",type:"string"},{name:"value",type:"number",optional:!0,description:"Bound value (typically $variable)"},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0,description:"Default 1"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new number (or null when blank)"}],render:(t,e,r)=>{const a=p(e.id),n=L(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?L(e.min,0):Number.NEGATIVE_INFINITY,u=o?L(e.max,0):Number.POSITIVE_INFINITY,c=T(e.disabled),m=l("div",{class:"rui-number-input","data-disabled":c?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:c?"":null},["−"]),f=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:p(e.value),placeholder:p(e.placeholder),min:i?String(s):null,max:o?String(u):null,step:String(n),disabled:c?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:c?"":null},["+"]),h=t.argMeta?.[1]?.stateRef,b=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};h&&r.bindState(f,h,{event:"input",getValue:b}),ie(f,e.onChange,r,{event:"input",getValue:b});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const A=Number(k.value),S=Number.isFinite(A)?A:0,$=qc(S+x,s,u);k.value=String($),k.dispatchEvent(new Event("input",{bubbles:!0}))};return d.onclick=y=>v(y.currentTarget??y.target,-n),g.onclick=y=>v(y.currentTarget??y.target,n),m.append(d,f,g),m}},Uc={name:"DatePicker",description:'Date picker that wraps the native `<input type="date">` with consistent styling. Pass a `$variable` as `value` for two-way binding. Use `min`/`max` to bound the selectable range.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date (YYYY-MM-DD); typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest ISO date"},{name:"max",type:"string",optional:!0,description:"Latest ISO date"},{name:"placeholder",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO date string when the picker changes"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-date-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-date-picker-label",for:a},[i]));const o=l("input",{type:"date",class:"rui-date-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,placeholder:p(e.placeholder),disabled:T(e.disabled)?"":null});return Fe(o,t,1,r),ie(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},Hc={name:"FileUpload",description:'Styled file picker. Renders a click/drop area with a leading icon, label, and helper text. Files cannot round-trip through `$variables` (they are not serialisable), so pass a callable as `action` to handle the picked files via `ctx.query("#id").files`.',props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0,description:'Primary label (default "Choose a file")'},{name:"hint",type:"string",optional:!0,description:"Secondary helper text"},{name:"accept",type:"string",optional:!0,description:"Comma-separated MIME types or extensions"},{name:"multiple",type:"boolean",optional:!0},{name:"onSelect",type:"callable",optional:!0,aliases:["action","onChange"],description:"Callable fired with the FileList when files are picked"},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon (default "cloud-arrow-up")'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=p(e.id),n=T(e.disabled),i=l("div",{class:"rui-file-upload","data-disabled":n?"true":"false"}),o=l("label",{class:"rui-file-upload-dropzone",for:a}),s=z(p(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const u=l("div",{class:"rui-file-upload-text"});u.append(l("div",{class:"rui-file-upload-label"},[p(e.label,"Choose a file")]));const c=p(e.hint);c&&u.append(l("div",{class:"rui-file-upload-hint"},[c])),o.append(u);const m=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:p(e.accept)||null,multiple:T(e.multiple)?"":null,disabled:n?"":null});o.append(m),i.append(o);const d=(f,g)=>g.includes("image")||f.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(f.name);return m.onchange=f=>{const g=f.currentTarget;r.invoke(e.onSelect,g.files);const h=g.closest(".rui-file-upload");if(!h)return;const b=g.files,v=h.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!b||b.length===0)return;const y=p(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(b).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const A=URL.createObjectURL(w),S=l("img",{src:A,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(A),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),h.append(x)},i}},jn={name:"Combobox",description:"Searchable single-select dropdown — type to filter, click an option to choose. Use instead of `Select` when the list is long enough that scanning is faster than scrolling (countries, currencies, repos, users). Pass a `$variable` as `value` for two-way binding; the selected option's `value` is written to state on pick.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"string",optional:!0,description:"Bound selected value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:'Text shown when no items match the filter (default "No matches")'},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=p(e.id),n=En(e.items),i=p(e.value),o=n.find(S=>S.value===i)?.label??i,s=p(e.placeholder,"Select…"),u=p(e.emptyLabel,"No matches"),c=T(e.disabled),m=T(e.open),d=r.useInstanceState("open",m),f=r.useInstanceState("filter",""),g=d.get(),h=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":c?"true":"false"}),b=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:c?"":null});b.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=z("chevron-down",{className:"rui-combobox-chevron"});v&&b.append(v),h.append(b);const y=l("div",{class:"rui-combobox-panel",role:"listbox"}),x=l("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:f.get()});y.append(x);const w=l("div",{class:"rui-combobox-list"});y.append(w);const k=(S,$)=>{S.replaceChildren();const M=$.trim().toLowerCase(),I=M===""?n:n.filter(E=>E.label.toLowerCase().includes(M)||E.value.toLowerCase().includes(M));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[u]));return}for(const E of I){const D=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":E.value,"aria-selected":E.value===i?"true":"false"},[E.label]);D.onclick=K=>{K.stopPropagation(),A(K.currentTarget,E.value)},S.append(D)}},A=(S,$)=>{const M=t.argMeta?.[2]?.stateRef;M&&r.setState(M,$),r.invoke(e.onChange,$),d.set(!1),f.set("");const I=S.closest(".rui-combobox");I?.setAttribute("data-open","false"),I?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ae(I)};return k(w,f.get()),x.oninput=S=>{const $=S.currentTarget;f.set($.value);const M=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");M&&k(M,$.value)},x.onkeydown=S=>{const $=S;if($.key!=="Enter")return;$.preventDefault();const E=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),D=E?.getAttribute("data-value");D!=null&&E&&A(E,D)},b.onclick=S=>{if(c)return;S.stopPropagation();const $=!d.get();d.set($);const M=S.currentTarget.closest(".rui-combobox");if(M?.setAttribute("data-open",$?"true":"false"),M?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!M){if(!$){Ae(M);return}setTimeout(()=>x.focus(),0),Xe({liveRoot:M,onDismiss:()=>{d.set(!1),f.set(""),M.setAttribute("data-open","false"),M.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(y),h}},Vc={name:"MultiSelect",description:"Multi-option searchable dropdown. Type to filter, click an option to add/remove it from the bound array. Renders the selected options as removable chips inside the trigger. Pass a `$variable` (array of values) as `value` for two-way binding.",props:[{name:"id",type:"string"},{name:"items",type:"SelectItem[]",description:"Options; SelectItem(value, label) or {value, label}"},{name:"value",type:"any[]",optional:!0,description:"Bound array of selected values (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no items match the filter"},{name:"max",type:"number",optional:!0,description:"Maximum number of selections"},{name:"disabled",type:"boolean",optional:!0},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the dropdown"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of selected values"}],render:(t,e,r)=>{const a=p(e.id),n=En(e.items),i=p(e.placeholder,"Select…"),o=p(e.emptyLabel,"No matches"),s=T(e.disabled),u=Math.max(0,Math.floor(Number(e.max??0))),c=Array.isArray(e.value)?e.value.map(I=>p(I)).filter(Boolean):[],m=new Set(c),d=t.argMeta?.[2]?.stateRef,f=T(e.open),g=r.useInstanceState("open",f),h=r.useInstanceState("filter",""),b=g.get(),v=l("div",{class:"rui-multiselect","data-open":b?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":b?"true":"false",disabled:s?"":null}),x=l("span",{class:"rui-multiselect-chips"}),w=I=>{d&&r.setState(d,I),r.invoke(e.onChange,I)};if(c.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of c){const E=n.find(F=>F.value===I)?.label??I,D=l("span",{class:"rui-multiselect-chip","data-value":I});D.append(l("span",{class:"rui-multiselect-chip-label"},[E]));const K=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${E}`},["×"]);K.onclick=F=>{F.stopPropagation();const U=c.filter(J=>J!==I);w(U)},D.append(K),x.append(D)}y.append(x);const k=z("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const A=l("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=l("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:h.get()});A.append(S);const $=l("div",{class:"rui-multiselect-list"});A.append($);const M=(I,E)=>{I.replaceChildren();const D=E.trim().toLowerCase(),K=D===""?n:n.filter(F=>F.label.toLowerCase().includes(D)||F.value.toLowerCase().includes(D));if(K.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const F of K){const U=m.has(F.value),J=!U&&u>0&&c.length>=u,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":F.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),de=l("span",{class:"rui-multiselect-option-check"}),Se=z(U?"check":"",{className:"rui-multiselect-option-check-icon"});Se&&de.append(Se),Z.append(de),Z.append(l("span",{class:"rui-multiselect-option-label"},[F.label])),Z.onclick=ft=>{if(ft.stopPropagation(),J)return;const He=U?c.filter(Wr=>Wr!==F.value):[...c,F.value];w(He)},I.append(Z)}};return M($,h.get()),S.oninput=I=>{const E=I.currentTarget;h.set(E.value);const D=E.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");D&&M(D,E.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const E=!g.get();g.set(E);const D=I.currentTarget.closest(".rui-multiselect");if(D?.setAttribute("data-open",E?"true":"false"),D?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",E?"true":"false"),!!D){if(!E){Ae(D);return}setTimeout(()=>S.focus(),0),Xe({liveRoot:D,onDismiss:()=>{g.set(!1),h.set(""),D.setAttribute("data-open","false"),D.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(A),v}},Wc={name:"DateRangePicker",description:"Paired date inputs with a single label, sharing the same min/max range. Pass `$variable` references for both `from` and `to` to two-way-bind a date range (ISO `YYYY-MM-DD` strings).",props:[{name:"id",type:"string"},{name:"from",type:"string",optional:!0,description:"ISO date start; typically $variable"},{name:"to",type:"string",optional:!0,description:"ISO date end; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0,description:"Earliest selectable ISO date"},{name:"max",type:"string",optional:!0,description:"Latest selectable ISO date"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with `{from, to}` whenever either endpoint changes"}],render:(t,e,r)=>{const a=p(e.id),n=`${a}-from`,i=`${a}-to`,o=p(e.min),s=p(e.max),u=T(e.disabled),c=l("div",{class:"rui-date-range-picker","data-disabled":u?"true":"false"}),m=p(e.label);m&&c.append(l("label",{class:"rui-date-range-picker-label",for:n},[m]));const d=l("div",{class:"rui-date-range-picker-row"}),f=l("input",{type:"date",class:"rui-date-range-picker-input",id:n,name:n,value:p(e.from),min:o||null,max:s||null,disabled:u?"":null,"data-role":"from"});d.append(f),d.append(l("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const g=l("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:p(e.to),min:o||null,max:s||null,disabled:u?"":null,"data-role":"to"});d.append(g),c.append(d);const h=t.argMeta?.[1]?.stateRef,b=t.argMeta?.[2]?.stateRef;if(h&&r.bindState(f,h),b&&r.bindState(g,b),e.onChange!=null){const v=y=>{const x=y.closest(".rui-date-range-picker"),w=x?.querySelector('.rui-date-range-picker-input[data-role="from"]')?.value??"",k=x?.querySelector('.rui-date-range-picker-input[data-role="to"]')?.value??"";return{from:w,to:k}};f.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget))),g.addEventListener("change",y=>r.invoke(e.onChange,v(y.currentTarget)))}return c}};function qc(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Gc(t,e,r){const a=t.argMeta?[...t.argMeta]:[];for(;a.length<5;)a.push({});a[4]?.stateRef&&(a[2]=a[4]);const n=jn.render({...t,argMeta:a},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return n.classList.add("rui-select-searchable"),n}function Fe(t,e,r,a){const n=e.argMeta?.[r]?.stateRef;if(n){if(t instanceof HTMLInputElement&&t.type==="checkbox"){a.bindState(t,n,{event:"change",getValue:i=>i.checked});return}a.bindState(t,n)}}function Kc(t,e){if(!e)return;const r=Array.isArray(e)?e.map(a=>String(a)):typeof e=="object"?Object.entries(e).map(([a,n])=>n?`${a}:${n}`:a):[];for(const a of r)a==="required"?t.required=!0:a.startsWith("minLength:")?t.minLength=Number(a.slice(10))||0:a.startsWith("maxLength:")?t.maxLength=Number(a.slice(10))||0:a==="email"&&(t.type="email")}const Ee=["default","primary","success","warning","danger","info"],Oe=(t,e)=>{const r=C(t);if(r.length===0)return null;const a=l("div",{class:"rui-pattern-actions"});for(const n of r)a.append(e.renderNode(n));return a},Yc=[{match:/\bbeta\b/i,label:"Beta"},{match:/\b(early\s?access|preview)\b/i,label:"Preview"},{match:/\b(introduc(?:ing|e)|launch(?:ed|ing)?|announcing)\b/i,label:"Introducing"},{match:/\b(welcome\b|get(?:ting)?\s?started)/i,label:"Welcome"},{match:/\b(new\b|whats\s?new|now\b)/i,label:"What's new"},{match:/\bfree\b/i,label:"Free trial"},{match:/\bupgrade\b/i,label:"Upgrade"},{match:/\b(sale|discount|deal)\b/i,label:"Limited time"}];function Xc(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Yc)if(a.match.test(r))return a.label;return""}const Jc={name:"Hero",description:'Eye-catching landing/marketing header with eyebrow tag, title, subtitle, optional bullet highlights, and primary/secondary CTA buttons. Use `layout="cover"` with `imageSrc` for an image-backed hero band (pass `height` and optional `caption`). Default layout shows an optional side illustration.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"primary",type:"Button",optional:!0,description:"Primary CTA — pass a Button(...)"},{name:"secondary",type:"Button",optional:!0,description:"Secondary CTA — pass a Button(...)"},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase tag above the title"},{name:"highlights",type:"string[]",optional:!0,description:"Bullet items rendered as tag pills"},{name:"imageSrc",type:"string",optional:!0,description:"Illustration or cover background when layout=cover"},{name:"caption",type:"string",optional:!0,description:"Small caption above CTAs (cover layout)"},{name:"height",type:"string",optional:!0,description:"Min-height for cover layout (default 280px)"},{name:"actions",type:"Node[]",optional:!0,description:"CTA row (cover layout; alternative to primary/secondary)"},{name:"layout",type:"string",optional:!0,enum:["default","cover"],description:"default = text-first; cover = image-backed band"},{name:"tone",type:"string",optional:!0,enum:Ee,description:"Accent tone"}],render:(t,e,r)=>{const a=p(e.layout,"default"),n=p(e.title),i=p(e.subtitle),s=p(e.eyebrow)||Xc(n,i),u=p(e.tone,"primary");if(a==="cover"){const h=tl(p(e.imageSrc)),b=te(p(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":u,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${h}");min-height:${b};`}),y=l("div",{class:"rui-cover-body"});s&&y.append(l("span",{class:"rui-cover-eyebrow"},[s])),y.append(l("h1",{class:"rui-cover-title"},[n])),i&&y.append(l("p",{class:"rui-cover-subtitle"},[i]));const x=p(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=Oe(e.actions,r);if(w)w.classList.add("rui-cover-actions"),y.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const A=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)A.append(r.renderNode(S));y.append(A)}}return v.append(y),v}const c=ne(e.imageSrc),m=l("section",{class:"rui-hero","data-tone":u,"data-has-image":c?"true":"false"}),d=l("div",{class:"rui-hero-body"});s&&d.append(l("span",{class:"rui-hero-eyebrow"},[s])),d.append(l("h1",{class:"rui-hero-title"},[n])),i&&d.append(l("p",{class:"rui-hero-subtitle"},[i]));const f=C(e.highlights);if(f.length>0){const h=l("div",{class:"rui-hero-highlights"});for(const b of f){const v=p(b);v&&h.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(h)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const h=l("div",{class:"rui-hero-ctas"});for(const b of g)h.append(r.renderNode(b));d.append(h)}if(m.append(d),c){const h=l("div",{class:"rui-hero-media"});h.append(l("img",{src:c,alt:"",loading:"lazy"})),m.append(h)}return m}},Zc={name:"PageHeader",description:'Page-level header with breadcrumbs, title, subtitle, status tag, and a right-aligned actions row. The canonical first child for any dashboard, settings, or detail page — replaces ad-hoc Stack+Header+Buttons stitching. If `breadcrumbs` is omitted the component auto-derives `["Home", title]` so the page never lacks a trail. Pass `breadcrumbs=false` to opt out.',props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0},{name:"breadcrumbs",type:"string[] | Breadcrumb | false",optional:!0,description:"Array of strings, a Breadcrumb(...) node, or `false` to suppress the auto-derived trail"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / NavLinks shown on the right"},{name:"status",type:"Badge",optional:!0,aliases:["badge"],description:"Optional Badge(...) rendered next to the title"}],render:(t,e,r)=>{const a=l("header",{class:"rui-page-header"}),n=p(e.title);let i=e.breadcrumbs;if(i==null?n&&(i=["Home",n]):(i===!1||i==="false")&&(i=null),i){const d=l("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((f,g)=>{g>0&&d.append(l("span",{class:"rui-page-header-crumb-sep"},["/"])),d.append(l("span",{class:"rui-page-header-crumb"},[p(f)]))}):d.append(r.renderNode(i)),a.append(d)}const o=l("div",{class:"rui-page-header-title-row"}),s=l("div",{class:"rui-page-header-title-block"}),u=l("div",{class:"rui-page-header-title-line"});u.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&u.append(r.renderNode(e.status)),s.append(u);const c=p(e.subtitle);c&&s.append(l("p",{class:"rui-page-header-subtitle"},[c])),o.append(s);const m=Oe(e.actions,r);return m&&(m.classList.add("rui-page-header-actions"),o.append(m)),a.append(o),a}},Qc={name:"EmptyState",description:"Zero-state placeholder for empty lists, searches, dashboards. Renders a centered icon (or illustration), title, description, and either a single `action` Button or an `actions` row (primary + secondary). Always preferable to an empty Card with raw text.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:'Font Awesome icon name (defaults to "inbox")'},{name:"illustration",type:"string",optional:!0,description:"Image URL — takes precedence over `icon` when provided"},{name:"action",type:"Button",optional:!0,description:"Single CTA (legacy slot)"},{name:"actions",type:"Node[]",optional:!0,description:"Row of CTA Buttons / Links — preferred over `action` for primary + secondary affordances"}],render:(t,e,r)=>{const a=l("div",{class:"rui-empty-state"}),n=ne(e.illustration);if(n)a.append(l("img",{class:"rui-empty-state-illustration",src:n,alt:"",loading:"lazy"}));else{const s=p(e.title),u=p(e.description),c=p(e.icon)||Rn(`${s} ${u}`)||"inbox",m=z(c,{className:"rui-empty-state-icon"});m&&a.append(m)}a.append(l("h3",{class:"rui-empty-state-title"},[p(e.title)]));const i=p(e.description);i&&a.append(l("p",{class:"rui-empty-state-description"},[i]));const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-empty-state-actions"});for(const u of o)s.append(r.renderNode(u));a.append(s)}else if(e.action){const s=l("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),a.append(s)}return a}},eu={name:"TimelineItem",description:"Single event on a Timeline.",props:[{name:"title",type:"string"},{name:"time",type:"string",optional:!0,description:"Display label (ISO, relative, etc.)"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered inside the marker"},{name:"tone",type:"string",optional:!0,enum:Ee}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":p(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=z(e.icon);n&&a.append(n),r.append(a);const i=l("div",{class:"rui-timeline-body"}),o=l("div",{class:"rui-timeline-head"});o.append(l("span",{class:"rui-timeline-title"},[p(e.title)]));const s=p(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const u=p(e.description);return u&&i.append(l("div",{class:"rui-timeline-description"},[u])),r.append(i),r}},tu={name:"Timeline",description:"Vertical event timeline. Children must be TimelineItem entries. Ideal for activity feeds, changelogs, and process flows.",props:[{name:"items",type:"TimelineItem[]"}],render:(t,e,r)=>{const a=l("ol",{class:"rui-timeline"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},ru={name:"FeatureItem",description:"Single tile on a FeatureGrid.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"tone",type:"string",optional:!0,enum:Ee}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":p(e.tone,"primary")}),a=p(e.icon,"sparkles"),n=z(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[p(e.title)]));const i=p(e.description);return i&&r.append(l("p",{class:"rui-feature-description"},[i])),r}},au={name:"FeatureGrid",description:"Responsive grid of FeatureItem tiles (typically 2–3 columns). Use to highlight product capabilities or page categories.",props:[{name:"items",type:"FeatureItem[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Number(e.columns??"auto"))),n=l("div",{class:"rui-feature-grid","data-columns":a>0?String(a):null});for(const i of C(e.items))n.append(r.renderNode(i));return n}},nu={name:"Testimonial",description:"Quote card with author, role, and optional avatar.",props:[{name:"quote",type:"string"},{name:"author",type:"string",aliases:["name"]},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"rating",type:"number",optional:!0,description:"0–5 stars"}],render:(t,e)=>{const r=l("figure",{class:"rui-testimonial"}),a=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(a>0){const u=l("div",{class:"rui-testimonial-rating"});for(let c=0;c<5;c+=1){const m=c<a,d=z(m?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&u.append(d)}r.append(u)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[p(e.quote)]));const n=l("figcaption",{class:"rui-testimonial-author"}),i=ne(e.avatarSrc);i&&n.append(l("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=l("div",{class:"rui-testimonial-meta"});o.append(l("div",{class:"rui-testimonial-name"},[p(e.author)]));const s=p(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},iu={name:"ProfileCard",description:"Compact profile/user card with avatar, name, role, optional bio, social tags, and a row of action buttons. Use for team rosters, contributor lists, and contact panels.",props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar image src; falls back to initials"},{name:"bio",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"actions",type:"Node[]",optional:!0,description:"Buttons to render at the bottom"}],render:(t,e,r)=>{const a=l("div",{class:"rui-profile-card"}),n=l("div",{class:"rui-profile-card-header"});n.append(lt(p(e.avatarSrc),p(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[p(e.name)]));const o=p(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=p(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const u=C(e.tags);if(u.length>0){const m=l("div",{class:"rui-profile-card-tags"});for(const d of u){const f=p(d);f&&m.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[f])]))}a.append(m)}const c=Oe(e.actions,r);return c&&(c.classList.add("rui-profile-card-actions"),a.append(c)),a}},ou={name:"Comment",description:"Single comment / message bubble. Renders avatar, author, timestamp, body, and an optional row of toolbar buttons (reply, like, …).",props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=l("article",{class:"rui-comment"});a.append(lt(p(e.avatarSrc),p(e.author),"md"));const n=l("div",{class:"rui-comment-body"}),i=l("header",{class:"rui-comment-header"});i.append(l("span",{class:"rui-comment-author"},[p(e.author)]));const o=p(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[p(e.body)]));const s=Oe(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},su={name:"Banner",description:"Full-width announcement banner. Use at the top of a page for promos, release notes, or downtime notices. For inline notices prefer Callout or Alert.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"action",type:"Button",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"},{name:"tone",type:"string",optional:!0,enum:Ee}],render:(t,e,r)=>{const a=p(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=p(e.icon)||uc(a)||"",o=z(i,{className:"rui-banner-icon"});o&&n.append(o);const s=l("div",{class:"rui-banner-body"});s.append(l("strong",{class:"rui-banner-title"},[p(e.title)]));const u=p(e.message);if(u&&s.append(l("span",{class:"rui-banner-message"},[u])),n.append(s),e.action){const c=l("div",{class:"rui-banner-action"});c.append(r.renderNode(e.action)),n.append(c)}return n}},lu={name:"KanbanCard",description:"Single card on a Kanban board.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0},{name:"assignee",type:"string",optional:!0,description:"Name shown next to avatar initials"},{name:"tone",type:"string",optional:!0,enum:Ee},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown beside the title"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Optional callable fired when the card is clicked"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-card","data-tone":p(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=c=>{const m=c;(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=z(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(p(e.title))),a.append(n);const o=p(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=C(e.tags);if(s.length>0){const c=l("div",{class:"rui-kanban-card-tags"});for(const m of s){const d=p(m);d&&c.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(c)}const u=p(e.assignee);if(u){const c=l("footer",{class:"rui-kanban-card-footer"});c.append(lt("",u,"sm")),c.append(l("span",{class:"rui-kanban-card-assignee"},[u])),a.append(c)}return a}},cu={name:"KanbanColumn",description:"Single column inside a KanbanBoard. Children must be KanbanCard entries.",props:[{name:"title",type:"string"},{name:"items",type:"KanbanCard[]",aliases:["cards"]},{name:"tone",type:"string",optional:!0,enum:Ee,description:"Header accent tone"}],render:(t,e,r)=>{const a=C(e.items),n=l("section",{class:"rui-kanban-column","data-tone":p(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[p(e.title)])),i.append(l("span",{class:"rui-kanban-column-count"},[String(a.length)])),n.append(i);const o=l("div",{class:"rui-kanban-column-body"});for(const s of a)o.append(r.renderNode(s));return a.length===0&&o.append(l("div",{class:"rui-kanban-column-empty"},["No items"])),n.append(o),n}},uu={name:"KanbanBoard",description:"Horizontal Kanban board. Children must be KanbanColumn entries. The board scrolls horizontally on narrow viewports so columns stay readable.",props:[{name:"columns",type:"KanbanColumn[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-kanban-board"});for(const n of C(e.columns))a.append(r.renderNode(n));return a}},du={name:"SectionHeader",description:"Compact section header for the top of a Card or panel. Renders a small eyebrow, a title, an optional subtitle, an optional status Tag/Badge, and a right-aligned actions row. Use this inside a Card to introduce a section instead of a bare `CardHeader`.",props:[{name:"title",type:"string"},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"eyebrow",type:"string",optional:!0,description:"Short uppercase label above the title"},{name:"status",type:"Badge | Tag",optional:!0,aliases:["badge"]},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links shown on the right"}],render:(t,e,r)=>{const a=l("header",{class:"rui-section-header"}),n=l("div",{class:"rui-section-header-left"}),i=p(e.eyebrow);i&&n.append(l("span",{class:"rui-section-header-eyebrow"},[i]));const o=l("div",{class:"rui-section-header-title-line"});o.append(l("h3",{class:"rui-section-header-title"},[p(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=p(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const u=Oe(e.actions,r);return u&&(u.classList.add("rui-section-header-actions"),a.append(u)),a}},pu={name:"Toolbar",description:"Horizontal toolbar for filters, search, view modes, and primary actions. Left/center/right slots wrap onto separate rows on narrow viewports so the bar never overflows. Pass `searchable: true` to auto-mount a SearchBar in the left slot (bind `searchValue` to a `$variable`). Use ABOVE a Table, List, Grid, or Kanban view — never replace `PageHeader` with it.",props:[{name:"left",type:"Node[]",optional:!0,description:"Filters / search inputs / chips"},{name:"right",type:"Node[]",optional:!0,description:"Primary action buttons"},{name:"center",type:"Node[]",optional:!0,description:"Centered controls (e.g. SegmentedControl, search bar)"},{name:"searchable",type:"boolean",optional:!0,description:"Auto-mount a SearchBar at the start of the left slot"},{name:"searchPlaceholder",type:"string",optional:!0,description:"Placeholder for the auto-mounted SearchBar"},{name:"searchValue",type:"string",optional:!0,description:"$variable bound to the auto-mounted SearchBar"}],render:(t,e,r)=>{const a=C(e.center),n=l("div",{class:"rui-toolbar","data-has-center":a.length>0?"true":"false"}),i=l("div",{class:"rui-toolbar-side rui-toolbar-left"});T(e.searchable)&&i.append(Dn.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:p(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of C(e.left))i.append(r.renderNode(s));if(n.append(i),a.length>0){const s=l("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const u of a)s.append(r.renderNode(u));n.append(s)}const o=l("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of C(e.right))o.append(r.renderNode(s));return n.append(o),n}},mu={name:"SidebarItem",description:"Single navigation item inside a Sidebar. Pass `active=true` to mark as the current page, a `to` path to navigate via the runtime router on click, an `onClick` callable for arbitrary click handling, or an optional `badge` (string/number) for a trailing chip. `to` and `onClick` can coexist — `onClick` is invoked AFTER the router navigates so authors can do extra work (analytics, side-effects).",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name rendered before the label"},{name:"active",type:"boolean",optional:!0,description:"Mark this item as the current page. When `to` is provided and `active` is omitted, the item auto-detects the active state from the current router path."},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"to",type:"string",optional:!0,description:'Router path to navigate to on click (e.g. "/", "/orders"). Uses the runtime router — no full page reload.'},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable invoked on click. Runs in addition to `to`-based navigation."}],render:(t,e,r)=>{const a=p(e.to),n=e.active!==void 0&&e.active!==null,i=a?r.router.getPath():"",o=a?a==="/"?i==="/":i===a?!0:i.startsWith(a+"/"):!1,s=n?T(e.active):o,u=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),c=z(e.icon,{className:"rui-sidebar-item-icon"});c&&u.append(c),u.append(l("span",{class:"rui-sidebar-item-label"},[p(e.label)]));const m=p(e.badge);return m&&u.append(l("span",{class:"rui-sidebar-item-badge"},[m])),(a||e.onClick!=null)&&(u.onclick=d=>{if(a){const f=d;if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey)return;r.router.navigate(a)}e.onClick!=null&&r.invoke(e.onClick)}),u}},fu={name:"SidebarSection",description:"Grouping inside a Sidebar — small uppercase label followed by SidebarItem entries. Use this to chunk a long sidebar into sections.",props:[{name:"label",type:"string"},{name:"items",type:"SidebarItem[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-sidebar-section"}),n=p(e.label);n&&a.append(l("div",{class:"rui-sidebar-section-label"},[n]));for(const i of C(e.items))a.append(r.renderNode(i));return a}},gu={name:"Sidebar",description:"Vertical app navigation panel. Supports a brand header, navigation items (`SidebarItem` or `SidebarSection`), an optional footer, and a `collapsed` mode that hides labels to leave just an icon rail. Use inside `AppShell` for SaaS-style left navigation.",props:[{name:"items",type:"(SidebarItem | SidebarSection)[]"},{name:"brand",type:"string",optional:!0,description:"Product name / workspace label at the top"},{name:"tagline",type:"string",optional:!0},{name:"footer",type:"Node[]",optional:!0,description:"Footer block (Avatar + name, upgrade CTA, …)"},{name:"collapsed",type:"boolean",optional:!0,description:"Render as an icon-only rail (hides labels/badges)"}],render:(t,e,r)=>{const a=T(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=p(e.brand),o=p(e.tagline);if(i||o){const c=l("div",{class:"rui-sidebar-header"});i&&c.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&c.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(c)}const s=l("nav",{class:"rui-sidebar-body"});for(const c of C(e.items))s.append(r.renderNode(c));n.append(s);const u=C(e.footer);if(u.length>0){const c=l("div",{class:"rui-sidebar-footer"});for(const m of u)c.append(r.renderNode(m));n.append(c)}return n}},hu={name:"AppShell",description:"Canonical SaaS application shell: optional top bar, fixed left Sidebar, and scrollable main content. Reach for this whenever a response represents a full product surface (dashboard with nav, settings + sections, admin panels). Pass `collapsible=true` to render a hamburger that turns the sidebar into a slide-over drawer on narrow viewports.",props:[{name:"sidebar",type:"Sidebar",description:"Pass a Sidebar(...) node"},{name:"content",type:"Node[]",description:"Main content (typically starts with a PageHeader)"},{name:"topbar",type:"Node[]",optional:!0,description:"Optional thin top bar above the content"},{name:"collapsible",type:"boolean",optional:!0,description:"Show a hamburger that toggles the sidebar drawer on mobile"},{name:"sidebarOpen",type:"boolean",optional:!0,description:"$variable controlling whether the mobile drawer is open"}],render:(t,e,r)=>{const a=T(e.collapsible),n=T(e.sidebarOpen),i=l("div",{class:"rui-app-shell"});a&&(i.dataset.collapsible="true"),n&&(i.dataset.sidebarOpen="true");const o=l("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),a){const m=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});m.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(m)}const s=l("div",{class:"rui-app-shell-main"}),u=C(e.topbar);if(u.length>0||a){const m=l("div",{class:"rui-app-shell-topbar"});if(a){const d=l("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});d.append(z("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),m.append(d)}for(const d of u)m.append(r.renderNode(d));s.append(m)}const c=l("div",{class:"rui-app-shell-content"});for(const m of C(e.content))c.append(r.renderNode(m));return s.append(c),i.append(s),i}},bu={name:"SplitView",description:"Two-pane master/detail layout — a narrow primary pane on the left, wider detail pane on the right. Collapses to a single column on narrow viewports. Use for inboxes, file browsers, contact lists.",props:[{name:"primary",type:"Node[]",description:"Master pane content (list, filters)"},{name:"detail",type:"Node[]",aliases:["secondary"],description:"Detail pane content (selected item, empty state)"},{name:"primaryWidth",type:"string",optional:!0,aliases:["splitAt"],description:"CSS width for the primary pane (default 320px)"}],render:(t,e,r)=>{const a=te(p(e.primaryWidth),"320px"),n=l("div",{class:"rui-split-view",style:`--rui-split-primary:${a}`}),i=l("div",{class:"rui-split-view-primary"});for(const s of C(e.primary))i.append(r.renderNode(s));const o=l("div",{class:"rui-split-view-detail"});for(const s of C(e.detail))o.append(r.renderNode(s));return n.append(i,o),n}},vu={name:"DescriptionItem",description:"Single row inside a DescriptionList. Renders a small uppercase label on the left and a value (string or arbitrary Node) on the right.",props:[{name:"label",type:"string"},{name:"value",type:"Node | string"},{name:"icon",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-description-item"}),n=l("dt",{class:"rui-description-label"}),i=z(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(p(e.label)));const o=l("dd",{class:"rui-description-value"});return e.value&&typeof e.value=="object"&&e.value.__kind==="Component"?o.append(r.renderNode(e.value)):o.append(document.createTextNode(p(e.value))),a.append(n,o),a}},yu={name:"DescriptionList",description:"Compact key/value summary for detail pages — replaces a row of `Text`s with a properly aligned `<dl>`. Children must be DescriptionItem entries. Two columns by default on wide viewports.",props:[{name:"items",type:"DescriptionItem[]"},{name:"columns",type:"number",optional:!0,description:"1 or 2 (default 2)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),n=l("dl",{class:"rui-description-list","data-columns":String(a)});for(const i of C(e.items))n.append(r.renderNode(i));return n}},xu={name:"StatusDot",description:"Inline status pip + label. Use for compact health/state indicators in toolbars, sidebars, lists, and table cells.",props:[{name:"label",type:"string"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]},{name:"pulse",type:"boolean",optional:!0,description:"Animate the dot for 'live' state"}],render:(t,e)=>{const r=l("span",{class:"rui-status-dot","data-tone":p(e.tone,"success"),"data-pulse":T(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[p(e.label)])),r}},wu={name:"PricingCard",description:"Single pricing tier card with plan name, price, billing period, description, bullet features, and a CTA button. Mark one tier as `featured=true` to highlight it (raises the card, adds a ribbon).",props:[{name:"plan",type:"string",description:"Tier name (e.g. 'Pro')"},{name:"price",type:"string",description:"Display price (e.g. '$29')"},{name:"period",type:"string",optional:!0,description:"Billing period (e.g. '/mo')"},{name:"description",type:"string",optional:!0},{name:"features",type:"string[]",optional:!0,description:"Bullet list of included features"},{name:"action",type:"Button",optional:!0,aliases:["cta"],description:"Primary CTA — pass a Button(...)"},{name:"badge",type:"string",optional:!0,description:"Eyebrow / badge above the plan name"},{name:"featured",type:"boolean",optional:!0,aliases:["highlighted"]}],render:(t,e,r)=>{const a=T(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=p(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[p(e.plan)]));const o=p(e.description);o&&n.append(l("p",{class:"rui-pricing-card-description"},[o]));const s=l("div",{class:"rui-pricing-card-price-row"});s.append(l("span",{class:"rui-pricing-card-price"},[p(e.price)]));const u=p(e.period);u&&s.append(l("span",{class:"rui-pricing-card-period"},[u])),n.append(s);const c=C(e.features);if(c.length>0){const m=l("ul",{class:"rui-pricing-card-features"});for(const d of c){const f=p(d);if(!f)continue;const g=z("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});m.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(f)]))}n.append(m)}if(e.action){const m=l("div",{class:"rui-pricing-card-action"});m.append(r.renderNode(e.action)),n.append(m)}return n}},ku={name:"PricingTable",description:"Responsive grid of PricingCard tiers. Items size uniformly across a row and wrap onto multiple rows on narrow viewports. Use as the centerpiece of any pricing or upgrade page.",props:[{name:"tiers",type:"PricingCard[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"}],render:(t,e,r)=>{const a=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),n=l("div",{class:"rui-pricing-table","data-columns":a>0?String(a):null});for(const i of C(e.tiers))n.append(r.renderNode(i));return n}},Su={name:"MediaCard",description:'Card with a media (image) header followed by title, body, optional tags, footer meta, and an actions row. Use for article previews, product cards, project highlights, gallery items — anywhere a Card needs a leading image. Orient with `orientation="horizontal"` for side-by-side media + content on wide viewports.',props:[{name:"title",type:"string"},{name:"imageSrc",type:"string",optional:!0,aliases:["src","image"],description:"Image URL (omit to render a neutral placeholder)"},{name:"description",type:"string",optional:!0},{name:"tags",type:"string[]",optional:!0,description:"Tag pill labels"},{name:"meta",type:"string",optional:!0,description:"Footer meta line (author · date · category)"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons / Links rendered at the bottom"},{name:"badge",type:"string | Badge",optional:!0,description:"Eyebrow string or Badge node shown over the image"},{name:"orientation",type:"string",optional:!0,enum:["vertical","horizontal"]},{name:"ratio",type:"string",optional:!0,description:"Media aspect ratio (default 16:9 vertical, 4:3 horizontal)"}],render:(t,e,r)=>{const a=p(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=Cu(p(e.ratio,a==="horizontal"?"4:3":"16:9")),o=l("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ne(e.imageSrc);if(s)o.append(l("img",{src:s,alt:p(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=z("image",{className:"rui-media-card-placeholder"})??l("span",{class:"rui-media-card-placeholder"});o.append(g)}if(e.badge){const g=l("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?g.append(document.createTextNode(p(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const u=l("div",{class:"rui-media-card-body"});u.append(l("h3",{class:"rui-media-card-title"},[p(e.title)]));const c=p(e.description);c&&u.append(l("p",{class:"rui-media-card-description"},[c]));const m=C(e.tags);if(m.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const h of m){const b=p(h);b&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[b])]))}u.append(g)}const d=p(e.meta);d&&u.append(l("p",{class:"rui-media-card-meta"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),u.append(f)),n.append(u),n}};function Cu(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function Nr(t,e="primary"){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg");if(i.setAttribute("class","rui-sparkline"),i.setAttribute("data-tone",e),i.setAttribute("viewBox","0 0 80 24"),i.setAttribute("width",String(80)),i.setAttribute("height",String(24)),i.setAttribute("aria-hidden","true"),t.length<2)return i;const o=Math.min(...t),s=Math.max(...t),u=s-o||1,c=80/(t.length-1),d=t.map((b,v)=>{const y=v*c,x=2+(s-b)/u*20;return[y,x]}).map(([b,v],y)=>`${y===0?"M":"L"}${b.toFixed(1)},${v.toFixed(1)}`).join(" "),f=`${d} L80,24 L0,24 Z`,g=document.createElementNS(n,"path");g.setAttribute("d",f),g.setAttribute("class","rui-sparkline-area"),i.appendChild(g);const h=document.createElementNS(n,"path");return h.setAttribute("d",d),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),i.appendChild(h),i}const $u={name:"Stats",description:'KPI strip or grid. Pass `items` as `{label, value, hint?, tone?, spark?}` objects for strip layout, or as `StatCard(...)` nodes when `layout="grid"`.',props:[{name:"items",type:"object[] | StatCard[]",description:"Stat objects or StatCard nodes when layout=grid"},{name:"layout",type:"string",optional:!0,enum:["strip","grid"],description:"strip = horizontal row; grid = responsive Grid"},{name:"columns",type:"number",optional:!0,description:"Preferred column count for grid layout (1–6)"},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:"Strip alignment (layout=strip only)"}],render:(t,e,r)=>{const a=C(e.items),n=a.some(u=>u&&typeof u=="object"&&u.__kind==="Component");if(p(e.layout,n?"grid":"strip")==="grid"){const u=e.columns?Math.max(1,Math.min(6,Math.floor(L(e.columns)))):0,c=Nn.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:u>0?u:"auto",gap:"m"},r);return c.classList.add("rui-metric-grid"),c}const o=p(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const u of a){const c=u??{},m=p(c.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":m});d.append(l("div",{class:"rui-stats-label"},[p(c.label)]));const f=l("div",{class:"rui-stats-value-row"});f.append(l("div",{class:"rui-stats-value"},[p(c.value)]));const g=C(c.spark).map(b=>Number(b)).filter(b=>Number.isFinite(b));g.length>1&&f.append(Nr(g,m)),d.append(f);const h=p(c.hint);h&&d.append(l("div",{class:"rui-stats-hint"},[h])),s.append(d)}return s}},Tu={name:"Tile",description:"Compact icon + label + optional value tile. Smaller and denser than `StatCard`, ideal for menu grids, quick-action panels, category directories, and category filters. Pair with `Grid` for uniform rows.",props:[{name:"label",type:"string"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"value",type:"string",optional:!0,description:"Secondary value rendered next to/under the label"},{name:"description",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:Ee},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",i=l(a?"button":"div",{type:a?"button":null,class:"rui-tile","data-tone":p(e.tone,"default")}),o=z(e.icon,{className:"rui-tile-icon"});o&&i.append(o);const s=l("div",{class:"rui-tile-body"});s.append(l("div",{class:"rui-tile-label"},[p(e.label)]));const u=p(e.value);u&&s.append(l("div",{class:"rui-tile-value"},[u]));const c=p(e.description);return c&&s.append(l("div",{class:"rui-tile-description"},[c])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},Bn={name:"Notification",description:"Inline notification card with title, message, time, optional avatar, and dismiss/action buttons. Use inside notification panels, inboxes, or activity drawers — for top-of-page announcements prefer `Banner`.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"time",type:"string",optional:!0,description:"Relative or absolute timestamp"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a colored disc"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"],description:"Avatar URL (alternative to `icon`)"},{name:"tone",type:"string",optional:!0,enum:Ee},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=T(e.unread),n=l("article",{class:"rui-notification","data-tone":p(e.tone,"default"),"data-unread":a?"true":"false"}),i=p(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(lt(i,p(e.title),"md"));else{const g=z(p(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),u=l("header",{class:"rui-notification-head"}),c=l("span",{class:"rui-notification-title-wrap"});a&&c.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),c.append(l("span",{class:"rui-notification-title"},[p(e.title)])),u.append(c);const m=p(e.time);m&&u.append(l("span",{class:"rui-notification-time"},[m])),s.append(u);const d=p(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const f=Oe(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),n.append(s),n}},Au={name:"PersonChip",description:'Inline avatar + name + optional role/meta pill. Use anywhere a person needs to be referenced compactly: table cells, list rows, comments, kanban cards, sidebar footers. Pair multiple chips with `Stack(direction="row", wrap=true)` for assignee lists.',props:[{name:"name",type:"string"},{name:"role",type:"string",optional:!0,description:"Sub-line below the name (role, email, handle, …)"},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const a=typeof e.onClick=="function",n=a?"button":"div",i=p(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=l(n,{type:a?"button":null,class:"rui-person-chip","data-size":i}),u=l("span",{class:"rui-person-chip-avatar"});u.append(lt(p(e.avatarSrc),p(e.name),o));const c=p(e.status);c&&u.append(l("span",{class:"rui-person-chip-status","data-status":c})),s.append(u);const m=l("div",{class:"rui-person-chip-meta"});m.append(l("span",{class:"rui-person-chip-name"},[p(e.name)]));const d=p(e.role);return d&&m.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(m),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},Fn=["left","center","right"],Nu={name:"Col",description:'Single column inside a Table or DataGrid. Use `align` for per-column text alignment, `format` for cell rendering (`text|number|currency|date`). `values` may be plain values OR an array of component nodes — e.g. `Col("Status", rows.map(r => Badge(r.status)))` or `Col("Actions", rows.map(r => Button("Edit")))` — each component renders directly in its cell. Pass `render: (value, index) => …` for the same effect when you prefer to keep `values` as the raw row data (return a component, string, or array). Pass `onClick: (value, index) => …` to make the whole cell clickable (pointer + keyboard). `sortable` and `filterable` only take effect inside `DataGrid` (Table ignores them).',props:[{name:"header",type:"string"},{name:"values",type:"any[]",description:"Column values. Plain values are formatted as text; component nodes (e.g. `rows.map(r => Badge(r.status))`) render directly. You can also pass the full row array and map each cell with `render`."},{name:"format",type:"string",optional:!0,enum:["text","number","currency","date"]},{name:"align",type:"string",optional:!0,enum:Fn,description:"Per-column horizontal alignment"},{name:"sortable",type:"boolean",optional:!0,description:"DataGrid: enable click-to-sort on this column"},{name:"filterable",type:"boolean",optional:!0,description:"DataGrid: enable a per-column filter chip"},{name:"render",type:"callable",optional:!0,aliases:["cell"],description:"`(value, index) => Component | string | array` — map each cell to arbitrary content (buttons, badges, links)."},{name:"onClick",type:"callable",optional:!0,aliases:["onclick","cellClick"],description:"`(value, index) => void` — fired when a cell in this column is clicked or activated via keyboard."}],render:(t,e)=>{const r=l("div",{class:"rui-col"});return r.append(l("strong",{},[p(e.header)])),r}},Mu={name:"Table",description:'Tabular data view. Children must be Col components. `density="compact"` tightens row padding for dense data, `striped=true` zebra-stripes the rows, and `sticky=true` pins the header row when the table scrolls. The empty-state row uses `emptyLabel` when set.',props:[{name:"columns",type:"Col[]"},{name:"caption",type:"string",optional:!0,aliases:["title"]},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"],description:"Row padding (default `comfortable`)"},{name:"striped",type:"boolean",optional:!0,description:"Zebra-stripe alternating rows"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the header row when the table scrolls"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when the table has no rows (default `No data`)"}],render:(t,e,r)=>{const a=C(e.columns),n=p(e.density,"comfortable"),i=T(e.striped),o=T(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),u=l("table",{class:"rui-table"}),c=p(e.caption);c&&u.append(l("caption",{class:"rui-table-caption"},[c]));const m=a.map(w=>{const k=p(w.args?.[3],"");return Fn.includes(k)?k:""}),d=l("thead"),f=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],A=l("th",{"data-align":m[w]||null},[p(k.args?.[0])]);f.append(A)}d.append(f),u.append(d);const g=l("tbody"),h=a.map(w=>C(w.args?.[1])),b=a.map(w=>p(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...h.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");h.forEach((A,S)=>{const $=b[S]??"text",M=m[S],I=l("td",{"data-format":$,"data-align":M||null});yr(I,{format:$,render:v[S],onClick:y[S]},A[w],w,r,ju),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=p(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return u.append(g),s.append(u),s}},Pu={name:"ListItem",description:"Single list item with optional title and description.",props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0,aliases:["meta"]},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-list-item"}),a=z(e.icon,{className:"rui-list-icon"});a&&r.append(a);const n=l("div",{class:"rui-list-text"});n.append(l("div",{class:"rui-list-title"},[p(e.title)]));const i=p(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},Iu={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of C(e.items))n.append(r.renderNode(i));return n}},Lu={name:"StatCard",description:"Single KPI card with label, value, optional delta, optional icon, and optional inline sparkline (`spark=[…numbers]`). Use inside `Stats` for a uniform KPI strip.",props:[{name:"label",type:"string"},{name:"value",type:"string"},{name:"trend",type:"string",optional:!0,enum:["up","down","flat"]},{name:"delta",type:"string",optional:!0,description:"Change vs previous period"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown in a chip beside the label"},{name:"spark",type:"number[]",optional:!0,description:"Optional inline sparkline values"},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"]}],render:(t,e)=>{const r=p(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=p(e.label),o=p(e.icon)||Rn(i)||"",s=z(o,{className:"rui-stat-icon"});s&&n.append(s),n.append(l("div",{class:"rui-stat-label"},[i])),a.append(n),a.append(l("div",{class:"rui-stat-value"},[p(e.value)]));const u=p(e.delta),c=p(e.trend);(u||c)&&a.append(l("div",{class:"rui-stat-trend","data-trend":c||"flat"},[u||Du(c)]));const m=C(e.spark).map(d=>L(d));if(m.length>1){const d=l("div",{class:"rui-stat-spark"});d.append(Nr(m,r==="default"?"primary":r)),a.append(d)}return a}},Ru={name:"Sparkline",description:"Tiny inline trend chart for KPIs, table cells, and dashboards. Renders an SVG line with a soft fill — use anywhere you would otherwise reach for `LineChart` but a single value series should stay inline with surrounding text.",props:[{name:"values",type:"number[]"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=p(e.tone,"primary"),a=C(e.values).map(i=>L(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append(Nr(a,r)),n}},Eu={name:"TreeNode",description:"Single node in a Tree view. When `children` is provided the node renders as an expandable branch with a chevron; otherwise it renders as a leaf. `onClick` fires on click. Use `active=true` to highlight the current selection.",props:[{name:"label",type:"string"},{name:"children",type:"TreeNode[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon shown before the label"},{name:"expanded",type:"boolean",optional:!0,description:"Whether the branch is open by default"},{name:"active",type:"boolean",optional:!0,aliases:["selected"],description:"Highlights the row as the current selection"},{name:"badge",type:"string",optional:!0,description:"Trailing chip (count or status)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired when the row is clicked"}],render:(t,e,r)=>{const a=C(e.children),n=a.length>0,i=T(e.expanded),o=T(e.active),s=typeof e.onClick=="function",u=l(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":n?i?"true":"false":null});if(n){const h=z("chevron-right",{className:"rui-tree-node-chevron"});h&&u.append(h)}else u.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const c=z(e.icon,{className:"rui-tree-node-icon"});c&&u.append(c),u.append(l("span",{class:"rui-tree-node-label"},[p(e.label)]));const m=p(e.badge);if(m&&u.append(l("span",{class:"rui-tree-node-badge"},[m])),s&&(u.onclick=()=>r.invoke(e.onClick)),!n)return u;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const f=l("summary",{class:"rui-tree-node-summary"});f.append(u),s&&(f.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),d.append(f);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const h of a)g.append(r.renderNode(h));return d.append(g),d}},zu={name:"Tree",description:"Hierarchical tree view. Children must be TreeNode entries. Use for file browsers, nested navigation, category pickers, and any parent/child structure with arbitrary depth.",props:[{name:"items",type:"TreeNode[]"}],render:(t,e,r)=>{const a=l("div",{class:"rui-tree",role:"tree"});for(const n of C(e.items))a.append(r.renderNode(n));return a}};function Du(t){return t==="up"?"▲":t==="down"?"▼":"—"}function ju(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Mr=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],Ze=t=>Mr[t%Mr.length]??Mr[0],Bu={name:"Series",description:"Named data series for charts. Used inside BarChart, LineChart, PieChart.",props:[{name:"name",type:"string"},{name:"values",type:"number[]"}],render:(t,e)=>l("span",{class:"rui-series","data-name":p(e.name)})},On=t=>t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}}),Fu={name:"BarChart",description:"Vertical bar chart. `labels` define the x-axis, `series` define grouped bars.",props:[{name:"labels",type:"string[]"},{name:"series",type:"Series[]"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=C(e.labels).map(y=>p(y)),a=On(C(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});p(e.title)&&n.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,u=Un(r,o-40-12),c={left:40,right:12,top:12,bottom:u.bottomPadding},m=o-c.left-c.right,d=s-c.top-c.bottom,f=Pr(o,s);Vn(f,c,m,d,i);const g=r.length,h=m/Math.max(g,1),b=a.length,v=h*.7/Math.max(b,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const A=w/i*d,S=c.left+k*h+h*.15+x*v,$=c.top+d-A,M=ge("rect",{x:String(S),y:String($),width:String(Math.max(v-2,1)),height:String(A),fill:Ze(x),rx:"2"});M.append(ge("title",{},[`${y.name}: ${w}`])),f.append(M)})}),Hn(f,r,c,m,d,u,y=>c.left+(y+.5)*h),n.append(f),a.length>0&&n.append(Ir(a)),n}},Ou={name:"LineChart",description:'Line chart. `labels` define the x-axis, each Series is a line. As a shortcut you can pass `data=[{x: "Jan", revenue: 12, signups: 4}, …]` and the labels + series will be derived automatically (one line per non-`x` key). Use `data` when the dataset is already row-shaped; use `series` when you have explicit Series objects.',props:[{name:"labels",type:"string[]",optional:!0},{name:"series",type:"Series[]",optional:!0},{name:"data",type:"{x: string, [key: string]: number}[]",optional:!0,description:"Row-shaped data — labels and series are auto-derived"},{name:"title",type:"string",optional:!0},{name:"filled",type:"boolean",optional:!0,description:"Fill the area beneath each line (area-chart style)"},{name:"stacked",type:"boolean",optional:!0,description:"Stack series when filled=true"}],render:(t,e)=>{let r=C(e.labels).map($=>p($)),a=On(C(e.series));const n=C(e.data);if(n.length>0&&(r.length===0||a.length===0)){const $=[],M=new Map;for(const I of n){const E=I;if(!(!E||typeof E!="object")){$.push(p(E.x??E.label??""));for(const[D,K]of Object.entries(E)){if(D==="x"||D==="label")continue;const F=L(K);Number.isNaN(F)||(M.has(D)||M.set(D,[]),M.get(D).push(F))}}}r.length===0&&(r=$),a.length===0&&(a=[...M.entries()].map(([I,E])=>({name:I,values:E})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map($=>$.values.length),1),u=a.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let M=0;a.forEach((I,E)=>{M+=I.values[$]??0,u[E][$]=M})}const c=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});p(e.title)&&c.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const m=i&&o?u.flat():a.flatMap($=>$.values),d=Math.max(1,...m),f=i&&o?0:Math.min(0,...m),g=640,h=240,b=Un(r,g-40-12),v={left:40,right:12,top:12,bottom:b.bottomPadding},y=g-v.left-v.right,x=h-v.top-v.bottom,w=Pr(g,h);Vn(w,v,y,x,d,f);const k=Math.max(r.length-1,1),A=y/k,S=$=>v.left+$*(y/Math.max(s-1,1));return a.forEach(($,M)=>{const I=i&&o?u[M]:$.values,E=i&&o&&M>0?u[M-1]:null,D=I.map((F,U)=>{const J=S(U),Z=v.top+x-(F-f)/(d-f||1)*x;return[J,Z]});if(i&&D.length>0){let F=D.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(E){const U=E.map((J,Z)=>{const de=S(Z),Se=v.top+x-(J-f)/(d-f||1)*x;return[de,Se]});F+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=D[0],J=D[D.length-1];F+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ge("path",{d:F,fill:Ze(M),"fill-opacity":"0.2",stroke:"none"}))}const K=D.map(([F,U],J)=>`${J===0?"M":"L"}${F.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ge("path",{d:K,fill:"none",stroke:Ze(M),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&D.forEach(([F,U])=>{w.append(ge("circle",{cx:String(F),cy:String(U),r:"3",fill:Ze(M)}))})}),Hn(w,r,v,y,x,b,$=>v.left+$*A),c.append(w),a.length>0&&c.append(Ir(a)),c}},_u={name:"PieChart",description:'Pie / Donut chart. Each segment maps to a label/value pair. Numeric labels are rendered on every segment by default — set `showValues: false` to hide them, or `valueFormat: "percent"` to show the share instead of the raw value.',props:[{name:"labels",type:"string[]"},{name:"values",type:"number[]"},{name:"title",type:"string",optional:!0},{name:"showValues",type:"boolean",optional:!0,description:"Render numeric labels on each slice (default true)"},{name:"valueFormat",type:"string",optional:!0,enum:["value","percent","both"],description:'How to format the on-segment label (default "value")'}],render:(t,e)=>{const r=C(e.labels).map(b=>p(b)),a=C(e.values).map(b=>L(b)),n=e.showValues==null?!0:T(e.showValues),i=p(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=a.reduce((b,v)=>b+(v>0?v:0),0)||1,c=Pr(240,240),m=120,d=120,f=90,g=.05;let h=-Math.PI/2;return a.forEach((b,v)=>{const y=b>0?b:0,x=y/u,w=x*Math.PI*2,k=h+w,A=w>Math.PI?1:0,S=m+f*Math.cos(h),$=d+f*Math.sin(h),M=m+f*Math.cos(k),I=d+f*Math.sin(k),E=`M${m},${d} L${S},${$} A${f},${f} 0 ${A} 1 ${M},${I} Z`,D=ge("path",{d:E,fill:Ze(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(D.append(ge("title",{},[`${r[v]??""}: ${b} (${(x*100).toFixed(1)}%)`])),c.append(D),n&&y>0&&x>=g){const K=h+w/2,F=f*.62,U=m+F*Math.cos(K),J=d+F*Math.sin(K),Z=Uu(b,x,o),de=ge("text",{x:String(U),y:String(J),class:"rui-pie-chart-value","text-anchor":"middle","dominant-baseline":"central","paint-order":"stroke",stroke:"rgba(15, 23, 42, 0.55)","stroke-width":"3","stroke-linejoin":"round",fill:"#fff"},[Z]);c.append(de)}h=k}),s.append(c),s.append(Ir(r.map((b,v)=>({name:b,values:[a[v]??0]})))),s}};function Uu(t,e,r){const a=`${Math.round(e*100)}%`,n=Hu(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function Hu(t){if(!Number.isFinite(t))return String(t);const e=Math.abs(t);return e>=1e6?`${(t/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}k`:Number.isInteger(t)?String(t):t.toFixed(1)}const Vu=7,_n=12;function Un(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),a=t.reduce((o,s)=>Math.max(o,s.length),0);if(a*Vu+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<_n?Math.max(1,Math.ceil(_n/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function Wu(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Hn(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((u,c)=>{if(c%i.step!==0)return;const m=o(c),d=Wu(u,i.maxChars),f={x:String(m),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${m}, ${s})`);const g=ge("text",f,[d]);d!==u&&g.append(ge("title",{},[u])),t.append(g)})}function Pr(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ge(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function Vn(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ge("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ge("text",{x:String(e.left-6),y:String(c+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}function Ir(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${Ze(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const qu={name:"SectionBlock",description:"Titled chat block with a description and child content.",props:[{name:"title",type:"string"},{name:"children",type:"Node[]"},{name:"description",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("section",{class:"rui-section-block"});a.append(l("h3",{class:"rui-section-block-title"},[p(e.title)]));const n=p(e.description);n&&a.append(l("p",{class:"rui-section-block-description"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},Gu={name:"ListBlock",description:"Chat-styled list with bullets, useful for steps or summaries.",props:[{name:"items",type:"string[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e)=>{const r=T(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of C(e.items))a.append(l("li",{},[p(n)]));return a}},Ku={name:"FollowUpBlock",description:'Suggested follow-up prompts shown as buttons. Each item dispatches its label as an assistant message (equivalent to `emit "assistant-message" { message }`).',props:[{name:"items",type:"FollowUpItem[]",description:"Array of FollowUpItem(label, message?), {label, message} objects, or plain strings"},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-follow-up"}),n=p(e.title,"You can also ask");n&&a.append(l("div",{class:"rui-follow-up-title"},[n]));const i=l("div",{class:"rui-follow-up-list"});for(const o of C(e.items))i.append(Yu(o,r));return a.append(i),a}},Yu=(t,e)=>{const{label:r,message:a}=Xu(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},Xu=t=>{if(typeof t=="string")return{label:t,message:t};if(t&&typeof t=="object"){const r=t;if(r.__kind==="Component"&&Array.isArray(r.args)){const i=p(r.args[0]),o=p(r.args[1],i);return{label:i,message:o}}const a=p(r.label),n=p(r.message,a);return{label:a,message:n}}const e=p(t);return{label:e,message:e}},Ju={name:"FollowUpItem",description:"Single follow-up item.",props:[{name:"label",type:"string"},{name:"message",type:"string",optional:!0,description:"Defaults to label"}],render:(t,e,r)=>{const a=p(e.label),n=p(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},Zu={name:"ActionLink",description:"Inline link that runs an action when clicked instead of navigating.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",aliases:["action","onclick"]}],render:(t,e,r)=>{const a=l("a",{class:"rui-action-link",href:"#",role:"button"},[p(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},Wn=["sm","md","lg","xl"],qn={name:"Avatar",description:'User avatar. Shows the image at `src`. When `src` is missing, falls back to a deterministic DiceBear illustration seeded by `name` (pass `fallback="initials"` to render two-letter initials instead). If the image errors at runtime the avatar gracefully degrades to initials.',props:[{name:"name",type:"string",description:"Used for alt text + initials fallback"},{name:"src",type:"string",optional:!0,description:"Image URL"},{name:"size",type:"string",optional:!0,enum:Wn},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:["initials","dicebear"],description:"How to render when `src` is missing (default: dicebear illustration; pass `initials` for the two-letter pill)"}],render:(t,e)=>{const r=p(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=p(e.name),i=p(e.fallback,"dicebear"),o=ne(e.src),s=!o&&i==="dicebear"&&n?ne(dc(n)):"",u=o||s;if(u){const m=l("img",{src:u,alt:n,loading:"lazy"});m.onerror=d=>{const f=d;(f.currentTarget??f.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[ct(n)]))},a.append(m)}else a.append(l("span",{class:"rui-avatar-fallback"},[ct(n)]));const c=p(e.status);return c&&a.append(l("span",{class:"rui-avatar-status","data-status":c})),a}},Qu={name:"AvatarGroup",description:"Stack of overlapping avatars with a `+N` chip when the list overflows. Pass either Avatar(...) nodes or plain {name, src} objects.",props:[{name:"items",type:"Avatar[]",description:"Avatar(...) nodes or {name, src} objects"},{name:"max",type:"number",optional:!0,description:"Maximum avatars to show (default 4)"},{name:"size",type:"string",optional:!0,enum:Wn}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=p(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,u=l("div",{class:"rui-avatar-group","data-size":i});for(const c of o){if(c&&typeof c=="object"&&c.__kind==="Component"){u.append(r.renderNode(c));continue}const m=c,d=typeof m=="string"?m:p((m??{}).name),f=typeof m=="string"?"":p((m??{}).src);u.append(qn.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:f,size:i},r))}return s>0&&u.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),u}},ed={name:"Progress",description:"Linear progress bar. `value` is clamped between 0 and `max` (default 100). `indeterminate=true` renders a looping animation when the total is unknown. Provide `segments` to render a segmented progress strip (steps in an onboarding flow), or `buffered` for a secondary buffer indicator (downloads, video buffering).",props:[{name:"value",type:"number",optional:!0,description:"Current progress; ignored when indeterminate"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:"Shown above the bar"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"indeterminate",type:"boolean",optional:!0},{name:"showValue",type:"boolean",optional:!0,description:"Show the numeric value on the right"},{name:"segments",type:"number",optional:!0,description:"Render N equal segments (filled by current step)"},{name:"buffered",type:"number",optional:!0,description:"Secondary value (0..max) drawn behind the bar"}],render:(t,e)=>{const r=Math.max(1,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(L(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,L(e.buffered,0))):null,u=l("div",{class:"rui-progress","data-tone":p(e.tone,"primary")}),c=p(e.label),m=T(e.showValue);if(c||m){const f=l("div",{class:"rui-progress-head"});if(f.append(l("span",{class:"rui-progress-label"},[c])),m&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;f.append(l("span",{class:"rui-progress-value"},[g]))}u.append(f)}if(o>0&&!a){const f=l("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(n/r*o)))}),g=Math.min(o,Math.round(n/r*o));for(let h=0;h<o;h+=1)f.append(l("span",{class:"rui-progress-segment","data-filled":h<g?"true":"false"}));return u.append(f),u}const d=l("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":a?null:String(n),"data-indeterminate":a?"true":"false"});if(s!==null){const f=Math.round(s/r*100);d.append(l("div",{class:"rui-progress-buffer",style:`width:${f}%`,"aria-hidden":"true"}))}return d.append(l("div",{class:"rui-progress-bar",style:a?"":`width:${i}%`})),u.append(d),u}},td={name:"Switch",description:"Compact on/off toggle. Pass a `$variable` as `value` for two-way binding — prefer Switch over Checkbox when the control represents a setting. `onChange(checked)` fires with the new boolean.",props:[{name:"id",type:"string"},{name:"label",type:"string",optional:!0},{name:"value",type:"boolean",optional:!0,aliases:["checked"],description:"Bound value (typically $variable)"},{name:"description",type:"string",optional:!0},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new boolean value"}],render:(t,e,r)=>{const a=p(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":T(e.disabled)?"true":"false"}),i=T(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:T(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),u=t.argMeta?.[2]?.stateRef;u&&r.bindState(o,u,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const c=p(e.label),m=p(e.description);if(n.append(o,s),c||m){const d=l("span",{class:"rui-switch-meta"});c&&d.append(l("span",{class:"rui-switch-label"},[c])),m&&d.append(l("span",{class:"rui-switch-description"},[m])),n.append(d)}return n}},rd={name:"ToggleGroup",description:"Group of mutually-exclusive Toggle-style buttons (single-select). Items are `[value, label]` arrays, `{value, label, icon?}` objects, or plain strings (used for both value and label). Pass a `$variable` as `value` for two-way binding. `onChange(value)` fires with the newly-selected value.",props:[{name:"id",type:"string"},{name:"items",type:"any[]"},{name:"value",type:"any",optional:!0},{name:"variant",type:"string",optional:!0,enum:["default","outline"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected value"}],render:(t,e,r)=>{const a=p(e.value),n=p(e.variant,"outline"),i=p(e.size,"md"),o=l("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":n,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const u of C(e.items)){const{value:c,label:m,icon:d}=ad(u),f=c===a,g=l("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":f?"true":"false","data-variant":n,"data-size":i,"data-state":f?"on":"off","data-value":c}),h=z(d,{className:"rui-toggle-icon"});h&&g.append(h),g.append(l("span",{class:"rui-toggle-label"},[m])),g.onclick=()=>{s&&r.setState(s,c),r.invoke(e.onChange,c)},o.append(g)}return o}};function ad(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:p(t[0]),label:p(t[1],p(t[0])),icon:p(t[2])};if(t&&typeof t=="object"){const e=t,r=p(e.value);return{value:r,label:p(e.label,r),icon:p(e.icon)}}return{value:"",label:"",icon:""}}const nd={name:"Tooltip",description:"Wraps a trigger node and shows `label` text when the user hovers or focuses it. Pure CSS — no JS needed. The tooltip hides on click/touch (so it does not stay stuck on touch devices) and supports `top|bottom|left|right` placement. Use for short hints (≤6 words); reach for HoverCard when you need rich content.",props:[{name:"label",type:"string"},{name:"trigger",type:"Node",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]}],render:(t,e,r)=>{const a=p(e.side,"top"),n=l("span",{class:"rui-tooltip","data-side":a,tabindex:"0"});n.append(l("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=l("span",{class:"rui-tooltip-content",role:"tooltip"},[p(e.label)]);return i.append(l("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),n.append(i),n.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===n||n.contains(document.activeElement))&&document.activeElement?.blur?.()})}),n}},id={name:"HoverCard",description:"Wraps a trigger node and reveals a card with rich content on hover/focus. Use for previewing a referenced item (profile, link target, definition).",props:[{name:"trigger",type:"Node"},{name:"content",type:"Node[]",aliases:["children"]},{name:"side",type:"string",optional:!0,enum:["top","bottom","left","right"],aliases:["placement"]},{name:"open",type:"boolean",optional:!0,description:"Force the card open (otherwise reveal on hover/focus)"}],render:(t,e,r)=>{const a=l("span",{class:"rui-hover-card","data-side":p(e.side,"bottom"),"data-open":T(e.open)?"true":null,tabindex:"0"});a.append(l("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const n=l("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of C(e.content))n.append(r.renderNode(i));return a.append(n),a}},Lr={star:{full:"star",half:"star-half-stroke",empty:"regular:star"},heart:{full:"heart",half:"heart",empty:"regular:heart"},thumb:{full:"thumbs-up",half:"thumbs-up",empty:"regular:thumbs-up"},fire:{full:"fire",half:"fire",empty:"regular:fire"},bolt:{full:"bolt",half:"bolt",empty:"regular:bolt"}},od={name:"Rating",description:"Compact 0–5 star rating with optional numeric badge and review count. Use in product cards, testimonials, reviews, and KPI rows. Pass `interactive=true` and a `$variable` as `value` to let users rate something; with `halfStep=true` clicking the left half of a star sets a fractional value. `icon` swaps the glyph family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any custom Font Awesome name.",props:[{name:"value",type:"number",description:"0–max; can be a $variable when interactive"},{name:"max",type:"number",optional:!0,description:"Maximum number of stars (default 5)"},{name:"label",type:"string",optional:!0,description:'Inline text shown after the stars (e.g. "4.2 of 5")'},{name:"count",type:"number",optional:!0,description:"Review/voter count rendered in parentheses"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"interactive",type:"boolean",optional:!0,description:"Allow clicking a star to set the value"},{name:"readonly",type:"boolean",optional:!0,description:"Force read-only (overrides `interactive`)"},{name:"halfStep",type:"boolean",optional:!0,description:"Allow half-star resolution when interactive"},{name:"icon",type:"string",optional:!0,description:"Icon family — `star` (default), `heart`, `thumb`, `fire`, `bolt`, or any FA name"},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new rating when the user clicks a star (interactive mode)"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.max,5))),n=Math.max(0,Math.min(a,L(e.value,0))),i=p(e.size,"md"),o=T(e.interactive)&&!T(e.readonly),s=T(e.halfStep),u=t.argMeta?.[0]?.stateRef,c=sd(p(e.icon)),m=l("div",{class:"rui-rating","data-size":i,"data-interactive":o&&u?"true":"false","data-half-step":o&&u&&s?"true":"false",role:"img","aria-label":`${n} of ${a}`}),d=l("span",{class:"rui-rating-stars"});for(let h=1;h<=a;h+=1){const b=Math.max(0,Math.min(1,n-(h-1))),v=b>=1?c.full:b>0?c.half:c.empty,y=vr(v).join(" "),x=l(o&&u?"button":"span",{class:`rui-rating-star ${y}`.trim(),type:o&&u?"button":null,"data-fill":b>=1?"full":b>0?"half":"empty","aria-label":o&&u?`Rate ${h}`:null,"aria-hidden":o&&u?null:"true"});if(o&&u){const w=h,k=h-.5;x.onclick=A=>{let S=w;if(s){const $=A,I=($.currentTarget??$.target).getBoundingClientRect();I.width>0&&$.clientX-I.left<I.width/2&&(S=k)}r.setState(u,S),r.invoke(e.onChange,S)}}d.append(x)}m.append(d);const f=p(e.label);f&&m.append(l("span",{class:"rui-rating-label"},[f]));const g=e.count!=null?L(e.count,0):null;return g!==null&&g>0&&m.append(l("span",{class:"rui-rating-count"},[`(${g.toLocaleString()})`])),m}};function sd(t){const e=t.trim().toLowerCase();return e?Lr[e]?Lr[e]:{full:e,half:e,empty:`regular:${e}`}:Lr.star}const ld={name:"ProgressRing",description:"Circular progress indicator. Use for KPIs, quotas, completion rings, and any metric better shown as a circle than a bar. Renders the value (or a custom label) inside the ring.",props:[{name:"value",type:"number",optional:!0,description:"Current value (ignored when indeterminate)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"label",type:"string",optional:!0,description:'Text shown inside the ring (default "{percent}%")'},{name:"caption",type:"string",optional:!0,aliases:["description"],description:"Small caption rendered under the ring"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"indeterminate",type:"boolean",optional:!0}],render:(t,e)=>{const r=Math.max(1,L(e.max,100)),a=T(e.indeterminate),n=Math.max(0,Math.min(r,L(e.value,0))),i=Math.round(n/r*100),o=p(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,u=o==="lg"?10:o==="sm"?6:8,c=(s-u)/2,m=2*Math.PI*c,d=a?m*.65:m*(1-i/100),f=l("div",{class:"rui-progress-ring","data-tone":p(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",b=document.createElementNS(h,"svg");b.setAttribute("width",String(s)),b.setAttribute("height",String(s)),b.setAttribute("viewBox",`0 0 ${s} ${s}`),b.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(c)),v.setAttribute("stroke-width",String(u)),v.setAttribute("fill","none"),b.appendChild(v);const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(c)),y.setAttribute("stroke-width",String(u)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(m)),y.setAttribute("stroke-dashoffset",String(d)),b.appendChild(y),g.append(b);const x=p(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=z(x,{className:"rui-progress-ring-icon"});k&&vr(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),f.append(g);const A=p(e.caption);return A&&f.append(l("span",{class:"rui-progress-ring-caption"},[A])),f}},cd={name:"ChatBubble",description:'Single chat-style message bubble with author, time, and body. Use for conversation threads, agent transcripts, support chats, and any message-style UI. Set `from="me"` (or any non-empty author) for the active speaker — the bubble aligns to the right with a primary tint. `from="agent"` (default) renders as the canonical incoming bubble on the left.',props:[{name:"author",type:"string"},{name:"body",type:"string",aliases:["text","message"]},{name:"time",type:"string",optional:!0},{name:"avatarSrc",type:"string",optional:!0,aliases:["src"]},{name:"from",type:"string",optional:!0,enum:["agent","me","system"],aliases:["role"],description:"Lane (default agent)"},{name:"status",type:"string",optional:!0,enum:["sending","sent","delivered","read","error"]}],render:(t,e)=>{const r=p(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(Gn(p(e.avatarSrc),p(e.author)));const n=l("div",{class:"rui-chat-bubble-bubble"}),i=l("header",{class:"rui-chat-bubble-head"});i.append(l("span",{class:"rui-chat-bubble-author"},[p(e.author)]));const o=p(e.time);o&&i.append(l("span",{class:"rui-chat-bubble-time"},[o])),n.append(i),n.append(l("p",{class:"rui-chat-bubble-body"},[p(e.body)]));const s=p(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(Gn(p(e.avatarSrc),p(e.author))),a}};function Gn(t,e){const r=l("span",{class:"rui-chat-bubble-avatar"}),a=ne(t);return a?r.append(l("img",{src:a,alt:e,loading:"lazy"})):r.append(l("span",{class:"rui-chat-bubble-fallback"},[ct(e)])),r}const ud={name:"Kbd",description:"Renders a keyboard shortcut chip (e.g. `Cmd+K`). Pass a single label, or multiple labels as an array to render a `key + key + …` combo.",props:[{name:"keys",type:"string | string[]"},{name:"size",type:"string",optional:!0,enum:["sm","md"]}],render:(t,e)=>{const r=p(e.size,"md"),a=l("span",{class:"rui-kbd-group","data-size":r});return(Array.isArray(e.keys)?e.keys:[e.keys]).forEach((i,o)=>{const s=p(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},dd={name:"Popover",description:"Click-triggered popup with arbitrary rich content. Use when HoverCard's hover trigger is too eager and Modal/Sheet is too heavy — perfect for filter panels, color pickers, share menus, and small settings flyouts. The trigger stays visible while the popover is open — clicking it again, clicking outside, pressing Escape, or clicking the built-in × button all close it.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (Button, Avatar, IconButton, …). The trigger remains visible while the popover is open."},{name:"content",type:"Node[]",aliases:["children"],description:"Body rendered inside the popover"},{name:"title",type:"string",optional:!0,description:"Optional bold heading rendered above the content"},{name:"side",type:"string",optional:!0,enum:["bottom","top","left","right"],aliases:["placement"],description:'Where the popover opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:["start","center","end"],description:'Alignment along the trigger edge (default "start")'},{name:"width",type:"string",optional:!0,description:'CSS width for the popover panel (default "280px")'},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the popover"}],render:(t,e,r)=>{const a=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=te(e.width,""),s=l("div",{class:"rui-popover","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(e.align,"start")}),u=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});u.append(r.renderNode(e.trigger)),s.append(u);const c=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),m=l("div",{class:"rui-popover-header"}),d=p(e.title);m.append(d?l("div",{class:"rui-popover-title"},[d]):l("span",{class:"rui-popover-title-spacer"}));const f=l("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);f.onclick=g=>{g.stopPropagation(),Dt(f,!1,n)},m.append(f),c.append(m);for(const g of C(e.content))c.append(r.renderNode(g));return s.append(c),u.onclick=g=>{g.stopPropagation();const h=g.currentTarget??g.target,b=!n.get(),v=Dt(h,b,n);b&&v&&Kn(v,n)},u.onkeydown=g=>{const h=g,b=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const v=!n.get(),y=Dt(b,v,n);v&&y&&Kn(y,n)}else h.key==="Escape"&&n.get()&&(h.preventDefault(),Dt(b,!1,n))},s}},Dt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-popover");if(!a)return null;a.setAttribute("data-open",e?"true":"false");const n=a.querySelector(".rui-popover-trigger");return n?.setAttribute("aria-expanded",e?"true":"false"),n?.setAttribute("data-state",e?"open":"closed"),e||Ae(a),a},Kn=(t,e)=>{Xe({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false");const r=t.querySelector(".rui-popover-trigger");r?.setAttribute("aria-expanded","false"),r?.setAttribute("data-state","closed")}})},pd={name:"Toast",description:"Single transient notification card. Always shows a close (×) button that removes the toast from the DOM (and fires `onClose` if set). Pass `duration` (ms) to auto-dismiss, or `position` for a standalone one-off toast (the renderer will pin it to the viewport corner so you do not have to wrap a single notification in `Stack(...)`). Use `Toasts` for grouped stacks; prefer `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.",props:[{name:"title",type:"string"},{name:"message",type:"string",optional:!0,aliases:["description"]},{name:"tone",type:"string",optional:!0,enum:["default","primary","success","warning","danger","info"],description:'Visual accent (default "default")'},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name (default picked from tone)"},{name:"duration",type:"number",optional:!0,description:"Auto-dismiss after N milliseconds (e.g. 4000). Omit to keep the toast until the user closes it."},{name:"action",type:"Button",optional:!0,description:"Optional inline `Button` action shown above the message"},{name:"onClose",type:"callable",optional:!0,description:"Callable invoked when the toast is dismissed (× button, auto-dismiss, or programmatic)"},{name:"position",type:"string",optional:!0,enum:["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const a=p(e.tone,"default"),n=p(e.position),i=l("div",{class:n?"rui-toast rui-toast-standalone":"rui-toast",role:"status","aria-live":a==="danger"?"assertive":"polite","data-tone":a,"data-position":n||null}),o=p(e.icon)||md(a),s=z(o,{className:"rui-toast-icon"});s&&i.append(s);const u=l("div",{class:"rui-toast-body"});u.append(l("div",{class:"rui-toast-title"},[p(e.title)]));const c=p(e.message);if(c&&u.append(l("div",{class:"rui-toast-message"},[c])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),u.append(x)}i.append(u);const m=r.useInstanceState("dismissed",!1),d=r.useInstanceState("timer",null),f=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},g=()=>{const x=d.get();x!==null&&(clearTimeout(x),d.set(null))},h=r.useInstanceState("removal-timer",null),b=x=>{if(m.get())return;m.set(!0),g();const w=f(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{h.set(null),w.remove()},180);h.set(k),r.registerDisposer(()=>{const A=h.get();A!==null&&(clearTimeout(A),h.set(null))},"exit-animation-timer"),r.invoke(e.onClose)},v=l("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);v.onclick=x=>{x.stopPropagation(),b(x.currentTarget??x.target)},i.append(v);const y=L(e.duration,0);if(y>0&&d.get()===null&&!m.get()){const x=setTimeout(()=>{d.set(null),!m.get()&&i.isConnected&&b()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return m.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function md(t){switch(t){case"success":return"circle-check";case"warning":return"triangle-exclamation";case"danger":return"circle-xmark";case"primary":return"bell";case"info":return"circle-info";default:return"circle-info"}}const Yn={name:"BreadcrumbItem",description:"Single item inside a Breadcrumb trail. Provide `href` for a link, omit it for the current/leaf page (rendered with emphasis).",props:[{name:"label",type:"string"},{name:"href",type:"string",optional:!0},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name"}],render:(t,e)=>{const r=l("li",{class:"rui-breadcrumb-item"}),a=p(e.label),n=p(e.href),i=n?Ye(n):"",o=[],s=z(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(l("span",{class:"rui-breadcrumb-label"},[a])),i)r.append(l("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const u=l("span",{class:"rui-breadcrumb-current"});for(const c of o)c&&u.append(typeof c=="string"?document.createTextNode(c):c);r.append(u)}return r}},fd={name:"Breadcrumb",description:"Trail of links showing the user's location. Children may be BreadcrumbItem(label, href?) nodes OR plain strings (the last string is treated as the current page).",props:[{name:"items",type:"BreadcrumbItem[] | string[]"},{name:"separator",type:"string",optional:!0,description:"Default `/`"}],render:(t,e,r)=>{const a=C(e.items),n=p(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,u)=>{if(u>0&&o.append(l("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[n])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const c=p(s),m=u===a.length-1;o.append(Yn.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:c,href:m?"":"#"},r))}),i.append(o),i}},gd=[10,20,50,100],hd={name:"Pagination",description:'Page navigator with Prev/Next, page numbers, and ellipses. Pass a `$variable` as `page` for two-way binding — clicking a page button sets that state to the new (1-indexed) value. Add `total` to render a "Showing N–M of T" summary, pass `$variable` as `perPage` to expose a per-page selector, or set `compact: true` to drop the page-number row for tight toolbars.',props:[{name:"page",type:"number",description:"Current page (1-indexed); typically a $variable"},{name:"totalPages",type:"number",aliases:["pages"]},{name:"siblings",type:"number",optional:!0,description:"Number of page links shown around the current page (default 1)"},{name:"total",type:"number",optional:!0,description:'Total record count — enables the "Showing N–M of T" summary'},{name:"perPage",type:"number",optional:!0,description:"Bind a `$variable` to expose a per-page selector"},{name:"perPageOptions",type:"number[]",optional:!0,description:"Override the per-page choices (default 10/20/50/100)"},{name:"compact",type:"boolean",optional:!0,description:"Hide page numbers — keep Prev / Next only"}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(L(e.page,1)))),i=Math.max(0,Math.floor(L(e.siblings,1))),o=T(e.compact),s=t.argMeta?.[0]?.stateRef,u=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),c=b=>{if(!s)return;const v=Math.max(1,Math.min(a,b));v!==n&&r.setState(s,v)},m=e.total!=null?Math.max(0,Math.floor(L(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(L(e.perPage,0))):null;if(m!==null&&d&&d>0){const b=m===0?0:(n-1)*d+1,v=Math.min(m,n*d);u.append(l("span",{class:"rui-pagination-summary"},[m===0?"No results":`Showing ${b.toLocaleString()}–${v.toLocaleString()} of ${m.toLocaleString()}`]))}else m!==null&&u.append(l("span",{class:"rui-pagination-summary"},[`${m.toLocaleString()} result${m===1?"":"s"}`]));const f=l("div",{class:"rui-pagination-buttons"}),g=(b,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[b]);const x=l("button",{type:"button",class:"rui-pagination-button","data-active":y.active?"true":"false","aria-current":y.active?"page":null,"aria-label":y.ariaLabel??null,disabled:y.disabled?"":null},[b]);return!y.disabled&&!y.active&&(x.onclick=()=>c(v)),x};if(f.append(g("‹",n-1,{disabled:n<=1,ariaLabel:"Previous page"})),o)f.append(l("span",{class:"rui-pagination-current"},[`${n} / ${a}`]));else{const b=bd(n,a,i);for(const v of b)v==="…"?f.append(g("…",0,{ellipsis:!0})):f.append(g(String(v),v,{active:v===n}))}f.append(g("›",n+1,{disabled:n>=a,ariaLabel:"Next page"})),u.append(f);const h=t.argMeta?.[4]?.stateRef;if(d&&(h||C(e.perPageOptions).length>0)){const b=C(e.perPageOptions).length>0?C(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(gd),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of b){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}h&&r.bindState(y,h,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),u.append(v)}return u}};function bd(t,e,r){const a=[],n=(u,c)=>{for(let m=u;m<=c;m+=1)a.push(m)},i=r*2+5;if(e<=i)return n(1,e),a;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return a.push(1),o>2&&a.push("…"),n(o,s),s<e-1&&a.push("…"),a.push(e),a}const vd={name:"NavbarItem",description:"Single link inside a Navbar's main item slot. Renders as an inline anchor / button — pass `to` for a router-aware link, `href` for an external link, or `onClick` for a click handler. `active=true` highlights the current page.",props:[{name:"label",type:"string"},{name:"to",type:"string",optional:!0,description:"Internal route (consumes the built-in router)"},{name:"href",type:"string",optional:!0,description:"External href; opens in a new tab when set with `external=true`"},{name:"icon",type:"string",optional:!0},{name:"active",type:"boolean",optional:!0},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable fired on click (alternative to `to`/`href`)"},{name:"external",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=p(e.label),n=e.icon,i=T(e.active),o=p(e.to),s=Ye(e.href,""),u=T(e.external),c=o||s?"a":"button",m=l(c,{class:"rui-navbar-item",type:c==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:u&&s?"_blank":null,rel:u&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=z(n,{className:"rui-navbar-item-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?m.onclick=f=>{if(f.defaultPrevented)return;const g=f;g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(f.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(m.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),m}},yd={name:"Navbar",description:"Top navigation bar with a brand on the left, primary nav items in the middle, and a right-aligned actions slot (user avatar, DropdownMenu, CTA buttons, …). Use `sticky=true` to pin it to the top of the page. The canonical companion of `Sidebar` for product surfaces; prefer Navbar for marketing/docs pages without a sidebar.",props:[{name:"brand",type:"string | Node",optional:!0,description:"Workspace/product name (string) or a node (e.g. logo Image)"},{name:"items",type:"NavbarItem[]",optional:!0,description:"Center navigation items"},{name:"actions",type:"Node[]",optional:!0,description:"Right-side controls (Buttons, Avatar, DropdownMenu, …)"},{name:"sticky",type:"boolean",optional:!0,description:"Pin the bar to the top of the viewport"},{name:"variant",type:"string",optional:!0,enum:["default","transparent"],description:"Visual variant"}],render:(t,e,r)=>{const a=l("nav",{class:"rui-navbar","data-sticky":T(e.sticky)?"true":"false","data-variant":p(e.variant,"default"),"aria-label":"Primary"}),n=e.brand;if(n!=null&&n!==""){const s=l("div",{class:"rui-navbar-brand"});typeof n=="string"?s.append(document.createTextNode(n)):s.append(r.renderNode(n)),a.append(s)}const i=C(e.items);if(i.length>0){const s=l("div",{class:"rui-navbar-items"});for(const u of i)s.append(r.renderNode(u));a.append(s)}const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const u of o)s.append(r.renderNode(u));a.append(s)}return a}},xd=["bottom","top","left","right"],wd=["start","center","end"],kd=["default","danger"],jt=(t,e,r)=>{r.set(e);const a=t.closest(".rui-dropdown-menu");return a?(a.setAttribute("data-open",e?"true":"false"),a.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||Ae(a),a):null},Xn=(t,e)=>{Xe({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Rr=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},Sd={name:"DropdownMenu",description:"Click-triggered dropdown menu. Click the trigger to toggle, click a MenuItem to run its action and close, click outside or press Escape to close without acting. Children must be MenuItem, MenuSeparator, or MenuLabel entries.",props:[{name:"trigger",type:"Node",description:"Clickable trigger element (typically a Button or Avatar)"},{name:"items",type:"(MenuItem | MenuSeparator | MenuLabel)[]"},{name:"side",type:"string",optional:!0,enum:xd,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:wd,description:'How the menu aligns along the trigger edge (default "start")'},{name:"label",type:"string",optional:!0,description:"Optional ARIA label for the menu"},{name:"open",type:"boolean",optional:!0,description:"Initial open state — use to demo or pre-open the menu"}],render:(t,e,r)=>{const a=T(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":p(e.side,"bottom"),"data-align":p(e.align,"start")}),s=l("span",{class:"rui-dropdown-menu-trigger","data-state":i?"open":"closed","aria-haspopup":"menu","aria-expanded":i?"true":"false",tabindex:"0"});s.append(r.renderNode(e.trigger)),s.onclick=c=>{c.stopPropagation();const m=c.currentTarget??c.target,d=!n.get(),f=jt(m,d,n);d&&f&&Xn(f,n)},s.onkeydown=c=>{const m=c,d=m.currentTarget??m.target;if(m.key==="Enter"||m.key===" "){m.preventDefault();const f=!n.get(),g=jt(d,f,n);f&&g&&Xn(g,n);return}m.key==="Escape"&&n.get()&&(m.preventDefault(),jt(d,!1,n))},o.append(s);const u=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":p(e.label)||null});for(const c of C(e.items)){if(Rr(c,"MenuItem")){const m=c.args??[],d=p(m[0]),f=m[1],g=m[2],h=p(m[3]),b=p(m[4],"default"),v=T(m[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":b,disabled:v?"":null}),x=z(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),h&&y.append(l("span",{class:"rui-menu-item-shortcut"},[h])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;jt(k,!1,n),r.invoke(f)}),u.append(y);continue}if(Rr(c,"MenuSeparator")){u.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Rr(c,"MenuLabel")){const m=p((c.args??[])[0]);u.append(l("div",{class:"rui-menu-label"},[m]));continue}u.append(r.renderNode(c))}return o.append(u),o}},Cd={name:"MenuItem",description:"Single item inside a DropdownMenu. Renders a button-style row with an optional leading icon and trailing keyboard-shortcut hint. `onClick` (legacy: `action`) runs when clicked; the menu closes automatically afterwards.",props:[{name:"label",type:"string"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"],description:"Callable to execute on click"},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon name shown before the label"},{name:"shortcut",type:"string",optional:!0,description:'Trailing keyboard-shortcut hint (e.g. "⌘ K")'},{name:"variant",type:"string",optional:!0,enum:kd,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=T(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":p(e.variant,"default"),disabled:a?"":null}),i=z(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[p(e.label)]));const o=p(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},$d={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},Td={name:"MenuLabel",description:'Small uppercase section header inside a DropdownMenu. Use to group related MenuItems (e.g. "Account", "Workspace", "Danger zone").',props:[{name:"label",type:"string"}],render:(t,e)=>l("div",{class:"rui-menu-label"},[p(e.label)])},Ad=["left","center","right"];function Nd(t){return C(t).map((e,r)=>{const a=e.args??[],n=p(a[0]);return{header:n,values:C(a[1]),format:p(a[2],"text"),align:Ad.includes(p(a[3]))?p(a[3]):"",sortable:T(a[4]),filterable:T(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function Jn(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return L(t,0)-L(e,0);if(r==="date"){const a=new Date(p(t)).getTime(),n=new Date(p(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return p(t).localeCompare(p(e))}function Bt(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():p(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):p(t);case"date":try{const r=new Date(p(t));return Number.isNaN(r.getTime())?p(t):r.toLocaleDateString()}catch{return p(t)}default:return p(t)}}const Md={name:"DataGrid",description:"Advanced data table with sortable headers, per-column filter chips, row selection (checkboxes), sticky header / first column, optional pagination, an optional bulk-action toolbar slot, and click-to-act rows. Columns are Col(header, values, format?, align?, sortable?, filterable?) entries. Bind `$sort` (`{key, direction}` object), `$selectedIds` (string[]), and `$page` (number) for full reactivity. Use INSTEAD of `Table` when you need any of those interactions.",props:[{name:"columns",type:"Col[]",description:"Columns; pass sortable=true / filterable=true on each Col."},{name:"rowIds",type:"any[]",optional:!0,description:"Stable id per row (used by `selectedIds`); defaults to row index."},{name:"caption",type:"string",optional:!0},{name:"sort",type:"object",optional:!0,description:"`{key, direction}` — pass a $variable for two-way binding"},{name:"selectedIds",type:"any[]",optional:!0,description:"Array of selected row ids — bind a $variable"},{name:"selectable",type:"boolean",optional:!0,description:"Render leading selection checkboxes"},{name:"page",type:"number",optional:!0,description:"1-indexed current page — bind a $variable"},{name:"perPage",type:"number",optional:!0,description:"Page size (default 20)"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when no rows match (default `No results`)"},{name:"onRowClick",type:"callable",optional:!0,aliases:["rowAction"],description:"Callable fired when a row is clicked. Receives the row index."},{name:"toolbar",type:"Node[]",optional:!0,description:"Bulk-action toolbar shown above the table when any rows are selected"},{name:"density",type:"string",optional:!0,enum:["comfortable","compact"]},{name:"striped",type:"boolean",optional:!0},{name:"stickyHeader",type:"boolean",optional:!0,description:"Pin the header row (default true)"},{name:"stickyFirstColumn",type:"boolean",optional:!0,description:"Pin the first column horizontally"}],render:(t,e,r)=>{const a=Nd(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=C(e.rowIds),o=B=>p(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,u=p(s?.key),c=p(s?.direction,"asc")==="desc"?"desc":"asc",m=C(e.selectedIds).map(B=>p(B)),d=new Set(m),f=T(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:T(e.stickyHeader),h=T(e.stickyFirstColumn),b=p(e.density,"comfortable"),v=T(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let q=!0;for(const Y of a){if(!Y.filterable)continue;const G=(x[Y.key]??"").trim().toLowerCase();if(!G)continue;const ae=Y.values[B];if(!Bt(ae,Y.format).toLowerCase().includes(G)){q=!1;break}}q&&w.push(B)}if(u){const B=a.find(q=>q.key===u);B&&B.sortable&&w.sort((q,Y)=>{const G=Jn(B.values[q],B.values[Y],B.format);return c==="desc"?-G:G})}const k=w.length,A=Math.max(1,Math.floor(L(e.perPage,20))),S=Math.max(1,Math.ceil(k/A)),$=Math.max(1,Math.floor(L(e.page,1))),M=Math.min($,S),I=w.slice((M-1)*A,M*A),E=l("div",{class:"rui-data-grid","data-density":b,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":h?"true":"false"}),D=t.argMeta?.[3]?.stateRef,K=t.argMeta?.[4]?.stateRef,F=t.argMeta?.[6]?.stateRef,U=C(e.toolbar);if(m.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${m.length} selected`]));const q=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)q.append(r.renderNode(Y));B.append(q),E.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),de=p(e.caption);de&&Z.append(l("caption",{class:"rui-data-grid-caption"},[de]));const Se=l("thead"),ft=l("tr");if(f){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),q=I.length>0&&I.every(G=>d.has(o(G))),Y=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:q?"":null});K&&(Y.onclick=G=>{const ae=G.currentTarget,ee=new Set(m);for(const X of I){const Q=o(X);ae.checked?ee.add(Q):ee.delete(Q)}r.setState(K,Array.from(ee))}),B.append(Y),ft.append(B)}if(a.forEach((B,q)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===u?"true":null,"data-first":q===0?"true":null});if(B.sortable&&D){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const ae=B.key===u?c==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=z(ae,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===u&&c==="asc"?"desc":"asc";r.setState(D,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));ft.append(Y)}),Se.append(ft),a.some(B=>B.filterable)){const B=l("tr",{class:"rui-data-grid-filter-row"});f&&B.append(l("td",{class:"rui-data-grid-cell-select"})),a.forEach(q=>{const Y=l("td");if(q.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${q.header}`,value:x[q.key]??""});G.oninput=ae=>{const ee=ae.currentTarget,X={...y.get(),[q.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");Af(Q)},Y.append(G)}B.append(Y)}),Se.append(B)}Z.append(Se);const He=l("tbody");Z.append(He);const Wr=B=>{if(He.replaceChildren(),B.length===0){const q=l("tr"),Y=(f?1:0)+Math.max(a.length,1);q.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),He.append(q);return}for(const q of B){const Y=o(q),G=d.has(Y),ae=l("tr",{"data-selected":G?"true":null});if(f){const ee=l("td",{class:"rui-data-grid-cell-select"}),X=l("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:G?"":null});K&&(X.onclick=Q=>{Q.stopPropagation();const ve=Q.currentTarget,ye=new Set(m);ve.checked?ye.add(Y):ye.delete(Y),r.setState(K,Array.from(ye))}),ee.append(X),ae.append(ee)}a.forEach((ee,X)=>{const Q=l("td",{"data-format":ee.format,"data-align":ee.align||null,"data-first":X===0?"true":null});yr(Q,ee,ee.values[q],q,r,Bt),ae.append(Q)}),typeof e.onRowClick=="function"&&(ae.setAttribute("data-clickable","true"),ae.onclick=ee=>{ee.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,q)}),He.append(ae)}},Af=B=>{const q=B??He,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const ve of a){if(!ve.filterable)continue;const ye=(Y[ve.key]??"").trim().toLowerCase();if(!ye)continue;const gt=ve.values[X];if(!Bt(gt,ve.format).toLowerCase().includes(ye)){Q=!1;break}}Q&&G.push(X)}if(u){const X=a.find(Q=>Q.key===u);X&&X.sortable&&G.sort((Q,ve)=>{const ye=Jn(X.values[Q],X.values[ve],X.format);return c==="desc"?-ye:ye})}const ae=G.slice((M-1)*A,M*A);(X=>{X.replaceChildren();for(const Q of ae){const ve=o(Q),ye=d.has(ve),gt=l("tr",{"data-selected":ye?"true":null});if(f){const Ve=l("td",{class:"rui-data-grid-cell-select"}),qr=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:ye?"":null});Ve.append(qr),gt.append(Ve)}a.forEach((Ve,qr)=>{const Ei=l("td",{"data-format":Ve.format,"data-align":Ve.align||null,"data-first":qr===0?"true":null});yr(Ei,Ve,Ve.values[Q],Q,r,Bt),gt.append(Ei)}),X.append(gt)}if(ae.length===0){const Q=l("tr"),ve=(f?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(ve),class:"rui-data-grid-empty"},[p(e.emptyLabel,"No results")])),X.append(Q)}})(q)};if(Wr(I),J.append(Z),E.append(J),k>A){const B=l("div",{class:"rui-data-grid-footer"}),q=k===0?0:(M-1)*A+1,Y=Math.min(k,M*A);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${q}–${Y} of ${k}`]));const G=l("div",{class:"rui-data-grid-footer-buttons"}),ae=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M<=1?"":null},["‹ Prev"]),ee=l("button",{type:"button",class:"rui-data-grid-page-button",disabled:M>=S?"":null},["Next ›"]);F&&(ae.onclick=()=>{M<=1||r.setState(F,M-1)},ee.onclick=()=>{M>=S||r.setState(F,M+1)}),G.append(ae),G.append(l("span",{class:"rui-data-grid-page-current"},[`${M} / ${S}`])),G.append(ee),B.append(G),E.append(B)}return E}};function Pd(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r,n=p(a.date);n&&e.push({date:n,title:p(a.title),tone:p(a.tone,"primary"),time:p(a.time)})}return e}function Zn(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-n),r}function Qn(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${a}`}const Id={name:"CalendarView",description:"Full-month or week calendar grid for scheduling apps — distinct from the form-input `DatePicker`. Pass events as an array of `{date: 'YYYY-MM-DD', title, tone?, time?}` objects. Bind `value` to a `$variable` for the selected date (ISO string). Use `view=\"week\"` for a single-week strip. `firstDay=1` (Monday) matches most business apps.",props:[{name:"value",type:"string",optional:!0,description:"Selected ISO date (YYYY-MM-DD); bind a $variable"},{name:"month",type:"string",optional:!0,description:"Reference month — ISO date or YYYY-MM (defaults to today)"},{name:"events",type:"object[]",optional:!0,description:"Array of {date, title, tone?, time?} objects"},{name:"view",type:"string",optional:!0,enum:["month","week"]},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday, 1=Monday (default 1)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a day is clicked; receives the ISO date string"}],render:(t,e,r)=>{const a=p(e.view,"month"),n=Pd(e.events),i=p(e.value),o=p(e.month,i),s=new Date;let u=new Date(NaN);if(o){const A=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(A)u=new Date(Number(A[1]),Number(A[2])-1,A[3]?Number(A[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(u=S)}}Number.isNaN(u.getTime())&&(u=s);const c=(L(e.firstDay,1)%7+7)%7,m=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const A of n){const S=A.date.slice(0,10),$=d.get(S)??[];$.push(A),d.set(S,$)}const f=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),h=l("div",{class:"rui-calendar-header"}),b=u.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(l("div",{class:"rui-calendar-title"},[b])),g.append(h);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let A=0;A<7;A+=1){const S=y[(c+A)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const A=m?new Date(m):u,S=Zn(A,c);for(let $=0;$<7;$+=1){const M=new Date(S);M.setDate(S.getDate()+$),x.push({date:M,inMonth:M.getMonth()===u.getMonth()})}}else{const A=new Date(u.getFullYear(),u.getMonth(),1),S=new Date(u.getFullYear(),u.getMonth()+1,0),$=Zn(A,c),M=Math.ceil((S.getDate()+(A.getDay()-c+7)%7)/7)*7;for(let I=0;I<M;I+=1){const E=new Date($);E.setDate($.getDate()+I),x.push({date:E,inMonth:E.getMonth()===u.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=Qn(s);for(const A of x){const S=Qn(A.date),$=S===k,M=S===m,I=d.get(S)??[],E=l("button",{type:"button",class:"rui-calendar-day","data-in-month":A.inMonth?"true":"false","data-today":$?"true":"false","data-selected":M?"true":"false","aria-label":A.date.toDateString()});if(E.append(l("span",{class:"rui-calendar-daynumber"},[String(A.date.getDate())])),I.length>0){const D=l("div",{class:"rui-calendar-day-events"}),K=I.slice(0,3);for(const F of K){const U=l("span",{class:"rui-calendar-event","data-tone":F.tone??"primary",title:F.time?`${F.time} — ${F.title}`:F.title},[F.title]);D.append(U)}I.length>3&&D.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),E.append(D)}E.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(E)}return g.append(w),g}};function Ld(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:p(a.title),description:p(a.description),actor:p(a.actor),avatarSrc:p(a.avatarSrc),time:p(a.time),icon:p(a.icon),tone:p(a.tone,"default"),meta:p(a.meta)})}return e}function Rd(t,e,r){const a=l("ol",{class:t,"data-variant":r});for(const n of e){const i=l("li",{class:`${t}-item`,"data-tone":n.tone}),o=l("span",{class:`${t}-marker`}),s=z(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const u=l("div",{class:`${t}-body`}),c=l("div",{class:`${t}-head`});n.actor&&c.append(l("span",{class:`${t}-actor`},[n.actor])),c.append(l("span",{class:`${t}-title`},[n.title])),n.time&&c.append(l("span",{class:`${t}-time`},[n.time])),u.append(c),n.description&&u.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&u.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(u),a.append(i)}return a}const Ed={name:"ActivityLog",description:'Purpose-built feed of user/system activity. Each entry has `actor`, `title`, `description?`, `time?`, `icon?`, `tone?`, and optional `meta` (IP, browser, request id). Use `variant="audit"` for monospace security/admin trails. Pass items as `{actor, title, description, time, icon, tone, avatarSrc, meta}` objects.',props:[{name:"items",type:"object[]"},{name:"variant",type:"string",optional:!0,enum:["default","audit"],description:"audit = monospace voice with meta column"}],render:(t,e)=>{const r=p(e.variant,"default");return Rd(r==="audit"?"rui-audit-trail":"rui-activity-log",Ld(e.items),r)}},zd={name:"ComparisonTable",description:"Feature/spec comparison table — generic counterpart of `PricingTable`. Pass `columns` (e.g. plan/product names) and `rows` of `{label, values}` where `values` aligns 1-to-1 with `columns`. Each value can be a boolean (✓/—), a string, or a node.",props:[{name:"columns",type:"string[]",description:"Column headers"},{name:"rows",type:"object[]",description:"Array of {label, values, hint?, group?} entries"},{name:"highlightColumn",type:"number",optional:!0,description:"0-indexed column to visually emphasise"}],render:(t,e,r)=>{const a=C(e.columns).map(f=>p(f)),n=C(e.rows).map(f=>{const g=f??{};return{label:p(g.label),values:C(g.values),hint:p(g.hint),group:p(g.group)}}),i=Math.floor(L(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),u=l("thead"),c=l("tr");c.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((f,g)=>{c.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[f]))}),u.append(c),s.append(u);const m=l("tbody");let d="";for(const f of n){if(f.group&&f.group!==d){d=f.group;const b=l("tr",{class:"rui-comparison-table-group"});b.append(l("td",{colspan:String(a.length+1)},[f.group])),m.append(b)}const g=l("tr"),h=l("td",{class:"rui-comparison-table-feature"});h.append(l("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&h.append(l("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),g.append(h);for(let b=0;b<a.length;b+=1){const v=f.values[b],y=l("td",{"data-highlight":b===i?"true":null});if(v===!0){const x=z("circle-check",{className:"rui-comparison-yes"});x?y.append(x):y.textContent="✓"}else v===!1||v===null||v===void 0?y.append(l("span",{class:"rui-comparison-no"},["—"])):v&&typeof v=="object"&&v.__kind==="Component"?y.append(r.renderNode(v)):y.textContent=p(v);g.append(y)}m.append(g)}return s.append(m),o.append(s),o}},Dd={name:"InfiniteList",description:"Vertical list that fires `onLoadMore` when the user scrolls near the bottom. Pass already-rendered child nodes as `items`; wire `onLoadMore` to an `action` that awaits a `$mutation` or `$query` (e.g. `await loadMore.invoke()`) and appends to the bound state. Use `loading=true` to show the spinner row, `hasMore=false` to suppress further loads.",props:[{name:"items",type:"Node[]",description:"Already-rendered child nodes"},{name:"onLoadMore",type:"callable",optional:!0,description:"Callable fired when the sentinel scrolls into view"},{name:"loading",type:"boolean",optional:!0},{name:"hasMore",type:"boolean",optional:!0,description:"Default true — set false to hide the sentinel"},{name:"loaderLabel",type:"string",optional:!0,description:"Label rendered while loading (default `Loading…`)"}],render:(t,e,r)=>{const a=l("div",{class:"rui-infinite-list"}),n=l("div",{class:"rui-infinite-list-body"});for(const s of C(e.items))n.append(r.renderNode(s));a.append(n);const i=e.hasMore===void 0?!0:T(e.hasMore),o=T(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const u=z("spinner",{className:"rui-infinite-list-spin"});u&&s.append(u),s.append(l("span",{},[p(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const u=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);u.onclick=()=>r.invoke(e.onLoadMore),s.append(u)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const u=e.onLoadMore,c=new IntersectionObserver(m=>{for(const d of m)if(d.isIntersecting){r.invoke(u);break}});c.observe(s),r.registerDisposer(()=>c.disconnect(),"infinite-observer")}}return a}},jd=/^(https?:|blob:|data:(audio|video)\/)/i;function Ft(t){const e=p(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":jd.test(e)?e:"":""}const Bd={name:"VideoPlayer",description:"Themed native `<video>` wrapper. Pass a `src` URL (or `sources` array for multi-codec fallback) and optional `poster`. Standard controls are visible by default; pass `autoplay`, `loop`, `muted`, or `controls=false` to override. Use for product demos, tutorials, and any inline video.",props:[{name:"src",type:"string",optional:!0,description:"Video URL (mp4 / webm / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"poster",type:"string",optional:!0,description:"Thumbnail image URL shown before playback"},{name:"caption",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"muted",type:"boolean",optional:!0},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio (default 16:9)"}],render:(t,e)=>{const r=l("figure",{class:"rui-video-player"}),a=Er(p(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:T(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,muted:T(e.muted)?"":null,poster:ne(e.poster)||null,playsinline:"",preload:"metadata"}),s=C(e.sources);if(s.length>0)for(const c of s){if(!c||typeof c!="object")continue;const m=c,d=Ft(m.src);d&&o.append(l("source",{src:d,type:p(m.type)||null}))}else{const c=Ft(e.src);c&&o.setAttribute("src",c)}n.append(o),r.append(n);const u=p(e.caption);return u&&r.append(l("figcaption",{class:"rui-video-player-caption"},[u])),r}},Fd={name:"AudioPlayer",description:"Themed native `<audio>` wrapper with a title, optional artist, and standard transport controls. Pass `src` (or `sources`) plus a `title` so the bar still looks like a player when the controls bar is hidden. Use for podcasts, voice notes, and demo audio.",props:[{name:"src",type:"string",optional:!0,description:"Audio URL (mp3 / ogg / wav / etc.)"},{name:"sources",type:"object[]",optional:!0,description:"Array of {src, type} entries for multi-codec fallback"},{name:"title",type:"string",optional:!0},{name:"artist",type:"string",optional:!0},{name:"controls",type:"boolean",optional:!0,description:"Show native controls (default true)"},{name:"autoplay",type:"boolean",optional:!0},{name:"loop",type:"boolean",optional:!0},{name:"icon",type:"string",optional:!0,description:"Leading icon (default `music`)"}],render:(t,e)=>{const r=l("div",{class:"rui-audio-player"}),a=l("div",{class:"rui-audio-player-meta"}),n=z(p(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=p(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=p(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const u=e.controls===void 0?!0:T(e.controls),c=l("audio",{class:"rui-audio-player-audio",controls:u?"":null,autoplay:T(e.autoplay)?"":null,loop:T(e.loop)?"":null,preload:"metadata"}),m=C(e.sources);if(m.length>0)for(const d of m){if(!d||typeof d!="object")continue;const f=d,g=Ft(f.src);g&&c.append(l("source",{src:g,type:p(f.type)||null}))}else{const d=Ft(e.src);d&&c.setAttribute("src",d)}return r.append(c),r}};function Od(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ne(t);return r?l("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,a=ne(r.src);if(a){const n=l("figure",{class:"rui-carousel-figure"});n.append(l("img",{src:a,alt:p(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=p(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const _d={name:"Carousel",description:"Horizontal slider with prev/next buttons and dot navigation. Each child slide takes full width. Slides may be Component nodes (Image, Card, MediaCard, …), URL strings, or plain `{src, alt, caption?}` image objects — bare image objects are auto-wrapped into a captioned figure. Use for image galleries, onboarding carousels, hero banners, and product image strips. The active slide is preserved across re-renders via instance state.",props:[{name:"items",type:"Node[]",description:"Slide nodes, image URLs, or {src, alt, caption?} objects"},{name:"activeIndex",type:"number",optional:!0,description:"0-indexed initial slide (default 0)"},{name:"ratio",type:"string",optional:!0,description:"Aspect ratio of the frame (default `16:9`)"},{name:"showDots",type:"boolean",optional:!0,description:"Show indicator dots (default true)"},{name:"showArrows",type:"boolean",optional:!0,description:"Show prev/next arrows (default true)"}],render:(t,e,r)=>{const a=C(e.items),n=a.length,i=Math.max(0,Math.min(Math.max(n-1,0),Math.floor(L(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const u=e.showDots===void 0?!0:T(e.showDots),c=e.showArrows===void 0?!0:T(e.showArrows),m=Er(p(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),f=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${m};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(b=>{const v=l("div",{class:"rui-carousel-slide"}),y=Od(b,r);y&&v.append(y),g.append(v)}),f.append(g);const h=(b,v)=>{const y=(v%n+n)%n;o.set(y);const x=b.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,A)=>{k.setAttribute("data-active",A===y?"true":"false")})};if(c&&n>1){const b=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=z("chevron-left");v&&b.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=z("chevron-right");x&&y.append(x),b.onclick=w=>h(w.currentTarget,o.get()-1),y.onclick=w=>h(w.currentTarget,o.get()+1),f.append(b,y)}if(d.append(f),u&&n>1){const b=l("div",{class:"rui-carousel-dots"});a.forEach((v,y)=>{const x=l("button",{type:"button",class:"rui-carousel-dot","data-active":y===s?"true":"false","aria-label":`Go to slide ${y+1}`});x.onclick=w=>h(w.currentTarget,y),b.append(x)}),d.append(b)}return d}},Ud={name:"Gallery",description:"Responsive image grid. Pass items as plain URL strings, `{src, alt, caption?}` objects, or `Image(...)` nodes. When `onSelect` is provided each tile becomes a button; bind it through an Action that opens a `Lightbox`.",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default auto)"},{name:"ratio",type:"string",optional:!0,description:"Per-tile aspect ratio (default `1:1`)"},{name:"onSelect",type:"callable",optional:!0,description:"Callable fired when a tile is clicked"}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Er(p(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,u)=>{const{src:c,alt:m,caption:d}=ei(s),f=ne(c),g=typeof e.onSelect=="function",h=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(u)});if(f)h.append(l("img",{src:f,alt:m,loading:"lazy"}));else{const b=z("image",{className:"rui-gallery-placeholder"});b&&h.append(b)}d&&h.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(h.onclick=()=>r.invoke(e.onSelect,u,s)),o.append(h)}),o}};function ei(t){if(typeof t=="string")return{src:t,alt:"",caption:""};if(t&&typeof t=="object"){const e=t;return e.__kind==="Component"&&Array.isArray(e.args)?{src:p(e.args[0]),alt:p(e.args[1]),caption:p(e.args[2])}:{src:p(e.src),alt:p(e.alt),caption:p(e.caption)}}return{src:"",alt:"",caption:""}}const Hd={name:"Lightbox",description:"Image overlay. When you bind a `$variable` to `open` you control it explicitly; without one, Lightbox renders a clickable thumbnail of the current image that opens the overlay on click (and uses internal state for next/prev). Pass `items` (string URLs or `{src, alt, caption?}` objects). Clicking the backdrop or × closes; arrows step through the array.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Open/closed; bind a $variable to control externally"},{name:"index",type:"number",optional:!0,description:"0-indexed current image; typically a $variable"}],render:(t,e,r)=>{const a=C(e.items).map($=>ei($)).filter($=>ne($.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),u=r.useInstanceState("index",0),c=o?T(e.open):s.get(),m=i?Math.floor(L(e.index,0)):u.get(),d=n===0?0:(m%n+n)%n,f=$=>{o?r.setState(o,$):s.set($)},g=$=>{i?r.setState(i,$):u.set($)},h=()=>f(!1),b=$=>{n!==0&&g(((d+$)%n+n)%n)},v=l("div",{class:"rui-lightbox-root"});if(!o&&n>0){const $=a[d],M=l("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const I=ne($.src);I&&M.append(l("img",{src:I,alt:$.alt,loading:"lazy"}))}M.onclick=I=>{I.stopPropagation(),f(!0)},v.append(M)}const y=l("div",{class:"rui-lightbox-overlay","data-open":c?"true":"false"});if(v.append(y),!c||n===0)return v;const x=a[d];if(!x)return v;const w=ne(x.src);y.onclick=$=>{$.target===y&&h()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),A=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(A.onclick=h,k.append(A),n>1){const $=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),M=z("chevron-left");M&&$.append(M),$.onclick=()=>b(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),E=z("chevron-right");E&&I.append(E),I.onclick=()=>b(1),k.append($,I)}const S=l("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(l("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(l("div",{class:"rui-lightbox-caption"},[x.caption])),n>1&&k.append(l("div",{class:"rui-lightbox-counter"},[`${d+1} / ${n}`])),y.append(k),v}};function Vd(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=L(e.lat??e.latitude,NaN),a=L(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(a))return{lat:r,lng:a}}if(Array.isArray(t)&&t.length>=2){const e=L(t[0],NaN),r=L(t[1],NaN);if(Number.isFinite(e)&&Number.isFinite(r))return{lat:e,lng:r}}if(typeof t=="string"){const e=t.split(",").map(r=>Number(r.trim()));if(e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]))return{lat:e[0],lng:e[1]}}return null}const Wd={name:"Map",description:"Static map view centered on a lat/lng coordinate. Renders an OpenStreetMap embed inside an `<iframe>` (no external JS, no API key). Pass `lat` and `lng` as bare numbers; `zoom` controls the level (1–18, default 13). Optional `markers` array adds map pins (rendered as a labelled list alongside the map). Use for store locators, address cards, itinerary previews.",props:[{name:"lat",type:"number",description:"Latitude of the map center"},{name:"lng",type:"number",description:"Longitude of the map center"},{name:"zoom",type:"number",optional:!0,description:"1–18 (default 13)"},{name:"markers",type:"object[]",optional:!0,description:"Array of {lat, lng, label?} markers (informational; rendered alongside the map)"},{name:"height",type:"string",optional:!0,description:"CSS height (default 320px)"},{name:"caption",type:"string",optional:!0}],render:(t,e)=>{const r=l("figure",{class:"rui-map"}),a=te(e.height,"320px"),n=l("div",{class:"rui-map-frame",style:`height:${a};`}),i=L(e.lat,NaN),o=L(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){n.append(l("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(n);const b=p(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}const u=Math.max(1,Math.min(18,Math.floor(L(e.zoom,13)))),c=1/Math.pow(2,u-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-c,s.lat-c/2,s.lng+c,s.lat+c/2].join(",")}&layer=mapnik&marker=${s.lat},${s.lng}`,f=l("iframe",{class:"rui-map-iframe",src:d,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});n.append(f),r.append(n);const g=C(e.markers).map(b=>{const v=Vd(b),y=b&&typeof b=="object"?p(b.label):"";return v?{...v,label:y}:null}).filter(b=>b!==null);if(g.length>0){const b=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=z("location-dot",{className:"rui-map-marker-icon"});x&&y.append(x),y.append(l("span",{class:"rui-map-marker-label"},[v.label||`${v.lat.toFixed(4)}, ${v.lng.toFixed(4)}`])),b.append(y)}r.append(b)}const h=p(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),r}};function Er(t){if(t.includes(":")){const[r,a]=t.split(":"),n=Number(r),i=Number(a);if(Number.isFinite(n)&&Number.isFinite(i)&&i>0)return`${n} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const qd=[{command:"bold",icon:"bold",label:"Bold"},{command:"italic",icon:"italic",label:"Italic"},{command:"underline",icon:"underline",label:"Underline"},{command:"strikeThrough",icon:"strikethrough",label:"Strikethrough"},{command:"formatBlock",icon:"heading",label:"Heading",block:"h2"},{command:"formatBlock",icon:"quote-left",label:"Quote",block:"blockquote"},{command:"insertUnorderedList",icon:"list-ul",label:"Bullet list"},{command:"insertOrderedList",icon:"list-ol",label:"Numbered list"},{command:"createLink",icon:"link",label:"Link"}],Gd={name:"RichTextEditor",description:"Rich-text WYSIWYG editor for CMS, email, and comment surfaces. Renders a small toolbar (bold / italic / underline / strikethrough / headings / lists / quote / link) above a `contenteditable` region. Pass `$variable` as `value` for two-way binding — the HTML body is written back to state on every edit. Provide `placeholder` for the empty-state prompt.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound HTML body (typically $variable)"},{name:"placeholder",type:"string",optional:!0,description:"Empty-state prompt"},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 160px)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current HTML on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.placeholder,"Start writing…"),i=T(e.disabled),o=l("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=l("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const g of qd){const h=l("button",{type:"button",class:"rui-rich-text-tool","data-command":g.command,"data-block":g.block??null,"aria-label":g.label,title:g.label,disabled:i?"":null}),b=z(g.icon);b&&h.append(b),h.onmousedown=v=>v.preventDefault(),h.onclick=v=>{const x=v.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(g.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else g.command==="formatBlock"&&g.block?document.execCommand("formatBlock",!1,g.block):document.execCommand(g.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(h)}o.append(s);const u=p(e.value)||"",c=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,m=l("div",{class:"rui-rich-text-content",id:a,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":n,"data-placeholder":n,"data-empty":c(u)?"true":"false",style:`min-height:${p(e.minHeight,"160px")};`,html:u}),d=g=>{g.setAttribute("data-empty",c(g.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(m,f,{event:"input",getValue:g=>{const h=g;return d(h),h.innerHTML}}):m.oninput=g=>{const h=g.currentTarget??g.target;d(h)},m.onblur=g=>{const h=g.currentTarget??g.target;d(h)},ie(m,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(m),o}},Kd={name:"CodeEditor",description:"Lightweight, dependency-free code editor. Pairs a styled textarea with a synchronised line-number gutter — no syntax highlighting, but the editor stays a single rendered node so it works inside Shadow DOM. Use for dev tooling, snippet editing, prompt playgrounds. Pass a `$variable` as `value` for two-way binding. For read-only rendering with highlights prefer `CodeBlock`.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound source text (typically $variable)"},{name:"language",type:"string",optional:!0,enum:["text","javascript","typescript","json","html","css","bash","python","sql","markdown"],description:"Language label shown on the header (default `text`)"},{name:"placeholder",type:"string",optional:!0},{name:"minHeight",type:"string",optional:!0,description:"CSS min-height for the editor area (default 200px)"},{name:"tabSize",type:"number",optional:!0,description:"Spaces per Tab (default 2)"},{name:"showGutter",type:"boolean",optional:!0,description:"Show line-number gutter (default true)"},{name:"readonly",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current source on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.value),i=p(e.language,"text"),o=e.showGutter===void 0?!0:T(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(L(e.tabSize,2)))),u=T(e.readonly),c=p(e.minHeight,"200px"),m=l("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),d=l("div",{class:"rui-code-editor-head"});d.append(l("span",{class:"rui-code-editor-language"},[i])),m.append(d);const f=l("div",{class:"rui-code-editor-body",style:`min-height:${c};`}),g=l("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((y=>{g.replaceChildren();const x=y.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)g.append(l("span",{class:"rui-code-editor-line"},[String(k)]))})(n),f.append(g));const b=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:p(e.placeholder),readonly:u?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});b.value=n,b.oninput=y=>{const x=y.currentTarget;if(!o)return;const k=x.closest(".rui-code-editor")?.querySelector(".rui-code-editor-gutter");if(!k)return;k.replaceChildren();const A=x.value.split(/\r?\n/),S=Math.max(1,A.length);for(let $=1;$<=S;$+=1)k.append(l("span",{class:"rui-code-editor-line"},[String($)]))},b.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,A=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(A),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!u&&r.bindState(b,v,{event:"input",getValue:y=>y.value}),u||ie(b,e.onChange,r,{event:"input",getValue:y=>y.value}),f.append(b),m.append(f),m}};function Yd(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const a=e.args;return{label:p(a[0]),action:a[1],icon:p(a[2]),shortcut:p(a[3]),variant:p(a[4],"default"),disabled:T(a[5]),separator:!1}}if(e.__kind==="Component"&&e.name==="MenuSeparator")return{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0};const r=t;return r.separator?{label:"",action:null,icon:"",shortcut:"",variant:"default",disabled:!1,separator:!0}:{label:p(r.label),action:r.action,icon:p(r.icon),shortcut:p(r.shortcut),variant:p(r.variant,"default"),disabled:T(r.disabled),separator:!1}}return null}const Xd={name:"ContextMenu",description:"Right-click (or long-press) menu that attaches to a child node. Wraps `target` and shows the menu at the pointer when the user right-clicks anywhere inside it. Items are `MenuItem(...)` nodes, `MenuSeparator()` entries, or `{label, action, icon?, shortcut?, variant?, disabled?, separator?}` objects. Use on table rows, tree nodes, kanban cards, file browser entries.",props:[{name:"target",type:"Node",description:"Child node the menu is bound to"},{name:"items",type:"any[]",description:"MenuItem nodes or {label, action} objects"},{name:"label",type:"string",optional:!0,description:"ARIA label for the menu"}],render:(t,e,r)=>{const a=l("div",{class:"rui-context-menu"}),n=l("div",{class:"rui-context-menu-target"});n.append(r.renderNode(e.target)),a.append(n);const i=l("div",{class:"rui-context-menu-pop",role:"menu","aria-label":p(e.label)||null,"data-open":"false"}),o=C(e.items).map(Yd).filter(c=>c!==null);for(const c of o){if(c.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const m=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":c.variant,disabled:c.disabled?"":null}),d=z(c.icon,{className:"rui-menu-item-icon"});d&&m.append(d),m.append(l("span",{class:"rui-menu-item-label"},[c.label])),c.shortcut&&m.append(l("span",{class:"rui-menu-item-shortcut"},[c.shortcut])),c.disabled||(m.onclick=()=>{r.invoke(c.action),i.setAttribute("data-open","false")}),i.append(m)}a.append(i);const s=()=>i.setAttribute("data-open","false"),u=(c,m)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,f=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),h=g?c-g.left:c,b=g?m-g.top:m;f.style.left=`${h}px`,f.style.top=`${b}px`,f.setAttribute("data-open","true");const v=y=>{y.target&&f.contains(y.target)||(f.setAttribute("data-open","false"),document.removeEventListener("click",v,!0),document.removeEventListener("contextmenu",v,!0))};setTimeout(()=>{document.addEventListener("click",v,!0),document.addEventListener("contextmenu",v,!0)},0)};return n.oncontextmenu=c=>{c.preventDefault(),u(c.clientX,c.clientY)},n.onkeydown=c=>{const m=c;if(m.key==="ContextMenu"||m.shiftKey&&m.key==="F10"){m.preventDefault();const f=m.currentTarget.getBoundingClientRect();u(f.left,f.top+f.height)}m.key==="Escape"&&s()},a}},Jd=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function ut(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(a=>a+a).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const Zd={name:"ColorPicker",description:'Hex / RGB color form control with preset swatches. Pairs a native `<input type="color">` chip with a hex text input and a row of preset swatches. Pass a `$variable` as `value` (hex string, e.g. `"#6366f1"`) for two-way binding. Use for theme builders, label color pickers, and any "pick a color" surface.',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound hex value (typically $variable)"},{name:"label",type:"string",optional:!0},{name:"swatches",type:"string[]",optional:!0,description:"Preset hex colors (default to a 12-color palette)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the newly-selected hex string"}],render:(t,e,r)=>{const a=p(e.id),n=ut(p(e.value))||p(e.value,"#000000"),i=T(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=p(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const u=l("div",{class:"rui-color-picker-row"}),c=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:ut(n)||"#000000",disabled:i?"":null}),m=l("input",{type:"text",class:"rui-color-picker-hex",value:n,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),d=l("div",{class:"rui-color-picker-swatches"}),f=C(e.swatches).map(b=>p(b)).filter(Boolean),g=f.length>0?f:Jd;for(const b of g){const v=ut(b)||b,y=l("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${v}`,"aria-label":v,title:v,"data-active":v.toLowerCase()===n.toLowerCase()?"true":"false"});y.onclick=()=>{c.value=ut(v)||c.value,m.value=v,c.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const h=t.argMeta?.[1]?.stateRef;return h&&!i&&(r.bindState(c,h,{event:"input",getValue:b=>b.value}),c.addEventListener("input",()=>{m.value=c.value}),m.oninput=()=>{const b=ut(m.value);b&&(c.value=b,c.dispatchEvent(new Event("input",{bubbles:!0})))}),i||ie(c,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(c,m),o.append(u,d),o}},zr=["var(--rui-chart-1, #6366f1)","var(--rui-chart-2, #10b981)","var(--rui-chart-3, #f59e0b)","var(--rui-chart-4, #ef4444)","var(--rui-chart-5, #06b6d4)","var(--rui-chart-6, #8b5cf6)"],_e=t=>zr[t%zr.length]??zr[0];function Qd(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>L(o));return{name:n,values:i}})}function Ot(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("viewBox",`0 0 ${t} ${e}`),r.setAttribute("class","rui-chart-svg"),r.setAttribute("role","img"),r}function ce(t,e,r){const a=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[n,i]of Object.entries(e))a.setAttribute(n,i);if(r)for(const n of r)a.append(typeof n=="string"?document.createTextNode(n):n);return a}function ti(t){const e=l("div",{class:"rui-chart-legend"});return t.forEach((r,a)=>{const n=l("span",{class:"rui-chart-legend-item"});n.append(l("span",{class:"rui-chart-legend-swatch",style:`background:${_e(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const ep={name:"Gauge",description:"Half-doughnut gauge indicator for a single value between `min` and `max`. The inner value is auto-formatted from the value (override via `label`). Pass `caption`, `tone`, and `size` for visual treatment. Use for KPI thresholds (uptime %, score, capacity, NPS, page-speed).",props:[{name:"value",type:"number"},{name:"min",type:"number",optional:!0,description:"Lower bound (default 0)"},{name:"max",type:"number",optional:!0,description:"Upper bound (default 100)"},{name:"caption",type:"string",optional:!0,description:"Small caption below the gauge"},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]},{name:"label",type:"string",optional:!0,description:"Inner label override (defaults to auto-formatted value)"}],render:(t,e)=>{const r=L(e.min,0),a=Math.max(r+1,L(e.max,100)),n=Math.max(r,Math.min(a,L(e.value,r))),i=(n-r)/(a-r),o=p(e.tone,"primary"),s=p(e.size,"md"),u=s==="lg"?220:s==="sm"?140:180,c=u/2,m=s==="lg"?18:s==="sm"?10:14,d=c-m,f=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=Ot(u,c+m+4),h=c,b=c,v=h-d,y=b,x=h+d,w=b;if(g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(m),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,M=h-d*Math.cos($),I=b-d*Math.sin($);g.append(ce("path",{d:`M${v},${y} A${d},${d} 0 0 1 ${M.toFixed(2)},${I.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${_e(0)})`,"stroke-width":String(m),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(g);const k=tp(n,r,a),A=p(e.label)||k;f.append(l("div",{class:"rui-gauge-value"},[A]));const S=p(e.caption);return S&&f.append(l("div",{class:"rui-gauge-caption"},[S])),f}};function tp(t,e,r){return e===0&&r===100?t%1===0?`${t}%`:`${t.toFixed(1)}%`:Math.abs(t)>=1e3?Math.round(t).toLocaleString():t%1===0?String(t):t.toFixed(t<10?2:1)}const rp={name:"Heatmap",description:"Color-intensity matrix grid (calendar-style or correlation-style). Pass `xLabels`, `yLabels`, and a `values` array of arrays (rows × columns). Each cell's color intensity scales with the value relative to the global max. Use for activity heatmaps, schedule density, correlation matrices.",props:[{name:"xLabels",type:"string[]"},{name:"yLabels",type:"string[]"},{name:"values",type:"number[][]",description:"Matrix indexed by row (y), then column (x)"},{name:"title",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","success","warning","danger","info"]}],render:(t,e)=>{const r=C(e.xLabels).map(m=>p(m)),a=C(e.yLabels).map(m=>p(m)),n=C(e.values).map(m=>C(m).map(d=>L(d,0))),i=p(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});p(e.title)&&s.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const u=l("div",{class:"rui-heatmap-table"}),c=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const m of r)c.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[m]));return u.append(c),n.forEach((m,d)=>{const f=l("div",{class:"rui-heatmap-row"});f.append(l("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[a[d]??String(d+1)])),m.forEach((g,h)=>{const b=o>0?g/o:0,v=l("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${_e(0)}) ${Math.round(b*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),f.append(v)}),u.append(f)}),s.append(u),s}},ap={name:"RadarChart",description:"Polygon chart with one axis per category. Use for skill maps, scorecards, capability comparisons, and any multi-dimensional snapshot. Each Series renders as a filled polygon — overlapping is expected for comparisons.",props:[{name:"axes",type:"string[]",description:"Category labels — one per radial axis"},{name:"series",type:"Series[]"},{name:"max",type:"number",optional:!0,description:"Outer ring value (default = max across series)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=C(e.axes).map(g=>p(g)),a=Qd(C(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});p(e.title)&&i.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const o=Math.max(1,L(e.max,a.flatMap(g=>g.values).reduce((g,h)=>Math.max(g,h),1))),s=280,u=s/2,c=s/2,m=s/2-24,d=Ot(s,s),f=4;for(let g=1;g<=f;g+=1){const h=m/f*g,b=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;b.push(`${(u+h*Math.cos(y)).toFixed(1)},${(c+h*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:b.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let g=0;g<n;g+=1){const h=Math.PI*2*g/n-Math.PI/2,b=u+m*Math.cos(h),v=c+m*Math.sin(h);d.append(ce("line",{x1:String(u),y1:String(c),x2:b.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=u+(m+16)*Math.cos(h),x=c+(m+16)*Math.sin(h);d.append(ce("text",{x:y.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[g]??""]))}return a.forEach((g,h)=>{const b=[];for(let v=0;v<n;v+=1){const y=g.values[v]??0,x=Math.max(0,Math.min(1,y/o)),w=Math.PI*2*v/n-Math.PI/2,k=u+m*x*Math.cos(w),A=c+m*x*Math.sin(w);b.push(`${k.toFixed(1)},${A.toFixed(1)}`)}d.append(ce("polygon",{points:b.join(" "),fill:_e(h),"fill-opacity":"0.2",stroke:_e(h),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(ti(a)),i}};function np(t){return t.map((e,r)=>{const a=e,n=p(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:L(o[0],0),y:L(o[1],0),label:p(o[2])};if(o&&typeof o=="object"){const s=o;return{x:L(s.x,0),y:L(s.y,0),label:p(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const ip={name:"ScatterChart",description:'XY scatter plot — one dot per data point, optionally grouped by series. Pass each `Series(name, points)` with points as `{x, y, label?}` objects or `[x, y, label?]` tuples. Use for correlations, distributions, and "price vs. rating" style charts.',props:[{name:"series",type:"Series[]"},{name:"xLabel",type:"string",optional:!0},{name:"yLabel",type:"string",optional:!0},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=np(C(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,u=i-o.top-o.bottom,c=r.flatMap(k=>k.points);if(c.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const m=c.map(k=>k.x),d=c.map(k=>k.y),f=Math.min(...m),g=Math.max(...m),h=Math.min(...d),b=Math.max(...d),v=g-f||1,y=b-h||1,x=Ot(n,i);if(ai(x,o,s,u,b,h),x.append(ce("line",{x1:String(o.left),y1:String(o.top+u),x2:String(o.left+s),y2:String(o.top+u),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,A)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/v*s,M=o.top+u-(S.y-h)/y*u,I=ce("circle",{cx:$.toFixed(1),cy:M.toFixed(1),r:"7",fill:_e(A),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),p(e.xLabel)&&x.append(ce("text",{x:String(o.left+s/2),y:String(i-6),"text-anchor":"middle",class:"rui-chart-label","font-size":"14","font-weight":"500"},[p(e.xLabel)])),p(e.yLabel)){const A=o.top+u/2;x.append(ce("text",{x:String(14),y:String(A),"text-anchor":"middle",transform:`rotate(-90, 14, ${A})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[p(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(A=>A.y)}));return w.length>0&&a.append(ti(w)),a}},op={name:"Histogram",description:"Frequency distribution from raw numeric values. Pass `values` directly (the component bins them automatically) or pre-computed `bins` of `{label, count}` objects. Use for response-time histograms, score distributions, age buckets.",props:[{name:"values",type:"number[]",optional:!0,description:"Raw observations (binned automatically)"},{name:"bins",type:"object[]",optional:!0,description:"Pre-computed {label, count} entries (overrides `values`)"},{name:"binCount",type:"number",optional:!0,description:"Number of bins when computing from `values` (default 10)"},{name:"title",type:"string",optional:!0}],render:(t,e)=>{let r=[];if(Array.isArray(e.bins)&&e.bins.length>0)r=e.bins.map(f=>{const g=f??{};return{label:p(g.label),count:L(g.count,0)}});else{const f=C(e.values).map(g=>L(g,NaN)).filter(g=>Number.isFinite(g));if(f.length>0){const g=Math.max(2,Math.min(50,Math.floor(L(e.binCount,10)))),h=Math.min(...f),y=(Math.max(...f)-h||1)/g,x=new Array(g).fill(0);for(const w of f){let k=Math.floor((w-h)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const A=h+k*y,S=A+y;return{label:`${ri(A)}–${ri(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(p(e.title)&&a.append(l("div",{class:"rui-chart-title"},[p(e.title)])),r.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No data"])),a;const n=640,i=240,o={left:40,right:12,top:16,bottom:50},s=n-o.left-o.right,u=i-o.top-o.bottom,c=Math.max(1,...r.map(f=>f.count)),m=s/r.length,d=Ot(n,i);return ai(d,o,s,u,c),r.forEach((f,g)=>{const h=o.left+g*m+m*.1,b=m*.8,v=f.count/c*u,y=o.top+u-v,x=ce("rect",{x:h.toFixed(1),y:y.toFixed(1),width:b.toFixed(1),height:v.toFixed(1),fill:_e(0),rx:"2"});x.append(ce("title",{},[`${f.label}: ${f.count}`])),d.append(x),d.append(ce("text",{x:(h+b/2).toFixed(1),y:String(o.top+u+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),a.append(d),a}};function ri(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function ai(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const u=s/4,c=e.top+a-u*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(c),y2:String(c),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(c+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*u)*10)/10)]))}}const sp=["numeric","alphanumeric"];function lp(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),u=[];for(let d=0;d<e;d+=1){const f=l("input",{class:"rui-pin-input-slot",id:d===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${d+1}`,value:a.charAt(d)||"",disabled:n?"":null});u.push(f),s.append(f)}const c=d=>{const f=d.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):u},m=d=>c(d).map(f=>f.value).join("").slice(0,e);return u.forEach((d,f)=>{d.oninput=g=>{const h=g.currentTarget,b=c(h);let v=h.value;if(r==="numeric"?v=v.replace(/\D/g,""):v=v.replace(/[^A-Za-z0-9]/g,""),v.length>1){const y=v.split("");y.slice(0,e-f).forEach((w,k)=>{const A=b[f+k];A&&(A.value=w)});const x=Math.min(f+y.length,e-1);b[x]?.focus()}else h.value=v,v&&f<e-1&&b[f+1]?.focus();o?.(m(h))},d.onkeydown=g=>{const h=g,b=h.currentTarget,v=c(b);if(h.key==="Backspace"&&!b.value&&f>0){h.preventDefault(),v[f-1]?.focus();const y=v[f-1];y&&(y.value=""),o?.(m(b))}else h.key==="ArrowLeft"&&f>0?(h.preventDefault(),v[f-1]?.focus()):h.key==="ArrowRight"&&f<e-1&&(h.preventDefault(),v[f+1]?.focus())}}),s}const cp={name:"PinInput",description:'Per-digit PIN entry. Auto-advances focus as the user types and supports paste. Pass a `$variable` as `value` for two-way binding (the bound value is the joined string). Use `type="numeric"` for PINs / 2FA codes, `"alphanumeric"` for invite codes.',props:[{name:"id",type:"string"},{name:"length",type:"number",optional:!0,description:"Number of slots (default 4)"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"type",type:"string",optional:!0,enum:sp},{name:"mask",type:"boolean",optional:!0,description:"Render slots as `<input type=password>`"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current joined string on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=Math.max(1,Math.min(12,Math.floor(L(e.length,4)))),i=p(e.type,"numeric"),o=p(e.value),s=T(e.disabled),u=T(e.mask),c=t.argMeta?.[2]?.stateRef;return lp(a,n,i,o,s,u,m=>{c&&r.setState(c,m),r.invoke(e.onChange,m)})}};function up(t){if(!t)return{score:0,label:""};let e=0;return t.length>=8&&(e+=1),t.length>=12&&(e+=1),/[A-Z]/.test(t)&&/[a-z]/.test(t)&&(e+=1),/[0-9]/.test(t)&&(e+=1),/[^A-Za-z0-9]/.test(t)&&(e+=1),e=Math.min(4,e),{score:e,label:["Too short","Weak","Fair","Good","Strong"][e]??""}}const dp={name:"PasswordInput",description:"Password input with a show/hide toggle and an optional strength meter. Pass a `$variable` as `value` for two-way binding. Set `strengthMeter=true` to render a 4-step indicator and label.",props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"strengthMeter",type:"boolean",optional:!0,aliases:["showStrength"]},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current value on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=T(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),u=p(e.label);u&&s.append(l("label",{class:"rui-password-input-label",for:a},[u]));const c=l("div",{class:"rui-password-input-row"}),m=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:p(e.placeholder),value:p(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=z(i?"eye-slash":"eye");f&&d.append(f),d.onclick=h=>{h.preventDefault();const b=!n.get();n.set(b);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=b?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(m,g,{event:"input",getValue:h=>h.value}),ie(m,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(m),c.append(d),s.append(c),T(e.strengthMeter)){const h=up(p(e.value)),b=l("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let y=0;y<4;y+=1)b.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<h.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(b),h.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[h.label])),s.append(v)}return s}},pp={name:"TagInput",description:"Tag/chip input — type a value, press Enter (or comma) to commit, click × on a chip to remove. Pass a `$variable` (array of strings) as `value` for two-way binding. Use for keywords, recipients, labels, skills, allowlists.",props:[{name:"id",type:"string"},{name:"value",type:"string[]",optional:!0,description:"Bound array of tag values"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"max",type:"number",optional:!0,description:"Maximum number of tags"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the updated array of tags whenever one is added or removed"}],render:(t,e,r)=>{const a=p(e.id),n=C(e.value).map(f=>p(f)).filter(Boolean),i=Math.max(0,Math.floor(L(e.max,0))),o=T(e.disabled),s=t.argMeta?.[1]?.stateRef,u=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},c=p(e.label),m=l("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const f of n){const g=l("span",{class:"rui-tag-input-chip"});g.append(l("span",{},[f]));const h=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);h.onclick=()=>u(n.filter(b=>b!==f)),g.append(h),m.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:p(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=f=>{const g=f,h=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const b=h.value.trim();if(!b||i>0&&n.length>=i)return;if(n.includes(b)){h.value="";return}u([...n,b]),h.value=""}else g.key==="Backspace"&&h.value===""&&n.length>0&&(g.preventDefault(),u(n.slice(0,-1)))},m.append(d),c){const f=l("div",{class:"rui-tag-input-wrapper"});return f.append(l("label",{class:"rui-tag-input-label",for:a},[c])),f.append(m),f}return m}};function mp(t){return C(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=p(r.label??r.name??r.value??r.id);return{value:p(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const fp={name:"MentionInput",description:"Multi-line input with inline @-mention suggestions. Typing `@` opens a popover listing the provided `people` (filtered by what follows). Selecting an option inserts `@label` into the text. Pass a `$variable` as `value` for two-way binding. Use for comments, task notes, chat composers.",props:[{name:"id",type:"string"},{name:"people",type:"any[]",description:"Available mentions: strings or {value, label} objects"},{name:"value",type:"string",optional:!0,description:"Bound text (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"rows",type:"number",optional:!0,description:"TextArea rows (default 3)"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the current text on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=mp(e.people),i=T(e.disabled),o=l("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=l("textarea",{class:"rui-mention-input-field",id:a,name:a,rows:String(Math.max(2,Math.floor(L(e.rows,3)))),placeholder:p(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=p(e.value);const u=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),c=r.useInstanceState("activeIndex",0),m=r.useInstanceState("matches",[]),d=r.useInstanceState("query",null),f=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,g=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-field")??null,h=(x,w)=>{const k=x.value,A=x.selectionStart??k.length,S=k.slice(0,A),$=S.lastIndexOf("@");if($===-1)return;const M=k.slice(A),I=`@${w.value} `,E=S.slice(0,$)+I+M;x.value=E;const D=$+I.length;x.selectionStart=x.selectionEnd=D,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},b=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),m.set([]);return}const k=w.toLowerCase(),S=n.filter(M=>M.label.toLowerCase().includes(k)||M.value.toLowerCase().includes(k)).slice(0,6);if(m.set(S),S.length===0){x.setAttribute("data-open","false");return}const $=Math.min(c.get(),S.length-1);c.set($),x.setAttribute("data-open","true"),S.forEach((M,I)=>{const E=l("button",{type:"button",class:"rui-mention-input-option","data-value":M.value,"data-active":I===$?"true":"false"});E.append(l("span",{class:"rui-mention-input-option-label"},[M.label])),M.value&&M.value!==M.label&&E.append(l("span",{class:"rui-mention-input-option-handle"},[`@${M.value}`])),E.onmousedown=D=>D.preventDefault(),E.onclick=D=>{const K=D.currentTarget,F=g(K),U=f(K);F&&h(F,M),d.set(null),U&&b(U,null)},x.append(E)})},v=x=>{const w=f(x);if(!w)return;const k=x.selectionStart??x.value.length,A=x.value.slice(0,k),S=/@([\w-]*)$/.exec(A),$=S?S[1]??"":null;d.set($),b(w,$)},y=t.argMeta?.[2]?.stateRef;return y?r.bindState(s,y,{event:"input",getValue:x=>{const w=x;return v(w),w.value}}):s.oninput=x=>{v(x.currentTarget)},ie(s,e.onChange,r,{event:"input",getValue:x=>x.value}),s.onkeydown=x=>{const w=x.currentTarget,k=f(w);if(!k||k.getAttribute("data-open")!=="true")return;const A=m.get();if(A.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(c.get()+1)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(c.get()-1+A.length)%A.length;c.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((M,I)=>M.setAttribute("data-active",I===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=A[c.get()];S&&(h(w,S),d.set(null),b(k,null))}else x.key==="Escape"&&(d.set(null),b(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);d.set(null),k&&b(k,null)},120)},o.append(s),o.append(u),b(u,d.get()),o}},gp={name:"TimePicker",description:'Time-of-day picker that wraps `<input type="time">`. Pass a `$variable` as `value` for two-way binding (HH:MM 24-hour). Set `step` to constrain to specific increments (e.g. 900 for 15-minute buckets).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"HH:MM value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new HH:MM string when the user picks a time"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-time-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-time-picker-label",for:a},[i]));const o=l("input",{type:"time",class:"rui-time-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}},hp={name:"DateTimePicker",description:'Combined date + time picker — wraps `<input type="datetime-local">`. Pass a `$variable` as `value` for two-way binding (ISO `YYYY-MM-DDTHH:MM`).',props:[{name:"id",type:"string"},{name:"value",type:"string",optional:!0,description:"ISO date-time value; typically $variable"},{name:"label",type:"string",optional:!0},{name:"min",type:"string",optional:!0},{name:"max",type:"string",optional:!0},{name:"step",type:"number",optional:!0,description:"Seconds between selectable times"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the new ISO `YYYY-MM-DDTHH:MM` string"}],render:(t,e,r)=>{const a=p(e.id),n=l("div",{class:"rui-datetime-picker"}),i=p(e.label);i&&n.append(l("label",{class:"rui-datetime-picker-label",for:a},[i]));const o=l("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:a,name:a,value:p(e.value),min:p(e.min)||null,max:p(e.max)||null,step:e.step!=null?String(L(e.step,60)):null,disabled:T(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:u=>u.value}),n.append(o),n}};function ni(t,e){if(!e)return t;let r="",a=0;const n=String(t??"");for(const i of e){if(a>=n.length)break;if(i==="9"){for(;a<n.length&&!/\d/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else if(i==="A"){for(;a<n.length&&!/[a-zA-Z]/.test(n[a]??"");)a+=1;if(a>=n.length)break;r+=n[a],a+=1}else i==="*"?(r+=n[a],a+=1):(r+=i,n[a]===i&&(a+=1))}return r}const bp={name:"MaskedInput",description:'Text input with an inline mask — `9` matches a digit, `A` matches a letter, `*` matches any character, every other character is a fixed delimiter. Useful for phone numbers, postal codes, credit cards. Pass `mask` (e.g. `"(999) 999-9999"`) and a `$variable` as `value`.',props:[{name:"id",type:"string"},{name:"mask",type:"string",description:"Mask pattern"},{name:"value",type:"string",optional:!0,description:"Bound value (typically $variable)"},{name:"placeholder",type:"string",optional:!0},{name:"label",type:"string",optional:!0,description:"Inline label above the field"},{name:"disabled",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"],description:"Called with the masked value on every keystroke"}],render:(t,e,r)=>{const a=p(e.id),n=p(e.mask),i=T(e.disabled),o=ni(p(e.value),n),s=p(e.label),u=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:p(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});u.value=o;const c=t.argMeta?.[2]?.stateRef,m=d=>{const f=d.value,g=ni(f,n);if(g===f)return g;const h=d.selectionStart??g.length;d.value=g;const b=Math.min(g.length,h);try{d.setSelectionRange(b,b)}catch{}return g};if(c?r.bindState(u,c,{event:"input",getValue:d=>m(d)}):u.oninput=d=>{m(d.currentTarget??d.target)},ie(u,e.onChange,r,{event:"input",getValue:d=>d.value}),s){const d=l("div",{class:"rui-masked-input-wrapper"});return d.append(l("label",{class:"rui-masked-input-label",for:a},[s])),d.append(u),d}return u}},vp={name:"FormSection",description:"Semantic grouping for related form fields — renders a small heading (`label`), optional helper paragraph, and stacks the children with consistent spacing. Use INSTEAD of wrapping fields in `Card` + `SectionHeader` by hand. Pair with `FieldSet` when the group is a true `<fieldset>` (radio sets, checkbox groups).",props:[{name:"label",type:"string",aliases:["title"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["description"],description:"Description rendered below the label"}],render:(t,e,r)=>{const a=l("section",{class:"rui-form-section"}),n=l("header",{class:"rui-form-section-header"});n.append(l("h3",{class:"rui-form-section-label"},[p(e.label)]));const i=p(e.helper);i&&n.append(l("p",{class:"rui-form-section-helper"},[i])),a.append(n);const o=l("div",{class:"rui-form-section-body"});for(const s of C(e.children))o.append(r.renderNode(s));return a.append(o),a}},yp={name:"FieldSet",description:"Native `<fieldset>`/`<legend>` wrapper for accessible grouping of related controls. Use when assistive tech should announce the wrapper (radio sets, checkbox groups). For purely visual grouping prefer `FormSection`.",props:[{name:"legend",type:"string",aliases:["title","label"]},{name:"children",type:"Node[]",aliases:["fields"]},{name:"helper",type:"string",optional:!0,aliases:["hint","description"]},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("fieldset",{class:"rui-fieldset",disabled:T(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[p(e.legend)]));const n=p(e.helper);n&&a.append(l("p",{class:"rui-fieldset-helper"},[n]));for(const i of C(e.children))a.append(r.renderNode(i));return a}},xp={name:"ValidationSummary",description:"Aggregate error list rendered at the top of a form. Pass `errors` as `{label?, message, field?}` objects or plain strings. Pair with individual field hints via `FormControl(hint=...)`.",props:[{name:"errors",type:"any[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Please fix the following:")'},{name:"tone",type:"string",optional:!0,enum:["danger","warning"]}],render:(t,e)=>{const r=C(e.errors).map(u=>{if(!u)return null;if(typeof u=="string")return{label:"",message:u,field:""};if(typeof u=="object"){const c=u;return{label:p(c.label),message:p(c.message??c.error),field:p(c.field)}}return null}).filter(u=>u!==null&&u.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=p(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=z(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(p(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const u of r){const c=l("li",{class:"rui-validation-summary-item"});u.label&&c.append(l("strong",{},[`${u.label}: `])),c.append(document.createTextNode(u.message)),s.append(c)}return n.append(s),n}};function wp(t){return C(t).map(e=>{if(!e||typeof e!="object")return{title:p(e),details:"",content:null};const r=e;return{title:p(r.title),details:p(r.details),content:r.content??null}})}const kp={name:"MultiStepForm",description:'Multi-step / wizard form composite. Renders a `Steps` indicator, the active step\'s `content`, and Prev/Next buttons that drive a `$variable` for the current 0-indexed step. Use INSTEAD of hand-rolling `Steps` + content + manual prev/next wiring. The submit button is rendered on the final step (override via `submitLabel`). Step indicator direction defaults to `column` (stacked next to the content); set `stepsLayout: "row"` for a classic horizontal stepper.',props:[{name:"steps",type:"object[]",description:"Array of {title, details?, content} step objects"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"onSubmit",type:"callable",optional:!0,description:"Callable fired when the user clicks Submit on the final step"},{name:"prevLabel",type:"string",optional:!0,description:'Default "Back"'},{name:"nextLabel",type:"string",optional:!0,description:'Default "Continue"'},{name:"submitLabel",type:"string",optional:!0,description:'Default "Submit" (final step)'},{name:"stepsLayout",type:"string",optional:!0,enum:["column","row"],aliases:["layout","stepsDirection"],description:'Direction of the steps indicator (default "column")'}],render:(t,e,r)=>{const a=wp(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(L(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=p(e.stepsLayout,"column").toLowerCase(),u=s==="row"||s==="horizontal"?"row":"column",c=l("div",{class:"rui-multi-step-form","data-layout":u}),m=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":u});a.forEach((x,w)=>{const k=l("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(l("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(l("div",{class:"rui-steps-details"},[x.details])),m.append(k)}),c.append(m);const d=l("div",{class:"rui-multi-step-form-body"}),f=a[i];f&&f.content&&d.append(r.renderNode(f.content)),c.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),h=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[p(e.prevLabel,"Back")]);o&&i>0&&(h.onclick=()=>r.setState(o,i-1));const b=i>=n-1,v=b?p(e.submitLabel,"Submit"):p(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{b?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(h),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),c.append(g),c}};function Sp(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),message:p(r.message),time:p(r.time),icon:p(r.icon),tone:p(r.tone,"default"),unread:T(r.unread),avatarSrc:p(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const Cp={name:"InboxPanel",description:"Grouped notification list — entries are grouped into Unread/Earlier sections, with a count chip on each group header. Pass `items` as `{title, message, time, icon?, tone?, unread?, avatarSrc?, onClick?}` objects (`action` is also accepted as an alias). Pair with a `SectionHeader` for the panel title (the component does not render its own title to avoid duplication). Use for top-bar notification trays, activity drawers, and alert center pages.",props:[{name:"items",type:"object[]"},{name:"emptyLabel",type:"string",optional:!0,description:"Text shown when there are no notifications"},{name:"onMarkAllRead",type:"callable",optional:!0,description:'Callable fired by the "Mark all as read" button'}],render:(t,e,r)=>{const a=Sp(e.items),n=a.filter(u=>u.unread),i=a.filter(u=>!u.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const u=l("div",{class:"rui-inbox-panel-toolbar"}),c=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);c.onclick=()=>r.invoke(e.onMarkAllRead),u.append(c),o.append(u)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[p(e.emptyLabel,"You're all caught up.")])),o;const s=(u,c)=>{if(c.length===0)return;const m=l("section",{class:"rui-inbox-panel-group"}),d=l("header",{class:"rui-inbox-panel-group-head"});d.append(l("span",{class:"rui-inbox-panel-group-label"},[u])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(c.length)])),m.append(d);for(const f of c){const g=Bn.render({__kind:"Component",name:"Notification",args:[],argMeta:[]},{title:f.title,message:f.message,time:f.time,icon:f.icon,tone:f.tone,avatarSrc:f.avatarSrc,unread:f.unread},r);typeof f.onClick=="function"&&(g.setAttribute("data-clickable","true"),g.onclick=()=>r.invoke(f.onClick)),m.append(g)}o.append(m)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function $p(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:p(r.title),description:p(r.description),done:T(r.done),onClick:r.onClick??r.action,cta:p(r.cta,"Start")}}).filter(e=>e!==null)}const Tp={name:"OnboardingChecklist",description:'Step-by-step product checklist with completion progress at the top. Pass `items` as `{title, description?, done?, onClick?, cta?}` objects (`action` is also accepted as an alias). The progress percentage is computed automatically from `done`. Use on first-run dashboards, empty workspaces, and "complete your profile" surfaces.',props:[{name:"items",type:"object[]"},{name:"title",type:"string",optional:!0,description:'Heading (default "Getting started")'},{name:"subtitle",type:"string",optional:!0}],render:(t,e,r)=>{const a=$p(e.items),n=a.filter(d=>d.done).length,i=Math.max(1,a.length),o=Math.round(n/i*100),s=l("div",{class:"rui-onboarding-checklist"}),u=l("header",{class:"rui-onboarding-checklist-header"});u.append(l("h3",{class:"rui-onboarding-checklist-title"},[p(e.title,"Getting started")]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[c])),u.append(l("div",{class:"rui-onboarding-checklist-progress"},[l("div",{class:"rui-onboarding-checklist-bar"},[l("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),l("span",{class:"rui-onboarding-checklist-meta"},[`${n}/${a.length} complete`])])),s.append(u);const m=l("ol",{class:"rui-onboarding-checklist-list"});for(const d of a){const f=l("li",{class:"rui-onboarding-checklist-item","data-done":d.done?"true":"false"}),g=l("span",{class:"rui-onboarding-checklist-marker"}),h=z(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&g.append(h),f.append(g);const b=l("div",{class:"rui-onboarding-checklist-body"});if(b.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&b.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),f.append(b),!d.done&&typeof d.onClick=="function"){const v=l("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[d.cta]);v.onclick=()=>r.invoke(d.onClick),f.append(v)}m.append(f)}return s.append(m),s}};function ii(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=z(t.iconName,{className:t.iconClass});a&&e.append(a)}t.title&&e.append(l("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(l("p",{class:`rui-${t.klass}-description`},[t.description]));const r=C(t.actions);if(r.length>0){const a=l("div",{class:`rui-${t.klass}-actions`});for(const n of r)a.append(t.helpers.renderNode(n));e.append(a)}return e}const Ap={name:"LoadingState",description:"Full-card loading state — large spinner + title + description. Use while a query is in flight or while a long-running tool runs. For tiny inline loaders prefer `Spinner`; for skeleton placeholders prefer `Skeleton`.",props:[{name:"title",type:"string",optional:!0,description:'Default "Loading…"'},{name:"description",type:"string",optional:!0}],render:(t,e)=>{const r=l("div",{class:"rui-loading-state"}),a=l("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});a.append(l("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(a),r.append(l("h3",{class:"rui-loading-state-title"},[p(e.title,"Loading…")]));const n=p(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},Np={name:"ErrorState",description:"Full-card error placeholder. Pairs a danger icon with title, description, and a row of recovery actions (Retry / Contact support / Go home). Pass `actions` as Button(...) entries.",props:[{name:"title",type:"string",optional:!0,description:'Default "Something went wrong"'},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome icon (default `circle-exclamation`)"}],render:(t,e,r)=>ii({klass:"error-state",iconName:p(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:p(e.title,"Something went wrong"),description:p(e.description),actions:e.actions,helpers:r})},Mp={name:"SuccessState",description:'Full-card success placeholder. Use for confirmation screens ("Order placed", "Payment succeeded", "Account verified") at the end of a flow. Pass `actions` for follow-up CTAs.',props:[{name:"title",type:"string"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0},{name:"icon",type:"string",optional:!0,description:"Default `circle-check`"}],render:(t,e,r)=>ii({klass:"success-state",iconName:p(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:p(e.title),description:p(e.description),actions:e.actions,helpers:r})},Pp={name:"Tour",description:"Product-tour controller — renders the current step's title, description, and a Prev/Next/Skip row. Bind `current` to a `$variable` (0-indexed). Pass `steps` as `{title, description, target?}` objects; the optional `target` is a CSS selector that renders alongside the step for designers to reference.",props:[{name:"steps",type:"object[]"},{name:"current",type:"number",description:"0-indexed active step — bind a $variable"},{name:"open",type:"boolean",optional:!0,description:"Whether the tour is visible"},{name:"onComplete",type:"callable",optional:!0}],render:(t,e,r)=>{const a=C(e.steps).map(v=>{if(!v||typeof v!="object")return{title:p(v),description:"",target:""};const y=v;return{title:p(y.title),description:p(y.description),target:p(y.target)}}),n=e.open===void 0?!0:T(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(L(e.current,0)))),s=t.argMeta?.[1]?.stateRef,u=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return u;const c=a[o];if(!c)return u;const m=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});m.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),m.append(l("h3",{class:"rui-tour-title"},[c.title])),c.description&&m.append(l("p",{class:"rui-tour-description"},[c.description])),c.target&&m.append(l("div",{class:"rui-tour-target"},[`Target: ${c.target}`]));const d=l("div",{class:"rui-tour-footer"}),f=l("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);f.onclick=()=>r.invoke(e.onComplete);const g=l("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(g.onclick=()=>r.setState(s,o-1));const h=o>=i-1,b=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return b.onclick=()=>{h?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(f,g,b),m.append(d),u.append(m),u}},Ip={name:"Spotlight",description:'Single-step product highlight — a dimmed full-page overlay with a ring around the focused area and a small explainer card. Use for one-off feature reveals ("Try the new commands menu"). Bind `open` to a `$variable` to dismiss.',props:[{name:"title",type:"string"},{name:"open",type:"boolean",optional:!0,description:"Whether the spotlight is visible — typically a $variable (default true)"},{name:"description",type:"string",optional:!0},{name:"actions",type:"Node[]",optional:!0,aliases:["action"]}],render:(t,e,r)=>{const a=e.open===void 0?!0:T(e.open),n=l("div",{class:"rui-spotlight","data-open":a?"true":"false"});if(!a)return n;const i=l("div",{class:"rui-spotlight-card"});i.append(l("h3",{class:"rui-spotlight-title"},[p(e.title)]));const o=p(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=C(e.actions);if(s.length>0){const c=l("div",{class:"rui-spotlight-actions"});for(const m of s)c.append(r.renderNode(m));i.append(c)}const u=t.argMeta?.[1]?.stateRef;return u&&(n.onclick=c=>{c.target===n&&r.setState(u,!1)}),n.append(i),n}},Lp={name:"Sticky",description:"Wraps content in a `position: sticky` container so it pins to the top (or bottom) of the nearest scrollable ancestor. Use for toolbar action rows above tables, in-page navs, status banners.",props:[{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["top","bottom"]},{name:"offset",type:"string",optional:!0,description:"CSS offset (default 0)"},{name:"zIndex",type:"number",optional:!0,description:"Z-index (default 10)"}],render:(t,e,r)=>{const a=p(e.side,"top"),n=te(e.offset,"0"),i=Math.max(0,Math.floor(L(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const u of C(e.children))s.append(r.renderNode(u));return s}},Rp={name:"ResizablePanels",description:"Two-pane horizontal split with a draggable divider. The user can drag the divider to resize the primary pane; defaults respect the starting width. Use for code editors, file browsers, master/detail layouts that need user-controllable proportions.",props:[{name:"primary",type:"Node[]"},{name:"secondary",type:"Node[]"},{name:"initialPrimaryWidth",type:"string",optional:!0,description:"CSS width for the primary pane (default 40%)"},{name:"minPrimaryWidth",type:"string",optional:!0,description:"Min width (default 240px)"}],render:(t,e,r)=>{const a=te(e.initialPrimaryWidth,"40%"),n=te(e.minPrimaryWidth,"240px"),i=l("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${a};--rui-resizable-min:${n};`}),o=l("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const c of C(e.primary))o.append(r.renderNode(c));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),u=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const c of C(e.secondary))u.append(r.renderNode(c));return i.append(o,s,u),s.onpointerdown=c=>{const m=c,d=m.currentTarget;d.setPointerCapture(m.pointerId);const f=d.closest(".rui-resizable-panels");if(!f)return;const g=f.getBoundingClientRect(),h=v=>{const y=(v.clientX-g.left)/g.width*100,x=Math.max(15,Math.min(85,y));f.style.setProperty("--rui-resizable-primary",`${x}%`)},b=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",h),d.removeEventListener("pointerup",b)};d.addEventListener("pointermove",h),d.addEventListener("pointerup",b)},i}},Ep={name:"MasonryGrid",description:"Pinterest-style column grid. Children flow into columns that reflow on viewport changes. Use for galleries, social-style feeds, and mixed-height card walls. Prefer `Grid` when children should share the same height per row.",props:[{name:"items",type:"Node[]"},{name:"columns",type:"number",optional:!0,description:"Preferred column count (default 3)"},{name:"gap",type:"string",optional:!0,enum:["xs","s","m","l","xl"]}],render:(t,e,r)=>{const a=Math.max(1,Math.min(6,Math.floor(L(e.columns,3)))),n=p(e.gap,"m"),i=l("div",{class:"rui-masonry-grid","data-columns":String(a),"data-gap":n});for(const o of C(e.items))i.append(r.renderNode(o));return i}},zp={name:"Drawer",description:"Side drawer overlay shown when `open` is true. Pass a `$variable` as `open` to control it. Choose `side` for slide direction (default right). `onClose` fires whenever the drawer is dismissed (× button or backdrop click).",props:[{name:"title",type:"string"},{name:"open",type:"boolean",description:"Open/closed state — usually a $variable"},{name:"children",type:"Node[]"},{name:"side",type:"string",optional:!0,enum:["right","left","top","bottom"]},{name:"footer",type:"Node[]",optional:!0,description:"Optional footer actions row"},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"],description:"Callable invoked when the drawer is dismissed"}],render:(t,e,r)=>{const a=T(e.open),n=p(e.side,"right"),i=l("div",{class:"rui-sheet-overlay","data-open":a?"true":"false","data-side":n}),o=l("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":n}),s=l("header",{class:"rui-sheet-header"});s.append(l("h3",{class:"rui-sheet-title"},[p(e.title)]));const u=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),c=t.argMeta?.[1]?.stateRef,m=()=>{c&&r.setState(c,!1),r.invoke(e.onClose)};u.onclick=m,i.onclick=g=>{g.target===i&&m()},s.append(u),o.append(s);const d=l("div",{class:"rui-sheet-body"});for(const g of C(e.children))d.append(r.renderNode(g));o.append(d);const f=C(e.footer);if(f.length>0){const g=l("footer",{class:"rui-sheet-footer"});for(const h of f)g.append(r.renderNode(h));o.append(g)}return i.append(o),i}},Dp={name:"TopBar",description:'Compact header strip that pairs a title (or breadcrumb) with search and action slots. Use INSTEAD of hand-rolling a `Stack(direction="row")` above a page. For full SaaS shells use `Navbar` (links) or `AppShell` (sidebar + topbar + content).',props:[{name:"title",type:"string",optional:!0},{name:"subtitle",type:"string",optional:!0},{name:"left",type:"Node[]",optional:!0,aliases:["badges"],description:"Leading slot (breadcrumbs, brand, status, badges)"},{name:"center",type:"Node[]",optional:!0,aliases:["search"],description:"Centered slot (search bar, segmented control)"},{name:"right",type:"Node[]",optional:!0,aliases:["actions"],description:"Trailing slot (actions, avatar)"},{name:"sticky",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("header",{class:"rui-topbar","data-sticky":T(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=p(e.title);if(i){const u=l("div",{class:"rui-topbar-title-block"});u.append(l("h2",{class:"rui-topbar-title"},[i]));const c=p(e.subtitle);c&&u.append(l("p",{class:"rui-topbar-subtitle"},[c])),n.append(u)}for(const u of C(e.left))n.append(r.renderNode(u));a.append(n);const o=C(e.center);if(o.length>0){const u=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const c of o)u.append(r.renderNode(c));a.append(u)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const u of C(e.right))s.append(r.renderNode(u));return a.append(s),a}},jp={name:"Theme",description:"Apply a partial theme on top of the base theme. Pass an object of token → value pairs (colors, fonts, radii, spacing, button styling). Assigning the result to a top-level binding (conventionally `theme`) lets the runtime detect it and write the tokens to the host as CSS custom properties — the rest of the rendered UI picks them up instantly.",props:[{name:"tokens",type:"any",description:"Object literal of theme tokens. Keys must match `ThemeTokens` (e.g. colorPrimary, colorBg, fontFamily, fontFamilyHeading, fontSizeBase, radiusMd, radiusButton, borderWidth, shadowMd, buttonFontWeight, …). Unknown keys are ignored."}],render:()=>document.createDocumentFragment()},Bp={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` when the current path matches `to` (set `exact=true` to require exact equality instead of prefix matching).',props:[{name:"label",type:"string",description:"Visible link text."},{name:"to",type:"string",description:'Target route path, e.g. "/about".'},{name:"variant",type:"string",optional:!0,enum:["default","primary","ghost","pill"],description:"Visual variant."},{name:"exact",type:"boolean",optional:!0,description:"Match the current path exactly (default: prefix match)."},{name:"icon",type:"string",optional:!0,description:"Optional Font Awesome icon name shown before the label."}],render:(t,e,r)=>{const a=p(e.label,""),n=p(e.to,"/"),i=p(e.variant,"default"),o=T(e.exact,!1),s=r.router,u=s.getPath(),c=u?o?u===n:n==="/"?u==="/":u===n?!0:u.startsWith(n+"/"):!1,m=l("a",{class:"rui-nav-link","data-variant":i,"data-active":c?"true":"false",href:"#"+(n.startsWith("/")?n:"/"+n)}),d=z(e.icon,{className:"rui-nav-link-icon"});return d&&m.append(d),m.append(l("span",{class:"rui-nav-link-label"},[a])),m.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(n)))},m}},Fp=["primary","secondary","ghost","danger"],Op=["xs","sm","md","lg","xl","small","normal","large"];function _p(t){const e=p(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="small"||e==="sm"?"sm":e==="large"||e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":e==="normal"||e==="md"||e===""?"md":e==="xs"||e==="sm"||e==="md"||e==="lg"||e==="xl"?e:"md"}function Up(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n)}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function _t(t){return C(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Hp(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.value??a.label);return{value:n,label:p(a.label,n),group:p(a.group)||void 0,shortcut:p(a.shortcut)||void 0,action:a.action}}const r=p(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function oi(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=p(a.name??a.label);return{name:n,label:p(a.label,n),type:p(a.type,"text")||"text"}}const r=p(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Vp(t){return _t(t).map((e,r)=>({id:p(e.id,`task-${r}`),label:p(e.label??e.name,`Task ${r+1}`),start:p(e.start),end:p(e.end),progress:e.progress!=null?L(e.progress,0):void 0}))}function Ue(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Wp(t,e){const r=t.split(`
|
|
41
41
|
`),a=e.split(`
|
|
42
|
-
`),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],u=a[o];s===u?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),u!==void 0&&i.push({type:"add",text:u}))}return i}function ai(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function ni(t,e,r,a){for(const[n,i]of e){const o=l("div",{class:"rui-json-tree-row"});o.append(l("span",{class:"rui-json-tree-key"},[`${n}: `])),i!==null&&typeof i=="object"?o.append(ii(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[ai(i)])),t.append(o)}}function ii(t,e,r=0){const a=l("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return a.append(l("span",{class:"rui-json-tree-leaf"},[ai(t)])),a;const n=Array.isArray(t),i=n?t.map((c,m)=>[String(m),c]):Object.entries(t),o=e||r<1,s=l("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",n?` Array(${i.length})`:" Object"]),u=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&ni(u,i,e,r),s.onclick=c=>{const m=c.currentTarget,d=m.nextElementSibling;if(!d)return;const f=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",f?"true":"false"),m.setAttribute("aria-expanded",f?"true":"false"),m.firstChild&&(m.firstChild.textContent=f?"▼":"▶"),f&&d.childElementCount===0?ni(d,i,e,r):f||d.replaceChildren()},a.append(s,u),a}const Op={name:"IconButton",description:"Icon-only button with an accessible label. Use for toolbars, table row actions, and compact controls.",props:[{name:"icon",type:"string",description:"Font Awesome icon name"},{name:"label",type:"string",description:"Accessible label (visually hidden)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:zp},{name:"size",type:"string",optional:!0,enum:Rp},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":p(e.variant,"ghost"),"data-size":Ep(e.size),"aria-label":p(e.label),title:p(e.label),disabled:T(e.disabled)?"":null}),n=E(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},_p={name:"CommandPalette",description:"Cmd-K style searchable command list. Pass `items` as `{label, value, group?, shortcut?, action?}` objects.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Whether the palette is visible (default true)"},{name:"placeholder",type:"string",optional:!0},{name:"shortcut",type:"string",optional:!0,description:"Hint label, e.g. Cmd+K"}],render:(t,e,r)=>{const a=Dp(e.items),n=e.open!==void 0,i=n?T(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),u=n?i:o.get(),c=l("div",{class:"rui-command-palette","data-open":u?"true":"false"});if(!u)return c;const m=l("div",{class:"rui-command-palette-backdrop"}),d=l("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),f=l("div",{class:"rui-command-palette-header"}),g=l("input",{type:"text",class:"rui-command-palette-input",placeholder:p(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(g);const h=p(e.shortcut);h&&f.append(l("span",{class:"rui-command-palette-shortcut"},[h])),d.append(f);const b=l("div",{class:"rui-command-palette-list",role:"listbox"}),v=(y,x)=>{y.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?a:a.filter(S=>S.label.toLowerCase().includes(w)||S.value.toLowerCase().includes(w)||(S.group??"").toLowerCase().includes(w));let A="";for(const S of k.slice(0,50)){S.group&&S.group!==A&&(A=S.group,y.append(l("div",{class:"rui-command-palette-group"},[A])));const $=l("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&$.append(l("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),$.onclick=M=>{M.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const I=M.currentTarget.closest(".rui-command-palette"),R=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Ae(R??null)},y.append($)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(b,s.get()),d.append(b),m.onclick=y=>{const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ae(w??null)},c.append(m,d),g.oninput=y=>{const x=y.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&v(w,x.value)},g.onkeydown=y=>{if(y.key==="Escape"){const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ae(w??null)}},setTimeout(()=>g.focus(),0),Xe({liveRoot:d,onDismiss:()=>{o.set(!1),c.setAttribute("data-open","false")}}),c}},Up={name:"FilterChips",description:"Removable filter chips with an optional clear-all control.",props:[{name:"chips",type:"any[]",description:"Array of strings or {label, value} objects"},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed chip value as an argument"},{name:"onClear",type:"callable",optional:!0}],render:(t,e,r)=>{const a=jp(e.chips),n=l("div",{class:"rui-filter-chips"}),i=l("div",{class:"rui-filter-chips-row"});for(const o of a){const s=l("span",{class:"rui-filter-chip","data-value":o.value});s.append(l("span",{class:"rui-filter-chip-label"},[o.label]));const u=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),c=E("xmark",{className:"rui-filter-chip-remove-icon"});c&&u.append(c),u.onclick=()=>r.invoke(e.onRemove,o.value),s.append(u),i.append(s)}if(n.append(i),a.length>0&&typeof e.onClear=="function"){const o=l("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),n.append(o)}return n}},Hp={name:"FieldRepeater",description:"Dynamic list of field groups. Pass `items` as row objects and `fields` as `{name, label, type?}` definitions.",props:[{name:"items",type:"any[]"},{name:"fields",type:"any[]"},{name:"onAdd",type:"callable",optional:!0},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed row's 0-indexed position"},{name:"addLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Ot(e.items),n=ri(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const u=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),c=l("div",{class:"rui-field-repeater-grid"});for(const m of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[m.label]));const f=l("input",{class:"rui-input",type:m.type==="number"?"number":"text",name:`${m.name}-${s}`,value:p(o[m.name]),readonly:""});d.append(f),c.append(d)}if(u.append(c),typeof e.onRemove=="function"){const m=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);m.onclick=()=>r.invoke(e.onRemove,s),u.append(m)}i.append(u)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[p(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},Vp={name:"VirtualList",description:"Windowed vertical list for large datasets. Pass pre-rendered nodes as `items` or plain row objects plus a `renderItem` component node per row.",props:[{name:"items",type:"any[]"},{name:"itemHeight",type:"number",optional:!0,description:"Fixed row height in px (default 40)"},{name:"renderItem",type:"Node",optional:!0,description:"Template node rendered per data row"}],render:(t,e,r)=>{const a=Math.max(24,L(e.itemHeight,40)),n=C(e.items),i=l("div",{class:"rui-virtual-list"}),o=l("div",{class:"rui-virtual-list-scroller"}),s=l("div",{class:"rui-virtual-list-spacer"}),u=l("div",{class:"rui-virtual-list-window"}),c=n.length;s.style.height=`${c*a}px`,s.style.position="relative",u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.right="0",o.style.maxHeight=`${Math.min(Math.max(c,1),12)*a}px`,o.style.overflow="auto";const m=d=>{u.replaceChildren();const f=o.clientHeight||a*12,g=Math.ceil(f/a)+2,h=Math.max(0,d),b=Math.min(c,h+g);u.style.transform=`translateY(${h*a}px)`;for(let v=h;v<b;v++){const y=n[v];if(e.renderItem)u.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)u.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[p(y)])),u.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);m(d)},m(0),o.append(s,u),i.append(o),i}},Wp={name:"QueryBuilder",description:"Visual filter builder. Pass `fields` as `{name, label, type?}` and bind `value` to a rule array.",props:[{name:"fields",type:"any[]"},{name:"value",type:"any[]",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"Receives the next rule array"}],render:(t,e,r)=>{const a=ri(e.fields),n=Ot(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=u=>{o.replaceChildren(),u.forEach((m,d)=>{const f=l("div",{class:"rui-query-builder-row","data-index":String(d)}),g=l("select",{class:"rui-select rui-query-builder-field"});for(const y of a)g.append(l("option",{value:y.name},[y.label]));g.value=p(m.field??a[0]?.name);const h=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])h.append(l("option",{value:y},[y]));h.value=p(m.op,"equals");const b=l("input",{class:"rui-input rui-query-builder-value",value:p(m.value)});f.append(g,h,b);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=u.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},f.append(v),o.append(f)});const c=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);c.onclick=()=>{const m=[...u,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,m):r.invoke(e.onChange,m),s(m)},o.append(c)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},qp={name:"DiffViewer",description:"Side-by-side or unified diff of two text blobs.",props:[{name:"left",type:"string"},{name:"right",type:"string"},{name:"mode",type:"string",optional:!0,enum:["split","unified"],description:"Default split"}],render:(t,e)=>{const r=p(e.left),a=p(e.right),n=p(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const c=l("pre",{class:"rui-diff-viewer-unified"});for(const m of Fp(r,a))c.append(l("div",{class:`rui-diff-line rui-diff-line-${m.type}`},[(m.type==="add"?"+ ":m.type==="remove"?"- ":" ")+m.text]));return i.append(c),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),u=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,u),i.append(o),i}},Gp={name:"JsonTree",description:"Expandable JSON tree viewer for objects and arrays.",props:[{name:"data",type:"any"},{name:"expanded",type:"boolean",optional:!0,description:"Expand all nodes (default: first level only)"}],render:(t,e)=>{const r=l("div",{class:"rui-json-tree"});return r.append(ii(e.data,T(e.expanded))),r}},Kp={name:"Gantt",description:"Simple Gantt chart. Pass `tasks` as `{id, label, start, end, progress?}` ISO date strings.",props:[{name:"tasks",type:"any[]"},{name:"startDate",type:"string",optional:!0},{name:"endDate",type:"string",optional:!0}],render:(t,e)=>{const r=Bp(e.tasks),a=r.map(m=>Ue(m.start)),n=r.map(m=>Ue(m.end)),i=e.startDate?Ue(p(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?Ue(p(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),u=l("div",{class:"rui-gantt"}),c=l("div",{class:"rui-gantt-track"});for(const m of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[m.label]));const f=l("div",{class:"rui-gantt-bars"}),g=(Ue(m.start)-i)/s*100,h=Math.max((Ue(m.end)-Ue(m.start))/s*100,2),b=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${h}%`,title:`${m.start} → ${m.end}`});m.progress!=null&&b.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,m.progress))}%`})),f.append(b),d.append(f),c.append(d)}return u.append(c),u}},Yp={name:"Truncate",description:"Clamp long text with an expand control.",props:[{name:"text",type:"string"},{name:"maxLines",type:"number",optional:!0,description:"Lines before clamping (default 3)"},{name:"expandLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.maxLines,3))),n=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${a};-webkit-box-orient:vertical;overflow:hidden`,o=l("div",{class:"rui-truncate","data-expanded":n.get()?"true":"false"}),s=l("p",{class:"rui-truncate-text",style:n.get()?"":i},[p(e.text)]),u=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":p(e.expandLabel,"Show more")]);return u.onclick=c=>{const m=c.currentTarget,d=m.closest(".rui-truncate"),f=d?.querySelector(".rui-truncate-text");if(!d||!f)return;const g=!n.get();n.set(g),f.style.cssText=g?"":i,m.textContent=g?"Show less":p(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,u),o}},Xp={name:"InlineEdit",description:"Click-to-edit inline field with save on Enter or blur.",props:[{name:"value",type:"string"},{name:"label",type:"string",optional:!0},{name:"onSave",type:"callable",optional:!0,description:"Receives the committed draft string"}],render:(t,e,r)=>{const a=r.useInstanceState("editing",!1),n=r.useInstanceState("draft",p(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=p(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const u=l("button",{type:"button",class:"rui-inline-edit-display"},[p(e.value)]),c=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),m=f=>{const g=f.closest(".rui-inline-edit"),h=g?.querySelector(".rui-inline-edit-input");return!g||!h?null:{root:g,input:h}},d=f=>{const g=m(f);a.set(!1),g?.root.setAttribute("data-editing","false");const h=n.get();i&&r.setState(i,h),r.invoke(e.onSave,h)};return u.onclick=f=>{const g=m(f.currentTarget);n.set(p(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},c.oninput=f=>n.set(f.currentTarget.value),c.onkeydown=f=>{const g=f;if(g.key==="Enter"&&d(f.currentTarget),g.key==="Escape"){const h=m(f.currentTarget);a.set(!1),h?.root.setAttribute("data-editing","false")}},c.onblur=f=>d(f.currentTarget),o.append(u,c),o}},Jp={name:"NotificationBell",description:"Bell icon with unread count badge and dropdown notification list.",props:[{name:"count",type:"number",optional:!0},{name:"items",type:"any[]",optional:!0,description:"{title, message?, time?} objects"},{name:"onOpen",type:"callable",optional:!0}],render:(t,e,r)=>{const a=Math.max(0,Math.floor(L(e.count,0))),n=Ot(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),u=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),c=E("bell",{className:"rui-notification-bell-icon"});c&&u.append(c),a>0&&u.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(u);const m=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)m.append(l("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const d of n){const f=l("div",{class:"rui-notification-bell-item"});f.append(l("div",{class:"rui-notification-bell-item-title"},[p(d.title)]));const g=p(d.message);g&&f.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const h=p(d.time);h&&f.append(l("div",{class:"rui-notification-bell-item-time"},[h])),m.append(f)}return s.append(m),u.onclick=d=>{d.stopPropagation();const f=d.currentTarget,g=f.closest(".rui-notification-bell");if(!g)return;const h=!i.get();i.set(h),g.setAttribute("data-open",h?"true":"false"),f.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),Xe({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):Ae(g)},s}},he=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Zp=t=>!!(t&&typeof t=="object"),Qp={name:"Async",description:"Render `loading`, `error`, `empty`, or `data` slot based on an `$http({...})` resource's state.",props:[{name:"resource",type:"any",positional:!0,required:!0},{name:"loading",type:"Node",optional:!0},{name:"error",type:"Node",optional:!0},{name:"empty",type:"Node",optional:!0},{name:"data",type:"Node",optional:!0}],render:(t,e,r)=>{const a=e.resource,n={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Zp(a))return he(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return he(r,n.loading??null);if(i==="error"||a.error)return he(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?he(r,n.empty??n.data??null):he(r,n.data??null)}},em={name:"Show",description:"Conditional renderer. Sugar over `if expr { children } else { fallback }`.",props:[{name:"when",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>e.when?he(r,e.children??null):he(r,e.fallback??null)},tm={name:"Portal",description:"Render children outside the parent subtree (e.g. into document.body).",props:[{name:"target",type:"string",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=p(e.target);let n=null;if(a)try{n=document.querySelector(a)}catch{n=null}n||(n=document.body);const i=l("div",{class:"rui-portal"});for(const o of C(e.children))i.append(r.renderNode(o));return n&&(n.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)})),l("span",{class:"rui-portal-anchor","data-portal":a??"body"})}},rm={name:"Redirect",description:"Navigate to `path` and unmount the rest of the subtree.",props:[{name:"path",type:"string",positional:!0,required:!0}],render:(t,e,r)=>{const a=p(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},am={name:"Lazy",description:"Defer rendering `children` until `loader` resolves.",props:[{name:"loader",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=e.loader;if(typeof a=="function")try{const n=a();return n&&typeof n.then=="function"?he(r,e.fallback??null):he(r,n??e.children??null)}catch{return he(r,e.fallback??null)}return he(r,e.children??null)}},nm={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws.",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-error-boundary"});try{for(const n of C(e.children))a.append(r.renderNode(n));return a}catch(n){try{r.invoke(e.onError,n)}catch{}const i=he(r,e.fallback??null),o=l("div",{class:"rui-error-boundary rui-error-boundary--fallback"});return o.append(i),o.setAttribute("data-error",n instanceof Error?n.message:String(n)),o}}},im=new Set(["div","span","p","section","article","header","footer","main","nav","aside","figure","figcaption","details","summary","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","a","img","picture","source","video","audio","track","small","strong","em","b","i","u","s","mark","code","pre","kbd","samp","var","sub","sup","abbr","cite","blockquote","q","time","address","ins","del","ruby","rt","rp","bdi","bdo","br","hr","wbr","hgroup","label","fieldset","legend","progress","meter","output"]),om=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,sm=new Set(["href","ping","action","formaction"]),lm=new Set(["src","poster"]);function cm(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function um(t){const e=p(t).trim().toLowerCase();return!e||!im.has(e)?"div":e}function dm(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){const n=r.trim();if(!n||!om.test(n))continue;const i=n.toLowerCase();if(!i.startsWith("on")&&!(a==null||a===!1)){if(i==="style"){const o=cm(a);o&&(e.style=o);continue}if(sm.has(i)){const o=Ye(a,"");o&&(e[n]=o);continue}if(lm.has(i)){const o=ne(a);o&&(e[n]=o);continue}e[n]=a===!0?"":p(a)}}return e}const pm={name:"HTMLTag",description:"Escape-hatch primitive that renders an allow-listed HTML tag with the given attributes and children. Use ONLY when the standard component catalogue cannot express the markup (custom semantic elements, inline SVG, third-party widget mounts). Tag names outside the allow-list collapse to `div`. Attribute names matching `on*` (event handlers) are dropped, `href`/`src` are sanitised, and `style` is filtered for `expression()` / `javascript:` / `@import`. Pass children as an array of components — strings render as text nodes.",props:[{name:"tag",type:"string",positional:!0,required:!0,description:'HTML tag name (e.g. "div", "section", "svg"). Falls back to `div` when outside the allow-list.'},{name:"attributes",type:"object",optional:!0,aliases:["attrs","props"],description:'Plain object of attribute name → value pairs (e.g. `{ class: "hero", "data-id": 1 }`). `on*` handlers are dropped.'},{name:"children",type:"Node[]",optional:!0,description:"Child components or text nodes to render inside the tag."}],render:(t,e,r)=>{const a=um(e.tag),n=dm(e.attributes),i=l(a,n);for(const o of C(e.children))if(o!=null){if(typeof o=="string"){i.append(document.createTextNode(o));continue}if(typeof o=="number"||typeof o=="boolean"){i.append(document.createTextNode(String(o)));continue}i.append(r.renderNode(o))}return i}},mm=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,fm=64*1024;function gm(t){const e=p(t);return!e||e.length>fm||mm.test(e)?"":e}const oi=[dl,pl,fl,ml,cl,Cn,Tl,Al,gl,hl,bl,vl,wl,xl,Cl,Sl,Il,yl,Nl,Pl,Jl,Zl,Dl,Bl,Fl,In,_l,Ul,Hl,Vl,Gl,Xl,ec,Rl,Ql,zc,Lc,Cc,$c,Ac,Tc,Nc,Pc,Mc,Ic,kc,Sc,Ln,Rc,Ec,jc,Dc,zn,Bc,Fc,Su,ku,$u,Cu,Tu,Au,Mu,Nu,zu,Ru,Eu,Lu,Ou,_u,Uu,Wu,qu,ad,Un,Gu,Ku,rd,Yu,Xu,Zu,Qu,id,od,nd,ed,ld,Wn,ud,md,pd,bd,vd,yd,xd,Wc,qc,yu,xu,Gc,Yc,Kc,Jc,Xc,Zc,Qc,wu,eu,tu,Rn,bu,nu,au,ru,iu,ou,cu,lu,su,uu,du,mu,pu,fu,hu,gu,Sd,$d,Nd,Md,Pd,Ld,zd,Ed,jd,Dd,Fd,_d,Ud,Vd,qd,Kd,Xd,Jd,Qd,ep,ap,ip,op,lp,cp,up,dp,pp,mp,fp,hp,vp,xp,wp,kp,Sp,Cp,$p,Tp,Ap,Np,Mp,Pp,Ip,Lp,Op,_p,Up,Hp,Vp,Wp,qp,Gp,Kp,Yp,Xp,Jp,Qp,em,tm,rm,am,nm,cc,dc,mc,fc,gc,bc,In,pm,{name:"Styles",description:"Escape-hatch primitive that injects a `<style>` block containing the given CSS rules. Use ONLY when a layout cannot be expressed via component props or the `$theme(...)` token map. The CSS is rendered verbatim into the document so authors can target their own `HTMLTag` markup or scope rules to a wrapper class. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped for safety.",props:[{name:"css",type:"string",positional:!0,required:!0,aliases:["content","rules"],description:'Raw CSS text (e.g. `".hero { color: red; }"`).'}],render:(t,e)=>{const r=gm(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],hm=[{name:"Layout",components:["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Modal","Drawer","Steps","AspectRatio","ScrollArea","Sticky","ResizablePanels","MasonryGrid"],notes:["- THREE primitives cover almost everything: `Column` (stack top→bottom), `Row` (left→right), and `Grid` (equal columns / card walls). Reach for these first.","- `root` is normally a `Column([...])` (or `Container([...])` for a centered page). A `Column` is the page body; put each major chunk in a `Card(...)`.","- `Row([...])` keeps children at their natural width and vertically centered — ideal for toolbars, button rows, label+value pairs, nav bars. Use `justify` to distribute (`between`, `center`, `end`) and `gap` for spacing.","- `Grid([...], { columns: N })` = N equal columns. Omit `columns` for auto-fit (wraps as many ≥`minChildWidth` columns as fit — best for KPI/card grids). Prefer `Grid` over a wrapping `Row` whenever cells should share a width.",'- For a 12-column dashboard / sidebar layout use `GridItem` spans: `Grid([GridItem(side, { span: "1/4" }), GridItem(main, { span: "3/4" })])`. Fractions `"1/2"`…`"1/12"` (or numbers 1–12) resolve on a 12-track grid; any `GridItem` child turns the grid on automatically.','- `Center([...], { minHeight })` centers content on both axes — spinners, empty states, hero CTAs, modal bodies. Add `minHeight: "60vh"` to center vertically in a region.','- `Stack` is the responsive escape hatch: use it ONLY when the direction itself must change across breakpoints, e.g. `Stack([...], { direction: {base: "column", md: "row"} })`.',"- Make one child in a `Row` expand with `StackItem(child, { grow: 1 })` (e.g. a search input beside a fixed button), or push items apart with a bare `Spacer()` between them.","- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.","- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.",'- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered "OR"-style divider.',"- `gap`/`padding` spacing tokens are `xs|s|m|l|xl`; `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.","- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls."]},{name:"Content",components:["Text","Image","Badge","BadgeList","Callout","Quote","CodeBlock","Skeleton","Spinner","Markdown","Kbd","Icon"],notes:["- Prefer `Markdown(...)` for rich paragraph text with inline formatting — the parser supports headings, blockquotes, fenced code, numbered/bullet lists, links, images, and bare-URL auto-linking.","- Use `Callout(variant, title, description, icon?, compact?)` for highlighted notices; pass `compact: true` for a one-line inline note.","- Use `Quote(text, cite?)` for inline pull-quotes inside articles and marketing sections (use `Testimonial` when you also have author/role/rating).","- Use `CodeBlock(language, codeString, showLineNumbers?, highlightLines?)` for read-only code snippets. The header always renders a copy-to-clipboard button.",'- Use `Badge(label, variant?, icon?, size?)` for a single pill and `BadgeList(["a","b","c"], variant?, size?)` to render an array of strings as Badge pills.',"- Use `Skeleton(variant?, lines?, height?, shape?, width?)` for loading placeholders; `variant` accepts `paragraph` (default), `card`, `table-row`, `avatar`, `image`.","- Use `Spinner(size?, label?, tone?)` for tiny inline loading indicators inside buttons, toolbars, or table cells.",'- Use `Image(src, alt?, caption?, ratio?, fit?, fallback?)` — `ratio` (e.g. `"16:9"`) makes the image self-constrain so you do not need an outer `AspectRatio`.','- Use `Kbd(["Cmd", "K"])` when referring to keyboard shortcuts.','- Use `Icon(name, variant?, size?)` to render a standalone Font Awesome icon (`name` is the FA name without the `fa-` prefix, e.g. `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`).','- For page-level titles reach for `PageHeader(...)` (top of dashboards/detail pages) or `SectionHeader(...)` (inside a Card). For tiny inline titles use `Text(value, variant="large-heavy")`.']},{name:"Forms",components:["Form","FormControl","FormSection","FieldSet","ValidationSummary","Input","TextArea","PasswordInput","MaskedInput","MentionInput","TagInput","Select","SelectItem","Combobox","MultiSelect","Checkbox","CheckBoxGroup","CheckBoxItem","Radio","Switch","ToggleGroup","Button","Buttons","SearchBar","Slider","NumberInput","ColorPicker","DatePicker","DateRangePicker","TimePicker","DateTimePicker","FileUpload","PinInput","MultiStepForm"],notes:["- Each FormControl should be a separate reference for progressive streaming.","- Pass a `$variable` as the last argument to `Input`, `Select`, `Checkbox`, `Switch`, `MultiSelect`, or `CheckBoxGroup` for two-way binding.","- Prefer `Switch` over `Checkbox` for settings; use `ToggleGroup` for view-mode pickers and mutually-exclusive filters.","- Reach for `SearchBar(id, placeholder?, value?, shortcut?)` instead of a raw `Input` whenever the field's purpose is to filter content. It ships with the magnifier icon and keyboard hint baked in.","- `Slider(id, min?, max?, step?, value?, label?, showValue?)` is the canonical control for numeric ranges (volume, brightness, filters); pass a `$variable` as `value` for two-way binding.",'- `NumberInput(id, value?, min?, max?, step?, placeholder?)` is friendlier than `Input(type="number")` for quantity steppers and integer settings — it ships with +/- buttons that respect `min`/`max`.',"- `DatePicker(id, value?, label?, min?, max?, placeholder?)` wraps the native date picker; pass `value` as a `$variable` for two-way binding (ISO `YYYY-MM-DD`).","- `DateRangePicker(id, from?, to?, label?, min?, max?)` is the paired-date variant — bind both `from` and `to` to `$variable`s for a single shared range.","- `Combobox(id, items, value?, placeholder?, emptyLabel?)` is the searchable single-select alternative to `Select` — type to filter long option lists (countries, currencies, users).","- `MultiSelect(id, items, value?, placeholder?, emptyLabel?, max?)` is the multi-select equivalent — bind a `$variable` array as `value` for two-way binding, the trigger renders the picks as removable chips.","- `FileUpload(id, { label?, hint?, accept?, multiple?, action? })` is the styled file picker; the picked files cannot pass through a `$variable`, so wire the `action` prop to a `function` declaration.",'- A submit button should call an `action` that awaits the relevant `$mutation` resource, optionally refetches a `$query`, and resets the form `$variable`s (e.g. `$title = ""`).',"- Button `size` accepts both `sm|md|lg` (canonical) and the legacy `small|normal|large`. Pass `icon` for an inline leading icon.","- `FormSection(label, children, helper?)` is the canonical wrapper for related fields. Reach for it INSTEAD of nesting fields in Card + SectionHeader by hand.","- `FieldSet(legend, children, helper?)` is the accessible `<fieldset>` for radio/checkbox groups; prefer `FormSection` for purely visual grouping.","- `ValidationSummary(errors, title?)` renders an aggregate error panel at the top of the form. Pass `errors` as `{label, message}` objects.",'- `PasswordInput(id, value?, placeholder?, strengthMeter?)` adds a show/hide toggle and an optional 4-step strength meter — prefer over `Input(type="password")` for sign-up flows.',"- `PinInput(id, length?, value?, type?)` renders per-digit code entry for 2FA / SMS verification (use `length=6` for OTP codes).","- `TagInput(id, value?, placeholder?)` lets the user add comma- or Enter-separated chips bound to a `$variable` array.","- `MentionInput(id, people, value?)` is a textarea with inline @-mention suggestions — use for comments, task notes, chat composers.","- `MaskedInput(id, mask, value?)` formats input against a mask string (`9` digit, `A` letter, `*` any). Use for phone numbers, postal codes.","- `TimePicker(id, value?)` and `DateTimePicker(id, value?)` wrap the corresponding native inputs with consistent styling.","- `ColorPicker(id, value?, label?, swatches?)` pairs a color chip with a hex input and preset swatches — bind a $variable holding a hex string.","- `MultiStepForm(steps, current, onSubmit?)` replaces ad-hoc `Steps` + content + manual prev/next wiring. Each step is `{title, details?, content}`."]},{name:"Data",components:["Table","Col","DataGrid","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","Pagination","Tree","TreeNode","CalendarView","ComparisonTable","InfiniteList"],notes:['- Build columns using array pluck: `Col("Title", data.rows.title, format?, align?)`.',"- For per-row controls inside a Col, use `for (let row of data.rows) { ... }` and reference `row.field` inline.",'- `Table(cols, caption?, density?, striped?, sticky?, emptyLabel?)` — pass `density="compact"` for dense data, `sticky=true` to pin the header in a scrolling parent, and `emptyLabel` for the zero-state cell.',"- `DataGrid(cols, rowIds?, caption?, sort, selectedIds, selectable?, page, perPage?, …)` is the advanced Table — adds sortable headers (`sortable=true` on Col), per-column filter chips (`filterable=true`), checkbox row selection bound to `$selectedIds`, sticky header / first column, pagination, and an optional bulk-action toolbar. Reach for this whenever a user needs to sort, filter, or page through a list.","- `CalendarView(value?, month?, events?, view?, firstDay?, onSelect?)` renders a full-month (or week) calendar grid for scheduling apps — distinct from the `DatePicker` input. Bind `value` to a `$variable` for the selected ISO date.","- `ComparisonTable(columns, rows, highlightColumn?)` is the generic counterpart of `PricingTable` — pass rows of `{label, values, hint?, group?}`. Use for feature comparisons, spec sheets, plan grids.","- `InfiniteList(items, onLoadMore?, loading?, hasMore?)` is a scroll-to-load list; the action fires when the sentinel scrolls into view.","- Use `Progress(value, max?, label?, tone?, indeterminate?, segments?, buffered?)` for linear bars — `segments` renders an N-step strip (onboarding flows), `buffered` adds a secondary buffer indicator.","- `ProgressRing(value, max?, label?, tone?, size?)` is the circular variant for quotas/completion.",'- `Stats([{label, value, hint?, tone?, spark?}, …], layout?)` — `layout="strip"` (default) for inline KPIs; `layout="grid"` for a responsive StatCard grid. Pass `spark` for an inline trend line.',"- `StatCard(label, value, trend?, delta?, icon?, spark?, tone?)` gains an optional inline `Sparkline` via the `spark` prop. Use `Sparkline(values, tone?)` standalone for tiny trend chips in table cells.","- `Tile(label, icon?, value?, description?, tone?, action?)` is the dense icon tile for quick-action menus and category grids; pair with `Grid` for uniform rows.","- `Tree([TreeNode(label, children?, icon?, expanded?, active?, badge?, action?)])` renders a hierarchical tree (file browsers, nested navigation, category pickers); use `expanded=true` to open a branch by default.",'- `Pagination(page, totalPages, siblings?, total?, perPage?, perPageOptions?, compact?)` — bind `page` (and optionally `perPage`) to a `$variable`; pass `total` to render the "Showing N–M of T" summary. Reuse the same variable when slicing data with `arr.filter(...)` / `for`.']},{name:"Charts",components:["BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series"],notes:["- Use `LineChart` for trends (pass `filled=true` for area-style charts), `BarChart` for comparisons, `PieChart` for proportions, `RadarChart` for multi-axis scorecards.","- `Heatmap(xLabels, yLabels, values)` renders a color-intensity matrix — perfect for calendar heatmaps, correlation grids, schedule density.","- `ScatterChart(series, xLabel?, yLabel?)` plots XY points; pass each Series as `Series(name, points)` where points are `{x, y, label?}`.","- `Histogram(values, binCount?)` bins raw numbers; pass pre-computed `bins=[{label, count}]` instead when you control the bucketing.","- `Gauge(value, min?, max?, label?, tone?, size?)` is the half-doughnut KPI indicator for thresholds (uptime %, score, NPS).",'- Pass series via `Series("Name", [...numbers])`.']},{name:"Feedback & Media",components:["Avatar","AvatarGroup","PersonChip","Tooltip","HoverCard","Popover","Rating","Toast","VideoPlayer","AudioPlayer","Carousel","Gallery","Lightbox","Map"],notes:["- `Avatar(name, src?, size?, status?)` falls back to initials when the image is missing.","- Use `AvatarGroup` to render contributor strips with a `+N` overflow chip.","- `PersonChip(name, role?, avatarSrc?, size?, status?, action?)` is the inline avatar + name + role pill — use everywhere a person is referenced (table cells, list rows, sidebar footers, kanban cards) instead of a raw `Avatar` next to `Text`.","- Wrap any node in `Tooltip(label, trigger)` for inline hints.","- Use `HoverCard(trigger, content)` when the popover needs rich content (profile preview, link target) and the trigger should open on hover.","- `Popover(trigger, content, title?, side?, align?, width?)` is the click-triggered counterpart of `HoverCard` — use for filter panels, color pickers, share menus, and small settings flyouts. Always renders an × close button in the header; clicking the trigger again, clicking outside, or pressing Escape also closes it.",'- `Rating(value, max?, label?, count?, size?, interactive?, halfStep?, icon?)` renders stars for product reviews, testimonials, and ranked lists. Pass a `$variable` as `value` with `interactive=true` to let users rate; add `halfStep=true` so clicking the left half of a star sets a half-value. Set `icon="heart"|"thumb"|"fire"|"bolt"` (or any FA name) to swap glyphs.',"- `Toast(title, message?, tone?, icon?, duration?, action?, onClose?, position?)` pins a transient notice; pass `duration` (ms) for auto-dismiss. Drive lists from an `action` body: `$toasts = [...$toasts, item]` to append and `$toasts = $toasts.filter((t) => t.id !== id)` to dismiss. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `NotificationBell(count?, items?, onOpen?)` — compact inbox trigger; `CommandPalette` for Cmd-K action search."]},{name:"Navigation",components:["Breadcrumb","BreadcrumbItem","Navbar","NavbarItem","DropdownMenu","MenuItem","MenuSeparator","MenuLabel"],notes:['- Use `Breadcrumb(["Workspace", "Reports", "Q3"])` at the top of every detail page so users see the path.',"- For per-item links, pass `BreadcrumbItem(label, href)` nodes instead of strings.","- `Navbar(brand?, items?, actions?, sticky?, variant?)` + `NavbarItem(label, to?, href?, icon?, active?, action?, external?)` produces a top navigation bar with brand on the left, links in the middle, and actions on the right — the canonical companion of `Sidebar` for marketing pages, docs, or any product surface without left-side nav.",'- `DropdownMenu(trigger, items, side?, align?, label?)` is the click-triggered dropdown menu — use it for user-profile menus, row "…" action menus, and any compact list of actions hanging off a single trigger. Children must be `MenuItem`, `MenuSeparator`, or `MenuLabel` entries.','- `MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)` renders a single row inside a `DropdownMenu`; use `variant="danger"` for destructive actions and `MenuSeparator()`/`MenuLabel(label)` to group related items.']},{name:"Chat",components:["SectionBlock","ListBlock","FollowUpBlock","FollowUpItem","ActionLink","ChatBubble"],notes:["- End most responses with a `FollowUpBlock` of 2–4 short prompts to keep the conversation moving.",'- `ChatBubble(author, body, time?, avatarSrc?, from?)` renders a single message bubble; use `from="me"` for the active speaker and `from="agent"` for the assistant. Compose transcripts as `Stack([ChatBubble(...), ChatBubble(...), …])` inside a `Card`.']},{name:"Patterns",components:["Hero","PageHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","Banner","Notification","InboxPanel","OnboardingChecklist","MediaCard","TopBar","KanbanBoard","KanbanColumn","KanbanCard","SectionHeader","Toolbar","DescriptionList","DescriptionItem","StatusDot","PricingTable","PricingCard","LoadingState","ErrorState","SuccessState","Tour","Spotlight"],notes:["- Patterns are **opinionated composites** that pack an entire UI idiom into one component. Reach for them BEFORE composing equivalent layouts by hand with Card+Stack — the result will look more polished and require fewer tokens.",'- `Hero(title, subtitle, primary, secondary, eyebrow?, highlights?, tone?)` — landing-style text-first header. Use `layout="cover"` with `imageSrc`, `height`, and optional `caption` for image-backed hero bands.','- `PageHeader(title, subtitle?, breadcrumbs?, actions?, status?)` — the canonical first child for any dashboard or detail page. If you omit `breadcrumbs`, the component auto-derives `["Home", title]`.',"- `TopBar(title?, search?, actions?, sticky?)` — compact top strip for a content surface (panels, dialogs, embedded views). Use `AppShell` when you need a full sidebar; use `TopBar` for narrower headers above scrolling content.","- `SectionHeader(title, subtitle?, eyebrow?, status?, actions?)` — sub-header inside a Card or panel. Use instead of bare `CardHeader` when the section also needs eyebrow / actions / status.",'- `Stats(items, layout?)` — KPI strip (`layout="strip"`, default) or responsive grid (`layout="grid"` with StatCard children). Prefer over hand-rolled StatCard rows.',"- `Toolbar(left?, right?, center?, searchable?, searchPlaceholder?, searchValue?)` — filter/search/actions row above a list, table, or board. Pass `searchable: true` to auto-mount a `SearchBar` (use `searchValue` to bind it to a `$variable`).","- `EmptyState(title, description?, icon?, illustration?, actions?, action?)` — render this when a list is empty rather than an empty Card. The icon is auto-picked from the title keywords if you omit it (inbox/messages → `inbox`, charts/analytics → `chart-pie`, files/folders → `folder-open`, etc.).","- `Timeline([TimelineItem(...)])` — vertical event feed (audit log, changelog, activity).",'- `ActivityLog(entries, variant?)` — purpose-built feed of user actions. Pass `entries` of `{actor, title, description?, time?, icon?, tone?, meta?}`; use `variant="audit"` for security/admin trails with monospace meta.',"- `FeatureGrid([FeatureItem(...)])` — feature highlights with iconography.","- `MediaCard(title, imageSrc?, description?, tags?, meta?, actions?, badge?, orientation?, ratio?)` — image + content card. Use for article previews, product cards, project highlights. Pair with `Grid` for uniform card rows.",'- `KanbanBoard([KanbanColumn("To do", [KanbanCard(...), ...])])` — task boards.','- `DescriptionList([DescriptionItem("Status", Badge(...)), …])` — detail-page key/value summary. Always preferable to a Stack of Text rows on profile, billing, or metadata panels.',"- `StatusDot(label, tone?, pulse?)` — inline status pip. Use in toolbars, list rows, table cells, sidebars.","- `Notification(title, message?, time?, icon?, avatarSrc?, tone?, unread?, actions?)` — inline notification card for notification panels / inboxes (prefer `Banner` for top-of-page announcements).","- `InboxPanel(items, title?, onMarkAllRead?)` — `Notification` cards grouped into Unread / Earlier sections, with a shared mark-all-read action.","- `OnboardingChecklist(items, title?, description?)` — checklist of `{title, description?, done?, action?}` items with progress. Use for product onboarding, setup wizards, getting-started panels.","- `PricingTable([PricingCard(plan, price, period?, description?, features?, action?, badge?, featured?)])` — full pricing page block.","- `LoadingState(title?, description?, tone?, action?)`, `ErrorState(title, description?, action?, secondaryAction?, retryLabel?)`, `SuccessState(title, description?, action?, secondaryAction?)` — full-card empty-state alternatives for asynchronous content states.","- `Tour(steps, current, onFinish?)` and `Spotlight(title?, description?, action?)` are the product-tour primitives. `Spotlight` is a single highlighted call-out; `Tour` walks the user through multiple `{title, description, image?}` steps with Prev/Next/Skip controls and a progress dots indicator."]},{name:"Editors & overlays",components:["RichTextEditor","CodeEditor","ContextMenu"],notes:["- `RichTextEditor(id, value?, placeholder?, minHeight?)` is the contenteditable WYSIWYG editor — toolbar ships with bold/italic/underline/strike/heading/lists/link. Bind `value` to a `$variable` holding HTML.","- `CodeEditor(id, value?, language?, placeholder?, minHeight?)` is a lightweight `<textarea>` with a synced line-number gutter and tab indentation. Use for snippet editors, prompt sandboxes, settings JSON.","- `ContextMenu(target, items)` attaches a right-click menu to any node. `items` are `MenuItem` or `{label, action?, icon?, shortcut?, variant?, disabled?}` objects; pass a `MenuSeparator()` to split groups."]},{name:"App shell",components:["AppShell","Sidebar","SidebarSection","SidebarItem","SplitView"],notes:["- App shell components produce a **full SaaS-style layout in a single statement**. Use them whenever the response represents a complete product surface (dashboards with nav, settings sections, admin consoles, inboxes).","- `AppShell(sidebar, content, topbar?, collapsible?, sidebarOpen?)` — fixed-left navigation + scrollable main area. Pass `collapsible=true` to enable a hamburger that turns the sidebar into a slide-over drawer on mobile; bind `sidebarOpen` to a `$variable` if you want to drive that drawer programmatically.","- `Sidebar(items, brand?, tagline?, footer?, collapsed?)` + `SidebarItem(label, icon?, active?, badge?, action?)` + `SidebarSection(label, items)` — group nav links into sections, mark the current page with `active=true`, attach badges for counts. Pass `collapsed=true` (or bind to a `$variable`) to collapse it to an icon rail.","- `SplitView(primary, detail, primaryWidth?)` — master/detail layout (inboxes, file browsers, contact lists). Both panes are scrollable."]},{name:"Theming",components:["Theme"],notes:["- `$theme({...})` applies a partial token override **on top of** the base theme set by the host (attribute / `setTheme()`). Use it to brand a single response without changing host configuration.","- Assign to `aktion.theme` so the runtime picks it up:",' `theme = $theme({ colors: { primary: "#0969da" }, radius: { button: "6px" } })`',"- Tokens MUST use the structured form. Top-level groups: `colors`, `radius`, `font`, `motion`, `elevation` (plus metadata: `name`, `direction`).","- Common tokens (each lives inside its group): `colors.primary`, `colors.primaryHover`, `colors.primaryText`, `colors.accent`, `colors.bg`, `colors.surface`, `colors.text`, `colors.textMuted`, `colors.border`, `colors.focusRing`; `radius.md`, `radius.button`, `radius.input`; `font.family`, `font.familyHeading`, `font.sizeBase`, `font.weightHeading`; `motion.transitionDuration`; `elevation.md`.","- The legacy flat-shape form (`$theme({colorPrimary: ...})`) and free-form `--css-vars` are removed in Aktion 0.5 — the runtime drops them and the schema validator surfaces a migration warning.",'- Tokens are CSS values (`"#0969da"`, `"\'Inter\', sans-serif"`, `"6px"`, `"600"`). The runtime ignores unknown keys inside a group, so typos fail silent.',"- Removing the `theme = $theme(...)` line snaps the UI back to the base theme without a reload."]},{name:"Advanced UI",components:["IconButton","CommandPalette","FilterChips","FieldRepeater","VirtualList","QueryBuilder","DiffViewer","JsonTree","Gantt","Truncate","InlineEdit","NotificationBell"],notes:["- `IconButton(icon, label, action?, variant?, size?, disabled?)` — accessible icon-only control.","- `CommandPalette(items, open?, placeholder?, shortcut?)` — Cmd-K searchable actions.","- `FilterChips(chips, onRemove?, onClear?)` — applied filter pills with remove.","- `FieldRepeater(items, fields, onAdd?, onRemove?)` — dynamic form rows.","- `VirtualList(items, itemHeight?, renderItem)` — windowed long lists.","- `QueryBuilder(fields, value?)` — visual AND/OR filter builder.","- `DiffViewer(left, right, mode?)` — side-by-side or unified diff.","- `JsonTree(data)` — collapsible JSON inspector.","- `Gantt(tasks, startDate?, endDate?)` — horizontal schedule timeline.","- `Truncate(text, maxLines?)` / `InlineEdit(value, onSave?)` / `NotificationBell(count?, items?)`."]},{name:"Routing",components:["NavLink"],notes:['- Declare routes with the `$router({...})` call form: `pages = $router({ "/": Dashboard(), "/orders/:id": OrderDetail({ id: params.id }), default: NotFound() })`. The matched arm\'s `params` object is in scope on the right-hand side; nest `$router` inside components for layout-preserving sub-routes.',"- `Redirect(path)` is a router-aware component: returning it from a route's body navigates and unmounts the rest of the subtree.","- `NavLink(label, { to })` is a thin link wrapper that reads `route.path` and dispatches `route.navigate(to)` — use it for sidebars, navbars and breadcrumbs.","- Read URL params via `route.params.<name>` (e.g. `route.params.id` for `/users/:id`) and the current path via `route.path`."]},{name:"Helpers",components:["Async","Show","Portal","Redirect","Lazy","ErrorBoundary"],notes:["- `Async(resource, { loading:, error:, empty:, data: })` switches an `$http({...})` resource on its `state` field (`empty` shows for `null`/empty-array data).","- `Show(when, { fallback?, children })` is sugar over `if (expr) { children } else { fallback }`.","- `Portal(target?, children)` renders into a different DOM subtree (defaults to `document.body`).","- `Redirect(path)` is a router-aware component — see Routing.","- `Lazy(loader, fallback?)` defers children until `loader` resolves.","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","Css","Link"],notes:["- Wrappers compose: any built-in component can be made clickable, hoverable, observable, or restyled by wrapping it in one of these primitives — no need for the underlying component to grow another prop.","- `OnClick(child, { onClick, disabled?, stopPropagation? })` makes any component clickable / tappable (touch devices fire `click` too). Use for clickable cards, list rows, media tiles, and any custom layout that needs a tap target without a `<button>` baseline.","- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` attaches any combination of mouse / pointer / drag listeners. Pass `draggable: true` to make the wrapper itself draggable. Scroll / wheel listeners default to `{ passive: true }` for smooth scrolling.","- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })` attaches keyboard listeners. The wrapper is focusable by default; pass `focusable: false` when the child is already focusable (input, button).","- `OnFocus(child, { onFocus?, onBlur? })` tracks focus moving into or out of a subtree (uses bubbling `focusin` / `focusout` so descendants count).","- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` is the IntersectionObserver wrapper — perfect for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.","- `Css(child, { style?, class? })` merges raw class tokens and inline styles onto the wrapped child. Reach for it ONLY when the standard component props can't express the styling — prefer `Box`/`Stack`/`Grid` for layout and `$theme(...)` for tokens.","- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links."]},{name:"Escape hatches",components:["HTMLTag","Styles"],notes:["- **Use only as a last resort.** Reach for these primitives when the standard catalogue cannot express the markup or styling you need; for everything else (typography, layout, surfaces, controls) the dedicated components produce a more consistent UI for fewer tokens.",'- `HTMLTag(tag, attributes?, children?)` renders an allow-listed HTML tag with the given attribute object and child nodes (e.g. `HTMLTag("section", attributes: {class: "hero", "data-id": 1}, children: [Text("Hello")])`). Tag names outside the allow-list collapse to `div`; `on*` attributes, `javascript:` URLs in `href`/`src`, and `expression()` / `@import` in inline `style` are stripped.',"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped."]}];ba(oi);const dt={root:"Column",components:oi,componentGroups:hm},bm="$";function vm(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function ym(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(t[n],e[n]))return!1;return!0}class si{constructor(e){D(this,"instanceStates",new Map);D(this,"instanceDisposers",new Map);D(this,"aliveInstances",new Set);D(this,"instancesWithEffects",new Set);D(this,"instancesWithHooks",new Set);D(this,"memoCache",new Map);D(this,"changedPaths",new Set);D(this,"memoEnabled",!1);this.options=e}setLibrary(e){this.options={...this.options,library:e}}reset(){for(const e of this.instanceDisposers.values())for(const r of e.values())this.safeDispose(r);if(this.instanceDisposers.clear(),this.instanceStates.clear(),this.memoCache.clear(),this.options.unmountInstanceEffects)for(const e of this.instancesWithEffects)try{this.options.unmountInstanceEffects(e)}catch(r){console.error(`[aktion] unmountInstanceEffects threw for ${e}`,r)}if(this.instancesWithEffects.clear(),this.options.unmountInstanceHooks)for(const e of this.instancesWithHooks)try{this.options.unmountInstanceHooks(e)}catch(r){console.error(`[aktion] unmountInstanceHooks threw for ${e}`,r)}this.instancesWithHooks.clear(),this.aliveInstances=new Set}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1}endRender(){const e=this.aliveInstances;for(const r of[...this.instanceStates.keys()]){const a=r.lastIndexOf("::"),n=a===-1?r:r.slice(0,a);e.has(n)||this.instanceStates.delete(r)}for(const[r,a]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const n of a.values())this.safeDispose(n);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(a){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,a)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(a){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,a)}this.instancesWithHooks.delete(r)}}for(const r of[...this.memoCache.keys()])e.has(r)||this.memoCache.delete(r)}safeDispose(e){try{e()}catch(r){console.error("[aktion] disposer threw",r)}}writeState(e,r){const a=e.indexOf(".");if(a<0){this.options.state.set(e,r);return}const n=e.slice(0,a),i=e.slice(a+1).split(".");this.options.state.setPath(n,i,r)}render(e){return this.renderAt(e,bm)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const a=document.createDocumentFragment();return e.forEach((n,i)=>{a.append(this.renderAt(n,`${r}/${i}`))}),a}return Wa(e)?this.renderUserComponent(e,r):Va(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const a=this.options.evaluationContext;if(!a){const u=document.createElement("div");return u.className="rui-unknown-component",u.textContent=`[unknown component: ${e.decl.name}]`,u}const n=a(),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.decl.name}${i}`;this.aliveInstances.add(o);const s=this.memoCache.get(o);if(this.memoEnabled&&s&&vm(e.positional,s.positional)&&ym(e.named,s.named)&&!vt(this.changedPaths,s.deps)){const u=n.trackedState;for(const c of s.deps)u.add(c);nr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{ir(n)}}nr(n,e.decl.name);try{const u=n.trackedState,c=new Set;n.trackedState=c;let m;try{m=tn(e,n,o)}finally{n.trackedState=u;for(const h of c)u.add(h)}const{value:d,effects:f,hooks:g}=m;return this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,f,a),f.length>0&&this.instancesWithEffects.add(o)),g>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:c,value:d}),this.renderAt(d,o)}finally{ir(n)}}renderComponent(e,r){const a=Ne(this.options.library,e.name);if(!a){const c=document.createElement("div");return c.className="rui-unknown-component",c.textContent=`[unknown component: ${e.name}]`,c}const n=va(a,e.args),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.name}${i}`;this.aliveInstances.add(o);let s=0;const u={renderNode:c=>this.renderAt(c,`${o}>${s++}`),invoke:(c,...m)=>{if(typeof c=="function")try{const d=c(...m);d&&typeof d.then=="function"&&d.catch(f=>{console.error("[aktion] handler rejected",f)})}catch(d){console.error("[aktion] handler threw",d)}},setState:(c,m)=>{this.writeState(c,m)},resetState:(...c)=>{this.options.state.reset(...c)},sendToAssistant:c=>{this.options.onAssistantMessage?.(c)},openUrl:c=>{const m=Ye(c,"#"),d=this.options.onOpenUrl;d?d(m):m!=="#"&&typeof window<"u"&&window.open(m,"_blank","noopener,noreferrer")},bindState:(c,m,d)=>{const g=`on${d?.event??this.eventFor(c)}`,h=d?.getValue??this.defaultValueGetter(c);c[g]=b=>{const v=b.currentTarget??b.target??c;this.writeState(m,h(v))}},useInstanceState:(c,m)=>{const d=`${o}::${c}`;return this.instanceStates.has(d)||this.instanceStates.set(d,m),{get:()=>this.instanceStates.get(d),set:f=>{this.instanceStates.set(d,f)}}},registerDisposer:(c,m)=>{let d=this.instanceDisposers.get(o);d||(d=new Map,this.instanceDisposers.set(o,d));const f=m??`__anon::${d.size}`,g=d.get(f);g&&g!==c&&this.safeDispose(g),d.set(f,c)},router:this.options.router};try{return a.render(e,n,u)}catch(c){console.error(`[aktion] failed to render ${a.name}`,c);const m=document.createElement("div");return m.className="rui-render-error",m.textContent=`[render error in ${a.name}]`,m}}eventFor(e){return e instanceof HTMLSelectElement||e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?"change":"input"}defaultValueGetter(e){return e instanceof HTMLInputElement&&e.type==="checkbox"?r=>r.checked:e instanceof HTMLInputElement&&e.type==="radio"?r=>r.value:e instanceof HTMLInputElement&&e.type==="number"?r=>{const a=r.value;if(a==="")return null;const n=Number(a);return Number.isFinite(n)?n:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}const xm=["onclick","oninput","onchange","onsubmit","onfocus","onblur","onkeydown","onkeyup","onkeypress","onerror","onmouseenter","onmouseleave","onmousedown","onmouseup","onpointerdown","onpointerup"];function wm(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];ui(t,r)}function li(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return ci(t,e);if(t.nodeType===Node.TEXT_NODE)return t.textContent!==e.textContent&&(t.textContent=e.textContent),t;if(t.nodeType!==Node.ELEMENT_NODE)return t;const r=t,a=e;return r.tagName!==a.tagName?ci(r,a):(km(r,a),r)}function ci(t,e){return t.parentNode?.replaceChild(e,t),e}function km(t,e){Sm(t,e),Cm(t,e),ui(t,Array.from(e.childNodes)),$m(t,e)}function Sm(t,e){const r=t.attributes;for(let n=r.length-1;n>=0;n-=1){const i=r[n];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.removeAttribute(i.name)}const a=e.attributes;for(let n=0;n<a.length;n+=1){const i=a[n];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function Cm(t,e){for(const r of xm){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function $m(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Tm(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Am(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!_t(t)&&t.value!==e.value&&(t.value=e.value);return}}function Tm(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!_t(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!_t(t)&&t.value!==r&&(t.value=r)}function Am(t,e){const r=e.value??e.textContent??"";!_t(t)&&t.value!==r&&(t.value=r)}function _t(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function ui(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=zr(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=zr(n);if(o&&r.has(o)){const u=r.get(o);r.delete(o),u!==i&&t.insertBefore(u,i),li(u,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=zr(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}li(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function zr(t){if(t.nodeType!==Node.ELEMENT_NODE)return null;const e=t;if(e.id)return`#${e.id}`;const r=e.getAttribute("data-rui-key");return r?`@${r}`:null}const V="aktion";function Rr(t,e={}){return e.mode==="chat"?Pm(t,e):Mm(t,e)}function Nm(t){return Ut(t)}function Mm(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(Im(e.preamble)),n.push(Lm()),n.push(zm()),r&&n.push(Rm()),n.push(Em()),n.push(jm()),a&&n.push(Dm()),n.push(Bm()),n.push(Fm()),n.push(Om()),n.push(_m()),n.push(Um()),n.push(Hm()),n.push(Vm()),n.push(Wm(t)),e.inlineMode&&n.push(qm()),e.editMode&&n.push(Gm()),e.tools&&e.tools.length>0&&n.push(sf(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(Er("Endpoint examples",e.toolExamples));const i=e.examples??Ym();return i.length>0&&n.push(Er("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(di(e.additionalRules)),n.push(Km()),n.join(`
|
|
42
|
+
`),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],u=a[o];s===u?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),u!==void 0&&i.push({type:"add",text:u}))}return i}function si(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function li(t,e,r,a){for(const[n,i]of e){const o=l("div",{class:"rui-json-tree-row"});o.append(l("span",{class:"rui-json-tree-key"},[`${n}: `])),i!==null&&typeof i=="object"?o.append(ci(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[si(i)])),t.append(o)}}function ci(t,e,r=0){const a=l("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return a.append(l("span",{class:"rui-json-tree-leaf"},[si(t)])),a;const n=Array.isArray(t),i=n?t.map((c,m)=>[String(m),c]):Object.entries(t),o=e||r<1,s=l("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",n?` Array(${i.length})`:" Object"]),u=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&li(u,i,e,r),s.onclick=c=>{const m=c.currentTarget,d=m.nextElementSibling;if(!d)return;const f=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",f?"true":"false"),m.setAttribute("aria-expanded",f?"true":"false"),m.firstChild&&(m.firstChild.textContent=f?"▼":"▶"),f&&d.childElementCount===0?li(d,i,e,r):f||d.replaceChildren()},a.append(s,u),a}const qp={name:"IconButton",description:"Icon-only button with an accessible label. Use for toolbars, table row actions, and compact controls.",props:[{name:"icon",type:"string",description:"Font Awesome icon name"},{name:"label",type:"string",description:"Accessible label (visually hidden)"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]},{name:"variant",type:"string",optional:!0,aliases:["tone"],enum:Fp},{name:"size",type:"string",optional:!0,enum:Op},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":p(e.variant,"ghost"),"data-size":_p(e.size),"aria-label":p(e.label),title:p(e.label),disabled:T(e.disabled)?"":null}),n=z(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},Gp={name:"CommandPalette",description:"Cmd-K style searchable command list. Pass `items` as `{label, value, group?, shortcut?, action?}` objects.",props:[{name:"items",type:"any[]"},{name:"open",type:"boolean",optional:!0,description:"Whether the palette is visible (default true)"},{name:"placeholder",type:"string",optional:!0},{name:"shortcut",type:"string",optional:!0,description:"Hint label, e.g. Cmd+K"}],render:(t,e,r)=>{const a=Hp(e.items),n=e.open!==void 0,i=n?T(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),u=n?i:o.get(),c=l("div",{class:"rui-command-palette","data-open":u?"true":"false"});if(!u)return c;const m=l("div",{class:"rui-command-palette-backdrop"}),d=l("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),f=l("div",{class:"rui-command-palette-header"}),g=l("input",{type:"text",class:"rui-command-palette-input",placeholder:p(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(g);const h=p(e.shortcut);h&&f.append(l("span",{class:"rui-command-palette-shortcut"},[h])),d.append(f);const b=l("div",{class:"rui-command-palette-list",role:"listbox"}),v=(y,x)=>{y.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?a:a.filter(S=>S.label.toLowerCase().includes(w)||S.value.toLowerCase().includes(w)||(S.group??"").toLowerCase().includes(w));let A="";for(const S of k.slice(0,50)){S.group&&S.group!==A&&(A=S.group,y.append(l("div",{class:"rui-command-palette-group"},[A])));const $=l("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&$.append(l("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),$.onclick=M=>{M.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const I=M.currentTarget.closest(".rui-command-palette"),E=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Ae(E??null)},y.append($)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(b,s.get()),d.append(b),m.onclick=y=>{const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ae(w??null)},c.append(m,d),g.oninput=y=>{const x=y.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&v(w,x.value)},g.onkeydown=y=>{if(y.key==="Escape"){const x=y.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ae(w??null)}},setTimeout(()=>g.focus(),0),Xe({liveRoot:d,onDismiss:()=>{o.set(!1),c.setAttribute("data-open","false")}}),c}},Kp={name:"FilterChips",description:"Removable filter chips with an optional clear-all control.",props:[{name:"chips",type:"any[]",description:"Array of strings or {label, value} objects"},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed chip value as an argument"},{name:"onClear",type:"callable",optional:!0}],render:(t,e,r)=>{const a=Up(e.chips),n=l("div",{class:"rui-filter-chips"}),i=l("div",{class:"rui-filter-chips-row"});for(const o of a){const s=l("span",{class:"rui-filter-chip","data-value":o.value});s.append(l("span",{class:"rui-filter-chip-label"},[o.label]));const u=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),c=z("xmark",{className:"rui-filter-chip-remove-icon"});c&&u.append(c),u.onclick=()=>r.invoke(e.onRemove,o.value),s.append(u),i.append(s)}if(n.append(i),a.length>0&&typeof e.onClear=="function"){const o=l("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),n.append(o)}return n}},Yp={name:"FieldRepeater",description:"Dynamic list of field groups. Pass `items` as row objects and `fields` as `{name, label, type?}` definitions.",props:[{name:"items",type:"any[]"},{name:"fields",type:"any[]"},{name:"onAdd",type:"callable",optional:!0},{name:"onRemove",type:"callable",optional:!0,description:"Receives the removed row's 0-indexed position"},{name:"addLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=_t(e.items),n=oi(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const u=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),c=l("div",{class:"rui-field-repeater-grid"});for(const m of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[m.label]));const f=l("input",{class:"rui-input",type:m.type==="number"?"number":"text",name:`${m.name}-${s}`,value:p(o[m.name]),readonly:""});d.append(f),c.append(d)}if(u.append(c),typeof e.onRemove=="function"){const m=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);m.onclick=()=>r.invoke(e.onRemove,s),u.append(m)}i.append(u)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[p(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},Xp={name:"VirtualList",description:"Windowed vertical list for large datasets. Pass pre-rendered nodes as `items` or plain row objects plus a `renderItem` component node per row.",props:[{name:"items",type:"any[]"},{name:"itemHeight",type:"number",optional:!0,description:"Fixed row height in px (default 40)"},{name:"renderItem",type:"Node",optional:!0,description:"Template node rendered per data row"}],render:(t,e,r)=>{const a=Math.max(24,L(e.itemHeight,40)),n=C(e.items),i=l("div",{class:"rui-virtual-list"}),o=l("div",{class:"rui-virtual-list-scroller"}),s=l("div",{class:"rui-virtual-list-spacer"}),u=l("div",{class:"rui-virtual-list-window"}),c=n.length;s.style.height=`${c*a}px`,s.style.position="relative",u.style.position="absolute",u.style.top="0",u.style.left="0",u.style.right="0",o.style.maxHeight=`${Math.min(Math.max(c,1),12)*a}px`,o.style.overflow="auto";const m=d=>{u.replaceChildren();const f=o.clientHeight||a*12,g=Math.ceil(f/a)+2,h=Math.max(0,d),b=Math.min(c,h+g);u.style.transform=`translateY(${h*a}px)`;for(let v=h;v<b;v++){const y=n[v];if(e.renderItem)u.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)u.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[p(y)])),u.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);m(d)},m(0),o.append(s,u),i.append(o),i}},Jp={name:"QueryBuilder",description:"Visual filter builder. Pass `fields` as `{name, label, type?}` and bind `value` to a rule array.",props:[{name:"fields",type:"any[]"},{name:"value",type:"any[]",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"Receives the next rule array"}],render:(t,e,r)=>{const a=oi(e.fields),n=_t(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=u=>{o.replaceChildren(),u.forEach((m,d)=>{const f=l("div",{class:"rui-query-builder-row","data-index":String(d)}),g=l("select",{class:"rui-select rui-query-builder-field"});for(const y of a)g.append(l("option",{value:y.name},[y.label]));g.value=p(m.field??a[0]?.name);const h=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])h.append(l("option",{value:y},[y]));h.value=p(m.op,"equals");const b=l("input",{class:"rui-input rui-query-builder-value",value:p(m.value)});f.append(g,h,b);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=u.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},f.append(v),o.append(f)});const c=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);c.onclick=()=>{const m=[...u,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,m):r.invoke(e.onChange,m),s(m)},o.append(c)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},Zp={name:"DiffViewer",description:"Side-by-side or unified diff of two text blobs.",props:[{name:"left",type:"string"},{name:"right",type:"string"},{name:"mode",type:"string",optional:!0,enum:["split","unified"],description:"Default split"}],render:(t,e)=>{const r=p(e.left),a=p(e.right),n=p(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const c=l("pre",{class:"rui-diff-viewer-unified"});for(const m of Wp(r,a))c.append(l("div",{class:`rui-diff-line rui-diff-line-${m.type}`},[(m.type==="add"?"+ ":m.type==="remove"?"- ":" ")+m.text]));return i.append(c),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),u=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,u),i.append(o),i}},Qp={name:"JsonTree",description:"Expandable JSON tree viewer for objects and arrays.",props:[{name:"data",type:"any"},{name:"expanded",type:"boolean",optional:!0,description:"Expand all nodes (default: first level only)"}],render:(t,e)=>{const r=l("div",{class:"rui-json-tree"});return r.append(ci(e.data,T(e.expanded))),r}},em={name:"Gantt",description:"Simple Gantt chart. Pass `tasks` as `{id, label, start, end, progress?}` ISO date strings.",props:[{name:"tasks",type:"any[]"},{name:"startDate",type:"string",optional:!0},{name:"endDate",type:"string",optional:!0}],render:(t,e)=>{const r=Vp(e.tasks),a=r.map(m=>Ue(m.start)),n=r.map(m=>Ue(m.end)),i=e.startDate?Ue(p(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?Ue(p(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),u=l("div",{class:"rui-gantt"}),c=l("div",{class:"rui-gantt-track"});for(const m of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[m.label]));const f=l("div",{class:"rui-gantt-bars"}),g=(Ue(m.start)-i)/s*100,h=Math.max((Ue(m.end)-Ue(m.start))/s*100,2),b=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${h}%`,title:`${m.start} → ${m.end}`});m.progress!=null&&b.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,m.progress))}%`})),f.append(b),d.append(f),c.append(d)}return u.append(c),u}},tm={name:"Truncate",description:"Clamp long text with an expand control.",props:[{name:"text",type:"string"},{name:"maxLines",type:"number",optional:!0,description:"Lines before clamping (default 3)"},{name:"expandLabel",type:"string",optional:!0}],render:(t,e,r)=>{const a=Math.max(1,Math.floor(L(e.maxLines,3))),n=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${a};-webkit-box-orient:vertical;overflow:hidden`,o=l("div",{class:"rui-truncate","data-expanded":n.get()?"true":"false"}),s=l("p",{class:"rui-truncate-text",style:n.get()?"":i},[p(e.text)]),u=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":p(e.expandLabel,"Show more")]);return u.onclick=c=>{const m=c.currentTarget,d=m.closest(".rui-truncate"),f=d?.querySelector(".rui-truncate-text");if(!d||!f)return;const g=!n.get();n.set(g),f.style.cssText=g?"":i,m.textContent=g?"Show less":p(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,u),o}},rm={name:"InlineEdit",description:"Click-to-edit inline field with save on Enter or blur.",props:[{name:"value",type:"string"},{name:"label",type:"string",optional:!0},{name:"onSave",type:"callable",optional:!0,description:"Receives the committed draft string"}],render:(t,e,r)=>{const a=r.useInstanceState("editing",!1),n=r.useInstanceState("draft",p(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=p(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const u=l("button",{type:"button",class:"rui-inline-edit-display"},[p(e.value)]),c=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),m=f=>{const g=f.closest(".rui-inline-edit"),h=g?.querySelector(".rui-inline-edit-input");return!g||!h?null:{root:g,input:h}},d=f=>{const g=m(f);a.set(!1),g?.root.setAttribute("data-editing","false");const h=n.get();i&&r.setState(i,h),r.invoke(e.onSave,h)};return u.onclick=f=>{const g=m(f.currentTarget);n.set(p(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},c.oninput=f=>n.set(f.currentTarget.value),c.onkeydown=f=>{const g=f;if(g.key==="Enter"&&d(f.currentTarget),g.key==="Escape"){const h=m(f.currentTarget);a.set(!1),h?.root.setAttribute("data-editing","false")}},c.onblur=f=>d(f.currentTarget),o.append(u,c),o}},am={name:"NotificationBell",description:"Bell icon with unread count badge and dropdown notification list.",props:[{name:"count",type:"number",optional:!0},{name:"items",type:"any[]",optional:!0,description:"{title, message?, time?} objects"},{name:"onOpen",type:"callable",optional:!0}],render:(t,e,r)=>{const a=Math.max(0,Math.floor(L(e.count,0))),n=_t(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),u=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),c=z("bell",{className:"rui-notification-bell-icon"});c&&u.append(c),a>0&&u.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(u);const m=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)m.append(l("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const d of n){const f=l("div",{class:"rui-notification-bell-item"});f.append(l("div",{class:"rui-notification-bell-item-title"},[p(d.title)]));const g=p(d.message);g&&f.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const h=p(d.time);h&&f.append(l("div",{class:"rui-notification-bell-item-time"},[h])),m.append(f)}return s.append(m),u.onclick=d=>{d.stopPropagation();const f=d.currentTarget,g=f.closest(".rui-notification-bell");if(!g)return;const h=!i.get();i.set(h),g.setAttribute("data-open",h?"true":"false"),f.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),Xe({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):Ae(g)},s}},he=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),nm=t=>!!(t&&typeof t=="object"),im={name:"Async",description:"Render `loading`, `error`, `empty`, or `data` slot based on an `$http({...})` resource's state.",props:[{name:"resource",type:"any",positional:!0,required:!0},{name:"loading",type:"Node",optional:!0},{name:"error",type:"Node",optional:!0},{name:"empty",type:"Node",optional:!0},{name:"data",type:"Node",optional:!0}],render:(t,e,r)=>{const a=e.resource,n={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!nm(a))return he(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return he(r,n.loading??null);if(i==="error"||a.error)return he(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?he(r,n.empty??n.data??null):he(r,n.data??null)}},om={name:"Show",description:"Conditional renderer. Sugar over `if expr { children } else { fallback }`.",props:[{name:"when",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>e.when?he(r,e.children??null):he(r,e.fallback??null)},sm={name:"Portal",description:"Render children outside the parent subtree (e.g. into document.body).",props:[{name:"target",type:"string",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=p(e.target);let n=null;if(a)try{n=document.querySelector(a)}catch{n=null}n||(n=document.body);const i=l("div",{class:"rui-portal"});for(const o of C(e.children))i.append(r.renderNode(o));return n&&(n.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)})),l("span",{class:"rui-portal-anchor","data-portal":a??"body"})}},lm={name:"Redirect",description:"Navigate to `path` and unmount the rest of the subtree.",props:[{name:"path",type:"string",positional:!0,required:!0}],render:(t,e,r)=>{const a=p(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},cm={name:"Lazy",description:"Defer rendering `children` until `loader` resolves.",props:[{name:"loader",type:"any",positional:!0,required:!0},{name:"fallback",type:"Node",optional:!0},{name:"children",type:"Node[]",optional:!0}],render:(t,e,r)=>{const a=e.loader;if(typeof a=="function")try{const n=a();return n&&typeof n.then=="function"?he(r,e.fallback??null):he(r,n??e.children??null)}catch{return he(r,e.fallback??null)}return he(r,e.children??null)}},um={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws.",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const a=l("div",{class:"rui-error-boundary"});try{for(const n of C(e.children))a.append(r.renderNode(n));return a}catch(n){try{r.invoke(e.onError,n)}catch{}const i=he(r,e.fallback??null),o=l("div",{class:"rui-error-boundary rui-error-boundary--fallback"});return o.append(i),o.setAttribute("data-error",n instanceof Error?n.message:String(n)),o}}},dm=new Set(["div","span","p","section","article","header","footer","main","nav","aside","figure","figcaption","details","summary","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","td","th","caption","colgroup","col","a","img","picture","source","video","audio","track","small","strong","em","b","i","u","s","mark","code","pre","kbd","samp","var","sub","sup","abbr","cite","blockquote","q","time","address","ins","del","ruby","rt","rp","bdi","bdo","br","hr","wbr","hgroup","label","fieldset","legend","progress","meter","output"]),pm=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,mm=new Set(["href","ping","action","formaction"]),fm=new Set(["src","poster"]);function gm(t){const e=p(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function hm(t){const e=p(t).trim().toLowerCase();return!e||!dm.has(e)?"div":e}function bm(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t)){const n=r.trim();if(!n||!pm.test(n))continue;const i=n.toLowerCase();if(!i.startsWith("on")&&!(a==null||a===!1)){if(i==="style"){const o=gm(a);o&&(e.style=o);continue}if(mm.has(i)){const o=Ye(a,"");o&&(e[n]=o);continue}if(fm.has(i)){const o=ne(a);o&&(e[n]=o);continue}e[n]=a===!0?"":p(a)}}return e}const vm={name:"HTMLTag",description:"Escape-hatch primitive that renders an allow-listed HTML tag with the given attributes and children. Use ONLY when the standard component catalogue cannot express the markup (custom semantic elements, inline SVG, third-party widget mounts). Tag names outside the allow-list collapse to `div`. Attribute names matching `on*` (event handlers) are dropped, `href`/`src` are sanitised, and `style` is filtered for `expression()` / `javascript:` / `@import`. Pass children as an array of components — strings render as text nodes.",props:[{name:"tag",type:"string",positional:!0,required:!0,description:'HTML tag name (e.g. "div", "section", "svg"). Falls back to `div` when outside the allow-list.'},{name:"attributes",type:"object",optional:!0,aliases:["attrs","props"],description:'Plain object of attribute name → value pairs (e.g. `{ class: "hero", "data-id": 1 }`). `on*` handlers are dropped.'},{name:"children",type:"Node[]",optional:!0,description:"Child components or text nodes to render inside the tag."}],render:(t,e,r)=>{const a=hm(e.tag),n=bm(e.attributes),i=l(a,n);for(const o of C(e.children))if(o!=null){if(typeof o=="string"){i.append(document.createTextNode(o));continue}if(typeof o=="number"||typeof o=="boolean"){i.append(document.createTextNode(String(o)));continue}i.append(r.renderNode(o))}return i}},ym=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,xm=64*1024;function wm(t){const e=p(t);return!e||e.length>xm||ym.test(e)?"":e}const ui=[bl,vl,xl,yl,gl,Nn,Ll,Rl,wl,kl,Sl,Cl,Al,Tl,Pl,Ml,jl,$l,El,Dl,ac,nc,Hl,Vl,Wl,zn,Gl,Kl,Yl,Xl,Ql,rc,oc,Ol,ic,Fc,Bc,Pc,Ic,Rc,Lc,Ec,Dc,zc,jc,Nc,Mc,Dn,Oc,_c,Uc,Hc,jn,Vc,Wc,Mu,Nu,Iu,Pu,Lu,Ru,zu,Eu,Fu,Ou,_u,Bu,qu,Gu,Ku,Ju,Zu,cd,qn,Qu,ed,ld,td,rd,nd,id,dd,pd,ud,od,fd,Yn,hd,yd,vd,Sd,Cd,$d,Td,Jc,Zc,$u,Tu,Qc,tu,eu,au,ru,nu,iu,Au,ou,su,Bn,Su,uu,cu,lu,du,pu,gu,fu,mu,hu,bu,yu,vu,xu,ku,wu,Md,Id,Ed,zd,Dd,Bd,Fd,_d,Ud,Hd,Wd,Gd,Kd,Xd,Zd,ep,rp,ap,ip,op,cp,dp,pp,fp,gp,hp,bp,vp,yp,xp,kp,Cp,Tp,Ap,Np,Mp,Pp,Ip,Lp,Rp,Ep,zp,Dp,jp,Bp,qp,Gp,Kp,Yp,Xp,Jp,Zp,Qp,em,tm,rm,am,im,om,sm,lm,cm,um,gc,bc,yc,xc,wc,Sc,zn,vm,{name:"Styles",description:"Escape-hatch primitive that injects a `<style>` block containing the given CSS rules. Use ONLY when a layout cannot be expressed via component props or the `$theme(...)` token map. The CSS is rendered verbatim into the document so authors can target their own `HTMLTag` markup or scope rules to a wrapper class. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped for safety.",props:[{name:"css",type:"string",positional:!0,required:!0,aliases:["content","rules"],description:'Raw CSS text (e.g. `".hero { color: red; }"`).'}],render:(t,e)=>{const r=wm(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],km=[{name:"Layout",components:["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Modal","Drawer","Steps","AspectRatio","ScrollArea","Sticky","ResizablePanels","MasonryGrid"],notes:["- THREE primitives cover almost everything: `Column` (stack top→bottom), `Row` (left→right), and `Grid` (equal columns / card walls). Reach for these first.","- `root` is normally a `Column([...])` (or `Container([...])` for a centered page). A `Column` is the page body; put each major chunk in a `Card(...)`.","- `Row([...])` keeps children at their natural width and vertically centered — ideal for toolbars, button rows, label+value pairs, nav bars. Use `justify` to distribute (`between`, `center`, `end`) and `gap` for spacing.","- `Grid([...], { columns: N })` = N equal columns. Omit `columns` for auto-fit (wraps as many ≥`minChildWidth` columns as fit — best for KPI/card grids). Prefer `Grid` over a wrapping `Row` whenever cells should share a width.",'- For a 12-column dashboard / sidebar layout use `GridItem` spans: `Grid([GridItem(side, { span: "1/4" }), GridItem(main, { span: "3/4" })])`. Fractions `"1/2"`…`"1/12"` (or numbers 1–12) resolve on a 12-track grid; any `GridItem` child turns the grid on automatically.','- `Center([...], { minHeight })` centers content on both axes — spinners, empty states, hero CTAs, modal bodies. Add `minHeight: "60vh"` to center vertically in a region.','- `Stack` is the responsive escape hatch: use it ONLY when the direction itself must change across breakpoints, e.g. `Stack([...], { direction: {base: "column", md: "row"} })`.',"- Make one child in a `Row` expand with `StackItem(child, { grow: 1 })` (e.g. a search input beside a fixed button), or push items apart with a bare `Spacer()` between them.","- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.","- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.",'- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered "OR"-style divider.',"- `gap`/`padding` spacing tokens are `xs|s|m|l|xl`; `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.","- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls."]},{name:"Content",components:["Text","Image","Badge","BadgeList","Callout","Quote","CodeBlock","Skeleton","Spinner","Markdown","Kbd","Icon"],notes:["- Prefer `Markdown(...)` for rich paragraph text with inline formatting — the parser supports headings, blockquotes, fenced code, numbered/bullet lists, links, images, and bare-URL auto-linking.","- Use `Callout(variant, title, description, icon?, compact?)` for highlighted notices; pass `compact: true` for a one-line inline note.","- Use `Quote(text, cite?)` for inline pull-quotes inside articles and marketing sections (use `Testimonial` when you also have author/role/rating).","- Use `CodeBlock(language, codeString, showLineNumbers?, highlightLines?)` for read-only code snippets. The header always renders a copy-to-clipboard button.",'- Use `Badge(label, variant?, icon?, size?)` for a single pill and `BadgeList(["a","b","c"], variant?, size?)` to render an array of strings as Badge pills.',"- Use `Skeleton(variant?, lines?, height?, shape?, width?)` for loading placeholders; `variant` accepts `paragraph` (default), `card`, `table-row`, `avatar`, `image`.","- Use `Spinner(size?, label?, tone?)` for tiny inline loading indicators inside buttons, toolbars, or table cells.",'- Use `Image(src, alt?, caption?, ratio?, fit?, fallback?)` — `ratio` (e.g. `"16:9"`) makes the image self-constrain so you do not need an outer `AspectRatio`.','- Use `Kbd(["Cmd", "K"])` when referring to keyboard shortcuts.','- Use `Icon(name, variant?, size?)` to render a standalone Font Awesome icon (`name` is the FA name without the `fa-` prefix, e.g. `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`).','- For page-level titles reach for `PageHeader(...)` (top of dashboards/detail pages) or `SectionHeader(...)` (inside a Card). For tiny inline titles use `Text(value, variant="large-heavy")`.']},{name:"Forms",components:["Form","FormControl","FormSection","FieldSet","ValidationSummary","Input","TextArea","PasswordInput","MaskedInput","MentionInput","TagInput","Select","SelectItem","Combobox","MultiSelect","Checkbox","CheckBoxGroup","CheckBoxItem","Radio","Switch","ToggleGroup","Button","Buttons","SearchBar","Slider","NumberInput","ColorPicker","DatePicker","DateRangePicker","TimePicker","DateTimePicker","FileUpload","PinInput","MultiStepForm"],notes:["- Each FormControl should be a separate reference for progressive streaming.","- Pass a `$variable` as the last argument to `Input`, `Select`, `Checkbox`, `Switch`, `MultiSelect`, or `CheckBoxGroup` for two-way binding.","- Prefer `Switch` over `Checkbox` for settings; use `ToggleGroup` for view-mode pickers and mutually-exclusive filters.","- Reach for `SearchBar(id, placeholder?, value?, shortcut?)` instead of a raw `Input` whenever the field's purpose is to filter content. It ships with the magnifier icon and keyboard hint baked in.","- `Slider(id, min?, max?, step?, value?, label?, showValue?)` is the canonical control for numeric ranges (volume, brightness, filters); pass a `$variable` as `value` for two-way binding.",'- `NumberInput(id, value?, min?, max?, step?, placeholder?)` is friendlier than `Input(type="number")` for quantity steppers and integer settings — it ships with +/- buttons that respect `min`/`max`.',"- `DatePicker(id, value?, label?, min?, max?, placeholder?)` wraps the native date picker; pass `value` as a `$variable` for two-way binding (ISO `YYYY-MM-DD`).","- `DateRangePicker(id, from?, to?, label?, min?, max?)` is the paired-date variant — bind both `from` and `to` to `$variable`s for a single shared range.","- `Combobox(id, items, value?, placeholder?, emptyLabel?)` is the searchable single-select alternative to `Select` — type to filter long option lists (countries, currencies, users).","- `MultiSelect(id, items, value?, placeholder?, emptyLabel?, max?)` is the multi-select equivalent — bind a `$variable` array as `value` for two-way binding, the trigger renders the picks as removable chips.","- `FileUpload(id, { label?, hint?, accept?, multiple?, action? })` is the styled file picker; the picked files cannot pass through a `$variable`, so wire the `action` prop to a `function` declaration.",'- A submit button should call an `action` that awaits the relevant `$mutation` resource, optionally refetches a `$query`, and resets the form `$variable`s (e.g. `$title = ""`).',"- Button `size` accepts both `sm|md|lg` (canonical) and the legacy `small|normal|large`. Pass `icon` for an inline leading icon.","- `FormSection(label, children, helper?)` is the canonical wrapper for related fields. Reach for it INSTEAD of nesting fields in Card + SectionHeader by hand.","- `FieldSet(legend, children, helper?)` is the accessible `<fieldset>` for radio/checkbox groups; prefer `FormSection` for purely visual grouping.","- `ValidationSummary(errors, title?)` renders an aggregate error panel at the top of the form. Pass `errors` as `{label, message}` objects.",'- `PasswordInput(id, value?, placeholder?, strengthMeter?)` adds a show/hide toggle and an optional 4-step strength meter — prefer over `Input(type="password")` for sign-up flows.',"- `PinInput(id, length?, value?, type?)` renders per-digit code entry for 2FA / SMS verification (use `length=6` for OTP codes).","- `TagInput(id, value?, placeholder?)` lets the user add comma- or Enter-separated chips bound to a `$variable` array.","- `MentionInput(id, people, value?)` is a textarea with inline @-mention suggestions — use for comments, task notes, chat composers.","- `MaskedInput(id, mask, value?)` formats input against a mask string (`9` digit, `A` letter, `*` any). Use for phone numbers, postal codes.","- `TimePicker(id, value?)` and `DateTimePicker(id, value?)` wrap the corresponding native inputs with consistent styling.","- `ColorPicker(id, value?, label?, swatches?)` pairs a color chip with a hex input and preset swatches — bind a $variable holding a hex string.","- `MultiStepForm(steps, current, onSubmit?)` replaces ad-hoc `Steps` + content + manual prev/next wiring. Each step is `{title, details?, content}`."]},{name:"Data",components:["Table","Col","DataGrid","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","Pagination","Tree","TreeNode","CalendarView","ComparisonTable","InfiniteList"],notes:['- Build columns using array pluck: `Col("Title", data.rows.title, format?, align?)`.',"- For per-row controls inside a Col, use `for (let row of data.rows) { ... }` and reference `row.field` inline.",'- `Table(cols, caption?, density?, striped?, sticky?, emptyLabel?)` — pass `density="compact"` for dense data, `sticky=true` to pin the header in a scrolling parent, and `emptyLabel` for the zero-state cell.',"- `DataGrid(cols, rowIds?, caption?, sort, selectedIds, selectable?, page, perPage?, …)` is the advanced Table — adds sortable headers (`sortable=true` on Col), per-column filter chips (`filterable=true`), checkbox row selection bound to `$selectedIds`, sticky header / first column, pagination, and an optional bulk-action toolbar. Reach for this whenever a user needs to sort, filter, or page through a list.","- `CalendarView(value?, month?, events?, view?, firstDay?, onSelect?)` renders a full-month (or week) calendar grid for scheduling apps — distinct from the `DatePicker` input. Bind `value` to a `$variable` for the selected ISO date.","- `ComparisonTable(columns, rows, highlightColumn?)` is the generic counterpart of `PricingTable` — pass rows of `{label, values, hint?, group?}`. Use for feature comparisons, spec sheets, plan grids.","- `InfiniteList(items, onLoadMore?, loading?, hasMore?)` is a scroll-to-load list; the action fires when the sentinel scrolls into view.","- Use `Progress(value, max?, label?, tone?, indeterminate?, segments?, buffered?)` for linear bars — `segments` renders an N-step strip (onboarding flows), `buffered` adds a secondary buffer indicator.","- `ProgressRing(value, max?, label?, tone?, size?)` is the circular variant for quotas/completion.",'- `Stats([{label, value, hint?, tone?, spark?}, …], layout?)` — `layout="strip"` (default) for inline KPIs; `layout="grid"` for a responsive StatCard grid. Pass `spark` for an inline trend line.',"- `StatCard(label, value, trend?, delta?, icon?, spark?, tone?)` gains an optional inline `Sparkline` via the `spark` prop. Use `Sparkline(values, tone?)` standalone for tiny trend chips in table cells.","- `Tile(label, icon?, value?, description?, tone?, action?)` is the dense icon tile for quick-action menus and category grids; pair with `Grid` for uniform rows.","- `Tree([TreeNode(label, children?, icon?, expanded?, active?, badge?, action?)])` renders a hierarchical tree (file browsers, nested navigation, category pickers); use `expanded=true` to open a branch by default.",'- `Pagination(page, totalPages, siblings?, total?, perPage?, perPageOptions?, compact?)` — bind `page` (and optionally `perPage`) to a `$variable`; pass `total` to render the "Showing N–M of T" summary. Reuse the same variable when slicing data with `arr.filter(...)` / `for`.']},{name:"Charts",components:["BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series"],notes:["- Use `LineChart` for trends (pass `filled=true` for area-style charts), `BarChart` for comparisons, `PieChart` for proportions, `RadarChart` for multi-axis scorecards.","- `Heatmap(xLabels, yLabels, values)` renders a color-intensity matrix — perfect for calendar heatmaps, correlation grids, schedule density.","- `ScatterChart(series, xLabel?, yLabel?)` plots XY points; pass each Series as `Series(name, points)` where points are `{x, y, label?}`.","- `Histogram(values, binCount?)` bins raw numbers; pass pre-computed `bins=[{label, count}]` instead when you control the bucketing.","- `Gauge(value, min?, max?, label?, tone?, size?)` is the half-doughnut KPI indicator for thresholds (uptime %, score, NPS).",'- Pass series via `Series("Name", [...numbers])`.']},{name:"Feedback & Media",components:["Avatar","AvatarGroup","PersonChip","Tooltip","HoverCard","Popover","Rating","Toast","VideoPlayer","AudioPlayer","Carousel","Gallery","Lightbox","Map"],notes:["- `Avatar(name, src?, size?, status?)` falls back to initials when the image is missing.","- Use `AvatarGroup` to render contributor strips with a `+N` overflow chip.","- `PersonChip(name, role?, avatarSrc?, size?, status?, action?)` is the inline avatar + name + role pill — use everywhere a person is referenced (table cells, list rows, sidebar footers, kanban cards) instead of a raw `Avatar` next to `Text`.","- Wrap any node in `Tooltip(label, trigger)` for inline hints.","- Use `HoverCard(trigger, content)` when the popover needs rich content (profile preview, link target) and the trigger should open on hover.","- `Popover(trigger, content, title?, side?, align?, width?)` is the click-triggered counterpart of `HoverCard` — use for filter panels, color pickers, share menus, and small settings flyouts. Always renders an × close button in the header; clicking the trigger again, clicking outside, or pressing Escape also closes it.",'- `Rating(value, max?, label?, count?, size?, interactive?, halfStep?, icon?)` renders stars for product reviews, testimonials, and ranked lists. Pass a `$variable` as `value` with `interactive=true` to let users rate; add `halfStep=true` so clicking the left half of a star sets a half-value. Set `icon="heart"|"thumb"|"fire"|"bolt"` (or any FA name) to swap glyphs.',"- `Toast(title, message?, tone?, icon?, duration?, action?, onClose?, position?)` pins a transient notice; pass `duration` (ms) for auto-dismiss. Drive lists from an `action` body: `$toasts = [...$toasts, item]` to append and `$toasts = $toasts.filter((t) => t.id !== id)` to dismiss. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `NotificationBell(count?, items?, onOpen?)` — compact inbox trigger; `CommandPalette` for Cmd-K action search."]},{name:"Navigation",components:["Breadcrumb","BreadcrumbItem","Navbar","NavbarItem","DropdownMenu","MenuItem","MenuSeparator","MenuLabel"],notes:['- Use `Breadcrumb(["Workspace", "Reports", "Q3"])` at the top of every detail page so users see the path.',"- For per-item links, pass `BreadcrumbItem(label, href)` nodes instead of strings.","- `Navbar(brand?, items?, actions?, sticky?, variant?)` + `NavbarItem(label, to?, href?, icon?, active?, action?, external?)` produces a top navigation bar with brand on the left, links in the middle, and actions on the right — the canonical companion of `Sidebar` for marketing pages, docs, or any product surface without left-side nav.",'- `DropdownMenu(trigger, items, side?, align?, label?)` is the click-triggered dropdown menu — use it for user-profile menus, row "…" action menus, and any compact list of actions hanging off a single trigger. Children must be `MenuItem`, `MenuSeparator`, or `MenuLabel` entries.','- `MenuItem(label, action?, icon?, shortcut?, variant?, disabled?)` renders a single row inside a `DropdownMenu`; use `variant="danger"` for destructive actions and `MenuSeparator()`/`MenuLabel(label)` to group related items.']},{name:"Chat",components:["SectionBlock","ListBlock","FollowUpBlock","FollowUpItem","ActionLink","ChatBubble"],notes:["- End most responses with a `FollowUpBlock` of 2–4 short prompts to keep the conversation moving.",'- `ChatBubble(author, body, time?, avatarSrc?, from?)` renders a single message bubble; use `from="me"` for the active speaker and `from="agent"` for the assistant. Compose transcripts as `Stack([ChatBubble(...), ChatBubble(...), …])` inside a `Card`.']},{name:"Patterns",components:["Hero","PageHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","Banner","Notification","InboxPanel","OnboardingChecklist","MediaCard","TopBar","KanbanBoard","KanbanColumn","KanbanCard","SectionHeader","Toolbar","DescriptionList","DescriptionItem","StatusDot","PricingTable","PricingCard","LoadingState","ErrorState","SuccessState","Tour","Spotlight"],notes:["- Patterns are **opinionated composites** that pack an entire UI idiom into one component. Reach for them BEFORE composing equivalent layouts by hand with Card+Stack — the result will look more polished and require fewer tokens.",'- `Hero(title, subtitle, primary, secondary, eyebrow?, highlights?, tone?)` — landing-style text-first header. Use `layout="cover"` with `imageSrc`, `height`, and optional `caption` for image-backed hero bands.','- `PageHeader(title, subtitle?, breadcrumbs?, actions?, status?)` — the canonical first child for any dashboard or detail page. If you omit `breadcrumbs`, the component auto-derives `["Home", title]`.',"- `TopBar(title?, search?, actions?, sticky?)` — compact top strip for a content surface (panels, dialogs, embedded views). Use `AppShell` when you need a full sidebar; use `TopBar` for narrower headers above scrolling content.","- `SectionHeader(title, subtitle?, eyebrow?, status?, actions?)` — sub-header inside a Card or panel. Use instead of bare `CardHeader` when the section also needs eyebrow / actions / status.",'- `Stats(items, layout?)` — KPI strip (`layout="strip"`, default) or responsive grid (`layout="grid"` with StatCard children). Prefer over hand-rolled StatCard rows.',"- `Toolbar(left?, right?, center?, searchable?, searchPlaceholder?, searchValue?)` — filter/search/actions row above a list, table, or board. Pass `searchable: true` to auto-mount a `SearchBar` (use `searchValue` to bind it to a `$variable`).","- `EmptyState(title, description?, icon?, illustration?, actions?, action?)` — render this when a list is empty rather than an empty Card. The icon is auto-picked from the title keywords if you omit it (inbox/messages → `inbox`, charts/analytics → `chart-pie`, files/folders → `folder-open`, etc.).","- `Timeline([TimelineItem(...)])` — vertical event feed (audit log, changelog, activity).",'- `ActivityLog(entries, variant?)` — purpose-built feed of user actions. Pass `entries` of `{actor, title, description?, time?, icon?, tone?, meta?}`; use `variant="audit"` for security/admin trails with monospace meta.',"- `FeatureGrid([FeatureItem(...)])` — feature highlights with iconography.","- `MediaCard(title, imageSrc?, description?, tags?, meta?, actions?, badge?, orientation?, ratio?)` — image + content card. Use for article previews, product cards, project highlights. Pair with `Grid` for uniform card rows.",'- `KanbanBoard([KanbanColumn("To do", [KanbanCard(...), ...])])` — task boards.','- `DescriptionList([DescriptionItem("Status", Badge(...)), …])` — detail-page key/value summary. Always preferable to a Stack of Text rows on profile, billing, or metadata panels.',"- `StatusDot(label, tone?, pulse?)` — inline status pip. Use in toolbars, list rows, table cells, sidebars.","- `Notification(title, message?, time?, icon?, avatarSrc?, tone?, unread?, actions?)` — inline notification card for notification panels / inboxes (prefer `Banner` for top-of-page announcements).","- `InboxPanel(items, title?, onMarkAllRead?)` — `Notification` cards grouped into Unread / Earlier sections, with a shared mark-all-read action.","- `OnboardingChecklist(items, title?, description?)` — checklist of `{title, description?, done?, action?}` items with progress. Use for product onboarding, setup wizards, getting-started panels.","- `PricingTable([PricingCard(plan, price, period?, description?, features?, action?, badge?, featured?)])` — full pricing page block.","- `LoadingState(title?, description?, tone?, action?)`, `ErrorState(title, description?, action?, secondaryAction?, retryLabel?)`, `SuccessState(title, description?, action?, secondaryAction?)` — full-card empty-state alternatives for asynchronous content states.","- `Tour(steps, current, onFinish?)` and `Spotlight(title?, description?, action?)` are the product-tour primitives. `Spotlight` is a single highlighted call-out; `Tour` walks the user through multiple `{title, description, image?}` steps with Prev/Next/Skip controls and a progress dots indicator."]},{name:"Editors & overlays",components:["RichTextEditor","CodeEditor","ContextMenu"],notes:["- `RichTextEditor(id, value?, placeholder?, minHeight?)` is the contenteditable WYSIWYG editor — toolbar ships with bold/italic/underline/strike/heading/lists/link. Bind `value` to a `$variable` holding HTML.","- `CodeEditor(id, value?, language?, placeholder?, minHeight?)` is a lightweight `<textarea>` with a synced line-number gutter and tab indentation. Use for snippet editors, prompt sandboxes, settings JSON.","- `ContextMenu(target, items)` attaches a right-click menu to any node. `items` are `MenuItem` or `{label, action?, icon?, shortcut?, variant?, disabled?}` objects; pass a `MenuSeparator()` to split groups."]},{name:"App shell",components:["AppShell","Sidebar","SidebarSection","SidebarItem","SplitView"],notes:["- App shell components produce a **full SaaS-style layout in a single statement**. Use them whenever the response represents a complete product surface (dashboards with nav, settings sections, admin consoles, inboxes).","- `AppShell(sidebar, content, topbar?, collapsible?, sidebarOpen?)` — fixed-left navigation + scrollable main area. Pass `collapsible=true` to enable a hamburger that turns the sidebar into a slide-over drawer on mobile; bind `sidebarOpen` to a `$variable` if you want to drive that drawer programmatically.","- `Sidebar(items, brand?, tagline?, footer?, collapsed?)` + `SidebarItem(label, icon?, active?, badge?, action?)` + `SidebarSection(label, items)` — group nav links into sections, mark the current page with `active=true`, attach badges for counts. Pass `collapsed=true` (or bind to a `$variable`) to collapse it to an icon rail.","- `SplitView(primary, detail, primaryWidth?)` — master/detail layout (inboxes, file browsers, contact lists). Both panes are scrollable."]},{name:"Theming",components:["Theme"],notes:["- `$theme({...})` applies a partial token override **on top of** the base theme set by the host (attribute / `setTheme()`). Use it to brand a single response without changing host configuration.","- Assign to `aktion.theme` so the runtime picks it up:",' `theme = $theme({ colors: { primary: "#0969da" }, radius: { button: "6px" } })`',"- Tokens MUST use the structured form. Top-level groups: `colors`, `radius`, `font`, `motion`, `elevation` (plus metadata: `name`, `direction`).","- Common tokens (each lives inside its group): `colors.primary`, `colors.primaryHover`, `colors.primaryText`, `colors.accent`, `colors.bg`, `colors.surface`, `colors.text`, `colors.textMuted`, `colors.border`, `colors.focusRing`; `radius.md`, `radius.button`, `radius.input`; `font.family`, `font.familyHeading`, `font.sizeBase`, `font.weightHeading`; `motion.transitionDuration`; `elevation.md`.","- The legacy flat-shape form (`$theme({colorPrimary: ...})`) and free-form `--css-vars` are removed in Aktion 0.5 — the runtime drops them and the schema validator surfaces a migration warning.",'- Tokens are CSS values (`"#0969da"`, `"\'Inter\', sans-serif"`, `"6px"`, `"600"`). The runtime ignores unknown keys inside a group, so typos fail silent.',"- Removing the `theme = $theme(...)` line snaps the UI back to the base theme without a reload."]},{name:"Advanced UI",components:["IconButton","CommandPalette","FilterChips","FieldRepeater","VirtualList","QueryBuilder","DiffViewer","JsonTree","Gantt","Truncate","InlineEdit","NotificationBell"],notes:["- `IconButton(icon, label, action?, variant?, size?, disabled?)` — accessible icon-only control.","- `CommandPalette(items, open?, placeholder?, shortcut?)` — Cmd-K searchable actions.","- `FilterChips(chips, onRemove?, onClear?)` — applied filter pills with remove.","- `FieldRepeater(items, fields, onAdd?, onRemove?)` — dynamic form rows.","- `VirtualList(items, itemHeight?, renderItem)` — windowed long lists.","- `QueryBuilder(fields, value?)` — visual AND/OR filter builder.","- `DiffViewer(left, right, mode?)` — side-by-side or unified diff.","- `JsonTree(data)` — collapsible JSON inspector.","- `Gantt(tasks, startDate?, endDate?)` — horizontal schedule timeline.","- `Truncate(text, maxLines?)` / `InlineEdit(value, onSave?)` / `NotificationBell(count?, items?)`."]},{name:"Routing",components:["NavLink"],notes:['- Declare routes with the `$router({...})` call form: `pages = $router({ "/": Dashboard(), "/orders/:id": OrderDetail({ id: params.id }), default: NotFound() })`. The matched arm\'s `params` object is in scope on the right-hand side; nest `$router` inside components for layout-preserving sub-routes.',"- `Redirect(path)` is a router-aware component: returning it from a route's body navigates and unmounts the rest of the subtree.","- `NavLink(label, { to })` is a thin link wrapper that reads `route.path` and dispatches `route.navigate(to)` — use it for sidebars, navbars and breadcrumbs.","- Read URL params via `route.params.<name>` (e.g. `route.params.id` for `/users/:id`) and the current path via `route.path`."]},{name:"Helpers",components:["Async","Show","Portal","Redirect","Lazy","ErrorBoundary"],notes:["- `Async(resource, { loading:, error:, empty:, data: })` switches an `$http({...})` resource on its `state` field (`empty` shows for `null`/empty-array data).","- `Show(when, { fallback?, children })` is sugar over `if (expr) { children } else { fallback }`.","- `Portal(target?, children)` renders into a different DOM subtree (defaults to `document.body`).","- `Redirect(path)` is a router-aware component — see Routing.","- `Lazy(loader, fallback?)` defers children until `loader` resolves.","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","Css","Link"],notes:["- Wrappers compose: any built-in component can be made clickable, hoverable, observable, or restyled by wrapping it in one of these primitives — no need for the underlying component to grow another prop.","- `OnClick(child, { onClick, disabled?, stopPropagation? })` makes any component clickable / tappable (touch devices fire `click` too). Use for clickable cards, list rows, media tiles, and any custom layout that needs a tap target without a `<button>` baseline.","- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` attaches any combination of mouse / pointer / drag listeners. Pass `draggable: true` to make the wrapper itself draggable. Scroll / wheel listeners default to `{ passive: true }` for smooth scrolling.","- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })` attaches keyboard listeners. The wrapper is focusable by default; pass `focusable: false` when the child is already focusable (input, button).","- `OnFocus(child, { onFocus?, onBlur? })` tracks focus moving into or out of a subtree (uses bubbling `focusin` / `focusout` so descendants count).","- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` is the IntersectionObserver wrapper — perfect for lazy-load sentinels, infinite-scroll triggers, impression analytics, and reveal-on-scroll animations.","- `Css(child, { style?, class? })` merges raw class tokens and inline styles onto the wrapped child. Reach for it ONLY when the standard component props can't express the styling — prefer `Box`/`Stack`/`Grid` for layout and `$theme(...)` for tokens.","- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links."]},{name:"Escape hatches",components:["HTMLTag","Styles"],notes:["- **Use only as a last resort.** Reach for these primitives when the standard catalogue cannot express the markup or styling you need; for everything else (typography, layout, surfaces, controls) the dedicated components produce a more consistent UI for fewer tokens.",'- `HTMLTag(tag, attributes?, children?)` renders an allow-listed HTML tag with the given attribute object and child nodes (e.g. `HTMLTag("section", attributes: {class: "hero", "data-id": 1}, children: [Text("Hello")])`). Tag names outside the allow-list collapse to `div`; `on*` attributes, `javascript:` URLs in `href`/`src`, and `expression()` / `@import` in inline `style` are stripped.',"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped."]}];wa(ui);const dt={root:"Column",components:ui,componentGroups:km},Sm="$";function Cm(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r+=1)if(!Object.is(t[r],e[r]))return!1;return!0}function $m(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(t[n],e[n]))return!1;return!0}class di{constructor(e){j(this,"instanceStates",new Map);j(this,"instanceDisposers",new Map);j(this,"aliveInstances",new Set);j(this,"instancesWithEffects",new Set);j(this,"instancesWithHooks",new Set);j(this,"memoCache",new Map);j(this,"changedPaths",new Set);j(this,"memoEnabled",!1);this.options=e}setLibrary(e){this.options={...this.options,library:e}}reset(){for(const e of this.instanceDisposers.values())for(const r of e.values())this.safeDispose(r);if(this.instanceDisposers.clear(),this.instanceStates.clear(),this.memoCache.clear(),this.options.unmountInstanceEffects)for(const e of this.instancesWithEffects)try{this.options.unmountInstanceEffects(e)}catch(r){console.error(`[aktion] unmountInstanceEffects threw for ${e}`,r)}if(this.instancesWithEffects.clear(),this.options.unmountInstanceHooks)for(const e of this.instancesWithHooks)try{this.options.unmountInstanceHooks(e)}catch(r){console.error(`[aktion] unmountInstanceHooks threw for ${e}`,r)}this.instancesWithHooks.clear(),this.aliveInstances=new Set}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1}endRender(){const e=this.aliveInstances;for(const r of[...this.instanceStates.keys()]){const a=r.lastIndexOf("::"),n=a===-1?r:r.slice(0,a);e.has(n)||this.instanceStates.delete(r)}for(const[r,a]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const n of a.values())this.safeDispose(n);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(a){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,a)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(a){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,a)}this.instancesWithHooks.delete(r)}}for(const r of[...this.memoCache.keys()])e.has(r)||this.memoCache.delete(r)}safeDispose(e){try{e()}catch(r){console.error("[aktion] disposer threw",r)}}writeState(e,r){const a=e.indexOf(".");if(a<0){this.options.state.set(e,r);return}const n=e.slice(0,a),i=e.slice(a+1).split(".");this.options.state.setPath(n,i,r)}render(e){return this.renderAt(e,Sm)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const a=document.createDocumentFragment();return e.forEach((n,i)=>{a.append(this.renderAt(n,`${r}/${i}`))}),a}return Ya(e)?this.renderUserComponent(e,r):Ka(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const a=this.options.evaluationContext;if(!a){const u=document.createElement("div");return u.className="rui-unknown-component",u.textContent=`[unknown component: ${e.decl.name}]`,u}const n=a(),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.decl.name}${i}`;this.aliveInstances.add(o);const s=this.memoCache.get(o);if(this.memoEnabled&&s&&Cm(e.positional,s.positional)&&$m(e.named,s.named)&&!yt(this.changedPaths,s.deps)){const u=n.trackedState;for(const c of s.deps)u.add(c);sr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{lr(n)}}sr(n,e.decl.name);try{const u=n.trackedState,c=new Set;n.trackedState=c;let m;try{m=on(e,n,o)}finally{n.trackedState=u;for(const h of c)u.add(h)}const{value:d,effects:f,hooks:g}=m;return this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,f,a),f.length>0&&this.instancesWithEffects.add(o)),g>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:c,value:d}),this.renderAt(d,o)}finally{lr(n)}}renderComponent(e,r){const a=Ne(this.options.library,e.name);if(!a){const c=document.createElement("div");return c.className="rui-unknown-component",c.textContent=`[unknown component: ${e.name}]`,c}const n=ka(a,e.args),i=e.explicitKey!=null?`=${String(e.explicitKey)}`:`@${e.source?.line??0}:${e.source?.column??0}`,o=`${r}#${e.name}${i}`;this.aliveInstances.add(o);let s=0;const u={renderNode:c=>this.renderAt(c,`${o}>${s++}`),invoke:(c,...m)=>{if(typeof c=="function")try{const d=c(...m);d&&typeof d.then=="function"&&d.catch(f=>{console.error("[aktion] handler rejected",f)})}catch(d){console.error("[aktion] handler threw",d)}},setState:(c,m)=>{this.writeState(c,m)},resetState:(...c)=>{this.options.state.reset(...c)},sendToAssistant:c=>{this.options.onAssistantMessage?.(c)},openUrl:c=>{const m=Ye(c,"#"),d=this.options.onOpenUrl;d?d(m):m!=="#"&&typeof window<"u"&&window.open(m,"_blank","noopener,noreferrer")},bindState:(c,m,d)=>{const g=`on${d?.event??this.eventFor(c)}`,h=d?.getValue??this.defaultValueGetter(c);c[g]=b=>{const v=b.currentTarget??b.target??c;this.writeState(m,h(v))}},useInstanceState:(c,m)=>{const d=`${o}::${c}`;return this.instanceStates.has(d)||this.instanceStates.set(d,m),{get:()=>this.instanceStates.get(d),set:f=>{this.instanceStates.set(d,f)}}},registerDisposer:(c,m)=>{let d=this.instanceDisposers.get(o);d||(d=new Map,this.instanceDisposers.set(o,d));const f=m??`__anon::${d.size}`,g=d.get(f);g&&g!==c&&this.safeDispose(g),d.set(f,c)},router:this.options.router};try{return a.render(e,n,u)}catch(c){console.error(`[aktion] failed to render ${a.name}`,c);const m=document.createElement("div");return m.className="rui-render-error",m.textContent=`[render error in ${a.name}]`,m}}eventFor(e){return e instanceof HTMLSelectElement||e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")?"change":"input"}defaultValueGetter(e){return e instanceof HTMLInputElement&&e.type==="checkbox"?r=>r.checked:e instanceof HTMLInputElement&&e.type==="radio"?r=>r.value:e instanceof HTMLInputElement&&e.type==="number"?r=>{const a=r.value;if(a==="")return null;const n=Number(a);return Number.isFinite(n)?n:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}const Tm=["onclick","oninput","onchange","onsubmit","onfocus","onblur","onkeydown","onkeyup","onkeypress","onerror","onmouseenter","onmouseleave","onmousedown","onmouseup","onpointerdown","onpointerup"];function Am(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];fi(t,r)}function pi(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return mi(t,e);if(t.nodeType===Node.TEXT_NODE)return t.textContent!==e.textContent&&(t.textContent=e.textContent),t;if(t.nodeType!==Node.ELEMENT_NODE)return t;const r=t,a=e;return r.tagName!==a.tagName?mi(r,a):(Nm(r,a),r)}function mi(t,e){return t.parentNode?.replaceChild(e,t),e}function Nm(t,e){Mm(t,e),Pm(t,e),fi(t,Array.from(e.childNodes)),Im(t,e)}function Mm(t,e){const r=t.attributes;for(let n=r.length-1;n>=0;n-=1){const i=r[n];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.removeAttribute(i.name)}const a=e.attributes;for(let n=0;n<a.length;n+=1){const i=a[n];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function Pm(t,e){for(const r of Tm){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function Im(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Lm(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Rm(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!Ut(t)&&t.value!==e.value&&(t.value=e.value);return}}function Lm(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!Ut(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!Ut(t)&&t.value!==r&&(t.value=r)}function Rm(t,e){const r=e.value??e.textContent??"";!Ut(t)&&t.value!==r&&(t.value=r)}function Ut(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function fi(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=Dr(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=Dr(n);if(o&&r.has(o)){const u=r.get(o);r.delete(o),u!==i&&t.insertBefore(u,i),pi(u,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=Dr(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}pi(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function Dr(t){if(t.nodeType!==Node.ELEMENT_NODE)return null;const e=t;if(e.id)return`#${e.id}`;const r=e.getAttribute("data-rui-key");return r?`@${r}`:null}const V="aktion";function jr(t,e={}){return e.mode==="chat"?Dm(t,e):zm(t,e)}function Em(t){return Ht(t)}function zm(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(jm(e.preamble)),n.push(Bm()),n.push(Fm()),r&&n.push(Om()),n.push(_m()),n.push(Um()),a&&n.push(Hm()),n.push(Vm()),n.push(Wm()),n.push(qm()),n.push(Gm()),n.push(Km()),n.push(Ym()),n.push(Xm()),n.push(Jm(t)),e.inlineMode&&n.push(Zm()),e.editMode&&n.push(Qm()),e.tools&&e.tools.length>0&&n.push(mf(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(Br("Endpoint examples",e.toolExamples));const i=e.examples??tf();return i.length>0&&n.push(Br("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(gi(e.additionalRules)),n.push(ef()),n.join(`
|
|
43
43
|
|
|
44
44
|
`).trim()+`
|
|
45
|
-
`}function
|
|
45
|
+
`}function Dm(t,e){const r=[];r.push(af(e.preamble)),r.push(nf()),r.push(of(t)),r.push(sf()),e.tools&&e.tools.length>0&&r.push(cf(e.tools));const a=e.examples??uf();return a.length>0&&r.push(Br("Examples",a)),e.additionalRules&&e.additionalRules.length>0&&r.push(gi(e.additionalRules)),r.push(lf()),r.push(df()),r.push(pf()),r.join(`
|
|
46
46
|
|
|
47
47
|
`).trim()+`
|
|
48
|
-
`}function
|
|
48
|
+
`}function jm(t){return`${t?.trim()||"You are a UI engineer authoring complete, working applications in Aktion — a declarative language whose surface syntax is a strict subset of JavaScript. Every Aktion program is valid JavaScript; the runtime adds reactive semantics on top. Respond ONLY in Aktion: no prose, JSON, markdown, or HTML."}
|
|
49
49
|
|
|
50
|
-
Every response MUST start with \`${V} = ...\` on the first line. Forward references are allowed — declare the shell first (\`${V} = AppShell(...)\` for apps, \`${V} = Column(...)\` or \`${V} = Container(...)\` for pages, \`${V} = MyApp()\` when you wrap a user component) and let children stream in below it.`}function
|
|
50
|
+
Every response MUST start with \`${V} = ...\` on the first line. Forward references are allowed — declare the shell first (\`${V} = AppShell(...)\` for apps, \`${V} = Column(...)\` or \`${V} = Container(...)\` for pages, \`${V} = MyApp()\` when you wrap a user component) and let children stream in below it.`}function Bm(){return`## Core syntax
|
|
51
51
|
|
|
52
52
|
A program is a flat list of \`name = expression\` statements, one per line. Newlines terminate statements; semicolons are optional.
|
|
53
53
|
|
|
@@ -82,7 +82,7 @@ StatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })
|
|
|
82
82
|
Row([Card1(), Card2()], { gap: "m" })
|
|
83
83
|
\`\`\`
|
|
84
84
|
|
|
85
|
-
\`Button("Save", "primary", true)\` is a schema error — write the named-prop form instead. Every call site also accepts \`{ key: ... }\` to pin per-instance state across reorders.`}function
|
|
85
|
+
\`Button("Save", "primary", true)\` is a schema error — write the named-prop form instead. Every call site also accepts \`{ key: ... }\` to pin per-instance state across reorders.`}function Fm(){return'## JavaScript is fully supported\n\nAktion is a strict subset of JavaScript — every standard JS feature works inside expressions, action bodies, effect callbacks, and lambdas. Use whichever style is clearest for the value you need to compute.\n\n### In expressions (right-hand side of `=`)\nUse **value-producing** JS — no `if`/`switch`/`for` statements here.\n\n```\n// Ternary for branching\nbanner = $error ? Banner($error, { tone: "danger" }) : null\ntone = $value > 0 ? "success" : ($value < 0 ? "danger" : "muted")\n\n// .map / .filter / .reduce for iteration\nrows = $todos.map(t => TodoRow(t))\nvisible = $todos.filter(t => !t.done).map(t => TodoRow(t))\ntotal = $cart.reduce((sum, item) => sum + item.price, 0)\n\n// Object/array spread, destructuring, optional chaining, nullish coalescing\nmerged = { ...$base, status: "done" }\n[a, b] = $points\nname = $user?.profile?.name ?? "Guest"\n\n// Template literals — preferred over string concatenation\ntitle = `Found ${rows.length} ${$util.plural(rows.length, "result", "results")}`\n\n// Wrap a switch/match in a function and call it\nfunction panelFor(tab) {\n switch (tab) {\n case "overview": return Overview()\n case "billing": return Billing()\n default: return Empty()\n }\n}\npanel = panelFor($tab)\n```\n\n### In action / effect / lambda bodies\nThe full **statement** surface is available — `if`, `else`, `switch`, `for...of`, `for...in`, classic `for`, `while`, `do…while`, `break`, `continue`, `try`/`catch`/`finally`, `throw`, `return`. Plus all assignment operators (`= += -= *= /= ??= ++ --`) against `$atoms` and member chains rooted at one (`$user.name = "Alex"`).\n\n```\nfunction submit(payload) {\n if (!payload.email) return\n for (let tag of payload.tags) $tags = [...$tags, tag]\n switch (payload.kind) {\n case "draft": $drafts = [...$drafts, payload]; break\n default: $records = [...$records, payload]\n }\n $emit("submitted", { id: payload.id })\n}\n```\n\n### Timers — `setTimeout` / `setInterval`\n`setTimeout(fn, ms)`, `setInterval(fn, ms)`, `clearTimeout(id)`, and `clearInterval(id)` are available and behave like their JS counterparts. They return a handle you can later clear. Timers are tracked by the runtime and torn down automatically when the program re-plans, so they never outlive the program — but you should still clear a `setInterval` you no longer need. Create them inside an `effect` (not at the top level, which would re-create them on every render) and clear them in the effect\'s `cleanup`.\n\n```\n// Debounced search — restart a 300ms timer on every keystroke\nfunction onType(q) {\n clearTimeout($searchTimer)\n $searchTimer = setTimeout(() => { $results = $http({ url: `/search?q=${q}` }) }, 300)\n}\n\n// A ticking clock — start on mount, clear on unmount\n$effect(() => {\n let id = setInterval(() => { $now = $util.now() }, 1000)\n cleanup(() => clearInterval(id))\n}, ["mount"])\n```\n\nPrefer `$effect(..., ["every(1000)"])` for a simple repeating effect; reach for `setInterval`/`setTimeout` when you need an imperative handle to clear, a one-shot delay, or a debounce/restart.\n\n### Lambdas (arrow functions) — every JS form works\n`() => expr`, `x => expr`, `(x, y) => expr`, `(x = 0) => x`, `(...args) => sum(args)`, and the multi-statement `(x) => { ...; return ... }` form. Long lambdas may continue onto the next line.\n\n### Line continuations (matches JS ASI)\nAny expression operator (`.`, `?.`, `?`, `:`, `&&`, `||`, `??`, comparison, arithmetic) at the **start** of the next line keeps building the same expression.\n\n```\nfilteredTodos = $todos\n .filter(t => t.category == $filter)\n .filter(t => t.title.includes($searchQuery))\n```\n\n### Comments\nOnly `// line` and `/* block */` comments. No `#` shebangs.\n\n### Forbidden in expression position\n`if`, `switch`, `for`, `while`, `try` are statements — they cannot be assigned to a binding directly. Use a ternary, `.map`/`.filter`, or wrap them in a function.'}function Om(){return`## Reactive State
|
|
86
86
|
|
|
87
87
|
The \`$\` sigil is the only thing that makes a binding reactive. \`let\`/\`const\`/\`var\` keywords are optional and have no effect on reactivity.
|
|
88
88
|
|
|
@@ -164,7 +164,7 @@ function CartBadge() { return Badge(\`\${cart.count()} items\`) }
|
|
|
164
164
|
function AddButton(item) { return Button("Add", { onClick: () => cart.add(item) }) } // calls a method
|
|
165
165
|
\`\`\`
|
|
166
166
|
|
|
167
|
-
Reads are fine-grained and per-component: changing \`cart.items\` re-renders only components that read \`items\`. Two-way binding works against a store field (\`Input(value: form.draft)\`). Use a \`Store\` for shared/global state; use a component's local \`$state\` / \`$name = …\` for state only one component owns.`}function
|
|
167
|
+
Reads are fine-grained and per-component: changing \`cart.items\` re-renders only components that read \`items\`. Two-way binding works against a store field (\`Input(value: form.draft)\`). Use a \`Store\` for shared/global state; use a component's local \`$state\` / \`$name = …\` for state only one component owns.`}function _m(){return`## Components & Actions
|
|
168
168
|
|
|
169
169
|
A \`function\` declaration creates BOTH a component (callable in render position; its return value is rendered) and an action (callable from an event handler; its body runs for side effects). The first-letter case of the name is NOT significant — \`function Card(...)\`, \`function card(...)\`, \`function SaveOrder(...)\`, and \`function saveOrder(...)\` are all valid. A function with no \`return\` simply renders nothing when invoked in a render position. The same applies to arrow-function bindings (\`Display = () => Card(...)\` and \`display = () => Card(...)\` both work).
|
|
170
170
|
|
|
@@ -213,7 +213,7 @@ resetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } })
|
|
|
213
213
|
\`return\` is optional. Inside the body, the full JS statement surface is available (see *JavaScript is fully supported*).
|
|
214
214
|
|
|
215
215
|
### \`$emit("name", { detail })\`
|
|
216
|
-
Inside any action / effect / lambda, \`$emit("name", { detail })\` dispatches an outbound \`CustomEvent\` on the host \`<aktion-app>\` element. Reserved names: \`assistant-message\` (chat follow-up), \`error\`, \`route-change\`. Pick stable names; the host listens with \`el.addEventListener("name", ...)\`.`}function
|
|
216
|
+
Inside any action / effect / lambda, \`$emit("name", { detail })\` dispatches an outbound \`CustomEvent\` on the host \`<aktion-app>\` element. Reserved names: \`assistant-message\` (chat follow-up), \`error\`, \`route-change\`. Pick stable names; the host listens with \`el.addEventListener("name", ...)\`.`}function Um(){return`## Effects — Declarative side effects
|
|
217
217
|
|
|
218
218
|
\`$effect(() => { ... }, [...deps])\` runs declarative side effects. Dependency entries:
|
|
219
219
|
|
|
@@ -246,7 +246,7 @@ $effect(() => {
|
|
|
246
246
|
document.addEventListener("keydown", onKey)
|
|
247
247
|
cleanup(() => document.removeEventListener("keydown", onKey))
|
|
248
248
|
}, ["mount"])
|
|
249
|
-
\`\`\``}function
|
|
249
|
+
\`\`\``}function Hm(){return'## Data — `$http({...})`\n\n`$http({ ... })` is the only HTTP primitive. Every call is self-contained — pass a full absolute `url`, an optional `method` (`GET` is the default), a convenience `query` object serialised into the URL, `headers`, `body`, and any other `fetch`-compatible option. There are NO host-wide defaults.\n\n```\n$orders = $http({\n url: `https://api.example.com/users/${$userId}/orders`,\n method: "GET",\n query: { limit: 5, status: "open" }, // → ?limit=5&status=open\n headers:{ "X-Tenant": $tenant }\n})\n```\n\nThe request fires once when the binding mounts. To re-run it call `$orders.refetch()`, or wrap it in an `$effect(..., [$dep])` so it re-issues when a dependency changes.\n\n### Reactive resource shape\n```\n$orders.data // parsed body (null until resolved)\n$orders.error // null on success\n$orders.status // HTTP status code, e.g. 200\n$orders.loading // true while in-flight\n$orders.headers // response headers as a plain object\n$orders.lastUpdated // ms-epoch of last successful response\n$orders.refetch() // re-issue the request\n$orders.cancel() // abort the in-flight request\n$orders.onDone = fn // callback fired each time the request settles\n```\n\n### `onDone` — run something when the request settles\nAssign `onDone` after creating the resource. It fires once every time the request completes — the initial load and every `refetch()`, on both success and error — and receives the resource bag as its argument. It does NOT fire for a request that was superseded or `cancel()`led. This is the idiomatic way to refresh a list after a mutation:\n\n```\n$patch = $http({\n url: endpoint + "/" + todo.id,\n method: "PATCH",\n body: { isCompleted: !todo.isCompleted }\n})\n\n$patch.onDone = () => {\n $todos.refetch()\n}\n```\n\n### Writes — fire from an action\n```\nfunction saveOrder(payload) {\n $save = $http({ url: "https://api.example.com/orders", method: "POST", body: payload })\n $save.onDone = () => { $orders.refetch() }\n $emit("assistant-message", { message: "Saved." })\n}\n```\n\n`body` objects are JSON-encoded automatically (a `Content-Type: application/json` header is added unless you set one). After a write, call `.refetch()` on the list resource to refresh it — either directly or from the write resource\'s `onDone`.\n\n### `Async` wrapper — branch on resource state\n```\nview = Async($orders, {\n loading: LoadingState("Loading orders…"),\n error: ErrorState("Couldn\'t fetch orders"),\n empty: EmptyState("No orders yet"), // shown when data is null or an empty array\n data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, { format: "currency" })])\n})\n```'}function Vm(){return`## Routing
|
|
250
250
|
|
|
251
251
|
The router is a plain function call. Assign \`$router({ ... })\` to a binding and reference that binding from your shell.
|
|
252
252
|
|
|
@@ -267,7 +267,7 @@ ${V} = AppShell(MainSidebar(), pages, TopBar())
|
|
|
267
267
|
- \`route.navigate("/path")\` inside an action / effect changes the URL.
|
|
268
268
|
- \`NavLink(label, { to, exact?, icon? })\` and \`SidebarItem(label, { to, icon?, badge? })\` are router-aware anchors that auto-derive their active state from \`route.path\`.
|
|
269
269
|
|
|
270
|
-
NEVER declare a state slot named \`route\` yourself. Forget the \`default:\` arm and unknown paths render \`null\`.`}function
|
|
270
|
+
NEVER declare a state slot named \`route\` yourself. Forget the \`default:\` arm and unknown paths render \`null\`.`}function Wm(){return'## Built-in globals — `storage` & `console`\n\nBoth are always in scope, lowercase. No imports.\n\n```\n// localStorage (default); \'$storage.local\' is its alias\n$storage.set("name", "John")\n$name = $storage.get("name")\n$storage.remove("name")\n\n// sessionStorage (per-tab)\n$storage.session.set("draft", $draft)\n\n// Cookies — options as an object literal\n$storage.cookies.set("user", "John", { expires: 7, path: "/", sameSite: "Lax" })\n$storage.cookies.remove("user", { path: "/" })\n\n// Console — forwards to host console\n$console.log("Hello", $user)\n$console.error("Failed", $error)\n```\n\nNon-string values JSON-roundtrip; missing keys return `null`. Cookie options: `expires` (days/Date/ISO), `maxAge` (seconds), `path`, `domain`, `secure`, `sameSite`. Failures (quota, disabled storage) are swallowed silently.\n\n### The full JavaScript global surface\nBeyond `storage` and `console`, **every** JavaScript global resolves by name — the standard library (`Math`, `JSON`, `Object`, `Date`, `Map`, …), browser dialogs (`alert`, `confirm`, `prompt`), and Web APIs (`fetch`, `URL`, `URLSearchParams`, `Blob`, `FormData`, `crypto`, `navigator`, `localStorage`, `atob`/`btoa`, `Intl`, `BigInt`, …), plus `window` / `document`.\n\n```\nfunction copyLink() {\n navigator.clipboard.writeText(window.location.href)\n $toast = "Link copied"\n}\nfunction remove(id) {\n if (confirm("Delete this item?")) { $items = $items.filter(x => x.id != id) }\n}\nid = crypto.randomUUID()\n```\n\nAuthor declarations and built-in components always win over a same-named global, so the passthrough only fills in names you haven\'t defined. Prefer the reactive `$http({...})` over raw `fetch` for data that drives the UI, and keep timers/listeners inside `$effect(...)` so they\'re cleaned up.'}function qm(){return'## Behaviour wrappers\n\nSix tiny wrappers attach behaviour or styling to ANY component without forcing every primitive to grow another prop. They render the child via `display: contents`, so the visual tree is unchanged — only the event / styling layer changes.\n\n```\n// Clickable card\nOnClick(Card([Text("View order")]), { onClick: () => route.navigate("/orders/4821") })\n\n// Lazy-load sentinel — fires once when scrolled into view\nOnIntersect(Skeleton({ variant: "card" }), { onEnter: $items.refetch, once: true })\n\n// Drop zone using HTML5 drag-and-drop\nOnMouse(Card([Text("Drop files here")]), {\n dragOver: e => e.preventDefault(),\n drop: e => { e.preventDefault(); $files = e.dataTransfer.files }\n})\n\n// Apply a class / inline style without breaking out of the component\nCss(Card([Text("Highlighted")]), { class: "highlight", style: "border-color: #f59e0b;" })\n\n// Router-aware anchor wrapping any node\nLink(PersonChip("Ada Lovelace"), { to: "/people/ada" })\n```\n\n- `OnClick(child, { onClick, disabled?, stopPropagation? })` — touch + mouse + keyboard (Enter/Space) activatable.\n- `OnMouse(child, { enter?, leave?, hover?, move?, down?, up?, click?, doubleClick?, contextMenu?, scroll?, wheel?, drag?, drop?, dragStart?, dragEnd?, dragEnter?, dragLeave?, dragOver?, draggable?, passiveScroll? })` — pass only the events you need.\n- `OnKeyboard(child, { onKeyDown?, onKeyUp?, onKeyPress?, focusable? })`.\n- `OnFocus(child, { onFocus?, onBlur? })` — uses bubbling `focusin`/`focusout`.\n- `OnIntersect(child, { onEnter?, onLeave?, onChange?, threshold?, rootMargin?, once? })` — IntersectionObserver wrapper.\n- `Css(child, { style?, class? })` — last-resort raw CSS class/style merge.\n- `Link(child_or_label, { to?, href?, external?, variant? })` — anchor primitive; `to` for router nav, `href`+`external: true` for outbound links.\n\nDon\'t wrap a `Button` in `OnClick` — `Button` already exposes `onClick`. Use `OnClick` for clickable cards / list rows / custom layouts.'}function Gm(){return`## Escape hatches — \`HTMLTag\` & \`Styles\`
|
|
271
271
|
|
|
272
272
|
Use only when the standard catalogue cannot express the markup or styling you need.
|
|
273
273
|
|
|
@@ -282,7 +282,7 @@ ${V} = Column([
|
|
|
282
282
|
Text("Use these only when the standard library cannot capture the design.")
|
|
283
283
|
]})
|
|
284
284
|
])
|
|
285
|
-
\`\`\``}function
|
|
285
|
+
\`\`\``}function Km(){return`## Theming, i18n & icons
|
|
286
286
|
|
|
287
287
|
### \`theme = $theme({ ... })\`
|
|
288
288
|
Assign before \`${V}\` to brand the response. Tokens use the structured form — top-level groups \`colors\`, \`radius\`, \`font\`, \`motion\`, \`elevation\` (plus metadata: \`name\`, \`direction\`). Removing the line snaps the UI back to the host theme.
|
|
@@ -316,8 +316,8 @@ Icon-typed props expect a Font Awesome name as a string — no \`fa-\` prefix, N
|
|
|
316
316
|
|
|
317
317
|
- \`"name"\` defaults to the solid set: \`"house"\`, \`"chart-line"\`, \`"star"\`.
|
|
318
318
|
- \`"regular:name"\` for the outline set; \`"brands:name"\` for brand logos.
|
|
319
|
-
- \`Icon(name, { variant?, size? })\` renders a standalone glyph (\`size\` ∈ \`xs|sm|md|lg|xl\`).`}function
|
|
320
|
-
`).trim()}function
|
|
319
|
+
- \`Icon(name, { variant?, size? })\` renders a standalone glyph (\`size\` ∈ \`xs|sm|md|lg|xl\`).`}function Ym(){return'## `$util` — runtime helper namespace\n\nPure helpers — no side effects. `$util` is a global available inside every Aktion expression, action body, effect, and lambda. Library consumers can call the same methods from JavaScript (`import { Util } from "aktion"`).\n\nReach for `$util` when native JavaScript would be verbose (formatting, date math, grouping). Prefer plain JS where it is just as clear: `arr.length` over `$util.count(arr)`, `a.filter(x => x.done)` over `$util.filter(a, "done", "==", true)`.\n\n### Collections\n- `$util.count(arr)` — length / object key count.\n- `$util.sum(arr)` / `$util.avg(arr)` / `$util.min(arr)` / `$util.max(arr)` — numeric reductions.\n- `$util.first(arr)` / `$util.last(arr)` — endpoints (safe on empty arrays).\n- `$util.filter(arr, field, op, value)` — declarative filter (`op` ∈ `==`, `!=`, `<`, `<=`, `>`, `>=`, `contains`, `startsWith`, `endsWith`).\n- `$util.find(arr, field, op, value)` — first match.\n- `$util.sort(arr, field, dir?)` — stable sort (`dir` ∈ `"asc"` | `"desc"`).\n- `$util.groupBy(arr, field)` — `{ [key]: items[] }`.\n- `$util.unique(arr, field?)` / `$util.reverse(arr)` / `$util.slice(arr, start, end?)` / `$util.pick(obj, ["a", "b"])`.\n- `$util.range(start, end, step?)` — inclusive numeric range.\n- `$util.repeat(value, count)` — fixed-length array.\n- `$util.join(arr, sep?)` — string join.\n\n### Strings\n- `$util.capitalize(s)` / `$util.lowercase(s)` / `$util.uppercase(s)` / `$util.titlecase(s)` / `$util.case(s, mode)`.\n- `$util.split / .trim / .replace / .substring / .startsWith / .endsWith / .contains / .match`.\n- `$util.plural(n, singular, plural)` — picks the right word for a count.\n\n### Formatting\n- `$util.format(value, mode, opts?)` — numbers, currency, percent, compact (`{ currency, locale, decimals }`).\n- `$util.formatDate(value, mode, opts?)` — `"short"` | `"long"` | `"time"` | `"relative"` | token strings (`"YYYY-MM-DD"`).\n\n### Dates\n- `$util.now()` / `$util.today()` / `$util.addDays(date, n)` / `$util.addHours(date, n)` / `$util.diffDays(a, b)` / `$util.startOfWeek(date)` / `$util.endOfMonth(date)`.\n\n### Math\n- `$util.round / .floor / .ceil / .abs / .clamp(v, min, max) / .pow / .sqrt / .random / .log`.\n\nThe namespace is open for extension — new helpers may be added over time.\n\n```\nfiltered = $users.filter((u) => u.team === $team)\nsorted = $util.sort(filtered, "joinedAt", "desc")\nfirstFive = sorted.slice(0, 5)\nsummary = `${rows.length} ${$util.plural(rows.length, "order", "orders")}: ${$util.format($util.sum(rows.amount), "currency")}`\n```'}function Xm(){return"## Standard helper components\n\n| Component | Purpose |\n|---|---|\n| `Async(resource, { loading, error, empty, data })` | Branch on an `$http({...})` resource state. |\n| `Show(when, { fallback?, children })` | Sugar for `when ? children : fallback`. |\n| `Portal(children, { target? })` | Render outside the parent subtree. |\n| `Redirect(path)` | Navigate and unmount the rest of the subtree. |\n| `Lazy(loader, { fallback?, children })` | Defer rendering until `loader` resolves. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised list — preferred for >100 rows. |"}function Jm(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(o=>o.name)}],r=new Map(t.components.map(o=>[o.name,o])),a=[];a.push("## Component library"),a.push("Use only these components. Each signature lists props in declaration order; optional props end with `?`. The prop tagged `(positional)` is the canonical positional slot — pass it bare; every other prop goes in a trailing `{ prop: value }` object."),a.push("");for(const o of e){a.push(`### ${o.name}`);for(const s of o.components){const u=r.get(s);u&&a.push(Ht(u))}a.push("")}const n=new Set(e.flatMap(o=>o.components)),i=t.components.filter(o=>!n.has(o.name));if(i.length>0){a.push("### Other");for(const o of i)a.push(Ht(o))}return a.join(`
|
|
320
|
+
`).trim()}function Zm(){return"## Inline mode\n\nYou may answer questions in plain text. When you do, wrap any UI you produce in a fenced ```aktion``` block. Otherwise output Aktion directly with no surrounding prose."}function Qm(){return"## Edit mode\n\nWhen the user asks for an incremental change to a prior response, output ONLY the statements that need to change (additions, replacements, removals). Do NOT re-emit the whole UI. To remove a statement, write `name = null`."}function ef(){return`## Streaming, output rules & verification
|
|
321
321
|
|
|
322
322
|
### Hoisting & streaming (CRITICAL)
|
|
323
323
|
References resolve from the entire top-level scope, not source order. Emit the shell first so the renderer has somewhere to attach streamed leaves. Required statement order:
|
|
@@ -353,7 +353,7 @@ Before finishing, walk your output and check:
|
|
|
353
353
|
8. \`$http({...})\` uses an absolute \`url\` and exposes \`.data\`, \`.error\`, \`.loading\`, \`.status\`, \`.refetch()\`, \`.cancel()\`.
|
|
354
354
|
9. \`$router({...})\` arms use \`:\` (not \`->\`) and \`default\` (not \`_\`) for the wildcard.
|
|
355
355
|
10. Effects use \`$effect(() => {...}, [deps])\` — never the legacy bracket form.
|
|
356
|
-
11. \`storage\` / \`console\` are lowercase; \`route\` is reserved (never declare it).`}function
|
|
356
|
+
11. \`storage\` / \`console\` are lowercase; \`route\` is reserved (never declare it).`}function tf(){return[`// Tasks dashboard — $http(), Async, action, multi-section layout
|
|
357
357
|
$tasks = $http({ url: "https://api.example.com/tasks", method: "GET" })
|
|
358
358
|
|
|
359
359
|
function toggle(task) {
|
|
@@ -404,9 +404,9 @@ function Overview() {
|
|
|
404
404
|
|
|
405
405
|
function Projects() { return PageHeader("Projects") }
|
|
406
406
|
function Calendar() { return PageHeader("Calendar") }
|
|
407
|
-
function NotFound() { return PageHeader("Not found") }`]}const
|
|
407
|
+
function NotFound() { return PageHeader("Not found") }`]}const rf=["Column","Row","Center","Stack","StackItem","Grid","GridItem","Box","Container","Spacer","Card","CardHeader","CardFooter","Separator","Tabs","TabItem","Accordion","AccordionItem","Steps","AspectRatio","Text","Markdown","Quote","Callout","CodeBlock","Image","Link","Badge","BadgeList","Icon","Kbd","Spinner","Skeleton","Table","Col","List","ListItem","StatCard","Stats","Sparkline","Tile","Progress","ProgressRing","DescriptionList","DescriptionItem","StatusDot","Tree","TreeNode","BarChart","LineChart","PieChart","RadarChart","ScatterChart","Histogram","Heatmap","Gauge","Series","Avatar","AvatarGroup","PersonChip","Rating","ChatBubble","Banner","Notification","Hero","PageHeader","SectionHeader","EmptyState","Timeline","TimelineItem","ActivityLog","FeatureGrid","FeatureItem","Testimonial","ProfileCard","Comment","MediaCard","LoadingState","ErrorState","SuccessState","DiffViewer","JsonTree","SectionBlock","ListBlock","FollowUpBlock","FollowUpItem"];function af(t){return`${t?.trim()||"You are an assistant that responds in Aktion — a declarative language whose surface syntax is a strict subset of JavaScript. The host renders your reply as a rich, read-only UI surface. Output ONLY Aktion: no markdown, prose, or JSON."}
|
|
408
408
|
|
|
409
|
-
Every response MUST start with \`${V} = ...\` on the first line. You are in read-only UI mode — use only the layout, content, data-presentation, chart, and feedback components listed below. Do NOT emit reactive-state writes, action functions, \`effect\` calls, HTTP calls, routing primitives, form controls, clickable buttons, app shells, sidebars, kanban boards, modals, drawers, popovers, hover-cards, tooltips, or dropdown menus. The single exception is \`FollowUpBlock\`, which the host renders as plain follow-up prompt buttons.`}function
|
|
409
|
+
Every response MUST start with \`${V} = ...\` on the first line. You are in read-only UI mode — use only the layout, content, data-presentation, chart, and feedback components listed below. Do NOT emit reactive-state writes, action functions, \`effect\` calls, HTTP calls, routing primitives, form controls, clickable buttons, app shells, sidebars, kanban boards, modals, drawers, popovers, hover-cards, tooltips, or dropdown menus. The single exception is \`FollowUpBlock\`, which the host renders as plain follow-up prompt buttons.`}function nf(){return`## Syntax (read-only subset)
|
|
410
410
|
|
|
411
411
|
A program is a flat list of \`name = expression\` statements, written in standard JavaScript. \`${V}\` is the entry point — every program MUST begin with \`${V} = ...\` (typically \`${V} = Column([...])\`).
|
|
412
412
|
|
|
@@ -449,9 +449,9 @@ follow = FollowUpBlock(["Break down by region", "Compare to Q3"])
|
|
|
449
449
|
|
|
450
450
|
stats = [{ label: "MRR", value: "$48.2k", hint: "+12% vs Q3" }]
|
|
451
451
|
rows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]
|
|
452
|
-
\`\`\``}function
|
|
453
|
-
### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(
|
|
454
|
-
`)}function
|
|
452
|
+
\`\`\``}function of(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(n=>n.name)}],r=new Map(t.components.map(n=>[n.name,n])),a=["## Component library (read-only)","Use only these components. Each signature lists props in declaration order; optional props end with `?`. Pass the positional prop bare, then all other props in a trailing `{ prop: value }` object."];for(const n of e){const i=n.components.filter(o=>rf.includes(o));if(i.length!==0){a.push(`
|
|
453
|
+
### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(Ht(s))}}}return a.join(`
|
|
454
|
+
`)}function sf(){return'## `$util` — runtime helper namespace\n\nPure helpers — no side effects. Use `$util` anywhere in expressions for data shaping, formatting, math, and strings. Prefer plain JavaScript where it is just as clear (`arr.length`, `arr.slice(0, 5)`, `s.toUpperCase()`).\n\n### Most useful helpers\n- Collections: `$util.sum / .avg / .min / .max / .sort(arr, field, dir?) / .groupBy(arr, field) / .unique(arr, field?)`.\n- Strings: `$util.capitalize / .titlecase / .plural(n, singular, plural)`.\n- Formatting: `$util.format(value, mode, opts?)` (numbers, currency, percent, compact) and `$util.formatDate(value, mode)` (`"short"` | `"long"` | `"time"` | `"relative"`).\n\nIcons are Font Awesome names — `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`. Never use `fa-` prefixes or emoji characters.'}function lf(){return`## Hoisting & streaming (CRITICAL)
|
|
455
455
|
|
|
456
456
|
References resolve from the entire scope, not source order — undefined references render as empty until their definitions arrive. This produces a smooth top-down reveal as the response streams.
|
|
457
457
|
|
|
@@ -460,8 +460,8 @@ Required statement order:
|
|
|
460
460
|
2. Container statements (\`heroCard\`, \`tableBlock\`, \`statsRow\`, ...).
|
|
461
461
|
3. Leaf data values (arrays, objects, strings) — last.
|
|
462
462
|
|
|
463
|
-
Define one named reference per \`Col\`, \`TabItem\`, \`AccordionItem\`, \`Series\`, \`FollowUpItem\` so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.`}function
|
|
464
|
-
`)}function
|
|
463
|
+
Define one named reference per \`Col\`, \`TabItem\`, \`AccordionItem\`, \`Series\`, \`FollowUpItem\` so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.`}function cf(t){const e=["## Available data sources (context only)","These endpoints are available to the host. You cannot call them from read-only mode, but you may incorporate the data they describe when composing the UI:"];for(const r of t)e.push(`- **${r.name}** — ${r.description}`);return e.join(`
|
|
464
|
+
`)}function uf(){return[`// Comparison table reply with a template-literal summary
|
|
465
465
|
${V} = Column([title, tbl, totals, follow])
|
|
466
466
|
title = Text("Top languages by users", { variant: "large-heavy" })
|
|
467
467
|
tbl = Table([
|
|
@@ -487,7 +487,7 @@ kpis = Stats([
|
|
|
487
487
|
{ label: "Avg latency", value: "84ms", hint: "p99" }
|
|
488
488
|
])
|
|
489
489
|
|
|
490
|
-
article = "The renderer ships **130+ components**, a single reactive sigil, and a streaming-first parser."`]}function
|
|
490
|
+
article = "The renderer ships **130+ components**, a single reactive sigil, and a streaming-first parser."`]}function df(){return'## Important rules\n\n- **Pick the right component for the content.** Tables for comparisons, charts for trends, `Callout`/`Banner` for highlights, `Markdown` for paragraph prose, `Hero`/`PageHeader` for top titles, `Stats` for KPI strips.\n- **Lead with a clear title.** `Text(text, { variant: "large-heavy" })`, `SectionHeader(...)`, `PageHeader(...)`, or `Hero(...)`.\n- **Realistic data** — believable names, numbers, and dates. Never Lorem Ipsum.\n- **Tables are column-oriented:** `Table([Col("Label", arr1), Col("Count", arr2, { format: "number" })])`. Columns can hold components in two equivalent ways: map values to components directly — `Col("Status", rows.map(r => Badge(r.status)))`, `Col("Actions", rows.map(r => Button("Edit")))` — or keep rows as values and use `render: (r) => Component`. A whole column can be clickable with `onClick: (value, index) => …`.\n- **Charts need numeric arrays** — use array pluck (`PieChart(rows.label, rows.value)`).\n- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.\n- **`Markdown`** for rich paragraph prose; **`Text`** for short labels.\n- **Template literals** for any string mixing copy with values.\n- **Trailing-object form** — `Button("Save", { variant: "primary" })`, never bare `Button("Save", variant: "primary")`.'}function pf(){return`## Final verification
|
|
491
491
|
|
|
492
492
|
Before finishing, walk your output and verify:
|
|
493
493
|
1. \`${V} = ...\` is the FIRST line.
|
|
@@ -497,11 +497,11 @@ Before finishing, walk your output and verify:
|
|
|
497
497
|
5. Only the read-only components above are used — no forms, clickable buttons, modals, app shells, reactive-state writes, action functions, effect calls, HTTP calls, or routing primitives.
|
|
498
498
|
6. No statement is split across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.
|
|
499
499
|
7. Tables are column-oriented; charts use numeric arrays (use array pluck like \`rows.value\` when needed).
|
|
500
|
-
8. Named arguments use a trailing \`{ prop: value }\` object — not bare \`prop: value\` syntax.`}function
|
|
501
|
-
`)}function
|
|
502
|
-
`)}function
|
|
500
|
+
8. Named arguments use a trailing \`{ prop: value }\` object — not bare \`prop: value\` syntax.`}function Ht(t){const e=er(t),r=t.props.map(a=>{const n=a.enum?a.enum.map(o=>`"${o}"`).join("|"):a.type,i=a===e&&a.positional===!0?" (positional)":"";return`${a.name}${a.optional?"?":""}: ${n}${i}`}).join(", ");return`- ${t.name}(${r}) — ${t.description}`}function Br(t,e){const r=[`## ${t}`];for(const a of e)r.push("```"),r.push(a.trim()),r.push("```");return r.join(`
|
|
501
|
+
`)}function gi(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
|
|
502
|
+
`)}function mf(t){const e=["## Available endpoints","These endpoints are provided by the host. Fire requests with `$http({ url, method, body, headers, ... })` and observe the reactive bag (`.data`, `.error`, `.loading`, `.status`, `.refetch()`)."];for(const r of t){const a=r.kind==="Mutation"?"POST/PUT/PATCH/DELETE":"GET",n=r.argsExample?` example body: ${JSON.stringify(r.argsExample)}`:" example body: {}";e.push(`- ${r.name} (${a}) — ${r.description}
|
|
503
503
|
${n}`)}return e.join(`
|
|
504
|
-
`)}const be={colorBg:"#ffffff",colorBgSubtle:"#f8fafc",colorSurface:"#ffffff",colorSurfaceMuted:"#f1f5f9",colorBorder:"#e2e8f0",colorBorderSubtle:"rgba(15, 23, 42, 0.08)",colorText:"#0f172a",colorTextMuted:"#475569",colorPrimary:"#6366f1",colorPrimaryHover:"#4f46e5",colorPrimaryText:"#ffffff",colorAccent:"#6366f1",colorAccentHover:"#4f46e5",colorAccentText:"#ffffff",colorFocusRing:"#6366f1",colorSuccess:"#10b981",colorWarning:"#f59e0b",colorDanger:"#ef4444",colorInfo:"#06b6d4",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.06)",shadowMd:"0 6px 24px rgba(15, 23, 42, 0.08)",shadowLg:"0 18px 60px rgba(15, 23, 42, 0.12)",borderWidth:"1px",chart1:"#6366f1",chart2:"#10b981",chart3:"#f59e0b",chart4:"#ef4444",chart5:"#06b6d4",chart6:"#8b5cf6",...{fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyHeading:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},...{fontSizeBase:"14px",fontSizeSm:"12px",fontSizeLg:"16px",fontSizeHeading:"16px",fontSizeTitle:"22px",fontWeightBody:"400",fontWeightHeading:"700",lineHeightBody:"1.5",lineHeightHeading:"1.2",letterSpacingHeading:"0",headingTextTransform:"none"},...{spacingXs:"4px",spacingS:"8px",spacingM:"12px",spacingL:"20px",spacingXl:"32px"},...{radiusXs:"4px",radiusSm:"6px",radiusMd:"10px",radiusLg:"16px",radiusPill:"999px",radiusButton:"6px",radiusInput:"6px"},...{buttonFontWeight:"600",buttonTextTransform:"none",buttonLetterSpacing:"0",buttonPaddingY:"8px",buttonPaddingX:"14px"},...{transitionDuration:"120ms"}},pi={...be,colorBg:"#0b1220",colorBgSubtle:"#0f172a",colorSurface:"#111827",colorSurfaceMuted:"#1e293b",colorBorder:"#1f2937",colorBorderSubtle:"rgba(248, 250, 252, 0.08)",colorText:"#f8fafc",colorTextMuted:"#94a3b8",colorPrimary:"#818cf8",colorPrimaryHover:"#6366f1",colorPrimaryText:"#0b1220",colorAccent:"#818cf8",colorAccentHover:"#6366f1",colorAccentText:"#0b1220",colorFocusRing:"#818cf8",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.4)",shadowMd:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowLg:"0 22px 60px rgba(0, 0, 0, 0.55)"},mi={...be,colorBg:"#05060f",colorBgSubtle:"#0a0c1c",colorSurface:"#0d1024",colorSurfaceMuted:"#161a36",colorBorder:"#2a2f6b",colorBorderSubtle:"rgba(236, 72, 153, 0.18)",colorText:"#f5f3ff",colorTextMuted:"#a5b4fc",colorPrimary:"#ec4899",colorPrimaryHover:"#f472b6",colorPrimaryText:"#05060f",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#05060f",colorFocusRing:"#ec4899",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#f87171",colorInfo:"#22d3ee",fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyHeading:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyMono:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",letterSpacingHeading:"0.02em",radiusXs:"2px",radiusSm:"2px",radiusMd:"4px",radiusLg:"6px",radiusButton:"2px",radiusInput:"2px",shadowSm:"0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)",shadowMd:"0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)",shadowLg:"0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"22px",spacingXl:"36px",chart1:"#ec4899",chart2:"#22d3ee",chart3:"#fbbf24",chart4:"#a78bfa",chart5:"#34d399",chart6:"#f472b6"},fi={...be,colorBg:"#fdf6ff",colorBgSubtle:"#fbf2ff",colorSurface:"#ffffff",colorSurfaceMuted:"#f4ecff",colorBorder:"#ead8ff",colorBorderSubtle:"rgba(168, 132, 232, 0.18)",colorText:"#3b1f56",colorTextMuted:"#7d6193",colorPrimary:"#a78bfa",colorPrimaryHover:"#8b5cf6",colorPrimaryText:"#ffffff",colorAccent:"#5eead4",colorAccentHover:"#2dd4bf",colorAccentText:"#0f3a35",colorFocusRing:"#a78bfa",colorSuccess:"#5eead4",colorWarning:"#fcd34d",colorDanger:"#fda4af",colorInfo:"#93c5fd",fontFamily:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"8px",radiusSm:"12px",radiusMd:"20px",radiusLg:"28px",radiusButton:"16px",radiusInput:"16px",shadowSm:"0 4px 14px rgba(168, 132, 232, 0.12)",shadowMd:"0 18px 40px rgba(168, 132, 232, 0.18)",shadowLg:"0 28px 70px rgba(168, 132, 232, 0.22)",spacingXs:"6px",spacingS:"12px",spacingM:"18px",spacingL:"28px",spacingXl:"44px",chart1:"#a78bfa",chart2:"#5eead4",chart3:"#fcd34d",chart4:"#fda4af",chart5:"#93c5fd",chart6:"#f9a8d4"},gi={...be,colorBg:"#0f1730",colorBgSubtle:"#13204a",colorSurface:"rgba(255, 255, 255, 0.08)",colorSurfaceMuted:"rgba(255, 255, 255, 0.04)",colorBorder:"rgba(255, 255, 255, 0.18)",colorBorderSubtle:"rgba(255, 255, 255, 0.10)",colorText:"#f1f5ff",colorTextMuted:"#b6c3e6",colorPrimary:"#60a5fa",colorPrimaryHover:"#3b82f6",colorPrimaryText:"#0b132b",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#0b132b",colorFocusRing:"#60a5fa",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#fb7185",colorInfo:"#22d3ee",fontFamily:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"6px",radiusSm:"10px",radiusMd:"16px",radiusLg:"24px",radiusButton:"12px",radiusInput:"12px",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)",shadowMd:"0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)",shadowLg:"0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"24px",spacingXl:"40px",chart1:"#60a5fa",chart2:"#22d3ee",chart3:"#a78bfa",chart4:"#f472b6",chart5:"#34d399",chart6:"#fbbf24"},hi={...be,colorBg:"#fef9c3",colorBgSubtle:"#fde68a",colorSurface:"#ffffff",colorSurfaceMuted:"#fef3c7",colorBorder:"#0a0a0a",colorBorderSubtle:"#0a0a0a",colorText:"#0a0a0a",colorTextMuted:"#3f3f46",colorPrimary:"#1d4ed8",colorPrimaryHover:"#1e40af",colorPrimaryText:"#ffffff",colorAccent:"#dc2626",colorAccentHover:"#b91c1c",colorAccentText:"#ffffff",colorFocusRing:"#0a0a0a",colorSuccess:"#16a34a",colorWarning:"#ea580c",colorDanger:"#dc2626",colorInfo:"#0891b2",fontFamily:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyHeading:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyMono:"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontWeightHeading:"800",letterSpacingHeading:"-0.01em",headingTextTransform:"uppercase",radiusXs:"0px",radiusSm:"0px",radiusMd:"0px",radiusLg:"0px",radiusPill:"0px",radiusButton:"0px",radiusInput:"0px",borderWidth:"2px",shadowSm:"3px 3px 0 0 #0a0a0a",shadowMd:"6px 6px 0 0 #0a0a0a",shadowLg:"10px 10px 0 0 #0a0a0a",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"22px",spacingXl:"36px",buttonFontWeight:"800",buttonTextTransform:"uppercase",buttonLetterSpacing:"0.02em",chart1:"#dc2626",chart2:"#1d4ed8",chart3:"#16a34a",chart4:"#ea580c",chart5:"#7c3aed",chart6:"#0a0a0a"},bi={...be,colorBg:"#eff2f7",colorBgSubtle:"#e6ecf3",colorSurface:"#ffffff",colorSurfaceMuted:"#f4f7fb",colorBorder:"#d6deea",colorBorderSubtle:"rgba(13, 27, 58, 0.08)",colorText:"#0d1b3a",colorTextMuted:"#5a6a85",colorPrimary:"#003580",colorPrimaryHover:"#002a66",colorPrimaryText:"#ffffff",colorAccent:"#0095d6",colorAccentHover:"#0078ad",colorAccentText:"#ffffff",colorFocusRing:"#0095d6",colorSuccess:"#1b8f4f",colorWarning:"#c47e00",colorDanger:"#c8362b",colorInfo:"#0095d6",fontFamily:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"3px",radiusSm:"4px",radiusMd:"6px",radiusLg:"10px",radiusButton:"4px",radiusInput:"4px",shadowSm:"0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)",shadowMd:"0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)",shadowLg:"0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"20px",spacingXl:"32px",chart1:"#003580",chart2:"#0095d6",chart3:"#1b8f4f",chart4:"#c47e00",chart5:"#d43594",chart6:"#5a6a85"},jr={light:be,dark:pi,neon:mi,pastel:fi,glass:gi,brutalist:hi,skyline:bi},Ht={colorBg:"--rui-color-bg",colorBgSubtle:"--rui-color-bg-subtle",colorSurface:"--rui-color-surface",colorSurfaceMuted:"--rui-color-surface-muted",colorBorder:"--rui-color-border",colorBorderSubtle:"--rui-color-border-subtle",colorText:"--rui-color-text",colorTextMuted:"--rui-color-text-muted",colorPrimary:"--rui-color-primary",colorPrimaryHover:"--rui-color-primary-hover",colorPrimaryText:"--rui-color-primary-text",colorAccent:"--rui-color-accent",colorAccentHover:"--rui-color-accent-hover",colorAccentText:"--rui-color-accent-text",colorFocusRing:"--rui-color-focus-ring",colorSuccess:"--rui-color-success",colorWarning:"--rui-color-warning",colorDanger:"--rui-color-danger",colorInfo:"--rui-color-info",fontFamily:"--rui-font-family",fontFamilyHeading:"--rui-font-family-heading",fontFamilyMono:"--rui-font-family-mono",fontSizeBase:"--rui-font-size-base",fontSizeSm:"--rui-font-size-sm",fontSizeLg:"--rui-font-size-lg",fontSizeHeading:"--rui-font-size-heading",fontSizeTitle:"--rui-font-size-title",fontWeightBody:"--rui-font-weight-body",fontWeightHeading:"--rui-font-weight-heading",lineHeightBody:"--rui-line-height-body",lineHeightHeading:"--rui-line-height-heading",letterSpacingHeading:"--rui-letter-spacing-heading",headingTextTransform:"--rui-heading-text-transform",radiusXs:"--rui-radius-xs",radiusSm:"--rui-radius-sm",radiusMd:"--rui-radius-md",radiusLg:"--rui-radius-lg",radiusPill:"--rui-radius-pill",radiusButton:"--rui-radius-button",radiusInput:"--rui-radius-input",borderWidth:"--rui-border-width",shadowSm:"--rui-shadow-sm",shadowMd:"--rui-shadow-md",shadowLg:"--rui-shadow-lg",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",buttonFontWeight:"--rui-button-font-weight",buttonTextTransform:"--rui-button-text-transform",buttonLetterSpacing:"--rui-button-letter-spacing",buttonPaddingY:"--rui-button-padding-y",buttonPaddingX:"--rui-button-padding-x",transitionDuration:"--rui-transition-duration",chart1:"--rui-chart-1",chart2:"--rui-chart-2",chart3:"--rui-chart-3",chart4:"--rui-chart-4",chart5:"--rui-chart-5",chart6:"--rui-chart-6"};function Dr(t){if(!t)return{name:"light",tokens:be};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:wi(JSON.parse(t))}}catch{return{name:"light",tokens:be}}const r=jr[e];return r?{name:e,tokens:r}:{name:"light",tokens:be}}return{name:"custom",tokens:wi(t)}}function Br(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(Ht))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function vi(t,e){const r=[];for(const a of Object.keys(e)){const n=Ht[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function yi(t,e){for(const r of e){const a=Ht[r];a&&t.style.removeProperty(a)}}function xi(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in Ht&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function wi(t){return{...be,...t}}const ki=`
|
|
504
|
+
`)}const be={colorBg:"#ffffff",colorBgSubtle:"#f8fafc",colorSurface:"#ffffff",colorSurfaceMuted:"#f1f5f9",colorBorder:"#e2e8f0",colorBorderSubtle:"rgba(15, 23, 42, 0.08)",colorText:"#0f172a",colorTextMuted:"#475569",colorPrimary:"#6366f1",colorPrimaryHover:"#4f46e5",colorPrimaryText:"#ffffff",colorAccent:"#6366f1",colorAccentHover:"#4f46e5",colorAccentText:"#ffffff",colorFocusRing:"#6366f1",colorSuccess:"#10b981",colorWarning:"#f59e0b",colorDanger:"#ef4444",colorInfo:"#06b6d4",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.06)",shadowMd:"0 6px 24px rgba(15, 23, 42, 0.08)",shadowLg:"0 18px 60px rgba(15, 23, 42, 0.12)",borderWidth:"1px",chart1:"#6366f1",chart2:"#10b981",chart3:"#f59e0b",chart4:"#ef4444",chart5:"#06b6d4",chart6:"#8b5cf6",...{fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyHeading:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},...{fontSizeBase:"14px",fontSizeSm:"12px",fontSizeLg:"16px",fontSizeHeading:"16px",fontSizeTitle:"22px",fontWeightBody:"400",fontWeightHeading:"700",lineHeightBody:"1.5",lineHeightHeading:"1.2",letterSpacingHeading:"0",headingTextTransform:"none"},...{spacingXs:"4px",spacingS:"8px",spacingM:"12px",spacingL:"20px",spacingXl:"32px"},...{radiusXs:"4px",radiusSm:"6px",radiusMd:"10px",radiusLg:"16px",radiusPill:"999px",radiusButton:"6px",radiusInput:"6px"},...{buttonFontWeight:"600",buttonTextTransform:"none",buttonLetterSpacing:"0",buttonPaddingY:"8px",buttonPaddingX:"14px"},...{transitionDuration:"120ms"}},hi={...be,colorBg:"#0b1220",colorBgSubtle:"#0f172a",colorSurface:"#111827",colorSurfaceMuted:"#1e293b",colorBorder:"#1f2937",colorBorderSubtle:"rgba(248, 250, 252, 0.08)",colorText:"#f8fafc",colorTextMuted:"#94a3b8",colorPrimary:"#818cf8",colorPrimaryHover:"#6366f1",colorPrimaryText:"#0b1220",colorAccent:"#818cf8",colorAccentHover:"#6366f1",colorAccentText:"#0b1220",colorFocusRing:"#818cf8",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.4)",shadowMd:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowLg:"0 22px 60px rgba(0, 0, 0, 0.55)"},bi={...be,colorBg:"#05060f",colorBgSubtle:"#0a0c1c",colorSurface:"#0d1024",colorSurfaceMuted:"#161a36",colorBorder:"#2a2f6b",colorBorderSubtle:"rgba(236, 72, 153, 0.18)",colorText:"#f5f3ff",colorTextMuted:"#a5b4fc",colorPrimary:"#ec4899",colorPrimaryHover:"#f472b6",colorPrimaryText:"#05060f",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#05060f",colorFocusRing:"#ec4899",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#f87171",colorInfo:"#22d3ee",fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyHeading:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontFamilyMono:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",letterSpacingHeading:"0.02em",radiusXs:"2px",radiusSm:"2px",radiusMd:"4px",radiusLg:"6px",radiusButton:"2px",radiusInput:"2px",shadowSm:"0 0 0 1px rgba(236, 72, 153, 0.25), 0 0 12px rgba(34, 211, 238, 0.18)",shadowMd:"0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 28px rgba(34, 211, 238, 0.22)",shadowLg:"0 0 0 1px rgba(236, 72, 153, 0.45), 0 0 48px rgba(34, 211, 238, 0.35)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"22px",spacingXl:"36px",chart1:"#ec4899",chart2:"#22d3ee",chart3:"#fbbf24",chart4:"#a78bfa",chart5:"#34d399",chart6:"#f472b6"},vi={...be,colorBg:"#fdf6ff",colorBgSubtle:"#fbf2ff",colorSurface:"#ffffff",colorSurfaceMuted:"#f4ecff",colorBorder:"#ead8ff",colorBorderSubtle:"rgba(168, 132, 232, 0.18)",colorText:"#3b1f56",colorTextMuted:"#7d6193",colorPrimary:"#a78bfa",colorPrimaryHover:"#8b5cf6",colorPrimaryText:"#ffffff",colorAccent:"#5eead4",colorAccentHover:"#2dd4bf",colorAccentText:"#0f3a35",colorFocusRing:"#a78bfa",colorSuccess:"#5eead4",colorWarning:"#fcd34d",colorDanger:"#fda4af",colorInfo:"#93c5fd",fontFamily:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Quicksand', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"8px",radiusSm:"12px",radiusMd:"20px",radiusLg:"28px",radiusButton:"16px",radiusInput:"16px",shadowSm:"0 4px 14px rgba(168, 132, 232, 0.12)",shadowMd:"0 18px 40px rgba(168, 132, 232, 0.18)",shadowLg:"0 28px 70px rgba(168, 132, 232, 0.22)",spacingXs:"6px",spacingS:"12px",spacingM:"18px",spacingL:"28px",spacingXl:"44px",chart1:"#a78bfa",chart2:"#5eead4",chart3:"#fcd34d",chart4:"#fda4af",chart5:"#93c5fd",chart6:"#f9a8d4"},yi={...be,colorBg:"#0f1730",colorBgSubtle:"#13204a",colorSurface:"rgba(255, 255, 255, 0.08)",colorSurfaceMuted:"rgba(255, 255, 255, 0.04)",colorBorder:"rgba(255, 255, 255, 0.18)",colorBorderSubtle:"rgba(255, 255, 255, 0.10)",colorText:"#f1f5ff",colorTextMuted:"#b6c3e6",colorPrimary:"#60a5fa",colorPrimaryHover:"#3b82f6",colorPrimaryText:"#0b132b",colorAccent:"#22d3ee",colorAccentHover:"#67e8f9",colorAccentText:"#0b132b",colorFocusRing:"#60a5fa",colorSuccess:"#34d399",colorWarning:"#fbbf24",colorDanger:"#fb7185",colorInfo:"#22d3ee",fontFamily:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"6px",radiusSm:"10px",radiusMd:"16px",radiusLg:"24px",radiusButton:"12px",radiusInput:"12px",shadowSm:"0 1px 2px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.08)",shadowMd:"0 18px 50px rgba(7, 14, 33, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10)",shadowLg:"0 28px 80px rgba(7, 14, 33, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12)",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"24px",spacingXl:"40px",chart1:"#60a5fa",chart2:"#22d3ee",chart3:"#a78bfa",chart4:"#f472b6",chart5:"#34d399",chart6:"#fbbf24"},xi={...be,colorBg:"#fef9c3",colorBgSubtle:"#fde68a",colorSurface:"#ffffff",colorSurfaceMuted:"#fef3c7",colorBorder:"#0a0a0a",colorBorderSubtle:"#0a0a0a",colorText:"#0a0a0a",colorTextMuted:"#3f3f46",colorPrimary:"#1d4ed8",colorPrimaryHover:"#1e40af",colorPrimaryText:"#ffffff",colorAccent:"#dc2626",colorAccentHover:"#b91c1c",colorAccentText:"#ffffff",colorFocusRing:"#0a0a0a",colorSuccess:"#16a34a",colorWarning:"#ea580c",colorDanger:"#dc2626",colorInfo:"#0891b2",fontFamily:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyHeading:"'Space Grotesk', 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",fontFamilyMono:"'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontWeightHeading:"800",letterSpacingHeading:"-0.01em",headingTextTransform:"uppercase",radiusXs:"0px",radiusSm:"0px",radiusMd:"0px",radiusLg:"0px",radiusPill:"0px",radiusButton:"0px",radiusInput:"0px",borderWidth:"2px",shadowSm:"3px 3px 0 0 #0a0a0a",shadowMd:"6px 6px 0 0 #0a0a0a",shadowLg:"10px 10px 0 0 #0a0a0a",spacingXs:"4px",spacingS:"10px",spacingM:"16px",spacingL:"22px",spacingXl:"36px",buttonFontWeight:"800",buttonTextTransform:"uppercase",buttonLetterSpacing:"0.02em",chart1:"#dc2626",chart2:"#1d4ed8",chart3:"#16a34a",chart4:"#ea580c",chart5:"#7c3aed",chart6:"#0a0a0a"},wi={...be,colorBg:"#eff2f7",colorBgSubtle:"#e6ecf3",colorSurface:"#ffffff",colorSurfaceMuted:"#f4f7fb",colorBorder:"#d6deea",colorBorderSubtle:"rgba(13, 27, 58, 0.08)",colorText:"#0d1b3a",colorTextMuted:"#5a6a85",colorPrimary:"#003580",colorPrimaryHover:"#002a66",colorPrimaryText:"#ffffff",colorAccent:"#0095d6",colorAccentHover:"#0078ad",colorAccentText:"#ffffff",colorFocusRing:"#0095d6",colorSuccess:"#1b8f4f",colorWarning:"#c47e00",colorDanger:"#c8362b",colorInfo:"#0095d6",fontFamily:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyHeading:"'Inter', 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",radiusXs:"3px",radiusSm:"4px",radiusMd:"6px",radiusLg:"10px",radiusButton:"4px",radiusInput:"4px",shadowSm:"0 1px 0 rgba(13, 27, 58, 0.04), 0 1px 3px rgba(13, 27, 58, 0.06)",shadowMd:"0 4px 16px rgba(13, 27, 58, 0.08), 0 1px 3px rgba(13, 27, 58, 0.04)",shadowLg:"0 16px 40px rgba(13, 27, 58, 0.12), 0 2px 6px rgba(13, 27, 58, 0.06)",spacingXs:"4px",spacingS:"8px",spacingM:"14px",spacingL:"20px",spacingXl:"32px",chart1:"#003580",chart2:"#0095d6",chart3:"#1b8f4f",chart4:"#c47e00",chart5:"#d43594",chart6:"#5a6a85"},Fr={light:be,dark:hi,neon:bi,pastel:vi,glass:yi,brutalist:xi,skyline:wi},Vt={colorBg:"--rui-color-bg",colorBgSubtle:"--rui-color-bg-subtle",colorSurface:"--rui-color-surface",colorSurfaceMuted:"--rui-color-surface-muted",colorBorder:"--rui-color-border",colorBorderSubtle:"--rui-color-border-subtle",colorText:"--rui-color-text",colorTextMuted:"--rui-color-text-muted",colorPrimary:"--rui-color-primary",colorPrimaryHover:"--rui-color-primary-hover",colorPrimaryText:"--rui-color-primary-text",colorAccent:"--rui-color-accent",colorAccentHover:"--rui-color-accent-hover",colorAccentText:"--rui-color-accent-text",colorFocusRing:"--rui-color-focus-ring",colorSuccess:"--rui-color-success",colorWarning:"--rui-color-warning",colorDanger:"--rui-color-danger",colorInfo:"--rui-color-info",fontFamily:"--rui-font-family",fontFamilyHeading:"--rui-font-family-heading",fontFamilyMono:"--rui-font-family-mono",fontSizeBase:"--rui-font-size-base",fontSizeSm:"--rui-font-size-sm",fontSizeLg:"--rui-font-size-lg",fontSizeHeading:"--rui-font-size-heading",fontSizeTitle:"--rui-font-size-title",fontWeightBody:"--rui-font-weight-body",fontWeightHeading:"--rui-font-weight-heading",lineHeightBody:"--rui-line-height-body",lineHeightHeading:"--rui-line-height-heading",letterSpacingHeading:"--rui-letter-spacing-heading",headingTextTransform:"--rui-heading-text-transform",radiusXs:"--rui-radius-xs",radiusSm:"--rui-radius-sm",radiusMd:"--rui-radius-md",radiusLg:"--rui-radius-lg",radiusPill:"--rui-radius-pill",radiusButton:"--rui-radius-button",radiusInput:"--rui-radius-input",borderWidth:"--rui-border-width",shadowSm:"--rui-shadow-sm",shadowMd:"--rui-shadow-md",shadowLg:"--rui-shadow-lg",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",buttonFontWeight:"--rui-button-font-weight",buttonTextTransform:"--rui-button-text-transform",buttonLetterSpacing:"--rui-button-letter-spacing",buttonPaddingY:"--rui-button-padding-y",buttonPaddingX:"--rui-button-padding-x",transitionDuration:"--rui-transition-duration",chart1:"--rui-chart-1",chart2:"--rui-chart-2",chart3:"--rui-chart-3",chart4:"--rui-chart-4",chart5:"--rui-chart-5",chart6:"--rui-chart-6"};function Or(t){if(!t)return{name:"light",tokens:be};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:$i(JSON.parse(t))}}catch{return{name:"light",tokens:be}}const r=Fr[e];return r?{name:e,tokens:r}:{name:"light",tokens:be}}return{name:"custom",tokens:$i(t)}}function _r(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(Vt))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function ki(t,e){const r=[];for(const a of Object.keys(e)){const n=Vt[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function Si(t,e){for(const r of e){const a=Vt[r];a&&t.style.removeProperty(a)}}function Ci(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in Vt&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function $i(t){return{...be,...t}}const Ti=`
|
|
505
505
|
:host {
|
|
506
506
|
display: block;
|
|
507
507
|
box-sizing: border-box;
|
|
@@ -8383,7 +8383,7 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
|
|
|
8383
8383
|
}
|
|
8384
8384
|
.rui-lightbox-thumb img { display: block; width: 100%; height: auto; }
|
|
8385
8385
|
.rui-lightbox-thumb:hover { border-color: var(--rui-color-primary); }
|
|
8386
|
-
`,Fr="theme",pt="streaming",Or="response",Qe="showerrors",Si="route";function lf(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof window<"u"&&window.location){const i=window.location.search||"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function cf(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,a=e;return r.path!==a.path||r.pattern!==a.pattern?!1:Ci(r.params??{},a.params??{})&&Ci(r.query??{},a.query??{})}function Ci(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}let _r=null,Vt=null;function uf(){if(Vt===!1)return null;if(_r)return _r;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Vt=!1,null;const t=new CSSStyleSheet;return t.replaceSync(ki),_r=t,Vt=!0,t}catch{return Vt=!1,null}}class mt extends HTMLElement{constructor(){super();D(this,"state",new Aa);D(this,"router",new ja);D(this,"library",dt);D(this,"http",new Pa);D(this,"effectRunner");D(this,"actionDeclRunner");D(this,"renderer");D(this,"context");D(this,"root");D(this,"rootEl");D(this,"errorEl");D(this,"currentResponse","");D(this,"renderScheduled",!1);D(this,"programDirty",!0);D(this,"lastRenderDeps",null);D(this,"pendingChangedPaths",new Set);D(this,"forceFullRender",!1);D(this,"parseErrors",[]);D(this,"scriptThemeKeys",[]);D(this,"warnedStateWriteDuringRender",!1);this.root=this.attachShadow({mode:"open"}),this.errorEl=document.createElement("div"),this.errorEl.className="rui-error-banner",this.errorEl.hidden=!0,this.rootEl=document.createElement("div"),this.rootEl.className="rui-root";const r=uf();if(r)try{this.root.adoptedStyleSheets=[r],this.root.append(this.errorEl,this.rootEl)}catch{this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl)}else this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl);const a=n=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:n},bubbles:!0,composed:!0}))};this.effectRunner=new pn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.actionDeclRunner=new gn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onAssistantMessage:a}),this.context=or(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.renderer=new si({library:this.library,state:this.state,router:this.router,onAssistantMessage:a,evaluationContext:()=>this.context,mountInstanceEffects:(n,i,o)=>this.effectRunner.syncInstanceEffects(n,i,o),unmountInstanceEffects:n=>this.effectRunner.unmountInstance(n),unmountInstanceHooks:n=>ln(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);(this.lastRenderDeps===null||vt(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[Fr,pt,Or,Qe]}connectedCallback(){_s(this.root),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(Or);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}if(!this.currentResponse){const a=(this.textContent??"").trim();if(a){this.setResponse(a);return}}this.currentResponse&&(this.programDirty=!0,this.scheduleRender())}disconnectedCallback(){this.effectRunner.reset(),this.context&&sr(this.context),this.router.stop()}attributeChangedCallback(r,a,n){if(r===Fr&&this.applyThemeFromAttribute(),r===pt&&(this.updateErrorBanner(),this.scheduleRender()),r===Qe&&this.updateErrorBanner(),r===Or){const i=n??"";i!==this.currentResponse&&this.setResponse(i)}}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const a=this.state.snapshot(),n=so(this.currentResponse,r);return Object.assign(a,n.stateUpdates),this.loadSnapshot({programText:n.programText,state:a}),n.warnings}loadSnapshot(r){this.currentResponse=r.programText,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.state.hydrate(r.state),this.scheduleRender()}appendChunk(r){if(r==null)return;const a=typeof r=="string"?r:String(r);a!==""&&(this.currentResponse+=a,this.programDirty=!0,this.scheduleRender())}setTheme(r){Br(this,Dr(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=ha(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return Rr(this.library,r??{})}navigate(r){this.router.navigate(r)}get route(){return this.router.getPath()}clear(){this.currentResponse="",this.state.rebind([]),this.effectRunner.reset(),this.renderer.reset(),this.programDirty=!0,this.parseErrors=[],this.errorEl.hidden=!0,this.errorEl.replaceChildren(),this.rootEl.replaceChildren(),this.router.setActiveMatch(null,{})}get response(){return this.currentResponse}set response(r){this.setResponse(r)}get streaming(){return $i(this.getAttribute(pt))}set streaming(r){r?this.setAttribute(pt,"true"):this.removeAttribute(pt)}get showErrors(){return $i(this.getAttribute(Qe))}set showErrors(r){r?this.setAttribute(Qe,"true"):this.removeAttribute(Qe)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}buildInlineStyle(){const r=document.createElement("style");return r.textContent=ki,r}startRouter(){this.router.start(),this.writeRouteState()}writeRouteState(){const r=lf(this.router);cf(this.state.get(Si),r)||this.state.set(Si,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(Fr);Br(this,Dr(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(yi(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Ca(a))return;const n=xi(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=vi(this,n))}scheduleRender(){this.renderScheduled||(this.renderScheduled=!0,queueMicrotask(()=>this.renderNow()))}requestFullRender(){this.forceFullRender=!0,this.scheduleRender()}renderNow(){if(this.renderScheduled=!1,!this.isConnected)return;this.programDirty&&(this.replan(),this.programDirty=!1),this.context.budget&&ar(this.context.budget);const r=new Set,a=this.context.trackedState;this.context.trackedState=r;let n=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),qa(this.context);const i=this.context.bindings.get("aktion");let o=null;if(i)try{o=i()}catch(d){if(d instanceof Pe){this.handleRuntimeBudgetError(d);return}console.error("[aktion] entry point evaluation error",d)}const s=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const u=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:s,memoize:u});const c=this.captureFocus();let m;try{m=this.renderer.render(o)}catch(d){if(this.renderer.endRender(),d instanceof Pe){this.handleRuntimeBudgetError(d);return}throw d}wm(this.rootEl,m),this.renderer.endRender(),this.restoreFocus(c),n=!0}finally{this.context.trackedState=a,this.lastRenderDeps=n?r:null,this.state.endRenderPass()&&this.warnStateWriteDuringRender()}}warnStateWriteDuringRender(){this.warnedStateWriteDuringRender||(this.warnedStateWriteDuringRender=!0,console.warn("[aktion] A reactive `$state` write happened during render and was applied WITHOUT scheduling a re-render, to prevent an infinite render loop. This usually means a `$name = …` assignment is running in render position — e.g. `$user = {…}` at the top of a lowercase `function` that's invoked to build the UI (`aktion = app()`), where the function runs as an action and re-writes the atom every render. Seed component-local state with a PascalCase component (so `$name = …` becomes a set-once per-instance declaration) or the `$state` hook, and only write state from event handlers / effects."))}handleRuntimeBudgetError(r){const a=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(a)||(this.parseErrors=[...this.parseErrors,a]),this.updateErrorBanner(),this.streaming||this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r.message}]},bubbles:!0,composed:!0}))}captureFocus(){const r=this.root.activeElement;if(!r||!this.rootEl.contains(r))return null;const a=r.id||null;if(!a)return null;const n={id:a,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(n.selectionStart=r.selectionStart,n.selectionEnd=r.selectionEnd,n.selectionDirection=r.selectionDirection??null),n}restoreFocus(r){if(!r)return;const a=this.rootEl.querySelector(`#${df(r.id)}`);!a||a.tagName!==r.tagName||this.root.activeElement===a||(a.focus(),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&mf(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&sr(this.context),this.context=or(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=$e(this.currentResponse),a=Zt(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&ar(this.context.budget);try{Ga(r,this.context)}catch(i){if(i instanceof Pe)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const n=[...this.context.effectDecls.values()];n.length>0&&this.effectRunner.syncEffects(n,()=>this.context),this.writeRouteState(),this.parseErrors=[...r.errors.map(i=>`Line ${i.line}: ${i.message}`),...this.effectRunner.getErrors()],this.updateErrorBanner(),r.errors.length>0&&!this.streaming&&this.dispatchEvent(new CustomEvent("error",{detail:{errors:r.errors},bubbles:!0,composed:!0}))}updateErrorBanner(){if(!this.showErrors||this.streaming||this.parseErrors.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const r=document.createElement("div");r.textContent=`${this.parseErrors.length} parse issue${this.parseErrors.length===1?"":"s"} (rendered partial UI):`;const a=document.createElement("ul");for(const n of this.parseErrors.slice(0,5)){const i=document.createElement("li");i.textContent=n,a.append(i)}this.errorEl.replaceChildren(r,a)}}D(mt,"tagName","aktion-app");function df(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const pf=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function mf(t,e,r,a){if(t instanceof HTMLInputElement&&pf.has(t.type)){const n=t.type;try{t.type="text",t.setSelectionRange(e,r,a)}catch{}finally{t.type=n}return}try{t.setSelectionRange(e,r,a)}catch{}}function $i(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===Qe}function Ti(){customElements.get(mt.tagName)||customElements.define(mt.tagName,mt)}const ff=t=>{const e={name:t.name,type:t.type,required:!t.optional};return t.description&&(e.description=t.description),t.enum&&t.enum.length>0&&(e.enumValues=t.enum),e},gf=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},hf=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const a of r.components)e.set(a,r.name);return e};function Ai(t=dt){const e=hf(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(ff),signature:gf(r)}))}function Ni(t){const e={};for(const r of t)e[r.name]=r;return e}const bf=[{name:"App",description:"Top-level `aktion` binding — every program needs one.",template:'aktion = Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n])'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
|
|
8386
|
+
`,Ur="theme",pt="streaming",Hr="response",Qe="showerrors",Ai="route";function ff(t){const e=t.getPath(),r={...t.getParams()},a=t.getActivePattern(),n={};if(typeof window<"u"&&window.location){const i=window.location.search||"";if(i){const o=new URLSearchParams(i.startsWith("?")?i.slice(1):i);for(const[s,u]of o)n[s]=u}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function gf(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,a=e;return r.path!==a.path||r.pattern!==a.pattern?!1:Ni(r.params??{},a.params??{})&&Ni(r.query??{},a.query??{})}function Ni(t,e){const r=Object.keys(t),a=Object.keys(e);if(r.length!==a.length)return!1;for(const n of r)if(t[n]!==e[n])return!1;return!0}let Vr=null,Wt=null;function hf(){if(Wt===!1)return null;if(Vr)return Vr;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Wt=!1,null;const t=new CSSStyleSheet;return t.replaceSync(Ti),Vr=t,Wt=!0,t}catch{return Wt=!1,null}}class mt extends HTMLElement{constructor(){super();j(this,"state",new Ia);j(this,"router",new Oa);j(this,"library",dt);j(this,"http",new Ea);j(this,"effectRunner");j(this,"actionDeclRunner");j(this,"renderer");j(this,"context");j(this,"root");j(this,"rootEl");j(this,"errorEl");j(this,"currentResponse","");j(this,"pendingCompiled",null);j(this,"compiledSourceId",null);j(this,"renderScheduled",!1);j(this,"programDirty",!0);j(this,"lastRenderDeps",null);j(this,"pendingChangedPaths",new Set);j(this,"forceFullRender",!1);j(this,"parseErrors",[]);j(this,"scriptThemeKeys",[]);j(this,"warnedStateWriteDuringRender",!1);this.root=this.attachShadow({mode:"open"}),this.errorEl=document.createElement("div"),this.errorEl.className="rui-error-banner",this.errorEl.hidden=!0,this.rootEl=document.createElement("div"),this.rootEl.className="rui-root";const r=hf();if(r)try{this.root.adoptedStyleSheets=[r],this.root.append(this.errorEl,this.rootEl)}catch{this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl)}else this.root.append(this.buildInlineStyle(),this.errorEl,this.rootEl);const a=n=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:n},bubbles:!0,composed:!0}))};this.effectRunner=new hn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.actionDeclRunner=new yn({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onAssistantMessage:a}),this.context=cr(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i)}),this.renderer=new di({library:this.library,state:this.state,router:this.router,onAssistantMessage:a,evaluationContext:()=>this.context,mountInstanceEffects:(n,i,o)=>this.effectRunner.syncInstanceEffects(n,i,o),unmountInstanceEffects:n=>this.effectRunner.unmountInstance(n),unmountInstanceHooks:n=>pn(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);(this.lastRenderDeps===null||yt(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[Ur,pt,Hr,Qe]}connectedCallback(){Gs(this.root),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(Hr);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}if(!this.currentResponse){const a=(this.textContent??"").trim();if(a){this.setResponse(a);return}}this.currentResponse&&(this.programDirty=!0,this.scheduleRender())}disconnectedCallback(){this.effectRunner.reset(),this.context&&ur(this.context),this.router.stop()}attributeChangedCallback(r,a,n){if(r===Ur&&this.applyThemeFromAttribute(),r===pt&&(this.updateErrorBanner(),this.scheduleRender()),r===Qe&&this.updateErrorBanner(),r===Hr){const i=n??"";i!==this.currentResponse&&this.setResponse(i)}}registerHttpInterceptors(r){this.http.registerInterceptors(r)}setResponse(r){r!==this.currentResponse&&(this.currentResponse=r,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const a=this.state.snapshot(),n=fo(this.currentResponse,r);return Object.assign(a,n.stateUpdates),this.loadSnapshot({programText:n.programText,state:a}),n.warnings}loadSnapshot(r){this.currentResponse=r.programText,this.pendingCompiled=null,this.compiledSourceId=null,this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],this.state.hydrate(r.state),this.scheduleRender()}mountCompiled(r,a){if(!ba(r)){console.error("[aktion] mountCompiled() expected a CompiledProgram (from the aktion-runtime Vite plugin or compile()); ignoring the call.");return}this.currentResponse=r.source,this.compiledSourceId=r.path,this.pendingCompiled={...r.program,errors:[...r.program.errors]},this.programDirty=!0,this.state.rebind([]),this.renderer.reset(),this.parseErrors=[],a&&this.state.hydrate(a),this.scheduleRender()}get sourceId(){return this.compiledSourceId}appendChunk(r){if(r==null)return;const a=typeof r=="string"?r:String(r);a!==""&&(this.currentResponse+=a,this.programDirty=!0,this.scheduleRender())}setTheme(r){_r(this,Or(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=xa(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return jr(this.library,r??{})}navigate(r){this.router.navigate(r)}get route(){return this.router.getPath()}clear(){this.currentResponse="",this.pendingCompiled=null,this.compiledSourceId=null,this.state.rebind([]),this.effectRunner.reset(),this.renderer.reset(),this.programDirty=!0,this.parseErrors=[],this.errorEl.hidden=!0,this.errorEl.replaceChildren(),this.rootEl.replaceChildren(),this.router.setActiveMatch(null,{})}get response(){return this.currentResponse}set response(r){this.setResponse(r)}get streaming(){return Mi(this.getAttribute(pt))}set streaming(r){r?this.setAttribute(pt,"true"):this.removeAttribute(pt)}get showErrors(){return Mi(this.getAttribute(Qe))}set showErrors(r){r?this.setAttribute(Qe,"true"):this.removeAttribute(Qe)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}buildInlineStyle(){const r=document.createElement("style");return r.textContent=Ti,r}startRouter(){this.router.start(),this.writeRouteState()}writeRouteState(){const r=ff(this.router);gf(this.state.get(Ai),r)||this.state.set(Ai,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(Ur);_r(this,Or(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(Si(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Na(a))return;const n=Ci(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=ki(this,n))}scheduleRender(){this.renderScheduled||(this.renderScheduled=!0,queueMicrotask(()=>this.renderNow()))}requestFullRender(){this.forceFullRender=!0,this.scheduleRender()}renderNow(){if(this.renderScheduled=!1,!this.isConnected)return;this.programDirty&&(this.replan(),this.programDirty=!1),this.context.budget&&or(this.context.budget);const r=new Set,a=this.context.trackedState;this.context.trackedState=r;let n=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),Xa(this.context);const i=this.context.bindings.get("aktion");let o=null;if(i)try{o=i()}catch(d){if(d instanceof Pe){this.handleRuntimeBudgetError(d);return}console.error("[aktion] entry point evaluation error",d)}const s=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const u=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:s,memoize:u});const c=this.captureFocus();let m;try{m=this.renderer.render(o)}catch(d){if(this.renderer.endRender(),d instanceof Pe){this.handleRuntimeBudgetError(d);return}throw d}Am(this.rootEl,m),this.renderer.endRender(),this.restoreFocus(c),n=!0}finally{this.context.trackedState=a,this.lastRenderDeps=n?r:null,this.state.endRenderPass()&&this.warnStateWriteDuringRender()}}warnStateWriteDuringRender(){this.warnedStateWriteDuringRender||(this.warnedStateWriteDuringRender=!0,console.warn("[aktion] A reactive `$state` write happened during render and was applied WITHOUT scheduling a re-render, to prevent an infinite render loop. This usually means a `$name = …` assignment is running in render position — e.g. `$user = {…}` at the top of a lowercase `function` that's invoked to build the UI (`aktion = app()`), where the function runs as an action and re-writes the atom every render. Seed component-local state with a PascalCase component (so `$name = …` becomes a set-once per-instance declaration) or the `$state` hook, and only write state from event handlers / effects."))}handleRuntimeBudgetError(r){const a=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(a)||(this.parseErrors=[...this.parseErrors,a]),this.updateErrorBanner(),this.streaming||this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r.message}]},bubbles:!0,composed:!0}))}captureFocus(){const r=this.root.activeElement;if(!r||!this.rootEl.contains(r))return null;const a=r.id||null;if(!a)return null;const n={id:a,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(n.selectionStart=r.selectionStart,n.selectionEnd=r.selectionEnd,n.selectionDirection=r.selectionDirection??null),n}restoreFocus(r){if(!r)return;const a=this.rootEl.querySelector(`#${bf(r.id)}`);!a||a.tagName!==r.tagName||this.root.activeElement===a||(a.focus(),(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&yf(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&ur(this.context),this.context=cr(this.state,{router:this.router,library:this.library,http:this.http,actionRunner:this.actionDeclRunner,notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=this.pendingCompiled??Ce(this.currentResponse);this.pendingCompiled=null;const a=tr(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&or(this.context.budget);try{Ja(r,this.context)}catch(i){if(i instanceof Pe)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const n=[...this.context.effectDecls.values()];n.length>0&&this.effectRunner.syncEffects(n,()=>this.context),this.writeRouteState(),this.parseErrors=[...r.errors.map(i=>`Line ${i.line}: ${i.message}`),...this.effectRunner.getErrors()],this.updateErrorBanner(),r.errors.length>0&&!this.streaming&&this.dispatchEvent(new CustomEvent("error",{detail:{errors:r.errors},bubbles:!0,composed:!0}))}updateErrorBanner(){if(!this.showErrors||this.streaming||this.parseErrors.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const r=document.createElement("div");r.textContent=`${this.parseErrors.length} parse issue${this.parseErrors.length===1?"":"s"} (rendered partial UI):`;const a=document.createElement("ul");for(const n of this.parseErrors.slice(0,5)){const i=document.createElement("li");i.textContent=n,a.append(i)}this.errorEl.replaceChildren(r,a)}}j(mt,"tagName","aktion-app");function bf(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const vf=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function yf(t,e,r,a){if(t instanceof HTMLInputElement&&vf.has(t.type)){const n=t.type;try{t.type="text",t.setSelectionRange(e,r,a)}catch{}finally{t.type=n}return}try{t.setSelectionRange(e,r,a)}catch{}}function Mi(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===Qe}function Pi(){customElements.get(mt.tagName)||customElements.define(mt.tagName,mt)}const xf=t=>{const e={name:t.name,type:t.type,required:!t.optional};return t.description&&(e.description=t.description),t.enum&&t.enum.length>0&&(e.enumValues=t.enum),e},wf=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},kf=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const a of r.components)e.set(a,r.name);return e};function Ii(t=dt){const e=kf(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(xf),signature:wf(r)}))}function Li(t){const e={};for(const r of t)e[r.name]=r;return e}const Sf=[{name:"App",description:"Top-level `aktion` binding — every program needs one.",template:'aktion = Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n])'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
|
|
8387
8387
|
CardHeader("\${2:Title}", { subtitle: "\${3:Subtitle}" }),
|
|
8388
8388
|
Column([
|
|
8389
8389
|
Text("\${4:Body copy goes here.}")
|
|
@@ -8477,5 +8477,5 @@ list = $users.map(u => \${1:UserCard}(u))`},{name:"Ternary",description:"Pick be
|
|
|
8477
8477
|
url: "\${2:https://api.example.com/items}",
|
|
8478
8478
|
method: "\${3:GET}",
|
|
8479
8479
|
headers: { "Content-Type": "application/json" }
|
|
8480
|
-
})`},{name:"State",description:"Reactive state atom — declared with `$name = value`.",template:'$${1:name} = ${2:"default"}'},{name:"Store",description:"Global store — colocated state + actions shared across components (like Zustand/Pinia).",template:"${1:cart} = $store({\n ${2:items}: [],\n ${3:count}: (s) => s.${2:items}.length,\n ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\n})"},{name:"useState",description:"`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).",template:'const [${1:value}, set${2:Value}] = $state(${3:"default"})'},{name:"useMemo",description:"`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).",template:"const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])"},{name:"Hook",description:"Custom hook declaration — a `$`-prefixed function that composes $state / $memo.",template:"function $use${1:Counter}(${2:start}) {\n const [${3:count}, set${4:Count}] = $state(${2:start})\n return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\n}"},{name:"ResponsiveGrid",description:"Grid with a responsive column map per breakpoint.",template:'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:l}" })'}];function
|
|
8480
|
+
})`},{name:"State",description:"Reactive state atom — declared with `$name = value`.",template:'$${1:name} = ${2:"default"}'},{name:"Store",description:"Global store — colocated state + actions shared across components (like Zustand/Pinia).",template:"${1:cart} = $store({\n ${2:items}: [],\n ${3:count}: (s) => s.${2:items}.length,\n ${4:add}: (s, item) => { s.${2:items} = [...s.${2:items}, item] },\n})"},{name:"useState",description:"`$state` hook — per-instance state with a [value, setValue] pair (like React's useState).",template:'const [${1:value}, set${2:Value}] = $state(${3:"default"})'},{name:"useMemo",description:"`$memo` hook — value recomputed only when a dependency changes (like React's useMemo).",template:"const ${1:memoized} = $memo(() => ${2:compute}, [${3:deps}])"},{name:"Hook",description:"Custom hook declaration — a `$`-prefixed function that composes $state / $memo.",template:"function $use${1:Counter}(${2:start}) {\n const [${3:count}, set${4:Count}] = $state(${2:start})\n return { ${3:count}: ${3:count}, increment: () => set${4:Count}(v => v + 1) }\n}"},{name:"ResponsiveGrid",description:"Grid with a responsive column map per breakpoint.",template:'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:l}" })'}];function Ri(){return Sf}function Cf(t=dt){const e=Ii(t);return{grammar:vt,tokenizer:$a(vt),tagMap:Ta,components:e,componentsByName:Li(e),snippets:Ri(),keywordDocs:Ca,themeNames:Object.keys(Fr),severityTokenMap:{"parse-error":"error"},iconAliases:$f}}const $f=["house","user","users","gear","bell","envelope","magnifying-glass","plus","minus","pen","trash","check","xmark","arrow-right","arrow-left","arrow-up","arrow-down","chevron-right","chevron-left","chevron-down","chevron-up","ellipsis","ellipsis-vertical","star","heart","bookmark","calendar","clock","file","folder","image","video","music","chart-line","chart-bar","chart-pie","gauge","table","circle-info","circle-check","circle-exclamation","circle-question","triangle-exclamation","shield","lock","unlock","key","rocket","bolt","fire","snowflake","sun","moon","cloud","code","terminal","database","server","globe","link","share","download","upload","filter","sort","list","grid","columns","sidebar","bars","tag","tags","flag","trophy","medal","gift","cart-shopping","credit-card","money-bill","receipt","wallet","comment","comments","paper-plane","inbox","paper-clip","phone","video-camera","play","pause","stop","forward","backward","expand","compress","eye","eye-slash","thumbs-up","thumbs-down","thumbtack"];Pi();const Tf=jr(dt);P.ActionDeclRunner=yn,P.AktionElement=mt,P.BreakSignal=we,P.COMPILED_PROGRAM_VERSION=Xt,P.ContinueSignal=$e,P.DEFAULT_RUNTIME_BUDGET=kt,P.EffectRunner=hn,P.HttpRuntime=Ea,P.Renderer=di,P.ReturnSignal=Ie,P.Router=Oa,P.RuntimeBudgetError=Pe,P.SYSTEM_PROMPT_TEXT=Tf,P.StateStore=Ia,P.anyPathAffects=rr,P.applyPartialTheme=ki,P.applyTheme=_r,P.assertOnePositionalMax=wa,P.brutalistTheme=xi,P.buildFrontier=ga,P.builtInThemes=Fr,P.clearInstanceHooks=pn,P.clearTokenOverrides=Si,P.compileLite=mo,P.computeFrontier=lo,P.consoleNs=Wa,P.createContext=cr,P.createHttpResource=za,P.createI18n=Da,P.createRuntimeBudget=Ga,P.createStreamTokenizer=$a,P.darkTheme=hi,P.dataBuiltins=Aa,P.defaultLibrary=dt,P.defaultTagMap=Ta,P.defineCompiledProgram=po,P.defineElement=Pi,P.describeComponentSpec=Em,P.disposeContext=ur,P.enterUserComponent=sr,P.evaluate=N,P.evaluateUserComponent=on,P.extractStatePath=Ct,P.findComponent=Ne,P.findPositionalIndex=Qt,P.findPositionalProp=er,P.generatePrompt=jr,P.getComponentCatalog=Ii,P.getLanguageSpec=Cf,P.getSnippets=Ri,P.glassTheme=yi,P.grammarSpec=vt,P.indexCatalog=Li,P.isCompiledProgram=ba,P.isComponentNode=Ka,P.isEndpointResource=Ra,P.isQuiescent=co,P.isStoreHandle=St,P.isThemeNode=Na,P.isUserComponentNode=Ya,P.joinStatePath=Ma,P.keywordDocs=Ca,P.leaveUserComponent=lr,P.lightTheme=be,P.mapPositionalArgs=ka,P.matchRoute=Fa,P.mergeLibraries=xa,P.neonTheme=bi,P.normalisePath=je,P.parse=Ce,P.pastelTheme=vi,P.pathAffects=Pa,P.pathsOverlap=yt,P.planProgram=Ja,P.resetMutableBindings=Xa,P.resetRuntimeBudget=or,P.resolvePatternBindings=ot,P.resolveStateAlias=xe,P.resolveTheme=Or,P.runControlFlowStatement=Nt,P.sanitiseThemeTokens=Ci,P.skylineTheme=wi,P.storage=nr,P.tokenize=Gr,P.validateProgram=vo,P.validateProgramSchema=tr,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|
|
8481
8481
|
//# sourceMappingURL=aktion.umd.cjs.map
|