aktion-runtime 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +90 -114
  2. package/dist/aktion.iife.js +106 -460
  3. package/dist/aktion.iife.js.map +1 -1
  4. package/dist/aktion.js +5530 -5076
  5. package/dist/aktion.js.map +1 -1
  6. package/dist/aktion.umd.cjs +106 -460
  7. package/dist/aktion.umd.cjs.map +1 -1
  8. package/dist/devtools.js +1367 -0
  9. package/dist/devtools.js.map +1 -0
  10. package/dist/{node/index-8OvnOYPI.js → language.js} +13669 -12428
  11. package/dist/language.js.map +1 -0
  12. package/dist/plugin.cjs +2650 -0
  13. package/dist/plugin.cjs.map +1 -0
  14. package/dist/plugin.js +2650 -0
  15. package/dist/plugin.js.map +1 -0
  16. package/dist/system_prompt.txt +164 -447
  17. package/dist/system_prompt_chat.txt +33 -84
  18. package/dist/{node/index-DBgA3bHQ.cjs → testing.js} +28116 -12689
  19. package/dist/testing.js.map +1 -0
  20. package/dist/types/aktion-modules.d.ts +6 -10
  21. package/dist/types/compiler/index.d.ts +9 -11
  22. package/dist/types/compiler/linker.d.ts +11 -11
  23. package/dist/types/compiler/project.d.ts +45 -0
  24. package/dist/types/compiler/runtime.d.ts +22 -26
  25. package/dist/types/devtools/hook.d.ts +88 -0
  26. package/dist/types/devtools/index.d.ts +35 -0
  27. package/dist/types/devtools/panel.d.ts +109 -0
  28. package/dist/types/devtools/protocol.d.ts +130 -0
  29. package/dist/types/devtools/styles.d.ts +7 -0
  30. package/dist/types/element.d.ts +56 -24
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/language-api.d.ts +8 -8
  33. package/dist/types/parser/types.d.ts +8 -8
  34. package/dist/types/plugin/index.d.ts +13 -6
  35. package/dist/types/renderer/renderer.d.ts +28 -0
  36. package/dist/types/runtime/builtins.d.ts +5 -11
  37. package/dist/types/runtime/effects.d.ts +15 -0
  38. package/dist/types/runtime/http.d.ts +0 -1
  39. package/dist/types/testing/index.d.ts +201 -0
  40. package/dist/types/theme/index.d.ts +3 -3
  41. package/dist/types/theme/styles.d.ts +1 -1
  42. package/dist/types/tooling/formatter.d.ts +7 -1
  43. package/dist/types/tooling/index.d.ts +0 -3
  44. package/package.json +21 -19
  45. package/dist/node/compile-BUw0GAvN.cjs +0 -491
  46. package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
  47. package/dist/node/compile-DxttTzo8.js +0 -492
  48. package/dist/node/compile-DxttTzo8.js.map +0 -1
  49. package/dist/node/compiler.cjs +0 -11
  50. package/dist/node/compiler.cjs.map +0 -1
  51. package/dist/node/compiler.js +0 -11
  52. package/dist/node/compiler.js.map +0 -1
  53. package/dist/node/index-8OvnOYPI.js.map +0 -1
  54. package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
  55. package/dist/node/language.cjs +0 -1244
  56. package/dist/node/language.cjs.map +0 -1
  57. package/dist/node/language.js +0 -1244
  58. package/dist/node/language.js.map +0 -1
  59. package/dist/node/vite.cjs +0 -65
  60. package/dist/node/vite.cjs.map +0 -1
  61. package/dist/node/vite.js +0 -65
  62. package/dist/node/vite.js.map +0 -1
  63. package/dist/types/compiler/compile.d.ts +0 -54
  64. package/dist/types/compiler/emit.d.ts +0 -15
  65. package/dist/types/compiler/sourcemap.d.ts +0 -40
  66. package/dist/types/library/components/theme.d.ts +0 -2
  67. package/dist/types/plugin/vite.d.ts +0 -21
  68. package/dist/types/tooling/codemod.d.ts +0 -36
@@ -1,19 +1,76 @@
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
- `?(a+=1,n=1):n+=1,u};for(;r<t.length;){const u=i();if(u===void 0)break;if(u===`
3
- `){const h=a,b=n;s(),o("Newline",`
4
- `,h,b);continue}if(u===" "||u===" "||u==="\r"){s();continue}if(u==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
5
- `;)s();continue}if(u==="/"&&i(1)==="*"){for(s(),s();r<t.length&&!(i()==="*"&&i(1)==="/");)s();r<t.length&&(s(),s());continue}if(u===";"){const h=a,b=n;s(),o("Semicolon",";",h,b);continue}if(u==='"'||u==="'"){const h=u,b=a,v=n;s();let y="";for(;r<t.length&&i()!==h;){if(i()==="\\"&&i(1)!==void 0){s();const x=s();switch(x){case"n":y+=`
1
+ (function(P,fe){typeof exports=="object"&&typeof module<"u"?fe(exports):typeof define=="function"&&define.amd?define(["exports"],fe):(P=typeof globalThis<"u"?globalThis:P||self,fe(P.Aktion={}))})(this,function(P){"use strict";var pg=Object.defineProperty;var mg=(P,fe,Ye)=>fe in P?pg(P,fe,{enumerable:!0,configurable:!0,writable:!0,value:Ye}):P[fe]=Ye;var D=(P,fe,Ye)=>mg(P,typeof fe!="symbol"?fe+"":fe,Ye);const fe=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"]),Ye=new Set(["(",")","[","]","{","}",",",":","?","."]),eo={true:"Boolean",false:"Boolean",null:"Null"};function na(t){const e=[];let r=0,a=1,n=1;const i=(c=0)=>t[r+c],o=(c,u,p,d)=>{e.push({type:c,value:u,line:p,column:d})},s=()=>{const c=t[r];return r+=1,c===`
2
+ `?(a+=1,n=1):n+=1,c};for(;r<t.length;){const c=i();if(c===void 0)break;if(c===`
3
+ `){const b=a,h=n;s(),o("Newline",`
4
+ `,b,h);continue}if(c===" "||c===" "||c==="\r"){s();continue}if(c==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
5
+ `;)s();continue}if(c==="/"&&i(1)==="*"){for(s(),s();r<t.length&&!(i()==="*"&&i(1)==="/");)s();r<t.length&&(s(),s());continue}if(c===";"){const b=a,h=n;s(),o("Semicolon",";",b,h);continue}if(c==='"'||c==="'"){const b=c,h=a,v=n;s();let y="";for(;r<t.length&&i()!==b;){if(i()==="\\"&&i(1)!==void 0){s();const x=s();switch(x){case"n":y+=`
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
- `)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
- `;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&&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(`
7
+ `)break;y+=s()}i()===b&&s(),o("String",y,h,v);continue}if(c==="`"){const b=a,h=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
+ `;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 T=1,S="";for(;r<t.length&&T>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($==="{"){T+=1,S+=s();continue}if($==="}"){if(T-=1,T===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,b,h);continue}e.push({type:"TemplateString",value:"",line:b,column:h,parts:v});continue}const u=e[e.length-1],p=!u||u.type==="Newline"||u.type==="Semicolon"||u.type==="Operator"||u.type==="Punctuation"&&(u.value==="("||u.value==="["||u.value===","||u.value===":"||u.value==="?"||u.value==="{");if(Ie(c)||c==="-"&&Ie(i(1)??"")&&p||c==="."&&Ie(i(1)??"")&&p){const b=a,h=n;let v="";c==="-"&&(v+=s());const y=i(1);if(i()==="0"&&(y==="x"||y==="X"||y==="b"||y==="B"||y==="o"||y==="O")){for(v+=s(),v+=s();r<t.length;){const k=i()??"";if(ia(k)){v+=s();continue}if(k==="_"&&ia(i(1)??"")){v+=s();continue}break}o("Number",v,b,h);continue}let x=!1,w=!1;for(;r<t.length;){const k=i()??"";if(Ie(k)){v+=s();continue}if(k==="_"&&Ie(i(1)??"")){v+=s();continue}if(k==="."&&!x&&!w&&Ie(i(1)??"")){x=!0,v+=s();continue}if((k==="e"||k==="E")&&!w){const T=i(1)??"",S=T==="+"||T==="-"?i(2)??"":T;if(Ie(S)){w=!0,v+=s(),(i()==="+"||i()==="-")&&(v+=s());continue}}break}o("Number",v,b,h);continue}if(c==="$"){const b=a,h=n;s();let v="";for(;r<t.length&&sa(i()??"");)v+=s();o("StateIdentifier",v,b,h);continue}if(oa(c)){const b=a,h=n;let v="";for(;r<t.length&&sa(i()??"");)v+=s();const y=eo[v];y==="Boolean"?o("Boolean",v,b,h):y==="Null"?o("Null",v,b,h):fe.has(v)?o("Keyword",v,b,h):o("Identifier",v,b,h);continue}if(c==="."&&i(1)==="."&&i(2)==="."){const b=a,h=n;s(),s(),s(),o("Operator","...",b,h);continue}const d=c+(i(1)??""),f=d+(i(2)??""),g=f+(i(3)??"");if(g===">>>="){const b=a,h=n;s(),s(),s(),s(),o("Operator",g,b,h);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const b=a,h=n;s(),s(),s(),o("Operator",f,b,h);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 b=a,h=n;s(),s(),o("Operator",d,b,h);continue}if("+-*/%!=<>&|^~".includes(c)){const b=a,h=n;s(),o("Operator",c,b,h);continue}if(Ye.has(c)){const b=a,h=n;s(),o("Punctuation",c,b,h);continue}s()}return e.push({type:"EOF",value:"",line:a,column:n}),e}function Ie(t){return t>="0"&&t<="9"}function ia(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}function oa(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function sa(t){return oa(t)||Ie(t)}function ge(t){const e=na(t),r=new so(e),a=[],n=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=kt(r,!0);i&&a.push(i)}catch(i){const o=i;n.push(o),r.recoverToNextLine()}return{statements:a,errors:n}}function kt(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return ro(t);if(r.type==="Keyword")switch(r.value){case"function":return St(t);case"import":return lo(t);case"export":return co(t);case"await":return io(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),St(t);break}case"return":return oo(t);case"let":case"const":case"var":return er(t);case"if":return Ca(t);case"switch":return bo(t);case"for":return vo(t);case"while":return xo(t);case"do":return wo(t);case"break":return ko(t);case"continue":return So(t);case"throw":return Co(t);case"try":return $o(t)}const a=t.snapshot();if(la(t))try{return pa(t)}catch(n){if(n&&typeof n=="object"&&n.__definitive)throw n;t.restore(a)}return to(t)}function la(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 to(t){const e=t.peek();let r=F(t);const a=t.peek();if(a.type==="Operator"&&ca(a.value)){if(ua(r)){t.consume();const n=F(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==="--")&&ua(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 ca(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function ua(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function St(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",a=r?t.consume():t.expect("Identifier"),n=da(t),i=_e(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 da(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=tr(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=F(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=F(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 ro(t){const e=t.consume();t.expect("Punctuation","("),z(t);const r=F(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==="]");)ao(t,n,s=>{i=s}),z(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),z(t));t.expect("Punctuation","]")}else F(t);z(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 ao(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 er(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return no(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=F(t);return re(t),{kind:"Assignment",identifier:a,isState:n,expression:i,loc:{line:e.line,column:e.column}}}function no(t,e){const r=tr(t);t.expect("Operator","=");const a=F(t);return re(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:a,loc:{line:e.line,column:e.column}}}function tr(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=F(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 p=t.expect("Identifier");s=i.value,o=p.value}let c;!n&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),c=F(t));const u={name:o};if(s&&(u.sourceKey=s),n&&(u.rest=!0),c&&(u.defaultValue=c),a.push(u),z(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),z(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:a}}function _e(t){const e=t.expect("Punctuation","{"),r=[];for(z(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const a=kt(t);a&&r.push(a),z(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function Xe(t){if(z(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return _e(t);const e=t.peek(),r=kt(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function io(t){const e=t.expect("Keyword","await"),r=F(t);return re(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function oo(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=F(t)),re(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class so{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 pa(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=F(t);return re(t),{kind:"Assignment",identifier:r,isState:a,expression:i,loc:{line:n.line,column:n.column}}}function lo(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 c=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const u=t.peek();let p=!1;if(u.type==="StateIdentifier")c=t.consume().value,p=!0;else if(u.type==="Identifier")c=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${u.type} "${u.value}"`,line:u.line,column:u.column};if(p!==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:u.line,column:u.column}}if(r.push(s?{imported:o,local:c,isState:!0}:{imported:o,local:c}),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 co(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=St(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),a=St(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(a=er(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(la(t))a=pa(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 F(t){return po(t)}function uo(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function de(t,e){const{token:r,skipped:a}=uo(t);if(!e(r))return!1;for(let n=0;n<a;n+=1)t.consume();return!0}function po(t){const e=mo(t);if(de(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),z(t);const r=F(t);z(t),t.expect("Punctuation",":"),z(t);const a=F(t);return{kind:"Ternary",test:e,consequent:r,alternate:a}}return e}function mo(t){let e=ma(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;z(t);const a=ma(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ma(t){let e=fa(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),z(t);const r=fa(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function fa(t){let e=ga(t);for(;de(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),z(t);const r=ga(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function ga(t){let e=ha(t);for(;de(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),z(t);const r=ha(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function ha(t){let e=ba(t);for(;de(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),z(t);const r=ba(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function ba(t){let e=va(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;z(t);const a=va(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function va(t){let e=rr(t);for(;;){if(de(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;z(t);const a=rr(t);e={kind:"Binary",operator:r,left:e,right:a};continue}if(de(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;z(t);const a=rr(t);e={kind:"Binary",operator:r,left:e,right:a};continue}break}return e}function rr(t){let e=ya(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;z(t);const a=ya(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ya(t){let e=xa(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;z(t);const a=xa(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function xa(t){let e=ar(t);for(;de(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;z(t);const a=ar(t);e={kind:"Binary",operator:r,left:e,right:a}}return e}function ar(t){const e=it(t);if(de(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),z(t);const r=ar(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function it(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=it(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:[it(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:[it(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=it(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=ka(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=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),a=Me(t),t.expect("Punctuation",")"))}const n={kind:"New",callee:r,arguments:a,loc:{line:e.line,column:e.column}};return wa(t,n)}return fo(t)}function fo(t){const e=go(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 go(t){return wa(t,ka(t))}function wa(t,e){let r=e;for(;;){de(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=Me(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=F(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=Me(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=Me(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=F(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:n};continue}if(a.type==="Punctuation"&&a.value==="("){t.consume();const n=Me(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:n,loc:{line:a.line,column:a.column}};continue}break}return r}function ka(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=da(t),s=_e(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=Me(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:No(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 c of r){if(c.kind==="str"){i+=c.text,o=!0;continue}o?s():a.push("");const p=ge(`__rui_tmpl__ = ${c.source}`).statements[0];p&&p.kind==="Assignment"?n.push(p.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(),ho(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=$a(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=Me(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=Me(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=To(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),a=Ao(t);if(a)return a;t.restore(r),t.consume();const n=F(t);return t.expect("Punctuation",")"),n}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function ho(t,e){t.consume();const r=Me(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Me(t){const e=[];if(z(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(Sa(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(Sa(t)),z(t);return z(t),e}function Sa(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:F(t),loc:{line:e.line,column:e.column}}}return F(t)}function Ca(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Xe(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=Xe(t)),re(t),{kind:"IfStatement",test:r,consequent:a,alternate:n,loc:{line:e.line,column:e.column}}}function bo(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=F(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=F(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=kt(t);o&&i.push(o),z(t)}a.push({test:n,body:i}),z(t)}return t.expect("Punctuation","}"),re(t),{kind:"SwitchStatement",discriminant:r,cases:a,loc:{line:e.line,column:e.column}}}function vo(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),z(t);const r=t.snapshot();let a="for-of";{let u=1,p=0;for(;;){const d=t.peek(p);if(d.type==="EOF")break;if(d.type==="Punctuation"&&d.value==="(")u+=1;else if(d.type==="Punctuation"&&d.value===")"){if(u-=1,u===0)break}else if(u===1&&d.type==="Semicolon"){a="classic";break}else if(u===1&&d.type==="Keyword"&&d.value==="of"){a="for-of";break}else if(u===1&&d.type==="Keyword"&&d.value==="in"){a="for-in";break}p+=1}}if(t.restore(r),a==="classic")return yo(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 u=[];for(;!(t.peek().type==="Punctuation"&&t.peek().value==="}");)u.push(t.expect("Identifier").value),t.peek().type==="Punctuation"&&t.peek().value===","&&t.consume();t.expect("Punctuation","}"),n="__row",o=u}else n=t.expect("Identifier").value;a==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=F(t);t.expect("Punctuation",")");const c=Xe(t);return re(t),a==="for-in"?{kind:"ForInStatement",item:n,iterable:s,body:c,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:n,index:i,destructure:o,iterable:s,body:c,loc:{line:e.line,column:e.column}}}function yo(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=er(t);o.kind==="Assignment"&&(r=o),z(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:F(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=F(t)),t.expect("Semicolon"),z(t);let n;t.peek().type==="Punctuation"&&t.peek().value===")"||(n=Aa(t)),t.expect("Punctuation",")");const i=Xe(t);return re(t),{kind:"ForClassicStatement",init:r,test:a,update:n,body:i,loc:{line:e.line,column:e.column}}}function xo(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=F(t);t.expect("Punctuation",")");const a=Xe(t);return re(t),{kind:"WhileStatement",test:r,body:a,loc:{line:e.line,column:e.column}}}function wo(t){const e=t.expect("Keyword","do"),r=Xe(t);z(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const a=F(t);return t.expect("Punctuation",")"),re(t),{kind:"DoWhileStatement",test:a,body:r,loc:{line:e.line,column:e.column}}}function ko(t){const e=t.expect("Keyword","break");return re(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function So(t){const e=t.expect("Keyword","continue");return re(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function Co(t){const e=t.expect("Keyword","throw"),r=F(t);return re(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function $o(t){const e=t.expect("Keyword","try"),r=_e(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=_e(t),z(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=_e(t)),re(t),{kind:"TryStatement",block:r,catchParam:a,catchBlock:n,finallyBlock:i,loc:{line:e.line,column:e.column}}}function Ao(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=tr(t)}catch{return null}const c={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{c.defaultValue=F(t)}catch{return null}}if(r.push(c),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=F(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=$a(t);return{kind:"Lambda",params:r,body:a,loc:{line:e.line,column:e.column}}}function $a(t){return z(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?_e(t):Aa(t)}function Aa(t){const e=F(t),r=t.peek();if(r.type==="Operator"){if(ca(r.value)){t.consume();const a=F(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 To(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 c=F(t);if(e.push({key:"",value:c,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=F(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=F(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 re(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function No(t){let e=t.replace(/_/g,""),r=1;return e.startsWith("-")?(r=-1,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),r*Number(e)}function Mo(t){const e=ge(t);return Ta(t,e)}function Ta(t,e){const r=new Set(e.errors.map(s=>s.line)),a=[],n=[];for(const s of e.statements){const c=s.loc?.line??0;if(r.has(c)){n.push(s);continue}a.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(p=>p.line)),c=Io(t,s);i=c.before,o=c.after;const u=a.findIndex(p=>(p.loc?.line??0)>=s);if(u>=0)for(const p of a.splice(u))n.push(p)}return{committedSource:i,draftingSource:o,committedBindings:a.map(Na).filter(s=>s!==null),uncommittedBindings:n.map(Na).filter(s=>s!==null),committedStatements:a,errors:e.errors}}function Po(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 Na(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function Io(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 nr=1;function Ma(t){if(!t||typeof t!="object")return!1;const e=t;return e.__aktionCompiled===nr&&typeof e.source=="string"&&typeof e.path=="string"&&!!e.program&&Array.isArray(e.program.statements)}function Eo(t){return t}function Lo(t,e={}){const r=ge(t);return{__aktionCompiled:nr,program:r,source:t,path:e.path??"<inline>"}}const Te=" ",Pa=/^[A-Za-z_$][A-Za-z0-9_$]*$/,zo=/[\\"]/;function Ro(t){const e=[];let r=null;for(const a of t.statements)r&&Do(r,a)&&e.push(""),e.push(Je(a,0)),r=a;return e.join(`
11
+ `)+`
12
+ `}function Do(t,e){const r=new Set(["ComponentDeclaration","EffectDeclaration","ActionDeclaration","HookDeclaration"]);return!!(r.has(t.kind)||r.has(e.kind))}function Je(t,e){const r=Te.repeat(e),a="exported"in t&&t.exported?"export ":"";switch(t.kind){case"Import":{const n=t.specifiers.map(i=>{const o=i.isState?`$${i.imported}`:i.imported;if(i.local===i.imported)return o;const s=i.isState?`$${i.local}`:i.local;return`${o} as ${s}`}).join(", ");return`${r}import { ${n} } from "${t.source}"`}case"Assignment":{const n=t.isState?`$${t.identifier}`:t.identifier,i=H(t.expression,e);return`${r}${a}${n} = ${i}`}case"ComponentDeclaration":{const n=t.params.map(ir).join(", "),i=`${r}${a}function ${t.name}(${n}) {`,o=ue(t.body.body,e+1);return o.length>0?`${i}
13
+ ${o}
14
+ ${r}}`:`${i}
15
+ ${r}}`}case"EffectDeclaration":{const n=t.triggers.map(jo).filter(s=>s.length>0);t.rateLimit&&n.push(`"${t.rateLimit.kind}(${t.rateLimit.ms})"`);const i=ue(t.body.body,e+1),o=`[${n.join(", ")}]`;return`${r}$effect(() => {
16
+ ${i}
17
+ ${r}}, ${o})`}case"ActionDeclaration":{const n=t.params.map(ir).join(", "),i=`${r}${a}function ${t.name}(${n}) {`,o=ue(t.body.body,e+1);return`${i}
18
+ ${o}
19
+ ${r}}`}case"HookDeclaration":{const n=t.params.map(ir).join(", "),i=`${r}${a}function $${t.name}(${n}) {`,o=ue(t.body.body,e+1);return`${i}
20
+ ${o}
21
+ ${r}}`}case"Await":return`${r}await ${H(t.argument,e)}`;case"Return":return t.argument?`${r}return ${H(t.argument,e)}`:`${r}return`;case"ExpressionStatement":return`${r}${H(t.expression,e)}`;case"IfStatement":{const n=H(t.test,e),i=`{
22
+ ${ue(t.consequent.body,e+1)}
23
+ ${r}}`;if(!t.alternate)return`${r}if (${n}) ${i}`;const o=t.alternate.kind==="IfStatement"?Je(t.alternate,e).trimStart():`{
24
+ ${ue(t.alternate.body,e+1)}
25
+ ${r}}`;return`${r}if (${n}) ${i} else ${o}`}case"SwitchStatement":{const n=H(t.discriminant,e),i=t.cases.map(o=>Bo(o,e+1)).join(`
26
+ `);return`${r}switch (${n}) {
27
+ ${i}
28
+ ${r}}`}case"ForOfStatement":{const n=H(t.iterable,e),i=`{
29
+ ${ue(t.body.body,e+1)}
30
+ ${r}}`;return`${r}for (let ${t.item} of ${n}) ${i}`}case"ForClassicStatement":{const n=t.init?Je(t.init,0).trimStart():"",i=t.test?H(t.test,e):"",o=t.update?H(t.update,e):"",s=`{
31
+ ${ue(t.body.body,e+1)}
32
+ ${r}}`;return`${r}for (${n}; ${i}; ${o}) ${s}`}case"WhileStatement":{const n=H(t.test,e),i=`{
33
+ ${ue(t.body.body,e+1)}
34
+ ${r}}`;return`${r}while (${n}) ${i}`}case"DoWhileStatement":{const n=H(t.test,e),i=`{
35
+ ${ue(t.body.body,e+1)}
36
+ ${r}}`;return`${r}do ${i} while (${n})`}case"ForInStatement":{const n=H(t.iterable,e),i=`{
37
+ ${ue(t.body.body,e+1)}
38
+ ${r}}`;return`${r}for (let ${t.item} in ${n}) ${i}`}case"DestructureStatement":{const n=t.patternKind==="array"?"[":"{",i=t.patternKind==="array"?"]":"}",o=t.bindings.map(c=>{const u=c.rest?"...":"",p=c.sourceKey?`${c.sourceKey}: ${c.name}`:c.name||"",d=c.defaultValue?` = ${H(c.defaultValue,e)}`:"";return`${u}${p}${d}`}),s=H(t.expression,e);return`${r}let ${n}${o.join(", ")}${i} = ${s}`}case"BreakStatement":return`${r}break`;case"ContinueStatement":return`${r}continue`;case"ThrowStatement":return`${r}throw ${H(t.argument,e)}`;case"TryStatement":{const n=`{
39
+ ${ue(t.block.body,e+1)}
40
+ ${r}}`;let i=`${r}try ${n}`;if(t.catchBlock){const o=t.catchParam?` (${t.catchParam})`:"",s=`{
41
+ ${ue(t.catchBlock.body,e+1)}
42
+ ${r}}`;i+=` catch${o} ${s}`}if(t.finallyBlock){const o=`{
43
+ ${ue(t.finallyBlock.body,e+1)}
44
+ ${r}}`;i+=` finally ${o}`}return i}}}function ir(t){return t.defaultValue?`${t.name} = ${H(t.defaultValue,0)}`:t.name}function jo(t){return t.kind==="lifecycle"?`"${t.name}"`:t.kind==="every"?`"every(${t.intervalMs})"`:t.kind==="state"?`$${t.name}`:""}function ue(t,e){return t.map(r=>Je(r,e)).join(`
45
+ `)}function H(t,e){switch(t.kind){case"Literal":return Oo(t.value);case"Identifier":return t.name;case"StateRef":return`$${t.name}`;case"Array":{if(t.elements.length===0)return"[]";const r=t.elements.map(i=>H(i,e)),a=`[${r.join(", ")}]`;if(a.length<=80&&!r.some(i=>i.includes(`
46
+ `)))return a;const n=Te.repeat(e+1);return`[
47
+ ${r.map(i=>`${n}${i}`).join(`,
48
+ `)}
49
+ ${Te.repeat(e)}]`}case"Object":{if(t.properties.length===0)return"{}";const r=t.properties.map(i=>_o(i,e)),a=`{ ${r.join(", ")} }`;if(a.length<=80&&!r.some(i=>i.includes(`
50
+ `)))return a;const n=Te.repeat(e+1);return`{
51
+ ${r.map(i=>`${n}${i}`).join(`,
52
+ `)}
53
+ ${Te.repeat(e)}}`}case"Member":{const r=H(t.object,e),a=t.optional?"?.":".";if(t.property)return`${r}${a}${t.property}`;if(t.computed){const n=H(t.computed,e);return t.optional?`${r}?.[${n}]`:`${r}[${n}]`}return r}case"Unary":return`${t.operator}${H(t.argument,e)}`;case"Binary":return`${H(t.left,e)} ${t.operator} ${H(t.right,e)}`;case"Ternary":return`${H(t.test,e)} ? ${H(t.consequent,e)} : ${H(t.alternate,e)}`;case"Call":return ot(t.callee,t.arguments,e);case"MethodCall":{const r=H(t.object,e),a=t.optional?"?.":".";return ot(`${r}${a}${t.method}`,t.arguments,e)}case"Invoke":{const r=H(t.callee,e),a=t.optional?"?.":"";return ot(`${r}${a}`,t.arguments,e)}case"New":{const r=H(t.callee,e);return`new ${ot(r,t.arguments,e)}`}case"BuiltinCall":return ot(`@${t.name}`,t.arguments,e);case"Template":return Fo(t.quasis,t.expressions,e);case"Spread":return`...${H(t.argument,e)}`;case"Lambda":{const r=t.params.map(n=>{const i=n.rest?"...":"";return n.defaultValue?`${i}${n.name} = ${H(n.defaultValue,e)}`:`${i}${n.name}`}).join(", ");return`${t.params.length===1&&!t.params[0].defaultValue&&!t.params[0].rest?t.params[0].name:`(${r})`} => ${H(t.body,e)}`}case"Block":return`{
54
+ ${ue(t.body,e+1)}
55
+ ${Te.repeat(e)}}`}}function ot(t,e,r){if(e.length===0)return`${t}()`;const a=e.map(o=>H(o,r)),n=`${t}(${a.join(", ")})`;if(n.length<=80&&!a.some(o=>o.includes(`
56
+ `)))return n;const i=Te.repeat(r+1);return`${t}(
57
+ ${a.map(o=>`${i}${o}`).join(`,
58
+ `)}
59
+ ${Te.repeat(r)})`}function Bo(t,e){const r=Te.repeat(e),a=t.body.map(n=>Je(n,e+1)).join(`
60
+ `);return t.test===null?`${r}default:
61
+ ${a}
62
+ ${Je({kind:"ExpressionStatement",expression:{kind:"Identifier",name:"break"}},e+1)}`:`${r}case ${H(t.test,e)}:
63
+ ${a}
64
+ ${Te.repeat(e+1)}break`}function _o(t,e){if(t.spread)return`...${H(t.value,e)}`;const r=H(t.value,e);return t.value.kind==="Identifier"&&t.value.name===t.key&&Pa.test(t.key)?t.key:`${Pa.test(t.key)?t.key:Ia(t.key)}: ${r}`}function Oo(t){return t===null?"null":typeof t=="string"?Ia(t):typeof t=="boolean"?t?"true":"false":String(t)}function Ia(t){return zo.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`"${t}"`}function Fo(t,e,r){const a=[];for(let n=0;n<t.length;n+=1)a.push(t[n]??""),n<e.length&&(a.push("${"),a.push(H(e[n],r)),a.push("}"));return`\`${a.join("")}\``}function Uo(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=Ho(n,i);n=o.programText,o.warning&&r.push(o.warning)}return{programText:n,stateUpdates:a,warnings:r}}function Ho(t,e){const r=ge(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=ge(e.source);if(a.errors.length>0||a.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${Ea(e.source)}" — op skipped`};const n=t.endsWith(`
11
65
  `)?"":`
12
66
  `;return{programText:t+n+e.source.trim()+`
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
- `),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
- `):[...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 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(() => {
67
+ `}}case"delete":{const a=or(r,e.binding);return a<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:sr(t,r,a,null)}}case"replace":{const a=or(r,e.binding);return a<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:ge(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:sr(t,r,a,`${e.binding} = ${e.source.trim()}`)}}case"append":{const a=or(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=ge(`__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 "${Ea(e.item)}" — op skipped`};const s=n.expression.elements,c=`${e.binding} = [${[...s.map(he),e.item.trim()].join(", ")}]`;return{programText:sr(t,r,a,c)}}}}function or(t,e){return t.statements.findIndex(r=>Vo(r)===e)}function Vo(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function sr(t,e,r,a){const n=t.split(`
68
+ `),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,c=o?(o.loc?.line??n.length+1)-1:n.length,u=n.slice(0,s),p=n.slice(c);return a===null?[...u,...p].join(`
69
+ `):[...u,a,...p].join(`
70
+ `)}function he(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(he).join(", ")})`;case"MethodCall":return`${he(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(he).join(", ")})`;case"Array":return`[${t.elements.map(he).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${he(e.value)}`:`${e.key}: ${he(e.value)}`).join(", ")} }`;case"Member":{const e=he(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${he(t.computed)}]`:e}case"Binary":return`${he(t.left)} ${t.operator} ${he(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(he(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function Ea(t){return t.length>40?`${t.slice(0,37)}...`:t}const La=new WeakMap;function Wo(t){let e=La.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);La.set(t.components,e)}return e}function za(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 Ee(t,e){return Wo(t).get(e)}function lr(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function cr(t){const e=lr(t);return e>=0?t.props[e]:void 0}function Ra(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 Da(t,e){const r={};return t.props.forEach((a,n)=>{n<e.length&&(r[a.name]=e[n])}),r}function qo(t,e){const r=ge(t),a=ur(r,e);return a.length>0&&(r.errors=[...r.errors,...a]),r}function ur(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":V(t.expression,e,r);return;case"ExpressionStatement":V(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&&V(t.argument,e,r);return;case"Await":V(t.argument,e,r);return;case"IfStatement":V(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":V(t.discriminant,e,r);for(const a of t.cases){a.test&&V(a.test,e,r);for(const n of a.body)se(n,e,r)}return;case"ForOfStatement":V(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&&V(t.test,e,r),t.update&&V(t.update,e,r);for(const a of t.body.body)se(a,e,r);return;case"WhileStatement":case"DoWhileStatement":V(t.test,e,r);for(const a of t.body.body)se(a,e,r);return;case"ForInStatement":V(t.iterable,e,r);for(const a of t.body.body)se(a,e,r);return;case"DestructureStatement":V(t.expression,e,r);for(const a of t.bindings)a.defaultValue&&V(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":V(t.argument,e,r);return;default:return}}function V(t,e,r){if(t)switch(t.kind){case"Call":{Ko(t,e,r);for(const a of t.arguments)V(a,e,r);return}case"MethodCall":{V(t.object,e,r);for(const a of t.arguments)V(a,e,r);return}case"BuiltinCall":{for(const a of t.arguments)V(a,e,r);return}case"Array":for(const a of t.elements)V(a,e,r);return;case"Object":for(const a of t.properties)V(a.value,e,r);return;case"Template":for(const a of t.expressions)V(a,e,r);return;case"Binary":V(t.left,e,r),V(t.right,e,r);return;case"Unary":V(t.argument,e,r);return;case"Ternary":V(t.test,e,r),V(t.consequent,e,r),V(t.alternate,e,r);return;case"Member":V(t.object,e,r),t.computed&&V(t.computed,e,r);return;case"Spread":V(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&Jo(t,r),V(t.callee,e,r);for(const a of t.arguments)V(a,e,r);return;case"New":V(t.callee,e,r);for(const a of t.arguments)V(a,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const a of t.body.body)se(a,e,r);else V(t.body,e,r);return;case"Block":for(const a of t.body)se(a,e,r);return;default:return}}function Ko(t,e,r){const a=Ee(e,t.callee);if(!a)return;const n=new Set;for(const p of a.props)if(n.add(p.name),p.aliases)for(const d of p.aliases)n.add(d);n.add("key");const i=t.arguments;let o=-1;for(let p=i.length-1;p>=0;p-=1)if(i[p].kind==="Object"){o=p;break}const s=o>=0?i[o]:null,c=[];for(let p=0;p<i.length;p++)p!==o&&c.push(i[p]);if(c.length>1){const d=cr(a)?.name??"(none)",f=Go(i,s),g=a.props.filter(h=>h.name!==d&&!f.has(h.name)).slice(0,c.length-1).map(h=>h.name),b=g.length>0?g.map(h=>`${h}: …`).join(", "):"use a trailing { prop: value } object";r.push({message:`${t.callee}(...) — Aktion 0.5 §19.1 allows at most one positional argument (the "${d}" 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 u=[];if(s)for(const p of s.properties)p.spread||u.push({name:p.key,value:p.value,loc:p.value.loc??s.loc});for(const p of u){if(!n.has(p.name)){r.push({message:`Unknown prop "${p.name}" on <${t.callee}>. Known props: ${a.props.map(f=>f.name).join(", ")}.`,line:p.loc?.line??t.loc?.line??0,column:p.loc?.column??t.loc?.column??0});continue}const d=a.props.find(f=>f.name===p.name||(f.aliases?.includes(p.name)??!1));if(d?.enum&&p.value.kind==="Literal"&&typeof p.value.value=="string"){const f=p.value.value;d.enum.includes(f)||r.push({message:`<${t.callee}> ${p.name}="${f}" — must be one of ${d.enum.map(g=>`"${g}"`).join(", ")}.`,line:p.loc?.line??t.loc?.line??0,column:p.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 Yo=new Set(["colors","radius","font"]),Xo=new Set(["name","direction"]);function Jo(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const a of r.properties){if(a.spread||Yo.has(a.key)||Xo.has(a.key))continue;const n=Zo(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 Zo(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"}];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: {...} })"}const Ct={name:"aktion",atoms:["true","false","null","undefined"],keywords:["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","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:"$"}},ja={aktion:{summary:"Legacy entry-point binding — prefer the `$app(...)` builtin to register the root of the rendered UI tree.",syntax:"$app(Component(...))",example:'$app(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 }))'},import:{summary:"Import named bindings (components, actions, hooks, `$state`) from another `.aktion` file. Multi-file projects are linked in the browser.",syntax:'import { Name, Other as Alias, $shared } from "./module.aktion"',example:`import { Button } from "./Button.aktion"
71
+ import { $count } from "./store.aktion"`},export:{summary:"Mark a top-level declaration importable from another file. Anything not exported is private to its file.",syntax:"export function Name(...) { ... } · export $state = ... · export name = ...",example:`export function Card2({ title }) {
72
+ return Card([CardHeader(title)])
73
+ }`},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
74
  $now = $util.now()
18
75
  }, ["every(1000)"])`},if:{summary:"Conditional statement — run a block when a condition is truthy.",syntax:"if (condition) { ... } else { ... }",example:`if (!$user) {
19
76
  return Spinner()
@@ -36,472 +93,65 @@
36
93
  risky()
37
94
  } catch (e) {
38
95
  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 $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 (`![alt](src)`), 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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),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,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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(/&nbsp;/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(`
96
+ }`},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 Ba(t=Ct){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+)?/,c=new Set([...t.operators.join(""),..."=<>!&|"]),u=(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 b=d.next();if(b==="\\"){d.next();continue}if(b==="`")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 b=g;return d.next(),u(d,b),"string"}if(g===t.strings.multiLineQuote){for(d.next();!d.eol();){const b=d.next();if(b==="\\"){d.next();continue}if(b==="`")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 h=d.match(o,!0);if(h){const v=h[0];return a.has(v)?"atom":n.has(v)?"keyword":d.peek()==="."?"loopvar":"identifier"}}for(const b of t.operatorsLong)if(d.match(b,!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"):c.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 _a={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},Oa=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function Fa(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function Ua(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function dr(t,e){if(t.has(e))return!0;for(const r of t)if(Ua(r,e))return!0;return!1}function st(t,e){for(const r of e)if(dr(t,r))return!0;return!1}class Ha{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=lt(n,r,0,a);this.values.set(e,i),this.enqueueChange(Fa(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 lt(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]=lt(t[i],e,r+1,a),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[n]=lt(t[n],e,r+1,a),s}if(i!==null){const s=[];return s[i]=lt(void 0,e,r+1,a),s}const o={};return o[n]=lt(void 0,e,r+1,a),o}const Va=Symbol("aktion.httpResource");function Wa(t){return typeof t=="object"&&t!==null&&t[Va]===!0}class qa{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=Qo(r.body,r.headers));const s=await i(r.url,o),c={};s.headers.forEach((d,f)=>{c[f]=d});const u=c["content-type"]??"";let p;return s.status===204||r.method==="HEAD"?p=null:u.includes("application/json")?p=await s.json().catch(()=>null):p=await s.text().catch(()=>""),{status:s.status,headers:c,body:p}};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 Qo(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 es=new Set(["url","method","headers","body","query","signal"]);function ts(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[c,u]of Object.entries(e.headers))u!=null&&(n[c]=String(u));let i=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const c=new URLSearchParams;for(const[p,d]of Object.entries(e.query))d!=null&&c.append(p,String(d));const u=c.toString();u&&(i+=(i.includes("?")?"&":"?")+u)}const o={};for(const[c,u]of Object.entries(e))es.has(c)||(o[c]=u);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 Ka(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,Va,{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 c=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 u=ts(t);u.url=e.http.resolveUrl(u.url),u.signal=c.signal;const p=await e.http.request(u);if(s!==n)return;p.status>=200&&p.status<300?(r.data=p.body,r.state="data",r.error=void 0):(r.error={status:p.status,body:p.body},r.state="error"),r.status=p.status,r.headers=p.headers,r.lastUpdated=Date.now()}catch(u){if(s!==n||u?.name==="AbortError")return;r.error=u,r.state="error"}finally{if(s===n&&(r.loading=!1,i(),typeof r.onDone=="function"))try{r.onDone(r)}catch(u){console.error("[aktion] Http onDone callback threw",u)}}};return o(),r}function Ga(t={}){const e=rs(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let a=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function n(s,c){if(typeof s!="string"||!s)return"";const u=e[s];let p;return u&&(a&&typeof u[a]=="string"?p=u[a]:r&&typeof u[r]=="string"&&(p=u[r])),p===void 0?s:as(p,c)}function i(s){typeof s!="string"||!s||(a=s)}function o(){return a}return{t:n,setCurrentLanguage:i,getCurrentLanguage:o}}function rs(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 as(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:[],Ya=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Xa=(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}},Ze=(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]}},Oe=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},ns=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],is=["January","February","March","April","May","June","July","August","September","October","November","December"],os=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ss=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ls=(t,e)=>{const r=(s,c=2)=>String(s).padStart(c,"0"),a=t.getHours(),n=(a+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,is[t.getMonth()]],[/MMM/g,ns[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,ss[t.getDay()]],[/ddd/g,os[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,c]of i)o=o.replace(s,c);return o},cs=(t,e=Date.now())=>{const r=e-t.getTime(),a=Math.abs(r),n=r<0,i=6e4,o=60*i,s=24*o,c=7*s,u=30*s,p=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<c?(d=Math.round(a/s),f="d"):a<u?(d=Math.round(a/c),f="w"):a<p?(d=Math.round(a/u),f="mo"):(d=Math.round(a/p),f="y"),n?`in ${d}${f}`:`${d}${f} ago`)},us=(t,e,r)=>{if(Ya(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},ds=(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("")},ps={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=>Xa(r,Ze(n,String(e)),a)),find:(t,e="",r="==",a)=>le(t).find(n=>Xa(r,Ze(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=Ze(i,String(e)),c=Ze(o,String(e));return typeof s=="number"&&typeof c=="number"?(s-c)*n:String(s??"").localeCompare(String(c??""))*n}),a},groupBy:(t,e="")=>{const r={};for(const a of le(t)){const n=String(Ze(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=Ze(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>$t)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${$t}).`);const c=[];if(i>0)for(let u=a;u<=n;u+=i)c.push(u);else for(let u=a;u>=n;u+=i)c.push(u);return c},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>$t)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${$t}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!Ya(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=us(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=Oe(t),a=String(e);switch(a){case"relative":return cs(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 ls(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 ds(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=Oe(t),a=new Date(r.getTime());return a.setDate(a.getDate()+W(e)),a.toISOString()},addHours:(t,e)=>{const r=Oe(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=Oe(t),a=Oe(e);return Math.round((a.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=Oe(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=Oe(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))},$t=1e5;function Fe(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 Ja(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=Fe(t),a=Fe(e),n=r==="/"?[]:r.slice(1).split("/"),i=a==="/"?[]:a.slice(1).split("/"),o={};let s=!1;for(let c=0;c<n.length;c+=1){const u=n[c];if(u==="*"){s=!0;const d=i.slice(c).join("/");return o._=d,{matched:!0,params:o,wildcard:s}}const p=i[c];if(p===void 0)return{matched:!1,params:{}};if(u.startsWith(":")){const d=u.slice(1);if(!d)return{matched:!1,params:{}};o[d]=decodeURIComponent(p);continue}if(u!==p)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 Za{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=Fe(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=Fe(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,ms(this.currentParams,r)||(this.currentParams=r)}navigate(e){const r=Fe(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=Fe(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 ms(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 Le=(t,e)=>{try{return t()}catch{return e}},Qa=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)}},en=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},tn=t=>({set:(e,r)=>Le(()=>{const a=t();return a?(a.setItem(String(e),Qa(r)),!0):!1},!1),get:e=>Le(()=>{const r=t();return r?en(r.getItem(String(e))):null},null),remove:e=>Le(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>Le(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),fs=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,gs=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,At=()=>typeof globalThis>"u"?null:globalThis.document??null,hs=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},pr=(t={})=>{const e=[],r=hs(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("; ")}`},rn=()=>{const t=At();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},bs={set:(t,e,r)=>Le(()=>{const a=At();if(!a)return!1;const n=encodeURIComponent(String(t)),i=encodeURIComponent(Qa(e));return a.cookie=`${n}=${i}${pr(r)}`,!0},!1),get:t=>Le(()=>{const r=rn()[String(t)];return r===void 0?null:en(r)},null),remove:(t,e)=>Le(()=>{const r=At();if(!r)return!1;const a=encodeURIComponent(String(t)),n={...e,expires:new Date(0),maxAge:0};return r.cookie=`${a}=${pr(n)}`,!0},!1),clear:()=>Le(()=>{const t=At();if(!t)return!1;const e=rn();for(const r of Object.keys(e)){const a=encodeURIComponent(r);t.cookie=`${a}=${pr({expires:new Date(0),maxAge:0})}`}return!0},!1)},ct=tn(fs),vs=tn(gs),mr={set:ct.set,get:ct.get,remove:ct.remove,clear:ct.clear,local:ct,session:vs,cookies:bs},ys=["log","error","warn","info","debug"],xs=()=>typeof globalThis>"u"?null:globalThis.console??null,ws=t=>(...e)=>{const r=xs();if(!r)return;const a=r[t]??r.log;if(typeof a=="function")try{a(...e)}catch{}},an=ys.reduce((t,e)=>(t[e]=ws(e),t),{}),ut={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},fr={util:ps,console:an,storage:mr};function nn(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 Tt={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class ze extends Error{constructor(r,a,n){super(ks(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 ks(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 on(t={}){return{componentDepthLimit:t.componentDepthLimit??Tt.componentDepthLimit,iterationLimit:t.iterationLimit??Tt.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??Tt.arrayLengthLimit,componentDepth:0,iterations:0}}function gr(t){t.iterations=0,t.componentDepth=0}function dt(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new ze("iterations",t.iterationLimit,r)}function hr(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new ze("component-depth",r.componentDepthLimit,`component "${e}"`)}function br(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}const sn=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),ln=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),Nt=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function vr(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??on()};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 yr(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(a){console.error("[aktion] context disposer threw",a)}}function cn(t){t.mutableBindings.clear()}function Se(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 Mt(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:Se(e,a.name),path:r}}function Pt(t,e){if(t.kind==="StateRef")return Se(e,t.name);if(t.kind==="Member"){const r=Mt(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const a=yn(t,e);if(a)return a.path.length===0?a.atom:`${a.atom}.${a.path.join(".")}`}return null}function un(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const a=Et(r.expression);e.state.declare(r.identifier,a)}for(const r of t.statements)xr(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!dn(r.expression))continue;const a=N(r.expression,e);e.state.set(r.identifier,a)}$s(t,e),Cs(t,e)}const Ss=8;function Cs(t,e){const r=[],a=o=>{const s=new Set,c=e.trackedState;e.trackedState=s;try{const u=N(o.expr,e);e.state.set(o.name,u)}finally{e.trackedState=c}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||It(o.expression)||dn(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 c=0;c<Ss;c+=1){let u=!1;for(const p of r){if(!st(s,p.deps))continue;const f=e.state.get(p.name);a(p),e.state.get(p.name)!==f&&(s.add(p.name),u=!0)}if(!u)break}}finally{n=!1}}});e.disposers.push(i)}function It(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&It(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&It(e.value));case"Template":return t.expressions.length===0;default:return!1}}function dn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function pn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="theme"}function mn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="app"}function xr(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":return;case"Import":return;case"ExpressionStatement":{const r=t.expression;mn(r)?e.bindings.set("aktion",()=>N(r,e)):pn(r)&&e.bindings.set("theme",()=>N(r,e));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 fn(t){switch(t.kind){case"IfStatement":case"SwitchStatement":case"ForOfStatement":case"ForClassicStatement":case"ForInStatement":case"WhileStatement":case"DoWhileStatement":case"TryStatement":case"DestructureStatement":case"ThrowStatement":return!0;case"ExpressionStatement":return!mn(t.expression)&&!pn(t.expression);default:return!1}}function $s(t,e){let r=!1;for(const a of t.statements)if(fn(a)){r=!0;break}if(r){for(const a of t.statements)a.kind==="Assignment"&&a.isState&&It(a.expression)&&e.state.set(a.identifier,Et(a.expression));for(const a of t.statements)if(fn(a))try{Lt(a,e)}catch(n){if(n instanceof Ce||n instanceof Ne||n instanceof Re)continue;if(n instanceof ze)throw n;console.error("[aktion] top-level statement threw",n)}}}function As(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=ol(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 c=Ja(s,n);if(c.matched)return gn(s,o.value,c.params,e)}return i?gn(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function gn(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 Et(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Et(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Et(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?sl(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 Zs(a,e);const n=e.componentDecls.get(t.name);if(n)return Qs(n);if(Object.prototype.hasOwnProperty.call(ut,t.name))return ut[t.name];if(e.library&&Ee(e.library,t.name))return el(t.name);const i=nn(t.name);return i.found?i.value:null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(fr,t.name))return fr[t.name];const r=Se(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(Rs(t))return Ds(t,e);const r=js(t,e);if(r)return Bs(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 Sr(a,n)}return Cr(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 Hs(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 Ws(t.callee,t.arguments,e,t.loc);case"MethodCall":return Vs(t,e);case"Invoke":return Os(t,e);case"New":return Fs(t,e);case"BuiltinCall":return tl(t.name,t.arguments,e);case"Template":return Us(t.quasis,t.expressions,e);case"Spread":return N(t.argument,e);case"Block":return wr(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),c=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 u=[],p=(d,f)=>{u.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 b of pt(f.pattern,g,e))p(b.name,b.value);continue}p(f.name,g)}try{return N(a,e)}finally{for(const d of u)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 c)e.stateAliases.push(d)}}}default:return null}}class Ce{constructor(){D(this,"kind","break")}}class Ne{constructor(){D(this,"kind","continue")}}class Re{constructor(e){D(this,"kind","return");this.value=e}}function hn(t,e){if(N(t.test,e)){$e(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){hn(t.alternate,e);return}t.alternate.kind==="Block"&&$e(t.alternate.body,e)}}function Ts(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&&$e(n.body,e)}catch(n){if(n instanceof Ce)return;throw n}}function Ns(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,c=t.destructure??[],u=c.map(p=>({name:p,had:e.loopVars.has(p),value:e.loopVars.get(p)}));try{let p=0;const d=(Array.isArray(r),r);for(const f of d){dt(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,p);for(const g of c){const b=f&&typeof f=="object"?f[g]:void 0;e.loopVars.set(g,b)}try{$e(t.body.body,e)}catch(g){if(g instanceof Ne){p+=1;continue}if(g instanceof Ce)return;throw g}p+=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 p of u)p.had?e.loopVars.set(p.name,p.value):e.loopVars.delete(p.name)}}function Ms(t,e){for(t.init&&zt(t.init,e);!(t.test&&!N(t.test,e));){dt(e.budget,1,"`for` loop");try{$e(t.body.body,e)}catch(r){if(!(r instanceof Ne)){if(r instanceof Ce)return;throw r}}t.update&&N(t.update,e)}}function Ps(t,e){for(;N(t.test,e);){dt(e.budget,1,"`while` loop");try{$e(t.body.body,e)}catch(r){if(r instanceof Ne)continue;if(r instanceof Ce)return;throw r}}}function Is(t,e){for(;;){dt(e.budget,1,"`do…while` loop");try{$e(t.body.body,e)}catch(r){if(!(r instanceof Ne)){if(r instanceof Ce)return;throw r}}if(!N(t.test,e))break}}function Es(t,e){const r=N(t.expression,e),a=pt({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:n,value:i}of a)e.loopVars.set(n,i)}function pt(t,e,r){const a=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const c of t.bindings){if(c.rest){a.push({name:c.name,value:o.slice(s)}),s=o.length;continue}let u=o[s];u===void 0&&c.defaultValue&&(u=N(c.defaultValue,r)),c.name!==""&&a.push({name:c.name,value:u}),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 u={};for(const[p,d]of Object.entries(n))i.has(p)||(u[p]=d);a.push({name:o.name,value:u});continue}const s=o.sourceKey??o.name;i.add(s);let c=n[s];c===void 0&&o.defaultValue&&(c=N(o.defaultValue,r)),a.push({name:o.name,value:c})}return a}function Ls(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){dt(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{$e(t.body.body,e)}catch(o){if(o instanceof Ne)continue;if(o instanceof Ce)return;throw o}}}finally{a?e.loopVars.set(t.item,n):e.loopVars.delete(t.item)}}function zs(t,e){try{$e(t.block.body,e)}catch(r){if(r instanceof Ce||r instanceof Ne||r instanceof Re)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{$e(t.catchBlock.body,e)}finally{a&&(n?e.loopVars.set(a,i):e.loopVars.delete(a))}}}finally{t.finallyBlock&&$e(t.finallyBlock.body,e)}}function $e(t,e){for(const r of t)zt(r,e)}function Lt(t,e){zt(t,e)}function zt(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=Se(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":hn(t,e);return;case"SwitchStatement":Ts(t,e);return;case"ForOfStatement":Ns(t,e);return;case"ForClassicStatement":Ms(t,e);return;case"ForInStatement":Ls(t,e);return;case"WhileStatement":Ps(t,e);return;case"DoWhileStatement":Is(t,e);return;case"DestructureStatement":Es(t,e);return;case"TryStatement":zs(t,e);return;case"BreakStatement":throw new Ce;case"ContinueStatement":throw new Ne;case"ThrowStatement":throw N(t.argument,e);case"Return":{const r=t.argument?N(t.argument,e):void 0;throw new Re(r)}case"Await":N(t.argument,e);return;default:return}}function Rs(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&Object.prototype.hasOwnProperty.call(fr,e.name)?!1:e.kind==="StateRef"}function Ds(t,e){const r=bn(t);let a=t;for(;a.kind==="Member";)a=a.object;const n=Se(e,a.name);return vn(r,n,e)}function bn(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function vn(t,e,r){let a=r.state.get(e);const n=[e];let i=!0;for(const o of t){let s,c=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(c=String(s))):s=N(o.computed,r):(s=o.property??"",c=o.property??"");const u=a!=null&&typeof a=="object"&&!Array.isArray(a);i&&c!==null&&u?n.push(c):i=!1,a=o.computed?Sr(a,s):Cr(a,o.property??"")}return r.trackedState.add(n.join(".")),a}function js(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const a=N(r,e);return Nt(a)?a:null}function Bs(t,e,r){const a=bn(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=Sr(i,N(s.computed,e)):i=Cr(i,s.property??"")}return i}return vn(a,r.__atom,e)}function _s(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 c=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;e.state.declare(c,o);const u={},p={__kind:"Store",__atom:c,__methods:u};for(const[d,f]of Object.entries(s))u[d]=(...g)=>f(p,...g);return e.stores.set(a,p),p}function yn(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 Nt(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 Ys(t.arguments,e,t.loc);if(n==="memo")return Xs(t.arguments,e,t.loc);switch(n){case"store":return _s(t.arguments,e,t.loc);case"router":return As(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Ka(o?N(o,e):{},e)}case"theme":{const o=t.arguments[0];return{kind:"Theme",tokens:ul(o?N(o,e):null)}}case"app":{const o=t.arguments;return o.length===1?N(o[0],e):o.map(s=>N(s,e))}case"i18n":{const o=t.arguments[0],s=o?N(o,e):null,c=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return Ga(c)}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),mr}const i=e.hookDecls.get(n);if(i)return Js(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 Fs(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 wr(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=Se(e,i.identifier);if(r.stateAsDeclaration){if(e.state.has(s)){a=e.state.get(s);continue}const u=N(i.expression,e);e.state.declare(s,u),a=u;continue}const c=N(i.expression,e);e.state.set(s,c),a=c;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)}):xr(i,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":xr(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":zt(i,e);continue}}catch(i){if(i instanceof Re)return i.value;throw i}finally{for(const i of n)e.loopVars.delete(i)}return a}function Us(t,e,r){let a=t[0]??"";for(let n=0;n<e.length;n+=1)a+=$r(N(e[n],r)),a+=t[n+1]??"";return a}function Hs(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"?$r(n)+$r(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)<<(De(i)&31);case">>":return oe(n)>>(De(i)&31);case">>>":return De(n)>>>(De(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 De(t){return O(t)>>>0}function Vs(t,e){const r=N(t.object,e);if(r==null)return t.optional?void 0:null;const a=Nt(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 c of s)n.push(c);continue}n.push(N(o,e))}const i=n;try{return a.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof ze)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function Ws(t,e,r,a){const n=r.componentDecls.get(t);if(n)return Ks(n,e,r,a);const i=r.actionDecls.get(t);if(i){const g=e.map(b=>N(b,r));return wn(i,g,r)}if(t==="setTimeout"||t==="setInterval")return rl(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(b=>N(b,r));return o(...g)}const s=r.bindings.get(t);if(s){const g=s();if(typeof g=="function"){const b=e.map(h=>N(h,r));return g(...b)}}if(Object.prototype.hasOwnProperty.call(ut,t)&&typeof ut[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Ee(r.library,t))){const g=ut[t],b=[];for(const h of e){if(h.kind==="Spread"){const v=N(h.argument,r);if(Array.isArray(v))for(const y of v)b.push(y);continue}b.push(N(h,r))}try{return g(...b)}catch(h){return console.error(`[aktion] global "${t}" threw`,h),null}}if(r.library&&!Ee(r.library,t)){const g=nn(t);if(g.found&&typeof g.value=="function"){const b=g.value,h=[];for(const v of e){if(v.kind==="Spread"){const y=N(v.argument,r);if(Array.isArray(y))for(const x of y)h.push(x);continue}h.push(N(v,r))}try{return b(...h)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}return Ee(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:a}:null}let c;const u=[...e];if(u.length>0){const g=u[u.length-1];if(g.kind==="Object"){const b=g.properties.find(h=>!h.spread&&h.key==="key");if(b){c=N(b.value,r);const h=g.properties.filter(v=>v!==b);h.length>0?u[u.length-1]={...g,properties:h}:u.pop()}}}const{args:p,argMeta:d}=qs(r,t,u);return{__kind:"Component",name:t,args:p,argMeta:d,explicitKey:c,source:a}}function qs(t,e,r){const a=t.library?Ee(t.library,e):void 0;if(!a){const f=r.map(b=>N(b,t)),g=r.map(b=>{const h=Pt(b,t);return h!==null?{stateRef:h}:{}});return{args:f,argMeta:g}}const n=new Map;a.props.forEach((f,g)=>{if(n.set(f.name,g),f.aliases)for(const b of f.aliases)n.has(b)||n.set(b,g)});const i=lr(a),o=a.props.map(()=>({value:void 0,meta:{},filled:!1})),s=[];let c=-1;for(let f=r.length-1;f>=0;f-=1)if(r[f].kind==="Object"){c=f;break}for(let f=0;f<r.length;f+=1){if(f===c)continue;const g=r[f];s.push({expr:g,value:N(g,t)})}if(c>=0){const f=r[c];if(f.kind==="Object")for(const g of f.properties){if(g.spread)continue;const b=n.get(g.key);if(b===void 0)continue;const h=N(g.value,t);o[b].value=h,o[b].filled=!0;const v=Pt(g.value,t);v!==null&&(o[b].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 b=Pt(f,t);b!==null&&(o[i].meta={stateRef:b})}let u=0;for(const{expr:f,value:g}of s){for(;u<a.props.length&&o[u].filled;)u+=1;if(u>=a.props.length)break;o[u].value=g,o[u].filled=!0;const b=Pt(f,t);b!==null&&(o[u].meta={stateRef:b}),u+=1}const p=o.map(f=>f.value),d=o.map(f=>f.meta);for(;p.length>0&&p[p.length-1]===void 0;)p.pop(),d.pop();return{args:p,argMeta:d}}function Ks(t,e,r,a){const n=[],i={};let o,s=-1;for(let b=e.length-1;b>=0;b-=1)if(e[b].kind==="Object"){s=b;break}let c=s>=0?e[s]:null,u=!1;if(c&&c.kind==="Object"){const b=new Set(t.params.map(h=>h.name));for(const h of c.properties)if(!h.spread&&(h.key==="key"||b.has(h.key))){u=!0;break}}u||(s=-1,c=null);for(let b=0;b<e.length;b+=1)b!==s&&n.push(e[b]);if(c&&c.kind==="Object")for(const b of c.properties)b.spread||(b.key==="key"?o=b.value:i[b.key]=b.value);const p=n.map(b=>b.kind==="Spread"?N(b.argument,r):N(b,r)),d=[];for(let b=0;b<n.length;b+=1){const h=n[b],v=p[b];if(h.kind==="Spread"&&Array.isArray(v))for(const y of v)d.push(y);else d.push(v)}const f={};for(const[b,h]of Object.entries(i))f[b]=N(h,r);const g=o?N(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:d,named:f,explicitKey:g,source:a}}function xn(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 h=n[f];h===void 0&&g.defaultValue&&(h=N(g.defaultValue,e));for(const v of pt(g.pattern,h,e))s(v.name,v.value);continue}let b;i[g.name]!==void 0?b=i[g.name]:n[f]!==void 0?b=n[f]:g.defaultValue?b=N(g.defaultValue,e):b=void 0,s(g.name,b)}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 c=new Map;for(const f of a.body.body)if(f.kind==="Assignment"&&f.isState){const g=`${r}:${f.identifier}`;c.set(f.identifier,g)}e.stateAliases.push(c);const u=[];e.componentEffectStack.push(u);const p=e.hookScope,d={instanceKey:r,cursor:0};e.hookScope=d;try{return{value:wr(a.body,e,{stateAsDeclaration:!0}),effects:u,hooks:d.cursor}}finally{e.hookScope=p,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 wn(t,e,r){return kn(t.params,t.body,e,r)}function kn(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 c=r[o];if(c===void 0&&s.defaultValue&&(c=N(s.defaultValue,a)),s.pattern){for(const u of pt(s.pattern,c,a))i(u.name,u.value);continue}i(s.name,c)}try{return wr(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 Sn(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 Gs(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 Ys(t,e,r){const a=Sn(e);if(!a)return $n("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=c=>{const u=typeof c=="function"?c(o.value):c;Object.is(u,o.value)||(o.value=u,e.notify?.())};return[o.value,s]}function Xs(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=Sn(e);if(!o)return $n("memo",r),i();const s=e.hookScope.cursor++,c=n?N(n,e):void 0,u=Array.isArray(c)?c:void 0,p=o[s];if(p&&p.kind==="memo"&&u&&p.deps&&Gs(p.deps,u))return p.value;const d=i();return o[s]={kind:"memo",deps:u,value:d},d}function Js(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 kn(t.params,t.body,a,r)}let Cn=!1;function $n(t,e){Cn||(Cn=!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 An(t,e){t.hookStore.delete(e)}function Zs(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,c]of a)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return wn(t,n,e)}finally{e.loopVars.clear();for(const[s,c]of i)e.loopVars.set(s,c);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function Qs(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function el(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function tl(t,e,r){return t==="__rui_assign__"?al(e,r):t==="__rui_postfix__"?nl(e,r):t==="__rui_prefix__"?il(e,r):t==="__rui_await__"?e[0]?N(e[0],r):void 0:null}function je(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)<<(De(r)&31);case">>=":return oe(e)>>(De(r)&31);case">>>=":return De(e)>>>(De(r)&31);default:return r}}function rl(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 u=2;u<e.length;u+=1)o.push(N(e[u],r));const s=()=>{try{n(...o)}catch(u){console.error(`[aktion] ${t} callback threw`,u)}finally{r.notify?.()}};if(t==="setTimeout"){const u=setTimeout(()=>{r.timers.timeouts.delete(u),s()},i);return r.timers.timeouts.add(u),u}const c=setInterval(s,i);return r.timers.intervals.add(c),c}function al(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=Se(e,r.name),c=e.state.get(s),u=je(i,c,o);return e.state.set(s,u),u}if(r.kind==="Member"){const s=Mt(r,e);if(s){const d=e.state.get(s.name);if(s.path.length>=1&&Wa(d)){let b=d;for(let h=0;h<s.path.length-1;h+=1)b=b?.[s.path[h]];if(b&&typeof b=="object"){const h=s.path[s.path.length-1],v=b[h],y=je(i,v,o);return b[h]=y,e.notify?.(),y}}const f=kr(d,s.path),g=je(i,f,o);return e.state.setPath(s.name,s.path,g),g}const c=yn(r,e);if(c){const d=kr(e.state.get(c.atom),c.path),f=je(i,d,o);return e.state.setPath(c.atom,c.path,f),f}const u=N(r.object,e),p=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(u&&typeof u=="object"&&p!=null){const d=u[String(p)],f=je(i,d,o);return u[String(p)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const p=e.loopVars.get(s),d=je(i,p,o);return e.loopVars.set(s,d),d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),d=je(i,p,o);return e.mutableBindings.set(s,d),d}const c=e.loopVars.get(s),u=je(i,c,o);return e.loopVars.set(s,u),u}return o}function kr(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 Tn(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=Se(e,a.name),c=O(e.state.get(s)),u=c+o;return e.state.set(s,u),r==="prefix"?u:c}if(a.kind==="Member"){const s=Mt(a,e);if(s){const c=O(kr(e.state.get(s.name),s.path)),u=c+o;return e.state.setPath(s.name,s.path,u),r==="prefix"?u:c}}if(a.kind==="Identifier"){const s=a.name;if(e.loopVars.has(s)){const p=O(e.loopVars.get(s)),d=p+o;return e.loopVars.set(s,d),r==="prefix"?d:p}if(e.bindings.has(s)||e.mutableBindings.has(s)){const p=O(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),d=p+o;return e.mutableBindings.set(s,d),r==="prefix"?d:p}const c=O(e.loopVars.get(s)),u=c+o;return e.loopVars.set(s,u),r==="prefix"?u:c}return null}function nl(t,e){return Tn(t,e,"postfix")}function il(t,e){return Tn(t,e,"prefix")}function ol(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 sl(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,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Sr(t,e){if(t!=null){if(Array.isArray(t)){const r=Nn(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=Nn(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function Nn(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 Cr(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 ll=new Set(["colors","radius","font"]),cl=new Set(["name","direction"]);function ul(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&&!cl.has(a)&&ll.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 c=i+dl(o);e[c]=pl(s)}}return e}function dl(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function pl(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function $r(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)}}const ml="__AKTION_DEVTOOLS_HOOK__";function fl(){return globalThis}function Rt(){return fl()[ml]}function Ar(){const t=Rt();return t!==void 0&&t.active}function Tr(t){Rt()?.emit(t)}function gl(t){Rt()?.unregisterApp(t)}function pe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Mn(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const Dt="::",hl=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(Dt)||a.has(n)||this.unmount(n);for(const n of e)this.mounted.has(n.name)||this.mount(n.name,n,r,[],hl)}syncInstanceEffects(e,r,a){const n=`${e}${Dt}`,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}`,c=this.mounted.get(s);if(c){c.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,a,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${Dt}`;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),this.emitEffect(e,r,"mount","mount");const c=bl(f=>{const g=o.cleanups.splice(0);if(g.length>0){for(const h of g)try{h()}catch(v){En(e,v)}this.emitEffect(e,r,"cleanup",f,{cleanups:g.length})}const b=pe();try{In(r,a(),o,this.options),this.emitEffect(e,r,"run",f,{duration:pe()-b})}catch(h){this.emitEffect(e,r,"error",f,{duration:pe()-b,error:h instanceof Error?h.message:String(h)}),console.error(`[aktion] effect "${e}" failed`,h)}finally{this.options.notify()}},r.rateLimit,o);let u=!1,p=!1,d=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(u=!0),f.name==="unmount"&&(p=!0);break;case"every":{d=!0;const g=`every(${f.intervalMs})`,b=setInterval(()=>c(g),f.intervalMs);o.intervals.push(b);break}case"state":{const g=wl(f.name,n),b=`state:${f.name}`,h=this.options.state.subscribe(v=>{dr(v,g)&&c(b)});o.unsubscribers.push(h);break}}(r.triggers.length===0||u||!d&&!p&&r.triggers.every(f=>f.kind==="state"))&&c("mount")}emitEffect(e,r,a,n,i={}){const o=this.options.onEffectEvent;if(!o||!Ar())return;const s=e.lastIndexOf(Dt);o({effectKey:e,label:yl(r.name),instanceKey:s>=0?e.slice(0,s):null,phase:a,reason:n,triggers:xl(r),...i})}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{}if(r.cleanups.length>0){const n=r.cleanups.length;for(const i of r.cleanups)try{i()}catch(o){En(e,o)}this.emitEffect(e,r.decl,"cleanup","unmount",{cleanups:n})}if(r.decl.triggers.some(n=>n.kind==="lifecycle"&&n.name==="unmount")){const n=pe();try{In(r.decl,r.ctxRef(),r,this.options),this.emitEffect(e,r.decl,"run","unmount",{duration:pe()-n})}catch(i){this.emitEffect(e,r.decl,"error","unmount",{error:i instanceof Error?i.message:String(i)}),console.error(`[aktion] effect "${e}" unmount body threw`,i)}}this.emitEffect(e,r.decl,"unmount","unmount")}}function bl(t,e,r){if(!e||e.ms<=0)return t;if(e.kind==="debounce"){let o=null;const s=()=>{o&&(clearTimeout(o),o=null)};return r.cleanups.push(s),c=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(c)},e.ms)}}let a=0,n=null,i="";return r.cleanups.push(()=>{n&&(clearTimeout(n),n=null)}),o=>{const s=Date.now(),c=s-a;c>=e.ms?(a=s,t(o)):n?i=o:(i=o,n=setTimeout(()=>{n=null,a=Date.now(),t(i)},e.ms-c))}}function In(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)vl(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 vl(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(Mn(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=Se(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":Lt(t,e);return;default:return}}function En(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function yl(t){const e=/^__effect_L(\d+)_C(\d+)$/.exec(t);return e?`effect @ L${e[1]}:C${e[2]}`:t}function xl(t){const e=t.triggers.map(r=>r.kind==="lifecycle"?`"${r.name}"`:r.kind==="every"?`every(${r.intervalMs})`:`$${r.name}`);return t.rateLimit&&e.push(`${t.rateLimit.kind}(${t.rateLimit.ms})`),e.length>0?`[${e.join(", ")}]`:"[mount]"}function wl(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 Ln{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],c=r[o];n.push({name:s.name,had:a.loopVars.has(s.name),prev:a.loopVars.get(s.name)}),a.loopVars.set(s.name,c)}const i=e.optimistic?kl(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 Re)return this.options.notify(),s.value;throw s}return this.options.notify(),o}catch(o){if(o instanceof Ce||o instanceof Ne){console.error(`[aktion] action "${e.name}" — \`${o.kind}\` outside a loop.`);return}throw i&&(Sl(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(Mn(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 jt(n)}case"Await":{const a=N(e.argument,r);return await jt(a)}case"Assignment":{const a=await jt(N(e.expression,r));if(e.identifier)if(e.isState){const n=Se(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 Re(void 0);const a=await jt(N(e.argument,r));throw new Re(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":Lt(e,r);return;default:return}}}async function jt(t){return t&&typeof t.then=="function"?await t:t}function kl(t){const e=new Map;for(const[r,a]of t.entries())e.set(r,a);return e}function Sl(t,e){for(const[r,a]of e)t.set(r,a)}const Cl="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",zn="6.7.2",Rn="data-rui-font-awesome",$l=new Set(["solid","regular","brands"]),Dn="solid";function Al(t){typeof document<"u"&&jn(document.head,document),jn(t,t.ownerDocument??document)}function jn(t,e){if(Tl()||t.querySelector(`link[${Rn}="${zn}"]`))return;const a=e.createElement("link");a.rel="stylesheet",a.href=Cl,a.setAttribute(Rn,zn);try{t.appendChild(a)}catch{}}function Tl(){return typeof globalThis.happyDOM<"u"}function Bt(t){if(typeof t!="string")return[];const e=Ml(t).trim();if(!e)return[];if(!Il(e))return[];const[r,a]=Pl(e);return a?[`fa-${r}`,`fa-${a}`]:[]}const Nl=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Ml(t){return t.replace(Nl,"")}function Pl(t){const e=t.indexOf(":");if(e===-1)return[Dn,t];const r=t.slice(0,e).trim().toLowerCase(),a=t.slice(e+1).trim();return $l.has(r)?[r,a]:[Dn,a||t]}function Il(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const El=["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 m(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function A(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function E(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 Qe=["base","sm","md","lg","xl"];function be(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)Qe.includes(n)&&(r[n]=i,a=!0);return a?{kind:"responsive",values:r}:{kind:"single",value:t}}const Ll=/["'\\\n\r<>;{}]/g;function zl(t){return t?t.replace(Ll,"").trim():""}const Rl=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function te(t,e){const r=(m(t)??"").trim();return!r||r.length>64||!Rl.test(r)?e:r}const Dl=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function jl(t){const e=m(t).trim();return!e||e.length>64||!Dl.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Bl=new Set(["http","https","mailto","tel"]);function et(t,e="#"){const r=m(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 Bl.has(i)?a:e}const _l=new Set(["http","https","data","blob"]);function ne(t){const e=m(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!_l.has(n)||n==="data"&&!/^data:image\//i.test(r)?"":r}function Ol(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function Nr(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(u){console.error("[aktion] Col render() threw",u),s=null}const c=u=>{Ol(u)?t.append(n.renderNode(u)):u!=null&&t.append(document.createTextNode(i(u,o)))};if(Array.isArray(s))for(const u of s)c(u);else c(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const u=p=>p.target?.closest("input,button,a,label,select,textarea")?!1:(p.stopPropagation(),n.invoke(e.onClick,r,a),!0);t.onclick=p=>{u(p)},t.onkeydown=p=>{p.key!=="Enter"&&p.key!==" "||u(p)&&p.preventDefault()}}}function j(t,e={}){const r=m(t);if(!r)return null;const a=e.color?jl(e.color):"",n=a?`color:${a};`:null,i=Bt(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 mt=12,Fl={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Ul={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Hl(t){return Fl[t]??"stretch"}function Vl(t){return Ul[t]??"flex-start"}function Bn(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function Ue(t,e,r){for(const a of Qe){const n=e.values[a];n&&t.push(`${r}-${a}:var(--rui-spacing-${n}, ${n})`)}}function Wl(t,e,r,a){for(const n of Qe){const i=e.values[n];i&&t.push(`${r}-${n}:${a(String(i))}`)}}function _n(t,e,r,a){const n=be(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",Wl(e,n,a.cssVarPrefix,a.mapper)}function ql(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function Kl(t){const e=be(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(E(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(a["data-shrink"]=String(E(e.shrink,1)));const i=m(e.basis);i==="auto"||i==="0"?a["data-basis"]=i:i&&n.push(`flex-basis:${te(i,i)}`);const o=m(e.alignSelf);if(o&&(a["data-align-self"]=o),e.order!==void 0&&e.order!==null){const p=E(e.order,0);a["data-order"]=String(p),n.push(`order:${p}`)}const s=m(e.minWidth);s&&n.push(`min-width:${te(s,s)}`);const c=m(e.maxWidth);c&&n.push(`max-width:${te(c,c)}`),n.length>0&&(a.style=n.join(";"));const u=l("div",a);return u.append(r.renderNode(e.child)),u}};function Mr(t,e,r,a,n){const i=be(t),o=be(a.gap),s=be(a.padding),c=A(a.reverse),u={class:"rui-stack","data-wrap":A(a.wrap)?"true":null,"data-reverse":c?"true":null,"data-uniform":e?"true":"false","data-inline":A(a.inline)?"true":null},p=[];if(i.kind==="single"){const g=i.value?String(i.value):"column";u["data-direction"]=Bn(g,c)}else{u["data-direction"]="responsive",u["data-responsive-dir"]="true";for(const g of Qe){const b=i.values[g];b&&p.push(`--rui-stack-dir-${g}:${Bn(String(b),c)}`)}}o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-stack-gap")),_n(a.align,p,u,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:Hl}),_n(a.justify,p,u,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:Vl});const d=m(a.alignContent);if(d&&(u["data-align-content"]=d),s.kind==="single"){const g=s.value?String(s.value):null;g&&(u["data-padding"]=g)}else u["data-padding"]="responsive",u["data-responsive-padding"]="true",Ue(p,s,"--rui-stack-padding");p.length>0&&(u.style=p.join(";"));const f=l("div",u);for(const g of C(a.children))f.append(n.renderNode(g));return f}const Yl={name:"gap",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Spacing between children. May be a responsive map."},Pr={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},Ir={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},Er={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},Lr={name:"padding",type:"string | object",optional:!0,enum:["xs","s","m","l","xl"],description:"Inner padding token. May be a responsive map."},zr={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},On={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},Xl={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."},{...Pr},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...Ir},{...Er},{...Lr},{...zr},{...On}],render:(t,e,r)=>Mr("row",A(e.grow),"center",e,r)},Jl={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."},{...Pr},{...Ir},{...Er},{...Lr},{...zr}],render:(t,e,r)=>Mr("column",!1,"stretch",e,r)},Zl={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"}`.'},{...Yl},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...Pr},{...On},{...Ir},{...Er},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...zr},{...Lr}],render:(t,e,r)=>{const n=Kl(e)==="row",i=e.uniform===void 0?n:A(e.uniform,n);return Mr(e.direction,i,"stretch",e,r)}},Ql={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":m(e.axis,"both"),"data-gap":m(e.gap,"m"),"data-inline":A(e.inline)?"true":null},n=m(e.padding);n&&(a["data-padding"]=n);const i=[],o=m(e.minHeight);o&&i.push(`min-height:${te(o,o)}`),i.length>0&&(a.style=i.join(";"));const s=l("div",a);for(const c of C(e.children))s.append(r.renderNode(c));return s}},ec={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":m(e.variant,"default")});for(const n of C(e.children))a.append(r.renderNode(n));return a}},tc={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"},[m(e.title)]));const a=m(e.subtitle);return a&&r.append(l("p",{class:"rui-card-subtitle"},[a])),r}},rc={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}},ac={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=m(e.orientation,"horizontal"),a=A(e.decorative,!0),n=m(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})}},Fn=(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},nc={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(Fn(m(i.title),m(i.details),A(i.active)));continue}a.append(Fn(m(n),""))}return a}},ic={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":m(e.value),"data-active":"false"});for(const n of C(e.children))a.append(r.renderNode(n));return a}},oc={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=m(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 c=m(e.defaultValue);if(!c&&a.length>0){const f=a[0];c=m(f?.args?.[0],"tab-0")}const u=r.useInstanceState("activeTab",c);m(e.defaultValue)&&m(e.defaultValue)!==c&&u.set(m(e.defaultValue)),new Set(a.map((f,g)=>m(f.args?.[0],`tab-${g}`))).has(u.get())||u.set(c);const d=(f,g)=>{const b=u.get();u.set(f);const h=g.closest(".rui-tabs");h&&(h.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}),h.querySelectorAll(".rui-tab-content").forEach(v=>{v.setAttribute("data-active",v.getAttribute("data-value")===f?"true":"false")})),b!==f&&r.invoke(e.onChange,f)};return a.forEach((f,g)=>{const b=f,h=m(b.args?.[0],`tab-${g}`),v=m(b.args?.[1],`Tab ${g+1}`),y=m(b.args?.[3]),x=m(b.args?.[4]),w=h===u.get(),k=l("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":h,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),T=x?sc(x):null;T&&k.append(T),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(h,M)},k.onkeydown=$=>{const M=$,I=n!=="vertical",L=I?M.key==="ArrowRight":M.key==="ArrowDown",R=I?M.key==="ArrowLeft":M.key==="ArrowUp";if(!L&&!R&&M.key!=="Home"&&M.key!=="End")return;M.preventDefault();const q=M.currentTarget??M.target,_=q.closest(".rui-tab-list");if(!_)return;const U=Array.from(_.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const J=U.indexOf(q);let Z=J;M.key==="Home"?Z=0:M.key==="End"?Z=U.length-1:L?Z=(J+1)%U.length:R&&(Z=(J-1+U.length)%U.length);const me=U[Z];if(!me)return;me.focus();const Ae=me.getAttribute("data-value")??"";Ae&&d(Ae,me)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",h),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function sc(t){return j(t,{className:"rui-tab-trigger-icon"})}const lc={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?A(e.showArrow)?"true":"false":null});A(e.open)&&n.setAttribute("open","");const i=l("summary",{class:"rui-accordion-trigger"});i.append(l("span",{class:"rui-accordion-title"},[m(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}},cc={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":A(e.showArrow)?"true":"false"});for(const n of C(e.items))a.append(r.renderNode(n));return a}},_t=t=>Math.max(1,Math.min(mt,Math.round(t)));function Rr(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 _t(Math.round(mt*n/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:_t(E(t,12))}function uc(t){const e=m(t.minChildWidth)||m(t.minItemWidth);return te(e||"220px","220px")}const dc={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=Rr(e.span??12),n=be(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(mt-1,Math.round(E(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 u of Qe){const p=n.values[u];if(p!==void 0){const d=Rr(p);s.push(`--rui-grid-item-span-${u}:${d}`)}}}else if(n.kind==="single"&&n.value!=null){const u=Rr(n.value);s.push(`--rui-grid-item-span:${u}`),o["data-span"]=String(u)}o.style=s.join(";");const c=l("div",o);return c.append(r.renderNode(e.child)),c}},pc={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=be(e.padding),n=be(e.margin),i={class:"rui-box","data-border":m(e.border,"none"),"data-background":m(e.background,"none")},o=[],s=m(e.maxWidth);if(s&&o.push(`max-width:${te(s,s)}`),a.kind==="single"){const u=a.value?String(a.value):null;u&&(i["data-padding"]=u)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",Ue(o,a,"--rui-box-padding");if(n.kind==="single"){const u=n.value?String(n.value):null;u&&(i["data-margin"]=u)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",Ue(o,n,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const c=l("div",i);for(const u of C(e.children))c.append(r.renderNode(u));return c}},Un={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=>ql(v,"GridItem")),i=be(e.columns),o=be(e.gap),s=be(e.rowGap),c=be(e.columnGap),u={class:"rui-grid"},p=[];let d=!1,f=!1;if(i.kind==="single"){const v=i.value===null?0:E(i.value,0),y=v>0?_t(v):0;if(y===mt?d=!0:y>0&&(f=!0),y>0){u["data-columns"]=String(y);const x=m(e.minChildWidth)||m(e.minItemWidth);x&&(u["data-min-child-width"]="true",p.push(`--rui-grid-min-child:${te(x,"220px")}`))}else p.push(`--rui-grid-min-item:${uc(e)}`)}else{u["data-responsive-cols"]="true";for(const v of Qe){const y=i.values[v];if(y===void 0)continue;const x=_t(E(y,0));x===mt?d=!0:x>0&&(f=!0),p.push(`--rui-grid-cols-${v}:${x}`)}}n&&!f&&(d=!0),d&&(u["data-grid-mode"]="12"),o.kind==="single"?u["data-gap"]=o.value?String(o.value):"m":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",Ue(p,o,"--rui-grid-gap")),s.kind==="single"&&s.value?u["data-row-gap"]=String(s.value):s.kind==="responsive"&&(u["data-row-gap"]="responsive",u["data-responsive-row-gap"]="true",Ue(p,s,"--rui-grid-row-gap")),c.kind==="single"&&c.value?u["data-column-gap"]=String(c.value):c.kind==="responsive"&&(u["data-column-gap"]="responsive",u["data-responsive-column-gap"]="true",Ue(p,c,"--rui-grid-column-gap"));const g=m(e.alignItems);g&&(u["data-align-items"]=g);const b=m(e.justifyItems);b&&(u["data-justify-items"]=b),A(e.dense)&&(u["data-dense"]="true"),p.length>0&&(u.style=p.join(";"));const h=l("div",u);for(const v of a)h.append(r.renderNode(v));return h}},mc={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=fc(m(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 fc(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 gc={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":m(e.direction,"vertical"),style:`max-height:${te(e.maxHeight,"320px")};`});for(const n of C(e.children))a.append(r.renderNode(n));return a}},hc={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=m(e.size,"md"),n=e.closable===void 0?!0:A(e.closable),i=l("div",{class:"rui-modal-overlay","data-open":A(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"},[m(e.title)]));const c=t.argMeta?.[1]?.stateRef,u=()=>{c&&r.setState(c,!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(),u()},s.append(f)}o.append(s);const p=l("div",{class:"rui-modal-body"});for(const f of C(e.children))p.append(r.renderNode(f));o.append(p);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),A(e.closeOnBackdrop)&&(i.onclick=f=>{f.target===i&&u()}),i}},bc=["solid","regular","brands"],Ot=["xs","sm","md","lg","xl"],vc=["default","neutral","primary","success","warning","danger","info"];function Dr(t,e="md"){const r=m(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":Ot.includes(r)?r:e:e}const yc={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:bc},{name:"size",type:"string",optional:!0,enum:El},{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=m(e.name),a=m(e.variant,""),n=m(e.size,"md"),i=m(e.color,""),o=a?`${a}:${r}`:r,s=j(o,{size:n,color:i});return s||l("span",{class:"rui-icon","data-icon-size":n},[r])}},xc=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function wc(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const Hn=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:xc},{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;").'}],Vn=(t,e)=>{const r=m(e.variant,"body"),a=m(e.tone,"default"),n=wc(e.style);return l("span",{class:"rui-text","data-variant":r,"data-color":a,style:n||null},[m(e.value)])},kc={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:Hn,render:Vn},Sc={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:Hn,render:Vn},Cc={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":m(e.fit,"cover"),style:e.ratio?`aspect-ratio:${$c(m(e.ratio))};`:null}),a=ne(e.src);if(a)r.append(l("img",{src:a,alt:m(e.alt),loading:"lazy"}));else{const i=l("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),o=m(e.fallback);if(o){const s=j(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=m(e.caption);return n&&r.append(l("figcaption",{class:"rui-image-caption"},[n])),r}};function $c(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 Wn=["neutral","primary","success","warning","danger","info"],Ac={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:Wn,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:Ot}],render:(t,e)=>{const r=m(e.tone,"neutral"),a=Dr(e.size,"md"),n=l("span",{class:"rui-badge","data-variant":r,"data-size":a}),i=j(e.icon,{className:"rui-badge-icon"});i&&n.append(i);const o=m(e.label);return o&&n.append(l("span",{class:"rui-badge-label"},[o])),n}},Tc={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:Wn,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:Ot}],render:(t,e)=>{const r=m(e.tone,"neutral"),a=Dr(e.size,"md"),n=l("div",{class:"rui-badge-list"});for(const i of C(e.labels)){const o=m(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}},Nc={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=m(e.tone,"info"),a=A(e.compact),n=l("div",{class:"rui-callout","data-variant":r,"data-compact":a?"true":"false"}),i=m(e.icon)||Ic(r),o=j(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"},[m(e.title)]));const c=m(e.description);return c&&s.append(l("div",{class:"rui-callout-description"},[c])),n.append(s),n}},Mc={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=m(e.language),a=m(e.codeString),n=A(e.showLineNumbers),i=Pc(m(e.highlightLines)),o=e.copy===void 0?!0:A(e.copy),s=l("div",{class:"rui-code-block"});if(r||o){const u=l("div",{class:"rui-code-block-head"});if(r&&u.append(l("span",{class:"rui-code-block-language"},[r])),o){const p=l("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),d=j("copy",{className:"rui-code-block-copy-icon"});d&&p.append(d),p.append(l("span",{class:"rui-code-block-copy-label"},["Copy"])),p.onclick=f=>{const g=f.currentTarget??f.target,h=g.closest(".rui-code-block")?.querySelector("code")?.textContent??a,y=(typeof navigator<"u"?navigator:null)?.clipboard;y?.writeText&&y.writeText(h).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)}},u.append(p)}s.append(u)}const c=l("pre",{class:"rui-code-block-pre","data-line-numbers":n?"true":"false"});if(n||i.size>0){const u=a.split(/\r?\n/),p=l("code",{});u.forEach((d,f)=>{const g=f+1,b=l("span",{class:"rui-code-block-line","data-line":String(g),"data-highlight":i.has(g)?"true":null});n&&b.append(l("span",{class:"rui-code-block-gutter"},[String(g)])),b.append(l("span",{class:"rui-code-block-code"},[d])),p.append(b)}),c.append(p)}else c.append(l("code",{},[a]));return s.append(c),s}};function Pc(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 Ic(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 Ec={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=m(e.variant),a=m(e.shape);if(a)return Lc(a,e);if(r&&r!=="paragraph")return zc(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,c=l("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let u=0;u<i;u+=1)c.append(l("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return c}};function Lc(t,e){const r=te(m(e.width),"100%"),a=m(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 zc(t,e){const r=l("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const a=te(m(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(m(e.width),"100%"),n=te(m(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 (`![alt](src)`), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=m(e.content),a=Oc(r);return l("div",{class:"rui-markdown",html:a})}},Dc={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":m(e.size,"lg"),"data-padding":m(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}},jc={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=m(e.size),a=e.flex===void 0?!r:A(e.flex);return l("span",{class:"rui-spacer","data-size":r||null,"data-flex":a?"true":"false","aria-hidden":"true"})}},Bc={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:Ot,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:vc,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=Dr(e.size,"md"),a=m(e.tone,"primary"),n=m(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}},_c={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":m(e.tone,"default")});r.append(l("blockquote",{class:"rui-quote-text"},[m(e.text)]));const a=m(e.cite);return a&&r.append(l("figcaption",{class:"rui-quote-cite"},[a])),r}};function Oc(t){const e=g=>g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=t.split(/\r?\n/),a=[];let n=null,i=!1,o=!1,s="",c=[];const u=()=>{n&&(a.push(n==="ul"?"</ul>":"</ol>"),n=null)},p=()=>{i&&(a.push("</blockquote>"),i=!1)},d=()=>{const g=s?` data-language="${e(s)}"`:"";a.push(`<pre class="rui-markdown-code"${g}><code>${e(c.join(`
97
+ `))}</code></pre>`),c=[],s="",o=!1};for(const g of r){const b=/^```\s*(.*)$/.exec(g.trim());if(o){if(b){d();continue}c.push(g);continue}if(b){u(),p(),o=!0,s=b[1]??"";continue}const h=/^\s*(#{1,3})\s+(.+)$/.exec(g);if(h){u(),p();const w=h[1].length;a.push(`<h${w} class="rui-markdown-h${w}">${f(e(h[2]))}</h${w}>`);continue}const v=/^\s*>\s?(.*)$/.exec(g);if(v){u(),i||(a.push('<blockquote class="rui-markdown-quote">'),i=!0),a.push(`<p>${f(e(v[1]??""))}</p>`);continue}else i&&g.trim()!==""&&p();const y=/^\s*[-*]\s+(.*)$/.exec(g);if(y){p(),n!=="ul"&&(u(),a.push("<ul>"),n="ul"),a.push(`<li>${f(e(y[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(g);if(x){p(),n!=="ol"&&(u(),a.push("<ol>"),n="ol"),a.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(g.trim()===""){u(),p();continue}u(),p(),a.push(`<p>${f(e(g))}</p>`)}return o&&d(),u(),p(),a.join("");function f(g){let b=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(h,v,y)=>{const x=ne(y);return x?`<img class="rui-markdown-image" src="${Ft(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,(h,v,y)=>`<a class="rui-link" href="${qn(y)}" target="_blank" rel="noopener noreferrer">${v}</a>`);return b=b.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,h=>`<a class="rui-link" href="${qn(h)}" target="_blank" rel="noopener noreferrer">${h}</a>`),b}}function qn(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return Ft(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return Ft(e);const a=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(a)?Ft(e):"#"}function Ft(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ft(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"},[gt(e)]))},a.append(i)}else a.append(l("span",{class:"rui-avatar-fallback"},[gt(e)]));return a}function gt(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 Ut=new WeakMap;function tt(t){const{liveRoot:e,onDismiss:r}=t,a=Ut.get(e);a&&a.dispose();const n=e.getRootNode();let i=!1;const o=d=>{const f=d.target;f&&e.contains(f)||(p.dispose(),r())},s=d=>{d.key==="Escape"&&(p.dispose(),r())},c=e.ownerDocument;let u=null;if(c&&typeof MutationObserver<"u"){u=new MutationObserver(()=>{e.isConnected||p.dispose()});const d=e.getRootNode();(d instanceof Element||d instanceof Document||d instanceof ShadowRoot)&&u.observe(d,{childList:!0,subtree:!0})}const p={dispose:()=>{i||(i=!0,n.removeEventListener("click",o,!0),n.removeEventListener("keydown",s,!0),u?.disconnect(),Ut.delete(e))}};return setTimeout(()=>{i||(n.addEventListener("click",o,!0),n.addEventListener("keydown",s,!0))},0),Ut.set(e,p),p}function Pe(t){if(!t)return;const e=Ut.get(t);e&&e.dispose()}const Fc=[{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 Kn(t){if(!t)return null;for(const e of Fc)if(e.match.test(t))return e.icon;return null}const Uc={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function Hc(t){return t?Uc[t.toLowerCase()]??null:null}function Vc(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 Gn(t){return C(t).map(r=>{if(r&&typeof r=="object"){const n=r;if(n.__kind==="Component"&&Array.isArray(n.args)){const i=m(n.args[0]);return{value:i,label:m(n.args[1],i)}}if(n.value!==void 0||n.label!==void 0){const i=m(n.value);return{value:i,label:m(n.label,i)}}}const a=m(r);return{value:a,label:a}}).filter(r=>r.value!==""||r.label!=="")}function rt(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 Ht(t,e){return l("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function Wc(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const qc=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function Kc(t){return(Array.isArray(t)?t.map(r=>m(r)):m(t).split(/\s+/)).map(r=>r.trim()).filter(r=>r.length>0&&r.length<=64&&qc.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=Ht("rui-on-click",{role:"button",tabindex:"0"});a.append(rt(r,e.child));const n=A(e.disabled),i=A(e.stopPropagation),o=s=>{n||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return a.addEventListener("click",o),a.addEventListener("keydown",s=>{const c=s;(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o(c))}),a}},Yc=[{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"}],Xc={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=Ht("rui-on-mouse");A(e.draggable)&&a.setAttribute("draggable","true"),a.append(rt(r,e.child));const n=e.passiveScroll===void 0?!0:A(e.passiveScroll);for(const{prop:i,event:o}of Yc){const s=e[i];if(s==null)continue;const u=o==="scroll"||o==="wheel"?{passive:n}:{};a.addEventListener(o,p=>{r.invoke(s,p)},u)}return a}},Jc=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],Zc={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:A(e.focusable),n=Ht("rui-on-keyboard",a?{tabindex:"0"}:{});n.append(rt(r,e.child));for(const{prop:i,event:o}of Jc){const s=e[i];s!=null&&n.addEventListener(o,c=>{r.invoke(s,c)})}return n}},Qc={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=Ht("rui-on-focus");return a.append(rt(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}},eu={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(rt(r,e.child));const n=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!n)return a;const i=Math.max(0,Math.min(1,E(e.threshold,.05))),o=m(e.rootMargin),s=A(e.once);let c=null;const u=new n(p=>{for(const d of p){const f=d.isIntersecting;if(f!==c&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,d),!f&&c===!0&&e.onLeave!=null&&r.invoke(e.onLeave,d),c=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:d.intersectionRatio}),s&&f){u.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return u.observe(a),r.registerDisposer(()=>u.disconnect()),a}};function tu(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 Yn={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=m(e.to),n=A(e.external),i=a||m(e.href),o=a?i.startsWith("/")||i.startsWith("#")?i:et(i,"#"):et(e.href,"#"),s=m(e.variant,"default"),c=l("a",{class:"rui-link","data-variant":s,href:o,target:n?"_blank":null,rel:n?"noopener noreferrer":null});for(const u of tu(r,e.label))c.append(u);return a&&!n&&c.addEventListener("click",u=>{u.defaultPrevented||u.button===0&&(u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r.router.navigate(a)))}),c}},ru={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=rt(r,e.child),n=a instanceof HTMLElement?a:(()=>{const s=l("span",{class:"rui-css"});return s.append(a),s})(),i=Kc(e.class);for(const s of i)n.classList.add(s);const o=Wc(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 au=["primary","secondary","ghost","danger"],nu=["xs","sm","md","lg","xl"],iu=["text","email","password","number","tel","url","date"];function ou(t){const e=m(t).trim().toLowerCase();return e==="xs"||e==="extra-small"?"xs":e==="sm"?"sm":e==="lg"?"lg":e==="xl"||e==="extra-large"?"xl":"md"}const su={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:au},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:nu,description:"Size token `xs|sm|md|lg|xl`"},{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=A(e.loading),n=A(e.iconOnly),i=m(e.iconPosition,"leading"),o=m(e.label),s=l("button",{class:"rui-button",type:m(e.type,"button"),"data-variant":m(e.variant,"primary"),"data-size":ou(e.size),"data-icon-position":i,"data-icon-only":n?"true":null,"data-full-width":A(e.fullWidth)?"true":null,"data-loading":a?"true":null,"aria-label":n?o:null,disabled:A(e.disabled)||a?"":null}),c=l("span",{class:"rui-button-label"},[o]),u=j(e.icon,{className:"rui-button-icon"}),d=(a?j("spinner",{className:"rui-button-spinner"}):null)??u;return n?d&&s.append(d):i==="trailing"?(s.append(c),d&&s.append(d)):(d&&s.append(d),s.append(c)),s.onclick=()=>{a||r.invoke(e.onClick)},s}},lu={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":m(e.direction,"row")});for(const n of C(e.items))a.append(r.renderNode(n));return a}},cu={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:iu},{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:m(e.id),name:m(e.id),type:m(e.type,"text"),placeholder:m(e.placeholder),value:m(e.value)});return He(a,t,4,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),Tu(a,e.validations),a}},uu={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:m(e.id),name:m(e.id),placeholder:m(e.placeholder),rows:String(Number(e.rows??4)||4)});return a.value=m(e.value),He(a,t,3,r),ie(a,e.onChange,r,{event:"input",getValue:n=>n.value}),a}},du={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>l("option",{value:m(e.value)},[m(e.label)])},pu={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(A(e.searchable))return Au(t,e,r);const a=l("select",{class:"rui-select",id:m(e.id),name:m(e.id)}),n=m(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=m(e.value),He(a,t,4,r),ie(a,e.onChange,r,{event:"change",getValue:i=>i.value}),a}},mu={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=A(e.value),i=l("input",{type:"checkbox",id:m(e.id),name:m(e.id),checked:n?"":null});return i.checked=n,He(i,t,2,r),ie(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),a.append(i,l("span",{class:"rui-checkbox-label"},[m(e.label)])),a}},fu={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=m(e.name),a=m(e.label),n=m(e.description),i=A(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 c=l("div",{class:"rui-checkbox-item-text"});return c.append(l("div",{class:"rui-checkbox-item-label"},[a])),n&&c.append(l("div",{class:"rui-checkbox-item-description"},[n])),o.append(s,c),o}},gu={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=m(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((u,p)=>{const d=m(u.args?.[0]),f=m(u.args?.[1],`${a}-${p}`),g=m(u.args?.[2]),b=A(u.args?.[3]),h=`${a}-${f}`,v=l("label",{class:"rui-checkbox-item",for:h}),y=f in o?!!o[f]:b,x=l("input",{type:"checkbox",id:h,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,c=u=>{const p={};return u.querySelectorAll('input[type="checkbox"]').forEach(d=>{p[d.name]=d.checked}),p};return s&&r.bindState(n,s,{event:"change",getValue:c}),ie(n,e.onChange,r,{event:"change",getValue:u=>c(u)}),n}},hu={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=m(e.id),n=l("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of C(e.items)){const o=m(i.args?.[0]),s=m(i.args?.[1],o),c=`${a}-${o}`,u=l("label",{class:"rui-radio",for:c}),p=m(e.value)===o,d=l("input",{type:"radio",id:c,name:a,value:o,checked:p?"":null});d.checked=p,He(d,t,2,r),ie(d,e.onChange,r,{event:"change",getValue:f=>f.value}),u.append(d,l("span",{class:"rui-radio-label"},[s])),n.append(u)}return n}},bu={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"},[m(e.label)]));const n=r.renderNode(e.field);a.append(n);const i=m(e.hint);return i&&a.append(l("p",{class:"rui-form-hint"},[i])),a}},Xn={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=j("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:m(e.id),name:m(e.id),type:"search",placeholder:m(e.placeholder,"Search…"),value:m(e.value),autocomplete:"off"});He(i,t,2,r),ie(i,e.onChange,r,{event:"input",getValue:s=>s.value}),a.append(i);const o=m(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"},[m(e.submitLabel,"Search")]);a.append(s)}return a}},vu={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:m(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}},yu={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=m(e.id),n=E(e.min,0),i=E(e.max,100),o=E(e.step,1),s=E(e.value,n),c=l("div",{class:"rui-slider","data-disabled":A(e.disabled)?"true":"false"}),u=m(e.label),p=A(e.showValue);if(u||p){const g=l("div",{class:"rui-slider-head"});u&&g.append(l("label",{class:"rui-slider-label",for:a},[u])),p&&g.append(l("span",{class:"rui-slider-value"},[String(s)])),c.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:A(e.disabled)?"":null});d.oninput=g=>{const b=g.currentTarget;if(!b)return;const v=b.closest(".rui-slider")?.querySelector(".rui-slider-value");v&&(v.textContent=b.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)}),c.append(d),c}},xu={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=m(e.id),n=E(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?E(e.min,0):Number.NEGATIVE_INFINITY,c=o?E(e.max,0):Number.POSITIVE_INFINITY,u=A(e.disabled),p=l("div",{class:"rui-number-input","data-disabled":u?"true":"false"}),d=l("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:u?"":null},["−"]),f=l("input",{type:"number",class:"rui-number-input-field",id:a,name:a,value:m(e.value),placeholder:m(e.placeholder),min:i?String(s):null,max:o?String(c):null,step:String(n),disabled:u?"":null}),g=l("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:u?"":null},["+"]),b=t.argMeta?.[1]?.stateRef,h=y=>{const x=y.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};b&&r.bindState(f,b,{event:"input",getValue:h}),ie(f,e.onChange,r,{event:"input",getValue:h});const v=(y,x)=>{const k=y.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const T=Number(k.value),S=Number.isFinite(T)?T:0,$=$u(S+x,s,c);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),p.append(d,f,g),p}},wu={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=m(e.id),n=l("div",{class:"rui-date-picker"}),i=m(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:m(e.value),min:m(e.min)||null,max:m(e.max)||null,placeholder:m(e.placeholder),disabled:A(e.disabled)?"":null});return He(o,t,1,r),ie(o,e.onChange,r,{event:"change",getValue:s=>s.value}),n.append(o),n}},ku={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=m(e.id),n=A(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=j(m(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const c=l("div",{class:"rui-file-upload-text"});c.append(l("div",{class:"rui-file-upload-label"},[m(e.label,"Choose a file")]));const u=m(e.hint);u&&c.append(l("div",{class:"rui-file-upload-hint"},[u])),o.append(c);const p=l("input",{type:"file",id:a,name:a,class:"rui-file-upload-input",accept:m(e.accept)||null,multiple:A(e.multiple)?"":null,disabled:n?"":null});o.append(p),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 p.onchange=f=>{const g=f.currentTarget;r.invoke(e.onSelect,g.files);const b=g.closest(".rui-file-upload");if(!b)return;const h=g.files,v=b.querySelector(".rui-file-upload-preview");if(v&&v.remove(),!h||h.length===0)return;const y=m(e.accept),x=l("div",{class:"rui-file-upload-preview"});Array.from(h).forEach(w=>{const k=l("div",{class:"rui-file-upload-preview-item"});if(d(w,y)){const T=URL.createObjectURL(w),S=l("img",{src:T,alt:w.name,class:"rui-file-upload-thumbnail"});S.onload=()=>URL.revokeObjectURL(T),k.append(S)}k.append(l("span",{class:"rui-file-upload-filename"},[w.name])),x.append(k)}),b.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=m(e.id),n=Gn(e.items),i=m(e.value),o=n.find(S=>S.value===i)?.label??i,s=m(e.placeholder,"Select…"),c=m(e.emptyLabel,"No matches"),u=A(e.disabled),p=A(e.open),d=r.useInstanceState("open",p),f=r.useInstanceState("filter",""),g=d.get(),b=l("div",{class:"rui-combobox","data-open":g?"true":"false","data-disabled":u?"true":"false"}),h=l("button",{type:"button",class:"rui-combobox-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:u?"":null});h.append(l("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const v=j("chevron-down",{className:"rui-combobox-chevron"});v&&h.append(v),b.append(h);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(L=>L.label.toLowerCase().includes(M)||L.value.toLowerCase().includes(M));if(I.length===0){S.append(l("div",{class:"rui-combobox-empty"},[c]));return}for(const L of I){const R=l("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":L.value,"aria-selected":L.value===i?"true":"false"},[L.label]);R.onclick=q=>{q.stopPropagation(),T(q.currentTarget,L.value)},S.append(R)}},T=(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"),Pe(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 L=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),R=L?.getAttribute("data-value");R!=null&&L&&T(L,R)},h.onclick=S=>{if(u)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(!$){Pe(M);return}setTimeout(()=>x.focus(),0),tt({liveRoot:M,onDismiss:()=>{d.set(!1),f.set(""),M.setAttribute("data-open","false"),M.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},b.append(y),b}},Su={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=m(e.id),n=Gn(e.items),i=m(e.placeholder,"Select…"),o=m(e.emptyLabel,"No matches"),s=A(e.disabled),c=Math.max(0,Math.floor(Number(e.max??0))),u=Array.isArray(e.value)?e.value.map(I=>m(I)).filter(Boolean):[],p=new Set(u),d=t.argMeta?.[2]?.stateRef,f=A(e.open),g=r.useInstanceState("open",f),b=r.useInstanceState("filter",""),h=g.get(),v=l("div",{class:"rui-multiselect","data-open":h?"true":"false","data-disabled":s?"true":"false"}),y=l("button",{type:"button",class:"rui-multiselect-trigger",id:a,"aria-haspopup":"listbox","aria-expanded":h?"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(u.length===0)x.append(l("span",{class:"rui-multiselect-placeholder"},[i]));else for(const I of u){const L=n.find(_=>_.value===I)?.label??I,R=l("span",{class:"rui-multiselect-chip","data-value":I});R.append(l("span",{class:"rui-multiselect-chip-label"},[L]));const q=l("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${L}`},["×"]);q.onclick=_=>{_.stopPropagation();const U=u.filter(J=>J!==I);w(U)},R.append(q),x.append(R)}y.append(x);const k=j("chevron-down",{className:"rui-multiselect-chevron"});k&&y.append(k),v.append(y);const T=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:b.get()});T.append(S);const $=l("div",{class:"rui-multiselect-list"});T.append($);const M=(I,L)=>{I.replaceChildren();const R=L.trim().toLowerCase(),q=R===""?n:n.filter(_=>_.label.toLowerCase().includes(R)||_.value.toLowerCase().includes(R));if(q.length===0){I.append(l("div",{class:"rui-multiselect-empty"},[o]));return}for(const _ of q){const U=p.has(_.value),J=!U&&c>0&&u.length>=c,Z=l("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":_.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:J?"":null}),me=l("span",{class:"rui-multiselect-option-check"}),Ae=j(U?"check":"",{className:"rui-multiselect-option-check-icon"});Ae&&me.append(Ae),Z.append(me),Z.append(l("span",{class:"rui-multiselect-option-label"},[_.label])),Z.onclick=xt=>{if(xt.stopPropagation(),J)return;const Ke=U?u.filter(ra=>ra!==_.value):[...u,_.value];w(Ke)},I.append(Z)}};return M($,b.get()),S.oninput=I=>{const L=I.currentTarget;b.set(L.value);const R=L.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");R&&M(R,L.value)},y.onclick=I=>{if(s)return;I.stopPropagation();const L=!g.get();g.set(L);const R=I.currentTarget.closest(".rui-multiselect");if(R?.setAttribute("data-open",L?"true":"false"),R?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",L?"true":"false"),!!R){if(!L){Pe(R);return}setTimeout(()=>S.focus(),0),tt({liveRoot:R,onDismiss:()=>{g.set(!1),b.set(""),R.setAttribute("data-open","false"),R.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},v.append(T),v}},Cu={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=m(e.id),n=`${a}-from`,i=`${a}-to`,o=m(e.min),s=m(e.max),c=A(e.disabled),u=l("div",{class:"rui-date-range-picker","data-disabled":c?"true":"false"}),p=m(e.label);p&&u.append(l("label",{class:"rui-date-range-picker-label",for:n},[p]));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:m(e.from),min:o||null,max:s||null,disabled:c?"":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:m(e.to),min:o||null,max:s||null,disabled:c?"":null,"data-role":"to"});d.append(g),u.append(d);const b=t.argMeta?.[1]?.stateRef,h=t.argMeta?.[2]?.stateRef;if(b&&r.bindState(f,b),h&&r.bindState(g,h),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 u}};function $u(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Au(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 He(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 Tu(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 Be=["default","primary","success","warning","danger","info"],Ve=(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},Nu=[{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 Mu(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const a of Nu)if(a.match.test(r))return a.label;return""}const Pu={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:Be,description:"Accent tone"}],render:(t,e,r)=>{const a=m(e.layout,"default"),n=m(e.title),i=m(e.subtitle),s=m(e.eyebrow)||Mu(n,i),c=m(e.tone,"primary");if(a==="cover"){const b=zl(m(e.imageSrc)),h=te(m(e.height),"280px"),v=l("section",{class:"rui-cover","data-tone":c,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${b}");min-height:${h};`}),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=m(e.caption);x&&y.append(l("p",{class:"rui-cover-caption"},[x]));const w=Ve(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 T=l("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)T.append(r.renderNode(S));y.append(T)}}return v.append(y),v}const u=ne(e.imageSrc),p=l("section",{class:"rui-hero","data-tone":c,"data-has-image":u?"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 b=l("div",{class:"rui-hero-highlights"});for(const h of f){const v=m(h);v&&b.append(l("span",{class:"rui-hero-highlight"},[v]))}d.append(b)}const g=[e.primary,e.secondary].filter(Boolean);if(g.length>0){const b=l("div",{class:"rui-hero-ctas"});for(const h of g)b.append(r.renderNode(h));d.append(b)}if(p.append(d),u){const b=l("div",{class:"rui-hero-media"});b.append(l("img",{src:u,alt:"",loading:"lazy"})),p.append(b)}return p}},Iu={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=m(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"},[m(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"}),c=l("div",{class:"rui-page-header-title-line"});c.append(l("h1",{class:"rui-page-header-title"},[n])),e.status&&c.append(r.renderNode(e.status)),s.append(c);const u=m(e.subtitle);u&&s.append(l("p",{class:"rui-page-header-subtitle"},[u])),o.append(s);const p=Ve(e.actions,r);return p&&(p.classList.add("rui-page-header-actions"),o.append(p)),a.append(o),a}},Eu={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=m(e.title),c=m(e.description),u=m(e.icon)||Kn(`${s} ${c}`)||"inbox",p=j(u,{className:"rui-empty-state-icon"});p&&a.append(p)}a.append(l("h3",{class:"rui-empty-state-title"},[m(e.title)]));const i=m(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 c of o)s.append(r.renderNode(c));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}},Lu={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:Be}],render:(t,e)=>{const r=l("li",{class:"rui-timeline-item","data-tone":m(e.tone,"default")}),a=l("span",{class:"rui-timeline-marker"}),n=j(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"},[m(e.title)]));const s=m(e.time);s&&o.append(l("span",{class:"rui-timeline-time"},[s])),i.append(o);const c=m(e.description);return c&&i.append(l("div",{class:"rui-timeline-description"},[c])),r.append(i),r}},zu={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:Be}],render:(t,e)=>{const r=l("div",{class:"rui-feature-item","data-tone":m(e.tone,"primary")}),a=m(e.icon,"sparkles"),n=j(a,{className:"rui-feature-icon"});n&&r.append(n),r.append(l("h3",{class:"rui-feature-title"},[m(e.title)]));const i=m(e.description);return i&&r.append(l("p",{class:"rui-feature-description"},[i])),r}},Du={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}},ju={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 c=l("div",{class:"rui-testimonial-rating"});for(let u=0;u<5;u+=1){const p=u<a,d=j(p?"star":"regular:star",{className:"rui-testimonial-rating-star"});d&&c.append(d)}r.append(c)}r.append(l("blockquote",{class:"rui-testimonial-quote"},[m(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"},[m(e.author)]));const s=m(e.role);return s&&o.append(l("div",{class:"rui-testimonial-role"},[s])),n.append(o),r.append(n),r}},Bu={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(ft(m(e.avatarSrc),m(e.name),"lg"));const i=l("div",{class:"rui-profile-card-meta"});i.append(l("h3",{class:"rui-profile-card-name"},[m(e.name)]));const o=m(e.role);o&&i.append(l("p",{class:"rui-profile-card-role"},[o])),n.append(i),a.append(n);const s=m(e.bio);s&&a.append(l("p",{class:"rui-profile-card-bio"},[s]));const c=C(e.tags);if(c.length>0){const p=l("div",{class:"rui-profile-card-tags"});for(const d of c){const f=m(d);f&&p.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[f])]))}a.append(p)}const u=Ve(e.actions,r);return u&&(u.classList.add("rui-profile-card-actions"),a.append(u)),a}},_u={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(ft(m(e.avatarSrc),m(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"},[m(e.author)]));const o=m(e.time);o&&i.append(l("span",{class:"rui-comment-time"},[o])),n.append(i),n.append(l("div",{class:"rui-comment-content"},[m(e.body)]));const s=Ve(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),n.append(s)),a.append(n),a}},Ou={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:Be}],render:(t,e,r)=>{const a=m(e.tone,"primary"),n=l("aside",{class:"rui-banner","data-tone":a}),i=m(e.icon)||Hc(a)||"",o=j(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"},[m(e.title)]));const c=m(e.message);if(c&&s.append(l("span",{class:"rui-banner-message"},[c])),n.append(s),e.action){const u=l("div",{class:"rui-banner-action"});u.append(r.renderNode(e.action)),n.append(u)}return n}},Fu={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:Be},{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":m(e.tone,"default")});typeof e.onClick=="function"&&(a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.onclick=()=>r.invoke(e.onClick),a.onkeydown=u=>{const p=u;(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r.invoke(e.onClick))});const n=l("div",{class:"rui-kanban-card-title"}),i=j(e.icon,{className:"rui-kanban-card-icon"});i&&n.append(i),n.append(document.createTextNode(m(e.title))),a.append(n);const o=m(e.description);o&&a.append(l("p",{class:"rui-kanban-card-description"},[o]));const s=C(e.tags);if(s.length>0){const u=l("div",{class:"rui-kanban-card-tags"});for(const p of s){const d=m(p);d&&u.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[d])]))}a.append(u)}const c=m(e.assignee);if(c){const u=l("footer",{class:"rui-kanban-card-footer"});u.append(ft("",c,"sm")),u.append(l("span",{class:"rui-kanban-card-assignee"},[c])),a.append(u)}return a}},Uu={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:Be,description:"Header accent tone"}],render:(t,e,r)=>{const a=C(e.items),n=l("section",{class:"rui-kanban-column","data-tone":m(e.tone,"default")}),i=l("header",{class:"rui-kanban-column-header"});i.append(l("span",{class:"rui-kanban-column-title"},[m(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}},Hu={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}},Vu={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=m(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"},[m(e.title)])),e.status&&o.append(r.renderNode(e.status)),n.append(o);const s=m(e.subtitle);s&&n.append(l("p",{class:"rui-section-header-subtitle"},[s])),a.append(n);const c=Ve(e.actions,r);return c&&(c.classList.add("rui-section-header-actions"),a.append(c)),a}},Wu={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"});A(e.searchable)&&i.append(Xn.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:m(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 c of a)s.append(r.renderNode(c));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}},qu={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=m(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?A(e.active):o,c=l("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":a||null}),u=j(e.icon,{className:"rui-sidebar-item-icon"});u&&c.append(u),c.append(l("span",{class:"rui-sidebar-item-label"},[m(e.label)]));const p=m(e.badge);return p&&c.append(l("span",{class:"rui-sidebar-item-badge"},[p])),(a||e.onClick!=null)&&(c.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)}),c}},Ku={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=m(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=A(e.collapsed),n=l("aside",{class:"rui-sidebar"});a&&(n.dataset.collapsed="true");const i=m(e.brand),o=m(e.tagline);if(i||o){const u=l("div",{class:"rui-sidebar-header"});i&&u.append(l("div",{class:"rui-sidebar-brand"},[i])),o&&u.append(l("div",{class:"rui-sidebar-tagline"},[o])),n.append(u)}const s=l("nav",{class:"rui-sidebar-body"});for(const u of C(e.items))s.append(r.renderNode(u));n.append(s);const c=C(e.footer);if(c.length>0){const u=l("div",{class:"rui-sidebar-footer"});for(const p of c)u.append(r.renderNode(p));n.append(u)}return n}},Yu={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=A(e.collapsible),n=A(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 p=l("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});p.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(p)}const s=l("div",{class:"rui-app-shell-main"}),c=C(e.topbar);if(c.length>0||a){const p=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(j("bars",{size:"md"})??document.createTextNode("≡")),d.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),p.append(d)}for(const d of c)p.append(r.renderNode(d));s.append(p)}const u=l("div",{class:"rui-app-shell-content"});for(const p of C(e.content))u.append(r.renderNode(p));return s.append(u),i.append(s),i}},Xu={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(m(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}},Ju={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=j(e.icon,{className:"rui-description-icon"});i&&n.append(i),n.append(document.createTextNode(m(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(m(e.value))),a.append(n,o),a}},Zu={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}},Qu={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":m(e.tone,"success"),"data-pulse":A(e.pulse)?"true":"false"});return r.append(l("span",{class:"rui-status-dot-marker"})),r.append(l("span",{class:"rui-status-dot-label"},[m(e.label)])),r}},ed={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=A(e.featured),n=l("article",{class:"rui-pricing-card","data-featured":a?"true":"false"}),i=m(e.badge);i&&n.append(l("div",{class:"rui-pricing-card-badge"},[i])),n.append(l("h3",{class:"rui-pricing-card-plan"},[m(e.plan)]));const o=m(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"},[m(e.price)]));const c=m(e.period);c&&s.append(l("span",{class:"rui-pricing-card-period"},[c])),n.append(s);const u=C(e.features);if(u.length>0){const p=l("ul",{class:"rui-pricing-card-features"});for(const d of u){const f=m(d);if(!f)continue;const g=j("circle-check",{className:"rui-pricing-card-check"})??l("span",{class:"rui-pricing-card-check"});p.append(l("li",{class:"rui-pricing-card-feature"},[g,document.createTextNode(f)]))}n.append(p)}if(e.action){const p=l("div",{class:"rui-pricing-card-action"});p.append(r.renderNode(e.action)),n.append(p)}return n}},td={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}},rd={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=m(e.orientation,"vertical"),n=l("article",{class:"rui-media-card","data-orientation":a}),i=ad(m(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:m(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const g=j("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(m(e.badge))):g.append(r.renderNode(e.badge)),o.append(g)}n.append(o);const c=l("div",{class:"rui-media-card-body"});c.append(l("h3",{class:"rui-media-card-title"},[m(e.title)]));const u=m(e.description);u&&c.append(l("p",{class:"rui-media-card-description"},[u]));const p=C(e.tags);if(p.length>0){const g=l("div",{class:"rui-media-card-tags"});for(const b of p){const h=m(b);h&&g.append(l("span",{class:"rui-tag","data-size":"sm"},[l("span",{class:"rui-tag-label"},[h])]))}c.append(g)}const d=m(e.meta);d&&c.append(l("p",{class:"rui-media-card-meta"},[d]));const f=Ve(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),c.append(f)),n.append(c),n}};function ad(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 jr(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),c=s-o||1,u=80/(t.length-1),d=t.map((h,v)=>{const y=v*u,x=2+(s-h)/c*20;return[y,x]}).map(([h,v],y)=>`${y===0?"M":"L"}${h.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 b=document.createElementNS(n,"path");return b.setAttribute("d",d),b.setAttribute("class","rui-sparkline-line"),b.setAttribute("fill","none"),i.appendChild(b),i}const nd={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(c=>c&&typeof c=="object"&&c.__kind==="Component");if(m(e.layout,n?"grid":"strip")==="grid"){const c=e.columns?Math.max(1,Math.min(6,Math.floor(E(e.columns)))):0,u=Un.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:a,columns:c>0?c:"auto",gap:"m"},r);return u.classList.add("rui-metric-grid"),u}const o=m(e.align,"start"),s=l("div",{class:"rui-stats","data-align":o});for(const c of a){const u=c??{},p=m(u.tone,"default"),d=l("div",{class:"rui-stats-item","data-tone":p});d.append(l("div",{class:"rui-stats-label"},[m(u.label)]));const f=l("div",{class:"rui-stats-value-row"});f.append(l("div",{class:"rui-stats-value"},[m(u.value)]));const g=C(u.spark).map(h=>Number(h)).filter(h=>Number.isFinite(h));g.length>1&&f.append(jr(g,p)),d.append(f);const b=m(u.hint);b&&d.append(l("div",{class:"rui-stats-hint"},[b])),s.append(d)}return s}},id={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:Be},{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":m(e.tone,"default")}),o=j(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"},[m(e.label)]));const c=m(e.value);c&&s.append(l("div",{class:"rui-tile-value"},[c]));const u=m(e.description);return u&&s.append(l("div",{class:"rui-tile-description"},[u])),i.append(s),a&&(i.onclick=()=>r.invoke(e.onClick)),i}},Zn={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:Be},{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=A(e.unread),n=l("article",{class:"rui-notification","data-tone":m(e.tone,"default"),"data-unread":a?"true":"false"}),i=m(e.avatarSrc),o=l("div",{class:"rui-notification-visual"});if(i)o.append(ft(i,m(e.title),"md"));else{const g=j(m(e.icon,"bell"),{className:"rui-notification-icon"});g&&o.append(g)}n.append(o);const s=l("div",{class:"rui-notification-body"}),c=l("header",{class:"rui-notification-head"}),u=l("span",{class:"rui-notification-title-wrap"});a&&u.append(l("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),u.append(l("span",{class:"rui-notification-title"},[m(e.title)])),c.append(u);const p=m(e.time);p&&c.append(l("span",{class:"rui-notification-time"},[p])),s.append(c);const d=m(e.message);d&&s.append(l("p",{class:"rui-notification-message"},[d]));const f=Ve(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),n.append(s),n}},od={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=m(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}),c=l("span",{class:"rui-person-chip-avatar"});c.append(ft(m(e.avatarSrc),m(e.name),o));const u=m(e.status);u&&c.append(l("span",{class:"rui-person-chip-status","data-status":u})),s.append(c);const p=l("div",{class:"rui-person-chip-meta"});p.append(l("span",{class:"rui-person-chip-name"},[m(e.name)]));const d=m(e.role);return d&&p.append(l("span",{class:"rui-person-chip-role"},[d])),s.append(p),a&&(s.onclick=()=>r.invoke(e.onClick)),s}},Qn=["left","center","right"],sd={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:Qn,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",{},[m(e.header)])),r}},ld={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=m(e.density,"comfortable"),i=A(e.striped),o=A(e.sticky),s=l("div",{class:"rui-table-wrapper","data-density":n,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),c=l("table",{class:"rui-table"}),u=m(e.caption);u&&c.append(l("caption",{class:"rui-table-caption"},[u]));const p=a.map(w=>{const k=m(w.args?.[3],"");return Qn.includes(k)?k:""}),d=l("thead"),f=l("tr");for(let w=0;w<a.length;w+=1){const k=a[w],T=l("th",{"data-align":p[w]||null},[m(k.args?.[0])]);f.append(T)}d.append(f),c.append(d);const g=l("tbody"),b=a.map(w=>C(w.args?.[1])),h=a.map(w=>m(w.args?.[2],"text")),v=a.map(w=>w.args?.[6]),y=a.map(w=>w.args?.[7]),x=Math.max(0,...b.map(w=>w.length));for(let w=0;w<x;w+=1){const k=l("tr");b.forEach((T,S)=>{const $=h[S]??"text",M=p[S],I=l("td",{"data-format":$,"data-align":M||null});Nr(I,{format:$,render:v[S],onClick:y[S]},T[w],w,r,hd),k.append(I)}),g.append(k)}if(x===0){const w=l("tr"),k=m(e.emptyLabel,"No data");w.append(l("td",{colspan:String(a.length||1),class:"rui-table-empty"},[k])),g.append(w)}return c.append(g),s.append(c),s}},cd={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=j(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"},[m(e.title)]));const i=m(e.description);return i&&n.append(l("div",{class:"rui-list-description"},[i])),r.append(n),r}},ud={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.ordered)?"ol":"ul",n=l(a,{class:"rui-list"});for(const i of C(e.items))n.append(r.renderNode(i));return n}},dd={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=m(e.tone,"default"),a=l("div",{class:"rui-stat-card","data-tone":r}),n=l("div",{class:"rui-stat-label-row"}),i=m(e.label),o=m(e.icon)||Kn(i)||"",s=j(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"},[m(e.value)]));const c=m(e.delta),u=m(e.trend);(c||u)&&a.append(l("div",{class:"rui-stat-trend","data-trend":u||"flat"},[c||gd(u)]));const p=C(e.spark).map(d=>E(d));if(p.length>1){const d=l("div",{class:"rui-stat-spark"});d.append(jr(p,r==="default"?"primary":r)),a.append(d)}return a}},pd={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=m(e.tone,"primary"),a=C(e.values).map(i=>E(i)),n=l("span",{class:"rui-sparkline-wrap"});return n.append(jr(a,r)),n}},md={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=A(e.expanded),o=A(e.active),s=typeof e.onClick=="function",c=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 b=j("chevron-right",{className:"rui-tree-node-chevron"});b&&c.append(b)}else c.append(l("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const u=j(e.icon,{className:"rui-tree-node-icon"});u&&c.append(u),c.append(l("span",{class:"rui-tree-node-label"},[m(e.label)]));const p=m(e.badge);if(p&&c.append(l("span",{class:"rui-tree-node-badge"},[p])),s&&(c.onclick=()=>r.invoke(e.onClick)),!n)return c;const d=l("details",{class:"rui-tree-node"});i&&d.setAttribute("open","");const f=l("summary",{class:"rui-tree-node-summary"});f.append(c),s&&(f.onclick=b=>{b.target?.closest(".rui-tree-node-chevron")||b.preventDefault()}),d.append(f);const g=l("div",{class:"rui-tree-node-children",role:"group"});for(const b of a)g.append(r.renderNode(b));return d.append(g),d}},fd={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 gd(t){return t==="up"?"▲":t==="down"?"▼":"—"}function hd(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():m(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):m(t);case"date":try{const r=new Date(m(t));return Number.isNaN(r.getTime())?m(t):r.toLocaleDateString()}catch{return m(t)}default:return m(t)}}const Br=["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)"],at=t=>Br[t%Br.length]??Br[0],bd={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":m(e.name)})},ei=t=>t.map((e,r)=>{const a=e,n=m(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>E(o));return{name:n,values:i}}),vd={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=>m(y)),a=ei(C(e.series)),n=l("div",{class:"rui-chart rui-bar-chart"});m(e.title)&&n.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const i=Math.max(1,...a.flatMap(y=>y.values)),o=640,s=240,c=ri(r,o-40-12),u={left:40,right:12,top:12,bottom:c.bottomPadding},p=o-u.left-u.right,d=s-u.top-u.bottom,f=_r(o,s);ni(f,u,p,d,i);const g=r.length,b=p/Math.max(g,1),h=a.length,v=b*.7/Math.max(h,1);return a.forEach((y,x)=>{y.values.forEach((w,k)=>{const T=w/i*d,S=u.left+k*b+b*.15+x*v,$=u.top+d-T,M=ve("rect",{x:String(S),y:String($),width:String(Math.max(v-2,1)),height:String(T),fill:at(x),rx:"2"});M.append(ve("title",{},[`${y.name}: ${w}`])),f.append(M)})}),ai(f,r,u,p,d,c,y=>u.left+(y+.5)*b),n.append(f),a.length>0&&n.append(Or(a)),n}},yd={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($=>m($)),a=ei(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 L=I;if(!(!L||typeof L!="object")){$.push(m(L.x??L.label??""));for(const[R,q]of Object.entries(L)){if(R==="x"||R==="label")continue;const _=E(q);Number.isNaN(_)||(M.has(R)||M.set(R,[]),M.get(R).push(_))}}}r.length===0&&(r=$),a.length===0&&(a=[...M.entries()].map(([I,L])=>({name:I,values:L})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...a.map($=>$.values.length),1),c=a.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let M=0;a.forEach((I,L)=>{M+=I.values[$]??0,c[L][$]=M})}const u=l("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});m(e.title)&&u.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const p=i&&o?c.flat():a.flatMap($=>$.values),d=Math.max(1,...p),f=i&&o?0:Math.min(0,...p),g=640,b=240,h=ri(r,g-40-12),v={left:40,right:12,top:12,bottom:h.bottomPadding},y=g-v.left-v.right,x=b-v.top-v.bottom,w=_r(g,b);ni(w,v,y,x,d,f);const k=Math.max(r.length-1,1),T=y/k,S=$=>v.left+$*(y/Math.max(s-1,1));return a.forEach(($,M)=>{const I=i&&o?c[M]:$.values,L=i&&o&&M>0?c[M-1]:null,R=I.map((_,U)=>{const J=S(U),Z=v.top+x-(_-f)/(d-f||1)*x;return[J,Z]});if(i&&R.length>0){let _=R.map(([U,J],Z)=>`${Z===0?"M":"L"}${U.toFixed(1)},${J.toFixed(1)}`).join(" ");if(L){const U=L.map((J,Z)=>{const me=S(Z),Ae=v.top+x-(J-f)/(d-f||1)*x;return[me,Ae]});_+=" "+U.slice().reverse().map(([J,Z])=>`L${J.toFixed(1)},${Z.toFixed(1)}`).join(" ")+" Z"}else{const U=R[0],J=R[R.length-1];_+=` L${J[0].toFixed(1)},${(v.top+x).toFixed(1)} L${U[0].toFixed(1)},${(v.top+x).toFixed(1)} Z`}w.append(ve("path",{d:_,fill:at(M),"fill-opacity":"0.2",stroke:"none"}))}const q=R.map(([_,U],J)=>`${J===0?"M":"L"}${_.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(ve("path",{d:q,fill:"none",stroke:at(M),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&R.forEach(([_,U])=>{w.append(ve("circle",{cx:String(_),cy:String(U),r:"3",fill:at(M)}))})}),ai(w,r,v,y,x,h,$=>v.left+$*T),u.append(w),a.length>0&&u.append(Or(a)),u}},xd={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(h=>m(h)),a=C(e.values).map(h=>E(h)),n=e.showValues==null?!0:A(e.showValues),i=m(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=l("div",{class:"rui-chart rui-pie-chart"});m(e.title)&&s.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const c=a.reduce((h,v)=>h+(v>0?v:0),0)||1,u=_r(240,240),p=120,d=120,f=90,g=.05;let b=-Math.PI/2;return a.forEach((h,v)=>{const y=h>0?h:0,x=y/c,w=x*Math.PI*2,k=b+w,T=w>Math.PI?1:0,S=p+f*Math.cos(b),$=d+f*Math.sin(b),M=p+f*Math.cos(k),I=d+f*Math.sin(k),L=`M${p},${d} L${S},${$} A${f},${f} 0 ${T} 1 ${M},${I} Z`,R=ve("path",{d:L,fill:at(v),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(R.append(ve("title",{},[`${r[v]??""}: ${h} (${(x*100).toFixed(1)}%)`])),u.append(R),n&&y>0&&x>=g){const q=b+w/2,_=f*.62,U=p+_*Math.cos(q),J=d+_*Math.sin(q),Z=wd(h,x,o),me=ve("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]);u.append(me)}b=k}),s.append(u),s.append(Or(r.map((h,v)=>({name:h,values:[a[v]??0]})))),s}};function wd(t,e,r){const a=`${Math.round(e*100)}%`,n=kd(t);return r==="percent"?a:r==="both"?`${n} (${a})`:n}function kd(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 Sd=7,ti=12;function ri(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*Sd+4<=r)return{step:1,rotated:!1,maxChars:a,bottomPadding:32};const n=r<ti?Math.max(1,Math.ceil(ti/r)):1,i=Math.min(a,14);return{step:n,rotated:!0,maxChars:i,bottomPadding:60}}function Cd(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function ai(t,e,r,a,n,i,o){const s=r.top+n+(i.rotated?14:18);e.forEach((c,u)=>{if(u%i.step!==0)return;const p=o(u),d=Cd(c,i.maxChars),f={x:String(p),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${p}, ${s})`);const g=ve("text",f,[d]);d!==c&&g.append(ve("title",{},[c])),t.append(g)})}function _r(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 ve(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 ni(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ve("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ve("text",{x:String(e.left-6),y:String(u+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}function Or(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:${at(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const $d={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"},[m(e.title)]));const n=m(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}},Ad={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=A(e.ordered)?"ol":"ul",a=l(r,{class:"rui-list-block"});for(const n of C(e.items))a.append(l("li",{},[m(n)]));return a}},Td={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=m(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(Nd(o,r));return a.append(i),a}},Nd=(t,e)=>{const{label:r,message:a}=Md(t),n=l("button",{class:"rui-follow-up-button",type:"button"},[r]);return n.onclick=()=>{e.sendToAssistant(a)},n},Md=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=m(r.args[0]),o=m(r.args[1],i);return{label:i,message:o}}const a=m(r.label),n=m(r.message,a);return{label:a,message:n}}const e=m(t);return{label:e,message:e}},Pd={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=m(e.label),n=m(e.message,a),i=l("button",{class:"rui-follow-up-button",type:"button"},[a]);return i.onclick=()=>{r.sendToAssistant(n)},i}},Id={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"},[m(e.label)]);return a.onclick=n=>{n.preventDefault(),r.invoke(e.onClick)},a}},ii=["xs","sm","md","lg","xl"],oi={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:ii},{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=m(e.size,"md"),a=l("span",{class:"rui-avatar","data-size":r,role:"img"}),n=m(e.name),i=m(e.fallback,"dicebear"),o=ne(e.src),s=!o&&i==="dicebear"&&n?ne(Vc(n)):"",c=o||s;if(c){const p=l("img",{src:c,alt:n,loading:"lazy"});p.onerror=d=>{const f=d;(f.currentTarget??f.target).replaceWith(l("span",{class:"rui-avatar-fallback"},[gt(n)]))},a.append(p)}else a.append(l("span",{class:"rui-avatar-fallback"},[gt(n)]));const u=m(e.status);return u&&a.append(l("span",{class:"rui-avatar-status","data-status":u})),a}},Ed={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:ii}],render:(t,e,r)=>{const a=C(e.items),n=Math.max(1,Math.floor(Number(e.max??4))),i=m(e.size,"md"),o=a.slice(0,n),s=a.length-o.length,c=l("div",{class:"rui-avatar-group","data-size":i});for(const u of o){if(u&&typeof u=="object"&&u.__kind==="Component"){c.append(r.renderNode(u));continue}const p=u,d=typeof p=="string"?p:m((p??{}).name),f=typeof p=="string"?"":m((p??{}).src);c.append(oi.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:d,src:f,size:i},r))}return s>0&&c.append(l("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[l("span",{class:"rui-avatar-fallback"},[`+${s}`])])),c}},Ld={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,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=Math.max(0,Math.floor(E(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,E(e.buffered,0))):null,c=l("div",{class:"rui-progress","data-tone":m(e.tone,"primary")}),u=m(e.label),p=A(e.showValue);if(u||p){const f=l("div",{class:"rui-progress-head"});if(f.append(l("span",{class:"rui-progress-label"},[u])),p&&!a){const g=o>0?`${Math.min(o,Math.round(n/r*o))} / ${o}`:`${i}%`;f.append(l("span",{class:"rui-progress-value"},[g]))}c.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 b=0;b<o;b+=1)f.append(l("span",{class:"rui-progress-segment","data-filled":b<g?"true":"false"}));return c.append(f),c}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}%`})),c.append(d),c}},zd={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=m(e.id),n=l("label",{class:"rui-switch",for:a,"data-disabled":A(e.disabled)?"true":"false"}),i=A(e.value),o=l("input",{type:"checkbox",id:a,name:a,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:A(e.disabled)?"":null});o.checked=i;const s=l("span",{class:"rui-switch-track"},[l("span",{class:"rui-switch-thumb"})]),c=t.argMeta?.[2]?.stateRef;c&&r.bindState(o,c,{event:"change",getValue:d=>d.checked}),e.onChange!=null&&o.addEventListener("change",d=>{r.invoke(e.onChange,d.currentTarget.checked)});const u=m(e.label),p=m(e.description);if(n.append(o,s),u||p){const d=l("span",{class:"rui-switch-meta"});u&&d.append(l("span",{class:"rui-switch-label"},[u])),p&&d.append(l("span",{class:"rui-switch-description"},[p])),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=m(e.value),n=m(e.variant,"outline"),i=m(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 c of C(e.items)){const{value:u,label:p,icon:d}=Dd(c),f=u===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":u}),b=j(d,{className:"rui-toggle-icon"});b&&g.append(b),g.append(l("span",{class:"rui-toggle-label"},[p])),g.onclick=()=>{s&&r.setState(s,u),r.invoke(e.onChange,u)},o.append(g)}return o}};function Dd(t){if(typeof t=="string")return{value:t,label:t,icon:""};if(Array.isArray(t))return{value:m(t[0]),label:m(t[1],m(t[0])),icon:m(t[2])};if(t&&typeof t=="object"){const e=t,r=m(e.value);return{value:r,label:m(e.label,r),icon:m(e.icon)}}return{value:"",label:"",icon:""}}const jd={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=m(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"},[m(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}},Bd={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":m(e.side,"bottom"),"data-open":A(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}},Fr={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"}},_d={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` (or an `onChange` handler) to let users pick a rating; bind `value: $rating` for two-way binding, or read the new value from `onChange: (v) => …`. 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(E(e.max,5))),n=m(e.size,"md"),i=A(e.halfStep),o=t.argMeta?.[0]?.stateRef,s=(A(e.interactive)||e.onChange!=null)&&!A(e.readonly),u=s&&!o?r.useInstanceState("rating-value",E(e.value,0)):null,p=E(u?u.get():e.value,0),d=Math.max(0,Math.min(a,p)),f=Fd(m(e.icon)),g=l("div",{class:"rui-rating","data-size":n,"data-interactive":s?"true":"false","data-half-step":s&&i?"true":"false",role:"img","aria-label":`${d} of ${a}`}),b=l("span",{class:"rui-rating-stars"});for(let y=1;y<=a;y+=1){const x=Math.max(0,Math.min(1,d-(y-1))),w=x>=1?f.full:x>0?f.half:f.empty,k=Bt(w).join(" "),T=l(s?"button":"span",{class:`rui-rating-star ${k}`.trim(),type:s?"button":null,"data-fill":x>=1?"full":x>0?"half":"empty","aria-label":s?`Rate ${y}`:null,"aria-hidden":s?null:"true"});if(s){const S=y,$=y-.5;T.onclick=M=>{const I=M,L=I.currentTarget??I.target;let R=S;if(i){const q=L.getBoundingClientRect();q.width>0&&I.clientX-q.left<q.width/2&&(R=$)}o&&r.setState(o,R),u&&u.set(R),Od(L.closest(".rui-rating"),R,a,f),r.invoke(e.onChange,R)}}b.append(T)}g.append(b);const h=m(e.label);h&&g.append(l("span",{class:"rui-rating-label"},[h]));const v=e.count!=null?E(e.count,0):null;return v!==null&&v>0&&g.append(l("span",{class:"rui-rating-count"},[`(${v.toLocaleString()})`])),g}};function Od(t,e,r,a){if(!t)return;t.querySelectorAll(".rui-rating-star").forEach((i,o)=>{const s=Math.max(0,Math.min(1,e-o)),c=s>=1?a.full:s>0?a.half:a.empty;i.setAttribute("data-fill",s>=1?"full":s>0?"half":"empty"),i.className=`rui-rating-star ${Bt(c).join(" ")}`.trim()}),t.setAttribute("aria-label",`${Math.max(0,Math.min(r,e))} of ${r}`)}function Fd(t){const e=t.trim().toLowerCase();return e?Fr[e]?Fr[e]:{full:e,half:e,empty:`regular:${e}`}:Fr.star}const Ud={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,E(e.max,100)),a=A(e.indeterminate),n=Math.max(0,Math.min(r,E(e.value,0))),i=Math.round(n/r*100),o=m(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,c=o==="lg"?10:o==="sm"?6:8,u=(s-c)/2,p=2*Math.PI*u,d=a?p*.65:p*(1-i/100),f=l("div",{class:"rui-progress-ring","data-tone":m(e.tone,"primary"),"data-size":o,"data-indeterminate":a?"true":"false"}),g=l("div",{class:"rui-progress-ring-wrap"}),b="http://www.w3.org/2000/svg",h=document.createElementNS(b,"svg");h.setAttribute("width",String(s)),h.setAttribute("height",String(s)),h.setAttribute("viewBox",`0 0 ${s} ${s}`),h.setAttribute("class","rui-progress-ring-svg");const v=document.createElementNS(b,"circle");v.setAttribute("class","rui-progress-ring-track"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(u)),v.setAttribute("stroke-width",String(c)),v.setAttribute("fill","none"),h.appendChild(v);const y=document.createElementNS(b,"circle");y.setAttribute("class","rui-progress-ring-bar"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(u)),y.setAttribute("stroke-width",String(c)),y.setAttribute("fill","none"),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-dasharray",String(p)),y.setAttribute("stroke-dashoffset",String(d)),h.appendChild(y),g.append(h);const x=m(e.label,a?"…":`${i}%`),w=l("span",{class:"rui-progress-ring-value"}),k=j(x,{className:"rui-progress-ring-icon"});k&&Bt(x).length>0?w.append(k):w.append(document.createTextNode(x)),g.append(w),f.append(g);const T=m(e.caption);return T&&f.append(l("span",{class:"rui-progress-ring-caption"},[T])),f}},Hd={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=m(e.from,"agent"),a=l("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&a.append(si(m(e.avatarSrc),m(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"},[m(e.author)]));const o=m(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"},[m(e.body)]));const s=m(e.status);return s&&n.append(l("span",{class:"rui-chat-bubble-status","data-status":s},[s])),a.append(n),r==="me"&&a.append(si(m(e.avatarSrc),m(e.author))),a}};function si(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"},[gt(e)])),r}const Vd={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=m(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=m(i);s&&(o>0&&a.append(l("span",{class:"rui-kbd-sep"},["+"])),a.append(l("kbd",{class:"rui-kbd"},[s])))}),a}},Wd={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=A(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":m(e.side,"bottom"),"data-align":m(e.align,"start")}),c=l("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});c.append(r.renderNode(e.trigger)),s.append(c);const u=l("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),p=l("div",{class:"rui-popover-header"}),d=m(e.title);p.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(),Vt(f,!1,n)},p.append(f),u.append(p);for(const g of C(e.content))u.append(r.renderNode(g));return s.append(u),c.onclick=g=>{g.stopPropagation();const b=g.currentTarget??g.target,h=!n.get(),v=Vt(b,h,n);h&&v&&li(v,n)},c.onkeydown=g=>{const b=g,h=b.currentTarget??b.target;if(b.key==="Enter"||b.key===" "){b.preventDefault();const v=!n.get(),y=Vt(h,v,n);v&&y&&li(y,n)}else b.key==="Escape"&&n.get()&&(b.preventDefault(),Vt(h,!1,n))},s}},Vt=(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||Pe(a),a},li=(t,e)=>{tt({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")}})},qd={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=m(e.tone,"default"),n=m(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=m(e.icon)||Kd(a),s=j(o,{className:"rui-toast-icon"});s&&i.append(s);const c=l("div",{class:"rui-toast-body"});c.append(l("div",{class:"rui-toast-title"},[m(e.title)]));const u=m(e.message);if(u&&c.append(l("div",{class:"rui-toast-message"},[u])),e.action){const x=l("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),c.append(x)}i.append(c);const p=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))},b=r.useInstanceState("removal-timer",null),h=x=>{if(p.get())return;p.set(!0),g();const w=f(x);if(!w)return;w.classList.add("is-dismissed");const k=setTimeout(()=>{b.set(null),w.remove()},180);b.set(k),r.registerDisposer(()=>{const T=b.get();T!==null&&(clearTimeout(T),b.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(),h(x.currentTarget??x.target)},i.append(v);const y=E(e.duration,0);if(y>0&&d.get()===null&&!p.get()){const x=setTimeout(()=>{d.set(null),!p.get()&&i.isConnected&&h()},y);d.set(x),r.registerDisposer(()=>{const w=d.get();w!==null&&(clearTimeout(w),d.set(null))},"auto-dismiss-timer")}return p.get()?l("div",{class:"rui-toast-placeholder",hidden:""}):i}};function Kd(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 ci={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=m(e.label),n=m(e.href),i=n?et(n):"",o=[],s=j(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 c=l("span",{class:"rui-breadcrumb-current"});for(const u of o)u&&c.append(typeof u=="string"?document.createTextNode(u):u);r.append(c)}return r}},Gd={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=m(e.separator,"/"),i=l("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=l("ol",{class:"rui-breadcrumb-list"});return a.forEach((s,c)=>{if(c>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 u=m(s),p=c===a.length-1;o.append(ci.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:u,href:p?"":"#"},r))}),i.append(o),i}},Yd=[10,20,50,100],Xd={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(E(e.totalPages,1))),n=Math.max(1,Math.min(a,Math.floor(E(e.page,1)))),i=Math.max(0,Math.floor(E(e.siblings,1))),o=A(e.compact),s=t.argMeta?.[0]?.stateRef,c=l("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),u=h=>{if(!s)return;const v=Math.max(1,Math.min(a,h));v!==n&&r.setState(s,v)},p=e.total!=null?Math.max(0,Math.floor(E(e.total,0))):null,d=e.perPage!=null?Math.max(1,Math.floor(E(e.perPage,0))):null;if(p!==null&&d&&d>0){const h=p===0?0:(n-1)*d+1,v=Math.min(p,n*d);c.append(l("span",{class:"rui-pagination-summary"},[p===0?"No results":`Showing ${h.toLocaleString()}–${v.toLocaleString()} of ${p.toLocaleString()}`]))}else p!==null&&c.append(l("span",{class:"rui-pagination-summary"},[`${p.toLocaleString()} result${p===1?"":"s"}`]));const f=l("div",{class:"rui-pagination-buttons"}),g=(h,v,y={})=>{if(y.ellipsis)return l("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[h]);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},[h]);return!y.disabled&&!y.active&&(x.onclick=()=>u(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 h=Jd(n,a,i);for(const v of h)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"})),c.append(f);const b=t.argMeta?.[4]?.stateRef;if(d&&(b||C(e.perPageOptions).length>0)){const h=C(e.perPageOptions).length>0?C(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(Yd),v=l("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),y=l("select",{class:"rui-pagination-per-page-select"});for(const x of h){const w=l("option",{value:String(x),selected:x===d?"":null},[String(x)]);y.append(w)}b&&r.bindState(y,b,{event:"change",getValue:x=>Number(x.value)}),v.append(y),v.append(document.createTextNode(" per page")),c.append(v)}return c}};function Jd(t,e,r){const a=[],n=(c,u)=>{for(let p=c;p<=u;p+=1)a.push(p)},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 Zd={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=m(e.label),n=e.icon,i=A(e.active),o=m(e.to),s=et(e.href,""),c=A(e.external),u=o||s?"a":"button",p=l(u,{class:"rui-navbar-item",type:u==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:c&&s?"_blank":null,rel:c&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),d=j(n,{className:"rui-navbar-item-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-navbar-item-label"},[a])),o&&!s?p.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"&&(p.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),p}},Qd={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":A(e.sticky)?"true":"false","data-variant":m(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 c of i)s.append(r.renderNode(c));a.append(s)}const o=C(e.actions);if(o.length>0){const s=l("div",{class:"rui-navbar-actions"});for(const c of o)s.append(r.renderNode(c));a.append(s)}return a}},ep=["bottom","top","left","right"],tp=["start","center","end"],rp=["default","danger"],Wt=(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||Pe(a),a):null},ui=(t,e)=>{tt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Ur=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},ap={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:ep,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:tp,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=A(e.open),n=r.useInstanceState("open",a),i=n.get(),o=l("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":m(e.side,"bottom"),"data-align":m(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=u=>{u.stopPropagation();const p=u.currentTarget??u.target,d=!n.get(),f=Wt(p,d,n);d&&f&&ui(f,n)},s.onkeydown=u=>{const p=u,d=p.currentTarget??p.target;if(p.key==="Enter"||p.key===" "){p.preventDefault();const f=!n.get(),g=Wt(d,f,n);f&&g&&ui(g,n);return}p.key==="Escape"&&n.get()&&(p.preventDefault(),Wt(d,!1,n))},o.append(s);const c=l("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":m(e.label)||null});for(const u of C(e.items)){if(Ur(u,"MenuItem")){const p=u.args??[],d=m(p[0]),f=p[1],g=p[2],b=m(p[3]),h=m(p[4],"default"),v=A(p[5]),y=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":h,disabled:v?"":null}),x=j(g,{className:"rui-menu-item-icon"});x&&y.append(x),y.append(l("span",{class:"rui-menu-item-label"},[d])),b&&y.append(l("span",{class:"rui-menu-item-shortcut"},[b])),v||(y.onclick=w=>{const k=w.currentTarget??w.target;Wt(k,!1,n),r.invoke(f)}),c.append(y);continue}if(Ur(u,"MenuSeparator")){c.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Ur(u,"MenuLabel")){const p=m((u.args??[])[0]);c.append(l("div",{class:"rui-menu-label"},[p]));continue}c.append(r.renderNode(u))}return o.append(c),o}},np={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:rp,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=A(e.disabled),n=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":m(e.variant,"default"),disabled:a?"":null}),i=j(e.icon,{className:"rui-menu-item-icon"});i&&n.append(i),n.append(l("span",{class:"rui-menu-item-label"},[m(e.label)]));const o=m(e.shortcut);return o&&n.append(l("span",{class:"rui-menu-item-shortcut"},[o])),a||(n.onclick=()=>{r.invoke(e.onClick)}),n}},ip={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>l("div",{class:"rui-menu-separator",role:"separator"})},op={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"},[m(e.label)])},sp=["left","center","right"];function lp(t){return C(t).map((e,r)=>{const a=e.args??[],n=m(a[0]);return{header:n,values:C(a[1]),format:m(a[2],"text"),align:sp.includes(m(a[3]))?m(a[3]):"",sortable:A(a[4]),filterable:A(a[5]),render:a[6],onClick:a[7],key:n||`col-${r}`}})}function di(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return E(t,0)-E(e,0);if(r==="date"){const a=new Date(m(t)).getTime(),n=new Date(m(e)).getTime();if(Number.isFinite(a)&&Number.isFinite(n))return a-n}return m(t).localeCompare(m(e))}function qt(t,e){if(t==null)return"";switch(e){case"number":return typeof t=="number"?t.toLocaleString():m(t);case"currency":return typeof t=="number"?t.toLocaleString(void 0,{style:"currency",currency:"USD"}):m(t);case"date":try{const r=new Date(m(t));return Number.isNaN(r.getTime())?m(t):r.toLocaleDateString()}catch{return m(t)}default:return m(t)}}const cp={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=lp(e.columns),n=Math.max(0,...a.map(B=>B.values.length)),i=C(e.rowIds),o=B=>m(i[B]??B),s=e.sort&&typeof e.sort=="object"?e.sort:null,c=m(s?.key),u=m(s?.direction,"asc")==="desc"?"desc":"asc",p=C(e.selectedIds).map(B=>m(B)),d=new Set(p),f=A(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,g=e.stickyHeader===void 0?!0:A(e.stickyHeader),b=A(e.stickyFirstColumn),h=m(e.density,"comfortable"),v=A(e.striped),y=r.useInstanceState("filters",{}),x=y.get(),w=[];for(let B=0;B<n;B+=1){let K=!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(!qt(ae,Y.format).toLowerCase().includes(G)){K=!1;break}}K&&w.push(B)}if(c){const B=a.find(K=>K.key===c);B&&B.sortable&&w.sort((K,Y)=>{const G=di(B.values[K],B.values[Y],B.format);return u==="desc"?-G:G})}const k=w.length,T=Math.max(1,Math.floor(E(e.perPage,20))),S=Math.max(1,Math.ceil(k/T)),$=Math.max(1,Math.floor(E(e.page,1))),M=Math.min($,S),I=w.slice((M-1)*T,M*T),L=l("div",{class:"rui-data-grid","data-density":h,"data-striped":v?"true":"false","data-sticky-header":g?"true":"false","data-sticky-first":b?"true":"false"}),R=t.argMeta?.[3]?.stateRef,q=t.argMeta?.[4]?.stateRef,_=t.argMeta?.[6]?.stateRef,U=C(e.toolbar);if(p.length>0&&U.length>0){const B=l("div",{class:"rui-data-grid-bulk"});B.append(l("span",{class:"rui-data-grid-bulk-count"},[`${p.length} selected`]));const K=l("div",{class:"rui-data-grid-bulk-tools"});for(const Y of U)K.append(r.renderNode(Y));B.append(K),L.append(B)}const J=l("div",{class:"rui-data-grid-scroll"}),Z=l("table",{class:"rui-data-grid-table"}),me=m(e.caption);me&&Z.append(l("caption",{class:"rui-data-grid-caption"},[me]));const Ae=l("thead"),xt=l("tr");if(f){const B=l("th",{class:"rui-data-grid-cell-select",scope:"col"}),K=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:K?"":null});q&&(Y.onclick=G=>{const ae=G.currentTarget,ee=new Set(p);for(const X of I){const Q=o(X);ae.checked?ee.add(Q):ee.delete(Q)}r.setState(q,Array.from(ee))}),B.append(Y),xt.append(B)}if(a.forEach((B,K)=>{const Y=l("th",{scope:"col","data-align":B.align||null,"data-sortable":B.sortable?"true":null,"data-active":B.sortable&&B.key===c?"true":null,"data-first":K===0?"true":null});if(B.sortable&&R){const G=l("button",{type:"button",class:"rui-data-grid-sort"});G.append(l("span",{},[B.header]));const ae=B.key===c?u==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ee=j(ae,{className:"rui-data-grid-sort-icon"});ee&&G.append(ee),G.onclick=()=>{const X=B.key===c&&u==="asc"?"desc":"asc";r.setState(R,{key:B.key,direction:X})},Y.append(G)}else Y.append(document.createTextNode(B.header));xt.append(Y)}),Ae.append(xt),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(K=>{const Y=l("td");if(K.filterable){const G=l("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${K.header}`,value:x[K.key]??""});G.oninput=ae=>{const ee=ae.currentTarget,X={...y.get(),[K.key]:ee.value};y.set(X);const Q=ee.closest("table")?.querySelector("tbody");dg(Q)},Y.append(G)}B.append(Y)}),Ae.append(B)}Z.append(Ae);const Ke=l("tbody");Z.append(Ke);const ra=B=>{if(Ke.replaceChildren(),B.length===0){const K=l("tr"),Y=(f?1:0)+Math.max(a.length,1);K.append(l("td",{colspan:String(Y),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),Ke.append(K);return}for(const K of B){const Y=o(K),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});q&&(X.onclick=Q=>{Q.stopPropagation();const we=Q.currentTarget,ke=new Set(p);we.checked?ke.add(Y):ke.delete(Y),r.setState(q,Array.from(ke))}),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});Nr(Q,ee,ee.values[K],K,r,qt),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,K)}),Ke.append(ae)}},dg=B=>{const K=B??Ke,Y=y.get(),G=[];for(let X=0;X<n;X+=1){let Q=!0;for(const we of a){if(!we.filterable)continue;const ke=(Y[we.key]??"").trim().toLowerCase();if(!ke)continue;const wt=we.values[X];if(!qt(wt,we.format).toLowerCase().includes(ke)){Q=!1;break}}Q&&G.push(X)}if(c){const X=a.find(Q=>Q.key===c);X&&X.sortable&&G.sort((Q,we)=>{const ke=di(X.values[Q],X.values[we],X.format);return u==="desc"?-ke:ke})}const ae=G.slice((M-1)*T,M*T);(X=>{X.replaceChildren();for(const Q of ae){const we=o(Q),ke=d.has(we),wt=l("tr",{"data-selected":ke?"true":null});if(f){const Ge=l("td",{class:"rui-data-grid-cell-select"}),aa=l("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:ke?"":null});Ge.append(aa),wt.append(Ge)}a.forEach((Ge,aa)=>{const Qi=l("td",{"data-format":Ge.format,"data-align":Ge.align||null,"data-first":aa===0?"true":null});Nr(Qi,Ge,Ge.values[Q],Q,r,qt),wt.append(Qi)}),X.append(wt)}if(ae.length===0){const Q=l("tr"),we=(f?1:0)+Math.max(a.length,1);Q.append(l("td",{colspan:String(we),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),X.append(Q)}})(K)};if(ra(I),J.append(Z),L.append(J),k>T){const B=l("div",{class:"rui-data-grid-footer"}),K=k===0?0:(M-1)*T+1,Y=Math.min(k,M*T);B.append(l("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${K}–${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 ›"]);_&&(ae.onclick=()=>{M<=1||r.setState(_,M-1)},ee.onclick=()=>{M>=S||r.setState(_,M+1)}),G.append(ae),G.append(l("span",{class:"rui-data-grid-page-current"},[`${M} / ${S}`])),G.append(ee),B.append(G),L.append(B)}return L}};function up(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r,n=m(a.date);n&&e.push({date:n,title:m(a.title),tone:m(a.tone,"primary"),time:m(a.time)})}return e}function pi(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 mi(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 dp={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=m(e.view,"month"),n=up(e.events),i=m(e.value),o=m(e.month,i),s=new Date;let c=new Date(NaN);if(o){const T=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(T)c=new Date(Number(T[1]),Number(T[2])-1,T[3]?Number(T[3]):1);else{const S=new Date(o);Number.isNaN(S.getTime())||(c=S)}}Number.isNaN(c.getTime())&&(c=s);const u=(E(e.firstDay,1)%7+7)%7,p=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",d=new Map;for(const T of n){const S=T.date.slice(0,10),$=d.get(S)??[];$.push(T),d.set(S,$)}const f=t.argMeta?.[0]?.stateRef,g=l("div",{class:"rui-calendar","data-view":a}),b=l("div",{class:"rui-calendar-header"}),h=c.toLocaleDateString(void 0,{month:"long",year:"numeric"});b.append(l("div",{class:"rui-calendar-title"},[h])),g.append(b);const v=l("div",{class:"rui-calendar-weekrow"}),y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let T=0;T<7;T+=1){const S=y[(u+T)%7]??"";v.append(l("div",{class:"rui-calendar-weekday"},[S]))}g.append(v);const x=[];if(a==="week"){const T=p?new Date(p):c,S=pi(T,u);for(let $=0;$<7;$+=1){const M=new Date(S);M.setDate(S.getDate()+$),x.push({date:M,inMonth:M.getMonth()===c.getMonth()})}}else{const T=new Date(c.getFullYear(),c.getMonth(),1),S=new Date(c.getFullYear(),c.getMonth()+1,0),$=pi(T,u),M=Math.ceil((S.getDate()+(T.getDay()-u+7)%7)/7)*7;for(let I=0;I<M;I+=1){const L=new Date($);L.setDate($.getDate()+I),x.push({date:L,inMonth:L.getMonth()===c.getMonth()})}}const w=l("div",{class:"rui-calendar-grid","data-view":a}),k=mi(s);for(const T of x){const S=mi(T.date),$=S===k,M=S===p,I=d.get(S)??[],L=l("button",{type:"button",class:"rui-calendar-day","data-in-month":T.inMonth?"true":"false","data-today":$?"true":"false","data-selected":M?"true":"false","aria-label":T.date.toDateString()});if(L.append(l("span",{class:"rui-calendar-daynumber"},[String(T.date.getDate())])),I.length>0){const R=l("div",{class:"rui-calendar-day-events"}),q=I.slice(0,3);for(const _ of q){const U=l("span",{class:"rui-calendar-event","data-tone":_.tone??"primary",title:_.time?`${_.time} — ${_.title}`:_.title},[_.title]);R.append(U)}I.length>3&&R.append(l("span",{class:"rui-calendar-event-more"},[`+${I.length-3} more`])),L.append(R)}L.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(L)}return g.append(w),g}};function pp(t){const e=[];for(const r of C(t)){if(!r||typeof r!="object")continue;const a=r;e.push({title:m(a.title),description:m(a.description),actor:m(a.actor),avatarSrc:m(a.avatarSrc),time:m(a.time),icon:m(a.icon),tone:m(a.tone,"default"),meta:m(a.meta)})}return e}function mp(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=j(n.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const c=l("div",{class:`${t}-body`}),u=l("div",{class:`${t}-head`});n.actor&&u.append(l("span",{class:`${t}-actor`},[n.actor])),u.append(l("span",{class:`${t}-title`},[n.title])),n.time&&u.append(l("span",{class:`${t}-time`},[n.time])),c.append(u),n.description&&c.append(l("p",{class:`${t}-description`},[n.description])),n.meta&&c.append(l("span",{class:`${t}-meta`},[n.meta])),i.append(c),a.append(i)}return a}const fp={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=m(e.variant,"default");return mp(r==="audit"?"rui-audit-trail":"rui-activity-log",pp(e.items),r)}},gp={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=>m(f)),n=C(e.rows).map(f=>{const g=f??{};return{label:m(g.label),values:C(g.values),hint:m(g.hint),group:m(g.group)}}),i=Math.floor(E(e.highlightColumn,-1)),o=l("div",{class:"rui-comparison-table"}),s=l("table"),c=l("thead"),u=l("tr");u.append(l("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),a.forEach((f,g)=>{u.append(l("th",{scope:"col","data-highlight":g===i?"true":null},[f]))}),c.append(u),s.append(c);const p=l("tbody");let d="";for(const f of n){if(f.group&&f.group!==d){d=f.group;const h=l("tr",{class:"rui-comparison-table-group"});h.append(l("td",{colspan:String(a.length+1)},[f.group])),p.append(h)}const g=l("tr"),b=l("td",{class:"rui-comparison-table-feature"});b.append(l("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&b.append(l("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),g.append(b);for(let h=0;h<a.length;h+=1){const v=f.values[h],y=l("td",{"data-highlight":h===i?"true":null});if(v===!0){const x=j("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=m(v);g.append(y)}p.append(g)}return s.append(p),o.append(s),o}},hp={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:A(e.hasMore),o=A(e.loading);if(i){const s=l("div",{class:"rui-infinite-list-sentinel"});if(o){const c=j("spinner",{className:"rui-infinite-list-spin"});c&&s.append(c),s.append(l("span",{},[m(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const c=l("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);c.onclick=()=>r.invoke(e.onLoadMore),s.append(c)}if(a.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const c=e.onLoadMore,u=new IntersectionObserver(p=>{for(const d of p)if(d.isIntersecting){r.invoke(c);break}});u.observe(s),r.registerDisposer(()=>u.disconnect(),"infinite-observer")}}return a}},bp=/^(https?:|blob:|data:(audio|video)\/)/i;function Kt(t){const e=m(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":bp.test(e)?e:"":""}const vp={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=Hr(m(e.ratio,"16:9")),n=l("div",{class:"rui-video-player-frame",style:`aspect-ratio:${a};`}),i=e.controls===void 0?!0:A(e.controls),o=l("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,muted:A(e.muted)?"":null,poster:ne(e.poster)||null,playsinline:"",preload:"metadata"}),s=C(e.sources);if(s.length>0)for(const u of s){if(!u||typeof u!="object")continue;const p=u,d=Kt(p.src);d&&o.append(l("source",{src:d,type:m(p.type)||null}))}else{const u=Kt(e.src);u&&o.setAttribute("src",u)}n.append(o),r.append(n);const c=m(e.caption);return c&&r.append(l("figcaption",{class:"rui-video-player-caption"},[c])),r}},yp={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=j(m(e.icon,"music"),{className:"rui-audio-player-icon"});n&&a.append(n);const i=l("div",{class:"rui-audio-player-text"}),o=m(e.title);o&&i.append(l("div",{class:"rui-audio-player-title"},[o]));const s=m(e.artist);s&&i.append(l("div",{class:"rui-audio-player-artist"},[s])),a.append(i),r.append(a);const c=e.controls===void 0?!0:A(e.controls),u=l("audio",{class:"rui-audio-player-audio",controls:c?"":null,autoplay:A(e.autoplay)?"":null,loop:A(e.loop)?"":null,preload:"metadata"}),p=C(e.sources);if(p.length>0)for(const d of p){if(!d||typeof d!="object")continue;const f=d,g=Kt(f.src);g&&u.append(l("source",{src:g,type:m(f.type)||null}))}else{const d=Kt(e.src);d&&u.setAttribute("src",d)}return r.append(u),r}};function xp(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:m(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=m(r.caption??r.title);return i&&n.append(l("figcaption",{class:"rui-carousel-caption"},[i])),n}}return e.renderNode(t)}const wp={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(E(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=n&&(s=0,o.set(s));const c=e.showDots===void 0?!0:A(e.showDots),u=e.showArrows===void 0?!0:A(e.showArrows),p=Hr(m(e.ratio,"16:9")),d=l("div",{class:"rui-carousel"}),f=l("div",{class:"rui-carousel-frame",style:`aspect-ratio:${p};`}),g=l("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});a.forEach(h=>{const v=l("div",{class:"rui-carousel-slide"}),y=xp(h,r);y&&v.append(y),g.append(v)}),f.append(g);const b=(h,v)=>{const y=(v%n+n)%n;o.set(y);const x=h.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${y*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,T)=>{k.setAttribute("data-active",T===y?"true":"false")})};if(u&&n>1){const h=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),v=j("chevron-left");v&&h.append(v);const y=l("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=j("chevron-right");x&&y.append(x),h.onclick=w=>b(w.currentTarget,o.get()-1),y.onclick=w=>b(w.currentTarget,o.get()+1),f.append(h,y)}if(d.append(f),c&&n>1){const h=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=>b(w.currentTarget,y),h.append(x)}),d.append(h)}return d}},kp={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=Hr(m(e.ratio,"1:1")),o=l("div",{class:"rui-gallery","data-columns":n>0?String(n):null});return a.forEach((s,c)=>{const{src:u,alt:p,caption:d}=fi(s),f=ne(u),g=typeof e.onSelect=="function",b=l(g?"button":"figure",{type:g?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(c)});if(f)b.append(l("img",{src:f,alt:p,loading:"lazy"}));else{const h=j("image",{className:"rui-gallery-placeholder"});h&&b.append(h)}d&&b.append(l("span",{class:"rui-gallery-caption"},[d])),g&&(b.onclick=()=>r.invoke(e.onSelect,c,s)),o.append(b)}),o}};function fi(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:m(e.args[0]),alt:m(e.args[1]),caption:m(e.args[2])}:{src:m(e.src),alt:m(e.alt),caption:m(e.caption)}}return{src:"",alt:"",caption:""}}const Sp={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($=>fi($)).filter($=>ne($.src)!==""),n=a.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),c=r.useInstanceState("index",0),u=o?A(e.open):s.get(),p=i?Math.floor(E(e.index,0)):c.get(),d=n===0?0:(p%n+n)%n,f=$=>{o?r.setState(o,$):s.set($)},g=$=>{i?r.setState(i,$):c.set($)},b=()=>f(!1),h=$=>{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":u?"true":"false"});if(v.append(y),!u||n===0)return v;const x=a[d];if(!x)return v;const w=ne(x.src);y.onclick=$=>{$.target===y&&b()};const k=l("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),T=l("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(T.onclick=b,k.append(T),n>1){const $=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),M=j("chevron-left");M&&$.append(M),$.onclick=()=>h(-1);const I=l("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),L=j("chevron-right");L&&I.append(L),I.onclick=()=>h(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 Cp(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=E(e.lat??e.latitude,NaN),a=E(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=E(t[0],NaN),r=E(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 $p={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=E(e.lat,NaN),o=E(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 h=m(e.caption);return h&&r.append(l("figcaption",{class:"rui-map-caption"},[h])),r}const c=Math.max(1,Math.min(18,Math.floor(E(e.zoom,13)))),u=1/Math.pow(2,c-8),d=`https://www.openstreetmap.org/export/embed.html?bbox=${[s.lng-u,s.lat-u/2,s.lng+u,s.lat+u/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(h=>{const v=Cp(h),y=h&&typeof h=="object"?m(h.label):"";return v?{...v,label:y}:null}).filter(h=>h!==null);if(g.length>0){const h=l("ul",{class:"rui-map-markers"});for(const v of g){const y=l("li",{class:"rui-map-marker"}),x=j("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)}`])),h.append(y)}r.append(h)}const b=m(e.caption);return b&&r.append(l("figcaption",{class:"rui-map-caption"},[b])),r}};function Hr(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 Ap=[{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"}],Tp={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=m(e.id),n=m(e.placeholder,"Start writing…"),i=A(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 Ap){const b=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}),h=j(g.icon);h&&b.append(h),b.onmousedown=v=>v.preventDefault(),b.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(b)}o.append(s);const c=m(e.value)||"",u=g=>g.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim().length===0,p=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":u(c)?"true":"false",style:`min-height:${m(e.minHeight,"160px")};`,html:c}),d=g=>{g.setAttribute("data-empty",u(g.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(p,f,{event:"input",getValue:g=>{const b=g;return d(b),b.innerHTML}}):p.oninput=g=>{const b=g.currentTarget??g.target;d(b)},p.onblur=g=>{const b=g.currentTarget??g.target;d(b)},ie(p,e.onChange,r,{event:"input",getValue:g=>g.innerHTML}),o.append(p),o}},Np={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=m(e.id),n=m(e.value),i=m(e.language,"text"),o=e.showGutter===void 0?!0:A(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(E(e.tabSize,2)))),c=A(e.readonly),u=m(e.minHeight,"200px"),p=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])),p.append(d);const f=l("div",{class:"rui-code-editor-body",style:`min-height:${u};`}),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 h=l("textarea",{class:"rui-code-editor-textarea",id:a,name:a,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:m(e.placeholder),readonly:c?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});h.value=n,h.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 T=x.value.split(/\r?\n/),S=Math.max(1,T.length);for(let $=1;$<=S;$+=1)k.append(l("span",{class:"rui-code-editor-line"},[String($)]))},h.onkeydown=y=>{const x=y;if(x.key!=="Tab")return;x.preventDefault();const w=x.currentTarget,k=w.selectionStart,T=w.selectionEnd,S=" ".repeat(s);w.value=w.value.slice(0,k)+S+w.value.slice(T),w.selectionStart=w.selectionEnd=k+S.length,w.dispatchEvent(new Event("input",{bubbles:!0}))};const v=t.argMeta?.[1]?.stateRef;return v&&!c&&r.bindState(h,v,{event:"input",getValue:y=>y.value}),c||ie(h,e.onChange,r,{event:"input",getValue:y=>y.value}),f.append(h),p.append(f),p}};function Mp(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:m(a[0]),action:a[1],icon:m(a[2]),shortcut:m(a[3]),variant:m(a[4],"default"),disabled:A(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:m(r.label),action:r.action,icon:m(r.icon),shortcut:m(r.shortcut),variant:m(r.variant,"default"),disabled:A(r.disabled),separator:!1}}return null}const Pp={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":m(e.label)||null,"data-open":"false"}),o=C(e.items).map(Mp).filter(u=>u!==null);for(const u of o){if(u.separator){i.append(l("div",{class:"rui-menu-separator",role:"separator"}));continue}const p=l("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":u.variant,disabled:u.disabled?"":null}),d=j(u.icon,{className:"rui-menu-item-icon"});d&&p.append(d),p.append(l("span",{class:"rui-menu-item-label"},[u.label])),u.shortcut&&p.append(l("span",{class:"rui-menu-item-shortcut"},[u.shortcut])),u.disabled||(p.onclick=()=>{r.invoke(u.action),i.setAttribute("data-open","false")}),i.append(p)}a.append(i);const s=()=>i.setAttribute("data-open","false"),c=(u,p)=>{const d=n.isConnected?n.closest(".rui-context-menu"):null,f=d?.querySelector(".rui-context-menu-pop")??i,g=d?.getBoundingClientRect(),b=g?u-g.left:u,h=g?p-g.top:p;f.style.left=`${b}px`,f.style.top=`${h}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=u=>{u.preventDefault(),c(u.clientX,u.clientY)},n.onkeydown=u=>{const p=u;if(p.key==="ContextMenu"||p.shiftKey&&p.key==="F10"){p.preventDefault();const f=p.currentTarget.getBoundingClientRect();c(f.left,f.top+f.height)}p.key==="Escape"&&s()},a}},Ip=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function ht(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 Ep={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=m(e.id),n=ht(m(e.value))||m(e.value,"#000000"),i=A(e.disabled),o=l("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=m(e.label);s&&o.append(l("label",{class:"rui-color-picker-label",for:a},[s]));const c=l("div",{class:"rui-color-picker-row"}),u=l("input",{type:"color",class:"rui-color-picker-color",id:a,name:a,value:ht(n)||"#000000",disabled:i?"":null}),p=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(h=>m(h)).filter(Boolean),g=f.length>0?f:Ip;for(const h of g){const v=ht(h)||h,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=()=>{u.value=ht(v)||u.value,p.value=v,u.dispatchEvent(new Event("input",{bubbles:!0}))},d.append(y)}const b=t.argMeta?.[1]?.stateRef;return b&&!i&&(r.bindState(u,b,{event:"input",getValue:h=>h.value}),u.addEventListener("input",()=>{p.value=u.value}),p.oninput=()=>{const h=ht(p.value);h&&(u.value=h,u.dispatchEvent(new Event("input",{bubbles:!0})))}),i||ie(u,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(u,p),o.append(c,d),o}},Vr=["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)"],We=t=>Vr[t%Vr.length]??Vr[0];function Lp(t){return t.map((e,r)=>{const a=e,n=m(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>E(o));return{name:n,values:i}})}function Gt(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 gi(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:${We(a)}`})),n.append(l("span",{},[r.name])),e.append(n)}),e}const zp={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=E(e.min,0),a=Math.max(r+1,E(e.max,100)),n=Math.max(r,Math.min(a,E(e.value,r))),i=(n-r)/(a-r),o=m(e.tone,"primary"),s=m(e.size,"md"),c=s==="lg"?220:s==="sm"?140:180,u=c/2,p=s==="lg"?18:s==="sm"?10:14,d=u-p,f=l("div",{class:"rui-gauge","data-tone":o,"data-size":s}),g=Gt(c,u+p+4),b=u,h=u,v=b-d,y=h,x=b+d,w=h;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(p),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,M=b-d*Math.cos($),I=h-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}, ${We(0)})`,"stroke-width":String(p),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(g);const k=Rp(n,r,a),T=m(e.label)||k;f.append(l("div",{class:"rui-gauge-value"},[T]));const S=m(e.caption);return S&&f.append(l("div",{class:"rui-gauge-caption"},[S])),f}};function Rp(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 Dp={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(p=>m(p)),a=C(e.yLabels).map(p=>m(p)),n=C(e.values).map(p=>C(p).map(d=>E(d,0))),i=m(e.tone,"primary"),o=Math.max(1,...n.flat()),s=l("div",{class:"rui-heatmap","data-tone":i});m(e.title)&&s.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const c=l("div",{class:"rui-heatmap-table"}),u=l("div",{class:"rui-heatmap-row rui-heatmap-row-header"});u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const p of r)u.append(l("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[p]));return c.append(u),n.forEach((p,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)])),p.forEach((g,b)=>{const h=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}, ${We(0)}) ${Math.round(h*90+5)}%, transparent);`,title:`${r[b]??b+1} · ${a[d]??d+1}: ${g}`});v.append(l("span",{},[String(g)])),f.append(v)}),c.append(f)}),s.append(c),s}},jp={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=>m(g)),a=Lp(C(e.series)),n=Math.max(r.length,3),i=l("div",{class:"rui-chart rui-radar-chart"});m(e.title)&&i.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const o=Math.max(1,E(e.max,a.flatMap(g=>g.values).reduce((g,b)=>Math.max(g,b),1))),s=280,c=s/2,u=s/2,p=s/2-24,d=Gt(s,s),f=4;for(let g=1;g<=f;g+=1){const b=p/f*g,h=[];for(let v=0;v<n;v+=1){const y=Math.PI*2*v/n-Math.PI/2;h.push(`${(c+b*Math.cos(y)).toFixed(1)},${(u+b*Math.sin(y)).toFixed(1)}`)}d.append(ce("polygon",{points:h.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 b=Math.PI*2*g/n-Math.PI/2,h=c+p*Math.cos(b),v=u+p*Math.sin(b);d.append(ce("line",{x1:String(c),y1:String(u),x2:h.toFixed(1),y2:v.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const y=c+(p+16)*Math.cos(b),x=u+(p+16)*Math.sin(b);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,b)=>{const h=[];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=c+p*x*Math.cos(w),T=u+p*x*Math.sin(w);h.push(`${k.toFixed(1)},${T.toFixed(1)}`)}d.append(ce("polygon",{points:h.join(" "),fill:We(b),"fill-opacity":"0.2",stroke:We(b),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(d),a.length>0&&i.append(gi(a)),i}};function Bp(t){return t.map((e,r)=>{const a=e,n=m(a.args?.[0],`Series ${r+1}`),i=C(a.args?.[1]).map(o=>{if(Array.isArray(o))return{x:E(o[0],0),y:E(o[1],0),label:m(o[2])};if(o&&typeof o=="object"){const s=o;return{x:E(s.x,0),y:E(s.y,0),label:m(s.label)}}return{x:0,y:0,label:""}});return{name:n,points:i}})}const _p={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=Bp(C(e.series)),a=l("div",{class:"rui-chart rui-scatter-chart"});m(e.title)&&a.append(l("div",{class:"rui-chart-title"},[m(e.title)]));const n=640,i=280,o={left:50,right:16,top:16,bottom:40},s=n-o.left-o.right,c=i-o.top-o.bottom,u=r.flatMap(k=>k.points);if(u.length===0)return a.append(l("div",{class:"rui-chart-empty"},["No points"])),a;const p=u.map(k=>k.x),d=u.map(k=>k.y),f=Math.min(...p),g=Math.max(...p),b=Math.min(...d),h=Math.max(...d),v=g-f||1,y=h-b||1,x=Gt(n,i);if(bi(x,o,s,c,h,b),x.append(ce("line",{x1:String(o.left),y1:String(o.top+c),x2:String(o.left+s),y2:String(o.top+c),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,T)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/v*s,M=o.top+c-(S.y-b)/y*c,I=ce("circle",{cx:$.toFixed(1),cy:M.toFixed(1),r:"7",fill:We(T),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});I.append(ce("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(I)})}),m(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"},[m(e.xLabel)])),m(e.yLabel)){const T=o.top+c/2;x.append(ce("text",{x:String(14),y:String(T),"text-anchor":"middle",transform:`rotate(-90, 14, ${T})`,class:"rui-chart-label","font-size":"14","font-weight":"500"},[m(e.yLabel)]))}a.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(T=>T.y)}));return w.length>0&&a.append(gi(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:m(g.label),count:E(g.count,0)}});else{const f=C(e.values).map(g=>E(g,NaN)).filter(g=>Number.isFinite(g));if(f.length>0){const g=Math.max(2,Math.min(50,Math.floor(E(e.binCount,10)))),b=Math.min(...f),y=(Math.max(...f)-b||1)/g,x=new Array(g).fill(0);for(const w of f){let k=Math.floor((w-b)/y);k>=g&&(k=g-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const T=b+k*y,S=T+y;return{label:`${hi(T)}–${hi(S)}`,count:w}})}}const a=l("div",{class:"rui-chart rui-histogram"});if(m(e.title)&&a.append(l("div",{class:"rui-chart-title"},[m(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,c=i-o.top-o.bottom,u=Math.max(1,...r.map(f=>f.count)),p=s/r.length,d=Gt(n,i);return bi(d,o,s,c,u),r.forEach((f,g)=>{const b=o.left+g*p+p*.1,h=p*.8,v=f.count/u*c,y=o.top+c-v,x=ce("rect",{x:b.toFixed(1),y:y.toFixed(1),width:h.toFixed(1),height:v.toFixed(1),fill:We(0),rx:"2"});x.append(ce("title",{},[`${f.label}: ${f.count}`])),d.append(x),d.append(ce("text",{x:(b+h/2).toFixed(1),y:String(o.top+c+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),a.append(d),a}};function hi(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function bi(t,e,r,a,n,i=0){for(let s=0;s<=4;s+=1){const c=s/4,u=e.top+a-c*a;t.append(ce("line",{x1:String(e.left),x2:String(e.left+r),y1:String(u),y2:String(u),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))"})),t.append(ce("text",{x:String(e.left-8),y:String(u+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(n-i)*c)*10)/10)]))}}const Fp=["numeric","alphanumeric"];function Up(t,e,r,a,n,i,o){const s=l("div",{class:"rui-pin-input","data-disabled":n?"true":"false"}),c=[];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});c.push(f),s.append(f)}const u=d=>{const f=d.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):c},p=d=>u(d).map(f=>f.value).join("").slice(0,e);return c.forEach((d,f)=>{d.oninput=g=>{const b=g.currentTarget,h=u(b);let v=b.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 T=h[f+k];T&&(T.value=w)});const x=Math.min(f+y.length,e-1);h[x]?.focus()}else b.value=v,v&&f<e-1&&h[f+1]?.focus();o?.(p(b))},d.onkeydown=g=>{const b=g,h=b.currentTarget,v=u(h);if(b.key==="Backspace"&&!h.value&&f>0){b.preventDefault(),v[f-1]?.focus();const y=v[f-1];y&&(y.value=""),o?.(p(h))}else b.key==="ArrowLeft"&&f>0?(b.preventDefault(),v[f-1]?.focus()):b.key==="ArrowRight"&&f<e-1&&(b.preventDefault(),v[f+1]?.focus())}}),s}const Hp={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:Fp},{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=m(e.id),n=Math.max(1,Math.min(12,Math.floor(E(e.length,4)))),i=m(e.type,"numeric"),o=m(e.value),s=A(e.disabled),c=A(e.mask),u=t.argMeta?.[2]?.stateRef;return Up(a,n,i,o,s,c,p=>{u&&r.setState(u,p),r.invoke(e.onChange,p)})}};function Vp(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 Wp={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=m(e.id),n=r.useInstanceState("visible",!1),i=n.get(),o=A(e.disabled),s=l("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),c=m(e.label);c&&s.append(l("label",{class:"rui-password-input-label",for:a},[c]));const u=l("div",{class:"rui-password-input-row"}),p=l("input",{type:i?"text":"password",class:"rui-password-input-field",id:a,name:a,autocomplete:"current-password",placeholder:m(e.placeholder),value:m(e.value),disabled:o?"":null}),d=l("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=j(i?"eye-slash":"eye");f&&d.append(f),d.onclick=b=>{b.preventDefault();const h=!n.get();n.set(h);const x=b.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=h?"text":"password")};const g=t.argMeta?.[1]?.stateRef;if(g&&r.bindState(p,g,{event:"input",getValue:b=>b.value}),ie(p,e.onChange,r,{event:"input",getValue:b=>b.value}),u.append(p),u.append(d),s.append(u),A(e.strengthMeter)){const b=Vp(m(e.value)),h=l("div",{class:"rui-password-input-strength","data-score":String(b.score)});for(let y=0;y<4;y+=1)h.append(l("span",{class:"rui-password-input-strength-bar","data-filled":y<b.score?"true":"false"}));const v=l("div",{class:"rui-password-input-strength-row"});v.append(h),b.label&&v.append(l("span",{class:"rui-password-input-strength-label"},[b.label])),s.append(v)}return s}},qp={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=m(e.id),n=C(e.value).map(f=>m(f)).filter(Boolean),i=Math.max(0,Math.floor(E(e.max,0))),o=A(e.disabled),s=t.argMeta?.[1]?.stateRef,c=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},u=m(e.label),p=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 b=l("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);b.onclick=()=>c(n.filter(h=>h!==f)),g.append(b),p.append(g)}const d=l("input",{type:"text",class:"rui-tag-input-field",id:a,name:a,placeholder:m(e.placeholder,n.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(d.onkeydown=f=>{const g=f,b=g.currentTarget;if(g.key==="Enter"||g.key===","){g.preventDefault();const h=b.value.trim();if(!h||i>0&&n.length>=i)return;if(n.includes(h)){b.value="";return}c([...n,h]),b.value=""}else g.key==="Backspace"&&b.value===""&&n.length>0&&(g.preventDefault(),c(n.slice(0,-1)))},p.append(d),u){const f=l("div",{class:"rui-tag-input-wrapper"});return f.append(l("label",{class:"rui-tag-input-label",for:a},[u])),f.append(p),f}return p}};function Kp(t){return C(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,a=m(r.label??r.name??r.value??r.id);return{value:m(r.handle??r.value??r.id??r.name??r.label),label:a}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const Gp={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=m(e.id),n=Kp(e.people),i=A(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(E(e.rows,3)))),placeholder:m(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=m(e.value);const c=l("div",{class:"rui-mention-input-suggestions","data-open":"false"}),u=r.useInstanceState("activeIndex",0),p=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,b=(x,w)=>{const k=x.value,T=x.selectionStart??k.length,S=k.slice(0,T),$=S.lastIndexOf("@");if($===-1)return;const M=k.slice(T),I=`@${w.value} `,L=S.slice(0,$)+I+M;x.value=L;const R=$+I.length;x.selectionStart=x.selectionEnd=R,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},h=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),p.set([]);return}const k=w.toLowerCase(),S=n.filter(M=>M.label.toLowerCase().includes(k)||M.value.toLowerCase().includes(k)).slice(0,6);if(p.set(S),S.length===0){x.setAttribute("data-open","false");return}const $=Math.min(u.get(),S.length-1);u.set($),x.setAttribute("data-open","true"),S.forEach((M,I)=>{const L=l("button",{type:"button",class:"rui-mention-input-option","data-value":M.value,"data-active":I===$?"true":"false"});L.append(l("span",{class:"rui-mention-input-option-label"},[M.label])),M.value&&M.value!==M.label&&L.append(l("span",{class:"rui-mention-input-option-handle"},[`@${M.value}`])),L.onmousedown=R=>R.preventDefault(),L.onclick=R=>{const q=R.currentTarget,_=g(q),U=f(q);_&&b(_,M),d.set(null),U&&h(U,null)},x.append(L)})},v=x=>{const w=f(x);if(!w)return;const k=x.selectionStart??x.value.length,T=x.value.slice(0,k),S=/@([\w-]*)$/.exec(T),$=S?S[1]??"":null;d.set($),h(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 T=p.get();if(T.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(u.get()+1)%T.length;u.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=(u.get()-1+T.length)%T.length;u.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=T[u.get()];S&&(b(w,S),d.set(null),h(k,null))}else x.key==="Escape"&&(d.set(null),h(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);d.set(null),k&&h(k,null)},120)},o.append(s),o.append(c),h(c,d.get()),o}},Yp={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=m(e.id),n=l("div",{class:"rui-time-picker"}),i=m(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:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}},Xp={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=m(e.id),n=l("div",{class:"rui-datetime-picker"}),i=m(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:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(E(e.step,60)):null,disabled:A(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ie(o,e.onChange,r,{event:"change",getValue:c=>c.value}),n.append(o),n}};function vi(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 Jp={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=m(e.id),n=m(e.mask),i=A(e.disabled),o=vi(m(e.value),n),s=m(e.label),c=l("input",{type:"text",class:"rui-masked-input",id:a,name:a,value:o,placeholder:m(e.placeholder,n),disabled:i?"":null,autocomplete:"off"});c.value=o;const u=t.argMeta?.[2]?.stateRef,p=d=>{const f=d.value,g=vi(f,n);if(g===f)return g;const b=d.selectionStart??g.length;d.value=g;const h=Math.min(g.length,b);try{d.setSelectionRange(h,h)}catch{}return g};if(u?r.bindState(c,u,{event:"input",getValue:d=>p(d)}):c.oninput=d=>{p(d.currentTarget??d.target)},ie(c,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(c),d}return c}},Zp={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"},[m(e.label)]));const i=m(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}},Qp={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:A(e.disabled)?"":null});a.append(l("legend",{class:"rui-fieldset-legend"},[m(e.legend)]));const n=m(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}},em={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(c=>{if(!c)return null;if(typeof c=="string")return{label:"",message:c,field:""};if(typeof c=="object"){const u=c;return{label:m(u.label),message:m(u.message??u.error),field:m(u.field)}}return null}).filter(c=>c!==null&&c.message!=="");if(r.length===0)return l("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const a=m(e.tone,"danger"),n=l("aside",{class:"rui-validation-summary","data-tone":a,role:"alert"}),i=l("div",{class:"rui-validation-summary-title"}),o=j(a==="warning"?"triangle-exclamation":"circle-xmark",{className:"rui-validation-summary-icon"});o&&i.append(o),i.append(document.createTextNode(m(e.title,"Please fix the following:"))),n.append(i);const s=l("ul",{class:"rui-validation-summary-list"});for(const c of r){const u=l("li",{class:"rui-validation-summary-item"});c.label&&u.append(l("strong",{},[`${c.label}: `])),u.append(document.createTextNode(c.message)),s.append(u)}return n.append(s),n}};function tm(t){return C(t).map(e=>{if(!e||typeof e!="object")return{title:m(e),details:"",content:null};const r=e;return{title:m(r.title),details:m(r.details),content:r.content??null}})}const rm={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=tm(e.steps),n=a.length,i=Math.max(0,Math.min(n-1,Math.floor(E(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=m(e.stepsLayout,"column").toLowerCase(),c=s==="row"||s==="horizontal"?"row":"column",u=l("div",{class:"rui-multi-step-form","data-layout":c}),p=l("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":c});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])),p.append(k)}),u.append(p);const d=l("div",{class:"rui-multi-step-form-body"}),f=a[i];f&&f.content&&d.append(r.renderNode(f.content)),u.append(d);const g=l("div",{class:"rui-multi-step-form-footer"}),b=l("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[m(e.prevLabel,"Back")]);o&&i>0&&(b.onclick=()=>r.setState(o,i-1));const h=i>=n-1,v=h?m(e.submitLabel,"Submit"):m(e.nextLabel,"Continue"),y=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[v]);return y.onclick=()=>{h?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},g.append(b),g.append(l("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${n}`])),g.append(y),u.append(g),u}};function am(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:m(r.title),message:m(r.message),time:m(r.time),icon:m(r.icon),tone:m(r.tone,"default"),unread:A(r.unread),avatarSrc:m(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const nm={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=am(e.items),n=a.filter(c=>c.unread),i=a.filter(c=>!c.unread),o=l("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&n.length>0){const c=l("div",{class:"rui-inbox-panel-toolbar"}),u=l("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);u.onclick=()=>r.invoke(e.onMarkAllRead),c.append(u),o.append(c)}if(a.length===0)return o.append(l("div",{class:"rui-inbox-panel-empty"},[m(e.emptyLabel,"You're all caught up.")])),o;const s=(c,u)=>{if(u.length===0)return;const p=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"},[c])),d.append(l("span",{class:"rui-inbox-panel-group-count"},[String(u.length)])),p.append(d);for(const f of u){const g=Zn.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)),p.append(g)}o.append(p)};return s(`Unread (${n.length})`,n),s("Earlier",i),o}};function im(t){return C(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:m(r.title),description:m(r.description),done:A(r.done),onClick:r.onClick??r.action,cta:m(r.cta,"Start")}}).filter(e=>e!==null)}const om={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=im(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"}),c=l("header",{class:"rui-onboarding-checklist-header"});c.append(l("h3",{class:"rui-onboarding-checklist-title"},[m(e.title,"Getting started")]));const u=m(e.subtitle);u&&c.append(l("p",{class:"rui-onboarding-checklist-subtitle"},[u])),c.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(c);const p=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"}),b=j(d.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});b&&g.append(b),f.append(g);const h=l("div",{class:"rui-onboarding-checklist-body"});if(h.append(l("div",{class:"rui-onboarding-checklist-item-title"},[d.title])),d.description&&h.append(l("p",{class:"rui-onboarding-checklist-item-description"},[d.description])),f.append(h),!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)}p.append(f)}return s.append(p),s}};function yi(t){const e=l("div",{class:`rui-${t.klass}`});if(t.iconName){const a=j(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 sm={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"},[m(e.title,"Loading…")]));const n=m(e.description);return n&&r.append(l("p",{class:"rui-loading-state-description"},[n])),r}},lm={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)=>yi({klass:"error-state",iconName:m(e.icon,"circle-exclamation"),iconClass:"rui-error-state-icon",title:m(e.title,"Something went wrong"),description:m(e.description),actions:e.actions,helpers:r})},cm={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)=>yi({klass:"success-state",iconName:m(e.icon,"circle-check"),iconClass:"rui-success-state-icon",title:m(e.title),description:m(e.description),actions:e.actions,helpers:r})},um={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:m(v),description:"",target:""};const y=v;return{title:m(y.title),description:m(y.description),target:m(y.target)}}),n=e.open===void 0?!0:A(e.open),i=a.length,o=Math.max(0,Math.min(i-1,Math.floor(E(e.current,0)))),s=t.argMeta?.[1]?.stateRef,c=l("div",{class:"rui-tour","data-open":n?"true":"false"});if(!n||i===0)return c;const u=a[o];if(!u)return c;const p=l("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});p.append(l("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),p.append(l("h3",{class:"rui-tour-title"},[u.title])),u.description&&p.append(l("p",{class:"rui-tour-description"},[u.description])),u.target&&p.append(l("div",{class:"rui-tour-target"},[`Target: ${u.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 b=o>=i-1,h=l("button",{type:"button",class:"rui-button","data-variant":"primary"},[b?"Finish":"Next"]);return h.onclick=()=>{b?r.invoke(e.onComplete):s&&r.setState(s,o+1)},d.append(f,g,h),p.append(d),c.append(p),c}},dm={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:A(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"},[m(e.title)]));const o=m(e.description);o&&i.append(l("p",{class:"rui-spotlight-description"},[o]));const s=C(e.actions);if(s.length>0){const u=l("div",{class:"rui-spotlight-actions"});for(const p of s)u.append(r.renderNode(p));i.append(u)}const c=t.argMeta?.[1]?.stateRef;return c&&(n.onclick=u=>{u.target===n&&r.setState(c,!1)}),n.append(i),n}},pm={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=m(e.side,"top"),n=te(e.offset,"0"),i=Math.max(0,Math.floor(E(e.zIndex,10))),o=`position:sticky;${a}:${n};z-index:${i};`,s=l("div",{class:"rui-sticky",style:o});for(const c of C(e.children))s.append(r.renderNode(c));return s}},mm={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 u of C(e.primary))o.append(r.renderNode(u));const s=l("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),c=l("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const u of C(e.secondary))c.append(r.renderNode(u));return i.append(o,s,c),s.onpointerdown=u=>{const p=u,d=p.currentTarget;d.setPointerCapture(p.pointerId);const f=d.closest(".rui-resizable-panels");if(!f)return;const g=f.getBoundingClientRect(),b=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}%`)},h=v=>{d.releasePointerCapture(v.pointerId),d.removeEventListener("pointermove",b),d.removeEventListener("pointerup",h)};d.addEventListener("pointermove",b),d.addEventListener("pointerup",h)},i}},fm={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(E(e.columns,3)))),n=m(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}},gm={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=A(e.open),n=m(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"},[m(e.title)]));const c=l("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),u=t.argMeta?.[1]?.stateRef,p=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};c.onclick=p,i.onclick=g=>{g.target===i&&p()},s.append(c),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 b of f)g.append(r.renderNode(b));o.append(g)}return i.append(o),i}},hm={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":A(e.sticky)?"true":"false"}),n=l("div",{class:"rui-topbar-side rui-topbar-left"}),i=m(e.title);if(i){const c=l("div",{class:"rui-topbar-title-block"});c.append(l("h2",{class:"rui-topbar-title"},[i]));const u=m(e.subtitle);u&&c.append(l("p",{class:"rui-topbar-subtitle"},[u])),n.append(c)}for(const c of C(e.left))n.append(r.renderNode(c));a.append(n);const o=C(e.center);if(o.length>0){const c=l("div",{class:"rui-topbar-side rui-topbar-center"});for(const u of o)c.append(r.renderNode(u));a.append(c)}const s=l("div",{class:"rui-topbar-side rui-topbar-right"});for(const c of C(e.right))s.append(r.renderNode(c));return a.append(s),a}},bm={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=m(e.label,""),n=m(e.to,"/"),i=m(e.variant,"default"),o=A(e.exact,!1),s=r.router,c=s.getPath(),u=c?o?c===n:n==="/"?c==="/":c===n?!0:c.startsWith(n+"/"):!1,p=l("a",{class:"rui-nav-link","data-variant":i,"data-active":u?"true":"false",href:"#"+(n.startsWith("/")?n:"/"+n)}),d=j(e.icon,{className:"rui-nav-link-icon"});return d&&p.append(d),p.append(l("span",{class:"rui-nav-link-label"},[a])),p.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(n)))},p}},vm=["primary","secondary","ghost","danger"],ym=["xs","sm","md","lg","xl","small","normal","large"];function xm(t){const e=m(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 wm(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=m(a.value??a.label);return{value:n,label:m(a.label,n)}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Yt(t){return C(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function km(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=m(a.value??a.label);return{value:n,label:m(a.label,n),group:m(a.group)||void 0,shortcut:m(a.shortcut)||void 0,action:a.action}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function xi(t){return C(t).map(e=>{if(e&&typeof e=="object"){const a=e,n=m(a.name??a.label);return{name:n,label:m(a.label,n),type:m(a.type,"text")||"text"}}const r=m(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Sm(t){return Yt(t).map((e,r)=>({id:m(e.id,`task-${r}`),label:m(e.label??e.name,`Task ${r+1}`),start:m(e.start),end:m(e.end),progress:e.progress!=null?E(e.progress,0):void 0}))}function qe(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Cm(t,e){const r=t.split(`
41
98
  `),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 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(`
99
+ `),n=Math.max(r.length,a.length),i=[];for(let o=0;o<n;o++){const s=r[o],c=a[o];s===c?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),c!==void 0&&i.push({type:"add",text:c}))}return i}function wi(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function ki(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(Si(i,r,a+1)):o.append(l("span",{class:"rui-json-tree-leaf"},[wi(i)])),t.append(o)}}function Si(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"},[wi(t)])),a;const n=Array.isArray(t),i=n?t.map((u,p)=>[String(p),u]):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"]),c=l("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&ki(c,i,e,r),s.onclick=u=>{const p=u.currentTarget,d=p.nextElementSibling;if(!d)return;const f=d.getAttribute("data-open")!=="true";d.setAttribute("data-open",f?"true":"false"),p.setAttribute("aria-expanded",f?"true":"false"),p.firstChild&&(p.firstChild.textContent=f?"▼":"▶"),f&&d.childElementCount===0?ki(d,i,e,r):f||d.replaceChildren()},a.append(s,c),a}const $m={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:vm},{name:"size",type:"string",optional:!0,enum:ym},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const a=l("button",{class:"rui-icon-button",type:"button","data-variant":m(e.variant,"ghost"),"data-size":xm(e.size),"aria-label":m(e.label),title:m(e.label),disabled:A(e.disabled)?"":null}),n=j(e.icon,{className:"rui-icon-button-icon"});return n&&a.append(n),a.onclick=()=>r.invoke(e.onClick),a}},Am={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=km(e.items),n=e.open!==void 0,i=n?A(e.open):!0,o=r.useInstanceState("open",i);n&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),c=n?i:o.get(),u=l("div",{class:"rui-command-palette","data-open":c?"true":"false"});if(!c)return u;const p=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:m(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(g);const b=m(e.shortcut);b&&f.append(l("span",{class:"rui-command-palette-shortcut"},[b])),d.append(f);const h=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 T="";for(const S of k.slice(0,50)){S.group&&S.group!==T&&(T=S.group,y.append(l("div",{class:"rui-command-palette-group"},[T])));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"),L=I?.querySelector(".rui-command-palette-panel");I?.setAttribute("data-open","false"),Pe(L??null)},y.append($)}k.length===0&&y.append(l("div",{class:"rui-command-palette-empty"},["No commands found"]))};return v(h,s.get()),d.append(h),p.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"),Pe(w??null)},u.append(p,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"),Pe(w??null)}},setTimeout(()=>g.focus(),0),tt({liveRoot:d,onDismiss:()=>{o.set(!1),u.setAttribute("data-open","false")}}),u}},Tm={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=wm(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 c=l("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),u=j("xmark",{className:"rui-filter-chip-remove-icon"});u&&c.append(u),c.onclick=()=>r.invoke(e.onRemove,o.value),s.append(c),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}},Nm={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=Yt(e.items),n=xi(e.fields),i=l("div",{class:"rui-field-repeater"});if(a.forEach((o,s)=>{const c=l("div",{class:"rui-field-repeater-row","data-index":String(s)}),u=l("div",{class:"rui-field-repeater-grid"});for(const p of n){const d=l("label",{class:"rui-field-repeater-field"});d.append(l("span",{class:"rui-field-repeater-label"},[p.label]));const f=l("input",{class:"rui-input",type:p.type==="number"?"number":"text",name:`${p.name}-${s}`,value:m(o[p.name]),readonly:""});d.append(f),u.append(d)}if(c.append(u),typeof e.onRemove=="function"){const p=l("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);p.onclick=()=>r.invoke(e.onRemove,s),c.append(p)}i.append(c)}),typeof e.onAdd=="function"){const o=l("button",{type:"button",class:"rui-field-repeater-add rui-button","data-variant":"secondary"},[m(e.addLabel,"Add row")]);o.onclick=()=>r.invoke(e.onAdd),i.append(o)}return i}},Mm={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,E(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"}),c=l("div",{class:"rui-virtual-list-window"}),u=n.length;s.style.height=`${u*a}px`,s.style.position="relative",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.right="0",o.style.maxHeight=`${Math.min(Math.max(u,1),12)*a}px`,o.style.overflow="auto";const p=d=>{c.replaceChildren();const f=o.clientHeight||a*12,g=Math.ceil(f/a)+2,b=Math.max(0,d),h=Math.min(u,b+g);c.style.transform=`translateY(${b*a}px)`;for(let v=b;v<h;v++){const y=n[v];if(e.renderItem)c.append(r.renderNode(y??e.renderItem));else if(y&&typeof y=="object"&&y.__kind)c.append(r.renderNode(y));else{const x=l("div",{class:"rui-virtual-list-item",style:`height:${a}px`});x.append(l("span",{},[m(y)])),c.append(x)}}};return o.onscroll=()=>{const d=Math.floor(o.scrollTop/a);p(d)},p(0),o.append(s,c),i.append(o),i}},Pm={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=xi(e.fields),n=Yt(e.value),i=t.argMeta?.[1]?.stateRef,o=l("div",{class:"rui-query-builder"}),s=c=>{o.replaceChildren(),c.forEach((p,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=m(p.field??a[0]?.name);const b=l("select",{class:"rui-select rui-query-builder-op"},[]);for(const y of["equals","contains","gt","lt"])b.append(l("option",{value:y},[y]));b.value=m(p.op,"equals");const h=l("input",{class:"rui-input rui-query-builder-value",value:m(p.value)});f.append(g,b,h);const v=l("button",{type:"button",class:"rui-query-builder-remove"},["×"]);v.onclick=()=>{const y=c.filter((x,w)=>w!==d);i?r.setState(i,y):r.invoke(e.onChange,y),s(y)},f.append(v),o.append(f)});const u=l("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);u.onclick=()=>{const p=[...c,{field:a[0]?.name??"",op:"equals",value:""}];i?r.setState(i,p):r.invoke(e.onChange,p),s(p)},o.append(u)};return s(n.length>0?n:[{field:a[0]?.name??"",op:"equals",value:""}]),o}},Im={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=m(e.left),a=m(e.right),n=m(e.mode,"split"),i=l("div",{class:"rui-diff-viewer","data-mode":n});if(n==="unified"){const u=l("pre",{class:"rui-diff-viewer-unified"});for(const p of Cm(r,a))u.append(l("div",{class:`rui-diff-line rui-diff-line-${p.type}`},[(p.type==="add"?"+ ":p.type==="remove"?"- ":" ")+p.text]));return i.append(u),i}const o=l("div",{class:"rui-diff-viewer-panes"}),s=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),c=l("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[a]);return o.append(s,c),i.append(o),i}},Em={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(Si(e.data,A(e.expanded))),r}},Lm={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=Sm(e.tasks),a=r.map(p=>qe(p.start)),n=r.map(p=>qe(p.end)),i=e.startDate?qe(m(e.startDate)):a.length?Math.min(...a):Date.now(),o=e.endDate?qe(m(e.endDate)):n.length?Math.max(...n):i+864e5,s=Math.max(o-i,1),c=l("div",{class:"rui-gantt"}),u=l("div",{class:"rui-gantt-track"});for(const p of r){const d=l("div",{class:"rui-gantt-row"});d.append(l("div",{class:"rui-gantt-label"},[p.label]));const f=l("div",{class:"rui-gantt-bars"}),g=(qe(p.start)-i)/s*100,b=Math.max((qe(p.end)-qe(p.start))/s*100,2),h=l("div",{class:"rui-gantt-bar",style:`left:${g}%;width:${b}%`,title:`${p.start} → ${p.end}`});p.progress!=null&&h.append(l("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,p.progress))}%`})),f.append(h),d.append(f),u.append(d)}return c.append(u),c}},zm={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(E(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},[m(e.text)]),c=l("button",{type:"button",class:"rui-truncate-toggle"},[n.get()?"Show less":m(e.expandLabel,"Show more")]);return c.onclick=u=>{const p=u.currentTarget,d=p.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,p.textContent=g?"Show less":m(e.expandLabel,"Show more"),d.setAttribute("data-expanded",g?"true":"false")},o.append(s,c),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",m(e.value)),i=t.argMeta?.[0]?.stateRef,o=l("div",{class:"rui-inline-edit","data-editing":a.get()?"true":"false"}),s=m(e.label);s&&o.append(l("span",{class:"rui-inline-edit-label"},[s]));const c=l("button",{type:"button",class:"rui-inline-edit-display"},[m(e.value)]),u=l("input",{class:"rui-inline-edit-input rui-input",value:n.get()}),p=f=>{const g=f.closest(".rui-inline-edit"),b=g?.querySelector(".rui-inline-edit-input");return!g||!b?null:{root:g,input:b}},d=f=>{const g=p(f);a.set(!1),g?.root.setAttribute("data-editing","false");const b=n.get();i&&r.setState(i,b),r.invoke(e.onSave,b)};return c.onclick=f=>{const g=p(f.currentTarget);n.set(m(e.value)),a.set(!0),g&&(g.root.setAttribute("data-editing","true"),g.input.value=n.get(),setTimeout(()=>g.input.focus(),0))},u.oninput=f=>n.set(f.currentTarget.value),u.onkeydown=f=>{const g=f;if(g.key==="Enter"&&d(f.currentTarget),g.key==="Escape"){const b=p(f.currentTarget);a.set(!1),b?.root.setAttribute("data-editing","false")}},u.onblur=f=>d(f.currentTarget),o.append(c,u),o}},Dm={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(E(e.count,0))),n=Yt(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=l("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),c=l("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),u=j("bell",{className:"rui-notification-bell-icon"});u&&c.append(u),a>0&&c.append(l("span",{class:"rui-notification-bell-badge"},[a>99?"99+":String(a)])),s.append(c);const p=l("div",{class:"rui-notification-bell-panel",role:"menu"});if(n.length===0)p.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"},[m(d.title)]));const g=m(d.message);g&&f.append(l("div",{class:"rui-notification-bell-item-message"},[g]));const b=m(d.time);b&&f.append(l("div",{class:"rui-notification-bell-item-time"},[b])),p.append(f)}return s.append(p),c.onclick=d=>{d.stopPropagation();const f=d.currentTarget,g=f.closest(".rui-notification-bell");if(!g)return;const b=!i.get();i.set(b),g.setAttribute("data-open",b?"true":"false"),f.setAttribute("aria-expanded",b?"true":"false"),b?(r.invoke(e.onOpen),tt({liveRoot:g,onDismiss:()=>{i.set(!1),g.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):Pe(g)},s}},ye=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),jm=t=>!!(t&&typeof t=="object"),Bm={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(!jm(a))return ye(r,n.empty??n.data??null);const i=a.state;if(i==="loading"||a.loading)return ye(r,n.loading??null);if(i==="error"||a.error)return ye(r,n.error??null);const o=a.data;return o==null||Array.isArray(o)&&o.length===0?ye(r,n.empty??n.data??null):ye(r,n.data??null)}},_m={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?ye(r,e.children??null):ye(r,e.fallback??null)},Om={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=m(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"})}},Fm={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=m(e.path);if(a)try{r.router.navigate(a)}catch{}return l("span",{class:"rui-redirect","data-path":a,hidden:"true"})}},Um={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"?ye(r,e.fallback??null):ye(r,n??e.children??null)}catch{return ye(r,e.fallback??null)}return ye(r,e.children??null)}},Hm={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=ye(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}}},Vm=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"]),Wm=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,qm=new Set(["href","ping","action","formaction"]),Km=new Set(["src","poster"]);function Gm(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function Ym(t){const e=m(t).trim().toLowerCase();return!e||!Vm.has(e)?"div":e}function Xm(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||!Wm.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(qm.has(i)){const o=et(a,"");o&&(e[n]=o);continue}if(Km.has(i)){const o=ne(a);o&&(e[n]=o);continue}e[n]=a===!0?"":m(a)}}return e}const Jm={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=Ym(e.tag),n=Xm(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}},Zm=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,Qm=64*1024;function ef(t){const e=m(t);return!e||e.length>Qm||Zm.test(e)?"":e}const Ci=[Xl,Jl,Ql,Zl,Gl,Un,dc,pc,ec,tc,rc,ac,oc,ic,cc,lc,hc,nc,mc,gc,Dc,jc,kc,Sc,Cc,Yn,Ac,Tc,Nc,Mc,Ec,Rc,_c,yc,Bc,vu,bu,cu,uu,pu,du,mu,gu,fu,hu,su,lu,Xn,yu,xu,wu,ku,Jn,Su,Cu,ld,sd,ud,cd,dd,pd,fd,md,vd,yd,xd,bd,$d,Ad,Td,Pd,Id,Hd,oi,Ed,Ld,Ud,zd,Rd,jd,Bd,Wd,qd,Vd,_d,Gd,ci,Xd,Qd,Zd,ap,np,ip,op,Pu,Iu,nd,id,Eu,zu,Lu,Du,Ru,ju,Bu,od,_u,Ou,Zn,rd,Hu,Uu,Fu,Vu,Wu,Gu,Ku,qu,Yu,Xu,Zu,Ju,Qu,td,ed,cp,dp,fp,gp,hp,vp,yp,wp,kp,Sp,$p,Tp,Np,Pp,Ep,zp,Dp,jp,_p,Op,Hp,Wp,qp,Gp,Yp,Xp,Jp,Zp,Qp,em,rm,nm,om,sm,lm,cm,um,dm,pm,mm,fm,gm,hm,bm,$m,Am,Tm,Nm,Mm,Pm,Im,Em,Lm,zm,Rm,Dm,Bm,_m,Om,Fm,Um,Hm,Gc,Xc,Zc,Qc,eu,ru,Yn,Jm,{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=ef(e.css),a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}}],tf=[{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:"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."]}];Ra(Ci);const bt={root:"Column",components:Ci,componentGroups:tf},rf="$";function $i(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 Ai(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 Ti{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);D(this,"profiling",!1);D(this,"profilerRecords",[]);D(this,"profiledInstances",new Set);this.options=e}setProfiling(e){this.profiling=e,e||(this.profilerRecords=[],this.profiledInstances.clear())}drainProfilerRecords(){const e=this.profilerRecords;return this.profilerRecords=[],e}depthOf(e){let r=0;for(let a=0;a<e.length;a+=1)e[a]==="#"&&(r+=1);return r}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,this.profilerRecords=[],this.profiledInstances.clear()}beginRender(e={}){this.aliveInstances=new Set,this.changedPaths=e.changedPaths??new Set,this.memoEnabled=e.memoize??!1,this.profiling&&(this.profilerRecords=[])}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);if(this.profiling)for(const r of[...this.profiledInstances])e.has(r)||this.profiledInstances.delete(r)}profile(e,r,a,n,i,o,s){this.profilerRecords.push({instanceKey:e,name:r,kind:a,phase:n,selfTime:i,depth:this.depthOf(e),reason:o,deps:s?[...s]:void 0}),this.profiledInstances.add(e)}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,rf)}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 ln(e)?this.renderUserComponent(e,r):sn(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 d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.decl.name}]`,d}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&&$i(e.positional,s.positional)&&Ai(e.named,s.named)&&!st(this.changedPaths,s.deps)){const d=n.trackedState;for(const f of s.deps)d.add(f);this.profiling&&this.profile(o,e.decl.name,"user","memo",0,"memoized (args + deps unchanged)",s.deps),hr(n,e.decl.name);try{return this.renderAt(s.value,o)}finally{br(n)}}const c=this.profiledInstances.has(o)?"update":"mount",u=s?$i(e.positional,s.positional)?Ai(e.named,s.named)?st(this.changedPaths,s.deps)?"state dependency changed":"full render":"named args changed":"positional args changed":c==="mount"?"initial mount":"no memo (full render)",p=this.profiling?pe():0;hr(n,e.decl.name);try{const d=n.trackedState,f=new Set;n.trackedState=f;let g;try{g=xn(e,n,o)}finally{n.trackedState=d;for(const y of f)d.add(y)}const{value:b,effects:h,hooks:v}=g;return this.profiling&&this.profile(o,e.decl.name,"user",c,pe()-p,u,f),this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,h,a),h.length>0&&this.instancesWithEffects.add(o)),v>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:f,value:b}),this.renderAt(b,o)}finally{br(n)}}renderComponent(e,r){const a=Ee(this.options.library,e.name);if(!a){const d=document.createElement("div");return d.className="rui-unknown-component",d.textContent=`[unknown component: ${e.name}]`,d}const n=Da(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 c={renderNode:d=>this.renderAt(d,`${o}>${s++}`),invoke:(d,...f)=>{if(typeof d=="function")try{const g=d(...f);g&&typeof g.then=="function"&&g.catch(b=>{console.error("[aktion] handler rejected",b)})}catch(g){console.error("[aktion] handler threw",g)}},setState:(d,f)=>{this.writeState(d,f)},resetState:(...d)=>{this.options.state.reset(...d)},sendToAssistant:d=>{this.options.onAssistantMessage?.(d)},openUrl:d=>{const f=et(d,"#"),g=this.options.onOpenUrl;g?g(f):f!=="#"&&typeof window<"u"&&window.open(f,"_blank","noopener,noreferrer")},bindState:(d,f,g)=>{const h=`on${g?.event??this.eventFor(d)}`,v=g?.getValue??this.defaultValueGetter(d);d[h]=y=>{const x=y.currentTarget??y.target??d;this.writeState(f,v(x))}},useInstanceState:(d,f)=>{const g=`${o}::${d}`;return this.instanceStates.has(g)||this.instanceStates.set(g,f),{get:()=>this.instanceStates.get(g),set:b=>{this.instanceStates.set(g,b)}}},registerDisposer:(d,f)=>{let g=this.instanceDisposers.get(o);g||(g=new Map,this.instanceDisposers.set(o,g));const b=f??`__anon::${g.size}`,h=g.get(b);h&&h!==d&&this.safeDispose(h),g.set(b,d)},router:this.options.router},u=this.profiledInstances.has(o)?"update":"mount",p=this.profiling?pe():0;try{const d=a.render(e,n,c);return this.profiling&&this.profile(o,e.name,"library",u,pe()-p,u==="mount"?"mounted":"re-rendered"),d}catch(d){this.profiling&&this.profile(o,e.name,"library",u,pe()-p,"render threw"),console.error(`[aktion] failed to render ${a.name}`,d);const f=document.createElement("div");return f.className="rui-render-error",f.textContent=`[render error in ${a.name}]`,f}}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 af=["onclick","oninput","onchange","onsubmit","onfocus","onblur","onkeydown","onkeyup","onkeypress","onerror","onmouseenter","onmouseleave","onmousedown","onmouseup","onpointerdown","onpointerup"];function nf(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];Pi(t,r)}function Ni(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):(of(r,a),r)}function Mi(t,e){return t.parentNode?.replaceChild(e,t),e}function of(t,e){sf(t,e),lf(t,e),Pi(t,Array.from(e.childNodes)),cf(t,e)}function sf(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 lf(t,e){for(const r of af){const a=e[r],n=t[r];a!==n&&(t[r]=a??null)}}function cf(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){uf(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){df(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){!Xt(t)&&t.value!==e.value&&(t.value=e.value);return}}function uf(t,e){if(t.type==="checkbox"||t.type==="radio"){const a=e.hasAttribute("checked")||e.checked;t.checked!==a&&!Xt(t)&&(t.checked=a);return}const r=e.getAttribute("value")??e.value??"";!Xt(t)&&t.value!==r&&(t.value=r)}function df(t,e){const r=e.value??e.textContent??"";!Xt(t)&&t.value!==r&&(t.value=r)}function Xt(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function Pi(t,e){const r=new Map;for(const n of Array.from(t.childNodes)){const i=Wr(n);i&&r.set(i,n)}let a=0;for(const n of e){const i=t.childNodes[a]??null,o=Wr(n);if(o&&r.has(o)){const c=r.get(o);r.delete(o),c!==i&&t.insertBefore(c,i),Ni(c,n),a+=1;continue}if(!i){t.appendChild(n),a+=1;continue}const s=Wr(i);if(s&&(!o||s!==o)){t.insertBefore(n,i),a+=1;continue}Ni(i,n),a+=1}for(;t.childNodes.length>e.length;){const n=t.childNodes[t.childNodes.length-1];t.removeChild(n)}}function Wr(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}function qr(t,e={}){return e.mode==="chat"?ff(t,e):mf(t,e)}function pf(t){return Jt(t)}function mf(t,e){const r=e.bindings??!0,a=e.toolCalls??!0,n=[];n.push(gf(e.preamble)),n.push(hf()),n.push(bf()),r&&n.push(vf()),n.push(yf()),n.push(xf()),a&&n.push(wf()),n.push(kf()),n.push(Sf()),n.push(Cf()),n.push($f()),n.push(Af()),n.push(Tf()),n.push(Nf()),n.push(Mf(t)),e.inlineMode&&n.push(Pf()),e.editMode&&n.push(If()),e.tools&&e.tools.length>0&&n.push(Vf(e.tools)),e.toolExamples&&e.toolExamples.length>0&&n.push(Kr("Endpoint examples",e.toolExamples));const i=e.examples??Lf();return i.length>0&&n.push(Kr("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&n.push(Ii(e.additionalRules)),n.push(Ef()),n.join(`
43
100
 
44
101
  `).trim()+`
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(`
102
+ `}function ff(t,e){const r=[];r.push(Rf(e.preamble)),r.push(Df()),r.push(jf(t)),r.push(Bf()),e.tools&&e.tools.length>0&&r.push(Of(e.tools));const a=e.examples??Ff();return a.length>0&&r.push(Kr("Examples",a)),e.additionalRules&&e.additionalRules.length>0&&r.push(Ii(e.additionalRules)),r.push(_f()),r.push(Uf()),r.push(Hf()),r.join(`
46
103
 
47
104
  `).trim()+`
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."}
105
+ `}function gf(t){return`${t?.trim()||"You are a UI engineer building complete, working apps in Aktion — a declarative language that is a strict subset of JavaScript: every program is valid JS, and the runtime adds reactivity on top. Respond ONLY in Aktion — no prose, JSON, markdown, or HTML."}
49
106
 
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
-
52
- A program is a flat list of \`name = expression\` statements, one per line. Newlines terminate statements; semicolons are optional.
53
-
54
- \`\`\`
55
- ${V} = Column([header, kpis, table]) // root assignment (always first)
56
- header = PageHeader("Sales", { subtitle: "Q4 2026" })
57
- $count = 0 // reactive atom — '$' prefix is the contract
58
- function Counter(label) { return Text(\`\${label}: \${$count}\`) } // component (returns a render tree)
59
- function inc() { $count = $count + 1 } // action (no return — runs for side effects)
60
- $effect(() => { $console.log($count) }, [$count]) // declarative side effect
61
- \`\`\`
62
-
63
- ### Three name conventions
64
- - \`name = value\` — plain binding (not reactive). Captured once.
65
- - \`$name = value\` — reactive atom. Reading subscribes; writing notifies.
66
- - \`function name(...)\` — declares a component AND an action with that name. The same declaration works in both render position (its return value renders) and event-handler position (its body runs). First-letter case is NOT significant: \`function Card(...)\`, \`function card(...)\`, \`function SaveOrder(...)\`, and \`function saveOrder(...)\` are all valid.
67
-
68
- ### One hard rule — broken constantly, ALWAYS check
69
- 1. **Always invoke components with parentheses.** A component is a function — to render it you MUST call it. The bare identifier \`MyApp\` is a *reference to the function*; the rendered element is \`MyApp()\`. Even with no arguments, write \`MyApp()\`. So \`${V} = MyApp\` is wrong — write \`${V} = MyApp()\`. Inside arrays the same applies: \`Column([Header(), Body(), Footer()])\`, never \`Column([Header, Body, Footer])\`. The only exception is passing a component as a callback (e.g. \`render: UserCard\`) where the caller invokes it.
70
-
71
- ### Reserved top-level names
72
- - \`${V}\` — the UI root (REQUIRED, first line).
73
- - \`theme\` — optional brand override (\`theme = $theme({...})\`).
74
- - \`route\` — reactive router handle (\`route.path\`, \`route.params\`, \`route.navigate("/x")\`). NEVER declare \`route\` yourself.
75
-
76
- ### Component-call shape — One positional argument max (TRAILING-OBJECT RULE)
77
- Every call takes **at most one positional argument**; every other argument lives in a trailing \`{ }\` object literal:
78
-
79
- \`\`\`
80
- Button("Save", { variant: "primary", loading: $isSaving })
81
- StatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })
82
- Row([Card1(), Card2()], { gap: "m" })
83
- \`\`\`
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 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
-
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
-
89
- \`\`\`
90
- $count = 0
91
- $user = { name: "Ada", role: "Engineer" }
92
- $todos = []
93
- \`\`\`
94
-
95
- ### Read & write
96
- - Read \`$name\` anywhere — auto-subscribes whoever reads it (component, derived value, effect).
97
- - Write \`$name = ...\` from event handlers, effect callbacks, and lambda bodies — i.e. in response to an event, never while building the UI. \`+=\`, \`-=\`, \`*=\`, \`/=\`, \`??=\`, \`++\`, \`--\` work too. Member writes (\`$user.name = "Alex"\`) rebuild the root immutably so subscribers see a fresh reference.
98
- - **Never write \`$state\` in render position.** A \`$name = ...\` that runs while the UI is being built schedules a re-render that re-runs the write — an infinite loop. This bites when a \`function\` that *declares* state is invoked to render (\`aktion = app()\` where \`app\` does \`$user = {...}\`): a lowercase \`function\` called that way runs as an action, so the assignment is a per-render write. To hold component-local state, make it a **PascalCase component** (then top-of-body \`$count = 0\` is a set-once per-instance declaration) or use the \`$state\` hook — both seed once and persist. (The runtime defends against the loop — it applies the write but skips the re-render and warns — but the pattern is still wrong.)
99
-
100
- ### Fine-grained reactivity (path-level)
101
- Subscriptions are tracked at the **path** you read, not the whole atom. Reading \`$user.name\` subscribes to \`user.name\` alone: a write to a sibling field (\`$user.role = ...\`) won't re-render or recompute it, while replacing the whole atom (\`$user = ...\`) or writing a descendant still does. The same rule drives computed values and effect deps (\`$effect(..., [$user.name])\` fires only on \`name\` changes). Reading a whole object (\`$user\`) or indexing into an array (\`$rows[i]\`, the \`$rows.field\` pluck) subscribes at that object/array — so prefer reading the exact field you need (\`$user.name\`) to get the tightest updates. No selectors or special syntax — just read the path.
102
-
103
- A component re-executes only when **its own inputs change** — its args (props) or a \`$state\` path its body read — like \`React.memo\` / Solid, but automatic. So \`ShowName($user.name)\` and \`ShowAge($user.age)\` are independent: changing \`$user.age\` re-runs only \`ShowAge\`. Args are compared shallowly, so (as in React) a fresh inline lambda prop each render makes the child re-render — hoist the handler to a stable binding to skip it.
104
-
105
- ### Per-instance state
106
- \`$name = value\` inside a function body is per-instance when the function is used as a component. Two \`Counter()\` siblings each hold their own \`$count\`. Add \`{ key: id }\` at the call site to keep state attached when siblings reorder.
107
-
108
- ### Hooks — composable per-instance state
109
- A function whose name starts with \`$\` is a **hook** (mirroring React's \`use*\` convention). Call hooks only at the top level of a component body (or another hook), in a stable order — never inside an \`if\`, loop, or callback. Hook state is per-instance and resets when the instance leaves the tree.
110
-
111
- - \`$state(initial)\` → \`[value, setValue]\`, like React's \`useState\`. \`setValue(next)\` replaces the value; \`setValue(prev => next)\` derives it from the previous value. \`initial\` is evaluated once, on first render.
112
- - \`$memo(() => compute, [deps])\` → a cached value, like React's \`useMemo\`. Recomputes only when a dependency changes (shallow \`Object.is\` compare); omit the deps array to recompute every render.
113
- - \`function $name(...) { ... }\` declares a custom hook that composes the built-ins. Its \`$state\` / \`$memo\` calls attach to the component that called it.
114
-
115
- \`\`\`
116
- function $useCounter(start) {
117
- const [count, setCount] = $state(start)
118
- return { count: count, increment: () => setCount(c => c + 1) }
119
- }
120
-
121
- function Counter() {
122
- const c = $useCounter(0)
123
- const label = $memo(() => \`Count: \${c.count}\`, [c.count])
124
- return Stack([Text(label), Button("+1", { onClick: c.increment })])
125
- }
126
- ${V} = Counter()
127
- \`\`\`
128
-
129
- Reach for \`$state(...)\` when a component owns local state with explicit setters; the bare \`$name = value\` per-instance form above is the lighter option when an atom is written directly by the component's actions. \`$state\` and \`$memo\` are reserved hook names.
130
-
131
- ### Two-way binding (implicit)
132
- Pass a \`$variable\` (or a member chain rooted at one — \`value: $form.email\`) as a value prop on any input/select/checkbox/switch/slider/picker and the runtime wires the change handler automatically. Add \`onChange: v => ...\` when you also need a side effect (debounced search, persistence, etc.).
133
-
134
- \`\`\`
135
- $draft = ""
136
- $theme = "light"
137
-
138
- field = Input("draft", { value: $draft })
139
- darkMode = Switch("dark", { value: $theme == "dark", onChange: on => $theme = on ? "dark" : "light" })
140
- search = Input("query", { onChange: q => $results = $http({ url: \`https://api.example.com/search?q=\${q}\` }) })
141
- \`\`\`
142
-
143
- ### Computed values
144
- There is no separate "computed" tier — just compute. Every \`$\` reference inside an expression auto-tracks.
145
-
146
- \`\`\`
147
- $open = $todos.filter((t) => !t.done)
148
- $total = $util.sum($cart.price)
149
- \`\`\`
150
-
151
- ### Global stores — \`$store({...})\`
152
- For app-wide state shared across many components (no prop drilling), declare a **store** at the top level. Non-function entries are reactive **state**; function entries are **methods** that receive the store handle \`s\` as their first argument. Read state as \`store.field\` (fine-grained — subscribes to that slice) and call methods as \`store.method(args)\`. Mutate inside a method with \`s.field = …\`. The handle is an app-global singleton with reference-stable methods.
153
-
154
- \`\`\`
155
- cart = $store({
156
- items: [], // state
157
- count: (s) => s.items.length, // getter-method → cart.count()
158
- total: (s) => $util.sum(s.items.map(i => i.price)), // getter-method → cart.total()
159
- add: (s, item) => { s.items = [...s.items, item] }, // action → cart.add(item)
160
- clear: (s) => { s.items = [] },
161
- })
162
-
163
- function CartBadge() { return Badge(\`\${cart.count()} items\`) } // reads the store
164
- function AddButton(item) { return Button("Add", { onClick: () => cart.add(item) }) } // calls a method
165
- \`\`\`
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 _m(){return`## Components & Actions
168
-
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
-
171
- ### Components
172
- A function used as a component returns a render tree. Parameters use standard JS defaults; destructured options are canonical. To render a component you MUST call it with parentheses — even when it takes no arguments. The bare identifier is just the function value.
173
-
174
- \`\`\`
175
- // Both forms work — case is not significant
176
- function UserCard(user) { return Card([Text(user.name)]) }
177
- function userCard(user) { return Card([Text(user.name)]) }
178
- Display = () => ["apple", "banana"].map(function (e) { return Button(e) })
179
- ${V} = Column([UserCard($currentUser), userCard($otherUser), Display()])
180
- \`\`\`
181
-
182
- \`\`\`
183
- function UserCard(user, { tone = "default" } = {}) {
184
- $hover = false
185
- return Card([
186
- Avatar(user.name, { size: "md" }),
187
- Text(user.name, { variant: "large-heavy" }),
188
- Text(user.role, { tone: "muted" }),
189
- Badge(tone, { tone: tone })
190
- ])
191
- }
192
- \`\`\`
193
-
194
- - \`children\` parameter is the implicit slot — the call site's positional argument is delivered into it.
195
- - User-declared components shadow built-ins by name, so you can wrap library components with telemetry / per-app styling.
196
- - Lambdas (\`row = item => Row(item)\`) are the right tool for one-off helpers that don't need their own component.
197
- - A function that does not \`return\` anything simply renders nothing when called in a render position — the runtime treats the missing/undefined value as an empty fragment.
198
-
199
- ### Actions
200
- A \`function\` whose body runs for side effects (rather than returning a render tree) acts as an action. Use as event handler (\`onClick: save\`) or as a value-producing expression (\`$result = greet("Ada")\`). The first-letter case of the name does not matter — \`save\` and \`Save\` are both valid.
201
-
202
- \`\`\`
203
- function save(item) {
204
- $items = [...$items, item]
205
- $save = $http({ url: "https://api.example.com/save", method: "POST", body: { item } })
206
- $emit("saved", { id: item.id })
207
- }
208
-
209
- submitBtn = Button("Save", { onClick: save })
210
- resetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } }) // inline lambda
211
- \`\`\`
212
-
213
- \`return\` is optional. Inside the body, the full JS statement surface is available (see *JavaScript is fully supported*).
214
-
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 Um(){return`## Effects — Declarative side effects
217
-
218
- \`$effect(() => { ... }, [...deps])\` runs declarative side effects. Dependency entries:
219
-
220
- - \`$atom\` — re-run when this reactive atom changes.
221
- - \`"mount"\` — run once when the surrounding scope mounts.
222
- - \`"unmount"\` — run once when it unmounts.
223
- - \`"every(N)"\` — re-run every N milliseconds.
224
- - \`"debounce(N)"\` / \`"throttle(N)"\` — wrap the body with a trailing-edge rate limit.
225
-
226
- \`$effect(() => { ... })\` (no second argument) is shorthand for \`["mount"]\`.
227
-
228
- ### Scope — top-level vs. component-local
229
- Top-level effects mount on parse, tear down on \`setResponse\` / \`clear()\`. Effects inside a component body mount per-instance and tear down when the instance leaves the tree (clearing intervals, watched-atom subscriptions, and \`cleanup(fn)\` registrations).
230
-
231
- \`\`\`
232
- function LiveClock() {
233
- $now = $util.now()
234
- $effect(() => { $now = $util.now() }, ["every(1000)"])
235
- return Text($util.formatDate($now, "time"))
236
- }
237
-
238
- // Debounced search — re-issue the request when inputs change
239
- $effect(() => {
240
- $results = $http({ url: "https://api.example.com/search", query: { q: $query, page: $page } })
241
- }, [$query, $page, "debounce(250)"])
242
-
243
- // Cleanup
244
- $effect(() => {
245
- const onKey = e => { if (e.key == "/") $palette = true }
246
- document.addEventListener("keydown", onKey)
247
- cleanup(() => document.removeEventListener("keydown", onKey))
248
- }, ["mount"])
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
-
251
- The router is a plain function call. Assign \`$router({ ... })\` to a binding and reference that binding from your shell.
252
-
253
- \`\`\`
254
- pages = $router({
255
- "/": Dashboard(),
256
- "/orders": OrdersPage(),
257
- "/orders/:id": OrderDetail({ id: params.id }),
258
- "/settings/*": SettingsArea({ rest: params._ }),
259
- default: NotFound()
260
- })
261
-
262
- ${V} = AppShell(MainSidebar(), pages, TopBar())
263
- \`\`\`
264
-
265
- - Path patterns: literal \`"/about"\`, parameter \`"/users/:id"\` (read \`params.id\`), trailing wildcard \`"/docs/*"\` (read \`params._\`), \`default:\` for the catch-all.
266
- - \`route\` handle (read-only): \`route.path\`, \`route.params.x\`, \`route.query.tab\`, \`route.pattern\`.
267
- - \`route.navigate("/path")\` inside an action / effect changes the URL.
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
-
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
-
272
- Use only when the standard catalogue cannot express the markup or styling you need.
273
-
274
- - \`HTMLTag(tag, { attributes?, children? })\` — render an allow-listed HTML tag. \`on*\` attributes, \`javascript:\` URLs, and unsafe \`style\` patterns are stripped; tag names outside the allow-list collapse to \`div\`.
275
- - \`Styles(css)\` — inject a \`<style>\` block. Payloads containing \`</style>\`, \`<script>\`, \`expression(\`, \`javascript:\`, \`behavior:\`, or \`@import\` are dropped.
276
-
277
- \`\`\`
278
- ${V} = Column([
279
- Styles(\`.hero-callout { background: linear-gradient(135deg, #6366f1, #10b981); color: white; padding: 24px; border-radius: 12px; }\`),
280
- HTMLTag("div", { attributes: { class: "hero-callout" }, children: [
281
- HTMLTag("h2", { children: [Text("Custom block")] }),
282
- Text("Use these only when the standard library cannot capture the design.")
283
- ]})
284
- ])
285
- \`\`\``}function Km(){return`## Theming, i18n & icons
286
-
287
- ### \`theme = $theme({ ... })\`
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.
289
-
290
- \`\`\`
291
- theme = $theme({
292
- colors: { primary: "#635bff", bg: "#0a0a23", surface: "#10103a", text: "#fff" },
293
- radius: { md: "0.5rem", button: "999px" },
294
- font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif" }
295
- })
296
- \`\`\`
297
-
298
- The host page picks one of seven base themes (\`light\`, \`dark\`, \`neon\`, \`pastel\`, \`glass\`, \`brutalist\`, \`skyline\`) via the \`theme\` attribute. Authored programs should be theme-neutral by default — pass \`tone:\` / \`variant:\` instead of hard-coded colours.
299
-
300
- ### i18n
301
- \`\`\`
302
- const { t, setCurrentLanguage, getCurrentLanguage } = $i18n({
303
- defaultLanguage: "en",
304
- currentLanguage: "fr",
305
- translations: {
306
- greeting: { en: "Hello, {name}!", fr: "Bonjour, {name}!" },
307
- items_count: { en: "{count} items", fr: "{count} objets" }
308
- }
309
- })
310
- welcome = Text(t("greeting", { name: $user.name }))
311
- \`\`\`
312
- \`t(key, vars?)\` looks up \`translations[key][currentLanguage]\`, falls back to \`translations[key][defaultLanguage]\`, then to the bare key. Placeholders use \`{name}\` syntax. Drive \`currentLanguage\` from a \`$state\` atom (e.g. \`currentLanguage: $lang\`) for reactive language switching, or call \`setCurrentLanguage(next)\` on the bundle.
313
-
314
- ### Icons
315
- Icon-typed props expect a Font Awesome name as a string — no \`fa-\` prefix, NEVER an emoji character.
316
-
317
- - \`"name"\` defaults to the solid set: \`"house"\`, \`"chart-line"\`, \`"star"\`.
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 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
-
322
- ### Hoisting & streaming (CRITICAL)
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:
324
-
325
- 1. \`${V} = ...\` — first line, always.
326
- 2. Function declarations (components & actions) and \`$effect(...)\` calls.
327
- 3. Leaf data values (strings, numbers, arrays, objects) — last.
328
-
329
- Define one named reference per FormControl, TabItem, AccordionItem, Series, Col, etc. so each one streams independently. Never split a single statement across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.
330
-
331
- ### Output rules
332
- - Output ONLY Aktion (or a fenced \`\`\`aktion\`\`\` block when inline mode is enabled).
333
- - Build a complete, navigable surface — \`PageHeader\`, multi-section layouts, working buttons. Don't reply with a single Card.
334
- - Wire every visible button. Declare \`function name() { ... }\` blocks (any case for the name); reference via \`Button("Label", { onClick: name })\`.
335
- - Use \`$router({...})\` for multi-page apps; reach \`pages\` from \`${V}\`; link from sidebar/navbar with \`NavLink\`/\`SidebarItem\` (\`to: "/path"\`).
336
- - Seed realistic mock data inline when no backend is available (5–20 plausible rows).
337
- - Lay out with three primitives: \`Column([...])\` (vertical, the usual page/section), \`Row([...])\` (horizontal toolbars/rows), and \`Grid([...], { columns })\` (equal columns / card walls). \`Center([...], { minHeight })\` centers content. Use responsive prop maps (\`{ base: 1, md: 2, lg: 4 }\`) on \`Grid\` columns or \`Stack\` direction so the app works on phone and desktop.
338
- - Use template literals for any string mixing copy with values.
339
- - Tables are column-oriented: \`Table([Col("Label", arr1), Col("Count", arr2, { format: "number" })])\`. A column cell can be any component — the simplest form just maps each row to a component: \`Col("Status", rows.map(r => Badge(r.status)))\`, \`Col("Actions", rows.map(r => Button("Edit", { onClick: () => edit(r.id) })))\`. You can also keep \`values\` as the raw rows and pass \`render: (value, index) => Component\`. Make a column clickable with \`onClick: (value, index) => …\`. Both work in \`Table\` and \`DataGrid\`.
340
- - Charts need numeric arrays. Use array pluck: \`PieChart(rows.label, rows.value)\`.
341
- - Icons are Font Awesome names (no \`fa-\` prefix, no emoji).
342
- - Named arguments use a trailing \`{ prop: value }\` object — never bare \`prop: value\` in a call.
343
-
344
- ### Final verification
345
- Before finishing, walk your output and check:
346
- 1. \`${V} = ...\` is the FIRST line.
347
- 2. Every referenced name is defined somewhere below.
348
- 3. Every defined name (other than \`${V}\`, \`theme\`) is reachable from \`${V}\`.
349
- 4. **Function name case is NOT significant.** \`function Card(...)\` and \`function card(...)\` both declare a component-and-action; the same applies to arrow bindings.
350
- 5. **Every component reference is invoked with parentheses.** Scan for bare component identifiers used as values (root assignment, array elements, prop values) — wrap each in \`()\`. \`${V} = MyApp\` → \`${V} = MyApp()\`; \`Column([Hero, Body])\` → \`Column([Hero(), Body()])\`. The only exception is passing a component as a callback (e.g. \`render: UserCard\`) where the caller invokes it.
351
- 6. A function with no \`return\` simply renders nothing when called in a render position.
352
- 7. State uses the single-sigil \`$name = value\` form.
353
- 8. \`$http({...})\` uses an absolute \`url\` and exposes \`.data\`, \`.error\`, \`.loading\`, \`.status\`, \`.refetch()\`, \`.cancel()\`.
354
- 9. \`$router({...})\` arms use \`:\` (not \`->\`) and \`default\` (not \`_\`) for the wildcard.
355
- 10. Effects use \`$effect(() => {...}, [deps])\` — never the legacy bracket form.
356
- 11. \`storage\` / \`console\` are lowercase; \`route\` is reserved (never declare it).`}function tf(){return[`// Tasks dashboard — $http(), Async, action, multi-section layout
357
- $tasks = $http({ url: "https://api.example.com/tasks", method: "GET" })
107
+ Register the UI root with \`$app(...)\` on the first line. Pass it one node (\`$app(Component())\`), an array (\`$app([Component1(), Component2()])\`), or variadic nodes (\`$app(Component1(), Component2())\`). Wrap a dashboard/app in \`AppShell\` (left sidebar + topbar); build a website or marketing page from a top \`Navbar\` + stacked sections — never an \`AppShell\`. References resolve across the whole program, so call \`$app(...)\` first and let the rest stream in below it. There should be only one \`$app(...)\` in the program, as the runtime treats it as the UI root.`}function hf(){return'## Core syntax\n\nA program is a flat list of `name = expression` statements, one per line (newlines end statements; semicolons optional).\n\n```\n$app(Column([header, kpis, table])) // UI root — always first\nheader = PageHeader("Sales", { subtitle: "Q4 2026" })\n$count = 0 // reactive atom — the \'$\' prefix is the contract\nfunction Counter(label) { return Text(`${label}: ${$count}`) } // component (returns a tree)\nfunction inc() { $count += 1 } // action (no return — runs for side effects)\n$effect(() => $console.log($count), [$count]) // declarative side effect\n```\n\n### Three kinds of name\n- `name = value` — plain binding, captured once (not reactive).\n- `$name = value` — reactive atom: reading subscribes, writing notifies.\n- `function name(...)` — declares a component AND an action of that name. First-letter case is NOT significant (`Card`/`card`, `SaveOrder`/`saveOrder`); same for arrow bindings (`row = item => Row(...)`).\n\n### Two rules, broken constantly — always check\n1. **Invoke components with parentheses.** A component is a function; the bare name is just its value. Render it by calling it, even with no args: `$app(MyApp())` not `$app(MyApp)`; `Column([Header(), Body()])` not `Column([Header, Body])`. (Exception: passing a component as a callback, e.g. `render: UserCard`.)\n2. **One positional argument max** (the trailing-object rule): each call takes at most one bare positional arg; all other props go in a trailing `{ }` object.\n\n```\nButton("Save", { variant: "primary", loading: $isSaving })\nStatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })\nRow([Card1(), Card2()], { gap: "m" })\n```\n\n`Button("Save", "primary")` is a schema error — use the named-prop form. Any call also accepts `{ key: ... }` to pin per-instance state across reorders.\n\n### Reserved top-level names\n- `$app(...)` — registers the UI root (REQUIRED).\n- `$theme({...})` — optional brand override (written as a bare statement).\n- `route` — the reactive router handle (`route.path`, `route.params`, `route.navigate("/x")`); never declare it yourself.'}function bf(){return'## JavaScript is fully supported\n\nAktion *is* JavaScript — every standard feature works inside expressions, action bodies, effect callbacks, and lambdas. Use whatever is clearest.\n\n### Ways to produce the UI\nThere is no single required shape — compose however the content suggests, and mix these freely:\n- **Inline in `$app(...)`** — `$app(Column([Hero(), Features(), Footer()]))` for a self-contained tree.\n- **Named statements** — pull pieces into `name = ...` bindings and reference them; they hoist and stream in independently.\n- **`.map` / `.filter` over data** — turn arrays into nodes: `rows = $items.map(i => Row(i))`.\n- **`function` components** — factor reusable or parameterised UI into components; invoke them with `()`.\n- **`$router({...})` pages** — split a multi-page app into route arms.\n\n### In expressions (right of `=`) — value-producing JS only\n```\nbanner = $error ? Banner($error, { tone: "danger" }) : null // ternary\nrows = $todos.filter(t => !t.done).map(t => TodoRow(t)) // map / filter / reduce\ntotal = $cart.reduce((sum, i) => sum + i.price, 0)\nmerged = { ...$base, status: "done" } // spread / destructuring\nname = $user?.profile?.name ?? "Guest" // optional chain / nullish\ntitle = `${rows.length} ${$util.plural(rows.length, "result", "results")}` // template literal\n```\n`if` / `switch` / `for` / `while` / `try` are statements — they can\'t sit on the right of `=`. Use a ternary, an array method, or wrap them in a function and call it.\n\n### In action / effect / lambda bodies — full statement surface\n`if`/`else`, `switch`, every `for` and `while`, `try`/`catch`/`finally`, `throw`, `return`, plus all assignment operators (`= += -= *= /= ??= ++ --`) against `$atoms` and member chains (`$user.name = "Alex"`).\n\n```\nfunction submit(payload) {\n if (!payload.email) return\n for (let tag of payload.tags) $tags = [...$tags, tag]\n $emit("submitted", { id: payload.id })\n}\n```\n\n### Lambdas, continuations, comments, timers\n- Arrow functions in every form: `() => expr`, `x => expr`, `(a, b = 0) => { ...; return ... }`, `(...args) => ...`.\n- A leading operator (`.`, `?.`, `&&`, `??`, `?`/`:`, arithmetic) continues an expression onto the next line.\n- Comments: `// line` and `/* block */` only.\n- `setTimeout` / `setInterval` / `clearTimeout` / `clearInterval` work and are torn down on re-plan — create them in an `$effect` and clear them in its `cleanup`, or prefer `$effect(..., ["every(1000)"])` for simple repeats.\n- Every JavaScript global resolves by name (see *Built-in globals*).'}function vf(){return'## Reactive State\n\nThe `$` sigil is the only thing that makes a binding reactive; `let`/`const`/`var` are optional and don\'t affect reactivity.\n\n```\n$count = 0\n$user = { name: "Ada", role: "Engineer" }\n```\n\n- **Read** `$name` anywhere — it auto-subscribes whoever reads it (component, derived value, effect).\n- **Write** `$name = ...` (and `+= -= ??= ++ --`) only from event handlers, effects, and lambdas — never while building the UI. Member writes (`$user.name = "Alex"`) update immutably so subscribers see a fresh reference.\n- **Never write reactive state in render position.** A write that runs while the UI is built loops; the runtime applies it but skips the re-render and warns. Hold component-local state by declaring it at the top of a component body (set-once per instance) or with the `$state` hook.\n\n### Fine-grained reactivity (path-level)\nSubscriptions track the exact **path** you read. Reading `$user.name` subscribes to `user.name` alone — writing `$user.role` won\'t recompute it, but replacing `$user` will; effect deps work the same (`$effect(..., [$user.name])`). Prefer reading the precise field for the tightest updates. A component re-executes only when its own inputs change — its args or a `$` path its body read — like `React.memo`, but automatic. Args compare shallowly, so hoist inline-lambda props to a stable binding to avoid needless child re-renders.\n\n### Per-instance state\n`$name = value` inside a function body is per-instance when the function renders as a component — two `Counter()`s each own their `$count`. Add `{ key: id }` to keep state attached when siblings reorder.\n\n### Hooks\nFor composable local state, use hooks — a function whose name starts with `$`, called only at the top level of a component (or another hook) in a stable order:\n- `$state(initial)` → `[value, setValue]` (like `useState`; `setValue(prev => next)` supported, `initial` runs once).\n- `$memo(() => value, [deps])` → a cached value (like `useMemo`).\n- `function $name(...)` declares a custom hook composing the built-ins.\n\n```\nfunction Counter() {\n const [count, setCount] = $state(0)\n const label = $memo(() => `Count: ${count}`, [count])\n return Stack([Text(label), Button("+1", { onClick: () => setCount(c => c + 1) })])\n}\n```\n\n### Two-way binding\nPass a `$variable` (or member chain — `value: $form.email`) as the value prop of any input/select/checkbox/switch/slider and the runtime wires the change handler automatically; add `onChange: v => ...` for an extra side effect.\n\n```\n$draft = ""\nfield = Input("draft", { value: $draft })\n```\n\n### Computed values\nNo separate "computed" tier — just compute. Every `$` reference in an expression auto-tracks: `$open = $todos.filter(t => !t.done)`.\n\n### Global stores — `$store({...})`\nFor app-wide state without prop-drilling, declare a store. Non-function entries are reactive state; function entries are methods that receive the store handle `s` first. Read `store.field` (fine-grained) and call `store.method(args)`.\n\n```\ncart = $store({\n items: [],\n total: (s) => $util.sum(s.items.map(i => i.price)), // → cart.total()\n add: (s, item) => { s.items = [...s.items, item] }, // → cart.add(item)\n})\nfunction CartBadge() { return Badge(`${cart.items.length} items`) }\n```\n\nUse a store for shared state; use a component\'s local `$state` / `$name` for state one component owns.'}function yf(){return'## Components & Actions\n\nA `function` declaration is both a **component** (call it in render position → its return value renders) and an **action** (call it from an event handler → its body runs). Name case is not significant, and a function with no `return` renders nothing.\n\n### Components\n```\nfunction UserCard(user, { tone = "default" } = {}) {\n return Card([\n Avatar(user.name, { size: "md" }),\n Text(user.name, { variant: "large-heavy" }),\n Badge(tone, { tone })\n ])\n}\n$app(Column([UserCard($currentUser), UserCard($other, { tone: "primary" })]))\n```\n\n- The positional argument lands in the component\'s first parameter (the `children` slot for container-style components).\n- User components shadow built-ins of the same name — wrap a library component to add telemetry or styling.\n- Use a lambda (`row = item => Row(item)`) for one-off helpers that don\'t need a named component.\n\n### Actions\nA `function` whose body runs for side effects is an action — use it as a handler (`onClick: save`) or call it for its result. `return` is optional; the full JS statement surface applies.\n\n```\nfunction save(item) {\n $items = [...$items, item]\n $save = $http({ url: "https://api.example.com/save", method: "POST", body: { item } })\n $emit("saved", { id: item.id })\n}\nsaveBtn = Button("Save", { onClick: save })\nresetBtn = Button("Reset", { onClick: () => { $count = 0; $message = "" } })\n```\n\n### `$emit("name", { detail })`\nFrom any action / effect / lambda, `$emit` dispatches a `CustomEvent` on the host `<aktion-app>` (listen with `el.addEventListener`). Reserved names: `assistant-message`, `error`, `route-change`.'}function xf(){return'## Effects — Declarative side effects\n\n`$effect(() => { ... }, [...deps])` runs side effects. Dep entries: `$atom` (re-run on change), `"mount"` / `"unmount"` (once), `"every(N)"` (every N ms), `"debounce(N)"` / `"throttle(N)"` (trailing-edge rate limit). No second argument ≡ `["mount"]`.\n\nTop-level effects mount on parse and tear down on the next response; effects inside a component mount per-instance and tear down — running their `cleanup(fn)` — when the instance leaves the tree.\n\n```\n$effect(() => {\n $results = $http({ url: "https://api.example.com/search", query: { q: $term } })\n}, [$term, "debounce(250)"])\n\n$effect(() => {\n const onKey = e => { if (e.key == "/") $palette = true }\n document.addEventListener("keydown", onKey)\n cleanup(() => document.removeEventListener("keydown", onKey))\n}, ["mount"])\n```'}function wf(){return'## Data — `$http({...})`\n\n`$http({ ... })` is the only HTTP primitive. Each call is self-contained: pass an absolute `url`, optional `method` (default `GET`), `query` (serialised into the URL), `headers`, `body` (JSON-encoded automatically), and any `fetch` option. No host-wide defaults.\n\n```\n$orders = $http({ url: `https://api.example.com/users/${$userId}/orders`, query: { limit: 5 } })\n```\n\nIt fires once when the binding mounts and exposes a reactive bag:\n```\n$orders.data $orders.error $orders.status $orders.loading\n$orders.headers $orders.lastUpdated\n$orders.refetch() $orders.cancel() $orders.onDone = fn\n```\n\nRe-run with `.refetch()`, or wrap the call in `$effect(..., [$dep])` to re-issue when a dep changes. After a write, refresh a list from the write\'s `onDone` (fires on every settle — the initial load and each refetch):\n\n```\nfunction saveOrder(payload) {\n $save = $http({ url: "https://api.example.com/orders", method: "POST", body: payload })\n $save.onDone = () => $orders.refetch()\n}\n```\n\nBranch on resource state with `Async`:\n```\nview = Async($orders, {\n loading: LoadingState("Loading orders…"),\n error: ErrorState("Couldn\'t fetch orders"),\n empty: EmptyState("No orders yet"),\n data: Table([Col("Item", $orders.data.title), Col("Total", $orders.data.total, { format: "currency" })])\n})\n```'}function kf(){return'## Routing\n\n`$router({ ... })` is a plain function call — assign it and drop the result into your page shell.\n\n```\npages = $router({\n "/": Dashboard(),\n "/orders/:id": OrderDetail({ id: params.id }),\n "/docs/*": Docs({ rest: params._ }),\n default: NotFound()\n})\n$app(AppShell(MainSidebar(), pages)) // app/dashboard shell\n```\n\n- **Pick the shell for the surface.** `AppShell(Sidebar(...), pages)` for an app/dashboard (left sidebar + optional topbar); a top `Navbar(...)` above the pages inside a `Column` for a website / marketing / docs layout (no sidebar) — never wrap a website in `AppShell`. The router result is just a node, so it drops into either.\n- Patterns: literal, `:param` (read `params.id`), trailing `*` (read `params._`), and `default:` for the catch-all (unknown paths render `null` without it).\n- The read-only `route` handle: `route.path`, `route.params.x`, `route.query.tab`; navigate with `route.navigate("/path")` from an action/effect.\n- `NavLink(label, { to, exact?, icon? })` and `SidebarItem(label, { to, icon?, badge? })` derive active state from `route.path`. Never declare `route` yourself.'}function Sf(){return'## Built-in globals — `storage` & `console`\n\nAlways in scope, lowercase, no imports.\n\n```\n$storage.set("name", "John"); $name = $storage.get("name"); $storage.remove("name")\n$storage.session.set("draft", $draft)\n$storage.cookies.set("user", "John", { expires: 7, path: "/" })\n$console.log("Hello", $user)\n```\n\nNon-string values JSON-roundtrip; missing keys return `null`. Beyond these, every JavaScript global resolves by name — `Math`, `JSON`, `Date`, `crypto`, `fetch`, `URL`, `navigator`, `window`, `document`, dialogs like `confirm`, … — and your declarations and components shadow same-named globals. Prefer reactive `$http({...})` over raw `fetch` for UI data, and keep timers/listeners inside `$effect` so they\'re cleaned up.\n\n```\nfunction copyLink() { navigator.clipboard.writeText(window.location.href); $toast = "Copied" }\nid = crypto.randomUUID()\n```'}function Cf(){return'## Behaviour wrappers\n\nThese attach behaviour or styling to ANY node via `display: contents` (the visual tree is unchanged):\n- `OnClick(child, { onClick, disabled?, stopPropagation? })` — pointer + keyboard activatable. (Don\'t wrap `Button` — it already has `onClick`; use this for clickable cards / list rows.)\n- `OnMouse(child, { enter?, leave?, move?, down?, up?, drag?, drop?, dragOver?, ... })` — pass only the events you need.\n- `OnKeyboard(child, { onKeyDown?, onKeyUp?, focusable? })` and `OnFocus(child, { onFocus?, onBlur? })`.\n- `OnIntersect(child, { onEnter?, onLeave?, threshold?, once? })` — IntersectionObserver (lazy-load, infinite scroll).\n- `Css(child, { class?, style? })` — last-resort class/style merge.\n- `Link(childOrLabel, { to?, href?, external?, variant? })` — anchor; `to` for router nav, `href`+`external: true` for outbound links.\n\n```\nOnClick(Card([Text("View order")]), { onClick: () => route.navigate("/orders/4821") })\nOnIntersect(Skeleton({ variant: "card" }), { onEnter: $items.refetch, once: true })\n```'}function $f(){return'## Escape hatches — `HTMLTag` & `Styles`\n\nOnly when the catalogue can\'t express the markup/styling you need:\n- `HTMLTag(tag, { attributes?, children? })` — an allow-listed HTML tag (`on*` attributes, `javascript:` URLs, and unsafe `style` are stripped; unknown tags become `div`).\n- `Styles(css)` — inject a `<style>` block (`</style>`, `<script>`, `@import`, `javascript:` are dropped).\n\n```\n$app(Column([\n Styles(`.hero { background: linear-gradient(135deg, #6366f1, #10b981); padding: 24px; border-radius: 12px; }`),\n HTMLTag("div", { attributes: { class: "hero" }, children: [Text("Custom block")] })\n]))\n```'}function Af(){return'## Theming, i18n & icons\n\n### `$theme({ ... })`\nA bare `$theme({...})` statement (near the top) brands the response. Structured groups: `colors`, `radius`, `font` (plus metadata `name`, `direction`). Omit it to inherit the host theme.\n\n```\n$theme({\n colors: { primary: "#635bff", bg: "#0a0a23", surface: "#10103a", text: "#fff" },\n radius: { md: "0.5rem", button: "999px" },\n font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif" }\n})\n```\n\nThe host picks one of seven base themes (`light`, `dark`, `neon`, `pastel`, `glass`, `brutalist`, `skyline`) — author theme-neutral UI (use `tone:` / `variant:`, not hard-coded colours).\n\n### i18n\n```\nconst { t, setCurrentLanguage } = $i18n({\n defaultLanguage: "en", currentLanguage: $lang,\n translations: { greeting: { en: "Hello, {name}!", fr: "Bonjour, {name}!" } }\n})\nwelcome = Text(t("greeting", { name: $user.name }))\n```\n`t(key, vars?)` resolves `translations[key][currentLanguage]`, falling back to the default language then the bare key; `{name}` placeholders interpolate. Drive `currentLanguage` from a reactive atom for live switching.\n\n### Icons\nIcon props take a Font Awesome name (no `fa-` prefix, never an emoji): `"house"`, `"chart-line"`, `"regular:star"`, `"brands:github"`. `Icon(name, { variant?, size? })` renders a standalone glyph.'}function Tf(){return'## `$util` — runtime helper namespace\n\nPure helpers (no side effects), available in every expression, action, effect, and lambda. Reach for `$util` when plain JS would be verbose (formatting, dates, grouping); use plain JS when it\'s just as clear (`arr.length`, `arr.slice(0, 5)`).\n\n- **Collections**: `$util.sort(arr, field, dir?)`, `$util.groupBy(arr, field)`, `$util.unique(arr, field?)`, `$util.sum / .avg / .min / .max / .count`, `.first / .last`, `.filter(arr, field, op, value)`, `.find`, `.range(start, end, step?)`, `.pick(obj, keys)`.\n- **Strings**: `$util.capitalize / .titlecase / .uppercase / .lowercase`, `.plural(n, singular, plural)`, `.trim / .replace / .split / .match`.\n- **Formatting**: `$util.format(value, mode, opts?)` (number, currency, percent, compact) and `$util.formatDate(value, mode)` (`"short" | "long" | "time" | "relative"` or a token string).\n- **Dates / math**: `.now / .today / .addDays / .diffDays / .startOfWeek`; `.round / .floor / .ceil / .abs / .clamp(v, min, max) / .random`.\n\n```\nsorted = $util.sort($users.filter(u => u.team === $team), "joinedAt", "desc")\nsummary = `${rows.length} ${$util.plural(rows.length, "order", "orders")} · ${$util.format($util.sum(rows.amount), "currency")}`\n```'}function Nf(){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 Mf(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 c=r.get(s);c&&a.push(Jt(c))}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(Jt(o))}return a.join(`
108
+ `).trim()}function Pf(){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 If(){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 & verification\n\n### Hoisting & streaming (CRITICAL)\nReferences resolve across the whole top-level scope, not source order — undefined refs render empty until they arrive, giving a smooth top-down reveal. Emit in this order: (1) `$app(...)` first; (2) `function` declarations and `$effect(...)`; (3) leaf data (arrays, objects, strings) last. Give each `Col` / `TabItem` / `Series` its own named binding so it streams independently. Never split a statement across lines unless it sits inside an unmatched `[`, `(`, or `{`.\n\n### Before finishing, check\n1. `$app(...)` is first; every name it reaches is defined below, and every defined name is reachable from it.\n2. Every component reference is invoked with `()` — scan the root, array elements, and prop values for bare identifiers (callback props like `render: UserCard` are the one exception).\n3. State uses `$name = ...`; writes happen only in handlers/effects, never in render position.\n4. `$http({...})` uses an absolute URL and exposes `.data` / `.error` / `.loading` / `.refetch()`; `$router({...})` arms use `:` and `default`; effects are `$effect(() => {...}, [deps])`.\n5. Build a complete surface — `PageHeader`, multi-section layout, wired buttons, 5–20 rows of realistic seed data — not a lone Card. Lay out with `Column` / `Row` / `Grid`; use responsive maps (`{ base: 1, md: 2 }`) where they help.\n6. Tables are column-oriented (`Table([Col("Label", arr)])`, cells may be components via `rows.map(r => Badge(r.status))`); charts take numeric arrays (`PieChart(rows.label, rows.value)`); icons are Font Awesome names; `storage` / `console` are lowercase; `route` is reserved.'}function Lf(){return[`// Tasks dashboard — $http, Async, an action, multi-section layout
109
+ $tasks = $http({ url: "https://api.example.com/tasks" })
358
110
 
359
111
  function toggle(task) {
360
- $update = $http({ url: \`https://api.example.com/tasks/\${task.id}\`, method: "PATCH", body: { done: !task.done } })
361
- $tasks.refetch()
112
+ $patch = $http({ url: \`https://api.example.com/tasks/\${task.id}\`, method: "PATCH", body: { done: !task.done } })
113
+ $patch.onDone = () => $tasks.refetch()
362
114
  }
363
115
 
364
- renderRow = task => Card([Row([
116
+ row = task => Card([Row([
365
117
  Badge(task.done ? "done" : "open", { tone: task.done ? "success" : "neutral" }),
366
118
  StackItem(Text(task.title, { tone: task.done ? "muted" : "default" }), { grow: 1 }),
367
- Buttons([Button(task.done ? "Reopen" : "Done", { onClick: () => toggle(task), variant: "primary", size: "sm" })])
119
+ Button(task.done ? "Reopen" : "Done", { onClick: () => toggle(task), size: "sm" })
368
120
  ], { gap: "m" })])
369
121
 
370
- ${V} = Column([
122
+ $app(Column([
371
123
  PageHeader("Tasks", { subtitle: \`\${$tasks.data.length} items\`, actions: [Button("Refresh", { onClick: $tasks.refetch, variant: "ghost" })] }),
372
124
  Async($tasks, {
373
125
  loading: LoadingState("Loading tasks…"),
374
- error: ErrorState("Couldn't fetch tasks", { description: "Try again in a moment." }),
375
- empty: EmptyState("No tasks yet", { description: "Create your first task." }),
376
- data: Column($tasks.data.map(t => renderRow(t)), { gap: "s" })
126
+ error: ErrorState("Couldn't fetch tasks"),
127
+ empty: EmptyState("No tasks yet"),
128
+ data: Column($tasks.data.map(t => row(t)), { gap: "s" })
377
129
  })
378
- ], { gap: "l" })`,`// Multi-page app shell with router and sidebar
379
- pages = $router({
380
- "/": Overview(),
381
- "/projects": Projects(),
382
- "/calendar": Calendar(),
383
- default: NotFound()
384
- })
385
-
386
- nav = Sidebar([SidebarSection("Workspace", [
387
- SidebarItem("Overview", { icon: "house", to: "/" }),
388
- SidebarItem("Projects", { icon: "folder", to: "/projects" }),
389
- SidebarItem("Calendar", { icon: "calendar", to: "/calendar" })
390
- ])])
391
-
392
- ${V} = AppShell(nav, pages)
393
-
394
- function Overview() {
395
- return Column([
396
- PageHeader("Overview", { subtitle: "Everything across your workspace" }),
397
- Stats([
398
- StatCard("MRR", { value: "$48.2k", trend: "up", delta: "+12%", icon: "sack-dollar" }),
399
- StatCard("Active users", { value: "2,184", trend: "up", delta: "+184", icon: "users" }),
400
- StatCard("Open tickets", { value: "23", trend: "down", delta: "-9", icon: "ticket" })
401
- ])
402
- ], { gap: "l" })
403
- }
404
-
405
- function Projects() { return PageHeader("Projects") }
406
- function Calendar() { return PageHeader("Calendar") }
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
-
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
-
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
-
413
- ### Expressions
414
- - Strings \`"hello"\` / \`'hello'\`. Template literals: \`\` \`\${rows.length} results\` \`\` — preferred over \`+\` concatenation.
415
- - Numbers, booleans, \`null\`, arrays \`[1, 2, 3]\`, objects \`{ key: value }\`.
416
- - Operators: \`+ - * / %\`, \`== != > < >= <=\`, \`&& || !\`, ternary \`cond ? a : b\`, nullish \`a ?? b\`, spread \`[...a, ...b]\`, member access \`obj.field\`, optional chaining \`obj?.field\`.
417
-
418
- ### Component calls — two hard rules
419
- 1. **Any case works.** Component names may start with either an uppercase or lowercase letter — \`Card\`, \`card\`, \`Hero\`, \`hero\` are all valid declarations.
420
- 2. **Always invoke with parentheses.** A bare identifier (\`Hero\`) is a function reference; the rendered element is \`Hero()\`. Even with no arguments, write \`Hero()\`. In arrays: \`Column([Header(), Body(), Footer()])\`, never \`Column([Header, Body, Footer])\`.
421
-
422
- ### Trailing-object rule
423
- \`TypeName(positionalArg, { prop: value, ... })\`. The first argument is the canonical positional slot; every other argument lives in a trailing \`{ }\` object.
424
-
425
- \`\`\`
426
- Callout("info", { title: "Heads up", description: "Action required", icon: "circle-info", compact: true })
427
- Row([card1, card2], { gap: "m" })
428
- Badge("Live", { tone: "success", icon: "circle-dot" })
429
- \`\`\`
130
+ ], { gap: "l" }))`]}const zf=["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 Rf(t){return`${t?.trim()||"You respond in Aktion — a declarative language that is a strict subset of JavaScript. The host renders your reply as a rich, read-only UI. Output ONLY Aktion: no markdown, prose, or JSON."}
430
131
 
431
- ### Building UI from data — JS is fully supported
432
- - \`.map(...)\` / \`.filter().map()\` to render arrays into nodes (same as React).
433
- - Ternary for branching: \`tone = status == "ok" ? "success" : "warning"\`.
434
- - Array pluck: \`rows.title\` returns \`[row.title for each row]\` — feed columns (\`Col("Title", rows.title)\`) and chart series (\`PieChart(rows.label, rows.value)\`).
435
- - \`rows.length\`, \`rows.first\`, \`rows.last\` shortcuts.
436
-
437
- \`if\` / \`switch\` / \`for\` are statement-only — they cannot appear on the right-hand side of an assignment in chat mode.
438
-
439
- ### Streaming order
440
- Always declare \`${V}\` FIRST. Then container/composition statements. Then leaf data arrays last.
441
-
442
- \`\`\`
443
- ${V} = Column([heroCard, statsRow, table, follow])
444
-
445
- heroCard = Card([CardHeader("Q4 results", { subtitle: "Across all teams" })])
446
- statsRow = Stats(stats)
447
- table = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])
448
- follow = FollowUpBlock(["Break down by region", "Compare to Q3"])
449
-
450
- stats = [{ label: "MRR", value: "$48.2k", hint: "+12% vs Q3" }]
451
- rows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]
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
-
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
-
458
- Required statement order:
459
- 1. \`${V} = ...\` — emit FIRST so the shell appears immediately.
460
- 2. Container statements (\`heroCard\`, \`tableBlock\`, \`statsRow\`, ...).
461
- 3. Leaf data values (arrays, objects, strings) — last.
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 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
- ${V} = Column([title, tbl, totals, follow])
132
+ Register the UI root with \`$app(...)\` on the first line (typically \`$app(Column([...]))\`). This is read-only display mode — use only the layout, content, data, chart, and feedback components listed below. Do NOT emit state writes, actions, effects, HTTP, routing, form controls, or clickable buttons. The single exception is \`FollowUpBlock\`, which the host renders as suggested follow-up prompts.`}function Df(){return'## Syntax (read-only subset)\n\nA program is a flat list of `name = expression` statements in standard JavaScript. `$app(...)` registers the entry point (always first); every other binding hoists, so order is free — emit `$app(...)`, then containers, then leaf data last for a smooth streaming reveal.\n\n- Strings, numbers, booleans, `null`, arrays, objects; template literals `Found ${rows.length}` over `+` concatenation.\n- Operators `+ - * / %`, comparisons, `&& || !`, ternary `cond ? a : b`, nullish `a ?? b`, spread, member `obj.field`, optional chaining `obj?.field`.\n\n### Component calls\n- **Case doesn\'t matter** — `Card` and `card` are equivalent.\n- **Always invoke with parentheses** — `Column([Header(), Body()])`, never `Column([Header, Body])`; write `Hero()` even with no args.\n- **One positional arg, the rest in a trailing object** — `Callout("info", { title: "Heads up", icon: "circle-info" })`, `Badge("Live", { tone: "success" })`.\n\n### Build UI from data — JS is fully supported\n`.map` / `.filter` arrays into nodes (`rows.map(r => ListItem(r.title))`), ternaries for branching, and the array-pluck shortcut `rows.title` → `[each row.title]` to feed columns (`Col("Title", rows.title)`) and chart series (`PieChart(rows.label, rows.value)`). `if` / `for` are statements — not usable on the right of `=`.\n\n```\n$app(Column([title, table, follow]))\ntitle = Text("Q4 results", { variant: "large-heavy" })\ntable = Table([Col("Region", rows.region), Col("Revenue", rows.revenue, { format: "currency" })])\nfollow = FollowUpBlock(["Break down by region", "Compare to Q3"])\nrows = [{ region: "NA", revenue: 184000 }, { region: "EU", revenue: 122000 }]\n```'}function jf(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=>zf.includes(o));if(i.length!==0){a.push(`
133
+ ### ${n.name}`);for(const o of i){const s=r.get(o);s&&a.push(Jt(s))}}}return a.join(`
134
+ `)}function Bf(){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 _f(){return"## Hoisting & streaming (CRITICAL)\n\nReferences resolve from the whole scope, not source order — undefined refs render empty until they arrive, producing a smooth top-down reveal. Order: (1) `$app(...)` first; (2) container statements; (3) leaf data (arrays, objects, strings) last. Give each `Col` / `TabItem` / `Series` / `FollowUpItem` its own binding so it streams independently. Never split a statement across lines unless it sits inside an unmatched `[`, `(`, or `{`."}function Of(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(`
135
+ `)}function Ff(){return[`// Comparison table with a template-literal summary and follow-ups
136
+ $app(Column([title, tbl, totals, follow]))
466
137
  title = Text("Top languages by users", { variant: "large-heavy" })
467
138
  tbl = Table([
468
139
  Col("Language", langs.name),
469
140
  Col("Users (M)", langs.users, { format: "number" }),
470
141
  Col("First seen", langs.year, { format: "number" })
471
142
  ])
472
- totals = Callout("info", { title: \`Tracking \${langs.length} languages · \${$util.sum(langs.users)}M users combined\`, icon: "chart-line", compact: true })
143
+ totals = Callout("info", { title: \`Tracking \${langs.length} languages · \${$util.sum(langs.users)}M users\`, icon: "chart-line", compact: true })
473
144
  follow = FollowUpBlock(["Sort by users", "Show as a chart"])
474
145
 
475
146
  langs = [
476
147
  { name: "Python", users: 15.7, year: 1991 },
477
148
  { name: "JavaScript", users: 14.2, year: 1995 },
478
- { name: "TypeScript", users: 8.5, year: 2012 },
479
- { name: "Go", users: 5.2, year: 2009 }
480
- ]`,`// Article-style reply with Markdown body and KPI strip
481
- ${V} = Column([header, body, kpis])
482
- header = Hero("The fastest open-source UI runtime", { subtitle: "38,000 LLM responses per second.", eyebrow: "Engineering update" })
483
- body = Markdown(article)
484
- kpis = Stats([
485
- { label: "Open issues", value: "184", hint: "-23 vs last week" },
486
- { label: "PRs merged", value: "1,204", hint: "this quarter" },
487
- { label: "Avg latency", value: "84ms", hint: "p99" }
488
- ])
489
-
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
-
492
- Before finishing, walk your output and verify:
493
- 1. \`${V} = ...\` is the FIRST line.
494
- 2. Every referenced name is defined somewhere below.
495
- 3. Every defined name (other than \`${V}\`) is reachable from \`${V}\`.
496
- 4. Component name case is not significant, but every component reference is invoked with parentheses — \`Hero()\`, never bare \`Hero\`.
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
- 6. No statement is split across multiple lines unless it sits inside an unmatched \`[\`, \`(\`, or \`{\`.
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 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}
149
+ { name: "TypeScript", users: 8.5, year: 2012 }
150
+ ]`]}function Uf(){return"## Important rules\n\n- **Match the component to the content** — tables for comparisons, charts for trends, `Callout`/`Banner` for highlights, `Markdown` for paragraph prose, `Text` for short labels, `Hero`/`PageHeader` for titles, `Stats` for KPI strips.\n- **Lead with a clear title**, and use **realistic data** — believable names, numbers, dates; never Lorem Ipsum.\n- **Template literals** for any string mixing copy with values.\n- **End conversational replies with `FollowUpBlock([...])`** — 2–4 short next-prompt suggestions.\n- **Compose freely** — vary the structure and component mix to fit each request rather than reaching for the same template every time."}function Hf(){return'## Final verification\n\n1. `$app(...)` is first; every referenced name is defined below and reachable from the root.\n2. Every component is invoked with `()` — `Hero()`, never bare `Hero`.\n3. Only the read-only display components above — no forms, clickable buttons, state writes, actions, effects, HTTP, or routing.\n4. Tables are column-oriented (`Table([Col("Label", arr)])`, cells may be components via `rows.map(r => Badge(r.status))`); charts take numeric arrays (array-pluck `rows.value`).\n5. One positional arg per call, everything else in a trailing `{ }` object; no statement split across lines outside an unmatched bracket.'}function Jt(t){const e=cr(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 Kr(t,e){const r=[`## ${t}`];for(const a of e)r.push("```"),r.push(a.trim()),r.push("```");return r.join(`
151
+ `)}function Ii(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
152
+ `)}function Vf(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
153
  ${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"}},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=`
154
+ `)}const xe={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"}},Ei={...xe,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)"},Li={...xe,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"},zi={...xe,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"},Ri={...xe,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"},Di={...xe,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"},ji={...xe,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"},Gr={light:xe,dark:Ei,neon:Li,pastel:zi,glass:Ri,brutalist:Di,skyline:ji},Zt={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 Yr(t){if(!t)return{name:"light",tokens:xe};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:Fi(JSON.parse(t))}}catch{return{name:"light",tokens:xe}}const r=Gr[e];return r?{name:e,tokens:r}:{name:"light",tokens:xe}}return{name:"custom",tokens:Fi(t)}}function Xr(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[a,n]of Object.entries(Zt))t.style.setProperty(n,r.tokens[a]);t.setAttribute("data-rui-theme",r.name)}function Bi(t,e){const r=[];for(const a of Object.keys(e)){const n=Zt[a];if(!n)continue;const i=e[a];typeof i!="string"||i===""||(t.style.setProperty(n,i),r.push(a))}return r}function _i(t,e){for(const r of e){const a=Zt[r];a&&t.style.removeProperty(a)}}function Oi(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,a]of Object.entries(t))if(r in Zt&&a!=null)if(typeof a=="string"){if(a.trim()==="")continue;e[r]=a}else typeof a=="number"&&(e[r]=String(a));return e}function Fi(t){return{...xe,...t}}const Ui=`
505
155
  :host {
506
156
  display: block;
507
157
  box-sizing: border-box;
@@ -1386,10 +1036,8 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1386
1036
  .rui-button[data-variant="danger"] { background: var(--rui-color-danger); color: #fff; }
1387
1037
  .rui-button[data-variant="danger"]:hover:not(:disabled) { background: color-mix(in srgb, var(--rui-color-danger) 80%, black); }
1388
1038
  .rui-button[data-size="xs"] { padding: calc(var(--rui-button-padding-y) * 0.45) calc(var(--rui-button-padding-x) * 0.6); font-size: 11px; }
1389
- .rui-button[data-size="sm"],
1390
- .rui-button[data-size="small"] { padding: calc(var(--rui-button-padding-y) * 0.55) calc(var(--rui-button-padding-x) * 0.7); font-size: var(--rui-font-size-sm); }
1391
- .rui-button[data-size="lg"],
1392
- .rui-button[data-size="large"] { padding: calc(var(--rui-button-padding-y) * 1.4) calc(var(--rui-button-padding-x) * 1.3); font-size: var(--rui-font-size-lg); }
1039
+ .rui-button[data-size="sm"] { padding: calc(var(--rui-button-padding-y) * 0.55) calc(var(--rui-button-padding-x) * 0.7); font-size: var(--rui-font-size-sm); }
1040
+ .rui-button[data-size="lg"] { padding: calc(var(--rui-button-padding-y) * 1.4) calc(var(--rui-button-padding-x) * 1.3); font-size: var(--rui-font-size-lg); }
1393
1041
  .rui-button[data-size="xl"] { padding: calc(var(--rui-button-padding-y) * 1.6) calc(var(--rui-button-padding-x) * 1.5); font-size: var(--rui-font-size-lg); }
1394
1042
  .rui-button[data-full-width="true"] { width: 100%; }
1395
1043
  .rui-button[data-icon-only="true"] .rui-button-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@@ -1889,6 +1537,7 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
1889
1537
  color-mix(in srgb, var(--rui-color-primary) 30%, var(--rui-color-surface-muted)));
1890
1538
  color: color-mix(in srgb, var(--rui-color-primary) 90%, var(--rui-color-text));
1891
1539
  }
1540
+ .rui-avatar[data-size="xs"] { width: 18px; height: 18px; font-size: 8px; max-width: 18px; max-height: 18px; }
1892
1541
  .rui-avatar[data-size="sm"] { width: 24px; height: 24px; font-size: 10px; max-width: 24px; max-height: 24px; }
1893
1542
  .rui-avatar[data-size="md"] { width: 36px; height: 36px; font-size: 13px; max-width: 36px; max-height: 36px; }
1894
1543
  .rui-avatar[data-size="lg"] { width: 52px; height: 52px; font-size: 18px; max-width: 52px; max-height: 52px; }
@@ -8383,7 +8032,7 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
8383
8032
  }
8384
8033
  .rui-lightbox-thumb img { display: block; width: 100%; height: auto; }
8385
8034
  .rui-lightbox-thumb:hover { border-color: var(--rui-color-primary); }
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([
8035
+ `,Jr="theme",vt="streaming",Zr="response",nt="showerrors",Hi="route";function Wf(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,c]of o)n[s]=c}}return{path:e,params:r,pattern:a,query:n,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function qf(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:Vi(r.params??{},a.params??{})&&Vi(r.query??{},a.query??{})}function Vi(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 Qr=null,Qt=null,Kf=0;function Gf(){if(Qt===!1)return null;if(Qr)return Qr;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Qt=!1,null;const t=new CSSStyleSheet;return t.replaceSync(Ui),Qr=t,Qt=!0,t}catch{return Qt=!1,null}}class yt extends HTMLElement{constructor(){super();D(this,"state",new Ha);D(this,"router",new Za);D(this,"library",bt);D(this,"http",new qa);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,"pendingCompiled",null);D(this,"compiledSourceId",null);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,"devtoolsId",`aktion-app-${Kf+=1}`);D(this,"devtoolsCommitId",0);D(this,"devtoolsRegistered",!1);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=Gf();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),onEffectEvent:n=>this.emitDevtoolsEffect(n)}),this.actionDeclRunner=new Ln({state:this.state,notify:()=>this.requestFullRender(),onEmit:(n,i)=>this.emitCustomEvent(n,i),onAssistantMessage:a}),this.context=vr(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 Ti({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=>An(this.context,n)}),this.state.subscribe(n=>{for(const i of n)this.pendingChangedPaths.add(i);Ar()&&Tr({kind:"state",appId:this.devtoolsId,snapshot:this.state.snapshot(),changedPaths:[...n],time:pe()}),(this.lastRenderDeps===null||st(n,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(n=>this.handleRouteChange(n))}static get observedAttributes(){return[Jr,vt,Zr,nt]}connectedCallback(){Al(this.root),this.registerWithDevtools(),this.applyThemeFromAttribute(),this.startRouter();const r=this.getAttribute(Zr);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&&yr(this.context),this.router.stop(),this.devtoolsRegistered&&(gl(this.devtoolsId),this.devtoolsRegistered=!1)}attributeChangedCallback(r,a,n){if(r===Jr&&this.applyThemeFromAttribute(),r===vt&&(this.updateErrorBanner(),this.scheduleRender()),r===nt&&this.updateErrorBanner(),r===Zr){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=Uo(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(!Ma(r)){console.error("[aktion] mountCompiled() expected a CompiledProgram (from linkProject() or compileLite()); 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){Xr(this,Yr(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,a){this.library=za(this.library,{components:r,root:a}),this.renderer.setLibrary(this.library),this.scheduleRender()}getSystemPrompt(r){return qr(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 Wi(this.getAttribute(vt))}set streaming(r){r?this.setAttribute(vt,"true"):this.removeAttribute(vt)}get showErrors(){return Wi(this.getAttribute(nt))}set showErrors(r){r?this.setAttribute(nt,"true"):this.removeAttribute(nt)}emitCustomEvent(r,a){this.dispatchEvent(new CustomEvent(r,{detail:a,bubbles:!0,composed:!0}))}registerWithDevtools(){if(this.devtoolsRegistered)return;const r=Rt();if(!r)return;const a={id:this.devtoolsId,label:this.getAttribute("data-devtools-label")||this.id||this.devtoolsId,element:this,getState:()=>this.state.snapshot(),setState:(n,i)=>this.applyDevtoolsStateEdit(n,i),getProgram:()=>this.currentResponse,forceRender:()=>this.requestFullRender()};r.registerApp(a),this.devtoolsRegistered=!0}connectDevtools(){this.registerWithDevtools(),this.devtoolsRegistered&&this.requestFullRender()}applyDevtoolsStateEdit(r,a){const n=r.indexOf(".");if(n<0){this.state.set(r,a);return}const i=r.slice(0,n),o=r.slice(n+1).split(".");this.state.setPath(i,o,a)}emitDevtoolsEffect(r){Tr({kind:"effect",appId:this.devtoolsId,time:pe(),...r})}buildInlineStyle(){const r=document.createElement("style");return r.textContent=Ui,r}startRouter(){this.router.start(),this.writeRouteState()}writeRouteState(){const r=Wf(this.router);qf(this.state.get(Hi),r)||this.state.set(Hi,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender()}applyThemeFromAttribute(){const r=this.getAttribute(Jr);Xr(this,Yr(r)),this.scriptThemeKeys=[]}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(_i(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let a;try{a=r()}catch{return}if(!Oa(a))return;const n=Oi(a.tokens);Object.keys(n).length!==0&&(this.scriptThemeKeys=Bi(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&&gr(this.context.budget),this.devtoolsRegistered||this.registerWithDevtools();const r=Ar();this.renderer.setProfiling(r);const a=r?pe():0,n=new Set,i=this.context.trackedState;this.context.trackedState=n;let o=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),cn(this.context);const s=this.context.bindings.get("aktion");let c=null;if(s)try{c=s()}catch(g){if(g instanceof ze){this.handleRuntimeBudgetError(g);return}console.error("[aktion] entry point evaluation error",g)}const u=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const p=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:u,memoize:p});const d=this.captureFocus();let f;try{f=this.renderer.render(c)}catch(g){if(this.renderer.endRender(),g instanceof ze){this.handleRuntimeBudgetError(g);return}throw g}if(nf(this.rootEl,f),this.renderer.endRender(),this.restoreFocus(d),o=!0,r){const g=this.renderer.drainProfilerRecords();let b=0,h=0;for(const v of g)v.phase==="memo"?h+=1:b+=1;Tr({kind:"commit",appId:this.devtoolsId,commitId:this.devtoolsCommitId,startTime:a,duration:pe()-a,changedPaths:[...u],fullRender:!p,initial:this.devtoolsCommitId===0,components:g,rendered:b,memoized:h}),this.devtoolsCommitId+=1}}finally{this.context.trackedState=i,this.lastRenderDeps=o?n: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 (`$app(page())`), 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(`#${Yf(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&&Jf(a,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&yr(this.context),this.context=vr(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??ge(this.currentResponse);this.pendingCompiled=null;const a=ur(r,this.library);a.length>0&&(r.errors=[...r.errors,...a]),this.context.budget&&gr(this.context.budget);try{un(r,this.context)}catch(i){if(i instanceof ze)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(yt,"tagName","aktion-app");function Yf(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const Xf=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function Jf(t,e,r,a){if(t instanceof HTMLInputElement&&Xf.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 Wi(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===nt}function qi(){customElements.get(yt.tagName)||customElements.define(yt.tagName,yt)}const Zf=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},Qf=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},eg=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 Ki(t=bt){const e=eg(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(Zf),signature:Qf(r)}))}function Gi(t){const e={};for(const r of t)e[r.name]=r;return e}const tg=[{name:"App",description:"Top-level `$app(...)` root — every program needs one.",template:'$app(Column([\n ${1:Card([CardHeader("${2:Hello}")])}\n]))'},{name:"Card",description:"Card with header + body block.",template:`card\${1} = Card([
8387
8036
  CardHeader("\${2:Title}", { subtitle: "\${3:Subtitle}" }),
8388
8037
  Column([
8389
8038
  Text("\${4:Body copy goes here.}")
@@ -8392,7 +8041,7 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
8392
8041
  Text("\${2:Section title}", { variant: "large-heavy" }),
8393
8042
  Spacer(),
8394
8043
  Button("\${3:Action}", { variant: "primary" })
8395
- ], { gap: "m" })`},{name:"Center",description:"Center content on both axes inside a tall region.",template:'empty${1} = Center([\n EmptyState("${2:Nothing here yet}", { description: "${3:Create your first item to get started.}" })\n], { minHeight: "${4:50vh}" })'},{name:"Hero",description:"Landing-page hero with eyebrow, title, subtitle, and a CTA.",template:'function ${4:start}() { route.navigate("/start") }\nfunction ${5:openDemo}() { route.navigate("/demo") }\nhero${1} = Hero(\n "${2:Ship faster}",\n { subtitle: "${3:From idea to production in minutes.}",\n primary: Button("${6:Get started}", { action: ${4:start}, variant: "primary" }),\n secondary: Button("${7:Live demo}", { action: ${5:openDemo}, variant: "ghost" }),\n eyebrow: "${8:v2 launch}" }\n)'},{name:"PageHeader",description:"Dashboard page header with breadcrumbs and actions.",template:'function ${6:runAction}() { /* TODO: implement */ }\nheader${1} = PageHeader(\n "${2:Page title}",\n { subtitle: "${3:Subtitle / meta line}",\n breadcrumbs: ["${4:Workspace}", "${5:Section}"],\n actions: [Button("${7:Action}", { action: ${6:runAction}, variant: "primary" })],\n status: Badge("${8:On track}", { variant: "success" }) }\n)'},{name:"Stats",description:"Responsive KPI strip with four StatCards.",template:'metrics${1} = Stats([\n StatCard("${2:Active}", { value: "${3:12}", trend: "flat" }),\n StatCard("${4:At risk}", { value: "${5:4}", trend: "up", delta: "+2" }),\n StatCard("${6:Shipped}", { value: "${7:8}", trend: "up", delta: "+3" }),\n StatCard("${8:On-time}", { value: "${9:87%}", trend: "down", delta: "-3%" })\n])'},{name:"GridLayout",description:"12-column sidebar layout with named GridItem spans.",template:'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\naktion = Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "l" })'},{name:"KanbanBoard",description:"Three-column kanban board with sample cards.",template:'board${1} = KanbanBoard([\n KanbanColumn("To do", { items: [\n KanbanCard("${2:Migrate auth}", { description: "${3:Roll out the new SDK.}", tags: ["auth"], assignee: "${4:Asha}" })\n ] }),\n KanbanColumn("Doing", { items: [\n KanbanCard("${5:Streaming UI v2}", { description: "${6:Ship 20 new components.}", tags: ["frontend"], assignee: "${7:Alex}", tone: "primary" })\n ] }),\n KanbanColumn("Done", { items: [\n KanbanCard("${8:Activity timeline}", { description: "${9:Shipped to 100%.}", tags: ["shipped"], assignee: "${10:Mira}", tone: "success" })\n ] })\n])'},{name:"FollowUpBlock",description:"Chat follow-up prompts.",template:'follow${1} = FollowUpBlock([\n FollowUpItem("${2:Show me a chart}"),\n FollowUpItem("${3:Add a filter}"),\n FollowUpItem("${4:Export as CSV}")\n])'},{name:"Router",description:"Multi-page router via $router({…}) with NavLink sidebar.",template:`pages = $router({
8044
+ ], { gap: "m" })`},{name:"Center",description:"Center content on both axes inside a tall region.",template:'empty${1} = Center([\n EmptyState("${2:Nothing here yet}", { description: "${3:Create your first item to get started.}" })\n], { minHeight: "${4:50vh}" })'},{name:"Hero",description:"Landing-page hero with eyebrow, title, subtitle, and a CTA.",template:'function ${4:start}() { route.navigate("/start") }\nfunction ${5:openDemo}() { route.navigate("/demo") }\nhero${1} = Hero(\n "${2:Ship faster}",\n { subtitle: "${3:From idea to production in minutes.}",\n primary: Button("${6:Get started}", { action: ${4:start}, variant: "primary" }),\n secondary: Button("${7:Live demo}", { action: ${5:openDemo}, variant: "ghost" }),\n eyebrow: "${8:v2 launch}" }\n)'},{name:"PageHeader",description:"Dashboard page header with breadcrumbs and actions.",template:'function ${6:runAction}() { /* TODO: implement */ }\nheader${1} = PageHeader(\n "${2:Page title}",\n { subtitle: "${3:Subtitle / meta line}",\n breadcrumbs: ["${4:Workspace}", "${5:Section}"],\n actions: [Button("${7:Action}", { action: ${6:runAction}, variant: "primary" })],\n status: Badge("${8:On track}", { variant: "success" }) }\n)'},{name:"Stats",description:"Responsive KPI strip with four StatCards.",template:'metrics${1} = Stats([\n StatCard("${2:Active}", { value: "${3:12}", trend: "flat" }),\n StatCard("${4:At risk}", { value: "${5:4}", trend: "up", delta: "+2" }),\n StatCard("${6:Shipped}", { value: "${7:8}", trend: "up", delta: "+3" }),\n StatCard("${8:On-time}", { value: "${9:87%}", trend: "down", delta: "-3%" })\n])'},{name:"GridLayout",description:"12-column sidebar layout with named GridItem spans.",template:'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\n$app(Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "l" }))'},{name:"KanbanBoard",description:"Three-column kanban board with sample cards.",template:'board${1} = KanbanBoard([\n KanbanColumn("To do", { items: [\n KanbanCard("${2:Migrate auth}", { description: "${3:Roll out the new SDK.}", tags: ["auth"], assignee: "${4:Asha}" })\n ] }),\n KanbanColumn("Doing", { items: [\n KanbanCard("${5:Streaming UI v2}", { description: "${6:Ship 20 new components.}", tags: ["frontend"], assignee: "${7:Alex}", tone: "primary" })\n ] }),\n KanbanColumn("Done", { items: [\n KanbanCard("${8:Activity timeline}", { description: "${9:Shipped to 100%.}", tags: ["shipped"], assignee: "${10:Mira}", tone: "success" })\n ] })\n])'},{name:"FollowUpBlock",description:"Chat follow-up prompts.",template:'follow${1} = FollowUpBlock([\n FollowUpItem("${2:Show me a chart}"),\n FollowUpItem("${3:Add a filter}"),\n FollowUpItem("${4:Export as CSV}")\n])'},{name:"Router",description:"Multi-page router via $router({…}) with NavLink sidebar.",template:`pages = $router({
8396
8045
  "/": HomePage(),
8397
8046
  "/dashboard": DashboardPage(),
8398
8047
  "/users/:id": UserPage(params.id),
@@ -8449,7 +8098,7 @@ function add() {
8449
8098
  form\${1} = Column([
8450
8099
  Input("\${2:draft}", { placeholder: "What needs doing?", type: "text", value: $draft }),
8451
8100
  Button("Add", { action: add, variant: "primary" })
8452
- ])`},{name:"Theme",description:"Brand-style theme override applied on top of the base theme.",template:`theme = $theme({
8101
+ ])`},{name:"Theme",description:"Brand-style theme override applied on top of the base theme.",template:`$theme({
8453
8102
  name: "\${1:brand}",
8454
8103
  colors: {
8455
8104
  primary: "\${2:#0969da}",
@@ -8458,10 +8107,7 @@ form\${1} = Column([
8458
8107
  text: "\${5:#1f2328}"
8459
8108
  },
8460
8109
  radius: { button: "\${6:6px}", input: "\${7:6px}" },
8461
- font: {
8462
- family: "\${8:-apple-system, BlinkMacSystemFont, sans-serif}",
8463
- heading: "\${9:-apple-system, BlinkMacSystemFont, sans-serif}"
8464
- }
8110
+ font: { family: "\${8:-apple-system, BlinkMacSystemFont, sans-serif}" }
8465
8111
  })`},{name:"Component",description:"Reusable component declaration — first-letter case is not significant; a function with no `return` simply renders nothing.",template:`function \${1:UserCard}(\${2:user}) {
8466
8112
  return Card([
8467
8113
  Avatar(\${2:user}.name),
@@ -8477,5 +8123,5 @@ list = $users.map(u => \${1:UserCard}(u))`},{name:"Ternary",description:"Pick be
8477
8123
  url: "\${2:https://api.example.com/items}",
8478
8124
  method: "\${3:GET}",
8479
8125
  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 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"})});
8126
+ })`},{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 Yi(){return tg}function rg(t=bt){const e=Ki(t);return{grammar:Ct,tokenizer:Ba(Ct),tagMap:_a,components:e,componentsByName:Gi(e),snippets:Yi(),keywordDocs:ja,themeNames:Object.keys(Gr),severityTokenMap:{"parse-error":"error"},iconAliases:ag}}const ag=["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"];function Xi(t,e,r){const a=new Map,n=[],i=new Set,o=[];let s=0;const c=(f,g,b,h)=>{o.push({line:g,column:b,message:f===e?h:`${f}: ${h}`,severity:"error"})};function u(f,g){const b=a.get(f);if(b)return b;if(i.has(f))return;i.add(f);let h;if(g!==null)h=g;else try{h=r.load(f)}catch{i.delete(f),c(e,0,0,`Failed to load imported module "${f}".`);return}const v=ge(h),y={id:s++,path:f,program:v,edges:[],declaredPlain:new Set,declaredState:new Set,exportedPlain:new Set,exportedState:new Set,renamePlain:new Map,renameState:new Map};a.set(f,y),ng(y);for(const x of v.statements){if(x.kind!=="Import")continue;const w=r.resolve(x.source,f);if(y.edges.push({stmt:x,resolvedPath:w}),w===null){c(f,x.loc?.line??0,x.loc?.column??0,`Cannot resolve import "${x.source}".`);continue}u(w,null)}return i.delete(f),n.push(f),y}u(e,t);for(const f of a.values())if(f.path!==e){for(const g of f.declaredPlain)f.renamePlain.set(g,`__a${f.id}_${g}`);for(const g of f.declaredState)f.renameState.set(g,`__a${f.id}_${g}`)}for(const f of a.values())for(const{stmt:g,resolvedPath:b}of f.edges){if(b===null)continue;const h=a.get(b);if(h)for(const v of g.specifiers){const y=g.loc?.line??0,x=g.loc?.column??0;if(v.isState){if(!h.exportedState.has(v.imported)){c(f.path,y,x,`"${g.source}" does not export \`$${v.imported}\`.`);continue}f.renameState.set(v.local,h.renameState.get(v.imported)??`__a${h.id}_${v.imported}`)}else{if(!h.exportedPlain.has(v.imported)){c(f.path,y,x,`"${g.source}" does not export \`${v.imported}\`.`);continue}f.renamePlain.set(v.local,h.renamePlain.get(v.imported)??`__a${h.id}_${v.imported}`)}}}const p=[];for(const f of n){const g=a.get(f),b=og(g);for(const h of g.program.statements)h.kind!=="Import"&&(b.renameTopLevel(h),ig(h),h.kind==="EffectDeclaration"&&g.path!==e&&(h.name=`__effect_a${g.id}_${h.name.replace(/^__effect_/,"")}`),p.push(h))}const d=a.get(e);return{program:{statements:p,errors:d?d.program.errors:[]},diagnostics:o,dependencies:n.filter(f=>f!==e)}}function ng(t){for(const e of t.program.statements)switch(e.kind){case"Assignment":e.isState?(t.declaredState.add(e.identifier),e.exported&&t.exportedState.add(e.identifier)):(t.declaredPlain.add(e.identifier),e.exported&&t.exportedPlain.add(e.identifier));break;case"ComponentDeclaration":case"ActionDeclaration":t.declaredPlain.add(e.name),e.exported&&t.exportedPlain.add(e.name);break;case"HookDeclaration":t.declaredState.add(e.name),e.exported&&t.exportedState.add(e.name);break;case"DestructureStatement":for(const r of e.bindings)r.name&&t.declaredPlain.add(r.name);break}}function ig(t){(t.kind==="Assignment"||t.kind==="ComponentDeclaration"||t.kind==="ActionDeclaration"||t.kind==="HookDeclaration")&&delete t.exported}function og(t){const e=[],r=h=>{for(const v of e)if(v.has(h))return!0;return!1},a=h=>r(h)?h:t.renamePlain.get(h)??h,n=h=>t.renameState.get(h)??h,i=h=>{e.push(new Set(h))},o=()=>{e.pop()},s=h=>h.bindings.map(v=>v.name).filter(v=>!!v),c=h=>{const v=[];for(const y of h)y.name&&v.push(y.name),y.pattern&&v.push(...s(y.pattern));return v},u=h=>{for(const v of h)v.defaultValue&&p(v.defaultValue)};function p(h){switch(h.kind){case"Literal":return;case"Identifier":h.name=a(h.name);return;case"StateRef":h.name=n(h.name);return;case"Array":for(const v of h.elements)p(v);return;case"Object":for(const v of h.properties)v.computedKey&&p(v.computedKey),p(v.value);return;case"Member":p(h.object),h.computed&&p(h.computed);return;case"Unary":p(h.argument);return;case"Binary":p(h.left),p(h.right);return;case"Ternary":p(h.test),p(h.consequent),p(h.alternate);return;case"Call":h.callee=a(h.callee);for(const v of h.arguments)p(v);return;case"MethodCall":p(h.object);for(const v of h.arguments)p(v);return;case"Invoke":p(h.callee);for(const v of h.arguments)p(v);return;case"BuiltinCall":for(const v of h.arguments)p(v);return;case"New":p(h.callee);for(const v of h.arguments)p(v);return;case"Template":for(const v of h.expressions)p(v);return;case"Spread":p(h.argument);return;case"Lambda":i(c(h.params)),u(h.params),p(h.body),o();return;case"Block":d(h);return}}function d(h){i([]);const v=e[e.length-1];for(const y of h.body)b(y,!1),f(y,v);o()}function f(h,v){if(h.kind==="DestructureStatement")for(const y of h.bindings)y.name&&v.add(y.name);else(h.kind==="ComponentDeclaration"||h.kind==="ActionDeclaration")&&v.add(h.name)}function g(h){if(h.kind==="DestructureStatement"){p(h.expression);for(const v of h.bindings)v.defaultValue&&p(v.defaultValue),v.name=a(v.name);return}b(h,!0)}function b(h,v){switch(h.kind){case"Import":return;case"Assignment":h.identifier=h.isState?n(h.identifier):a(h.identifier),p(h.expression);return;case"ComponentDeclaration":case"ActionDeclaration":h.name=a(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"HookDeclaration":h.name=n(h.name),i(c(h.params)),u(h.params),d(h.body),o();return;case"EffectDeclaration":for(const y of h.triggers)y.kind==="state"&&(y.name=n(y.name));d(h.body);return;case"Await":p(h.argument);return;case"Return":h.argument&&p(h.argument);return;case"ExpressionStatement":p(h.expression);return;case"IfStatement":p(h.test),d(h.consequent),h.alternate&&(h.alternate.kind==="IfStatement"?b(h.alternate,!1):d(h.alternate));return;case"SwitchStatement":p(h.discriminant);for(const y of h.cases){y.test&&p(y.test);for(const x of y.body)b(x,!1)}return;case"ForOfStatement":{p(h.iterable);const y=[h.item];h.index&&y.push(h.index),h.destructure&&y.push(...h.destructure),i(y),d(h.body),o();return}case"ForInStatement":p(h.iterable),i([h.item]),d(h.body),o();return;case"ForClassicStatement":{const y=[];h.init&&h.init.kind==="Assignment"&&h.init.identifier&&y.push(h.init.identifier),i(y),h.init&&b(h.init,!1),h.test&&p(h.test),h.update&&p(h.update),d(h.body),o();return}case"WhileStatement":case"DoWhileStatement":p(h.test),d(h.body);return;case"DestructureStatement":p(h.expression);for(const y of h.bindings)y.defaultValue&&p(y.defaultValue);if(v)for(const y of h.bindings)y.name=a(y.name);return;case"ThrowStatement":p(h.argument);return;case"TryStatement":d(h.block),h.catchBlock&&(i(h.catchParam?[h.catchParam]:[]),d(h.catchBlock),o()),h.finallyBlock&&d(h.finallyBlock);return;case"BreakStatement":case"ContinueStatement":return}}return{renameTopLevel:g}}function ea(t){return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)}function Ji(t){const e=[];for(const r of t)r===""||r==="."||(r===".."?e.pop():e.push(r));return e.join("/")}function sg(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function ta(t,e){if(ea(t))try{return new URL(t).href}catch{return null}if(ea(e))try{return new URL(t,e).href}catch{return null}return t.startsWith("/")?Ji(t.split("/")):t.startsWith("./")||t.startsWith("../")?Ji(`${sg(e)}/${t}`.split("/")):null}function Zi(t){return{resolve:(e,r)=>ta(e,r),load:e=>{const r=t[e];if(r===void 0)throw new Error(`not found: ${e}`);return r}}}async function lg(t){if(typeof fetch!="function")throw new Error("global fetch is unavailable; cannot load URL imports");const e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.text()}async function cg(t){const{entry:e,files:r}=t,a=t.fetch??lg,n=[],i={...r},o=new Set;async function s(p){if(o.has(p))return;if(o.add(p),i[p]===void 0)if(ea(p))try{i[p]=await a(p)}catch(g){n.push({line:0,column:0,message:`Failed to fetch module "${p}": ${g.message??g}`,severity:"error"});return}else return;let d;try{d=ge(i[p])}catch{return}const f=[];for(const g of d.statements){if(g.kind!=="Import")continue;const b=ta(g.source,p);b!==null&&f.push(s(b))}await Promise.all(f)}if(i[e]===void 0)return{program:{statements:[],errors:[]},source:"",diagnostics:[{line:0,column:0,message:`Entry module "${e}" was not found.`,severity:"error"}],dependencies:[]};await s(e);const c=Xi(i[e],e,Zi(i));let u;try{u=Ro(c.program)}catch{u=i[e]}return{program:c.program,source:u,diagnostics:[...n,...c.diagnostics],dependencies:c.dependencies}}qi();const ug=qr(bt);P.ActionDeclRunner=Ln,P.AktionElement=yt,P.BreakSignal=Ce,P.COMPILED_PROGRAM_VERSION=nr,P.ContinueSignal=Ne,P.DEFAULT_RUNTIME_BUDGET=Tt,P.EffectRunner=Pn,P.HttpRuntime=qa,P.Renderer=Ti,P.ReturnSignal=Re,P.Router=Za,P.RuntimeBudgetError=ze,P.SYSTEM_PROMPT_TEXT=ug,P.StateStore=Ha,P.anyPathAffects=dr,P.applyPartialTheme=Bi,P.applyTheme=Xr,P.assertOnePositionalMax=Ra,P.brutalistTheme=Di,P.buildFrontier=Ta,P.builtInThemes=Gr,P.clearInstanceHooks=An,P.clearTokenOverrides=_i,P.compileLite=Lo,P.computeFrontier=Mo,P.consoleNs=an,P.createContext=vr,P.createHttpResource=Ka,P.createI18n=Ga,P.createMemoryResolver=Zi,P.createRuntimeBudget=on,P.createStreamTokenizer=Ba,P.darkTheme=Ei,P.defaultLibrary=bt,P.defaultTagMap=_a,P.defineCompiledProgram=Eo,P.defineElement=qi,P.describeComponentSpec=pf,P.disposeContext=yr,P.enterUserComponent=hr,P.evaluate=N,P.evaluateUserComponent=xn,P.extractStatePath=Mt,P.findComponent=Ee,P.findPositionalIndex=lr,P.findPositionalProp=cr,P.generatePrompt=qr,P.getComponentCatalog=Ki,P.getLanguageSpec=rg,P.getSnippets=Yi,P.glassTheme=Ri,P.grammarSpec=Ct,P.indexCatalog=Gi,P.isCompiledProgram=Ma,P.isComponentNode=sn,P.isEndpointResource=Wa,P.isQuiescent=Po,P.isStoreHandle=Nt,P.isThemeNode=Oa,P.isUserComponentNode=ln,P.joinStatePath=Fa,P.keywordDocs=ja,P.leaveUserComponent=br,P.lightTheme=xe,P.linkProgram=Xi,P.linkProject=cg,P.mapPositionalArgs=Da,P.matchRoute=Ja,P.mergeLibraries=za,P.neonTheme=Li,P.normalisePath=Fe,P.parse=ge,P.pastelTheme=zi,P.pathAffects=Ua,P.pathsOverlap=st,P.planProgram=un,P.resetMutableBindings=cn,P.resetRuntimeBudget=gr,P.resolvePatternBindings=pt,P.resolveSpecifier=ta,P.resolveStateAlias=Se,P.resolveTheme=Yr,P.runControlFlowStatement=Lt,P.sanitiseThemeTokens=Oi,P.skylineTheme=ji,P.storage=mr,P.tokenize=na,P.validateProgram=qo,P.validateProgramSchema=ur,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
8481
8127
  //# sourceMappingURL=aktion.umd.cjs.map